digego / extempore

A cyber-physical programming environment
1.41k stars 127 forks source link

Fix type error of nanovg wrapper #352

Closed cyblue9 closed 5 years ago

cyblue9 commented 5 years ago

There are some type error of functions return value and arguments.

Example: nanovg

void nvgStrokeColor(NVGcontext* ctx, NVGcolor color);

[Before fixed]

(bind-lib libnanovg nvgStrokeColor [void,NVGcontext*,NVGcolor*]*)

[After fixed]

(bind-lib libnanovg nvgStrokeColor [void,NVGcontext*,NVGcolor]*)

The second argument is NVGcolor type(not pointer).

Please review!

benswift commented 5 years ago

actually, sorry - I've just reverted this for now.

The bindings are actually to the extemporelang fork of nanovg. In particular, because xtlang code isn't ABI-compatible with C code, passing structs on the stack (e.g. NVGcolors) is problematic. I used to have a bunch of "wrapper" code to make it all pass-by-reference (and we just deal with the memory allocation thing).

So, in those cases they aren't actually typos - they're deliberate.

Having said that... it's a while since I touched that stuff, and I really should see if it's still all working fine. It's on my to-do list, but I'll just revert the pull request for now, and re-apply the changes later if they make sense. Sorry about the confusion.

cyblue9 commented 5 years ago

No problem.

The bindings are actually to the extemporelang fork of nanovg. In particular, because xtlang code isn't ABI-compatible with C code, passing structs on the stack (e.g. NVGcolors) is problematic. I used to have a bunch of "wrapper" code to make it all pass-by-reference (and we just deal with the memory allocation thing).

Oh, I see !


I wanted to draw some graphs with /lib/external/nanovg.xtm. But, it didn't work. As a result of thinking a lot, I thought that it was a bug, I sent a pull request.

But, I checked my code again. I found a mistake in my code. Therefore, this pull request is incorrect. Sorry. Really Sorry.

To avoid making the same mistake again, I need to write the xtlang/nanovg wrapper library as soon as possible.

benswift commented 5 years ago

It's all good 🙂