Complicated issue.
David
klesk at mixmail.com
Fri Oct 18 13:56:51 EDT 2002
Hi, my name is David. I have a complicated problem, that I am sure has
solution, but its hard to me to find one althoug I have half a week
reading swig glue code and reading swig and python documentation.
I have a class A that is created in my C++ program. The class A has a
referece to a class B. I have generated a shadow class in python, using
swig, of the class B, so I can create an instance of class B from Python.
Once I have the script, in my C++ program, I create an instance of class
A, run the interpreter and execute the script, so I have also an instance
of class B, but in Python (well, the "this" attribute has the pointer
string representation to the C++ instance of class B as you already must
know if you use swig ).
What I want is to assign this pointer to the reference of class A in
order to acces from it within the code of A class.
But there is also the counterpart. I would like to call methods from C++
of the class B that are only implemented in python, for example if I make
a subclass of class B named D with new methods only defined in D, it is
legal to have an instance of D in the reference atribute of A, because it
is just a subclass of B. So I will have to convert the C++ pointer to a
Python Object that is the instance of the D or B class and then call the
python method of the class.
Any ideas? It sounds complicated, I am sure it is, but maybe you can help
me as I am sure you are more experienced. Thanks in advance.
David.
PD.- Sorry for my bad english.
More information about the Python-list
mailing list