-
Notifications
You must be signed in to change notification settings - Fork 88
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
const variables? #12
Comments
Actually, I was able to create a patch that fixes the issues with const non-ref variable primitives. I'll create a PR for your review in case you are interested. I'm sure there is more work required for non-primitives which I can probably handle as well. |
Here's the commit I'm working on in case you have any design feedback: It's a little awkward because of the writeable property. I removed it entirely, but that makes the API a little more confusing and less discoverable. Perhaps it would be better to leave it for the const version and assert, or move the specialization for const further up the stack into LuaValue or something. |
Wouldn't it be simpler by adding: /**
* Add or replace a const data member.
*/
template <typename V>
CppBindClass<T>& addVariable(const char* name, const V T::* v)
{
setMemberGetter(name, LuaRef::createFunction(state(), &CppBindClassVariable<T, V>::get, const_cast<V T::*>(v)));
setMemberReadOnly(name);
return *this;
} |
That looks better. I'll give it a try. |
Hey Steve,
Any plans to support const variables? For example, I would like to export const globals with addVariable if possible, but I'm also happy writing a addProperty + lambda. However, I'm less clear how I would expose a const field on a class, since I haven't checked if you have access to the instance in the lambda.
Thanks again,
Kris
The text was updated successfully, but these errors were encountered: