<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<id>tag:old.nabble.com,2006:forum-3365</id>
	<title>Nabble - SWIG</title>
	<updated>2009-11-10T23:49:02Z</updated>
	<link rel="self" type="application/atom+xml" href="http://old.nabble.com/SWIG-f3365.xml" />
	<link rel="alternate" type="text/html" href="http://old.nabble.com/SWIG-f3365.html" />
	<subtitle type="html">SWIG is compiler that connects C and C++ with a variety of  scripting languages including Perl, Python, Tcl, Guile, and Ruby.   People often use it to create scripting language extensions or to create interpreted environments for existing software. SWIG home is &lt;a href=&quot;http://sourceforge.net/projects/swig/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.</subtitle>
	
<entry>
	<id>tag:old.nabble.com,2006:post-26297344</id>
	<title>Ownership Ruby &lt;-&gt; C++</title>
	<published>2009-11-10T23:49:02Z</published>
	<updated>2009-11-10T23:49:02Z</updated>
	<author>
		<name>Sören Freudiger-2</name>
	</author>
	<content type="html">Hi
&lt;br&gt;I don't know how to deal with following problem:
&lt;br&gt;&lt;br&gt;_______________________
&lt;br&gt;C++ code:
&lt;br&gt;struct Foo{ };
&lt;br&gt;&lt;br&gt;class Base {
&lt;br&gt;&amp;nbsp; &amp;nbsp;Base(Foo* foo) : foo(foo) {}
&lt;br&gt;&amp;nbsp; &amp;nbsp;~Base() { delete foo; }
&lt;br&gt;&amp;nbsp; &amp;nbsp;Foo* foo;
&lt;br&gt;};
&lt;br&gt;&lt;br&gt;class Derived : public Base{
&lt;br&gt;public:
&lt;br&gt;&amp;nbsp; &amp;nbsp;Derived (Foo* foo) : Base(foo) {}
&lt;br&gt;&lt;br&gt;};
&lt;br&gt;_______________________
&lt;br&gt;Ruby snippet:
&lt;br&gt;f1 = Ex::Foo.new()
&lt;br&gt;b &amp;nbsp;= Ex::Base.new(f1)
&lt;br&gt;&lt;br&gt;f2 = Ex::Foo.new()
&lt;br&gt;d &amp;nbsp;= Ex::Derived.new(f2)
&lt;br&gt;_______________________
&lt;br&gt;&lt;br&gt;ERROR:
&lt;br&gt;_______________________
&lt;br&gt;--&amp;gt; Segmentation fault, because f1/f2 will be deleted twice (once by
&lt;br&gt;~Base/Derived and once by Ruby-GC).
&lt;br&gt;_______________________
&lt;br&gt;&lt;br&gt;Therefore I can extend my interface like that:
&lt;br&gt;&lt;br&gt;_______________________
&lt;br&gt;ex.i
&lt;br&gt;...
&lt;br&gt;%trackobjects;
&lt;br&gt;%{
&lt;br&gt;static void free_Base (void* ptr) 
&lt;br&gt;{
&lt;br&gt;&amp;nbsp; &amp;nbsp;Base* base = (Base *) ptr;
&lt;br&gt;&amp;nbsp; &amp;nbsp;SWIG_RubyUnlinkObjects(base -&amp;gt;foo);
&lt;br&gt;&amp;nbsp; &amp;nbsp;SWIG_RubyRemoveTracking(base -&amp;gt;foo);
&lt;br&gt;&amp;nbsp; &amp;nbsp;SWIG_RubyRemoveTracking(ptr);
&lt;br&gt;&amp;nbsp; &amp;nbsp;delete base;
&lt;br&gt;}
&lt;br&gt;static void free_Derived (void* ptr) 
&lt;br&gt;{
&lt;br&gt;&amp;nbsp; &amp;nbsp;free_Base(ptr);
&lt;br&gt;}
&lt;br&gt;%}
&lt;br&gt;_______________________
&lt;br&gt;&lt;br&gt;Three questions:
&lt;br&gt;1. Is there any more easy way of doing that? 
&lt;br&gt;2. What to do if there's no access to &amp;quot;foo&amp;quot; of Base?
&lt;br&gt;3. Is it possible ONLY to remove the ownership from the foo objects
&lt;br&gt;(SWIG_RubyUnlinkObjects)?
&lt;br&gt;&lt;br&gt;Best regards,
&lt;br&gt;SirAnn
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
&lt;br&gt;trial. Simplify your report design, integration and deployment - and focus on 
&lt;br&gt;what you do best, core application coding. Discover what's new with
&lt;br&gt;Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26297344&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Passing-Wrapped-Struct-to-Python-Function-tp26290541p26297344.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26292049</id>
	<title>Passing arrays of objects between C++ and C#</title>
	<published>2009-11-10T14:01:22Z</published>
	<updated>2009-11-10T14:01:22Z</updated>
	<author>
		<name>eodabash</name>
	</author>
	<content type="html">We're currently dealing with a pretty tricky situation at my company trying to wrap a set of C++ classes for C# with SWIG. The problems we're running into mainly revolve around passing C++ structs or arrays of structs back and forth between C++ and C#. 
&lt;br&gt;&lt;br&gt;For example, suppose we have a simple type that looks like this in C++
&lt;br&gt;&lt;br&gt;struct Point
&lt;br&gt;{
&lt;br&gt;float x,y,z;
&lt;br&gt;};
&lt;br&gt;&lt;br&gt;We need to be able to do the following:
&lt;br&gt;&lt;br&gt;- Pass a single Point from C# to C++ 
&lt;br&gt;- Pass an array of Points from C# to C++
&lt;br&gt;- Pass a pointer to a single Point from C++ to C# (to a C# override of a C++ virtual function using the directors mechanism)
&lt;br&gt;- Pass an array of Points from C++ to C# through a virtual function override (as in the previous case)
&lt;br&gt;&lt;br&gt;I'm not sure if our approach here should be to work with a SWIG proxy version of the Point class, since an array of these proxy objects is really just an array of pointers to C++ objects, not an array of sequential C++ objects in memory, and for C++ to send an array of Points to C# we would need to really initialize an array of proxy objects, assign each one to an element in the C++ array, and then pass it on to the actual C# user code. Then we would also have to do something similar going the other way.
&lt;br&gt;&lt;br&gt;The other option I thought of is to (somehow) not let SWIG define a proxy Point class and instead define something like:
&lt;br&gt;&lt;br&gt;[StructLayout(LayoutKind.Sequential)]
&lt;br&gt;public struct Point
&lt;br&gt;{
&lt;br&gt;public float x;
&lt;br&gt;public float y;
&lt;br&gt;public float z;
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;And hopefully figure out a way to use this in C# so we can directly work with C++ input objects, and directly pass a pointer to an array of these structs from C# to C++ (rather than making copies).
&lt;br&gt;&lt;br&gt;So I guess I'm wondering if there's a canonical solution to this type of problem, or if we're in uncharted territory here, and are we maybe asking too much of SWIG?
&lt;br&gt;&lt;br&gt;Thanks in advance for any suggestions,
&lt;br&gt;&lt;br&gt;Evan
&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Passing-arrays-of-objects-between-C%2B%2B-and-C--tp26292049p26292049.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26290827</id>
	<title>Re: Passing Wrapped Struct to Python Function</title>
	<published>2009-11-10T12:38:53Z</published>
	<updated>2009-11-10T12:38:53Z</updated>
	<author>
		<name>ajayre</name>
	</author>
	<content type="html">I'm wondering if this might be due to my callback structure. Here is the 
&lt;br&gt;call flow:
&lt;br&gt;&lt;br&gt;Python calls function in C extension
&lt;br&gt;C extension starts a task in a different thread (thread B)
&lt;br&gt;C extension calls WaitForSingleObject to wait for completion of thread B
&lt;br&gt;C extension calls callback function in Python in thread B
&lt;br&gt;C extension finishes waiting for WaitForSingleObject and returns
&lt;br&gt;Python executes next statement
&lt;br&gt;&lt;br&gt;I've found that simple things in the callback work, but creating new 
&lt;br&gt;objects doesn't. I'm guessing this is because the python callback 
&lt;br&gt;function executes in a different thread?
&lt;br&gt;&lt;br&gt;Andy
&lt;br&gt;&lt;br&gt;Andrew Ayre wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hi, I'm using Python 2.6 and SWIG. In my C++ code I have:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; struct
&lt;br&gt;&amp;gt; {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;unsigned long id;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;unsigned char data[8];
&lt;br&gt;&amp;gt; } FOO;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; SWIG wraps this in a proxy class so in Python I can use:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; import MyLib
&lt;br&gt;&amp;gt; foo = MyLib.FOO()
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; In my Python code I have a callback function that receives a FOO object:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; def Callback(foo):
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;print &amp;quot;%d&amp;quot; % foo.id
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; however any use of foo in the callback function causes a crash of the 
&lt;br&gt;&amp;gt; Python interpreter. Either I just get a generic Windows error (when 
&lt;br&gt;&amp;gt; accessing foo.id), or I get (when accessing foo.data[0]):
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Exception SystemError: 'error return without exception set' in 'garbage 
&lt;br&gt;&amp;gt; collection' ignored
&lt;br&gt;&amp;gt; Fatal Python error: unexpected exception during garbage collection
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Here is how I am calling the Python callback function, and I'm sure the 
&lt;br&gt;&amp;gt; problem is in this area:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; FOO foo;
&lt;br&gt;&amp;gt; PyObject *fooobj, *args;
&lt;br&gt;&amp;gt; foo.id = 1;
&lt;br&gt;&amp;gt; foo.data[0] = 2;
&lt;br&gt;&amp;gt; fooobj = SWIG_NewPointerObj(&amp;foo, SWIGTYPE_p_FOO, 1);
&lt;br&gt;&amp;gt; args = Py_BuildValue(&amp;quot;(O)&amp;quot;, fooobj);
&lt;br&gt;&amp;gt; PyObject_Call(CallbackFunc, args, NULL);
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I tried allocated foo on the heap and it didn't help. Any ideas or hints 
&lt;br&gt;&amp;gt; what I might be doing wrong?
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; thanks, Andy
&lt;br&gt;&amp;gt; 
&lt;/div&gt;&lt;br&gt;-- 
&lt;br&gt;Andy
&lt;br&gt;PGP Key ID: 0xDC1B5864
&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
&lt;br&gt;trial. Simplify your report design, integration and deployment - and focus on 
&lt;br&gt;what you do best, core application coding. Discover what's new with
&lt;br&gt;Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26290827&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Passing-Wrapped-Struct-to-Python-Function-tp26290541p26290827.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26290541</id>
	<title>Passing Wrapped Struct to Python Function</title>
	<published>2009-11-10T11:56:54Z</published>
	<updated>2009-11-10T11:56:54Z</updated>
	<author>
		<name>ajayre</name>
	</author>
	<content type="html">Hi, I'm using Python 2.6 and SWIG. In my C++ code I have:
&lt;br&gt;&lt;br&gt;struct
&lt;br&gt;{
&lt;br&gt;&amp;nbsp; &amp;nbsp;unsigned long id;
&lt;br&gt;&amp;nbsp; &amp;nbsp;unsigned char data[8];
&lt;br&gt;} FOO;
&lt;br&gt;&lt;br&gt;SWIG wraps this in a proxy class so in Python I can use:
&lt;br&gt;&lt;br&gt;import MyLib
&lt;br&gt;foo = MyLib.FOO()
&lt;br&gt;&lt;br&gt;In my Python code I have a callback function that receives a FOO object:
&lt;br&gt;&lt;br&gt;def Callback(foo):
&lt;br&gt;&amp;nbsp; &amp;nbsp;print &amp;quot;%d&amp;quot; % foo.id
&lt;br&gt;&lt;br&gt;however any use of foo in the callback function causes a crash of the 
&lt;br&gt;Python interpreter. Either I just get a generic Windows error (when 
&lt;br&gt;accessing foo.id), or I get (when accessing foo.data[0]):
&lt;br&gt;&lt;br&gt;Exception SystemError: 'error return without exception set' in 'garbage 
&lt;br&gt;collection' ignored
&lt;br&gt;Fatal Python error: unexpected exception during garbage collection
&lt;br&gt;&lt;br&gt;Here is how I am calling the Python callback function, and I'm sure the 
&lt;br&gt;problem is in this area:
&lt;br&gt;&lt;br&gt;FOO foo;
&lt;br&gt;PyObject *fooobj, *args;
&lt;br&gt;foo.id = 1;
&lt;br&gt;foo.data[0] = 2;
&lt;br&gt;fooobj = SWIG_NewPointerObj(&amp;foo, SWIGTYPE_p_FOO, 1);
&lt;br&gt;args = Py_BuildValue(&amp;quot;(O)&amp;quot;, fooobj);
&lt;br&gt;PyObject_Call(CallbackFunc, args, NULL);
&lt;br&gt;&lt;br&gt;I tried allocated foo on the heap and it didn't help. Any ideas or hints 
&lt;br&gt;what I might be doing wrong?
&lt;br&gt;&lt;br&gt;thanks, Andy
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Andy
&lt;br&gt;PGP Key ID: 0xDC1B5864
&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
&lt;br&gt;trial. Simplify your report design, integration and deployment - and focus on 
&lt;br&gt;what you do best, core application coding. Discover what's new with
&lt;br&gt;Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26290541&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Passing-Wrapped-Struct-to-Python-Function-tp26290541p26290541.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26288982</id>
	<title>Re: Python Cygwin ld return 1 exit status Error</title>
	<published>2009-11-10T10:34:55Z</published>
	<updated>2009-11-10T10:34:55Z</updated>
	<author>
		<name>Josh Cherry</name>
	</author>
	<content type="html">&lt;br&gt;&lt;br&gt;On Tue, 10 Nov 2009, Govind wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; I am creating glue between Python and C using swig..
&lt;br&gt;&amp;gt; After preparing interface file, I &amp;nbsp;executed following three steps on cygwin-
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; step 1. swig -python example.i
&lt;br&gt;&amp;gt; step 2. gcc -fpic -c example.c example_wrap.c
&lt;br&gt;&amp;gt; -I/usr/local/include/python2.4/
&lt;br&gt;&amp;gt; step 3. gcc -shared example.o example_wrap.o -o _example.so
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; It successfully run first two steps.. But while executing third and
&lt;br&gt;&amp;gt; final steps..
&lt;br&gt;&amp;gt; It is displaying list of errors for undefined reference for Python
&lt;br&gt;&amp;gt; Objects.. errors listed below
&lt;/div&gt;&lt;br&gt;This suggests that under cygwin you need to link against the Python 
&lt;br&gt;library, or perhaps just give gcc some option to make it not complain 
&lt;br&gt;about missing symbols (preferable, if it works).
&lt;br&gt;&lt;br&gt;Josh
&lt;br&gt;&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
&lt;br&gt;trial. Simplify your report design, integration and deployment - and focus on 
&lt;br&gt;what you do best, core application coding. Discover what's new with
&lt;br&gt;Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26288982&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Python-Cygwin-ld-return-1-exit-status-Error-tp26279656p26288982.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26284542</id>
	<title>Re: Not getting type information from jni.h with %import (Python wrapping)</title>
	<published>2009-11-10T06:35:41Z</published>
	<updated>2009-11-10T06:35:41Z</updated>
	<author>
		<name>Antti Karanta</name>
	</author>
	<content type="html">&lt;br&gt;On Tue, 10 Nov 2009 14:21:11 +0200, David Beazley &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26284542&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;dave@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&lt;br&gt;&amp;gt; Maybe you're missing the swig -c++ option. &amp;nbsp;The warnings look like
&lt;br&gt;&amp;gt; overloaded functions.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;No. jni.h can be used from both c and c++ - there are sections separated &amp;nbsp;
&lt;br&gt;by
&lt;br&gt;&lt;br&gt;#ifdef __cplusplus
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;The lines where the warning comes from are not c++ specific. The struct &amp;nbsp;
&lt;br&gt;JNINativeInterface_ contains a huge number of function pointers, &amp;nbsp;
&lt;br&gt;essentially a c version of virtual functions. But it is valid c.
&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;If you have Java SDK installed, jni.h is located at &amp;nbsp;
&lt;br&gt;$JAVA_HOME/include/jni.h
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ::Antti::
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
&lt;br&gt;trial. Simplify your report design, integration and deployment - and focus on 
&lt;br&gt;what you do best, core application coding. Discover what's new with
&lt;br&gt;Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26284542&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Not-getting-type-information-from-jni.h-with--import-%28Python-wrapping%29-tp26279426p26284542.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26282543</id>
	<title>Re: Not getting type information from jni.h with %import (Python wrapping)</title>
	<published>2009-11-10T04:21:11Z</published>
	<updated>2009-11-10T04:21:11Z</updated>
	<author>
		<name>David Beazley-3</name>
	</author>
	<content type="html">Maybe you're missing the swig -c++ option. &amp;nbsp;The warnings look like &amp;nbsp;
&lt;br&gt;overloaded functions.
&lt;br&gt;&lt;br&gt;Cheers
&lt;br&gt;&lt;br&gt;- Dave
&lt;br&gt;&lt;br&gt;&lt;br&gt;On Nov 10, 2009, at 1:29 AM, &amp;quot;Antti Karanta&amp;quot; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26282543&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;antti.karanta@...&lt;/a&gt;&amp;gt; &amp;nbsp;
&lt;br&gt;wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Hi!
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; I'm trying to wrap some functions and global variables that use &amp;nbsp;
&lt;br&gt;&amp;gt; jni
&lt;br&gt;&amp;gt; types.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; Here's my interface file:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; %module nativelauncher
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; %import &amp;quot;jni.h&amp;quot;
&lt;br&gt;&amp;gt; %import &amp;quot;jni_md.h&amp;quot;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; %{
&lt;br&gt;&amp;gt; #include &amp;quot;jvmstarter.h&amp;quot;
&lt;br&gt;&amp;gt; %}
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; %include &amp;quot;jvmstarter.h&amp;quot;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; Here's a declaration from jvmstarter.h:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; extern jboolean _jst_debug ;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; jboolean is defined in jni.h as
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; typedef unsigned char &amp;nbsp; &amp;nbsp;jboolean;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; For some reason swig wraps this as a pointer (I would expect an &amp;nbsp;
&lt;br&gt;&amp;gt; integer
&lt;br&gt;&amp;gt; value as it's really an unsigned char):
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; import nativelauncher
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; nativelauncher.cvar._jst_debug
&lt;br&gt;&amp;gt; &amp;lt;Swig Object of type 'jboolean *' at 0x00B9A1A0&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; So I must be doing something wrong with the %import? It seems to &amp;nbsp;
&lt;br&gt;&amp;gt; me
&lt;br&gt;&amp;gt; swig
&lt;br&gt;&amp;gt; does not understand what jboolean is, i.e. it has missed the &amp;nbsp;
&lt;br&gt;&amp;gt; typedef? What
&lt;br&gt;&amp;gt; am I missing?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; Here's my command line:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; swig -python -Isource -I%JAVA_HOME%\include -I%JAVA_HOME%\include 
&lt;br&gt;&amp;gt; \win32
&lt;br&gt;&amp;gt; -outdir . -o tests/nativelauncher_wrap.c source/nativelauncher.i
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; SWIG Version 1.3.40
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ::Antti::
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; Ps. Swig gives a huge pile of warnings like this when run:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; C:\programs\Java\jdk1.6.0_16\include\jni.h(208): Warning(302): &amp;nbsp;
&lt;br&gt;&amp;gt; Identifier
&lt;br&gt;&amp;gt; 'jclass' redefined (ignored),
&lt;br&gt;&amp;gt; C:\programs\Java\jdk1.6.0_16\include\jni.h(206): Warning(302): &amp;nbsp;
&lt;br&gt;&amp;gt; previous
&lt;br&gt;&amp;gt; definition of 'jclass'.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; Here's lines 204-208:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; 204 &amp;nbsp; &amp;nbsp;jclass (JNICALL *DefineClass)
&lt;br&gt;&amp;gt; 205 &amp;nbsp; &amp;nbsp; &amp;nbsp;(JNIEnv *env, const char *name, jobject loader, const jbyte &amp;nbsp;
&lt;br&gt;&amp;gt; *buf,
&lt;br&gt;&amp;gt; 206 &amp;nbsp; &amp;nbsp; &amp;nbsp; jsize len);
&lt;br&gt;&amp;gt; 207 &amp;nbsp; &amp;nbsp;jclass (JNICALL *FindClass)
&lt;br&gt;&amp;gt; 208 &amp;nbsp; &amp;nbsp; &amp;nbsp;(JNIEnv *env, const char *name);
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; These are function pointer members in a struct, not definitions of
&lt;br&gt;&amp;gt; jclass. Something wrong with swig's parser or error reporting?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; Pps. The sources are available at
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://svn.codehaus.org/groovy/trunk/groovy/modules/native_launcher&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://svn.codehaus.org/groovy/trunk/groovy/modules/native_launcher&lt;/a&gt;&lt;br&gt;&amp;gt; (including the swig interface file).
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --- 
&lt;br&gt;&amp;gt; --- 
&lt;br&gt;&amp;gt; --- 
&lt;br&gt;&amp;gt; ---------------------------------------------------------------------
&lt;br&gt;&amp;gt; Let Crystal Reports handle the reporting - Free Crystal Reports 2008 &amp;nbsp;
&lt;br&gt;&amp;gt; 30-Day
&lt;br&gt;&amp;gt; trial. Simplify your report design, integration and deployment - and &amp;nbsp;
&lt;br&gt;&amp;gt; focus on
&lt;br&gt;&amp;gt; what you do best, core application coding. Discover what's new with
&lt;br&gt;&amp;gt; Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; Swig-user mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26282543&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;/div&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
&lt;br&gt;trial. Simplify your report design, integration and deployment - and focus on 
&lt;br&gt;what you do best, core application coding. Discover what's new with
&lt;br&gt;Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26282543&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Not-getting-type-information-from-jni.h-with--import-%28Python-wrapping%29-tp26279426p26282543.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26279656</id>
	<title>Python Cygwin ld return 1 exit status Error</title>
	<published>2009-11-09T23:58:32Z</published>
	<updated>2009-11-09T23:58:32Z</updated>
	<author>
		<name>govind@mangotechno.com</name>
	</author>
	<content type="html">Hi,
&lt;br&gt;&lt;br&gt;I am creating glue between Python and C using swig..
&lt;br&gt;After preparing interface file, I &amp;nbsp;executed following three steps on cygwin-
&lt;br&gt;&lt;br&gt;step 1. swig -python example.i 
&lt;br&gt;step 2. gcc -fpic -c example.c example_wrap.c 
&lt;br&gt;-I/usr/local/include/python2.4/
&lt;br&gt;step 3. gcc -shared example.o example_wrap.o -o _example.so
&lt;br&gt;&lt;br&gt;It successfully run first two steps.. But while executing third and 
&lt;br&gt;final steps..
&lt;br&gt;It is displaying list of errors for undefined reference for Python 
&lt;br&gt;Objects.. errors listed below
&lt;br&gt;-----------------------------------------------------------------------------------------
&lt;br&gt;example_wrap.o:example_wrap.c:(.text+0x3326): undefined reference to 
&lt;br&gt;`__imp__PyE
&lt;br&gt;xc_NameError'
&lt;br&gt;example_wrap.o:example_wrap.c:(.text+0x3330): undefined reference to 
&lt;br&gt;`_PyErr_Set
&lt;br&gt;String'
&lt;br&gt;example_wrap.o:example_wrap.c:(.text+0x33f0): undefined reference to 
&lt;br&gt;`__imp__PyT
&lt;br&gt;ype_Type'
&lt;br&gt;example_wrap.o:example_wrap.c:(.text+0x3424): undefined reference to 
&lt;br&gt;`_PyObject_
&lt;br&gt;Malloc'
&lt;br&gt;example_wrap.o:example_wrap.c:(.text+0x3430): undefined reference to 
&lt;br&gt;`_PyObject_
&lt;br&gt;Init'
&lt;br&gt;example_wrap.o:example_wrap.c:(.text+0x35f4): undefined reference to 
&lt;br&gt;`_PyDict_Se
&lt;br&gt;tItemString'
&lt;br&gt;example_wrap.o:example_wrap.c:(.text+0x38bd): undefined reference to 
&lt;br&gt;`_Py_InitMo
&lt;br&gt;dule4'
&lt;br&gt;example_wrap.o:example_wrap.c:(.text+0x38cb): undefined reference to 
&lt;br&gt;`_PyModule_
&lt;br&gt;GetDict'
&lt;br&gt;example_wrap.o:example_wrap.c:(.data+0x1a0): undefined reference to 
&lt;br&gt;`_PyObject_G
&lt;br&gt;enericGetAttr'
&lt;br&gt;collect2: ld returned 1 exit status
&lt;br&gt;&lt;br&gt;Mango_5@mango-5 /usr/local/govind/temp
&lt;br&gt;$
&lt;br&gt;----------------------------------------------------------------------------------------------
&lt;br&gt;Swig Version : 1.3.29 &amp;nbsp; &amp;nbsp;(as shown at cygwin prompt)
&lt;br&gt;Python Version : &amp;nbsp;Python2.6.4
&lt;br&gt;&lt;br&gt;&lt;br&gt;Please anyone help me or guide me to get somewhere..
&lt;br&gt;&lt;br&gt;Thanks and regards
&lt;br&gt;Govind.
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
&lt;br&gt;trial. Simplify your report design, integration and deployment - and focus on 
&lt;br&gt;what you do best, core application coding. Discover what's new with
&lt;br&gt;Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26279656&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Python-Cygwin-ld-return-1-exit-status-Error-tp26279656p26279656.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26279426</id>
	<title>Not getting type information from jni.h with %import (Python wrapping)</title>
	<published>2009-11-09T23:29:14Z</published>
	<updated>2009-11-09T23:29:14Z</updated>
	<author>
		<name>Antti Karanta</name>
	</author>
	<content type="html">&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Hi!
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;I'm trying to wrap some functions and global variables that use jni
&lt;br&gt;types.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Here's my interface file:
&lt;br&gt;&lt;br&gt;&lt;br&gt;%module nativelauncher
&lt;br&gt;&lt;br&gt;%import &amp;quot;jni.h&amp;quot;
&lt;br&gt;%import &amp;quot;jni_md.h&amp;quot;
&lt;br&gt;&lt;br&gt;%{
&lt;br&gt;#include &amp;quot;jvmstarter.h&amp;quot;
&lt;br&gt;%}
&lt;br&gt;&lt;br&gt;%include &amp;quot;jvmstarter.h&amp;quot;
&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Here's a declaration from jvmstarter.h:
&lt;br&gt;&lt;br&gt;extern jboolean _jst_debug ;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;jboolean is defined in jni.h as
&lt;br&gt;&lt;br&gt;typedef unsigned char	jboolean;
&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;For some reason swig wraps this as a pointer (I would expect an integer
&lt;br&gt;value as it's really an unsigned char):
&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; import nativelauncher
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; nativelauncher.cvar._jst_debug
&lt;br&gt;&amp;lt;Swig Object of type 'jboolean *' at 0x00B9A1A0&amp;gt;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;So I must be doing something wrong with the %import? It seems to me &amp;nbsp;
&lt;br&gt;swig
&lt;br&gt;does not understand what jboolean is, i.e. it has missed the typedef? What
&lt;br&gt;am I missing?
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Here's my command line:
&lt;br&gt;&lt;br&gt;swig -python -Isource -I%JAVA_HOME%\include -I%JAVA_HOME%\include\win32
&lt;br&gt;-outdir . -o tests/nativelauncher_wrap.c source/nativelauncher.i
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;SWIG Version 1.3.40
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;::Antti::
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;Ps. Swig gives a huge pile of warnings like this when run:
&lt;br&gt;&lt;br&gt;C:\programs\Java\jdk1.6.0_16\include\jni.h(208): Warning(302): Identifier &amp;nbsp;
&lt;br&gt;'jclass' redefined (ignored),
&lt;br&gt;C:\programs\Java\jdk1.6.0_16\include\jni.h(206): Warning(302): previous &amp;nbsp;
&lt;br&gt;definition of 'jclass'.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;Here's lines 204-208:
&lt;br&gt;&lt;br&gt;204 &amp;nbsp; &amp;nbsp;jclass (JNICALL *DefineClass)
&lt;br&gt;205 &amp;nbsp; &amp;nbsp; &amp;nbsp;(JNIEnv *env, const char *name, jobject loader, const jbyte *buf,
&lt;br&gt;206 &amp;nbsp; &amp;nbsp; &amp;nbsp; jsize len);
&lt;br&gt;207 &amp;nbsp; &amp;nbsp;jclass (JNICALL *FindClass)
&lt;br&gt;208 &amp;nbsp; &amp;nbsp; &amp;nbsp;(JNIEnv *env, const char *name);
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;These are function pointer members in a struct, not definitions of &amp;nbsp;
&lt;br&gt;jclass. Something wrong with swig's parser or error reporting?
&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;Pps. The sources are available at &amp;nbsp;
&lt;br&gt;&lt;a href=&quot;http://svn.codehaus.org/groovy/trunk/groovy/modules/native_launcher&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://svn.codehaus.org/groovy/trunk/groovy/modules/native_launcher&lt;/a&gt;&amp;nbsp; 
&lt;br&gt;(including the swig interface file).
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
&lt;br&gt;trial. Simplify your report design, integration and deployment - and focus on 
&lt;br&gt;what you do best, core application coding. Discover what's new with
&lt;br&gt;Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26279426&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Not-getting-type-information-from-jni.h-with--import-%28Python-wrapping%29-tp26279426p26279426.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26270652</id>
	<title>Re: //SWIG &lt;-&gt; Ruby - call by refrence for value types</title>
	<published>2009-11-09T09:42:29Z</published>
	<updated>2009-11-09T09:42:29Z</updated>
	<author>
		<name>Sören Freudiger-2</name>
	</author>
	<content type="html">Okay, I got it. Somehow.
&lt;br&gt;&lt;br&gt;My example.i (just for a global foo-function):
&lt;br&gt;----------------------------
&lt;br&gt;/* File : example.i */
&lt;br&gt;%module example
&lt;br&gt;%{
&lt;br&gt;#include &amp;quot;example.h&amp;quot;
&lt;br&gt;%}
&lt;br&gt;%include &amp;quot;typemaps.i&amp;quot;
&lt;br&gt;void foo(int&amp; INOUT);
&lt;br&gt;----------------------------
&lt;br&gt;&lt;br&gt;example.h
&lt;br&gt;----------------------------
&lt;br&gt;void foo(int&amp; val) { val +=10; }
&lt;br&gt;----------------------------
&lt;br&gt;&lt;br&gt;run.rb
&lt;br&gt;----------------------------
&lt;br&gt;require 'example'
&lt;br&gt;var = 7
&lt;br&gt;var = Example::foo(var)
&lt;br&gt;p var
&lt;br&gt;----------------------------
&lt;br&gt;&lt;br&gt;Works fine. Is there a way to map ALL &amp;quot;int&amp;&amp;quot; to &amp;quot;int&amp; INOUT&amp;quot; automatically?
&lt;br&gt;&lt;br&gt;Something like &amp;quot; %apply int&amp; {int&amp; INOUT)}&amp;quot;??? 
&lt;br&gt;That would simplifying the rest. Only if no INOUT is wished the interface has to be described in &amp;quot;.i&amp;quot;
&lt;br&gt;&lt;br&gt;Best,
&lt;br&gt;SirAnn
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;-----Ursprüngliche Nachricht-----
&lt;br&gt;Von: James17 [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26270652&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;james.d.masters@...&lt;/a&gt;] 
&lt;br&gt;Gesendet: Montag, 9. November 2009 16:27
&lt;br&gt;An: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26270652&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;swig-user@...&lt;/a&gt;
&lt;br&gt;Betreff: Re: [Swig-user] //SWIG &amp;lt;-&amp;gt; Ruby - call by refrence for value types
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Sören Freudiger-2 wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; --------------------
&lt;br&gt;&amp;gt; C++:
&lt;br&gt;&amp;gt; class A {
&lt;br&gt;&amp;gt; public:
&lt;br&gt;&amp;gt; &amp;nbsp;foo(int&amp; var){ var+=10;}
&lt;br&gt;&amp;gt; };
&lt;br&gt;&amp;gt; --------------------
&lt;br&gt;&amp;gt; Ruby:
&lt;br&gt;&amp;gt; var = 10
&lt;br&gt;&amp;gt; a = Example::A.new()
&lt;br&gt;&amp;gt; a.foo(var) 
&lt;br&gt;&amp;gt; --------------------
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; results in: error --&amp;gt; Expected argument 1 of type int &amp;, but got Fixnum 10
&lt;br&gt;&amp;gt; (TypeError)
&lt;br&gt;&amp;gt; 
&lt;/div&gt;&lt;br&gt;You are trying to pass an integer value when the C++ function is asking for
&lt;br&gt;an integer reference. &amp;nbsp;What to do about it probably depends upon what the
&lt;br&gt;integer is used for in the function... but it will come down to defining a
&lt;br&gt;typemap to convert a Ruby value properly.
&lt;br&gt;-- 
&lt;br&gt;View this message in context: &lt;a href=&quot;http://old.nabble.com/--SWIG-%3C-%3E-Ruby---call-by-refrence-for-value-types-tp26244076p26268232.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://old.nabble.com/--SWIG-%3C-%3E-Ruby---call-by-refrence-for-value-types-tp26244076p26268232.html&lt;/a&gt;&lt;br&gt;Sent from the swig-user mailing list archive at Nabble.com.
&lt;br&gt;&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
&lt;br&gt;trial. Simplify your report design, integration and deployment - and focus on 
&lt;br&gt;what you do best, core application coding. Discover what's new with
&lt;br&gt;Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26270652&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
&lt;br&gt;trial. Simplify your report design, integration and deployment - and focus on 
&lt;br&gt;what you do best, core application coding. Discover what's new with
&lt;br&gt;Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26270652&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/--SWIG-%3C-%3E-Ruby---call-by-refrence-for-value-types-tp26244076p26270652.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26268232</id>
	<title>Re: //SWIG &lt;-&gt; Ruby - call by refrence for value types</title>
	<published>2009-11-09T07:26:39Z</published>
	<updated>2009-11-09T07:26:39Z</updated>
	<author>
		<name>James17</name>
	</author>
	<content type="html">&lt;br&gt;&lt;blockquote class=&quot;quote light-black dark-border-color&quot;&gt;&lt;div class=&quot;quote light-border-color&quot;&gt;
&lt;div class=&quot;quote-author&quot; style=&quot;font-weight: bold;&quot;&gt;Sören Freudiger-2 wrote:&lt;/div&gt;
&lt;div class=&quot;quote-message shrinkable-quote&quot;&gt;--------------------
&lt;br&gt;C++:
&lt;br&gt;class A {
&lt;br&gt;public:
&lt;br&gt;&amp;nbsp;foo(int&amp; var){ var+=10;}
&lt;br&gt;};
&lt;br&gt;--------------------
&lt;br&gt;Ruby:
&lt;br&gt;var = 10
&lt;br&gt;a = Example::A.new()
&lt;br&gt;a.foo(var) 
&lt;br&gt;--------------------
&lt;br&gt;&lt;br&gt;results in: error --&amp;gt; Expected argument 1 of type int &amp;, but got Fixnum 10
&lt;br&gt;(TypeError)
&lt;/div&gt;
&lt;/div&gt;&lt;/blockquote&gt;
You are trying to pass an integer value when the C++ function is asking for an integer reference. &amp;nbsp;What to do about it probably depends upon what the integer is used for in the function... but it will come down to defining a typemap to convert a Ruby value properly.&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/--SWIG-%3C-%3E-Ruby---call-by-refrence-for-value-types-tp26244076p26268232.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26266138</id>
	<title>Re: freeargs typemap not being called in Tcl wrapper</title>
	<published>2009-11-09T05:04:32Z</published>
	<updated>2009-11-09T05:04:32Z</updated>
	<author>
		<name>Luis Lloret</name>
	</author>
	<content type="html">Hi,
&lt;br&gt;&lt;br&gt;yes sorry, that was as I wrote it on the mail. The original code is
&lt;br&gt;&amp;quot;freearg&amp;quot;, as it should be.
&lt;br&gt;&lt;br&gt;I have found that if I use the &amp;quot;argout&amp;quot; typemap, then I get the
&lt;br&gt;following at the end of the C function wrapper:
&lt;br&gt;{
&lt;br&gt;&amp;nbsp; &amp;nbsp; delete[] arg2;
&lt;br&gt;&amp;nbsp; }
&lt;br&gt;&amp;nbsp; return TCL_OK;
&lt;br&gt;fail:
&lt;br&gt;&amp;nbsp; return TCL_ERROR;
&lt;br&gt;&lt;br&gt;So maybe I should just use argout instead if freearg?
&lt;br&gt;&lt;br&gt;Thanks.
&lt;br&gt;&lt;br&gt;On Mon, Nov 9, 2009 at 12:25 PM, David Beazley &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26266138&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;dave@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Are you sure it's not just a typo?  The typemap is &amp;quot;freearg&amp;quot; not &amp;quot;freeargs&amp;quot;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Cheers
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; - Dave
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; On Nov 9, 2009, at 5:53 AM, Luis Lloret &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26266138&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;luislloret@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Hi,
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; I have a C function that receives a buffer and a size and uses the
&lt;br&gt;&amp;gt;&amp;gt; values in it. I am trying to get SWIG to generate a wrapper for this
&lt;br&gt;&amp;gt;&amp;gt; function in Tcl (that would pass a Tcl list, instead of a buffer +
&lt;br&gt;&amp;gt;&amp;gt; size), using the following typemaps:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; %typemap(in,numinputs=1,fragment=&amp;quot;SWIG_AsVal_unsigned_SS_int&amp;quot;) (void
&lt;br&gt;&amp;gt;&amp;gt; *src, unsigned long &amp;size) (unsigned long temp) {
&lt;br&gt;&amp;gt;&amp;gt;   int siz = 0;
&lt;br&gt;&amp;gt;&amp;gt;   int i = 0;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;   Tcl_Obj ** listobjv = NULL;
&lt;br&gt;&amp;gt;&amp;gt;   if( Tcl_ListObjGetElements(interp, $input, &amp;siz, &amp;listobjv) == TCL_ERROR
&lt;br&gt;&amp;gt;&amp;gt; )
&lt;br&gt;&amp;gt;&amp;gt;       return TCL_ERROR;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;   $1 = new unsigned char[siz];
&lt;br&gt;&amp;gt;&amp;gt;   $2 = &amp;temp;
&lt;br&gt;&amp;gt;&amp;gt;   temp = siz;
&lt;br&gt;&amp;gt;&amp;gt;   for (i = 0; i &amp;lt; siz; i++) {
&lt;br&gt;&amp;gt;&amp;gt;       int er=0;
&lt;br&gt;&amp;gt;&amp;gt;   unsigned int uintVal;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;       if( (er=SWIG_AsVal_unsigned_SS_int(interp, listobjv[i], &amp;uintVal)))
&lt;br&gt;&amp;gt;&amp;gt;       {
&lt;br&gt;&amp;gt;&amp;gt;           SWIG_Error(er,&amp;quot;list must contain ints&amp;quot;);
&lt;br&gt;&amp;gt;&amp;gt;           delete[] $1;
&lt;br&gt;&amp;gt;&amp;gt;           return TCL_ERROR;
&lt;br&gt;&amp;gt;&amp;gt;       }
&lt;br&gt;&amp;gt;&amp;gt;   else{
&lt;br&gt;&amp;gt;&amp;gt;       ((unsigned char *)($1))[i] = (unsigned char)uintVal;
&lt;br&gt;&amp;gt;&amp;gt;   }
&lt;br&gt;&amp;gt;&amp;gt;   }
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; %typemap(freeargs) void *src {
&lt;br&gt;&amp;gt;&amp;gt;     delete[] $1;
&lt;br&gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; What I do, is reserve some memory that will be passed to the C
&lt;br&gt;&amp;gt;&amp;gt; function, and populate it with the list passed from Tcl  (in the IN
&lt;br&gt;&amp;gt;&amp;gt; typemap). I then release the allocated memory in the freeargs typemap.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; The function that SWIG generates is this:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; SWIGINTERN int
&lt;br&gt;&amp;gt;&amp;gt; _wrap_iSGPIO_Put(ClientData clientData SWIGUNUSED, Tcl_Interp *interp,
&lt;br&gt;&amp;gt;&amp;gt; int objc, Tcl_Obj *CONST objv[]) {
&lt;br&gt;&amp;gt;&amp;gt;  int arg1 ;
&lt;br&gt;&amp;gt;&amp;gt;  void *arg2 = (void *) 0 ;
&lt;br&gt;&amp;gt;&amp;gt;  unsigned long *arg3 = 0 ;
&lt;br&gt;&amp;gt;&amp;gt;  bool arg4 ;
&lt;br&gt;&amp;gt;&amp;gt;  int val1 ;
&lt;br&gt;&amp;gt;&amp;gt;  int ecode1 = 0 ;
&lt;br&gt;&amp;gt;&amp;gt;  unsigned long temp2 ;
&lt;br&gt;&amp;gt;&amp;gt;  bool val4 ;
&lt;br&gt;&amp;gt;&amp;gt;  int ecode4 = 0 ;
&lt;br&gt;&amp;gt;&amp;gt;  int result;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;  if (SWIG_GetArgs(interp, objc, objv,&amp;quot;ooo:iSGPIO_Put channel src size
&lt;br&gt;&amp;gt;&amp;gt; ?wait? &amp;quot;,(void *)0,(void *)0,(void *)0) == TCL_ERROR) SWIG_fail;
&lt;br&gt;&amp;gt;&amp;gt;  ecode1 = SWIG_AsVal_int SWIG_TCL_CALL_ARGS_2(objv[1], &amp;val1);
&lt;br&gt;&amp;gt;&amp;gt;  if (!SWIG_IsOK(ecode1)) {
&lt;br&gt;&amp;gt;&amp;gt;   SWIG_exception_fail(SWIG_ArgError(ecode1), &amp;quot;in method '&amp;quot;
&lt;br&gt;&amp;gt;&amp;gt; &amp;quot;iSGPIO_Put&amp;quot; &amp;quot;', argument &amp;quot; &amp;quot;1&amp;quot;&amp;quot; of type '&amp;quot; &amp;quot;int&amp;quot;&amp;quot;'&amp;quot;);
&lt;br&gt;&amp;gt;&amp;gt;  }
&lt;br&gt;&amp;gt;&amp;gt;  arg1 = static_cast&amp;lt; int &amp;gt;(val1);
&lt;br&gt;&amp;gt;&amp;gt;  {
&lt;br&gt;&amp;gt;&amp;gt;   int siz = 0;
&lt;br&gt;&amp;gt;&amp;gt;   int i = 0;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;   Tcl_Obj ** listobjv = NULL;
&lt;br&gt;&amp;gt;&amp;gt;   if( Tcl_ListObjGetElements(interp, objv[2], &amp;siz, &amp;listobjv) ==
&lt;br&gt;&amp;gt;&amp;gt; TCL_ERROR )
&lt;br&gt;&amp;gt;&amp;gt;   return TCL_ERROR;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;   arg2 = new unsigned char[siz];
&lt;br&gt;&amp;gt;&amp;gt;   arg3 = &amp;temp2;
&lt;br&gt;&amp;gt;&amp;gt;   temp2 = siz;
&lt;br&gt;&amp;gt;&amp;gt;   for (i = 0; i &amp;lt; siz; i++) {
&lt;br&gt;&amp;gt;&amp;gt;     int er=0;
&lt;br&gt;&amp;gt;&amp;gt;     unsigned int uintVal;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;     if( (er=SWIG_AsVal_unsigned_SS_int(interp, listobjv[i], &amp;uintVal)))
&lt;br&gt;&amp;gt;&amp;gt;     {
&lt;br&gt;&amp;gt;&amp;gt;       SWIG_Error(er,&amp;quot;list must contain ints&amp;quot;);
&lt;br&gt;&amp;gt;&amp;gt;       delete[] arg2;
&lt;br&gt;&amp;gt;&amp;gt;       return TCL_ERROR;
&lt;br&gt;&amp;gt;&amp;gt;     }
&lt;br&gt;&amp;gt;&amp;gt;     else{
&lt;br&gt;&amp;gt;&amp;gt;       ((unsigned char *)(arg2))[i] = (unsigned char)uintVal;
&lt;br&gt;&amp;gt;&amp;gt;     }
&lt;br&gt;&amp;gt;&amp;gt;   }
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;  }
&lt;br&gt;&amp;gt;&amp;gt;  ecode4 = SWIG_AsVal_bool SWIG_TCL_CALL_ARGS_2(objv[3], &amp;val4);
&lt;br&gt;&amp;gt;&amp;gt;  if (!SWIG_IsOK(ecode4)) {
&lt;br&gt;&amp;gt;&amp;gt;   SWIG_exception_fail(SWIG_ArgError(ecode4), &amp;quot;in method '&amp;quot;
&lt;br&gt;&amp;gt;&amp;gt; &amp;quot;iSGPIO_Put&amp;quot; &amp;quot;', argument &amp;quot; &amp;quot;4&amp;quot;&amp;quot; of type '&amp;quot; &amp;quot;bool&amp;quot;&amp;quot;'&amp;quot;);
&lt;br&gt;&amp;gt;&amp;gt;  }
&lt;br&gt;&amp;gt;&amp;gt;  arg4 = static_cast&amp;lt; bool &amp;gt;(val4);
&lt;br&gt;&amp;gt;&amp;gt;  result = (int)iSGPIO_Put(arg1,arg2,*arg3,arg4);
&lt;br&gt;&amp;gt;&amp;gt;  Tcl_SetObjResult(interp,SWIG_From_int(static_cast&amp;lt; int &amp;gt;(result)));
&lt;br&gt;&amp;gt;&amp;gt;  return TCL_OK;
&lt;br&gt;&amp;gt;&amp;gt; fail:
&lt;br&gt;&amp;gt;&amp;gt;  return TCL_ERROR;
&lt;br&gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; So, as you can see, the freeargs typemap is not being inserted.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Am I missing something? I have read the docs, and saw nothing. Well,
&lt;br&gt;&amp;gt;&amp;gt; there is something that caught my eye and is the fact that in the Tcl
&lt;br&gt;&amp;gt;&amp;gt; docs, in the freeargs typemap, it says:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;quot;%typemap(tcl,freearg)    Cleans up a function argument (if necessary)&amp;quot;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Perhaps I am missing something about the &amp;quot;if necessary part&amp;quot;. That is
&lt;br&gt;&amp;gt;&amp;gt; not shown for other languages like Perl...
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Any help will be greatly appreciated.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Luis
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; ------------------------------------------------------------------------------
&lt;br&gt;&amp;gt;&amp;gt; Let Crystal Reports handle the reporting - Free Crystal Reports 2008
&lt;br&gt;&amp;gt;&amp;gt; 30-Day
&lt;br&gt;&amp;gt;&amp;gt; trial. Simplify your report design, integration and deployment - and focus
&lt;br&gt;&amp;gt;&amp;gt; on
&lt;br&gt;&amp;gt;&amp;gt; what you do best, core application coding. Discover what's new with
&lt;br&gt;&amp;gt;&amp;gt; Crystal Reports now.  &lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt;&amp;gt; Swig-user mailing list
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26266138&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
&lt;br&gt;trial. Simplify your report design, integration and deployment - and focus on 
&lt;br&gt;what you do best, core application coding. Discover what's new with
&lt;br&gt;Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26266138&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/freeargs-typemap-not-being-called-in-Tcl-wrapper-tp26265204p26266138.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26265641</id>
	<title>Re: freeargs typemap not being called in Tcl wrapper</title>
	<published>2009-11-09T04:25:33Z</published>
	<updated>2009-11-09T04:25:33Z</updated>
	<author>
		<name>David Beazley-3</name>
	</author>
	<content type="html">Are you sure it's not just a typo? &amp;nbsp;The typemap is &amp;quot;freearg&amp;quot; not &amp;nbsp;
&lt;br&gt;&amp;quot;freeargs&amp;quot;
&lt;br&gt;&lt;br&gt;Cheers
&lt;br&gt;&lt;br&gt;- Dave
&lt;br&gt;&lt;br&gt;&lt;br&gt;On Nov 9, 2009, at 5:53 AM, Luis Lloret &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26265641&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;luislloret@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hi,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I have a C function that receives a buffer and a size and uses the
&lt;br&gt;&amp;gt; values in it. I am trying to get SWIG to generate a wrapper for this
&lt;br&gt;&amp;gt; function in Tcl (that would pass a Tcl list, instead of a buffer +
&lt;br&gt;&amp;gt; size), using the following typemaps:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; %typemap(in,numinputs=1,fragment=&amp;quot;SWIG_AsVal_unsigned_SS_int&amp;quot;) (void
&lt;br&gt;&amp;gt; *src, unsigned long &amp;size) (unsigned long temp) {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;int siz = 0;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;int i = 0;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;Tcl_Obj ** listobjv = NULL;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;if( Tcl_ListObjGetElements(interp, $input, &amp;siz, &amp;listobjv) == &amp;nbsp;
&lt;br&gt;&amp;gt; TCL_ERROR )
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return TCL_ERROR;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;$1 = new unsigned char[siz];
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;$2 = &amp;temp;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;temp = siz;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;for (i = 0; i &amp;lt; siz; i++) {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;int er=0;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;unsigned int uintVal;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if( (er=SWIG_AsVal_unsigned_SS_int(interp, listobjv[i], &amp;nbsp;
&lt;br&gt;&amp;gt; &amp;uintVal)))
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SWIG_Error(er,&amp;quot;list must contain ints&amp;quot;);
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;delete[] $1;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return TCL_ERROR;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;else{
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;((unsigned char *)($1))[i] = (unsigned char)uintVal;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; %typemap(freeargs) void *src {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;delete[] $1;
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; What I do, is reserve some memory that will be passed to the C
&lt;br&gt;&amp;gt; function, and populate it with the list passed from Tcl &amp;nbsp;(in the IN
&lt;br&gt;&amp;gt; typemap). I then release the allocated memory in the freeargs typemap.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; The function that SWIG generates is this:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; SWIGINTERN int
&lt;br&gt;&amp;gt; _wrap_iSGPIO_Put(ClientData clientData SWIGUNUSED, Tcl_Interp *interp,
&lt;br&gt;&amp;gt; int objc, Tcl_Obj *CONST objv[]) {
&lt;br&gt;&amp;gt; &amp;nbsp;int arg1 ;
&lt;br&gt;&amp;gt; &amp;nbsp;void *arg2 = (void *) 0 ;
&lt;br&gt;&amp;gt; &amp;nbsp;unsigned long *arg3 = 0 ;
&lt;br&gt;&amp;gt; &amp;nbsp;bool arg4 ;
&lt;br&gt;&amp;gt; &amp;nbsp;int val1 ;
&lt;br&gt;&amp;gt; &amp;nbsp;int ecode1 = 0 ;
&lt;br&gt;&amp;gt; &amp;nbsp;unsigned long temp2 ;
&lt;br&gt;&amp;gt; &amp;nbsp;bool val4 ;
&lt;br&gt;&amp;gt; &amp;nbsp;int ecode4 = 0 ;
&lt;br&gt;&amp;gt; &amp;nbsp;int result;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;if (SWIG_GetArgs(interp, objc, objv,&amp;quot;ooo:iSGPIO_Put channel src size
&lt;br&gt;&amp;gt; ?wait? &amp;quot;,(void *)0,(void *)0,(void *)0) == TCL_ERROR) SWIG_fail;
&lt;br&gt;&amp;gt; &amp;nbsp;ecode1 = SWIG_AsVal_int SWIG_TCL_CALL_ARGS_2(objv[1], &amp;val1);
&lt;br&gt;&amp;gt; &amp;nbsp;if (!SWIG_IsOK(ecode1)) {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;SWIG_exception_fail(SWIG_ArgError(ecode1), &amp;quot;in method '&amp;quot;
&lt;br&gt;&amp;gt; &amp;quot;iSGPIO_Put&amp;quot; &amp;quot;', argument &amp;quot; &amp;quot;1&amp;quot;&amp;quot; of type '&amp;quot; &amp;quot;int&amp;quot;&amp;quot;'&amp;quot;);
&lt;br&gt;&amp;gt; &amp;nbsp;}
&lt;br&gt;&amp;gt; &amp;nbsp;arg1 = static_cast&amp;lt; int &amp;gt;(val1);
&lt;br&gt;&amp;gt; &amp;nbsp;{
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;int siz = 0;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;int i = 0;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;Tcl_Obj ** listobjv = NULL;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;if( Tcl_ListObjGetElements(interp, objv[2], &amp;siz, &amp;listobjv) == &amp;nbsp;
&lt;br&gt;&amp;gt; TCL_ERROR )
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;return TCL_ERROR;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;arg2 = new unsigned char[siz];
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;arg3 = &amp;temp2;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;temp2 = siz;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;for (i = 0; i &amp;lt; siz; i++) {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;int er=0;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;unsigned int uintVal;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;if( (er=SWIG_AsVal_unsigned_SS_int(interp, listobjv[i], &amp;nbsp;
&lt;br&gt;&amp;gt; &amp;uintVal)))
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;{
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SWIG_Error(er,&amp;quot;list must contain ints&amp;quot;);
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;delete[] arg2;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return TCL_ERROR;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;else{
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;((unsigned char *)(arg2))[i] = (unsigned char)uintVal;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;}
&lt;br&gt;&amp;gt; &amp;nbsp;ecode4 = SWIG_AsVal_bool SWIG_TCL_CALL_ARGS_2(objv[3], &amp;val4);
&lt;br&gt;&amp;gt; &amp;nbsp;if (!SWIG_IsOK(ecode4)) {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;SWIG_exception_fail(SWIG_ArgError(ecode4), &amp;quot;in method '&amp;quot;
&lt;br&gt;&amp;gt; &amp;quot;iSGPIO_Put&amp;quot; &amp;quot;', argument &amp;quot; &amp;quot;4&amp;quot;&amp;quot; of type '&amp;quot; &amp;quot;bool&amp;quot;&amp;quot;'&amp;quot;);
&lt;br&gt;&amp;gt; &amp;nbsp;}
&lt;br&gt;&amp;gt; &amp;nbsp;arg4 = static_cast&amp;lt; bool &amp;gt;(val4);
&lt;br&gt;&amp;gt; &amp;nbsp;result = (int)iSGPIO_Put(arg1,arg2,*arg3,arg4);
&lt;br&gt;&amp;gt; &amp;nbsp;Tcl_SetObjResult(interp,SWIG_From_int(static_cast&amp;lt; int &amp;gt;(result)));
&lt;br&gt;&amp;gt; &amp;nbsp;return TCL_OK;
&lt;br&gt;&amp;gt; fail:
&lt;br&gt;&amp;gt; &amp;nbsp;return TCL_ERROR;
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; So, as you can see, the freeargs typemap is not being inserted.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Am I missing something? I have read the docs, and saw nothing. Well,
&lt;br&gt;&amp;gt; there is something that caught my eye and is the fact that in the Tcl
&lt;br&gt;&amp;gt; docs, in the freeargs typemap, it says:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;quot;%typemap(tcl,freearg) &amp;nbsp; &amp;nbsp;Cleans up a function argument (if &amp;nbsp;
&lt;br&gt;&amp;gt; necessary)&amp;quot;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Perhaps I am missing something about the &amp;quot;if necessary part&amp;quot;. That is
&lt;br&gt;&amp;gt; not shown for other languages like Perl...
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Any help will be greatly appreciated.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Luis
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --- 
&lt;br&gt;&amp;gt; --- 
&lt;br&gt;&amp;gt; --- 
&lt;br&gt;&amp;gt; ---------------------------------------------------------------------
&lt;br&gt;&amp;gt; Let Crystal Reports handle the reporting - Free Crystal Reports 2008 &amp;nbsp;
&lt;br&gt;&amp;gt; 30-Day
&lt;br&gt;&amp;gt; trial. Simplify your report design, integration and deployment - and &amp;nbsp;
&lt;br&gt;&amp;gt; focus on
&lt;br&gt;&amp;gt; what you do best, core application coding. Discover what's new with
&lt;br&gt;&amp;gt; Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; Swig-user mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26265641&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;/div&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
&lt;br&gt;trial. Simplify your report design, integration and deployment - and focus on 
&lt;br&gt;what you do best, core application coding. Discover what's new with
&lt;br&gt;Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26265641&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/freeargs-typemap-not-being-called-in-Tcl-wrapper-tp26265204p26265641.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26265204</id>
	<title>freeargs typemap not being called in Tcl wrapper</title>
	<published>2009-11-09T03:53:56Z</published>
	<updated>2009-11-09T03:53:56Z</updated>
	<author>
		<name>Luis Lloret</name>
	</author>
	<content type="html">Hi,
&lt;br&gt;&lt;br&gt;I have a C function that receives a buffer and a size and uses the
&lt;br&gt;values in it. I am trying to get SWIG to generate a wrapper for this
&lt;br&gt;function in Tcl (that would pass a Tcl list, instead of a buffer +
&lt;br&gt;size), using the following typemaps:
&lt;br&gt;&lt;br&gt;%typemap(in,numinputs=1,fragment=&amp;quot;SWIG_AsVal_unsigned_SS_int&amp;quot;) (void
&lt;br&gt;*src, unsigned long &amp;size) (unsigned long temp) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; int siz = 0;
&lt;br&gt;&amp;nbsp; &amp;nbsp; int i = 0;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; Tcl_Obj ** listobjv = NULL;
&lt;br&gt;&amp;nbsp; &amp;nbsp; if( Tcl_ListObjGetElements(interp, $input, &amp;siz, &amp;listobjv) == TCL_ERROR )
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return TCL_ERROR;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; $1 = new unsigned char[siz];
&lt;br&gt;&amp;nbsp; &amp;nbsp; $2 = &amp;temp;
&lt;br&gt;&amp;nbsp; &amp;nbsp; temp = siz;
&lt;br&gt;&amp;nbsp; &amp;nbsp; for (i = 0; i &amp;lt; siz; i++) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int er=0;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; unsigned int uintVal;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if( (er=SWIG_AsVal_unsigned_SS_int(interp, listobjv[i], &amp;uintVal)))
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SWIG_Error(er,&amp;quot;list must contain ints&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; delete[] $1;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return TCL_ERROR;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else{
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ((unsigned char *)($1))[i] = (unsigned char)uintVal;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;}
&lt;br&gt;&lt;br&gt;%typemap(freeargs) void *src {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; delete[] $1;
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;&lt;br&gt;What I do, is reserve some memory that will be passed to the C
&lt;br&gt;function, and populate it with the list passed from Tcl &amp;nbsp;(in the IN
&lt;br&gt;typemap). I then release the allocated memory in the freeargs typemap.
&lt;br&gt;&lt;br&gt;The function that SWIG generates is this:
&lt;br&gt;&lt;br&gt;SWIGINTERN int
&lt;br&gt;_wrap_iSGPIO_Put(ClientData clientData SWIGUNUSED, Tcl_Interp *interp,
&lt;br&gt;int objc, Tcl_Obj *CONST objv[]) {
&lt;br&gt;&amp;nbsp; int arg1 ;
&lt;br&gt;&amp;nbsp; void *arg2 = (void *) 0 ;
&lt;br&gt;&amp;nbsp; unsigned long *arg3 = 0 ;
&lt;br&gt;&amp;nbsp; bool arg4 ;
&lt;br&gt;&amp;nbsp; int val1 ;
&lt;br&gt;&amp;nbsp; int ecode1 = 0 ;
&lt;br&gt;&amp;nbsp; unsigned long temp2 ;
&lt;br&gt;&amp;nbsp; bool val4 ;
&lt;br&gt;&amp;nbsp; int ecode4 = 0 ;
&lt;br&gt;&amp;nbsp; int result;
&lt;br&gt;&lt;br&gt;&amp;nbsp; if (SWIG_GetArgs(interp, objc, objv,&amp;quot;ooo:iSGPIO_Put channel src size
&lt;br&gt;?wait? &amp;quot;,(void *)0,(void *)0,(void *)0) == TCL_ERROR) SWIG_fail;
&lt;br&gt;&amp;nbsp; ecode1 = SWIG_AsVal_int SWIG_TCL_CALL_ARGS_2(objv[1], &amp;val1);
&lt;br&gt;&amp;nbsp; if (!SWIG_IsOK(ecode1)) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; SWIG_exception_fail(SWIG_ArgError(ecode1), &amp;quot;in method '&amp;quot;
&lt;br&gt;&amp;quot;iSGPIO_Put&amp;quot; &amp;quot;', argument &amp;quot; &amp;quot;1&amp;quot;&amp;quot; of type '&amp;quot; &amp;quot;int&amp;quot;&amp;quot;'&amp;quot;);
&lt;br&gt;&amp;nbsp; }
&lt;br&gt;&amp;nbsp; arg1 = static_cast&amp;lt; int &amp;gt;(val1);
&lt;br&gt;&amp;nbsp; {
&lt;br&gt;&amp;nbsp; &amp;nbsp; int siz = 0;
&lt;br&gt;&amp;nbsp; &amp;nbsp; int i = 0;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; Tcl_Obj ** listobjv = NULL;
&lt;br&gt;&amp;nbsp; &amp;nbsp; if( Tcl_ListObjGetElements(interp, objv[2], &amp;siz, &amp;listobjv) == TCL_ERROR )
&lt;br&gt;&amp;nbsp; &amp;nbsp; return TCL_ERROR;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; arg2 = new unsigned char[siz];
&lt;br&gt;&amp;nbsp; &amp;nbsp; arg3 = &amp;temp2;
&lt;br&gt;&amp;nbsp; &amp;nbsp; temp2 = siz;
&lt;br&gt;&amp;nbsp; &amp;nbsp; for (i = 0; i &amp;lt; siz; i++) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; int er=0;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; unsigned int uintVal;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if( (er=SWIG_AsVal_unsigned_SS_int(interp, listobjv[i], &amp;uintVal)))
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SWIG_Error(er,&amp;quot;list must contain ints&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; delete[] arg2;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return TCL_ERROR;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; else{
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ((unsigned char *)(arg2))[i] = (unsigned char)uintVal;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;&amp;nbsp; }
&lt;br&gt;&amp;nbsp; ecode4 = SWIG_AsVal_bool SWIG_TCL_CALL_ARGS_2(objv[3], &amp;val4);
&lt;br&gt;&amp;nbsp; if (!SWIG_IsOK(ecode4)) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; SWIG_exception_fail(SWIG_ArgError(ecode4), &amp;quot;in method '&amp;quot;
&lt;br&gt;&amp;quot;iSGPIO_Put&amp;quot; &amp;quot;', argument &amp;quot; &amp;quot;4&amp;quot;&amp;quot; of type '&amp;quot; &amp;quot;bool&amp;quot;&amp;quot;'&amp;quot;);
&lt;br&gt;&amp;nbsp; }
&lt;br&gt;&amp;nbsp; arg4 = static_cast&amp;lt; bool &amp;gt;(val4);
&lt;br&gt;&amp;nbsp; result = (int)iSGPIO_Put(arg1,arg2,*arg3,arg4);
&lt;br&gt;&amp;nbsp; Tcl_SetObjResult(interp,SWIG_From_int(static_cast&amp;lt; int &amp;gt;(result)));
&lt;br&gt;&amp;nbsp; return TCL_OK;
&lt;br&gt;fail:
&lt;br&gt;&amp;nbsp; return TCL_ERROR;
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;&lt;br&gt;So, as you can see, the freeargs typemap is not being inserted.
&lt;br&gt;&lt;br&gt;Am I missing something? I have read the docs, and saw nothing. Well,
&lt;br&gt;there is something that caught my eye and is the fact that in the Tcl
&lt;br&gt;docs, in the freeargs typemap, it says:
&lt;br&gt;&lt;br&gt;&amp;quot;%typemap(tcl,freearg)	Cleans up a function argument (if necessary)&amp;quot;
&lt;br&gt;&lt;br&gt;Perhaps I am missing something about the &amp;quot;if necessary part&amp;quot;. That is
&lt;br&gt;not shown for other languages like Perl...
&lt;br&gt;&lt;br&gt;Any help will be greatly appreciated.
&lt;br&gt;&lt;br&gt;Luis
&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
&lt;br&gt;trial. Simplify your report design, integration and deployment - and focus on 
&lt;br&gt;what you do best, core application coding. Discover what's new with
&lt;br&gt;Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26265204&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/freeargs-typemap-not-being-called-in-Tcl-wrapper-tp26265204p26265204.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26261091</id>
	<title>Double-Free memory C++-Lua</title>
	<published>2009-11-08T20:14:09Z</published>
	<updated>2009-11-08T20:14:09Z</updated>
	<author>
		<name>Vedran Pogacnik</name>
	</author>
	<content type="html">Hi All,
&lt;br&gt;&lt;br&gt;I have a custom type that I'm trying to use as an argument to a function:
&lt;br&gt;&lt;br&gt;typedef struct
&lt;br&gt;{
&lt;br&gt;} foo_t;
&lt;br&gt;&lt;br&gt;inside a function that takes in foo_t** type of argument.
&lt;br&gt;&lt;br&gt;Inside the wrapper template, I put the following line
&lt;br&gt;&lt;br&gt;%apply SWIGTYPE** OUTPUT &amp;nbsp; { foo_t** &amp;nbsp;};
&lt;br&gt;&lt;br&gt;Everything runs fine, but when I exit the program -- normally --
&lt;br&gt;(through the expected call for program exit), then I get a
&lt;br&gt;double-free/memory corruption error:
&lt;br&gt;&lt;br&gt;*** glibc detected *** &amp;lt;executable&amp;gt; : double free or corruption
&lt;br&gt;(fasttop): 0x09738ea8 ***
&lt;br&gt;&lt;br&gt;Does anyone know what am I doing wrong, or why is this happening?
&lt;br&gt;&lt;br&gt;Thanks,
&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Vedran Pogacnik
&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
&lt;br&gt;trial. Simplify your report design, integration and deployment - and focus on 
&lt;br&gt;what you do best, core application coding. Discover what's new with
&lt;br&gt;Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26261091&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Double-Free-memory-C%2B%2B-Lua-tp26261091p26261091.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26259420</id>
	<title>Re: SWIG &quot;multiply defined&quot; error on C header file</title>
	<published>2009-11-08T15:53:09Z</published>
	<updated>2009-11-08T15:53:09Z</updated>
	<author>
		<name>Evan Klitzke-4</name>
	</author>
	<content type="html">On Sat, Nov 7, 2009 at 11:24 AM, Josh Cherry &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26259420&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;jcherry@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; On Thu, 5 Nov 2009, Evan Klitzke wrote:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; I then tried compiling this using swig, but get an error like so:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; [evan@t500 py (master)]$ swig -python cldc.i
&lt;br&gt;&amp;gt;&amp;gt; ../include/cldc.h:33: Error: 'cldc_call_opts_u_get' is multiply
&lt;br&gt;&amp;gt;&amp;gt; defined in the generated module.
&lt;br&gt;&amp;gt;&amp;gt; ../include/cldc.h:28: Error: Previous declaration of
&lt;br&gt;&amp;gt;&amp;gt; 'cldc_call_opts_u_get'
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Everything I've found online about the meaning of this error is
&lt;br&gt;&amp;gt;&amp;gt; discussing SWIG bindings to C++ code, where a method/function is
&lt;br&gt;&amp;gt;&amp;gt; defined in multiple namespaces, which isn't the case here -- this is
&lt;br&gt;&amp;gt;&amp;gt; vanilla C code. I think that SWIG is choking on the the header file
&lt;br&gt;&amp;gt;&amp;gt; which is valid, but I'm not confident enough with my SWIG knowledge to
&lt;br&gt;&amp;gt;&amp;gt; say for sure.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; For reference, I'm using SWIG 1.3.40, and I've pastebinned the cldc.h
&lt;br&gt;&amp;gt;&amp;gt; file at &lt;a href=&quot;http://paste.pocoo.org/show/148964/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://paste.pocoo.org/show/148964/&lt;/a&gt;&amp;nbsp;. The git repo for the
&lt;br&gt;&amp;gt;&amp;gt; project (just clone git://git.kernel.org/pub/scm/daemon/cld/cld.git )
&lt;br&gt;&amp;gt;&amp;gt; is pretty small if you want to test it out yourself.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; It may have to do with the fact that you have a data member named &amp;quot;get&amp;quot;.
&lt;br&gt;&amp;gt; SWIG would generate a low-level Python function called cldc_call_opts_u_get
&lt;br&gt;&amp;gt; for accessing cldc_call_opts.u, and this might conflict internally with
&lt;br&gt;&amp;gt; cldc_call_opts.u.  Just a wild guess.
&lt;/div&gt;&lt;br&gt;Thanks Josh, this was exactly the problem. I plan on reporting this to
&lt;br&gt;the swig-developers list.
&lt;br&gt;-- 
&lt;br&gt;Evan Klitzke &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26259420&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;evan@...&lt;/a&gt;&amp;gt; :wq
&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
&lt;br&gt;trial. Simplify your report design, integration and deployment - and focus on 
&lt;br&gt;what you do best, core application coding. Discover what's new with
&lt;br&gt;Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26259420&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/SWIG-%22multiply-defined%22-error-on-C-header-file-tp26226947p26259420.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26247817</id>
	<title>Re: SWIG &quot;multiply defined&quot; error on C header file</title>
	<published>2009-11-07T11:24:48Z</published>
	<updated>2009-11-07T11:24:48Z</updated>
	<author>
		<name>Josh Cherry</name>
	</author>
	<content type="html">&lt;br&gt;&lt;br&gt;On Thu, 5 Nov 2009, Evan Klitzke wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; I then tried compiling this using swig, but get an error like so:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; [evan@t500 py (master)]$ swig -python cldc.i
&lt;br&gt;&amp;gt; ../include/cldc.h:33: Error: 'cldc_call_opts_u_get' is multiply
&lt;br&gt;&amp;gt; defined in the generated module.
&lt;br&gt;&amp;gt; ../include/cldc.h:28: Error: Previous declaration of 'cldc_call_opts_u_get'
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Everything I've found online about the meaning of this error is
&lt;br&gt;&amp;gt; discussing SWIG bindings to C++ code, where a method/function is
&lt;br&gt;&amp;gt; defined in multiple namespaces, which isn't the case here -- this is
&lt;br&gt;&amp;gt; vanilla C code. I think that SWIG is choking on the the header file
&lt;br&gt;&amp;gt; which is valid, but I'm not confident enough with my SWIG knowledge to
&lt;br&gt;&amp;gt; say for sure.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; For reference, I'm using SWIG 1.3.40, and I've pastebinned the cldc.h
&lt;br&gt;&amp;gt; file at &lt;a href=&quot;http://paste.pocoo.org/show/148964/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://paste.pocoo.org/show/148964/&lt;/a&gt;&amp;nbsp;. The git repo for the
&lt;br&gt;&amp;gt; project (just clone git://git.kernel.org/pub/scm/daemon/cld/cld.git )
&lt;br&gt;&amp;gt; is pretty small if you want to test it out yourself.
&lt;/div&gt;&lt;br&gt;It may have to do with the fact that you have a data member named &amp;quot;get&amp;quot;. 
&lt;br&gt;SWIG would generate a low-level Python function 
&lt;br&gt;called cldc_call_opts_u_get for accessing cldc_call_opts.u, and this might 
&lt;br&gt;conflict internally with cldc_call_opts.u. &amp;nbsp;Just a wild guess.
&lt;br&gt;&lt;br&gt;Josh
&lt;br&gt;&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
&lt;br&gt;trial. Simplify your report design, integration and deployment - and focus on 
&lt;br&gt;what you do best, core application coding. Discover what's new with
&lt;br&gt;Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26247817&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/SWIG-%22multiply-defined%22-error-on-C-header-file-tp26226947p26247817.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26244076</id>
	<title>//SWIG &lt;-&gt; Ruby - call by refrence for value types</title>
	<published>2009-11-07T03:17:00Z</published>
	<updated>2009-11-07T03:17:00Z</updated>
	<author>
		<name>Sören Freudiger-2</name>
	</author>
	<content type="html">Hi @all
&lt;br&gt;I'm pretty new to SWIG and Ruby and have a question.
&lt;br&gt;&lt;br&gt;--------------------
&lt;br&gt;C++:
&lt;br&gt;class A {
&lt;br&gt;public:
&lt;br&gt;&amp;nbsp;foo(int&amp; var){ var+=10;}
&lt;br&gt;};
&lt;br&gt;--------------------
&lt;br&gt;&lt;br&gt;--------------------
&lt;br&gt;Ruby:
&lt;br&gt;var = 10
&lt;br&gt;a = Example::A.new()
&lt;br&gt;a.foo(var) 
&lt;br&gt;--------------------
&lt;br&gt;&lt;br&gt;results in: error --&amp;gt; Expected argument 1 of type int &amp;, but got Fixnum 10
&lt;br&gt;(TypeError)
&lt;br&gt;&lt;br&gt;How can I fix that problem. Our C++ code I have to write a ruby interface
&lt;br&gt;for uses a huge number of methods like that...
&lt;br&gt;&lt;br&gt;Best regards,
&lt;br&gt;SirAnn
&lt;br&gt;&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
&lt;br&gt;trial. Simplify your report design, integration and deployment - and focus on 
&lt;br&gt;what you do best, core application coding. Discover what's new with
&lt;br&gt;Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26244076&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/--SWIG-%3C-%3E-Ruby---call-by-refrence-for-value-types-tp26244076p26244076.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26243972</id>
	<title>//SWIG &lt;-&gt; Ruby - call by refrence for value types</title>
	<published>2009-11-07T03:14:58Z</published>
	<updated>2009-11-07T03:14:58Z</updated>
	<author>
		<name>Sören Freudiger-2</name>
	</author>
	<content type="html">Hi @all
&lt;br&gt;I'm pretty new to SWIG and Ruby and have a question.
&lt;br&gt;&lt;br&gt;--------------------
&lt;br&gt;C++:
&lt;br&gt;class A {
&lt;br&gt;public:
&lt;br&gt;&amp;nbsp;foo(int&amp; var){ var+=10;}
&lt;br&gt;};
&lt;br&gt;--------------------
&lt;br&gt;&lt;br&gt;--------------------
&lt;br&gt;Ruby:
&lt;br&gt;var = 10
&lt;br&gt;a = Example::A.new()
&lt;br&gt;a.foo(var) 
&lt;br&gt;--------------------
&lt;br&gt;&lt;br&gt;results in: error --&amp;gt; Expected argument 1 of type int &amp;, but got Fixnum 10
&lt;br&gt;(TypeError)
&lt;br&gt;&lt;br&gt;How can I fix that problem. Our C++ code I have to write a ruby interface
&lt;br&gt;for uses a huge number of methods like that...
&lt;br&gt;&lt;br&gt;Best regards,
&lt;br&gt;SirAnn
&lt;br&gt;&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
&lt;br&gt;trial. Simplify your report design, integration and deployment - and focus on 
&lt;br&gt;what you do best, core application coding. Discover what's new with
&lt;br&gt;Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26243972&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/--SWIG-%3C-%3E-Ruby---call-by-refrence-for-value-types-tp26243972p26243972.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26226947</id>
	<title>SWIG &quot;multiply defined&quot; error on C header file</title>
	<published>2009-11-05T19:42:33Z</published>
	<updated>2009-11-05T19:42:33Z</updated>
	<author>
		<name>Evan Klitzke-4</name>
	</author>
	<content type="html">Hi all,
&lt;br&gt;&lt;br&gt;I'm trying to write a Python binding, using SWIG, to CLD
&lt;br&gt;(&lt;a href=&quot;http://hail.wiki.kernel.org/index.php/CLD&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://hail.wiki.kernel.org/index.php/CLD&lt;/a&gt;). I was hoping to start
&lt;br&gt;with the &amp;quot;truly lazy&amp;quot; approach described on the SWIG tutorial, and
&lt;br&gt;started with a trivial interface file like this:
&lt;br&gt;&lt;br&gt;%module cldc
&lt;br&gt;%{
&lt;br&gt;#define SWIG_FILE_WITH_INIT
&lt;br&gt;#include &amp;quot;../include/cldc.h&amp;quot;
&lt;br&gt;%}
&lt;br&gt;%include &amp;quot;../include/cldc.h&amp;quot;
&lt;br&gt;&lt;br&gt;I then tried compiling this using swig, but get an error like so:
&lt;br&gt;&lt;br&gt;[evan@t500 py (master)]$ swig -python cldc.i
&lt;br&gt;../include/cldc.h:33: Error: 'cldc_call_opts_u_get' is multiply
&lt;br&gt;defined in the generated module.
&lt;br&gt;../include/cldc.h:28: Error: Previous declaration of 'cldc_call_opts_u_get'
&lt;br&gt;&lt;br&gt;Everything I've found online about the meaning of this error is
&lt;br&gt;discussing SWIG bindings to C++ code, where a method/function is
&lt;br&gt;defined in multiple namespaces, which isn't the case here -- this is
&lt;br&gt;vanilla C code. I think that SWIG is choking on the the header file
&lt;br&gt;which is valid, but I'm not confident enough with my SWIG knowledge to
&lt;br&gt;say for sure.
&lt;br&gt;&lt;br&gt;For reference, I'm using SWIG 1.3.40, and I've pastebinned the cldc.h
&lt;br&gt;file at &lt;a href=&quot;http://paste.pocoo.org/show/148964/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://paste.pocoo.org/show/148964/&lt;/a&gt;&amp;nbsp;. The git repo for the
&lt;br&gt;project (just clone git://git.kernel.org/pub/scm/daemon/cld/cld.git )
&lt;br&gt;is pretty small if you want to test it out yourself.
&lt;br&gt;&lt;br&gt;Thanks!
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Evan Klitzke &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26226947&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;evan@...&lt;/a&gt;&amp;gt; :wq
&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
&lt;br&gt;trial. Simplify your report design, integration and deployment - and focus on 
&lt;br&gt;what you do best, core application coding. Discover what's new with
&lt;br&gt;Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26226947&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/SWIG-%22multiply-defined%22-error-on-C-header-file-tp26226947p26226947.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26202842</id>
	<title>SWIG &amp; Tcl: %newobject ignored?</title>
	<published>2009-11-04T11:06:52Z</published>
	<updated>2009-11-04T11:06:52Z</updated>
	<author>
		<name>Georgios Petasis-2</name>
	</author>
	<content type="html">Hi all,
&lt;br&gt;&lt;br&gt;For some reason swig 1.3.41 seems to ignore the &amp;quot;%newbject foo;&amp;quot; feature 
&lt;br&gt;(and its equivalent %feature(&amp;quot;new&amp;quot;, &amp;quot;1&amp;quot;) foo;), which seems strange. 
&lt;br&gt;This is because I looked insto Source/Modules/tcl8.cxx and the code 
&lt;br&gt;seems to check the &amp;quot;wrap:new&amp;quot; feature, and act accordingly. The code in 
&lt;br&gt;tcl8.cxx seems ok, why I don't see the results in the produced wrapper?
&lt;br&gt;&lt;br&gt;George
&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
&lt;br&gt;trial. Simplify your report design, integration and deployment - and focus on 
&lt;br&gt;what you do best, core application coding. Discover what's new with
&lt;br&gt;Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26202842&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/SWIG---Tcl%3A--newobject-ignored--tp26202842p26202842.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26195894</id>
	<title>Re: Can this be done with SWIG? - [BUG in Tcl generator?]</title>
	<published>2009-11-04T04:54:23Z</published>
	<updated>2009-11-04T04:54:23Z</updated>
	<author>
		<name>Georgios Petasis-2</name>
	</author>
	<content type="html">O/H Georgios Petasis έγραψε:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hi all,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I have a simple class:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; %nodefaultctor nsIDOMHTMLCollection;
&lt;br&gt;&amp;gt; %nodefaultdtor nsIDOMHTMLCollection;
&lt;br&gt;&amp;gt; class nsIDOMHTMLCollection {
&lt;br&gt;&amp;gt; public:
&lt;br&gt;&amp;gt; &amp;nbsp;void Release &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(void);
&lt;br&gt;&amp;gt; &amp;nbsp;void Item &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (PRUint32 index, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;nsIDOMNode **OUTPUT);
&lt;br&gt;&amp;gt; &amp;nbsp;void NamedItem &amp;nbsp; &amp;nbsp;(const nsAString &amp;name, nsIDOMNode **OUTPUT);
&lt;br&gt;&amp;gt; }; /* nsIDOMHTMLCollection */
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; %nodefaultdtor nsIDOMNode;
&lt;br&gt;&amp;gt; class nsIDOMNode {
&lt;br&gt;&amp;gt; &amp;nbsp;void Release(void);
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; What I want to do:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; 1) Tell SWIG that the arguments &amp;quot;nsIDOMNode **OUTPUT&amp;quot; are actually the 
&lt;br&gt;&amp;gt; return values of the methods Item &amp; NamedItem, and that the returned 
&lt;br&gt;&amp;gt; value is actually a new allocated pointer. I can do this with the 
&lt;br&gt;&amp;gt; following:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; %typemap(in, numinputs=0) &amp;nbsp;nsIDOMNode **OUTPUT(nsIDOMNode *temp) {
&lt;br&gt;&amp;gt; &amp;nbsp; $1 = &amp;temp;
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt; %typemap(argout) nsIDOMNode **OUTPUT {
&lt;br&gt;&amp;gt; &amp;nbsp;Tcl_SetObjResult(interp, SWIG_NewInstanceObj(
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SWIG_as_voidptr(*($1)), SWIGTYPE_p_nsIDOMNode, 1));
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt; %newobject nsIDOMHTMLCollection::Item;
&lt;br&gt;&amp;gt; %newobject nsIDOMHTMLCollection::NamedItem;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; 2) I want to tell SWIG to delete nsIDOMNode * by calling Release(). 
&lt;br&gt;&amp;gt; How can I do this?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; If I enable the default destructor, swig always uses delete on the 
&lt;br&gt;&amp;gt; object. How can I change that, and actually call Release() ?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thanks,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; George
&lt;/div&gt;&lt;br&gt;Is it possible the Tcl wrapper generator to have a bug?
&lt;br&gt;I tried the following:
&lt;br&gt;&lt;br&gt;%nodefaultctor nsIDOMHTMLCollection;
&lt;br&gt;%feature(&amp;quot;action&amp;quot;) nsIDOMHTMLCollection::~nsIDOMHTMLCollection {
&lt;br&gt;&amp;nbsp; arg1-&amp;gt;MyRelease();
&lt;br&gt;}
&lt;br&gt;class nsIDOMHTMLCollection {
&lt;br&gt;public:
&lt;br&gt;&amp;nbsp; nref AddRef &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (void);
&lt;br&gt;&amp;nbsp; nref Release &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(void);
&lt;br&gt;&amp;nbsp; void Item &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (PRUint32 index, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;nsIDOMNode **OUTPUT);
&lt;br&gt;&amp;nbsp; void NamedItem &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(const nsAString &amp;name, nsIDOMNode **OUTPUT);
&lt;br&gt;&amp;nbsp; void GetLength &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(PRUint32 *OUTPUT);
&lt;br&gt;}; /* nsIDOMHTMLCollection */
&lt;br&gt;&lt;br&gt;The wrapper was generated just fine (i.e. 
&lt;br&gt;_wrap_delete_nsIDOMHTMLCollection calls MyRelease()),
&lt;br&gt;but the class destructor is still:
&lt;br&gt;&lt;br&gt;SWIGINTERN void swig_delete_nsIDOMHTMLCollection(void *obj) {
&lt;br&gt;nsIDOMHTMLCollection *arg1 = (nsIDOMHTMLCollection *) obj;
&lt;br&gt;delete arg1;
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;Is this what I am supposed to get?
&lt;br&gt;&lt;br&gt;Regards,
&lt;br&gt;&lt;br&gt;George
&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
&lt;br&gt;trial. Simplify your report design, integration and deployment - and focus on 
&lt;br&gt;what you do best, core application coding. Discover what's new with
&lt;br&gt;Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26195894&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Can-this-be-done-with-SWIG--tp26188870p26195894.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26188870</id>
	<title>Can this be done with SWIG?</title>
	<published>2009-11-03T15:32:46Z</published>
	<updated>2009-11-03T15:32:46Z</updated>
	<author>
		<name>Georgios Petasis-2</name>
	</author>
	<content type="html">Hi all,
&lt;br&gt;&lt;br&gt;I have a simple class:
&lt;br&gt;&lt;br&gt;%nodefaultctor nsIDOMHTMLCollection;
&lt;br&gt;%nodefaultdtor nsIDOMHTMLCollection;
&lt;br&gt;class nsIDOMHTMLCollection {
&lt;br&gt;public:
&lt;br&gt;&amp;nbsp; void Release &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(void);
&lt;br&gt;&amp;nbsp; void Item &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (PRUint32 index, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;nsIDOMNode **OUTPUT);
&lt;br&gt;&amp;nbsp; void NamedItem &amp;nbsp; &amp;nbsp;(const nsAString &amp;name, nsIDOMNode **OUTPUT);
&lt;br&gt;}; /* nsIDOMHTMLCollection */
&lt;br&gt;&lt;br&gt;%nodefaultdtor nsIDOMNode;
&lt;br&gt;class nsIDOMNode {
&lt;br&gt;&amp;nbsp; void Release(void);
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;What I want to do:
&lt;br&gt;&lt;br&gt;1) Tell SWIG that the arguments &amp;quot;nsIDOMNode **OUTPUT&amp;quot; are actually the 
&lt;br&gt;return values of the methods Item &amp; NamedItem, and that the returned 
&lt;br&gt;value is actually a new allocated pointer. I can do this with the following:
&lt;br&gt;&lt;br&gt;%typemap(in, numinputs=0) &amp;nbsp;nsIDOMNode **OUTPUT(nsIDOMNode *temp) {
&lt;br&gt;&amp;nbsp; &amp;nbsp;$1 = &amp;temp;
&lt;br&gt;}
&lt;br&gt;%typemap(argout) nsIDOMNode **OUTPUT {
&lt;br&gt;&amp;nbsp; Tcl_SetObjResult(interp, SWIG_NewInstanceObj(
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SWIG_as_voidptr(*($1)), SWIGTYPE_p_nsIDOMNode, 1));
&lt;br&gt;}
&lt;br&gt;%newobject nsIDOMHTMLCollection::Item;
&lt;br&gt;%newobject nsIDOMHTMLCollection::NamedItem;
&lt;br&gt;&lt;br&gt;2) I want to tell SWIG to delete nsIDOMNode * by calling Release(). How 
&lt;br&gt;can I do this?
&lt;br&gt;&lt;br&gt;If I enable the default destructor, swig always uses delete on the 
&lt;br&gt;object. How can I change that, and actually call Release() ?
&lt;br&gt;&lt;br&gt;Thanks,
&lt;br&gt;&lt;br&gt;George
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
&lt;br&gt;trial. Simplify your report design, integration and deployment - and focus on 
&lt;br&gt;what you do best, core application coding. Discover what's new with
&lt;br&gt;Crystal Reports now. &amp;nbsp;&lt;a href=&quot;http://p.sf.net/sfu/bobj-july&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/bobj-july&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26188870&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Can-this-be-done-with-SWIG--tp26188870p26188870.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26187160</id>
	<title>Re: Temporarily disable std_vector.i?</title>
	<published>2009-11-03T13:35:10Z</published>
	<updated>2009-11-03T13:35:10Z</updated>
	<author>
		<name>Josh Cherry</name>
	</author>
	<content type="html">&lt;br&gt;&lt;br&gt;On Tue, 3 Nov 2009, Russell E. Owen wrote:
&lt;br&gt;&lt;br&gt;&amp;gt; There are two problems:
&lt;br&gt;&amp;gt; - The warning is wrong. The constructors are all available, despite
&lt;br&gt;&amp;gt; SWIG's claim that one has been shadowed. Clearly something is wrong (see
&lt;br&gt;&amp;gt; next item), but it is more subtle. &amp;nbsp;Both conversions and all the
&lt;br&gt;&amp;gt; constructors work as expected.
&lt;br&gt;&lt;br&gt;Here's my understanding of what's happening. &amp;nbsp;Every type conversion has a 
&lt;br&gt;precedence (many defined in swig.swg). &amp;nbsp;These are used in cases of 
&lt;br&gt;overloading to decide what order to use when looking for a matching 
&lt;br&gt;signature. &amp;nbsp;If two types have the same precedence (e.g., two vectors), 
&lt;br&gt;what should SWIG do? &amp;nbsp;It generates code to use both, but one must come 
&lt;br&gt;first. &amp;nbsp;It might be that the same input argument could match either check, 
&lt;br&gt;and it would be arbitrary which signature got called. &amp;nbsp;SWIG can't know, so 
&lt;br&gt;it issues a warning. &amp;nbsp;Perhaps the warning is poorly worded, but other than 
&lt;br&gt;that I'm not sure what behavior would be preferable.
&lt;br&gt;&lt;br&gt;&amp;gt; - The resulting library is not safe. It is easy to cause an abort, as
&lt;br&gt;&amp;gt; shown by the commented-out portions of the code.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I don't really understand the latter problem, since clearly SWIG does
&lt;br&gt;&amp;gt; some type checking when it walks through a list. If one fixes the
&lt;br&gt;&amp;gt; problem as per my previous email then SWIG will properly reject a list
&lt;br&gt;&amp;gt; of mixed values.
&lt;br&gt;&lt;br&gt;It's not clear to me that this is related. &amp;nbsp;SWIG should check all of the 
&lt;br&gt;list members, but the handling of this has gone though various changes. 
&lt;br&gt;Why not check whether it has anything to do with overloading?
&lt;br&gt;&lt;br&gt;As a work-around, you can use %pythonprepend to stop bad stuff from 
&lt;br&gt;happening.
&lt;br&gt;&lt;br&gt;Josh
&lt;br&gt;&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Come build with us! The BlackBerry(R) Developer Conference in SF, CA
&lt;br&gt;is the only developer event you need to attend this year. Jumpstart your
&lt;br&gt;developing skills, take BlackBerry mobile applications to market and stay 
&lt;br&gt;ahead of the curve. Join us from November 9 - 12, 2009. Register now!
&lt;br&gt;&lt;a href=&quot;http://p.sf.net/sfu/devconference&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/devconference&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26187160&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Temporarily-disable-std_vector.i--tp26119470p26187160.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26186253</id>
	<title>Re: Temporarily disable std_vector.i?</title>
	<published>2009-11-03T12:34:43Z</published>
	<updated>2009-11-03T12:34:43Z</updated>
	<author>
		<name>Russell E. Owen-4</name>
	</author>
	<content type="html">In article 
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26186253&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Pine.LNX.4.64.0911022004380.15130@...&lt;/a&gt;&amp;gt;,
&lt;br&gt;&amp;nbsp;Josh Cherry &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26186253&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;jcherry@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&lt;br&gt;&amp;gt; On Mon, 2 Nov 2009, Russell Owen wrote:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;gt; When I build it I get a warning about a shadowed method (see appended
&lt;br&gt;&amp;gt; &amp;gt; log). But when I run the test code it works as desired.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I'm not sure what the problem is. &amp;nbsp;It sounds like you're just getting a 
&lt;br&gt;&amp;gt; harmless warning (which I would expect, since the two conversions have the 
&lt;br&gt;&amp;gt; same &amp;quot;priority&amp;quot;).
&lt;br&gt;&lt;br&gt;There are two problems:
&lt;br&gt;- The warning is wrong. The constructors are all available, despite 
&lt;br&gt;SWIG's claim that one has been shadowed. Clearly something is wrong (see 
&lt;br&gt;next item), but it is more subtle. &amp;nbsp;Both conversions and all the 
&lt;br&gt;constructors work as expected.
&lt;br&gt;- The resulting library is not safe. It is easy to cause an abort, as 
&lt;br&gt;shown by the commented-out portions of the code.
&lt;br&gt;&lt;br&gt;I don't really understand the latter problem, since clearly SWIG does 
&lt;br&gt;some type checking when it walks through a list. If one fixes the 
&lt;br&gt;problem as per my previous email then SWIG will properly reject a list 
&lt;br&gt;of mixed values.
&lt;br&gt;&lt;br&gt;-- Russell
&lt;br&gt;&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Come build with us! The BlackBerry(R) Developer Conference in SF, CA
&lt;br&gt;is the only developer event you need to attend this year. Jumpstart your
&lt;br&gt;developing skills, take BlackBerry mobile applications to market and stay 
&lt;br&gt;ahead of the curve. Join us from November 9 - 12, 2009. Register now!
&lt;br&gt;&lt;a href=&quot;http://p.sf.net/sfu/devconference&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/devconference&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26186253&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Temporarily-disable-std_vector.i--tp26119470p26186253.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26181016</id>
	<title>Swig and sys.stdout</title>
	<published>2009-11-03T07:00:38Z</published>
	<updated>2009-11-03T07:00:38Z</updated>
	<author>
		<name>Mads Ipsen-3</name>
	</author>
	<content type="html">Hi,
&lt;br&gt;&lt;br&gt;This is my first post to this list, so I apologize if my posting is 
&lt;br&gt;misplaced.
&lt;br&gt;&lt;br&gt;We are using swig to wrap C++ to Python, and need to redirect stdout to 
&lt;br&gt;a GUI based log window. However, calls to printf or cout are not caught 
&lt;br&gt;by Pythons sys.stdout.
&lt;br&gt;&lt;br&gt;Any known solutions to this issue?
&lt;br&gt;&lt;br&gt;Best regards,
&lt;br&gt;&lt;br&gt;Mads
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;+-------------------------------------------------------------+
&lt;br&gt;| Mads Ipsen, Scientific developer &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|
&lt;br&gt;+-------------------------------+-----------------------------+
&lt;br&gt;| QuantumWise A/S &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | phone: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; +45-29716388 |
&lt;br&gt;| Nørre Søgade 27A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| www: &amp;nbsp; &amp;nbsp;www.quantumwise.com |
&lt;br&gt;| DK-1370 Copenhagen K, Denmark | email: &amp;nbsp;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26181016&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;mpi@...&lt;/a&gt; |
&lt;br&gt;+-------------------------------+-----------------------------+
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Come build with us! The BlackBerry(R) Developer Conference in SF, CA
&lt;br&gt;is the only developer event you need to attend this year. Jumpstart your
&lt;br&gt;developing skills, take BlackBerry mobile applications to market and stay 
&lt;br&gt;ahead of the curve. Join us from November 9 - 12, 2009. Register now!
&lt;br&gt;&lt;a href=&quot;http://p.sf.net/sfu/devconference&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/devconference&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26181016&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Swig-and-sys.stdout-tp26181016p26181016.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26175931</id>
	<title>Re: Problems with shared_ptr and Python</title>
	<published>2009-11-02T23:43:27Z</published>
	<updated>2009-11-02T23:43:27Z</updated>
	<author>
		<name>andreas.held</name>
	</author>
	<content type="html">Hi William
&lt;br&gt;&lt;br&gt;This is my interface file boost_example.i:
&lt;br&gt;%module example
&lt;br&gt;&amp;nbsp;
&lt;br&gt;// For plain classes, do not use for derived classes
&lt;br&gt;%include &amp;quot;boost_shared_ptr.i&amp;quot;
&lt;br&gt;MY_SWIG_SHARED_PTR(Foo, Foo)
&lt;br&gt;&lt;br&gt;struct Foo {};
&lt;br&gt;void test1(shared_ptr&amp;lt;Foo&amp;gt; f) {}
&lt;br&gt;void test2(boost::shared_ptr&amp;lt;Foo&amp;gt; f) {}
&lt;br&gt;&lt;br&gt;-----------------------------------------------------------
&lt;br&gt;&lt;br&gt;My command line:
&lt;br&gt;&lt;br&gt;$ swig -c++ -python boost_example.i 
&lt;br&gt;boost_example.i(6): Error: Syntax error in input(1).
&lt;br&gt;&lt;br&gt;I do get the same results whether I run the command from a MSYS shell or from the Windows Power Shell, obviously, both on Windows (XP to be accurate).
&lt;br&gt;&lt;br&gt;Finally, the version I am using:
&lt;br&gt;$ swig -version
&lt;br&gt;&lt;br&gt;SWIG Version 1.3.40
&lt;br&gt;&lt;br&gt;Compiled with i586-mingw32msvc-g++ [i686-pc-linux-gnu]
&lt;br&gt;Please see &lt;a href=&quot;http://www.swig.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.swig.org&lt;/a&gt;&amp;nbsp;for reporting bugs and further information
&lt;br&gt;&lt;br&gt;&lt;br&gt;Best regards and thanks for your help.
&lt;br&gt;&lt;br&gt;Andreas
&lt;br&gt;---- William S Fulton &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26175931&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;wsf@...&lt;/a&gt;&amp;gt; schrieb:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26175931&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;andreas.held@...&lt;/a&gt; wrote:
&lt;br&gt;&amp;gt; &amp;gt; Hi William
&lt;br&gt;&amp;gt; &amp;gt; 
&lt;br&gt;&amp;gt; &amp;gt; Thank you for your quick reply. Sorry for my mistake in the command line. As you pointed out, the correct command line should be:
&lt;br&gt;&amp;gt; &amp;gt; swig -c++ -python example.i
&lt;br&gt;&amp;gt; &amp;gt; 
&lt;br&gt;&amp;gt; &amp;gt; Still, even with that command line I do get the same error. I now stronly suspect that something is wrong with my boost installation. 
&lt;br&gt;&amp;gt; It is impossible for SWIG to be affected by your boost installation 
&lt;br&gt;&amp;gt; unless you tell it to via an include path (the -I option). However, 
&lt;br&gt;&amp;gt; there might be a problem when your c++ compiler compiles the generated 
&lt;br&gt;&amp;gt; code, as that will then use your boost installation.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;gt; Anyway, I have now found a way around my problem by using
&lt;br&gt;&amp;gt; &amp;gt; %template
&lt;br&gt;&amp;gt; &amp;gt; 
&lt;br&gt;&amp;gt; I don't know what you are doing wrong, but the SWIG_SHARED_PTR macro 
&lt;br&gt;&amp;gt; invokes the %template directive for you. I think you need to post your 
&lt;br&gt;&amp;gt; non-working example again.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; William
&lt;/div&gt;&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Come build with us! The BlackBerry(R) Developer Conference in SF, CA
&lt;br&gt;is the only developer event you need to attend this year. Jumpstart your
&lt;br&gt;developing skills, take BlackBerry mobile applications to market and stay 
&lt;br&gt;ahead of the curve. Join us from November 9 - 12, 2009. Register now!
&lt;br&gt;&lt;a href=&quot;http://p.sf.net/sfu/devconference&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/devconference&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26175931&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Problems-with-shared_ptr-and-Python-tp26112643p26175931.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26173514</id>
	<title>Re: Temporarily disable std_vector.i?</title>
	<published>2009-11-02T17:06:17Z</published>
	<updated>2009-11-02T17:06:17Z</updated>
	<author>
		<name>Josh Cherry</name>
	</author>
	<content type="html">&lt;br&gt;&lt;br&gt;On Mon, 2 Nov 2009, Russell Owen wrote:
&lt;br&gt;&lt;br&gt;&amp;gt; When I build it I get a warning about a shadowed method (see appended
&lt;br&gt;&amp;gt; log). But when I run the test code it works as desired.
&lt;br&gt;&lt;br&gt;I'm not sure what the problem is. &amp;nbsp;It sounds like you're just getting a 
&lt;br&gt;harmless warning (which I would expect, since the two conversions have the 
&lt;br&gt;same &amp;quot;priority&amp;quot;).
&lt;br&gt;&lt;br&gt;Josh
&lt;br&gt;&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Come build with us! The BlackBerry(R) Developer Conference in SF, CA
&lt;br&gt;is the only developer event you need to attend this year. Jumpstart your
&lt;br&gt;developing skills, take BlackBerry mobile applications to market and stay 
&lt;br&gt;ahead of the curve. Join us from November 9 - 12, 2009. Register now!
&lt;br&gt;&lt;a href=&quot;http://p.sf.net/sfu/devconference&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/devconference&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26173514&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Temporarily-disable-std_vector.i--tp26119470p26173514.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26173307</id>
	<title>Re: Temporarily disable std_vector.i?</title>
	<published>2009-11-02T16:17:54Z</published>
	<updated>2009-11-02T16:17:54Z</updated>
	<author>
		<name>Russell E. Owen-4</name>
	</author>
	<content type="html">In article &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26173307&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;4AEDF6C0.1070902@...&lt;/a&gt;&amp;gt;,
&lt;br&gt;&amp;nbsp;William S Fulton &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26173307&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;wsf@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&lt;br&gt;&lt;br&gt;On Nov 1, 2009, at 12:59 PM, William S Fulton wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Russell E. Owen wrote:
&lt;br&gt;&amp;gt; &amp;gt; I am having some issues with shadowed constructors that I think are caused 
&lt;br&gt;&amp;gt; &amp;gt; by 
&lt;br&gt;&amp;gt; &amp;gt; using std_vector.i
&lt;br&gt;&amp;gt; &amp;gt; Some of our classes have multiple constructors such as this:
&lt;br&gt;&amp;gt; &amp;gt; Foo::Foo(std::vector&amp;lt;double&amp;gt; &amp;values)
&lt;br&gt;&amp;gt; &amp;gt; Foo::Foo(std::vector&amp;lt;boost::shared_ptr&amp;lt;FancyClass&amp;gt; &amp;gt; &amp;fancyClasses)
&lt;br&gt;&amp;gt; &amp;gt; and our SWIG file wraps the class Foo and also wraps the arguments as so:
&lt;br&gt;&amp;gt; &amp;gt; %template(VectorDouble) std::vector&amp;lt;double&amp;gt;;
&lt;br&gt;&amp;gt; &amp;gt; %template(VectorFancyClass)std::vector&amp;lt;boost::shared_ptr&amp;lt;FancyClass&amp;gt; &amp;gt;;
&lt;br&gt;&amp;gt; &amp;gt; SWIG complains that the latter constructor is shadowed by the former.
&lt;br&gt;&amp;gt; &amp;gt; As far as I can tell this is because both std::vector&amp;lt;double&amp;gt; and 
&lt;br&gt;&amp;gt; &amp;gt; std::vector&amp;lt;boost::shared_ptr&amp;lt;some fancyclass&amp;gt; &amp;gt; have been templated after 
&lt;br&gt;&amp;gt; &amp;gt; including std_vector.i. Thus SWIG is trying to support all of the following 
&lt;br&gt;&amp;gt; &amp;gt; forms of Foo constructor:
&lt;br&gt;&amp;gt; &amp;gt; 1) an explicitly constructed VectorDouble
&lt;br&gt;&amp;gt; &amp;gt; 2) a python list of doubles (due to std_vector.i and much appreciated)
&lt;br&gt;&amp;gt; &amp;gt; 3) an explicitly constructed VectorFancyClass
&lt;br&gt;&amp;gt; &amp;gt; 4) a python list of FancyClasses (due to std_vector.i and not necessary)
&lt;br&gt;&amp;gt; &amp;gt; and the two python list versions (2 and 4) are colliding with each other.
&lt;br&gt;&amp;gt; &amp;gt; I suspect that both Foo constructors are actually available, and that only 
&lt;br&gt;&amp;gt; &amp;gt; case (4) is unavailable. If so, we can live with it. But I would rather 
&lt;br&gt;&amp;gt; &amp;gt; explicitly disable std_vector.i for VectorFancyClass if there is some easy 
&lt;br&gt;&amp;gt; &amp;gt; way to do this.
&lt;br&gt;&amp;gt; &amp;gt; I realize I could just include std_vector.i at the very end, but that 
&lt;br&gt;&amp;gt; &amp;gt; happens 
&lt;br&gt;&amp;gt; &amp;gt; to be a headache due to the way we're including it right now (in a common 
&lt;br&gt;&amp;gt; &amp;gt; .i 
&lt;br&gt;&amp;gt; &amp;gt; file shared by all others -- maybe that is a mistake).
&lt;br&gt;&amp;gt; &amp;gt; Anyone have any suggestions?
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I don't see why SWIG is doing this and I can't replicate this problem. I 
&lt;br&gt;&amp;gt; suggest you post a complete standalone example demonstrating it...
&lt;/div&gt;&lt;br&gt;Here is my example (slightly longer than you requested, but short 
&lt;br&gt;enough, I trust, to serve)
&lt;br&gt;&lt;br&gt;*** swigtest.h ***
&lt;br&gt;&lt;br&gt;#include &amp;lt;iostream&amp;gt;
&lt;br&gt;#include &amp;lt;vector&amp;gt;
&lt;br&gt;&lt;br&gt;namespace test {
&lt;br&gt;&amp;nbsp; &amp;nbsp;class Bar {
&lt;br&gt;&amp;nbsp; &amp;nbsp;public:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;explicit Bar::Bar(int val=0) : intVal(val) {};
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;int intVal;
&lt;br&gt;&amp;nbsp; &amp;nbsp;};
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;class Foo {
&lt;br&gt;&amp;nbsp; &amp;nbsp;public:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;explicit Foo::Foo(std::vector&amp;lt;int&amp;gt; const &amp;intVec) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;std::cout &amp;lt;&amp;lt; &amp;quot;Foo(&amp;quot;;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for (size_t ind = 0; ind &amp;lt; intVec.size(); ++ind)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;std::cout &amp;lt;&amp;lt; intVec[ind] &amp;lt;&amp;lt; &amp;quot;, &amp;quot;;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;std::cout &amp;lt;&amp;lt; &amp;quot;) constructor&amp;quot; &amp;lt;&amp;lt; std::endl;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;explicit Foo::Foo(std::vector&amp;lt;Bar&amp;gt; const &amp;barVec) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;std::cout &amp;lt;&amp;lt; &amp;quot;Foo(&amp;quot;;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for (size_t ind = 0; ind &amp;lt; barVec.size(); ++ind)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;std::cout &amp;lt;&amp;lt; &amp;quot;Bar(&amp;quot; &amp;lt;&amp;lt; barVec[ind].intVal &amp;lt;&amp;lt; &amp;quot;), &amp;quot;;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;std::cout &amp;lt;&amp;lt; &amp;quot;) constructor&amp;quot; &amp;lt;&amp;lt; std::endl;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp;};
&lt;br&gt;&lt;br&gt;}
&lt;br&gt;&lt;br&gt;*** swigtest.i ***
&lt;br&gt;&lt;br&gt;%module swigtest
&lt;br&gt;%{
&lt;br&gt;#include &amp;quot;swigtest.h&amp;quot;
&lt;br&gt;%}
&lt;br&gt;&lt;br&gt;%include &amp;quot;std_vector.i&amp;quot;
&lt;br&gt;%template(IntVec) std::vector&amp;lt;int&amp;gt;;
&lt;br&gt;%template(BarVec) std::vector&amp;lt;test::Bar&amp;gt;;
&lt;br&gt;%include &amp;quot;swigtest.h&amp;quot;
&lt;br&gt;&lt;br&gt;&lt;br&gt;*** runtest.py ***
&lt;br&gt;&lt;br&gt;#!/usr/bin/env python
&lt;br&gt;# run swigtest
&lt;br&gt;&lt;br&gt;import swigtest
&lt;br&gt;&lt;br&gt;# these should work
&lt;br&gt;iv = swigtest.IntVec()
&lt;br&gt;iv.append(1)
&lt;br&gt;iv.append(2)
&lt;br&gt;iv.append(3)
&lt;br&gt;swigtest.Foo(iv)
&lt;br&gt;&lt;br&gt;swigtest.Foo([1, 2, 3])
&lt;br&gt;&lt;br&gt;bv = swigtest.BarVec()
&lt;br&gt;bv.append(swigtest.Bar(1))
&lt;br&gt;bv.append(swigtest.Bar(2))
&lt;br&gt;bv.append(swigtest.Bar(3))
&lt;br&gt;swigtest.Foo(bv)
&lt;br&gt;&lt;br&gt;swigtest.Foo([swigtest.Bar(1), swigtest.Bar(2), swigtest.Bar(3)])
&lt;br&gt;&lt;br&gt;# this is commented out because it aborts or send Foo garbage
&lt;br&gt;# it may or may not be relevant to the problem being discussed
&lt;br&gt;# I suspect the abort or garbage is a swig bug in any case
&lt;br&gt;#swigtest.Foo([1, 2, swigtest.Bar(3)])
&lt;br&gt;#swigtest.Foo([swigtest.Bar(1), swigtest.Bar(2), 3])
&lt;br&gt;&lt;br&gt;When I build it I get a warning about a shadowed method (see appended 
&lt;br&gt;log). But when I run the test code it works as desired.
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;I also found that if I simply move the swigtest.i line:
&lt;br&gt;%template(BarVec) std::vector&amp;lt;test::Bar&amp;gt;;
&lt;br&gt;after the line:
&lt;br&gt;%include &amp;quot;swigtest.h&amp;quot;
&lt;br&gt;then the problem goes away (though one can no longer provide a plain 
&lt;br&gt;python list of Bar). Also it solves the problem from the commented-out 
&lt;br&gt;lines of the test code: instead of aborting or sending Foo garbage, swig 
&lt;br&gt;correctly detects the mixed type list and rejects it!
&lt;br&gt;&lt;br&gt;I would prefer a solution that allows a plain list of Bar and correctly 
&lt;br&gt;rejects lists of mixed types. But barring such a solution, simply 
&lt;br&gt;templating the list of Bar at the end will do.
&lt;br&gt;&lt;br&gt;-- Russell
&lt;br&gt;&lt;br&gt;*** Log ***
&lt;br&gt;&lt;br&gt;rowen:swigtest rowen$ swig -o swigtest_wrap.cc -c++ -python 
&lt;br&gt;-I/Users/rowen/lsst_home/DarwinX86/external/boost/1.37.0/include 
&lt;br&gt;-I/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 
&lt;br&gt;-I/Library/include swigtest.i
&lt;br&gt;swigtest.h:24: Warning(509): Overloaded method 
&lt;br&gt;test::Foo::Foo(std::vector&amp;lt; test::Bar,std::allocator&amp;lt; test::Bar &amp;gt; &amp;gt; 
&lt;br&gt;const &amp;) is shadowed by test::Foo::Foo(std::vector&amp;lt; int,std::allocator&amp;lt; 
&lt;br&gt;int &amp;gt; &amp;gt; const &amp;) at swigtest.h:18.
&lt;br&gt;&lt;br&gt;rowen:swigtest rowen$ g++ -o swigtest_wrap.os -c -g -Wall -O3 
&lt;br&gt;-DLSST_HAVE_TR1=1 -DLSST_LITTLE_ENDIAN=1 -fno-strict-aliasing -fPIC 
&lt;br&gt;-I/Users/rowen/lsst_home/DarwinX86/external/boost/1.37.0/include 
&lt;br&gt;-I/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 
&lt;br&gt;-I/Library/include swigtest_wrap.cc
&lt;br&gt;swigtest_wrap.cc: In member function swig::PySequence_Ref&amp;lt;T&amp;gt;::operator 
&lt;br&gt;T() const [with T = int]:
&lt;br&gt;swigtest_wrap.cc:3133: warning: v may be used uninitialized in this 
&lt;br&gt;function
&lt;br&gt;&lt;br&gt;rowen:swigtest rowen$ g++ -o _swigtest.so &amp;nbsp;-bundle -undefined suppress 
&lt;br&gt;-flat_namespace swigtest_wrap.os 
&lt;br&gt;-L/Users/rowen/lsst_home/DarwinX86/external/boost/1.37.0/lib 
&lt;br&gt;-L/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/config
&lt;br&gt;&lt;br&gt;rowen:afw-1000 rowen$ swig -version
&lt;br&gt;&lt;br&gt;SWIG Version 1.3.36
&lt;br&gt;&lt;br&gt;Compiled with g++ [i386-apple-darwin9.4.0]
&lt;br&gt;Please see &lt;a href=&quot;http://www.swig.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.swig.org&lt;/a&gt;&amp;nbsp;for reporting bugs and further information
&lt;br&gt;&lt;br&gt;rowen:swigtest rowen$ ./runtest.py
&lt;br&gt;Foo(1, 2, 3, ) constructor
&lt;br&gt;Foo(1, 2, 3, ) constructor
&lt;br&gt;Foo(Bar(1), Bar(2), Bar(3), ) constructor
&lt;br&gt;Foo(Bar(1), Bar(2), Bar(3), ) constructor
&lt;br&gt;&lt;br&gt;P.S. sorry if this is a duplicate; my reply to the mailing list has not 
&lt;br&gt;yet appeared on gmane. Even if it is a duplicate, this version has 
&lt;br&gt;additional information.
&lt;br&gt;&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Come build with us! The BlackBerry(R) Developer Conference in SF, CA
&lt;br&gt;is the only developer event you need to attend this year. Jumpstart your
&lt;br&gt;developing skills, take BlackBerry mobile applications to market and stay 
&lt;br&gt;ahead of the curve. Join us from November 9 - 12, 2009. Register now!
&lt;br&gt;&lt;a href=&quot;http://p.sf.net/sfu/devconference&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/devconference&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26173307&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Temporarily-disable-std_vector.i--tp26119470p26173307.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26173453</id>
	<title>Re: Temporarily disable std_vector.i?</title>
	<published>2009-11-02T13:33:10Z</published>
	<updated>2009-11-02T13:33:10Z</updated>
	<author>
		<name>Russell E. Owen-4</name>
	</author>
	<content type="html">&lt;br&gt;On Nov 1, 2009, at 12:59 PM, William S Fulton wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Russell E. Owen wrote:
&lt;br&gt;&amp;gt;&amp;gt; (Sorry if this is a duplicate; the first attempt didn't show up &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; here).
&lt;br&gt;&amp;gt;&amp;gt; I am having some issues with shadowed constructors that I think are &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; caused by using std_vector.i
&lt;br&gt;&amp;gt;&amp;gt; Some of our classes have multiple constructors such as this:
&lt;br&gt;&amp;gt;&amp;gt; Foo::Foo(std::vector&amp;lt;double&amp;gt; &amp;values)
&lt;br&gt;&amp;gt;&amp;gt; Foo::Foo(std::vector&amp;lt;boost::shared_ptr&amp;lt;FancyClass&amp;gt; &amp;gt; &amp;fancyClasses)
&lt;br&gt;&amp;gt;&amp;gt; and our SWIG file wraps the class Foo and also wraps the arguments &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; as so:
&lt;br&gt;&amp;gt;&amp;gt; %template(VectorDouble) std::vector&amp;lt;double&amp;gt;;
&lt;br&gt;&amp;gt;&amp;gt; %template 
&lt;br&gt;&amp;gt;&amp;gt; (VectorFancyClass)std::vector&amp;lt;boost::shared_ptr&amp;lt;FancyClass&amp;gt; &amp;gt;;
&lt;br&gt;&amp;gt;&amp;gt; SWIG complains that the latter constructor is shadowed by the former.
&lt;br&gt;&amp;gt;&amp;gt; As far as I can tell this is because both std::vector&amp;lt;double&amp;gt; and &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; std::vector&amp;lt;boost::shared_ptr&amp;lt;some fancyclass&amp;gt; &amp;gt; have been &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; templated after including std_vector.i. Thus SWIG is trying to &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; support all of the following forms of Foo constructor:
&lt;br&gt;&amp;gt;&amp;gt; 1) an explicitly constructed VectorDouble
&lt;br&gt;&amp;gt;&amp;gt; 2) a python list of doubles (due to std_vector.i and much &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; appreciated)
&lt;br&gt;&amp;gt;&amp;gt; 3) an explicitly constructed VectorFancyClass
&lt;br&gt;&amp;gt;&amp;gt; 4) a python list of FancyClasses (due to std_vector.i and not &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; necessary)
&lt;br&gt;&amp;gt;&amp;gt; and the two python list versions (2 and 4) are colliding with each &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; other.
&lt;br&gt;&amp;gt;&amp;gt; I suspect that both Foo constructors are actually available, and &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; that only case (4) is unavailable. If so, we can live with it. But &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; I would rather explicitly disable std_vector.i for VectorFancyClass &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; if there is some easy way to do this.
&lt;br&gt;&amp;gt;&amp;gt; I realize I could just include std_vector.i at the very end, but &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; that happens to be a headache due to the way we're including it &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; right now (in a common .i file shared by all others -- maybe that &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; is a mistake).
&lt;br&gt;&amp;gt;&amp;gt; Anyone have any suggestions?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I don't see why SWIG is doing this and I can't replicate this &amp;nbsp;
&lt;br&gt;&amp;gt; problem. I suggest you post a complete standalone example &amp;nbsp;
&lt;br&gt;&amp;gt; demonstrating it...
&lt;/div&gt;&lt;br&gt;Here is my example (slightly longer than you requested, but short &amp;nbsp;
&lt;br&gt;enough, I trust, to serve):
&lt;br&gt;&lt;br&gt;*** swigtest.h ***
&lt;br&gt;&lt;br&gt;#include &amp;lt;iostream&amp;gt;
&lt;br&gt;#include &amp;lt;vector&amp;gt;
&lt;br&gt;&lt;br&gt;namespace test {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;class Bar {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;public:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;explicit Bar::Bar(int val=0) : intVal(val) {};
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;int intVal;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;};
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;class Foo {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;public:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;explicit Foo::Foo(std::vector&amp;lt;int&amp;gt; const &amp;intVec) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;std::cout &amp;lt;&amp;lt; &amp;quot;Foo(&amp;quot;;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for (size_t ind = 0; ind &amp;lt; intVec.size(); ++ind)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;std::cout &amp;lt;&amp;lt; intVec[ind] &amp;lt;&amp;lt; &amp;quot;, &amp;quot;;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;std::cout &amp;lt;&amp;lt; &amp;quot;) constructor&amp;quot; &amp;lt;&amp;lt; std::endl;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;explicit Foo::Foo(std::vector&amp;lt;Bar&amp;gt; const &amp;barVec) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;std::cout &amp;lt;&amp;lt; &amp;quot;Foo(&amp;quot;;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for (size_t ind = 0; ind &amp;lt; barVec.size(); ++ind)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;std::cout &amp;lt;&amp;lt; &amp;quot;Bar(&amp;quot; &amp;lt;&amp;lt; barVec[ind].intVal &amp;lt;&amp;lt; &amp;quot;), &amp;quot;;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;std::cout &amp;lt;&amp;lt; &amp;quot;) constructor&amp;quot; &amp;lt;&amp;lt; std::endl;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;};
&lt;br&gt;&lt;br&gt;}
&lt;br&gt;&lt;br&gt;*** swigtest.i ***
&lt;br&gt;&lt;br&gt;%module swigtest
&lt;br&gt;%{
&lt;br&gt;#include &amp;quot;swigtest.h&amp;quot;
&lt;br&gt;%}
&lt;br&gt;&lt;br&gt;%include &amp;quot;std_vector.i&amp;quot;
&lt;br&gt;%template(IntVec) std::vector&amp;lt;int&amp;gt;;
&lt;br&gt;%template(BarVec) std::vector&amp;lt;test::Bar&amp;gt;;
&lt;br&gt;%include &amp;quot;swigtest.h&amp;quot;
&lt;br&gt;&lt;br&gt;&lt;br&gt;*** runtest.py ***
&lt;br&gt;&lt;br&gt;#!/usr/bin/env python
&lt;br&gt;# run swigtest
&lt;br&gt;&lt;br&gt;import swigtest
&lt;br&gt;&lt;br&gt;# these should work
&lt;br&gt;iv = swigtest.IntVec()
&lt;br&gt;iv.append(1)
&lt;br&gt;iv.append(2)
&lt;br&gt;iv.append(3)
&lt;br&gt;swigtest.Foo(iv)
&lt;br&gt;&lt;br&gt;swigtest.Foo([1, 2, 3])
&lt;br&gt;&lt;br&gt;bv = swigtest.BarVec()
&lt;br&gt;bv.append(swigtest.Bar(1))
&lt;br&gt;bv.append(swigtest.Bar(2))
&lt;br&gt;bv.append(swigtest.Bar(3))
&lt;br&gt;swigtest.Foo(bv)
&lt;br&gt;&lt;br&gt;swigtest.Foo([swigtest.Bar(1), swigtest.Bar(2), swigtest.Bar(3)])
&lt;br&gt;&lt;br&gt;# these do horrible things, but that is not relevant to the problem &amp;nbsp;
&lt;br&gt;being discussed:
&lt;br&gt;#swigtest.Foo([1, 2, swigtest.Bar(3)])
&lt;br&gt;#swigtest.Foo([swigtest.Bar(1), swigtest.Bar(2), 3])
&lt;br&gt;&lt;br&gt;When I build it I get a warning about a shadowed method (see appended &amp;nbsp;
&lt;br&gt;log). But when I run the test code it works as desired.
&lt;br&gt;&lt;br&gt;-- Russell
&lt;br&gt;&lt;br&gt;*** Log ***
&lt;br&gt;&lt;br&gt;rowen:swigtest rowen$ swig -o swigtest_wrap.cc -c++ -python -I/Users/ 
&lt;br&gt;rowen/lsst_home/DarwinX86/external/boost/1.37.0/include -I/Library/ 
&lt;br&gt;Frameworks/Python.framework/Versions/2.5/include/python2.5 -I/Library/ 
&lt;br&gt;include swigtest.i
&lt;br&gt;swigtest.h:24: Warning(509): Overloaded method &amp;nbsp;
&lt;br&gt;test::Foo::Foo(std::vector&amp;lt; test::Bar,std::allocator&amp;lt; test::Bar &amp;gt; &amp;gt; &amp;nbsp;
&lt;br&gt;const &amp;) is shadowed by test::Foo::Foo(std::vector&amp;lt; &amp;nbsp;
&lt;br&gt;int,std::allocator&amp;lt; int &amp;gt; &amp;gt; const &amp;) at swigtest.h:18.
&lt;br&gt;&lt;br&gt;rowen:swigtest rowen$ g++ -o swigtest_wrap.os -c -g -Wall -O3 - 
&lt;br&gt;DLSST_HAVE_TR1=1 -DLSST_LITTLE_ENDIAN=1 -fno-strict-aliasing -fPIC -I/ 
&lt;br&gt;Users/rowen/lsst_home/DarwinX86/external/boost/1.37.0/include -I/ 
&lt;br&gt;Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -I/ 
&lt;br&gt;Library/include swigtest_wrap.cc
&lt;br&gt;swigtest_wrap.cc: In member function &amp;nbsp;
&lt;br&gt;‘swig::PySequence_Ref&amp;lt;T&amp;gt;::operator T() const [with T = int]’:
&lt;br&gt;swigtest_wrap.cc:3133: warning: ‘v’ may be used uninitialized in this &amp;nbsp;
&lt;br&gt;function
&lt;br&gt;&lt;br&gt;rowen:swigtest rowen$ g++ -o _swigtest.so &amp;nbsp;-bundle -undefined suppress &amp;nbsp;
&lt;br&gt;-flat_namespace swigtest_wrap.os -L/Users/rowen/lsst_home/DarwinX86/ 
&lt;br&gt;external/boost/1.37.0/lib -L/Library/Frameworks/Python.framework/ 
&lt;br&gt;Versions/2.5/lib/python2.5/config
&lt;br&gt;&lt;br&gt;rowen:afw-1000 rowen$ swig -version
&lt;br&gt;&lt;br&gt;SWIG Version 1.3.36
&lt;br&gt;&lt;br&gt;Compiled with g++ [i386-apple-darwin9.4.0]
&lt;br&gt;Please see &lt;a href=&quot;http://www.swig.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.swig.org&lt;/a&gt;&amp;nbsp;for reporting bugs and further &amp;nbsp;
&lt;br&gt;information
&lt;br&gt;&lt;br&gt;rowen:swigtest rowen$ ./runtest.py
&lt;br&gt;Foo(1, 2, 3, ) constructor
&lt;br&gt;Foo(1, 2, 3, ) constructor
&lt;br&gt;Foo(Bar(1), Bar(2), Bar(3), ) constructor
&lt;br&gt;Foo(Bar(1), Bar(2), Bar(3), ) constructor
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Come build with us! The BlackBerry(R) Developer Conference in SF, CA
&lt;br&gt;is the only developer event you need to attend this year. Jumpstart your
&lt;br&gt;developing skills, take BlackBerry mobile applications to market and stay 
&lt;br&gt;ahead of the curve. Join us from November 9 - 12, 2009. Register now!
&lt;br&gt;&lt;a href=&quot;http://p.sf.net/sfu/devconference&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/devconference&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26173453&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Temporarily-disable-std_vector.i--tp26119470p26173453.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26167621</id>
	<title>Re: Embed perl and multi-threading (Re: segmentation fault	in event-driven library wrapped with swig)</title>
	<published>2009-11-02T09:22:08Z</published>
	<updated>2009-11-02T09:22:08Z</updated>
	<author>
		<name>Steve Chan-2</name>
	</author>
	<content type="html">-----BEGIN PGP SIGNED MESSAGE-----
&lt;br&gt;Hash: SHA1
&lt;br&gt;&lt;br&gt;Sri,
&lt;br&gt;&amp;nbsp; &amp;nbsp; I suspect you are asking the wrong forum about this.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; This sounds like a perl specific issue with embedded perl and
&lt;br&gt;multithreading. You could check through the groups at
&lt;br&gt;&lt;a href=&quot;http://www.nntp.perl.org/group/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.nntp.perl.org/group/&lt;/a&gt;&amp;nbsp;and see if anyone there has experience
&lt;br&gt;with multithreaded embedded perl.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; Steve
&lt;br&gt;&lt;br&gt;Sri wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hi all,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; In digging further into this, I feel that the pthread_getspecific()
&lt;br&gt;&amp;gt; functions are not finding the perl interpreter instance
&lt;br&gt;&amp;gt; corresponding to the thread in my library. &amp;nbsp;I guess its because I
&lt;br&gt;&amp;gt; havent really created one yet? To test if this was the cause, I
&lt;br&gt;&amp;gt; modified my SWIG_Wrap_bsa_disc_callback method to create a new
&lt;br&gt;&amp;gt; perl-interpreter when my_perl is NULL and the crash is now occuring
&lt;br&gt;&amp;gt; at the call_sv. &amp;nbsp;I realize its not the right way to do it, but not
&lt;br&gt;&amp;gt; sure exactly the steps required. &amp;nbsp;I think the solution likely
&lt;br&gt;&amp;gt; involves my library thread creating a interpreter instance and
&lt;br&gt;&amp;gt; saving relevant data (what is relevant?) via pthread_setspecific
&lt;br&gt;&amp;gt; method/SET_CONTEXT().
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Would be great if anyone can shed some light or confirm if I'm on
&lt;br&gt;&amp;gt; the right track.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thx
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; void SWIG_Wrap_bsa_disc_callback(int event, tMy_MSG *p_data) { int
&lt;br&gt;&amp;gt; new_perl = 0; printf(&amp;quot;entering perl callback handler...\n&amp;quot;); dTHX;
&lt;br&gt;&amp;gt; printf(&amp;quot;dTHX done...\n&amp;quot;);
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; if ( my_perl != NULL ) printf (&amp;quot;my_perl == %ul\n&amp;quot;, my_perl); else {
&lt;br&gt;&amp;gt; &amp;nbsp;printf (&amp;quot;my_perl was NULL\n&amp;quot;); my_perl = perl_alloc();
&lt;br&gt;&amp;gt; PERL_SET_CONTEXT(my_perl); new_perl = 1; } /* printf(&amp;quot;Destruct
&lt;br&gt;&amp;gt; level : %d...\n&amp;quot;, PL_perl_destruct_level); */ dSP; printf(&amp;quot;DSP
&lt;br&gt;&amp;gt; done...\n&amp;quot;); SV * sv = bsa_perl_disc_callback; if (sv == (SV*)NULL)
&lt;br&gt;&amp;gt; &amp;nbsp;croak(&amp;quot;Internal error...\n&amp;quot;);
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; printf(&amp;quot;Preparing to call perl callback...\n&amp;quot;); PUSHMARK(SP);
&lt;br&gt;&amp;gt; XPUSHs(sv_2mortal(newSViv(event))); printf(&amp;quot;newSViv of %d
&lt;br&gt;&amp;gt; done...\n&amp;quot;, event);
&lt;br&gt;&amp;gt; XPUSHs(SWIG_NewPointerObj(SWIG_as_voidptr(p_data),
&lt;br&gt;&amp;gt; SWIGTYPE_p_tMy_MSG, SWIG_SHADOW)); /* XPUSHs(sv_2mortal(newSVsv((SV
&lt;br&gt;&amp;gt; *)p_data))); */ printf(&amp;quot;newSVsv...\n&amp;quot;); PUTBACK;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; printf(&amp;quot;calling the Perl sub...\n&amp;quot;); /* Call the Perl sub */
&lt;br&gt;&amp;gt; call_sv(sv, G_DISCARD); printf(&amp;quot;Perl sub completed
&lt;br&gt;&amp;gt; successfully...\n&amp;quot;);
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; if ( new_perl ) perl_free(my_perl); }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --- On Fri, 10/30/09, Sri &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26167621&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;w2learn@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; From: Sri &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26167621&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;w2learn@...&lt;/a&gt;&amp;gt; Subject: segmentation fault in
&lt;br&gt;&amp;gt;&amp;gt; event-driven library wrapped with swig To:
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26167621&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;swig-user@...&lt;/a&gt; Date: Friday, October 30, 2009,
&lt;br&gt;&amp;gt;&amp;gt; 8:35 PM Hello SWIG, perl experts:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; With good help from swig-users posts &amp; Stephen Chan in
&lt;br&gt;&amp;gt;&amp;gt; particular, I've figured out how to wrap a C event-driven library
&lt;br&gt;&amp;gt;&amp;gt; with SWIG. &amp;nbsp;SWIG is really nice tool! &amp;nbsp;I'm able to call APIs and
&lt;br&gt;&amp;gt;&amp;gt; register perl-sub as callback into the C library. If I invoke the
&lt;br&gt;&amp;gt;&amp;gt; perl callback as part of an API invoked from Perl script, the
&lt;br&gt;&amp;gt;&amp;gt; callback is called (in perls main thread). &amp;nbsp;However, when the
&lt;br&gt;&amp;gt;&amp;gt; same callback handler invokes the callback via a different thread
&lt;br&gt;&amp;gt;&amp;gt; (based on async event), it crashes at the &amp;quot;dSP;&amp;quot; line.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; I've tried adding &amp;quot;dTX&amp;quot; before &amp;quot;dSP;&amp;quot; and also tried enabling
&lt;br&gt;&amp;gt;&amp;gt; more macros to match how my perl is built. &amp;nbsp;So far no luck. &amp;nbsp;The
&lt;br&gt;&amp;gt;&amp;gt; line that crashes is below (pre-processor output). &amp;nbsp;&amp;quot;dTHX done&amp;quot;
&lt;br&gt;&amp;gt;&amp;gt; is printed, but crashes before &amp;quot;DSP done&amp;quot; is printed.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; printf(&amp;quot;entering perl callback handler...\n&amp;quot;); register
&lt;br&gt;&amp;gt;&amp;gt; PerlInterpreter *my_perl __attribute__((unused)) =
&lt;br&gt;&amp;gt;&amp;gt; ((PerlInterpreter
&lt;br&gt;&amp;gt;&amp;gt; *)pthread_getspecific((*Perl_Gthr_key_ptr(((void *)0)))));
&lt;br&gt;&amp;gt;&amp;gt; printf(&amp;quot;dTHX done...\n&amp;quot;); register SV **sp =
&lt;br&gt;&amp;gt;&amp;gt; (*Perl_Tstack_sp_ptr(((PerlInterpreter
&lt;br&gt;&amp;gt;&amp;gt; *)pthread_getspecific((*Perl_Gthr_key_ptr(((void *)0))))))); &amp;nbsp;&amp;lt;--
&lt;br&gt;&amp;gt;&amp;gt; CRASHES!! printf(&amp;quot;DSP done...\n&amp;quot;);
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; The perl-callback handler code ------------------------------
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; void SWIG_Wrap_bsa_disc_callback(int event, tMy_MSG *p_data) {
&lt;br&gt;&amp;gt;&amp;gt; printf(&amp;quot;entering perl callback handler...\n&amp;quot;); dTHX; printf(&amp;quot;dTHX
&lt;br&gt;&amp;gt;&amp;gt; done...\n&amp;quot;); dSP; printf(&amp;quot;DSP done...\n&amp;quot;); SV * sv =
&lt;br&gt;&amp;gt;&amp;gt; bsa_perl_disc_callback; if (sv == (SV*)NULL) croak(&amp;quot;Internal
&lt;br&gt;&amp;gt;&amp;gt; error...\n&amp;quot;);
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; printf(&amp;quot;Preparing to call perl callback...\n&amp;quot;); PUSHMARK(SP);
&lt;br&gt;&amp;gt;&amp;gt; XPUSHs(sv_2mortal(newSViv(event))); printf(&amp;quot;newSViv of %d
&lt;br&gt;&amp;gt;&amp;gt; done...\n&amp;quot;, event);
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; XPUSHs(SWIG_NewPointerObj(SWIG_as_voidptr(p_data),
&lt;br&gt;&amp;gt;&amp;gt; SWIGTYPE_p_tMy_MSG, SWIG_SHADOW)); /*
&lt;br&gt;&amp;gt;&amp;gt; XPUSHs(sv_2mortal(newSVsv((SV *)p_data))); */
&lt;br&gt;&amp;gt;&amp;gt; printf(&amp;quot;newSVsv...\n&amp;quot;); PUTBACK;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; printf(&amp;quot;calling the Perl sub...\n&amp;quot;); /* Call the Perl sub */
&lt;br&gt;&amp;gt;&amp;gt; call_sv(sv, G_DISCARD); printf(&amp;quot;Perl sub completed
&lt;br&gt;&amp;gt;&amp;gt; successfully...\n&amp;quot;); }
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Options when running SWIG: --------------------------
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; swig -includeall -I. -I &amp;lt;lots of others proj specific dirs&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; -perl5 -outdir &amp;lt;outdir&amp;gt; -module &amp;lt;module&amp;gt; my_api.i
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Options when compliling _wrap.c: --------------------------------
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; gcc -E -Dbool=char -fpic -D_REENTRANT -D_GNU_SOURCE
&lt;br&gt;&amp;gt;&amp;gt; -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -pipe -isystem
&lt;br&gt;&amp;gt;&amp;gt; /usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
&lt;br&gt;&amp;gt;&amp;gt; -DSWIG -g -DMULTIPLICITY -DPERL_IMPLICIT_CONTEXT
&lt;br&gt;&amp;gt;&amp;gt; -DTHREADS_HAVE_PIDS -DUSE_LARGE_FILES -DUSE_PERLIO
&lt;br&gt;&amp;gt;&amp;gt; -DUSE_REENTRANT_API -DBSA_CLIENT -I/usr/lib/perl/5.8/CORE/
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Output from perl -V -------------------
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Summary of my perl5 (revision 5 version 8 subversion 8)
&lt;br&gt;&amp;gt;&amp;gt; configuration: Platform: osname=linux, osvers=2.6.24-19-server,
&lt;br&gt;&amp;gt;&amp;gt; archname=i486-linux-gnu-thread-multi uname='linux palmer
&lt;br&gt;&amp;gt;&amp;gt; 2.6.24-19-server #1 smp sat jul 12 00:40:01 utc 2008 i686
&lt;br&gt;&amp;gt;&amp;gt; gnulinux ' config_args='-Dusethreads -Duselargefiles
&lt;br&gt;&amp;gt;&amp;gt; -Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=i486-linux-gnu
&lt;br&gt;&amp;gt;&amp;gt; -Dprefix=/usr -Dprivlib=/usr/share/perl/5.8
&lt;br&gt;&amp;gt;&amp;gt; -Darchlib=/usr/lib/perl/5.8 -Dvendorprefix=/usr
&lt;br&gt;&amp;gt;&amp;gt; -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5
&lt;br&gt;&amp;gt;&amp;gt; -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.8.8
&lt;br&gt;&amp;gt;&amp;gt; -Dsitearch=/usr/local/lib/perl/5.8.8
&lt;br&gt;&amp;gt;&amp;gt; -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3
&lt;br&gt;&amp;gt;&amp;gt; -Dsiteman1dir=/usr/local/man/man1
&lt;br&gt;&amp;gt;&amp;gt; -Dsiteman3dir=/usr/local/man/man3 -Dman1ext=1 -Dman3ext=3perl
&lt;br&gt;&amp;gt;&amp;gt; -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Ud_ualarm
&lt;br&gt;&amp;gt;&amp;gt; -Uusesfio -Uusenm -Duseshrplib -Dlibperl=libperl.so.5.8.8
&lt;br&gt;&amp;gt;&amp;gt; -Dd_dosuid -des' hint=recommended, useposix=true,
&lt;br&gt;&amp;gt;&amp;gt; d_sigaction=define usethreads=define use5005threads=undef
&lt;br&gt;&amp;gt;&amp;gt; useithreads=define usemultiplicity=define useperlio=define
&lt;br&gt;&amp;gt;&amp;gt; d_sfio=undef uselargefiles=define usesocks=undef
&lt;br&gt;&amp;gt;&amp;gt; use64bitint=undef use64bitall=undef uselongdouble=undef
&lt;br&gt;&amp;gt;&amp;gt; usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags
&lt;br&gt;&amp;gt;&amp;gt; ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN
&lt;br&gt;&amp;gt;&amp;gt; -fno-strict-aliasing -pipe -I/usr/local/include
&lt;br&gt;&amp;gt;&amp;gt; -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2',
&lt;br&gt;&amp;gt;&amp;gt; cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN
&lt;br&gt;&amp;gt;&amp;gt; -fno-strict-aliasing -pipe -I/usr/local/include' ccversion='',
&lt;br&gt;&amp;gt;&amp;gt; gccversion='4.2.3 (Ubuntu 4.2.3-2ubuntu7)', gccosandvers=''
&lt;br&gt;&amp;gt;&amp;gt; intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
&lt;br&gt;&amp;gt;&amp;gt; d_longlong=define, longlongsize=8, d_longdbl=define,
&lt;br&gt;&amp;gt;&amp;gt; longdblsize=12 ivtype='long', ivsize=4, nvtype='double',
&lt;br&gt;&amp;gt;&amp;gt; nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4,
&lt;br&gt;&amp;gt;&amp;gt; prototype=define Linker and Libraries: ld='cc', ldflags ='
&lt;br&gt;&amp;gt;&amp;gt; -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lgdbm
&lt;br&gt;&amp;gt;&amp;gt; -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt perllibs=-ldl
&lt;br&gt;&amp;gt;&amp;gt; -lm -lpthread -lc -lcrypt libc=/lib/libc-2.7.so, so=so,
&lt;br&gt;&amp;gt;&amp;gt; useshrplib=true, libperl=libperl.so.5.8.8 gnulibc_version='2.7'
&lt;br&gt;&amp;gt;&amp;gt; Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef,
&lt;br&gt;&amp;gt;&amp;gt; ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared
&lt;br&gt;&amp;gt;&amp;gt; -L/usr/local/lib'
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Characteristics of this binary (from libperl): Compile-time
&lt;br&gt;&amp;gt;&amp;gt; options: MULTIPLICITY PERL_IMPLICIT_CONTEXT
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; PERL_MALLOC_WRAP THREADS_HAVE_PIDS USE_ITHREADS
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API Built under linux
&lt;br&gt;&amp;gt;&amp;gt; Compiled at Jan 14 2009 22:34:36 @INC: /etc/perl
&lt;br&gt;&amp;gt;&amp;gt; /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8
&lt;br&gt;&amp;gt;&amp;gt; /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8
&lt;br&gt;&amp;gt;&amp;gt; /usr/share/perl/5.8 /usr/local/lib/site_perl .
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; output from gcc -v ------------------
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; gcc -v Using built-in specs. Target: i486-linux-gnu Configured
&lt;br&gt;&amp;gt;&amp;gt; with: ../src/configure -v
&lt;br&gt;&amp;gt;&amp;gt; --enable-languages=c,c++,fortran,objc,obj-c++,treelang
&lt;br&gt;&amp;gt;&amp;gt; --prefix=/usr --enable-shared --with-system-zlib
&lt;br&gt;&amp;gt;&amp;gt; --libexecdir=/usr/lib --without-included-gettext
&lt;br&gt;&amp;gt;&amp;gt; --enable-threads=posix --enable-nls
&lt;br&gt;&amp;gt;&amp;gt; --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2
&lt;br&gt;&amp;gt;&amp;gt; --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc
&lt;br&gt;&amp;gt;&amp;gt; --enable-mpfr --enable-targets=all --enable-checking=release
&lt;br&gt;&amp;gt;&amp;gt; --build=i486-linux-gnu --host=i486-linux-gnu
&lt;br&gt;&amp;gt;&amp;gt; --target=i486-linux-gnu Thread model: posix gcc version 4.2.4
&lt;br&gt;&amp;gt;&amp;gt; (Ubuntu 4.2.4-1ubuntu4)
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; ------------------------------------------------------------------------------
&lt;br&gt;&amp;gt; &amp;nbsp;Come build with us! The BlackBerry(R) Developer Conference in SF,
&lt;br&gt;&amp;gt; CA is the only developer event you need to attend this year.
&lt;br&gt;&amp;gt; Jumpstart your developing skills, take BlackBerry mobile
&lt;br&gt;&amp;gt; applications to market and stay ahead of the curve. Join us from
&lt;br&gt;&amp;gt; November 9 - 12, 2009. Register now!
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://p.sf.net/sfu/devconference&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/devconference&lt;/a&gt;&lt;br&gt;&amp;gt; _______________________________________________ Swig-user mailing
&lt;br&gt;&amp;gt; list &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26167621&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;/div&gt;-----BEGIN PGP SIGNATURE-----
&lt;br&gt;Version: GnuPG/MacGPG2 v2.0.12 (Darwin)
&lt;br&gt;Comment: Using GnuPG with Mozilla - &lt;a href=&quot;http://enigmail.mozdev.org/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://enigmail.mozdev.org/&lt;/a&gt;&lt;br&gt;&lt;br&gt;iEYEARECAAYFAkrvFT8ACgkQcVd2YI1BWAi1vQCcDzOZ2kydduJm2Cn3WTeMzVl0
&lt;br&gt;fScAniNdTUCg/LLBhI2EXhij9AmUtdgS
&lt;br&gt;=0XmJ
&lt;br&gt;-----END PGP SIGNATURE-----
&lt;br&gt;&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Come build with us! The BlackBerry(R) Developer Conference in SF, CA
&lt;br&gt;is the only developer event you need to attend this year. Jumpstart your
&lt;br&gt;developing skills, take BlackBerry mobile applications to market and stay 
&lt;br&gt;ahead of the curve. Join us from November 9 - 12, 2009. Register now!
&lt;br&gt;&lt;a href=&quot;http://p.sf.net/sfu/devconference&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/devconference&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26167621&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Embed-perl-and-multi-threading-%28Re%3A-segmentation-fault-in-event-driven-library-wrapped-with-swig%29-tp26166799p26167621.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26166799</id>
	<title>Embed perl and multi-threading (Re: segmentation fault in event-driven library wrapped with swig)</title>
	<published>2009-11-02T08:35:16Z</published>
	<updated>2009-11-02T08:35:16Z</updated>
	<author>
		<name>Sri-26</name>
	</author>
	<content type="html">Hi all,
&lt;br&gt;&lt;br&gt;In digging further into this, I feel that the pthread_getspecific() functions are not finding the perl interpreter instance corresponding to the thread in my library. &amp;nbsp;I guess its because I havent really created one yet? To test if this was the cause, I modified my SWIG_Wrap_bsa_disc_callback method to create a new perl-interpreter when my_perl is NULL and the crash is now occuring at the call_sv. &amp;nbsp;I realize its not the right way to do it, but not sure exactly the steps required. &amp;nbsp;I think the solution likely involves my library thread creating a interpreter instance and saving relevant data (what is relevant?) via pthread_setspecific method/SET_CONTEXT().
&lt;br&gt;&lt;br&gt;Would be great if anyone can shed some light or confirm if I'm on the right track.
&lt;br&gt;&lt;br&gt;Thx
&lt;br&gt;&lt;br&gt;void SWIG_Wrap_bsa_disc_callback(int event, tMy_MSG *p_data)
&lt;br&gt;{
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; int new_perl = 0;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&amp;quot;entering perl callback handler...\n&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; dTHX;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&amp;quot;dTHX done...\n&amp;quot;);
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if ( my_perl != NULL )
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;printf (&amp;quot;my_perl == %ul\n&amp;quot;, my_perl);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; else
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;printf (&amp;quot;my_perl was NULL\n&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;my_perl = perl_alloc();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;PERL_SET_CONTEXT(my_perl);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;new_perl = 1;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;/*
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&amp;quot;Destruct level : %d...\n&amp;quot;, PL_perl_destruct_level);
&lt;br&gt;*/
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; dSP;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&amp;quot;DSP done...\n&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; SV * sv = bsa_perl_disc_callback;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if (sv == (SV*)NULL)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;croak(&amp;quot;Internal error...\n&amp;quot;);
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&amp;quot;Preparing to call perl callback...\n&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; PUSHMARK(SP);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; XPUSHs(sv_2mortal(newSViv(event)));
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&amp;quot;newSViv of %d done...\n&amp;quot;, event);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; XPUSHs(SWIG_NewPointerObj(SWIG_as_voidptr(p_data), SWIGTYPE_p_tMy_MSG, SWIG_SHADOW));
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; /* XPUSHs(sv_2mortal(newSVsv((SV *)p_data))); */
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&amp;quot;newSVsv...\n&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; PUTBACK;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&amp;quot;calling the Perl sub...\n&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; /* Call the Perl sub */
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; call_sv(sv, G_DISCARD);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&amp;quot;Perl sub completed successfully...\n&amp;quot;);
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if ( new_perl )
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; perl_free(my_perl);
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;&lt;br&gt;--- On Fri, 10/30/09, Sri &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26166799&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;w2learn@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; From: Sri &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26166799&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;w2learn@...&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;gt; Subject: segmentation fault in event-driven library wrapped with swig
&lt;br&gt;&amp;gt; To: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26166799&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;swig-user@...&lt;/a&gt;
&lt;br&gt;&amp;gt; Date: Friday, October 30, 2009, 8:35 PM
&lt;br&gt;&amp;gt; Hello SWIG, perl experts:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; With good help from swig-users posts &amp; Stephen Chan in
&lt;br&gt;&amp;gt; particular, I've figured out how to wrap a C event-driven
&lt;br&gt;&amp;gt; library with SWIG.  SWIG is really nice tool!  I'm able to
&lt;br&gt;&amp;gt; call APIs and register perl-sub as callback into the C
&lt;br&gt;&amp;gt; library. If I invoke the perl callback as part of an API
&lt;br&gt;&amp;gt; invoked from Perl script, the callback is called (in perls
&lt;br&gt;&amp;gt; main thread).  However, when the same callback handler
&lt;br&gt;&amp;gt; invokes the callback via a different thread (based on async
&lt;br&gt;&amp;gt; event), it crashes at the &amp;quot;dSP;&amp;quot; line. 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I've tried adding &amp;quot;dTX&amp;quot; before &amp;quot;dSP;&amp;quot; and also tried
&lt;br&gt;&amp;gt; enabling more macros to match how my perl is built.  So far
&lt;br&gt;&amp;gt; no luck.  The line that crashes is below (pre-processor
&lt;br&gt;&amp;gt; output).  &amp;quot;dTHX done&amp;quot; is printed, but crashes before
&lt;br&gt;&amp;gt; &amp;quot;DSP done&amp;quot; is printed.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt;       printf(&amp;quot;entering perl callback
&lt;br&gt;&amp;gt; handler...\n&amp;quot;);
&lt;br&gt;&amp;gt;       register PerlInterpreter *my_perl
&lt;br&gt;&amp;gt; __attribute__((unused)) = ((PerlInterpreter
&lt;br&gt;&amp;gt; *)pthread_getspecific((*Perl_Gthr_key_ptr(((void *)0)))));
&lt;br&gt;&amp;gt;       printf(&amp;quot;dTHX done...\n&amp;quot;);
&lt;br&gt;&amp;gt;       register SV **sp =
&lt;br&gt;&amp;gt; (*Perl_Tstack_sp_ptr(((PerlInterpreter
&lt;br&gt;&amp;gt; *)pthread_getspecific((*Perl_Gthr_key_ptr(((void
&lt;br&gt;&amp;gt; *)0)))))));  &amp;lt;-- CRASHES!!
&lt;br&gt;&amp;gt;       printf(&amp;quot;DSP done...\n&amp;quot;);
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; The perl-callback handler code
&lt;br&gt;&amp;gt; ------------------------------
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; void SWIG_Wrap_bsa_disc_callback(int event, tMy_MSG
&lt;br&gt;&amp;gt; *p_data)
&lt;br&gt;&amp;gt; {
&lt;br&gt;&amp;gt;       printf(&amp;quot;entering perl callback
&lt;br&gt;&amp;gt; handler...\n&amp;quot;);
&lt;br&gt;&amp;gt;       dTHX;
&lt;br&gt;&amp;gt;       printf(&amp;quot;dTHX done...\n&amp;quot;);
&lt;br&gt;&amp;gt;       dSP;
&lt;br&gt;&amp;gt;       printf(&amp;quot;DSP done...\n&amp;quot;);
&lt;br&gt;&amp;gt;       SV * sv = bsa_perl_disc_callback;
&lt;br&gt;&amp;gt;       if (sv == (SV*)NULL)
&lt;br&gt;&amp;gt;          croak(&amp;quot;Internal
&lt;br&gt;&amp;gt; error...\n&amp;quot;);
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt;       printf(&amp;quot;Preparing to call perl
&lt;br&gt;&amp;gt; callback...\n&amp;quot;);
&lt;br&gt;&amp;gt;       PUSHMARK(SP);
&lt;br&gt;&amp;gt;       XPUSHs(sv_2mortal(newSViv(event)));
&lt;br&gt;&amp;gt;       printf(&amp;quot;newSViv of %d done...\n&amp;quot;,
&lt;br&gt;&amp;gt; event);
&lt;br&gt;&amp;gt;      
&lt;br&gt;&amp;gt; XPUSHs(SWIG_NewPointerObj(SWIG_as_voidptr(p_data),
&lt;br&gt;&amp;gt; SWIGTYPE_p_tMy_MSG, SWIG_SHADOW));
&lt;br&gt;&amp;gt;       /* XPUSHs(sv_2mortal(newSVsv((SV
&lt;br&gt;&amp;gt; *)p_data))); */
&lt;br&gt;&amp;gt;       printf(&amp;quot;newSVsv...\n&amp;quot;);
&lt;br&gt;&amp;gt;       PUTBACK;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt;       printf(&amp;quot;calling the Perl sub...\n&amp;quot;);
&lt;br&gt;&amp;gt;       /* Call the Perl sub */
&lt;br&gt;&amp;gt;       call_sv(sv, G_DISCARD);
&lt;br&gt;&amp;gt;       printf(&amp;quot;Perl sub completed
&lt;br&gt;&amp;gt; successfully...\n&amp;quot;);
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Options when running SWIG:
&lt;br&gt;&amp;gt; --------------------------
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; swig -includeall -I. -I &amp;lt;lots of others proj specific
&lt;br&gt;&amp;gt; dirs&amp;gt; -perl5 -outdir &amp;lt;outdir&amp;gt; -module
&lt;br&gt;&amp;gt; &amp;lt;module&amp;gt; my_api.i
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Options when compliling _wrap.c:
&lt;br&gt;&amp;gt; --------------------------------
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; gcc -E -Dbool=char -fpic -D_REENTRANT -D_GNU_SOURCE
&lt;br&gt;&amp;gt; -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -pipe
&lt;br&gt;&amp;gt; -isystem /usr/local/include -D_LARGEFILE_SOURCE
&lt;br&gt;&amp;gt; -D_FILE_OFFSET_BITS=64 -DSWIG -g -DMULTIPLICITY
&lt;br&gt;&amp;gt; -DPERL_IMPLICIT_CONTEXT -DTHREADS_HAVE_PIDS
&lt;br&gt;&amp;gt; -DUSE_LARGE_FILES -DUSE_PERLIO -DUSE_REENTRANT_API
&lt;br&gt;&amp;gt; -DBSA_CLIENT -I/usr/lib/perl/5.8/CORE/
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Output from perl -V
&lt;br&gt;&amp;gt; -------------------
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Summary of my perl5 (revision 5 version 8 subversion 8)
&lt;br&gt;&amp;gt; configuration:
&lt;br&gt;&amp;gt;   Platform:
&lt;br&gt;&amp;gt;     osname=linux, osvers=2.6.24-19-server,
&lt;br&gt;&amp;gt; archname=i486-linux-gnu-thread-multi
&lt;br&gt;&amp;gt;     uname='linux palmer 2.6.24-19-server #1 smp
&lt;br&gt;&amp;gt; sat jul 12 00:40:01 utc 2008 i686 gnulinux '
&lt;br&gt;&amp;gt;     config_args='-Dusethreads -Duselargefiles
&lt;br&gt;&amp;gt; -Dccflags=-DDEBIAN -Dcccdlflags=-fPIC
&lt;br&gt;&amp;gt; -Darchname=i486-linux-gnu -Dprefix=/usr
&lt;br&gt;&amp;gt; -Dprivlib=/usr/share/perl/5.8 -Darchlib=/usr/lib/perl/5.8
&lt;br&gt;&amp;gt; -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5
&lt;br&gt;&amp;gt; -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local
&lt;br&gt;&amp;gt; -Dsitelib=/usr/local/share/perl/5.8.8
&lt;br&gt;&amp;gt; -Dsitearch=/usr/local/lib/perl/5.8.8
&lt;br&gt;&amp;gt; -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3
&lt;br&gt;&amp;gt; -Dsiteman1dir=/usr/local/man/man1
&lt;br&gt;&amp;gt; -Dsiteman3dir=/usr/local/man/man3 -Dman1ext=1
&lt;br&gt;&amp;gt; -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs
&lt;br&gt;&amp;gt; -Ud_csh -Ud_ualarm -Uusesfio -Uusenm -Duseshrplib
&lt;br&gt;&amp;gt; -Dlibperl=libperl.so.5.8.8 -Dd_dosuid -des'
&lt;br&gt;&amp;gt;     hint=recommended, useposix=true,
&lt;br&gt;&amp;gt; d_sigaction=define
&lt;br&gt;&amp;gt;     usethreads=define use5005threads=undef
&lt;br&gt;&amp;gt; useithreads=define usemultiplicity=define
&lt;br&gt;&amp;gt;     useperlio=define d_sfio=undef
&lt;br&gt;&amp;gt; uselargefiles=define usesocks=undef
&lt;br&gt;&amp;gt;     use64bitint=undef use64bitall=undef
&lt;br&gt;&amp;gt; uselongdouble=undef
&lt;br&gt;&amp;gt;     usemymalloc=n, bincompat5005=undef
&lt;br&gt;&amp;gt;   Compiler:
&lt;br&gt;&amp;gt;     cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE
&lt;br&gt;&amp;gt; -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -pipe
&lt;br&gt;&amp;gt; -I/usr/local/include -D_LARGEFILE_SOURCE
&lt;br&gt;&amp;gt; -D_FILE_OFFSET_BITS=64',
&lt;br&gt;&amp;gt;     optimize='-O2',
&lt;br&gt;&amp;gt;     cppflags='-D_REENTRANT -D_GNU_SOURCE
&lt;br&gt;&amp;gt; -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -pipe
&lt;br&gt;&amp;gt; -I/usr/local/include'
&lt;br&gt;&amp;gt;     ccversion='', gccversion='4.2.3 (Ubuntu
&lt;br&gt;&amp;gt; 4.2.3-2ubuntu7)', gccosandvers=''
&lt;br&gt;&amp;gt;     intsize=4, longsize=4, ptrsize=4,
&lt;br&gt;&amp;gt; doublesize=8, byteorder=1234
&lt;br&gt;&amp;gt;     d_longlong=define, longlongsize=8,
&lt;br&gt;&amp;gt; d_longdbl=define, longdblsize=12
&lt;br&gt;&amp;gt;     ivtype='long', ivsize=4, nvtype='double',
&lt;br&gt;&amp;gt; nvsize=8, Off_t='off_t', lseeksize=8
&lt;br&gt;&amp;gt;     alignbytes=4, prototype=define
&lt;br&gt;&amp;gt;   Linker and Libraries:
&lt;br&gt;&amp;gt;     ld='cc', ldflags =' -L/usr/local/lib'
&lt;br&gt;&amp;gt;     libpth=/usr/local/lib /lib /usr/lib
&lt;br&gt;&amp;gt;     libs=-lgdbm -lgdbm_compat -ldb -ldl -lm
&lt;br&gt;&amp;gt; -lpthread -lc -lcrypt
&lt;br&gt;&amp;gt;     perllibs=-ldl -lm -lpthread -lc -lcrypt
&lt;br&gt;&amp;gt;     libc=/lib/libc-2.7.so, so=so,
&lt;br&gt;&amp;gt; useshrplib=true, libperl=libperl.so.5.8.8
&lt;br&gt;&amp;gt;     gnulibc_version='2.7'
&lt;br&gt;&amp;gt;   Dynamic Linking:
&lt;br&gt;&amp;gt;     dlsrc=dl_dlopen.xs, dlext=so,
&lt;br&gt;&amp;gt; d_dlsymun=undef, ccdlflags='-Wl,-E'
&lt;br&gt;&amp;gt;     cccdlflags='-fPIC', lddlflags='-shared
&lt;br&gt;&amp;gt; -L/usr/local/lib'
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Characteristics of this binary (from libperl):
&lt;br&gt;&amp;gt;   Compile-time options: MULTIPLICITY
&lt;br&gt;&amp;gt; PERL_IMPLICIT_CONTEXT
&lt;br&gt;&amp;gt;                
&lt;br&gt;&amp;gt;         PERL_MALLOC_WRAP
&lt;br&gt;&amp;gt; THREADS_HAVE_PIDS USE_ITHREADS
&lt;br&gt;&amp;gt;                
&lt;br&gt;&amp;gt;         USE_LARGE_FILES USE_PERLIO
&lt;br&gt;&amp;gt; USE_REENTRANT_API
&lt;br&gt;&amp;gt;   Built under linux
&lt;br&gt;&amp;gt;   Compiled at Jan 14 2009 22:34:36
&lt;br&gt;&amp;gt;   @INC:
&lt;br&gt;&amp;gt;     /etc/perl
&lt;br&gt;&amp;gt;     /usr/local/lib/perl/5.8.8
&lt;br&gt;&amp;gt;     /usr/local/share/perl/5.8.8
&lt;br&gt;&amp;gt;     /usr/lib/perl5
&lt;br&gt;&amp;gt;     /usr/share/perl5
&lt;br&gt;&amp;gt;     /usr/lib/perl/5.8
&lt;br&gt;&amp;gt;     /usr/share/perl/5.8
&lt;br&gt;&amp;gt;     /usr/local/lib/site_perl
&lt;br&gt;&amp;gt;     .
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; output from gcc -v
&lt;br&gt;&amp;gt; ------------------
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp;gcc -v
&lt;br&gt;&amp;gt; Using built-in specs.
&lt;br&gt;&amp;gt; Target: i486-linux-gnu
&lt;br&gt;&amp;gt; Configured with: ../src/configure -v
&lt;br&gt;&amp;gt; --enable-languages=c,c++,fortran,objc,obj-c++,treelang
&lt;br&gt;&amp;gt; --prefix=/usr --enable-shared --with-system-zlib
&lt;br&gt;&amp;gt; --libexecdir=/usr/lib --without-included-gettext
&lt;br&gt;&amp;gt; --enable-threads=posix --enable-nls
&lt;br&gt;&amp;gt; --with-gxx-include-dir=/usr/include/c++/4.2
&lt;br&gt;&amp;gt; --program-suffix=-4.2 --enable-clocale=gnu
&lt;br&gt;&amp;gt; --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr
&lt;br&gt;&amp;gt; --enable-targets=all --enable-checking=release
&lt;br&gt;&amp;gt; --build=i486-linux-gnu --host=i486-linux-gnu
&lt;br&gt;&amp;gt; --target=i486-linux-gnu
&lt;br&gt;&amp;gt; Thread model: posix
&lt;br&gt;&amp;gt; gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu4)
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;/div&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Come build with us! The BlackBerry(R) Developer Conference in SF, CA
&lt;br&gt;is the only developer event you need to attend this year. Jumpstart your
&lt;br&gt;developing skills, take BlackBerry mobile applications to market and stay 
&lt;br&gt;ahead of the curve. Join us from November 9 - 12, 2009. Register now!
&lt;br&gt;&lt;a href=&quot;http://p.sf.net/sfu/devconference&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/devconference&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26166799&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Embed-perl-and-multi-threading-%28Re%3A-segmentation-fault-in-event-driven-library-wrapped-with-swig%29-tp26166799p26166799.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26159568</id>
	<title>Re: shared_ptr and directors.</title>
	<published>2009-11-10T07:02:21Z</published>
	<updated>2009-11-02T00:10:39Z</updated>
	<author>
		<name>Andrea-60</name>
	</author>
	<content type="html">On 01/11/09 21:03, William S Fulton wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; On the other hand if I return a raw pointer I get a warning
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;quot; Returning a pointer or reference in a director method is not recommended. &amp;quot;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Does it mean that in directors I can only return by value?
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; Take a close look at the generated code with pointers and you'll see the 
&lt;br&gt;&amp;gt; memory complications, with no clear solution. However, I very much doubt 
&lt;br&gt;&amp;gt; these problems would exist if you used shared_ptr and the director 
&lt;br&gt;&amp;gt; typemaps for shared_ptr were written.
&lt;/div&gt;&lt;br&gt;I've written typemaps for customized types, but never for directors.
&lt;br&gt;If you could give some hints about problems/solutions, you would make my life a lot easier.
&lt;br&gt;&lt;br&gt;Andrea
&lt;br&gt;&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Come build with us! The BlackBerry(R) Developer Conference in SF, CA
&lt;br&gt;is the only developer event you need to attend this year. Jumpstart your
&lt;br&gt;developing skills, take BlackBerry mobile applications to market and stay 
&lt;br&gt;ahead of the curve. Join us from November 9 - 12, 2009. Register now!
&lt;br&gt;&lt;a href=&quot;http://p.sf.net/sfu/devconference&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/devconference&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26159568&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/shared_ptr-and-directors.-tp25989904p26159568.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26158108</id>
	<title>Re: Python, virtual inheritance and directors</title>
	<published>2009-11-01T19:51:48Z</published>
	<updated>2009-11-01T19:51:48Z</updated>
	<author>
		<name>nitro-4</name>
	</author>
	<content type="html">Am 01.11.2009, 21:29 Uhr, schrieb William S Fulton &amp;nbsp;
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26158108&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;wsf@...&lt;/a&gt;&amp;gt;:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Nitro wrote:
&lt;br&gt;&amp;gt;&amp;gt; Hello,
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; suppose I have two classes like this and turn on directors for the &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; derived
&lt;br&gt;&amp;gt;&amp;gt; one:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; class BaseClass
&lt;br&gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;BaseClass(int a);
&lt;br&gt;&amp;gt;&amp;gt; };
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; class MyClass : virtual public BaseClass
&lt;br&gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt; public_
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;MyClass( int a );
&lt;br&gt;&amp;gt;&amp;gt; };
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; %feature(&amp;quot;director&amp;quot;) MyClass;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; The code swig will generate looks like
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; SwigDirector_MyClass::SwigDirector_MyClass(PyObject *self, int a):
&lt;br&gt;&amp;gt;&amp;gt; MyClass(a), Swig::Director(self)
&lt;br&gt;&amp;gt;&amp;gt; { ... }
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; This fails to compile, because it should look like
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; SwigDirector_MyClass::SwigDirector_MyClass(PyObject *self, int a):
&lt;br&gt;&amp;gt;&amp;gt; MyClass(a), BaseClass(a), Swig::Director(self)
&lt;br&gt;&amp;gt;&amp;gt; { ... }
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Notice the additional call to the BaseClass(int) constructor.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; How can I tell swig to insert BaseClass(a) there?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Matthias, no-one has had the misfortune of using virtual inheritance and
&lt;br&gt;&amp;gt; directors, so this problem of the most derived class (director class)
&lt;br&gt;&amp;gt; having to initialise the virtual bases hasn't come up. So consider it
&lt;br&gt;&amp;gt; unsupported for now. I'm afraid I can't think of any way to work around
&lt;br&gt;&amp;gt; it either without hacking the SWIG source. See
&lt;br&gt;&amp;gt; classDirectorConstructor() in python.cxx for where this code is
&lt;br&gt;&amp;gt; generated. I havn't given this too much thought, but I suspect there is
&lt;br&gt;&amp;gt; no way that this initialisation can be generated automatically and so a
&lt;br&gt;&amp;gt; feature of some sort to manually add in the extra base initialisations
&lt;br&gt;&amp;gt; is probably necessary.
&lt;/div&gt;&lt;br&gt;Thanks for your response, William. I've worked around this problem by now, &amp;nbsp;
&lt;br&gt;so swig doesn't see the virtual base class.
&lt;br&gt;&lt;br&gt;&amp;gt; And the reason why multiple inheritance is full of pitfalls and normally
&lt;br&gt;&amp;gt; avoided is probably becoming clearer...
&lt;br&gt;&lt;br&gt;Yes, I'm not a huge fan of it either. It's useful in limited contexts &amp;nbsp;
&lt;br&gt;though.
&lt;br&gt;&lt;br&gt;C++ is imperfect in quite some places for my purposes anyway, that's why I &amp;nbsp;
&lt;br&gt;am wrapping code to Python :-D
&lt;br&gt;&lt;br&gt;-Matthias
&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Come build with us! The BlackBerry(R) Developer Conference in SF, CA
&lt;br&gt;is the only developer event you need to attend this year. Jumpstart your
&lt;br&gt;developing skills, take BlackBerry mobile applications to market and stay 
&lt;br&gt;ahead of the curve. Join us from November 9 - 12, 2009. Register now!
&lt;br&gt;&lt;a href=&quot;http://p.sf.net/sfu/devconference&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/devconference&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26158108&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Python%2C-virtual-inheritance-and-directors-tp26150795p26158108.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26156881</id>
	<title>Problem with SwigValueWrapper</title>
	<published>2009-11-01T16:57:22Z</published>
	<updated>2009-11-01T16:57:22Z</updated>
	<author>
		<name>Robert Lupton</name>
	</author>
	<content type="html">This one I do think is a bug rather than a &amp;quot;feature&amp;quot;; &amp;nbsp;the non-use of &amp;nbsp;
&lt;br&gt;SwigValueWrapper when it's needed, and the ignoring of a %feature 
&lt;br&gt;(&amp;quot;valuewrapper&amp;quot;). &amp;nbsp;This is swig 1.3.40 and -python -c++.
&lt;br&gt;&lt;br&gt;// -*- c++ -*-
&lt;br&gt;%module hoo
&lt;br&gt;&lt;br&gt;%inline %{
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;template&amp;lt;typename Matrix&amp;gt;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;class MatrixBase {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;private:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MatrixBase() {}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;};
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;class Matrix { };
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;template&amp;lt;typename T&amp;gt;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;class TMatrix { };
&lt;br&gt;%}
&lt;br&gt;&lt;br&gt;//%template(MMatrix) MatrixBase&amp;lt;Matrix&amp;gt;; &amp;nbsp;	// makes no difference
&lt;br&gt;//%feature(&amp;quot;valuewrapper&amp;quot;) MatrixBase&amp;lt;Matrix&amp;gt;; 	// makes no difference
&lt;br&gt;&lt;br&gt;%typemap(in) MatrixBase&amp;lt;Matrix&amp;gt;() { }
&lt;br&gt;&lt;br&gt;%inline %{
&lt;br&gt;#if 1
&lt;br&gt;&amp;nbsp; &amp;nbsp; void size(MatrixBase&amp;lt;Matrix&amp;gt; mat);	// fails
&lt;br&gt;#else
&lt;br&gt;&amp;nbsp; &amp;nbsp; void size(MatrixBase&amp;lt;TMatrix&amp;lt;int&amp;gt; &amp;gt; mat); // OK
&lt;br&gt;#endif
&lt;br&gt;%}
&lt;br&gt;&lt;br&gt;With &amp;quot;#if 1&amp;quot; (i.e. void size(MatrixBase&amp;lt;Matrix&amp;gt; mat);) the generated &amp;nbsp;
&lt;br&gt;code uses:
&lt;br&gt;&lt;br&gt;SWIGINTERN PyObject *_wrap_size(PyObject *SWIGUNUSEDPARM(self), &amp;nbsp;
&lt;br&gt;PyObject *args) {
&lt;br&gt;&amp;nbsp; &amp;nbsp;PyObject *resultobj = 0;
&lt;br&gt;&amp;nbsp; &amp;nbsp;MatrixBase&amp;lt; Matrix &amp;gt; arg1 ;
&lt;br&gt;&lt;br&gt;and fails to compile due to MatrixBase's private constructor. &amp;nbsp;With &amp;nbsp;
&lt;br&gt;&amp;quot;#if 0&amp;quot; the code
&lt;br&gt;uses SwigValueWrapper and all is well:
&lt;br&gt;&lt;br&gt;SWIGINTERN PyObject *_wrap_size(PyObject *SWIGUNUSEDPARM(self), &amp;nbsp;
&lt;br&gt;PyObject *args) {
&lt;br&gt;&amp;nbsp; &amp;nbsp;PyObject *resultobj = 0;
&lt;br&gt;&amp;nbsp; &amp;nbsp;SwigValueWrapper&amp;lt; MatrixBase&amp;lt; TMatrix&amp;lt; int &amp;gt; &amp;gt; &amp;gt; arg1 ;
&lt;br&gt;&lt;br&gt;I'm actually most concerned about %feature(&amp;quot;valuewrapper&amp;quot;) &amp;nbsp;
&lt;br&gt;MatrixBase&amp;lt;Matrix&amp;gt;; being apparently ignored &amp;nbsp;as I have a class that &amp;nbsp;
&lt;br&gt;should have a private default constructor, but in fact has one that &amp;nbsp;
&lt;br&gt;just crashes...
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; R
&lt;br&gt;&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------------
&lt;br&gt;Come build with us! The BlackBerry(R) Developer Conference in SF, CA
&lt;br&gt;is the only developer event you need to attend this year. Jumpstart your
&lt;br&gt;developing skills, take BlackBerry mobile applications to market and stay 
&lt;br&gt;ahead of the curve. Join us from November 9 - 12, 2009. Register now!
&lt;br&gt;&lt;a href=&quot;http://p.sf.net/sfu/devconference&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://p.sf.net/sfu/devconference&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Swig-user mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26156881&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Swig-user@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.sourceforge.net/lists/listinfo/swig-user&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.sourceforge.net/lists/listinfo/swig-user&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/swig-user-f3366.html&quot; embed=&quot;fixTarget[3366]&quot; target=&quot;_top&quot; &gt;swig-user&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Problem-with-SwigValueWrapper-tp26156881p26156881.html" />
</entry>

</feed>
