GObject |
GObject is a library and framework which provides Object-oriented programming for the C programming language. It is released under the GNU Lesser General Public License license for many platforms.
Being the fundament of all GIMP Toolkit/GNOME applications, GObject is the base class of all GIMP Toolkit/GNOME classes. This library depends only on libc and GLib. GObject also provides additional features like signals, boxing of values, error handling and refcounting. Object type information is registered at runtime therefore offering good support for introspection (computer science). This support is used by language bindings and interface designers like Glade Interface Designer.
Compared to Objective-C, a language that extends C with a handful of keywords and a dynamic runtime, GObject is even more low-level in that it uses only C features (another difference is that Objective-C uses a message-passing model whereas GObject uses more conventional vtables). Unlike C++, object orientation with GObject does not allow multiple inheritance. Instead it uses interface classes comparable to Java programming language/C Sharp programming language interfaces.
A class in GObject is implemented by at least two C structs: One that holds the information for the class e.g. methods/vtable and another that contains the instance information e.g. member variables. There are no access modifiers public, protected, private like in the other mainstream object-oriented languages but private members can be implemented by declaring a struct in the C public header files of that class and defining it in the private C source. Lots of manual definitions of macros and initializers are necessary to create a new class. An optional tool called [http://www.jirka.org/gob.html GOB2] eases this process of writing objects for GObject by offering a Java like syntax. GOB2 acts as a preprocessor to the C compiler generating code from object templates.
The main drawback of the GObject framework is its verbosity. One of its biggest advantages comes from the C language: bindings can be made to any other language that has a C foreign function interface, dynamically typed or statically typed, garbage collected or not.
=History=
Before Gtk version 2.0 the object system was dependent on the Gtk userinterface libraries. It was decoupled and placed in its own independent framework to enable commandline applications and server applications without using the Gtk GUI library.
=Uses=
The combination of C and GObject is well accepted and used in many successful Open source projects including the GNOME desktop, GIMP, Midgard (software) and many others.
=External links=
|
|
