Skip to content

Conversation

@RobLoach
Copy link
Owner

@RobLoach RobLoach commented May 12, 2022

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...

  • float[4]
  • char[32]
  • Matrix[2]
  • float[2]
  • float[16]
  • Aliases

Fixes #145

@RobLoach RobLoach added the Hold label May 12, 2022
@RobLoach RobLoach mentioned this pull request May 12, 2022
Comment on lines 31 to 40
// @todo Verify Structs that have array properties
'VrStereoConfig', // Matrix[2], float[2]
'BoneInfo', // char[32]
'VrDeviceInfo', // float[4]
'Material', // float[4]

// raymath
// @todo Fix helper structs for float arrays
'Vector3ToFloatV', // float3
'MatrixToFloatV' // float16
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fix porting the array types.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I tried to do some work on this front - but ended up throwing out the changes. my understanding of types there was a little wrong. looking at the structs in question - i don't see a need to implicitly cast to/from a JS array anywhere for these unless a user really wanted to manipulate this data manually. I think we can get by with simply casting the pointers for these types into uint64_t, and then (float[]) or what the proper syntax might be on the way into C++.
for Matrix/Vector3V - can these just be implemented in JS? or does raylib do anything extra under the hood when making these?

Copy link
Owner Author

@RobLoach RobLoach May 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe be difficult to handle directly through the generator. We could likely put together wrapper functions for them though. Similar to the Shader ones you did.

Arrays can be passed by value as arrays in C++, but returned as pointers. Certainly not the best.

Copy link
Collaborator

@konsumer konsumer Jun 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we do it in js wrapper-space? Like how ref-array-napi does it?

@RobLoach RobLoach changed the title Update raylib_api.json with new parser for 4.0.0 Update Parser for 4.0.0 May 18, 2022
@RobLoach
Copy link
Owner Author

[ 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
Copy link
Collaborator

konsumer commented Aug 4, 2022

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
Copy link
Collaborator

konsumer commented Aug 5, 2022

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
Copy link
Collaborator

konsumer commented Aug 5, 2022

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.

@RobLoach RobLoach changed the title Update Parser for 4.0.0 Add raymath and raygui support through the new Parser Aug 5, 2022
@RobLoach RobLoach merged commit bc6e8d0 into master Aug 5, 2022
@RobLoach RobLoach deleted the parser branch October 5, 2022 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update Parser

4 participants