ThePhD / sol2

Sol3 (sol2 v3.0) - a C++ <-> Lua API wrapper with advanced features and top notch performance - is here, and it's great! Documentation:
http://sol2.rtfd.io/
MIT License
4.06k stars 492 forks source link

Global variable can't be wrapped by reference #1520

Open deadlocklogic opened 10 months ago

deadlocklogic commented 10 months ago

Consider:

static int x = 1;

And binding with:

state["num"] = sol::var(std::ref(x));

Now print(num) gives function:000000... (hex address), which should be a number instead. I even tried with global usertypes and got same issue. (When accessing the variable I get cannot index function etc...)

If we can fix #1416 , would be great too! (As I remember many other issues were related to it). So far the most serious issues in sol are static and global variable.

@ThePhD By the way I am working on a binding auto-generator which implements a lua/sol generator, when ready I will post an issue here if anyone ever gets interested.

Thanks for your efforts again!