problems using .def_readwrite and .property when binding classes
Jonathan Capps <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
Hello. I've been trying to learn how to use luabind, and I can't get my test
program to work as expected. Here's my binding code:
luabind::module(state)
[
luabind::class_<Item>("Item")
.def(luabind::constructor<const std::string&>() )
.def("GetText", &Item::GetText)
.def("SetText", &Item::SetText)
.def_readwrite("text1", &Item::m_text)
.property("text2", &Item::GetText, &Item::SetText)
];
My problem is that I cannot get the .def_readwrite or the .property line to
work as expected. They compile fine, but when I try to access them in lua
code as the documentation seems to show I can:
a = new Item("testing")
print(a:GetText()) -- prints "testing"
a:SetText("Hello World")
print(a:GetText()) --prints "Hello World", so SetText works, too
print(a.text1) --prints "function: 0014C670"
print(a.text2) -- prints "function 0014C800
so it seems that text1 and text2 were exposed as functions? but when I try
to call them as such, I get
print(a.texti()) --prints "luabind: property_tag function
can't be called
So, I've been banging my head against this for a while now, and I can't make
any headway. I could really use some help getting this working.
Thanks.
Jon
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
luabind-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user