|
NAMEGlib::Type - Utilities for dealing with the GLib Type systemDESCRIPTIONThis package defines several utilities for dealing with the GLib type system from Perl. Because of some fundamental differences in how the GLib and Perl type systems work, a fair amount of the binding magic leaks out, and you can find most of that in the "Glib::Type::register*" functions, which register new types with the GLib type system.Most of the rest of the functions provide introspection functionality, such as listing properties and values and other cool stuff that is used mainly by Glib's reference documentation generator (see Glib::GenPod). METHODSlist = Glib::Type->list_ancestors ($package)
List the ancestry of package, as seen by the GLib type system. The important difference is that GLib's type system implements only single inheritance, whereas Perl's @ISA allows multiple inheritance. This returns the package names of the ancestral types in reverse order, with the root of the tree at the end of the list. See also list_interfaces (). list = Glib::Type->list_interfaces ($package)
List the GInterfaces implemented by the type associated with package. The interfaces are returned as package names. list = Glib::Type->list_signals ($package)
List the signals associated with package. This lists only the signals for package, not any of its parents. The signals are returned as a list of anonymous hashes which mirror the GSignalQuery structure defined in the C API reference.
list = Glib::Type->list_values ($package)
List the legal values for the GEnum or GFlags type $package. If $package is not a package name registered with the bindings, this name is passed on to g_type_from_name() to see if it's a registered flags or enum type that just hasn't been registered with the bindings by "gperl_register_fundamental()" (see Glib::xsapi). If $package is not the name of an enum or flags type, this function will croak. Returns the values as a list of hashes, one hash for each value, containing the value, name and nickname, eg. for Glib::SignalFlags { value => 8, name => 'G_SIGNAL_NO_RECURSE', nick => 'no-recurse' } string = Glib::Type->package_from_cname ($cname)
Convert a C type name to the corresponding Perl package name. If no package is registered to that type, returns $cname. Glib::Type->register ($parent_class, $new_class, ...)
Register a new type with the GLib type system. This is a traffic-cop function. If $parent_type derives from Glib::Object, this passes the arguments through to "register_object". If $parent_type is Glib::Flags or Glib::Enum, this strips $parent_type and passes the remaining args on to "register_enum" or "register_flags". See those functions' documentation for more information. Glib::Type->register_enum ($name, ...)
Register and initialize a new Glib::Enum type with the provided "values". This creates a type properly registered GLib so that it can be used for property and signal parameter or return types created with "Glib::Type->register" or "Glib::Object::Subclass". The list of values is used to create the "nicknames" that are used in general Perl code; the actual numeric values used at the C level are automatically assigned, starting with 1. If you need to specify a particular numeric value for a nick, use an array reference containing the nickname and the numeric value, instead. You may mix and match the two styles. Glib::Type->register_enum ('MyFoo::Bar', 'value-one', # assigned 1 'value-two', # assigned 2 ['value-three' => 15 ], # explicit 15 ['value-four' => 35 ], # explicit 35 'value-five', # assigned 5 ); If you use the array-ref form, beware: the code performs no validation for unique values. Glib::Type->register_flags ($name, ...)
Register and initialize a new Glib::Flags type with the provided "values". This creates a type properly registered GLib so that it can be used for property and signal parameter or return types created with "Glib::Type->register" or "Glib::Object::Subclass". The list of values is used to create the "nicknames" that are used in general Perl code; the actual numeric values used at the C level are automatically assigned, of the form 1<<i, starting with i = 0. If you need to specify a particular numeric value for a nick, use an array reference containing the nickname and the numeric value, instead. You may mix and match the two styles. Glib::Type->register_flags ('MyFoo::Baz', 'value-one', # assigned 1<<0 'value-two', # assigned 1<<1 ['value-three' => 1<<10 ], # explicit 1<<10 ['value-four' => 0x0f ], # explicit 0x0f 'value-five', # assigned 1<<4 ); If you use the array-ref form, beware: the code performs no validation for unique values. Glib::Type->register_object ($parent_package, $new_package, ...)
Register new_package as an officially GLib-sanctioned derivative of the (GObject derivative) parent_package. This automatically sets up an @ISA entry for you, and creates a new GObjectClass under the hood. The ... parameters are key/value pairs, currently supporting:
SEE ALSOGlibCOPYRIGHTCopyright (C) 2003-2011 by the gtk2-perl team.This software is licensed under the LGPL. See Glib for a full notice.
Visit the GSP FreeBSD Man Page Interface. |