Help! How to expose a property correctly!

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Help! How to expose a property correctly!

LLK-2
Hi all:
I a new user of luabind. I have build the dll using bjam.exe in Windows XP. When I try to run the test of attributes(make a new VC project include main.cpp,test.hpp,test_attributes.cpp under \luabind-0.8.1\test\), there will be some error like:

d:\program files\luabind\luabind-0.8.1\test\test_attributes.cpp:124"ERROR: "[string "assert(test.o == 6)"]:1: assertion failed!""
d:\program files\luabind\luabind-0.8.1\test\test_attributes.cpp:152"ERROR: "[string "test.c.a = 1..."]:1: attempt to index field 'c' (a function value)""
d:\program files\luabind\luabind-0.8.1\test\test_attributes.cpp:162"ERROR: "[string "t1 = property()..."]:4: attempt to index global 'c' (a function value)""
function: 004BD698
d:\program files\luabind\luabind-0.8.1\test\test_attributes.cpp:171"ERROR: "[string "assert(a.x == 5)..."]:1: assertion failed!""
d:\program files\luabind\luabind-0.8.1\test\test_attributes.cpp:176"ERROR: "[string "assert(d.d == 3)"]:1: assertion failed!""
 
My question is:
If there a class like:
     class D
     {
      public:
            D(int i)
            {
                 d_ = i;
            }
            int get() const{return d_;}
            void set(int i) {d_ = i};
        protected:
            int d_;
        };
 
And a module defined as:
 
    module(L)
    [
        class_<D>("D")
        .def(constructor<int>())
        .property("d", &D::get,&D::set)
     ]
 
The statement in Lua like:
    
    d = D(5)
    print(d.d)
 
will be function: 003C5D68
Is that right?
If not, how should I do to make the result of "print(d.d)" is 5? 

 

 

Thanks in advance

Aason Liu




穿越地震带 纪念汶川地震一周年

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user