views:

113

answers:

1

I'm trying to build a set of Lua bindings for a collection of C++ classes, but have been toying with Python to see if I get better results. In either language the bindings seem to work, however, when I initialize an instance of a class that contains members of other classes, those data members do not seem to be guaranteed to be initialized.

For example, take the class:

class MyClass : public ParentClass // (Obviously) not a real class
{
    public:
        SomeClass sc;
        OtherClass oc;
};//Note that none of my classes have a constructor or destructor; this is by design.

When I generate bindings for a class like this, I am able to execute statements like:

var = module_name.MyClass()
print(var.sc.x, var.sc.y)

And I get the expected junk values printed to the screen. However, if I try to print anything about the instance of OtherClass, it becomes obvious that it is "stubbed out" -- in Lua it has no metatable at all and in Python doing dir(var.oc) gives only the default functions. However, if I then do:

var.oc = module_name.OtherClass()

The oc metatable / dir(oc) call are what I would have hoped for and it can be treated as expected.

Can anyone offer any insight into why only -some- of the member data are initialized?

Thanks!

A: 

Turns out this problem was related to another problem I was having. See this thread for the resolution.

Zack