Jump to content
  • Advertisement
Sign in to follow this  
Matt328

Lua with CML

This topic is 773 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm having trouble binding pretty much any classes from CML (configurable math library) to Lua. Due to them being such a tangled mess of templates and macros, I can't seem to find the function signatures for the overloaded operator functions.  I'm trying to use LuaBridge right now to register the cml::vector3f::operator+= function, and since there are so many overloads, I think I have to cast the address of the function to the function signature I want it to bind.  Currently I'm trying: 

.addFunction("__add", (Vector3& (*)(const Vector3&))&Vector3::operator+=)

(I have Vector3 typedef'ed to cml::vector3f) but that produces:

Address of overloaded function 'operator+=' does not match required type 'cml::vector<float, cml::fixed<3, -1> > &(const cml::vector<float, cml::fixed<3, -1> > &)'

I'm just about ready to punt on scripting altogether and just do everything in C++.

Share this post


Link to post
Share on other sites
Advertisement

I would try defining the proper function type you need, and assigning &Vector3::operator+= to a temporary of that type, to use in addFunction().

Share this post


Link to post
Share on other sites
That is what I hve been trying but poking around in the dark at the end of a very long day trying to guess the function signature had been less than effective. Even when I use auto, the compiler can't figure it out I guess because there are multiple overrides of the operator+= function. I think that is why .addFunction is complaining and making me explicitly cast to one of them. I've also tried using decltype to determine the signature, but with the same results.

I was also unable to get operator[] to work and I now realize for the same reason. I am able to define a helper struct and delegate to the original object but I'd rather not have to do that especially if it is as trivial as figuring out what the compiler thinks the function signatures are.

I'm using clang with C++14 support if that helps.

Share this post


Link to post
Share on other sites

I got this figured out, I was really close, but missing the signature for a function pointer to member is different than a function pointer to a free function.

.addFunction("__add", (Vector3&(Vector3::*)(const Vector3&))&Vector3::operator+=)

I had * instead of Vector3::* in the middle of the function pointer type.

Edited by Matt328

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!