I want to embed the Python interpreter into a program written in Vala to allow for some runtime scripting. I can run parts of my vala code from Python using Introspection, and I've found a rudimentary example of embedding the interpreter in Python here: https://gist.github.com/astagi/1282808.
That example does not show how to pass an instance of an object in Vala to the interpreter and back. In the example of how to embed Python (http://docs.python.org/3/extending/embedding.html#pure-embedding) a variable of type long is converted to/form the python type using using something like this:
PyObject *pvalue = PyLong_FromLong(foo);
and
long foo=PyLong_asLong(pvalue);
The question is what are the equivalent functions for a variable in Vala of type GLib.Object [a GObject in C form].
SomeClass
in Vala that inherits from GObject. I can compile SomeClass to a shared library, and import that to python usingfrom gi.repository import SomeClass
. When SomeClass is instantiated in python, the resulting object is actually a GObject, wrapped in a PyObject (is that incorrect?). With the python interpreter embed in a Vala program, the user might run a python script that creates an instance of SomeClasssc=SomeClass()
but its a PyObject managed by the interpreter. How do I get the GObject insc
back to main program – Windsail