thanks for replying
I made a small test case that fails with a similar problem
This is how it looks
1. Two simple classes A and B , each holds an integer.
2. A has a function getB() that returns pointer to B.
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\
#ifndef __AB_H__
#define __AB_H__
class B{
public:
int b;
B( int num = 0 ){
b = num;
}
~B(){}
};
class A{
public:
int a;
A( int a = 0 ){
this->a = a;
}
~A(){}
B* getB(){
B* temp = new B(a);
return temp;
}
};
#endif __AB_H__
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\
The swig file is as follows
%module testcase
%{
#include "AB.h"
%}
%include "AB.h"
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\
Compilation commands
swig-1.3 -c++ -python -o swig.cc swig.i
g++ -c -fPIC swig.cc -o swig.o -I /usr/local/include/python2.1/
g++ -shared swig.o -o _testcase.so
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\
Python File
from testcase import *
a = A() # works fine
b = B() # works fine
c = a.getB() # crashes ( Segmentation Fault )
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\
See if you can makeout something out of that
--
shekhar
On 8/4/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>> I have been working getting my C++ code to be used in Python (
>> Basically Extending ) This is the problem i am facing rite now.
>>
>> I have a function that returns a Pointer to a class in my C++ Code
>>
>> It looks like this
...
>> I have used SWIG to get the Glue code.
>>
>> When i call this function ( in python ) and it eventually returns (
>> when it gets a connection in this case ) it crashes ! I get a SEG
>> FAULT !
>>
>> Is it some thing that cannot be done ?
I'm certainly no SWIG expert, however:
1. Is your SLSocket class wrapped with SWIG? Do you maybe need a
typemap? Can you explicitly create one from Python? If so, does
that work?
2. What does your SWIG .i file look like?
3. Finally, have you tried asking on the SWIG mailing list
([EMAIL PROTECTED])? There are probably many more SWIG
experts there than here.
Skip
--
--
shekhar
-- http://mail.python.org/mailman/listinfo/python-list