RobLoach / node-raylib

Node.js bindings for Raylib
https://robloach.github.io/node-raylib/
Other
233 stars 20 forks source link

Add raymath and raygui support through the new Parser #148

Closed RobLoach closed 1 year ago

RobLoach commented 2 years ago

Given that the parser has changed, and it's difficult for us to target different versions of the API vs parser version, it may be worth it to manage it ourselves. The provided raylib_api.json was built using the latest Parser Generator from master, with the 4.0.0 raylib.h.

DO NOT MERGE YET! It's not compiling with this yet. We'll need to wrap...

Fixes #145

RobLoach commented 1 year ago

[ 96%] Building CXX object CMakeFiles/node-raylib.dir/src/generated/node-raylib.cc.o /Users/runner/work/node-raylib/node-raylib/src/generated/node-raylib.cc:268:6: error: non-constant-expression cannot be narrowed from type 'uintptr_t' (aka 'unsigned long') to 'char' in initializer list [-Wc++11-narrowing] pointerFromValue(info, index + 0), ^~~~~~~~~ /Users/runner/work/node-raylib/node-raylib/src/generated/node-raylib.cc:268:6: note: insert an explicit cast to silence this issue pointerFromValue(info, index + 0), ^~~~~~~~~ static_cast( ) 1 error generated. make[2]: [CMakeFiles/node-raylib.dir/src/generated/node-raylib.cc.o] Error 1 make[1]: [CMakeFiles/node-raylib.dir/all] Error 2 make: *** [all] Error 2 info REP Build has been failed, trying to do a full rebuild.

konsumer commented 1 year ago

I'm not sure I totally follow what changes are being made and what is failing, but I'd like to help. Is the issue that the generated code uses uintptr_t which is 64bit, but char is 8 bits? Is this what is intended? If this is what we intend, can we just do a cast there?

konsumer commented 1 year ago

I got it to build by hand-editing this:

inline BoneInfo BoneInfoFromValue(const Napi::CallbackInfo& info, int index) {
  return {
     (char) pointerFromValue(info, index + 0),
     charFromValue(info, index + 1)
  };
}

instead of

inline BoneInfo BoneInfoFromValue(const Napi::CallbackInfo& info, int index) {
  return {
     pointerFromValue(info, index + 0),
     charFromValue(info, index + 1)
  };
}

Not sure if that will actually work right, but might lead to a solution.

konsumer commented 1 year ago

I added a small change that gets it building in a542777 but I'm really not sure if that is the right way to go. Seems like it probly isn't dealing with arrays right, but I'm not sure how to test it.