# Lua with CML

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

## 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 on other sites

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

1. 1
2. 2
Rutin
20
3. 3
khawk
16
4. 4
A4L
14
5. 5

• 11
• 16
• 26
• 10
• 11
• ### Forum Statistics

• Total Topics
633755
• Total Posts
3013706
×