From: Darwin S. <dar...@ho...> - 2006-06-08 23:17:18
Attachments:
wxluanstest.tar.gz
|
Hi, Thanks for your reply. I think I'm just missing something small here. From your suggestions it seems that what I'm trying to do is completely possible in the .i file. Just to clarify one point in your last mail, I'm not looking to declare a class within another class declaration - I just want to write bindings for classes that have been declared in mulit-level namespaces like nsa::nsb::nsc. Thank you for your offer of looking at the code. I definitely don't want to cause any work for you or the team and any suggestions would be appreciated. The attached archive has the .i and MyClass header file and I've included a main driver file and makefile. Thanks for your help, Darwin Slattery From: "John Labenski" <jla...@gm...> To: djs...@us..., wxl...@li... Subject: Re: [Wxlua-users] multi-level C++ namespaces Date: Thu, 8 Jun 2006 15:57:15 -0400 On 6/8/06, Darwin Slattery <dar...@ho...> wrote: >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 You can easily fake using the namespaces by adding this in the in the rules file. -- in lua access as nsa.MyClass hook_lua_namespace = "nsa" -- in C++ the code is compiled in namespace nsa hook_cpp_binding_post_includes = "namespace nsa;\n" >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 Ugh, this is not something I really want to get involved in. You're talking about a class like this class MyClass { public: class MyClass2 { public: int GetX(); void SetX(int x); int x; } Stuff for MyClass } >this class in lua by >using nsa.nsb.MyClass but I don't mind using nsa_nsb.MyClass. I think you will need to use the latter. To allow you to access nsa.nsb.MyClass would require significant changes to the binding code generator and how wxLua deals with looking things up in the bindings. BUT! see below send me the sample code and if it's not too bad I'll do it. >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 >... I'd really have to be able to see the input and output code to make any sense of this. It looks like you have a nice little sample class and the interface file, could you just post the two of those and I can take a look at it this weekend. >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 See above, I'd have to see the output, but I'm guessing that the generator is not expecting :: to be in a classname and so it's just doing weird things. -John Labenski |
From: Darwin S. <dar...@ho...> - 2006-06-09 21:30:19
Attachments:
wxluanstest2.tar.gz
|
Hello, Thanks that works great. The naming convention for the namespaces is perfect. I have noticed something regarding enumerations declared inside a class in a namespace that I just wanted to check with you. I have the following declaration: namespace nsa { class MyClass { public: enum MyEnum { ENUMVAL1 = 10 }; }; } The corresponding entry for the enumeration in the .i file is: %enum nsa::MyClass::MyEnum %rename nsa_MyClass_ENUMVAL1 MyClass::ENUMVAL1 %endenum I could not put the 'nsa::' before 'MyClass::ENUMVAL1' because it results in a compile error saying that nsa::nsa isn't declared. Also when accessing this value within a lua script I use: wxluanstest.nsa_nsa_MyClass_ENUMVAL1 It works fine but I just wanted to check if I'm using this properly. I have attached the source again in case you want to try it out. Thanks again for all your time and help, Darwin Slattery From: "John Labenski" <jla...@gm...> To: djs...@us..., wxl...@li... Subject: Re: [Wxlua-users] multi-level C++ namespaces Date: Thu, 8 Jun 2006 23:10:26 -0400 On 6/8/06, Darwin Slattery <dar...@ho...> wrote: >Thanks for your reply. I think I'm just missing something small here. From >your suggestions it seems that what I'm trying to do is completely possible >in the .i file. Just to clarify one point in your last mail, I'm not >looking >to declare a class within another class declaration - I just want to write >bindings for classes that have been declared in mulit-level namespaces like >nsa::nsb::nsc. It was a very small fix, but in a few different places. In order to make it work you have to use the fully qualified namespace for both the %class and the constructor. The output will be nsa_nsb_MyClass which is reasonable enough, right? It's too much trouble to try to make nested lua "namespaces" like wx.nsa.nsb.MyClass. %class %delete %noclassinfo %encapsulate nsa::nsb::MyClass nsa::nsb::MyClass() %rename nsa_nsb_MyClassFromInt nsa::nsb::MyClass(int x) %constructor nsa_nsb_MyClassFromInt(int x) You use the %rename tag or %constructor tag for alternate constructors, but you must replace the :: with _. >Thank you for your offer of looking at the code. I definitely don't want to >cause any work for you or the team and any suggestions would be >appreciated. >The attached archive has the .i and MyClass header file and I've included a >main driver file and makefile. Thanks for the sample, it really helps and saves me a lot of time when I people give me a nice little sample to work with. The next snapshot will contain the fixed binding generator. Regards, John Labenski |
From: John L. <jla...@gm...> - 2006-06-12 03:52:12
|
On 6/9/06, Darwin Slattery <dar...@ho...> wrote: > Thanks that works great. The naming convention for the namespaces is > perfect. Good. > I have noticed something regarding enumerations declared inside a class in a > namespace that I just wanted to check with you. > > I have the following declaration: > namespace nsa > { > class MyClass > { > public: > enum MyEnum > { > ENUMVAL1 = 10 > }; > }; > } > > The corresponding entry for the enumeration in the .i file is: > %enum nsa::MyClass::MyEnum > %rename nsa_MyClass_ENUMVAL1 MyClass::ENUMVAL1 > %endenum > > I could not put the 'nsa::' before 'MyClass::ENUMVAL1' because it results in > a compile error saying that nsa::nsa isn't declared. I fixed some things related to this, get a new copy and try this. ie. Don't prepend the namespace on the enum name. %enum nsa::MyClass::MyEnum %rename nsa_MyClass_ENUMVAL1 ENUMVAL1 %rename ENUMVAL2 ENUMVAL2 ENUMVAL3 %endenum results should be (using the wx lua "global" namespace) wx.nsa_MyClass_ENUMVAL1 wx.ENUMVAL2 wx.nsa_MyClass_ENUMVAL3 Regards, John Labenski |
From: Darwin S. <dar...@ho...> - 2006-06-12 19:47:15
|
Yeah that works fine now. Thanks again, Darwin Slattery From: "John Labenski" <jla...@gm...> To: djs...@us..., wxl...@li... Subject: Re: [Wxlua-users] multi-level C++ namespaces Date: Sun, 11 Jun 2006 23:52:08 -0400 On 6/9/06, Darwin Slattery <dar...@ho...> wrote: >Thanks that works great. The naming convention for the namespaces is >perfect. Good. >I have noticed something regarding enumerations declared inside a class in >a >namespace that I just wanted to check with you. > >I have the following declaration: >namespace nsa >{ >class MyClass >{ >public: > enum MyEnum > { > ENUMVAL1 = 10 > }; >}; >} > >The corresponding entry for the enumeration in the .i file is: >%enum nsa::MyClass::MyEnum > %rename nsa_MyClass_ENUMVAL1 MyClass::ENUMVAL1 >%endenum > >I could not put the 'nsa::' before 'MyClass::ENUMVAL1' because it results >in >a compile error saying that nsa::nsa isn't declared. I fixed some things related to this, get a new copy and try this. ie. Don't prepend the namespace on the enum name. %enum nsa::MyClass::MyEnum %rename nsa_MyClass_ENUMVAL1 ENUMVAL1 %rename ENUMVAL2 ENUMVAL2 ENUMVAL3 %endenum results should be (using the wx lua "global" namespace) wx.nsa_MyClass_ENUMVAL1 wx.ENUMVAL2 wx.nsa_MyClass_ENUMVAL3 Regards, John Labenski |
From: John L. <jla...@gm...> - 2006-06-09 03:10:30
|
On 6/8/06, Darwin Slattery <dar...@ho...> wrote: > Thanks for your reply. I think I'm just missing something small here. From > your suggestions it seems that what I'm trying to do is completely possible > in the .i file. Just to clarify one point in your last mail, I'm not looking > to declare a class within another class declaration - I just want to write > bindings for classes that have been declared in mulit-level namespaces like > nsa::nsb::nsc. It was a very small fix, but in a few different places. In order to make it work you have to use the fully qualified namespace for both the %class and the constructor. The output will be nsa_nsb_MyClass which is reasonable enough, right? It's too much trouble to try to make nested lua "namespaces" like wx.nsa.nsb.MyClass. %class %delete %noclassinfo %encapsulate nsa::nsb::MyClass nsa::nsb::MyClass() %rename nsa_nsb_MyClassFromInt nsa::nsb::MyClass(int x) %constructor nsa_nsb_MyClassFromInt(int x) You use the %rename tag or %constructor tag for alternate constructors, but you must replace the :: with _. > Thank you for your offer of looking at the code. I definitely don't want to > cause any work for you or the team and any suggestions would be appreciated. > The attached archive has the .i and MyClass header file and I've included a > main driver file and makefile. Thanks for the sample, it really helps and saves me a lot of time when I people give me a nice little sample to work with. The next snapshot will contain the fixed binding generator. Regards, John Labenski |