From: Sascha V. C. <sas...@gm...> - 2011-10-07 12:59:31
|
Thank you for your answers. But I think I badly explained my problem. I don't want to generate a constructor wrapper for a private constructor. My problem is that in a given wrapping function (generated by SWIG), a variable of type T is declared, that is : "T exempleVar ; " At this point, the default constructor T() is called. But that constructor is private (and it cannot be changed). So, there is of course a compilation error. I would like to tell to SWIG to generate the code using pointers instead, that is : "T* exempleVar" Is it possible to do this ? Or maybe to avoid to use temporary variable or to tell SWIG to don't use default constructor ? Here is a piece of the generated code (the problematic constructor is GRelation() ) : "EXPORT GRelation *_wrap_CPRelVar_glb (MPG::CPRelVar *larg1) { GRelation * lresult = (GRelation *)0 ; MPG::CPRelVar *arg1 = (MPG::CPRelVar *) 0 ; GRelation result; arg1 = larg1; try { result = ((MPG::CPRelVar const *)arg1)->glb(); lresult = new GRelation(result); return lresult; } catch (...) { return (GRelation *)0; } }" Thank you for your help. Le 6 oct. 2011 à 20:13, William S Fulton a écrit : > SWIG should not generate constructor wrappers if the constructor is private. Can you post minimal cutdown code that shows the problem? > > Also look at %ignore for preventing the constructor wrapper as a work around if SWIG is getting it wrong. > > William > > On 06/10/11 17:28, Stefan Zager wrote: >> This part of the SWIG docs should help: >> >> http://www.swig.org/Doc2.0/SWIGPlus.html#SWIGPlus_nn8 >> >> Pay attention to the %nodefaultctor directive. >> >> Hope that helps. >> >> Stefan >> >> On Thu, Oct 6, 2011 at 1:12 AM, Sascha Van Cauwelaert >> <sas...@gm...> wrote: >>> Hello everybody, >>> >>> For now, I am trying to generate an interface between C++ and Common Lisp, using SWIG and CFFI. I cannot change the C++ code which is developed by somebody else. While trying to compile the wrapping code, I got an error : >>> >>> error: SomeClass::SomeClass() is private >>> >>> Looking at the generated wrapping code, I see the reason of this : >>> >>> EXPORT SomeClass *_wrap_SomeFunction (SomeArgType *larg1) { >>> SomeClass result; >>> >>> >>> >>> So of course it cannot compile because the default constructor is private and we aren't in the class. I cannot change this because the original code is not mine. >>> >>> So my question is : is there some way to tell to SWIG to generate the code differently (using pointers for instance instead of objects themselves) ? With some passed parameters to SWIG or in the interface file ? >>> >>> Any advice would be very helpful, I am very stuck here. Thank you in advance. >>> >>> Regards, >>> >>> Sascha Van Cauwelaert >>> ------------------------------------------------------------------------------ >>> All the data continuously generated in your IT infrastructure contains a >>> definitive record of customers, application performance, security >>> threats, fraudulent activity and more. Splunk takes this data and makes >>> sense of it. Business sense. IT sense. Common sense. >>> http://p.sf.net/sfu/splunk-d2dcopy1 >>> _______________________________________________ >>> Swig-user mailing list >>> Swi...@li... >>> https://lists.sourceforge.net/lists/listinfo/swig-user >>> >> >> ------------------------------------------------------------------------------ >> All the data continuously generated in your IT infrastructure contains a >> definitive record of customers, application performance, security >> threats, fraudulent activity and more. Splunk takes this data and makes >> sense of it. Business sense. IT sense. Common sense. >> http://p.sf.net/sfu/splunk-d2dcopy1 >> _______________________________________________ >> Swig-user mailing list >> Swi...@li... >> https://lists.sourceforge.net/lists/listinfo/swig-user >> > |