property setters not working
seanmhogan <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
Hi. I'm having a devil of a time binding to a class property and then
setting that property from Lua. I'm using Lua 5.1, Luabind 0.8.1, Boost
1.39 and Visual Studio 2005.
The C++ code:
struct Tough
{
Tough(){}
~Tough(){}
int Tough::get_i() const { return i; }
void Tough::set_i(int _i) { i = _i; }
int i;
};
int main()
{
lua_State* L = lua_open();
luaL_openlibs(L);
luabind::open(L);
module(L) [
class_<Tough>("Tough")
.def(constructor<>())
.property("i", &Tough::get_i, &Tough::set_i)
];
luaL_dofile(L, "test.lua");
object tough1 = globals(L)["tough1"];
Tough* ptough = object_cast<Tough*>(tough1);
printf("i=%d\n", ptough->get_i());
}
test.lua contains simply:
tough1 = Tough()
tough1.i = 8
The Tough::set_i() method is never called and stough->i is left as
-842150451 (uninitialized). Am I missing something obvious here?
Thanks,
Sean
---
Sean Hogan
Marport Canada
[email protected]
--
View this message in context: http://www.nabble.com/property-setters-not-working-tp25753482p25753482.html
Sent from the Lua C++ Bind mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf