Createing PyObjects from modules
ian reinhart geiser
geiseri at yahoo.com
Thu Oct 25 14:23:09 EDT 2001
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Greetings,
I have a little confusion about python objects. I am trying to share an
object between C++ and my embedded python script. To do this I have found
little to no help from the Python docs or on the web as how to mirror a
complex object between the two. I have found that siplib the library that
makes SIP work has the ability to map C++ objects to python and vis versa.
++++Reference Notes++++
sipMapCppToSelf
Name
sipMapCppToSelf -- Convert a C/C++ pointer to a Python instance
PyObject * sipMapCppToSelf(const void * cppPtr, PyObject * pyClass);
Description
If the C/C++ pointer is recognized and it is an instance of a sub-class of
the expected class then the previously wrapped instance is returned.
Otherwise a new Python instance is created with the expected class. The
instance comes with a reference.
Return Value
A pointer to the Python object instance (or Py_None if a NULL pointer was
passed in).
cppPtr - A pointer to the C++ object.
pyClass - The expected Python class.
++++END++++
- From what I can tell in the code this pyClass is the class created by my
module that is being called from the embedded script. My question is how do
a make a PyObject out of it?
In python i do this:
from foo import *
bar = foo()
I tried this in C++ but it seems not to work:
PyObject *object = PyModule_New("foo");
Am I mis understanding the documentation here?
Thanks
- -ian reinhart geiser
- --
========================================
May all your PUSHes be POPped.
========================================
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE72FiNPy62TRm8dvgRAtkUAKDRI2Y+UoBupROhi6lfkLJ3dUsMKwCdES0d
CfKC0vgu63VIrMlTsHU3kuU=
=boXL
-----END PGP SIGNATURE-----
More information about the Python-list
mailing list