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" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED], [email protected]
Subject: Re: [Wxlua-users] multi-level C++ namespaces
Date: Thu, 8 Jun 2006 15:57:15 -0400

On 6/8/06, Darwin Slattery <[EMAIL PROTECTED]> 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

Attachment: wxluanstest.tar.gz
Description: GNU Zip compressed data

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

Reply via email to