开发者

wxlua bindings does not work with my shaderobjects made using SWIG

I made a class using wxwdigets

//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();
};

I make the abc.i file for SWIG input like this

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

//wrapper over wxIPV4address class IPV4addressLua //: public wxIPV4address ................... ....

then I write make file to generate SWIG bindings : ===

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)

~

...

===== I generate my so like this :-

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开发者_如何学JAVA_gtk2d_core-2.8 -lwx_based_xml-2.8 -lwx_based_net-2.8 -lwx_based-2.8

=====

I write my lua file like this :

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)

.... ....

...

My code fails at the last line saying..

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

===== Please Note ..... wxSockAddess is base class of wxIPV4address from which I derived my class.

Check in this link http://docs.wxwidgets.org/trunk/classwx_i_paddress.html

Can anyone help?

My Diagnosis is :-

The basic problem is Whenever I make sos... using SWIG and try to refer functions or classes from lua .... it works fine till when I refer any wxwidget class or function ... even two sos of mine are able to refer to the classes across sos ... but not with wxwidgets clases ... although .... if I continue to refer any class of wx.so to any other class of wx.so it works ...

Kindly let me know what is stopping lua from understanding the type of my class to any class of wxwidgets.

I know the bindings of wxwidgets have generated by traditional methods and not by SWIG .. is this causing a problem ?


You need to tell SWIG how to convert the SWIG-generated type into one understood by the function calls you're trying to make. Take a look at the Typemap section of the SWIG user documentation. You should be able to come up with a set of typemaps that will allow you to convert the SWIG-generate type into one recognized by your non-SWIG generated wxwidget bindings.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜