embedding G-I into apps



(Using this list for gobject-introspection development for now,
probably ignore if you're not jdahlin =))

I was looking a bit today about applying our shiny new introspection
tool to Totem, with an eye to eliminating the manual binding
infrastructure, and more generally figure out how existing C
applications can use g-i (and something like Alex' GScript API) to
have a nicer way to embed Python or Spidermonkey.

Now, the scanner requires, at build time, to load the app's code so we
can call the foo_get_type() functions and introspect
properties/signals etc.  This is problematic because on some platforms
you can't just dlopen() an executable.  Owen and I had a discussion
about this and it sounds like basically what we need to do is actually
invoke the scanner from inside the application.  So here's how it
could work:

o Add a hidden --introspect option to application
o When given, dlopen("gobject-introspection-sanner.so")
o dlsym("g_introspection_scan")
o Pass our current argv to that function
o This function (in a separate shared library from
gobject-introspection.so), uses the cPython API to create an
interpreter and load /usr/bin/g-ir-scanner
o Locate the main() function inside the Python script g-ir-scanner,
and invoke it with the argv originally passed

Kind of gross admittedly, but apps should only need a small patch for
this approach and it seems most likely to work on random platforms.
If someone knows a better/nicer way, let me know!


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]