Thanks for your reply,

I have tried your suggestions but have had no luck unfortunately. I have attached
some of the compiler output below.

Just to clarify what I'm trying to do first:
I have a class called MyClass in a namespace called nsa. Its a very simple class with 2 member functions SetX and GetX which set and return an int. I would eventually like to move this class into sub-namespace of nsa called nsb. My main problem is that I don't want to move the class into the global C++ namepsace. Ideally I would also like to access this class in lua by
using nsa.nsb.MyClass but I don't mind using nsa_nsb.MyClass.

I tried adding "#include \"MyClass.h\"; using nsa::MyClass" in the hook_cpp_binding option but this
produced the following errors:
wxluanstest.cpp:21: error: ‘MyClass’ is already declared in this scope
wxluanstest.cpp: In function ‘int wxLua_MyClass_constructor(lua_State*)’:
wxluanstest.cpp:40: error: no matching function for call to ‘wxLua_AddToTrackedMemoryList(wxLuaState&, nsa::MyClass*)’ /usr/local/include/wxlua/include/wxlbind.h:189: note: candidates are: void wxLua_AddToTrackedMemoryList(wxLuaState&, wxObject*) /usr/local/include/wxbind/include/wxbind.h:2920: note: void wxLua_AddToTrackedMemoryList(wxLuaState&, wxString*) /usr/local/include/wxbind/include/wxbind.h:2921: note: void wxLua_AddToTrackedMemoryList(wxLuaState&, wxWindowDisabler*)
/usr/local/include/wxbind/include/wxbind.h:2929: note:                 void
...



Using nsa::MyClass instead of just MyClass in the .i file without the hook_cpp_binding
value above produced:

wxluanstest.h:48: error: ‘wxObject_nsa’ has not been declared
wxluanstest.h:48: error: expected unqualified-id before ‘:’ token
wxluanstest.cpp:110: error: ‘wxLua_nsa’ has not been declared
wxluanstest.cpp:111: error: ‘wxLua_nsa’ has not been declared
make: *** [wxluanstest.o] Error 1


Sorry for the long mail and if you want to look at my code or need any more information please
let me know.

Any help would be appreciated,
Darwin Slattery


I have been having problems with generating the bindings for classes when
they exist in sub-namespaces of the main namespaces e.g.
a::b::MyClass

I was not able to set this namesace in the rules file using the
hook_cpp_namespace because this caused problems with the #ifndef at the top
of the generated binding header e.g.:

<code>
#ifndef __HOOK_WXLUA_a::b_H__
#define __HOOK_WXLUA_a::b_H__
</code>

This is ok, hook_cpp_namespace is not really a C++ "namespace", but
rather a way to make sure that the names of the functions and
everything else created by the binding generator are unique.

Try just hook_cpp_namespace = "a_b"

To use a real C++ namespace use one of the
hook_cpp_binding_[XXX_includes] to add any code you need to the
bindings.

It also seems to only process the first part of the namespace:
'wxluatest.h:58: error: 'wxObject_a' has not been declared'

I was just wondering if this is supported or if there is any way around this
short of editing the generated binding files?

Let us know if the above works for you. I do not believe that I've
ever tried using classes within classes so there may be other issues
as well, but lets hope not.

Regards,
   John Labenski



_______________________________________________
Wxlua-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to