GObject

GObject is released under the LGPL license -free software library and a framework that allows object-oriented programming in the C programming language and can be used on many platforms.

The approach of GObject corresponds to the Objective- C, which for application development on Mac OS X (see Cocoa ) is used. As a foundation for all GTK -/Gnome-Anwendungen GObject is the base class of all GTK-/Gnome-Klassen. This software library depends only on libc (see Standard C Library / glibc ) and GLib. GObject provides additional functionality such as Events, Boxing of data types, error handling and the reference counting ready. Object types can be registered at runtime. This is a good introspection of classes allows, but at the expense of a strong type safety.

Object orientation in GObject does not allow multiple inheritance, in contrast to C . Instead, interface classes as in Java or C # are used. A class in GObject is implemented by at least two C - structures: One of them contains the information of the class, for example, the methods / vtable and static member variables. The second contains the instance information for instance the member variables. There are no access modifiers public, protected, private and in the programming languages ​​C , C # or Java; but private class member can be implemented by additional hidden C structures. These private structures are not defined in the public header files of the class. When creating a GObject class initialization functions and many macros have to be written manually. To facilitate the writing of classes, there is the tool GOB2 ( GObject Builder), which offers a borrowed from Java syntax. GOB2 acts as a preprocessor, which is generated from the object templates code for the C compiler. An alternative to GOB2 represents the Vala programming language, which is next to the skeleton code also capable of all the source code from C # -like language to translate.

Important limitations of the GObjekt frameworks are the lack of support for namespaces, no way to overload operators and methods as well as the pure "manual" exception handling.

History

Originally, the object system of GTK was closely intertwined with the user interface of GTK. Only for version 2.0 of the GTK / Gnome it was outsourced to a private framework, so that this object system can also be used without the involvement of GTK for example, pure command-line -driven applications and server applications without a graphical user interface.

Use

The combination of C and GObject is used in many successful open source projects, most notably GTK and ultimately the complete Gnome desktop and GIMP, Pango and many others.

270457
de