mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 15:03:39 +02:00
gtype: Improve documentation for G_TYPE_IS_CLASSED and interfaces
The documentation previously implicitly said in a few places that interfaces are classed, but reading through the implementation of `GType`, I don’t think they are. If they were, the registration of the fundamental `G_TYPE_INTERFACE` in `gobject_init()` would specify `G_TYPE_FLAG_CLASSED`. It only specifies `G_TYPE_FLAG_DERIVABLE`. I think this makes sense, because you can’t subclass an interface. Subclassing is a key property of being classed. Tweak the `GType` tutorial to remove that implicit statement, and expand the documentation for `G_TYPE_IS_CLASSED`. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Fixes: #252
This commit is contained in:
@@ -304,6 +304,15 @@ G_BEGIN_DECLS
|
||||
*
|
||||
* Checks if @type is a classed type.
|
||||
*
|
||||
* A classed type has an associated #GTypeClass which can be derived to store
|
||||
* class-wide virtual function pointers and data for all instances of the type.
|
||||
* This allows for subclassing. All #GObjects are classed; none of the scalar
|
||||
* fundamental types built into GLib are classed.
|
||||
*
|
||||
* Interfaces are not classed: while their #GTypeInterface struct could be
|
||||
* considered similar to #GTypeClass, and classes can derive interfaces,
|
||||
* #GTypeInterface doesn’t allow for subclassing.
|
||||
*
|
||||
* Returns: %TRUE if @type is classed
|
||||
*/
|
||||
#define G_TYPE_IS_CLASSED(type) (g_type_test_flags ((type), G_TYPE_FLAG_CLASSED))
|
||||
|
Reference in New Issue
Block a user