Using properties in luabind 0.8.1

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Using properties in luabind 0.8.1

Arisnova
Hi all,
I've moved from 0.7.1 to the new 0.8.1. Unfortunately my code doesn't work with new version and this is because of properties.
I've tested this simple code:

/************************************************************************/
class A
{
public:
    A(int val): a(val) {}
    int a;
};

/************************************************************************/
std::string fooFnc= "function foo(aVal) print(aVal.a) end";

/************************************************************************/
/*! main                                                                */
/************************************************************************/
int main (int agrc, char** argv)
{
    //creates engine master state
    lua_State* l= lua_open();

    if (l)
    {
        luaL_openlibs(l);

        //open luabind
        luabind::open(l);

        //register class
        luabind::module(l)
            [
                luabind::class_<A>("A")
                .def_readonly("a", &A::a)
            ];

        //create instance
        A aVal(33);

        int status = 0;

        //defines function in virtual machine
        status = luaL_dostring(l, fooFnc.c_str());

        //invokes function foo ( it should print '33' in console )
        luabind::call_function<void>(l,"foo", aVal);

        //close lua state
        lua_close(l);
        l= NULL;
    }
};

Quite simple, I just want to print the current A::a value (in this case 33) but a function is returned instead.
I've checked test code (in test_attribute.cpp and test_object.cpp) and looks like I'm writting the same to define a read only property.

What's wrong in my code?

Best regards,
Iván.




------------------------------------------------------------------------------

_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Using properties in luabind 0.8.1

Daniel Wallin
Arisnova wrote:
> Hi all,
> I've moved from 0.7.1 to the new 0.8.1. Unfortunately my code doesn't work
> with new version and this is because of properties.
[...]
> Quite simple, I just want to print the current A::a value (in this case 33)
> but a function is returned instead.

This looks correct. How are you building luabind, and how are you
linking to it?

--
Daniel Wallin
BoostPro Computing
http://www.boostpro.com

------------------------------------------------------------------------------
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Using properties in luabind 0.8.1

Arisnova
Hi Daniel,
We are using luabind as a DLL, with BOOST 1.36.0 and both libraries compiled with VC9 SP1.
We've built luabind from Pau's CMake project but we also tested with luabind 0.8.0 generated with the BJam from BOOST 1.36.0.

Ivan.

PD: Pau and I are co-workers ;)

2009/3/10 Daniel Wallin <[hidden email]>
Arisnova wrote:
> Hi all,
> I've moved from 0.7.1 to the new 0.8.1. Unfortunately my code doesn't work
> with new version and this is because of properties.
[...]
> Quite simple, I just want to print the current A::a value (in this case 33)
> but a function is returned instead.

This looks correct. How are you building luabind, and how are you
linking to it?

--
Daniel Wallin
BoostPro Computing
http://www.boostpro.com

------------------------------------------------------------------------------
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user


------------------------------------------------------------------------------

_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Using properties in luabind 0.8.1

Daniel Wallin
Arisnova wrote:
> Hi Daniel,
> We are using luabind as a DLL, with BOOST 1.36.0 and both libraries compiled
> with VC9 SP1.
> We've built luabind from Pau's CMake project but we also tested with luabind
> 0.8.0 generated with the BJam from BOOST 1.36.0.

You need to define LUABIND_DYNAMIC_LINK both when building and linking
to the shared library. Are you doing that?

--
Daniel Wallin
BoostPro Computing
http://www.boostpro.com

------------------------------------------------------------------------------
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Using properties in luabind 0.8.1

Arisnova
Looks like that was the problem, The luabind was built with LUABIND_DYNAMIC_LINK but not the application, now with the definitions LUA_BUILD_AS_DLL and
LUABIND_DYNAMIC_LINK it works as expected :D

Thank you,
Iván.


2009/3/10 Daniel Wallin <[hidden email]>
Arisnova wrote:
> Hi Daniel,
> We are using luabind as a DLL, with BOOST 1.36.0 and both libraries compiled
> with VC9 SP1.
> We've built luabind from Pau's CMake project but we also tested with luabind
> 0.8.0 generated with the BJam from BOOST 1.36.0.

You need to define LUABIND_DYNAMIC_LINK both when building and linking
to the shared library. Are you doing that?

--
Daniel Wallin
BoostPro Computing
http://www.boostpro.com

------------------------------------------------------------------------------
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user