0

The GObject Reference Manual states that the GObject system was designed to export functions written in C to other languages by using some generic glue code. It is also noted that this glue exists for perl and python explicitly. Omitted however, is how exactly where to find and how to use it.

So, lets suppose I have written a new GObject (for the sake of simplicity, the example given in the same manual) complete with C sources and header files, compiled it, and appropriately installed it, locating it where system libraries are to be found. Now I want to instantiate and use the object in a Python program. Or a Perl Program. Or even a Java program. Or any other programming language that has glib bindings available. How exactly can this be done?

Note that I want to use the object directly, most probably through the already existing generic glue code. I am aware of the possibility to use DBus to export the object from a running C program and access it with Python. But I look for no IPC-Solution. Compiled C library objects shall be more or less directly exported to another programming language.

nicael
  • 18,550
  • 13
  • 57
  • 90
XZS
  • 2,374
  • 2
  • 19
  • 38

2 Answers2

1

Here's a few examples below. GType and GObject are standards and do not provide the glue code. You'll just want to look for the language you want to use and see if anyone has implemented the glue yet. If not, maybe you can :)

https://wiki.gnome.org/PyGTK/WhatsNew28

http://search.cpan.org/~rmcfarla/Glib-1.020/GType.xs

xaxxon
  • 19,189
  • 5
  • 50
  • 80
  • Correct but outdated though, as the Gobject Introspection is intended to replace these bindings. Nevertheless, the links gave raise to [another question](http://stackoverflow.com/q/18593044). – XZS Sep 03 '13 at 13:15
1

You're looking for GObject Introspection. Once you have that set up properly you can use PyGObject (Python), Gjs (JavaScript), Vala, etc. pretty easily.

All the languages are, obviously, different, but since you sound most intested in Python... the Python GTK+ 3 Tutorial explains the process using GTK+ as an example.

nemequ
  • 16,623
  • 1
  • 43
  • 62