From: Jason D. <Jas...@yo...> - 2009-02-16 05:33:17
|
Turns out, the problem was I was using protected constructors in some of the base classes. Changing them to public solved my problem. From: Jason Dictos [mailto:Jas...@yo...] Sent: Sunday, February 15, 2009 2:37 PM To: swi...@li... Subject: [Swig-user] Problem with derived classes not generating call toswig construction wrapper code I've got a few different c++ classes now that I'm exporting to both php and perl in swig. There is a base class, that takes a couple different constructors, then a bunch of different classes that derive from it. When generating the swig wrappers, only some of the classes actually call their C++ construction code, the others don't. The classes that don't get their construction code generated, do get their methods generated, but of course when you try to call these methods from the script, swig generates a runtime type mismatch error, sinc the *this* ptr is not the instantiated class ptr (since their constructors were never called in the swig wrapper). What would cause swig to do this? Here's a snippet of the php module code: This class got its constructor generated properly: class YSiFileEnum extends YSiHandle { public $_cPtr=null; function __construct($path,$spec,$recurse) { $this->_cPtr=new_YSiFileEnum($path,$spec,$recurse); } function Enum() { return YSiFileEnum_Enum($this->_cPtr); } function GetFilePath() { return YSiFileEnum_GetFilePath($this->_cPtr); } } This class however didn't: class YSiBackupJob extends YSiJob { public $_cPtr=null; function __construct($h) { $this->_cPtr=$h; } function SetIncludeWildcardFilter($filter) { YSiBackupJob_SetIncludeWildcardFilter($this->_cPtr,$filter); } function SetExcludeWildcardFilter($filter) { YSiBackupJob_SetExcludeWildcardFilter($this->_cPtr,$filter); } function GetIncludeWildcardFilter() { return YSiBackupJob_GetIncludeWildcardFilter($this->_cPtr); } function GetExcludeWildcardFilter() { return YSiBackupJob_GetExcludeWildcardFilter($this->_cPtr); } function DisableAutoSelection() { YSiBackupJob_DisableAutoSelection($this->_cPtr); } function DisableNativeDataStreams() { YSiBackupJob_DisableNativeDataStreams($this->_cPtr); } } Both classes are derived from the same base class, and the base class itself has no c++ call to construct itself. I've specified c++ constructores that happen to take the same number and type of parameters in the specialized classes, is this the problem? Do I need to have different parameters in my derived classes constructors, different from the base class they derive from? -Jason |