From: Thomas M. <to...@al...> - 2014-02-17 23:39:46
|
I'm running into problems using allprotected, generating wraps... I've tried to debug, but I don't know nearly enough on how this code is supposed to work. Here is the code I'm seeing the problem with: Myplugin.i ---------- %module(directors="1", allprotected="1") myplugin %import "base.i" class myPlugin : public PluginBase { public: //void Foo(); <- not required.. } ; base.i ------ %module(directors="1", allprotected="1") base class string { }; class widget { }; class settings { }; %feature("director"); class PluginBase { public: virtual ~PluginBase (); protected: virtual bool SaveWindowInfo(const string &, const string &, widget * w); virtual bool SaveWindowInfo(const string &, const string &, widget * w, settings *s); }; The problem is if I look at the generated file, I see this code: SWIGINTERN PyObject *_wrap_myPlugin_SaveWindowInfo(PyObject *self, PyObject *args) { int argc; PyObject *argv[2]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = args ? (int)PyObject_Length(args) : 0; for (ii = 0; (ii < 1) && (ii < argc); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'myPlugin_SaveWindowInfo'.\n" " Possible C/C++ prototypes are:\n" " PluginBase::SaveWindowInfo(string const &,string const &,widget *)\n" " PluginBase::SaveWindowInfo(string const &,string const &,widget *,settings *)\n"); return 0; } Notice it contains no code to execute the different 'SWIG_#' wrapped functions (but those functions do exist)! I did look in dispatchFunction in the source code. It looks like Swig_overload_dispatch_cast gets called, and it calls Swig_overload_rank. This function returns a list, which is of size 0 (should be 2). That's the issue. But, I'm not sure how to proceed without some guidance... Can anyone think of a workaround? I've found a couple, but they won't work for me: 1) Getting rid of protected seems to do the trick. But, I think I'm going to have trouble convincing others of doing this.. Especially since I've got a lot more than 1 function at issue here. 2) If I merged the two .i files into 1, all works well. But, this is tricky to do, I believe, because my actual setup is much more complicated than this... Is it possible Swig_overload_rank isn't handling looking in the %import files? Any ideas on any simple, clever workaround? Thanks, Tom |