Typemaps for constructors?

Christina Noe via Swig-user <[email protected]>
Newsgroups gmane.comp.programming.swig
Message-ID <BN7PR02MB51726C4F6B106958AED5096683770@BN7PR02MB5172.namprd02.prod.outlook.com>
Hi all,

I'm trying to create C# wrappers for a C++ toolkit I'm developing. This toolkit references some data types from a third-party middleware. I'm trying to avoid wrapping any part of the middleware. I've been able to accomplish this to some extent by referencing existing swig-generated C# wrappers available for the middleware. For example, for a C++ type called TENA::Middleware::SessionPtr, I have been able to use a typemap like the following to construct a C# TENA.Middleware.Session object using a pointer to the object constructed in C++:


%typemap(csout, excode=SWIGEXCODE) TYPE*, TYPE&, TYPE {
       IntPtr ptr = $imcall;$excode
       TENA.Middleware.Session ret = new TENA.Middleware.Session(ptr, true);
       return ret;
}

However, I'm having issues doing the same for data types that do not provide a default constructor. For example, regarding a type called TENA::PlatformType::LocalClassPtr, functions in the generated C++ wrapper that try to initialize a TENA:: PlatformType::LocalClassPtr object experience the following error:


[cid:[email protected]]

I can fix this error by altering the generated C++ code so that arg2 initializes using a different constructor (such as "TENA::PlatformType::LocalClassPtr arg2 = TENA::PlatformType::create(0);"), but I want to use a typemap so that SWIG generates code using this constructor automatically. Is there a typemap that can do this? Also, has anyone attempted to generate wrappers that reference other swig-generated wrappers? If so, I would greatly appreciate any thoughts on feasibility and best practices.

Thanks!
Christina Noe

_______________________________________________
Swig-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/swig-user
image003.jpg (image/jpeg, 31.1 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.