2009-11-06 68 views
2

搞得我使用wxwdigetswxlua绑定不与我shaderobjects工作使用痛饮

//wrapper over wxIPV4address 
class IPV4addressLua : public wxIPV4address 
{ 

    public: 
      IPV4addressLua(); 
      ~IPV4addressLua(); 
      bool SetService (const wxString &service); 
      bool SetService (unsigned short service); 
      unsigned short GetService() const; 
      wxSockAddress* GetwxSockAddress(); 
      wxIPV4address GetwxIPV4address(); 
      wxSocketServer* GetwxSocketServer(); 
}; 

我做出这样的

%module wxAppManagerLua 
%{ 
#include "wxAppManager.h" 
#include "wx/socket.h" 
%} 

SWIG输入abc.i文件//封装在了一个班wxIPV4address 类IPV4addressLua //:公共wxIPV4address ................... ....

然后我写做文件生成痛饮绑定:===

TARGET= wxAppManagerLua.so 
WRAPPER= wxAppManager_wrap.cxx 
SRCS= $(ROOTSRC)/wxAppManager.cpp $(ROOTSRC)/XMLReader.cpp $(WRAPPER) 

INTERFACE=wxAppManager.i 
CC= g++ 
FLAGS=-shared -fPIC -DDEBUG=1 
SWIGFLGS= -lua -c++ -includeall -v 
RM=rm -rfv 

all:$(WRAPPER) 

$(TARGET) : $(SRCS) 
     $(CC) $(FLAGS) -o $(TARGET) $(SRCS) $(EXTRAINC) $(WXCONFIGFLGS) 

$(WRAPPER): 
     swig $(SWIGFLGS) -I/usr/include $(EXTRAINC) $(INTERFACE) 

clean: 
     $(RM) *.so* $(WRAPPER) 

...

===== 我生成这样我这样的: -

g++ -g -shared -fPIC -o wxAppManagerLua.so ./wxAppManager_wrap.cxx ./wxAppManager/src/XMLReader.cpp ./wxAppManager/src/wxAppManager.cpp -I./ -I./wxAppManager/inc/ -I/usr/local/lib/wx/include/gtk2-ansi-debug-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXDEBUG__ -D__WXGTK__ -pthread -L/usr/local/lib -pthread -lwx_gtk2d_richtext-2.8 -lwx_gtk2d_aui-2.8 -lwx_gtk2d_xrc-2.8 -lwx_gtk2d_qa-2.8 -lwx_gtk2d_html-2.8 -lwx_gtk2d_adv-2.8 -lwx_gtk2d_core-2.8 -lwx_based_xml-2.8 -lwx_based_net-2.8 -lwx_based-2.8

=====

我写我的lua文件是这样的:

function CreateServer() 

    -- Create the address - defaults to localhost:0 initially 

    local addr = wxAppManagerLua.IPV4addressLua() 
    if addr ~= nil then 
      print(" Calling Bind Port ") 
      addr:SetService(3000) 
    end 

    port = addr:GetService() 
    print(" Binded to Port "..port) 

    -- Create the socket 
    SockAddr = wx.wxSockAddress 

    --CODE FAILS HERE 
    SOCKSERVER = wx.wxSocketServer(addr) 

.... ....

...

我的代码失败,在最后一行说..

 
SockTestAppMgr.wx.lua:584: wxLua: Expected a 'wxSockAddress' for parameter 1, but got a 'userdata'. 

Function called: 'wxSocketServer(userdata)' 

01. wxSocketServer::wxSocketServer([wxSockAddress, integer]) 

stack traceback: 

     [C]: in function 'wxSocketServer' 
     SockTestAppMgr.wx.lua:584: in function 'CreateServer' 
     SockTestAppMgr.wx.lua:682: in function 'main' 
     SockTestAppMgr.wx.lua:694: in main chunk 

===== 请注意..... wxSockAddess是我从中派生我的类的wxIPV4address的基类。

入住这个环节http://docs.wxwidgets.org/trunk/classwx_i_paddress.html

谁能帮助?

我的诊断是: -

的基本问题是 每当我做SOS ......使用痛饮,并尝试从Lua参考函数或类....它工作得很好,直到当我提及任何wxwidget类或功能... 即使我的两个sos能够引用sos中的类...但不能与wxwidgets类别... 虽然....如果我继续将任何类的wx.so引用到任何类其他类的wx.so它的工作原理...

请让我知道什么是阻止lua从理解我的类的类型到任何类的wxwidgets。

我知道wxwidgets的绑定是由传统方法生成的,而不是由SWIG生成的。这是否会导致问题?

回答

3

您需要告诉SWIG如何将SWIG生成的类型转换为您正在尝试执行的函数调用所理解的类型。查看SWIG用户文档的Typemap section。您应该能够想出一组类型映射,这将允许您将SWIG生成类型转换为由您的非SWIG生成的wxwidget绑定识别的类型。