-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues with nesting classes #24
Comments
Hey thanks for the issue! If I understand correctly, you want be be able to Unfortunately I don't have the time to write a proper documentation, besides the Glue readme and EmGlue readme, but you can find an example in the unit tests. |
Hello, I am working on the same problem as here. class Writer{
public:
float prop = 1.02f;
}; Glued like follows: lib["Writer"] = glue:createClass<Writer>().addConstructor().addMember("prop", &Writer::prop); console.log(readerModule.prop()); prints the floating point number. Now if we had: class Writer{
public:
LibaryClass prop;
}; And then. console.log(readerModule.prop()); This prints Any{}. So, my question is how to actually create the bindings for these classes. Do I have to manually create all the bindings? Or is there a preferred way of creating those mappings. |
The glue code with the template is published here |
Yes, you would need to add a definition somewhere for all types that you want to interact with from JavaScript. So in your case, to be able to lib["Writer"] = glue:createClass<Writer>().addConstructor().addMember("prop", &Writer::prop);
lib["LibaryClass"] = glue:createClass<LibaryClass>().addMember(
glue::keys::operators::tostring,
[](const LibaryClass &obj){
return <code to convert LibaryClass to a string>;
}
); |
@HassanEmam @FireBlaze236 did this help with your issue? |
@TheLartians thanks for your response. I am still struggling to be honest. I have a Reader class that parses a file which contains Tasks class that has a vector of class Task The Task class has a lot of properties. what I want to achieve is to return an array of tasks with access to the properties not only a string. |
If you define the array type e.g. using |
I have created a library that parses a tsv file. Each line parsed is added to an object of another class that is used as a collections.
When I used the template to compile I had some initial issues accessing the filesystem but that has been sorted by modifying the CMAKELists and adding some extra arguments.
Now all compiles ok and I have exposed the functions and members using Glue; I am faced a new issue that I can access a member but when I try to console log the data in that member it does not recognise it.
The code for the library is https://github.com/Constology/XERNative
Any suggesting on what is the best practice to write the Glue code for this library?
The text was updated successfully, but these errors were encountered: