diff options
73 files changed, 1469 insertions, 337 deletions
diff --git a/gir/gio-2.0.c b/gir/gio-2.0.c index c50c3931..93a3db80 100644 --- a/gir/gio-2.0.c +++ b/gir/gio-2.0.c @@ -133,10 +133,9 @@ * @get_action_state_hint: the virtual function pointer for g_action_group_get_action_state_hint() * @get_action_enabled: the virtual function pointer for g_action_group_get_action_enabled() * @get_action_state: the virtual function pointer for g_action_group_get_action_state() - * @set_action_state: the virtual function pointer for g_action_group_set_action_state() + * @change_action_state: the virtual function pointer for g_action_group_change_action_state() * @query_action: the virtual function pointer for g_action_group_query_action() * @activate_action: the virtual function pointer for g_action_group_activate_action() - * @change_action_state: the virtual function pointer for g_action_group_change_action_state() * @action_added: the class closure for the #GActionGroup::action-added signal * @action_removed: the class closure for the #GActionGroup::action-removed signal * @action_enabled_changed: the class closure for the #GActionGroup::action-enabled-changed signal @@ -1397,6 +1396,7 @@ * @get_info: Returns a #GDBusInterfaceInfo. See g_dbus_interface_get_info(). * @get_object: Gets the enclosing #GDBusObject. See g_dbus_interface_get_object(). * @set_object: Sets the enclosing #GDBusObject. See g_dbus_interface_set_object(). + * @dup_object: Gets a reference to the enclosing #GDBusObject. See g_dbus_interface_dup_object(). Added in 2.32. * * Base type for D-Bus interfaces. * @@ -2203,6 +2203,10 @@ * that both @changed_properties and @invalidated_properties are * guaranteed to never be %NULL (either may be empty though). * + * If the proxy has the flag + * %G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES set, then + * @invalidated_properties will always be empty. + * * This signal corresponds to the * <literal>PropertiesChanged</literal> D-Bus signal on the * <literal>org.freedesktop.DBus.Properties</literal> interface. @@ -2361,6 +2365,7 @@ * @G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES: Don't load properties. * @G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS: Don't connect to signals on the remote object. * @G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START: If not set and the proxy if for a well-known name, then request the bus to launch an owner for the name if no-one owns the name. This flag can only be used in proxies for well-known names. + * @G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES: If set, the property value for any <emphasis>invalidated property</emphasis> will be (asynchronously) retrieved upon receiving the <ulink url="http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-properties">PropertiesChanged</ulink> D-Bus signal and the property will not cause emission of the #GDBusProxy::g-properties-changed signal. When the value is received the #GDBusProxy::g-properties-changed signal is emitted for the property along with the retrieved value. Since 2.32. * * Flags used when constructing an instance of a #GDBusProxy derived class. * @@ -3413,9 +3418,9 @@ /** * GIOErrorEnum: * @G_IO_ERROR_FAILED: Generic error condition for when any operation fails. - * @G_IO_ERROR_NOT_FOUND: File not found error. - * @G_IO_ERROR_EXISTS: File already exists error. - * @G_IO_ERROR_IS_DIRECTORY: File is a directory error. + * @G_IO_ERROR_NOT_FOUND: File not found. + * @G_IO_ERROR_EXISTS: File already exists. + * @G_IO_ERROR_IS_DIRECTORY: File is a directory. * @G_IO_ERROR_NOT_DIRECTORY: File is not a directory. * @G_IO_ERROR_NOT_EMPTY: File is a directory that isn't empty. * @G_IO_ERROR_NOT_REGULAR_FILE: File is not a regular file. @@ -9688,6 +9693,7 @@ * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_VALUE_ARRAY. * * Returns: %TRUE on success. + * Deprecated: 2.32: Use #GArray instead of #GValueArray */ @@ -10097,6 +10103,8 @@ * @pspec: a valid #GParamSpec instance * * Cast a #GParamSpec instance into a #GParamSpecValueArray. + * + * Deprecated: 2.32: Use #GArray instead of #GValueArray */ @@ -11282,6 +11290,8 @@ * G_TYPE_PARAM_VALUE_ARRAY: * * The #GType of #GParamSpecValueArray. + * + * Deprecated: 2.32: Use #GArray instead of #GValueArray */ @@ -11470,6 +11480,8 @@ * * The type ID of the "GValueArray" type which is a boxed type, * used to pass around pointers to GValueArrays. + * + * Deprecated: 2.32: Use #GArray instead of #GValueArray */ @@ -14266,48 +14278,6 @@ /** - * SECTION:gmenumarkup - * @title: GMenu Markup - * @short_description: parsing and printing GMenuModel XML - * - * The functions here allow to instantiate #GMenuModels by parsing - * fragments of an XML document. - * * The XML format for #GMenuModel consists of a toplevel - * <tag class="starttag">menu</tag> element, which contains one or more - * <tag class="starttag">item</tag> elements. Each <tag class="starttag">item</tag> - * element contains <tag class="starttag">attribute</tag> and <tag class="starttag">link</tag> - * elements with a mandatory name attribute. - * <tag class="starttag">link</tag> elements have the same content - * model as <tag class="starttag">menu</tag>. - * - * Here is the XML for <xref linkend="menu-example"/>: - * |[<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../gio/menumarkup2.xml"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include>]| - * - * The parser also understands a somewhat less verbose format, in which - * attributes are encoded as actual XML attributes of <tag class="starttag">item</tag> - * elements, and <tag class="starttag">link</tag> elements are replaced by - * <tag class="starttag">section</tag> and <tag class="starttag">submenu</tag> elements. - * - * Here is how the example looks in this format: - * |[<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../gio/menumarkup.xml"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include>]| - * - * The parser can obtaing translations for attribute values using gettext. - * To make use of this, the <tag class="starttag">menu</tag> element must - * have a domain attribute which specifies the gettext domain to use, and - * <tag class="starttag">attribute</tag> elements can be marked for translation - * with a <literal>translatable="yes"</literal> attribute. It is also possible - * to specify message context and translator comments, using the context - * and comments attributes. - * - * The following DTD describes the XML format approximately: - * |[<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../gio/menumarkup.dtd"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include>]| - * - * To serialize a #GMenuModel into an XML fragment, use - * g_menu_markup_print_string(). - */ - - -/** * SECTION:gmenumodel * @title: GMenuModel * @short_description: An abstract class representing the contents of a menu @@ -14517,7 +14487,9 @@ * @short_description: Network status monitor * @include: gio/gio.h * - * + * #GNetworkMonitor provides an easy-to-use cross-platform API + * for monitoring network connectivity. On Linux, the implementation + * is based on the kernels netlink interface. */ @@ -14698,7 +14670,7 @@ * GMenu markup xml, CSS files, icons, etc. These are often shipped as files in <filename>$datadir/appname</filename>, or * manually included as literal strings in the code. * - * The #GResource API and the <link linkend="glib-compile-schemas">glib-compile-resources</link> program + * The #GResource API and the <link linkend="glib-compile-resources">glib-compile-resources</link> program * provide a convenient and efficient alternative to this which has some nice properties. You * maintain the files as normal files, so its easy to edit them, but during the build the files * are combined into a binary bundle that is linked into the executable. This means that loading @@ -14710,7 +14682,23 @@ * in a compressed form, but will be automatically uncompressed when the resource is used. This * is very useful e.g. for larger text files that are parsed once (or rarely) and then thrown away. * - * Resource bundles are created by the <link linkend="glib-compile-schemas">glib-compile-resources</link> program + * Resource files can also be marked to be preprocessed, by setting the value of the + * <literal>preprocess</literal> attribute to a comma-separated list of preprocessing options. + * The only options currently supported are: + * + * <literal>xml-stripblanks</literal> which will use <command>xmllint</command> to strip + * ignorable whitespace from the xml file. For this to work, the <envar>XMLLINT</envar> + * environment variable must be set to the full path to the xmllint executable, or xmllint + * must be in the PATH; otherwise the preprocessing step is skipped. + * + * <literal>to-pixdata</literal> which will use <command>gdk-pixbuf-pixdata</command> to convert + * images to the GdkPixdata format, which allows you to create pixbufs directly using the data inside + * the resource file, rather than an (uncompressed) copy if it. For this, the gdk-pixbuf-pixdata + * program must be in the PATH, or the <envar>GDK_PIXBUF_PIXDATA</envar> environment variable must be + * set to the full path to the gdk-pixbuf-pixdata executable; otherwise the resource compiler will + * abort. + * + * Resource bundles are created by the <link linkend="glib-compile-resources">glib-compile-resources</link> program * which takes an xml file that describes the bundle, and a set of files that the xml references. These * are combined into a binary resource bundle. * @@ -14721,7 +14709,7 @@ * <gresource prefix="/org/gtk/Example"> * <file>data/splashscreen.png</file> * <file compressed="true">dialog.ui</file> - * <file>menumarkup.xml</file> + * <file preprocess="xml-stripblanks">menumarkup.xml</file> * </gresource> * </gresources> * ]]></programlisting></example> @@ -14736,7 +14724,7 @@ * Note that all resources in the process share the same namespace, so use java-style * path prefixes (like in the above example) to avoid conflicts. * - * You can then use <link linkend="glib-compile-schemas">glib-compile-resources</link> to compile the xml to a + * You can then use <link linkend="glib-compile-resources">glib-compile-resources</link> to compile the xml to a * binary bundle that you can load with g_resource_load(). However, its more common to use the --generate-source and * --generate-header arguments to create a source file and header to link directly into your application. * @@ -15381,8 +15369,8 @@ * @include: gio/gio.h * @see_also: #GSocketConnection, #GSocketListener * - * #GSocketClient is a high-level utility class for connecting to a - * network host using a connection oriented socket type. + * #GSocketClient is a lightweight high-level utility class for connecting to + * a network host using a connection oriented socket type. * * You create a #GSocketClient object, set any options you want, and then * call a sync or async connect operation, which returns a #GSocketConnection @@ -15392,6 +15380,9 @@ * the underlying socket that is in use. For instance, for a TCP/IP connection * it will be a #GTcpConnection. * + * As #GSocketClient is a lightweight object, you don't need to cache it. You + * can just create a new one any time you need one. + * * Since: 2.22 */ @@ -17543,7 +17534,6 @@ /** * g_application_get_default: - * @returns: (transfer none): the default application for this process, or %NULL * * Returns the default #GApplication instance for this process. * @@ -17553,6 +17543,7 @@ * * If there is no default application then %NULL is returned. * + * Returns: (transfer none): the default application for this process, or %NULL * Since: 2.32 */ @@ -21499,6 +21490,20 @@ /** + * g_dbus_interface_dup_object: + * @interface_: An exported D-Bus interface. + * + * Gets the #GDBusObject that @interface_ belongs to, if any. + * + * reference should be freed with g_object_unref(). + * + * Returns: (transfer full): A #GDBusObject or %NULL. The returned + * Since: 2.32 + * Rename to: g_dbus_interface_get_object + */ + + +/** * g_dbus_interface_get_info: * @interface_: An exported D-Bus interface. * @@ -21511,11 +21516,16 @@ /** - * g_dbus_interface_get_object: + * g_dbus_interface_get_object: (skip) * @interface_: An exported D-Bus interface. * * Gets the #GDBusObject that @interface_ belongs to, if any. * + * <warning>It is not safe to use the returned object if @interface_ + * or the returned object is being used from other threads. See + * g_dbus_interface_dup_object() for a thread-safe + * alternative.</warning> + * * reference belongs to @interface_ and should not be freed. * * Returns: (transfer none): A #GDBusObject or %NULL. The returned @@ -28818,18 +28828,6 @@ /** - * g_inet_address_get_scope_id: - * @address: a %G_SOCKET_FAMILY_IPV6 #GInetAddress - * - * Gets the <literal>sin6_scope_id</literal> field from @address, - * which must be an IPv6 address. - * - * Returns: the scope id field - * Since: 2.32 - */ - - -/** * g_inet_address_mask_equal: * @mask: a #GInetAddressMask * @mask2: another #GInetAddressMask @@ -29048,6 +29046,18 @@ /** + * g_inet_socket_address_get_scope_id: + * @address: a %G_SOCKET_FAMILY_IPV6 #GInetAddress + * + * Gets the <literal>sin6_scope_id</literal> field from @address, + * which must be an IPv6 address. + * + * Returns: the scope id field + * Since: 2.32 + */ + + +/** * g_inet_socket_address_new: * @address: a #GInetAddress * @port: a port number @@ -31005,130 +31015,6 @@ /** - * g_menu_markup_parser_end: - * @context: a #GMarkupParseContext - * - * Stop the parsing of a set of menus and return the #GHashTable. - * - * The #GHashTable maps strings to #GObject instances. The parser only - * adds #GMenu instances to the table, but it may contain other types if - * a table was provided to g_menu_markup_parser_start(). - * - * This call should be matched with g_menu_markup_parser_start(). - * See that function for more information - * - * Returns: (transfer full): the #GHashTable containing the objects - * Since: 2.32 - */ - - -/** - * g_menu_markup_parser_end_menu: - * @context: a #GMarkupParseContext - * - * Stop the parsing of a menu and return the newly-created #GMenu. - * - * This call should be matched with g_menu_markup_parser_start_menu(). - * See that function for more information - * - * Returns: (transfer full): the newly-created #GMenu - * Since: 2.32 - */ - - -/** - * g_menu_markup_parser_start: - * @context: a #GMarkupParseContext - * @domain: (allow-none): translation domain for labels, or %NULL - * @objects: (allow-none): a #GHashTable for the objects, or %NULL - * - * Begin parsing a group of menus in XML form. - * - * If @domain is not %NULL, it will be used to translate attributes - * that are marked as translatable, using gettext(). - * - * If @objects is specified then it must be a #GHashTable that was - * created using g_hash_table_new_full() with g_str_hash(), - * g_str_equal(), g_free() and g_object_unref(). - * Any named menus (ie: <tag class="starttag">menu</tag>, - * <tag class="starttag">submenu</tag>, - * <tag class="starttag">section</tag> or <tag class="starttag">link</tag> - * elements with an id='' attribute) that are encountered while parsing - * will be added to this table. Each toplevel menu must be named. - * - * If @objects is %NULL then an empty hash table will be created. - * - * This function should be called from the start_element function for - * the element representing the group containing the menus. In other - * words, the content inside of this element is expected to be a list of - * menus. - * - * Since: 2.32 - */ - - -/** - * g_menu_markup_parser_start_menu: - * @context: a #GMarkupParseContext - * @domain: (allow-none): translation domain for labels, or %NULL - * @objects: (allow-none): a #GHashTable for the objects, or %NULL - * - * Begin parsing the XML definition of a menu. - * - * This function should be called from the start_element function for - * the element representing the menu itself. In other words, the - * content inside of this element is expected to be a list of items. - * - * If @domain is not %NULL, it will be used to translate attributes - * that are marked as translatable, using gettext(). - * - * If @objects is specified then it must be a #GHashTable that was - * created using g_hash_table_new_full() with g_str_hash(), - * g_str_equal(), g_free() and g_object_unref(). - * Any named menus (ie: <tag class="starttag">submenu</tag>, - * <tag class="starttag">section</tag> or <tag class="starttag">link</tag> - * elements with an id='' attribute) that are encountered while parsing - * will be added to this table. - * Note that toplevel <tag class="starttag">menu</tag> is not added to - * the hash table, even if it has an id attribute. - * - * If @objects is %NULL then named menus will not be supported. - * - * You should call g_menu_markup_parser_end_menu() from the - * corresponding end_element function in order to collect the newly - * parsed menu. - * - * Since: 2.32 - */ - - -/** - * g_menu_markup_print_stderr: - * @model: a #GMenuModel - * - * Print @model to stderr for debugging purposes. - * - * This debugging function will be removed in the future. - */ - - -/** - * g_menu_markup_print_string: - * @string: a #GString - * @model: the #GMenuModel to print - * @indent: the intentation level to start at - * @tabstop: how much to indent each level - * - * Print the contents of @model to @string. - * Note that you have to provide the containing - * <tag class="starttag">menu</tag> element yourself. - * - * Returns: @string - * Since: 2.32 - */ - - -/** * g_menu_model_get_item_attribute: * @model: a #GMenuModel * @item_index: the index of the item @@ -32073,6 +31959,39 @@ /** + * g_network_monitor_can_reach_async: + * @monitor: a #GNetworkMonitor + * @connectable: a #GSocketConnectable + * @cancellable: a #GCancellable, or %NULL + * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied + * @user_data: (closure): the data to pass to callback function + * + * Asynchronously attempts to determine whether or not the host + * pointed to by @connectable can be reached, without actually + * trying to connect to it. + * + * For more details, see g_network_monitor_can_reach(). + * + * When the operation is finished, @callback will be called. + * You can then call g_network_monitor_can_reach_finish() + * to get the result of the operation. + */ + + +/** + * g_network_monitor_can_reach_finish: + * @monitor: a #GNetworkMonitor + * @result: a #GAsyncResult + * @error: return location for errors, or %NULL + * + * Finishes an async network connectivity test. + * See g_network_monitor_can_reach_async(). + * + * Returns: %TRUE if network is reachable, %FALSE if not. + */ + + +/** * g_network_monitor_get_default: * * Gets the default #GNetworkMonitor for the system. @@ -32263,6 +32182,18 @@ /** + * g_node_insert_data_after: + * @parent: the #GNode to place the new #GNode under + * @sibling: the sibling #GNode to place the new #GNode after + * @data: the data for the new #GNode + * + * Inserts a new #GNode after the given sibling. + * + * Returns: the new #GNode + */ + + +/** * g_node_insert_data_before: * @parent: the #GNode to place the new #GNode under * @sibling: the sibling #GNode to place the new #GNode before @@ -33283,6 +33214,27 @@ /** * g_remote_action_group_activate_action_full: + * @remote: a #GDBusActionGroup + * @action_name: the name of the action to activate + * @parameter: (allow none): the optional parameter to the activation + * @platform_data: the platform data to send + * + * Activates the remote action. + * + * This is the same as g_action_group_activate_action() except that it + * allows for provision of "platform data" to be sent along with the + * activation request. This typically contains details such as the user + * interaction timestamp or startup notification information. + * + * @platform_data must be non-%NULL and must have the type + * %G_VARIANT_TYPE_VARDICT. If it is floating, it will be consumed. + * + * Since: 2.32 + */ + + +/** + * g_remote_action_group_change_action_state_full: * @remote: a #GRemoteActionGroup * @action_name: the name of the action to change the state of * @value: the new requested value for the state @@ -34210,6 +34162,31 @@ /** + * g_settings_create_action: + * @settings: a #GSettings + * @key: the name of a key in @settings + * + * Creates a #GAction corresponding to a given #GSettings key. + * + * The action has the same name as the key. + * + * The value of the key becomes the state of the action and the action + * is enabled when the key is writable. Changing the state of the + * action results in the key being written to. Changes to the value or + * writability of the key cause appropriate change notifications to be + * emitted for the action. + * + * For boolean-valued keys, action activations take no parameter and + * result in the toggling of the value. For all other types, + * activations take the new value for the key (which must have the + * correct type). + * + * Returns: (transfer full): a new #GAction + * Since: 2.32 + */ + + +/** * g_settings_delay: * @settings: a #GSettings object * @@ -35237,6 +35214,18 @@ /** + * g_signal_handlers_disconnect_by_data: + * @instance: The instance to remove handlers from + * @data: the closure data of the handlers' closures + * + * Disconnects all handlers on an instance that match @data. + * + * Returns: The number of handlers that matched. + * Since: 2.32 + */ + + +/** * g_signal_handlers_disconnect_by_func: * @instance: The instance to remove handlers from. * @func: The C closure callback of the handlers (useless for non-C closures). @@ -37072,7 +37061,7 @@ * g_socket_join_multicast_group: * @socket: a #GSocket. * @group: a #GInetAddress specifying the group address to join. - * @iface: Interface to use + * @iface: (allow-none): Name of the interface to use, or %NULL * @source_specific: %TRUE if source-specific multicast should be used * @error: #GError for error reporting, or %NULL to ignore. * @@ -37081,8 +37070,12 @@ * been bound to an appropriate interface and port with * g_socket_bind(). * + * If @iface is %NULL, the system will automatically pick an interface + * to bind to based on @group. + * * If @source_specific is %TRUE, source-specific multicast as defined - * in RFC 4604 is used. + * in RFC 4604 is used. Note that on older platforms this may fail + * with a %G_IO_ERROR_NOT_SUPPORTED error. * * Returns: %TRUE on success, %FALSE on error. * Since: 2.32 @@ -37093,15 +37086,16 @@ * g_socket_leave_multicast_group: * @socket: a #GSocket. * @group: a #GInetAddress specifying the group address to leave. - * @iface: Interface to use - * @source_specific: %TRUE if source-specific multicast should be used + * @iface: (allow-none): Interface used + * @source_specific: %TRUE if source-specific multicast was used * @error: #GError for error reporting, or %NULL to ignore. * - * Removes @socket from the multicast group @group (while still - * allowing it to receive unicast messages). + * Removes @socket from the multicast group defined by @group, @iface, + * and @source_specific (which must all have the same values they had + * when you joined the group). * - * If @source_specific is %TRUE, source-specific multicast as defined - * in RFC 4604 is used. + * @socket remains bound to its address and port, and can still receive + * unicast messages after calling this. * * Returns: %TRUE on success, %FALSE on error. * Since: 2.32 @@ -37786,7 +37780,7 @@ /** * g_socket_set_broadcast: * @socket: a #GSocket. - * @loopback: whether @socket should allow sending to and receiving from broadcast addresses + * @broadcast: whether @socket should allow sending to and receiving from broadcast addresses * * Sets whether @socket should allow sending to and receiving from * broadcast addresses. This is %FALSE by default. @@ -38051,6 +38045,50 @@ /** + * g_static_resource_fini: + * @static_resource: pointer to a static #GStaticResource. + * + * Finalized a GResource initialized by g_static_resource_init (). + * + * This is normally used by code generated by + * <link linkend="glib-compile-resources">glib-compile-resources</link> and is + * not typically used by other code. + * + * Since: 2.32 + */ + + +/** + * g_static_resource_get_resource: + * @static_resource: pointer to a static #GStaticResource. + * + * Gets the GResource that was registred by a call to g_static_resource_init (). + * + * This is normally used by code generated by + * <link linkend="glib-compile-resources">glib-compile-resources</link> and is + * not typically used by other code. + * + * Returns: (transfer none): a #GResource. + * Since: 2.32 + */ + + +/** + * g_static_resource_init: + * @static_resource: pointer to a static #GStaticResource. + * + * Initializes a GResource from static data using a + * GStaticResource. + * + * This is normally used by code generated by + * <link linkend="glib-compile-resources">glib-compile-resources</link> and is + * not typically used by other code. + * + * Since: 2.32 + */ + + +/** * g_tcp_connection_get_graceful_disconnect: * @connection: a #GTcpConnection * @@ -39283,10 +39321,13 @@ * @password: a #GTlsPassword object * @length: (allow-none): location to place the length of the password. * - * Get the password value. If @length is not %NULL then it will be filled - * in with the length of the password value. + * Get the password value. If @length is not %NULL then it will be + * filled in with the length of the password value. (Note that the + * password value is not nul-terminated, so you can only pass %NULL + * for @length in contexts where you know the password will have a + * certain fixed length.) * - * Returns: The password value owned by the password object. + * Returns: The password value (owned by the password object). * Since: 2.30 */ @@ -39346,9 +39387,10 @@ * Set the value for this password. The @value will be copied by the password * object. * - * Specify the @length, for a non-null-terminated password. Pass -1 as - * @length if using a null-terminated password, and @length will be calculated - * automatically. + * Specify the @length, for a non-nul-terminated password. Pass -1 as + * @length if using a nul-terminated password, and @length will be + * calculated automatically. (Note that the terminating nul is not + * considered part of the password in this case.) * * Since: 2.30 */ @@ -39366,9 +39408,10 @@ * The @value will be owned by the password object, and later freed using * the @destroy function callback. * - * Specify the @length, for a non-null-terminated password. Pass -1 as - * @length if using a null-terminated password, and @length will be calculated - * automatically. + * Specify the @length, for a non-nul-terminated password. Pass -1 as + * @length if using a nul-terminated password, and @length will be + * calculated automatically. (Note that the terminating nul is not + * considered part of the password in this case.) * * Virtual: set_value * Since: 2.30 @@ -40988,9 +41031,9 @@ /** * g_win32_input_stream_new: * @handle: a Win32 file handle - * @close_fd: %TRUE to close the handle when done + * @close_handle: %TRUE to close the handle when done * - * Creates a new #GWin32InputStream for the given @fd. + * Creates a new #GWin32InputStream for the given @handle. * * If @close_handle is %TRUE, the handle will be closed * when the stream is closed. diff --git a/gir/glib-2.0.c b/gir/glib-2.0.c index 551c0844..2c5d7fee 100644 --- a/gir/glib-2.0.c +++ b/gir/glib-2.0.c @@ -972,11 +972,24 @@ * g_direct_hash() is also the appropriate hash function for keys * of the form <literal>GINT_TO_POINTER (n)</literal> (or similar macros). * - * <!-- FIXME: Need more here. --> The hash values should be evenly - * distributed over a fairly large range? The modulus is taken with the - * hash table size (a prime number) to find the 'bucket' to place each - * key into. The function should also be very fast, since it is called - * for each key lookup. + * <!-- FIXME: Need more here. --> A good hash functions should produce + * hash values that are evenly distributed over a fairly large range. + * The modulus is taken with the hash table size (a prime number) to + * find the 'bucket' to place each key into. The function should also + * be very fast, since it is called for each key lookup. + * + * Note that the hash functions provided by GLib have these qualities, + * but are not particularly robust against manufactured keys that + * cause hash collisions. Therefore, you should consider choosing + * a more secure hash function when using a GHashTable with keys + * that originate in untrusted data (such as HTTP requests). + * Using g_str_hash() in that situation might make your application + * vulerable to <ulink url="https://lwn.net/Articles/474912/">Algorithmic Complexity Attacks</ulink>. + * + * The key to choosing a good hash is unpredictability. Even + * cryptographic hashes are very easy to find collisions for when the + * remainder is taken modulo a somewhat predictable prime number. There + * must be an element of randomness that an attacker is unable to guess. * * Returns: the hash value corresponding to the key */ @@ -6177,6 +6190,7 @@ * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_VALUE_ARRAY. * * Returns: %TRUE on success. + * Deprecated: 2.32: Use #GArray instead of #GValueArray */ @@ -7258,6 +7272,8 @@ * @pspec: a valid #GParamSpec instance * * Cast a #GParamSpec instance into a #GParamSpecValueArray. + * + * Deprecated: 2.32: Use #GArray instead of #GValueArray */ @@ -8603,6 +8619,8 @@ * G_TYPE_PARAM_VALUE_ARRAY: * * The #GType of #GParamSpecValueArray. + * + * Deprecated: 2.32: Use #GArray instead of #GValueArray */ @@ -8766,6 +8784,8 @@ * * The type ID of the "GValueArray" type which is a boxed type, * used to pass around pointers to GValueArrays. + * + * Deprecated: 2.32: Use #GArray instead of #GValueArray */ @@ -9778,7 +9798,7 @@ * available in the queue at that point, the thread is now put to sleep * until a message arrives. The message will be removed from the queue * and returned. The functions g_async_queue_try_pop() and - * g_async_queue_timed_pop() can be used to only check for the presence + * g_async_queue_timeout_pop() can be used to only check for the presence * of messages or to only wait a certain time for messages respectively. * * For almost every function there exist two variants, one that locks @@ -12750,8 +12770,9 @@ * g_node_insert_before(), g_node_append() and g_node_prepend(). * * To create a new node and insert it into a tree use - * g_node_insert_data(), g_node_insert_data_before(), - * g_node_append_data() and g_node_prepend_data(). + * g_node_insert_data(), g_node_insert_data_after(), + * g_node_insert_data_before(), g_node_append_data() + * and g_node_prepend_data(). * * To reverse the children of a node use g_node_reverse_children(). * @@ -13201,6 +13222,25 @@ /** + * g_array_set_clear_func: + * @array: A #GArray + * @clear_func: a function to clear an element of @array + * + * Sets a function to clear an element of @array. + * + * The @clear_func will be called when an element in the array + * data segment is removed and when the array is freed and data + * segment is deallocated as well. + * + * Note that in contrast with other uses of #GDestroyNotify + * functions, @clear_func is expected to clear the contents of + * the array element it is given, but not free the element itself. + * + * Since: 2.32 + */ + + +/** * g_array_set_size: * @array: a #GArray. * @length: the new size of the #GArray. @@ -14150,6 +14190,7 @@ * received before @end_time. * * Returns: data from the queue or %NULL, when no data is + * Deprecated: use g_async_queue_timeout_pop(). */ @@ -14171,6 +14212,41 @@ * received before @end_time. * * Returns: data from the queue or %NULL, when no data is + * Deprecated: use g_async_queue_timeout_pop_unlocked(). + */ + + +/** + * g_async_queue_timeout_pop: + * @queue: a #GAsyncQueue + * @timeout: the number of microseconds to wait + * + * Pops data from the @queue. If the queue is empty, blocks for + * @timeout microseconds, or until data becomes available. + * + * If no data is received before the timeout, %NULL is returned. + * + * received before the timeout. + * + * Returns: data from the queue or %NULL, when no data is + */ + + +/** + * g_async_queue_timeout_pop_unlocked: + * @queue: a #GAsyncQueue + * @time: the number of microseconds to wait + * + * Pops data from the @queue. If the queue is empty, blocks for + * @timeout microseconds, or until data becomes available. + * + * If no data is received before the timeout, %NULL is returned. + * + * This function must be called while holding the @queue's lock. + * + * received before the timeout. + * + * Returns: data from the queue or %NULL, when no data is */ @@ -15191,7 +15267,7 @@ * @full_path. If the file could not be loaded then an %error is * set to either a #GFileError or #GBookmarkFileError. * - * Returns: %TRUE if a key file could be loaded, %FALSE othewise + * Returns: %TRUE if a key file could be loaded, %FALSE otherwise * Since: 2.12 */ @@ -16485,7 +16561,7 @@ * Notice that the end time is calculated once, before entering the * loop and reused. This is the motivation behind the use of absolute * time on this API -- if a relative time of 5 seconds were passed - * directly to the call and a spurious wakeup occured, the program would + * directly to the call and a spurious wakeup occurred, the program would * have to start over waiting again (which would lead to a total wait * time of more than 5 seconds). * @@ -16657,7 +16733,7 @@ * @key: the string identifying a data element. * @Returns: the data element, or %NULL if it is not found. * - * Gets a data element, using its string identifer. This is slower than + * Gets a data element, using its string identifier. This is slower than * g_datalist_id_get_data() because it compares strings. */ @@ -17004,7 +17080,7 @@ * @lhs: first date to compare * @rhs: second date to compare * - * qsort()-style comparsion function for dates. + * qsort()-style comparison function for dates. * Both dates must be valid. * * greater than zero if @lhs is greater than @rhs @@ -19712,8 +19788,8 @@ * On Windows, "limitations of the OS kernel" is a rather substantial * statement. Depending on the configuration of the system, the wall * clock time is updated as infrequently as 64 times a second (which - * is approximately every 16ms). Also, the on XP (not on Vista or later) - * the monitonic clock is locally monotonic, but may differ in exact + * is approximately every 16ms). Also, on XP (but not on Vista or later) + * the monotonic clock is locally monotonic, but may differ in exact * value between processes due to timer wrap handling. * * Returns: the monotonic time, in microseconds @@ -22221,8 +22297,8 @@ /** * g_key_file_load_from_data: * @key_file: an empty #GKeyFile struct - * @data: (array length=length): key file loaded in memory - * @length: the length of @data in bytes + * @data: key file loaded in memory + * @length: the length of @data in bytes (or -1 if data is nul-terminated) * @flags: flags from #GKeyFileFlags * @error: return location for a #GError, or %NULL * @@ -25467,6 +25543,18 @@ /** + * g_node_insert_data_after: + * @parent: the #GNode to place the new #GNode under + * @sibling: the sibling #GNode to place the new #GNode after + * @data: the data for the new #GNode + * + * Inserts a new #GNode after the given sibling. + * + * Returns: the new #GNode + */ + + +/** * g_node_insert_data_before: * @parent: the #GNode to place the new #GNode under * @sibling: the sibling #GNode to place the new #GNode before @@ -29376,7 +29464,7 @@ * Removes the item pointed to by @iter. It is an error to pass the * end iterator to this function. * - * If the sequnce has a data destroy function associated with it, this + * If the sequence has a data destroy function associated with it, this * function is called on the data for the removed item. * * Since: 2.14 @@ -29799,6 +29887,18 @@ /** + * g_signal_handlers_disconnect_by_data: + * @instance: The instance to remove handlers from + * @data: the closure data of the handlers' closures + * + * Disconnects all handlers on an instance that match @data. + * + * Returns: The number of handlers that matched. + * Since: 2.32 + */ + + +/** * g_signal_handlers_disconnect_by_func: * @instance: The instance to remove handlers from. * @func: The C closure callback of the handlers (useless for non-C closures). @@ -30623,7 +30723,7 @@ * self->idle_id = 0; * GDK_THREADS_LEAVE (<!-- -->); * - * return FALSE; + * return G_SOURCE_REMOVE; * } * * static void @@ -39219,7 +39319,7 @@ * This is an internal function and should only be used by * the internals of glib (such as libgio). * - * Returns: the transation of @str to the current locale + * Returns: the translation of @str to the current locale */ diff --git a/gir/gobject-2.0.c b/gir/gobject-2.0.c index 07a4d544..b7fc6b4c 100644 --- a/gir/gobject-2.0.c +++ b/gir/gobject-2.0.c @@ -3145,6 +3145,7 @@ * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_VALUE_ARRAY. * * Returns: %TRUE on success. + * Deprecated: 2.32: Use #GArray instead of #GValueArray */ @@ -3544,6 +3545,8 @@ * @pspec: a valid #GParamSpec instance * * Cast a #GParamSpec instance into a #GParamSpecValueArray. + * + * Deprecated: 2.32: Use #GArray instead of #GValueArray */ @@ -4590,6 +4593,8 @@ * G_TYPE_PARAM_VALUE_ARRAY: * * The #GType of #GParamSpecValueArray. + * + * Deprecated: 2.32: Use #GArray instead of #GValueArray */ @@ -4753,6 +4758,8 @@ * * The type ID of the "GValueArray" type which is a boxed type, * used to pass around pointers to GValueArrays. + * + * Deprecated: 2.32: Use #GArray instead of #GValueArray */ @@ -5984,6 +5991,23 @@ * object property that holds an array of values. A #GValueArray wraps * an array of #GValue elements in order for it to be used as a boxed * type through %G_TYPE_VALUE_ARRAY. + * + * #GValueArray is deprecated in favour of #GArray since GLib 2.32. It + * is possible to create a #GArray that behaves like a #GValueArray by + * using the size of #GValue as the element size, and by setting + * g_value_unset() as the clear function using g_array_set_clear_func(), + * for instance, the following code: + * + * |[ + * GValueArray *array = g_value_array_new (10); + * ]| + * + * can be replaced by: + * + * |[ + * GArray *array = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 10); + * g_array_set_clear_func (array, (GDestroyNotify) g_value_unset); + * ]| */ @@ -7142,6 +7166,18 @@ /** + * g_node_insert_data_after: + * @parent: the #GNode to place the new #GNode under + * @sibling: the sibling #GNode to place the new #GNode after + * @data: the data for the new #GNode + * + * Inserts a new #GNode after the given sibling. + * + * Returns: the new #GNode + */ + + +/** * g_node_insert_data_before: * @parent: the #GNode to place the new #GNode under * @sibling: the sibling #GNode to place the new #GNode before @@ -9347,6 +9383,18 @@ /** + * g_signal_handlers_disconnect_by_data: + * @instance: The instance to remove handlers from + * @data: the closure data of the handlers' closures + * + * Disconnects all handlers on an instance that match @data. + * + * Returns: The number of handlers that matched. + * Since: 2.32 + */ + + +/** * g_signal_handlers_disconnect_by_func: * @instance: The instance to remove handlers from. * @func: The C closure callback of the handlers (useless for non-C closures). @@ -10720,6 +10768,7 @@ * %NULL, an uninitialized value is appended. * * Returns: (transfer none): the #GValueArray passed in as @value_array + * Deprecated: 2.32: Use #GArray and g_array_append_val() instead. */ @@ -10731,6 +10780,7 @@ * contents. * * Returns: (transfer full): Newly allocated copy of #GValueArray + * Deprecated: 2.32: Use #GArray and g_array_ref() instead. */ @@ -10739,6 +10789,8 @@ * @value_array: #GValueArray to free * * Free a #GValueArray including its contents. + * + * Deprecated: 2.32: Use #GArray and g_array_unref() instead. */ @@ -10750,6 +10802,7 @@ * Return a pointer to the value at @index_ containd in @value_array. * * Returns: (transfer none): pointer to a value at @index_ in @value_array + * Deprecated: 2.32: Use g_array_index() instead. */ @@ -10763,6 +10816,7 @@ * is %NULL, an uninitialized value is inserted. * * Returns: (transfer none): the #GValueArray passed in as @value_array + * Deprecated: 2.32: Use #GArray and g_array_insert_val() instead. */ @@ -10775,6 +10829,7 @@ * regardless of the value of @n_prealloced. * * Returns: a newly allocated #GValueArray with 0 values + * Deprecated: 2.32: Use #GArray and g_array_sized_new() instead. */ @@ -10787,6 +10842,7 @@ * %NULL, an uninitialized value is prepended. * * Returns: (transfer none): the #GValueArray passed in as @value_array + * Deprecated: 2.32: Use #GArray and g_array_prepend_val() instead. */ @@ -10798,6 +10854,7 @@ * Remove the value at position @index_ from @value_array. * * Returns: (transfer none): the #GValueArray passed in as @value_array + * Deprecated: 2.32: Use #GArray and g_array_remove_index() instead. */ @@ -10812,6 +10869,7 @@ * The current implementation uses Quick-Sort as sorting algorithm. * * Returns: (transfer none): the #GValueArray passed in as @value_array + * Deprecated: 2.32: Use #GArray and g_array_sort(). */ @@ -10828,6 +10886,7 @@ * * Rename to: g_value_array_sort * Returns: (transfer none): the #GValueArray passed in as @value_array + * Deprecated: 2.32: Use #GArray and g_array_sort_with_data(). */ diff --git a/girepository/gdump.c b/girepository/gdump.c index c237a81e..7e02d391 100644 --- a/girepository/gdump.c +++ b/girepository/gdump.c @@ -1,4 +1,5 @@ -/* GObject introspection: Dump introspection data +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Dump introspection data * * Copyright (C) 2008 Colin Walters <walters@verbum.org> * diff --git a/girepository/gi-dump-types.c b/girepository/gi-dump-types.c index eacf8a01..13e7ae68 100644 --- a/girepository/gi-dump-types.c +++ b/girepository/gi-dump-types.c @@ -1,3 +1,4 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ #include "gdump.c" #include <gio/gunixoutputstream.h> diff --git a/girepository/giarginfo.c b/girepository/giarginfo.c index 0d1f0bbf..d61f4be2 100644 --- a/girepository/giarginfo.c +++ b/girepository/giarginfo.c @@ -1,4 +1,5 @@ -/* GObject introspection: Argument implementation +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Argument implementation * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/giarginfo.h b/girepository/giarginfo.h index 9daafa27..3f4163e3 100644 --- a/girepository/giarginfo.h +++ b/girepository/giarginfo.h @@ -1,4 +1,5 @@ -/* GObject introspection: Argument +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Argument * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/gibaseinfo.c b/girepository/gibaseinfo.c index ab4ce3cf..ff9c9395 100644 --- a/girepository/gibaseinfo.c +++ b/girepository/gibaseinfo.c @@ -1,4 +1,5 @@ -/* GObject introspection: Base struct implementation +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Base struct implementation * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/gibaseinfo.h b/girepository/gibaseinfo.h index 7bb1cab0..54c8ee4f 100644 --- a/girepository/gibaseinfo.h +++ b/girepository/gibaseinfo.h @@ -1,4 +1,5 @@ -/* GObject introspection: GIBaseInfo +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: GIBaseInfo * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/gicallableinfo.c b/girepository/gicallableinfo.c index 475346e2..28043fa5 100644 --- a/girepository/gicallableinfo.c +++ b/girepository/gicallableinfo.c @@ -1,4 +1,5 @@ -/* GObject introspection: Callable implementation +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Callable implementation * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/gicallableinfo.h b/girepository/gicallableinfo.h index a1d22c74..0c5fac79 100644 --- a/girepository/gicallableinfo.h +++ b/girepository/gicallableinfo.h @@ -1,4 +1,5 @@ -/* GObject introspection: Callable +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Callable * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/giconstantinfo.c b/girepository/giconstantinfo.c index 2c3cc292..88220b4e 100644 --- a/girepository/giconstantinfo.c +++ b/girepository/giconstantinfo.c @@ -1,4 +1,5 @@ -/* GObject introspection: Constant implementation +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Constant implementation * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/giconstantinfo.h b/girepository/giconstantinfo.h index 2e7d697f..2bbf9569 100644 --- a/girepository/giconstantinfo.h +++ b/girepository/giconstantinfo.h @@ -1,4 +1,5 @@ -/* GObject introspection: Constant +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Constant * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/gienuminfo.c b/girepository/gienuminfo.c index eeade756..a9b7c1df 100644 --- a/girepository/gienuminfo.c +++ b/girepository/gienuminfo.c @@ -1,4 +1,5 @@ -/* GObject introspection: Enum implementation +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Enum implementation * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/gienuminfo.h b/girepository/gienuminfo.h index def97f95..0b9a9e1b 100644 --- a/girepository/gienuminfo.h +++ b/girepository/gienuminfo.h @@ -1,4 +1,5 @@ -/* GObject introspection: Enum and Enum values +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Enum and Enum values * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/gifieldinfo.c b/girepository/gifieldinfo.c index 41976855..1d9a20dd 100644 --- a/girepository/gifieldinfo.c +++ b/girepository/gifieldinfo.c @@ -1,4 +1,5 @@ -/* GObject introspection: Field implementation +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Field implementation * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/gifieldinfo.h b/girepository/gifieldinfo.h index 589221b7..4ca54093 100644 --- a/girepository/gifieldinfo.h +++ b/girepository/gifieldinfo.h @@ -1,4 +1,5 @@ -/* GObject introspection: Field and Field values +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Field and Field values * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/gifunctioninfo.c b/girepository/gifunctioninfo.c index 2544cc3f..92f4ccd2 100644 --- a/girepository/gifunctioninfo.c +++ b/girepository/gifunctioninfo.c @@ -1,4 +1,5 @@ -/* GObject introspection: Function implementation +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Function implementation * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/gifunctioninfo.h b/girepository/gifunctioninfo.h index b2fa1f76..7a9ecae0 100644 --- a/girepository/gifunctioninfo.h +++ b/girepository/gifunctioninfo.h @@ -1,4 +1,5 @@ -/* GObject introspection: Function +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Function * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/giinterfaceinfo.c b/girepository/giinterfaceinfo.c index e3e721d8..69cd63d9 100644 --- a/girepository/giinterfaceinfo.c +++ b/girepository/giinterfaceinfo.c @@ -1,4 +1,5 @@ -/* GObject introspection: Interface implementation +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Interface implementation * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/giinterfaceinfo.h b/girepository/giinterfaceinfo.h index 4f4c05c9..8cab9961 100644 --- a/girepository/giinterfaceinfo.h +++ b/girepository/giinterfaceinfo.h @@ -1,4 +1,5 @@ -/* GObject introspection: Interface +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Interface * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/ginvoke.c b/girepository/ginvoke.c index 0f9d22c9..84e1e748 100644 --- a/girepository/ginvoke.c +++ b/girepository/ginvoke.c @@ -1,4 +1,5 @@ -/* GObject introspection: Invoke functionality +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Invoke functionality * * Copyright (C) 2005 Matthias Clasen * diff --git a/girepository/giobjectinfo.c b/girepository/giobjectinfo.c index 4aca8bd4..3b8f64bb 100644 --- a/girepository/giobjectinfo.c +++ b/girepository/giobjectinfo.c @@ -1,4 +1,5 @@ -/* GObject introspection: Object implementation +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Object implementation * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. @@ -660,6 +661,66 @@ g_object_info_find_vfunc (GIObjectInfo *info, } /** + * g_object_info_find_vfunc_using_interfaces: + * @info: a #GIObjectInfo + * @name: name of method to obtain + * @implementor: (out) (transfer full): The implementor of the interface + * + * Locate a virtual function slot with name @name, searching both the object + * @info and any interfaces it implements. Note that the namespace for + * virtuals is distinct from that of methods; there may or may not be a + * concrete method associated for a virtual. If there is one, it may be + * retrieved using g_vfunc_info_get_invoker(), otherwise %NULL will be + * returned. + * + * Note that this function does *not* search parent classes; you will have + * to chain up if that's desired. + * + * Returns: (transfer full): the #GIFunctionInfo. Free the struct by calling + * g_base_info_unref() when done. + */ +GIVFuncInfo * +g_object_info_find_vfunc_using_interfaces (GIObjectInfo *info, + const gchar *name, + GIObjectInfo **implementor) +{ + GIVFuncInfo *result = NULL; + GIObjectInfo *implementor_result = NULL; + + result = g_object_info_find_vfunc (info, name); + if (result) + implementor_result = g_base_info_ref ((GIBaseInfo*) info); + + if (result == NULL) + { + int n_interfaces; + int i; + + n_interfaces = g_object_info_get_n_interfaces (info); + for (i = 0; i < n_interfaces; ++i) + { + GIInterfaceInfo *iface_info; + + iface_info = g_object_info_get_interface (info, i); + + result = g_interface_info_find_vfunc (iface_info, name); + + if (result != NULL) + { + implementor_result = iface_info; + break; + } + g_base_info_unref ((GIBaseInfo*) iface_info); + } + } + if (implementor) + *implementor = implementor_result; + else if (implementor_result != NULL) + g_base_info_unref ((GIBaseInfo*) implementor_result); + return result; +} + +/** * g_object_info_get_n_constants: * @info: a #GIObjectInfo * diff --git a/girepository/giobjectinfo.h b/girepository/giobjectinfo.h index fd35ef8f..ee4b8a82 100644 --- a/girepository/giobjectinfo.h +++ b/girepository/giobjectinfo.h @@ -1,4 +1,5 @@ -/* GObject introspection: Object +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Object * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. @@ -108,6 +109,9 @@ GIVFuncInfo * g_object_info_get_vfunc (GIObjectInfo *info, gint n); GIVFuncInfo * g_object_info_find_vfunc (GIObjectInfo *info, const gchar *name); +GIVFuncInfo * g_object_info_find_vfunc_using_interfaces (GIObjectInfo *info, + const gchar *name, + GIObjectInfo **implementor); gint g_object_info_get_n_constants (GIObjectInfo *info); GIConstantInfo * g_object_info_get_constant (GIObjectInfo *info, gint n); diff --git a/girepository/gipropertyinfo.c b/girepository/gipropertyinfo.c index 552c0c3e..61316cb9 100644 --- a/girepository/gipropertyinfo.c +++ b/girepository/gipropertyinfo.c @@ -1,4 +1,5 @@ -/* GObject introspection: Property implementation +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Property implementation * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/gipropertyinfo.h b/girepository/gipropertyinfo.h index 487389cb..14b18b41 100644 --- a/girepository/gipropertyinfo.h +++ b/girepository/gipropertyinfo.h @@ -1,4 +1,5 @@ -/* GObject introspection: Property +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Property * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/giregisteredtypeinfo.c b/girepository/giregisteredtypeinfo.c index 6c1b9321..6e3d31e2 100644 --- a/girepository/giregisteredtypeinfo.c +++ b/girepository/giregisteredtypeinfo.c @@ -1,4 +1,5 @@ -/* GObject introspection: Registered Type implementation +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Registered Type implementation * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/giregisteredtypeinfo.h b/girepository/giregisteredtypeinfo.h index 76a1ee22..d46d738b 100644 --- a/girepository/giregisteredtypeinfo.h +++ b/girepository/giregisteredtypeinfo.h @@ -1,4 +1,5 @@ -/* GObject introspection: Registered Type +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Registered Type * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/girepository-private.h b/girepository/girepository-private.h index 52d65b2b..05b13626 100644 --- a/girepository/girepository-private.h +++ b/girepository/girepository-private.h @@ -1,5 +1,5 @@ -/* -*- Mode: C; c-file-style: "gnu"; -*- */ -/* GObject introspection: Private headers +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Private headers * * Copyright (C) 2010 Johan Dahlin * diff --git a/girepository/girepository.c b/girepository/girepository.c index b5cd4c7c..1384c0e9 100644 --- a/girepository/girepository.c +++ b/girepository/girepository.c @@ -1,5 +1,5 @@ -/* -*- Mode: C; c-file-style: "gnu"; -*- */ -/* GObject introspection: Repository implementation +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Repository implementation * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008 Colin Walters <walters@verbum.org> @@ -93,7 +93,9 @@ g_irepository_init (GIRepository *repository) (GDestroyNotify) NULL, (GDestroyNotify) g_typelib_free); repository->priv->lazy_typelibs - = g_hash_table_new (g_str_hash, g_str_equal); + = g_hash_table_new_full (g_str_hash, g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) NULL); repository->priv->info_by_gtype = g_hash_table_new_full (g_direct_hash, g_direct_equal, (GDestroyNotify) NULL, diff --git a/girepository/girepository.h b/girepository/girepository.h index 9e99f6e3..02bd4a10 100644 --- a/girepository/girepository.h +++ b/girepository/girepository.h @@ -1,4 +1,5 @@ -/* GObject introspection: Repository +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Repository * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/girffi.c b/girepository/girffi.c index 3bddb724..11400613 100644 --- a/girepository/girffi.c +++ b/girepository/girffi.c @@ -1,4 +1,5 @@ -/* GObject introspection: Helper functions for ffi integration +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Helper functions for ffi integration * * Copyright (C) 2008 Red Hat, Inc * Copyright (C) 2005 Matthias Clasen @@ -230,13 +231,7 @@ g_function_info_prep_invoker (GIFunctionInfo *info, GError **error) { const char *symbol; - ffi_type *rtype; - ffi_type **atypes; - GITypeInfo *tinfo; - GIArgInfo *ainfo; - gboolean is_method; - gboolean throws; - gint n_args, n_invoke_args, i; + gpointer addr; g_return_val_if_fail (info != NULL, FALSE); g_return_val_if_fail (invoker != NULL, FALSE); @@ -244,7 +239,7 @@ g_function_info_prep_invoker (GIFunctionInfo *info, symbol = g_function_info_get_symbol ((GIFunctionInfo*) info); if (!g_typelib_symbol (g_base_info_get_typelib((GIBaseInfo *) info), - symbol, &(invoker->native_address))) + symbol, &addr)) { g_set_error (error, G_INVOKE_ERROR, @@ -254,15 +249,79 @@ g_function_info_prep_invoker (GIFunctionInfo *info, return FALSE; } - is_method = (g_function_info_get_flags (info) & GI_FUNCTION_IS_METHOD) != 0 - && (g_function_info_get_flags (info) & GI_FUNCTION_IS_CONSTRUCTOR) == 0; - throws = g_function_info_get_flags (info) & GI_FUNCTION_THROWS; + return g_function_invoker_new_for_address (addr, info, invoker, error); +} + +/** + * g_function_invoker_new_for_address: + * @addr: The address + * @info: A #GICallableInfo + * @invoker: Output invoker structure + * @error: A #GError + * + * Initialize the caller-allocated @invoker structure with a cache + * of information needed to invoke the C function corresponding to + * @info with the platform's default ABI. + * + * A primary intent of this function is that a dynamic structure allocated + * by a language binding could contain a #GIFunctionInvoker structure + * inside the binding's function mapping. + * + * Returns: %TRUE on success, %FALSE otherwise with @error set. + */ +gboolean +g_function_invoker_new_for_address (gpointer addr, + GICallableInfo *info, + GIFunctionInvoker *invoker, + GError **error) +{ + ffi_type *rtype; + ffi_type **atypes; + GITypeInfo *tinfo; + GIArgInfo *ainfo; + GIInfoType info_type; + gboolean is_method; + gboolean throws; + gint n_args, n_invoke_args, i; + + g_return_val_if_fail (info != NULL, FALSE); + g_return_val_if_fail (invoker != NULL, FALSE); + + invoker->native_address = addr; + + info_type = g_base_info_get_type ((GIBaseInfo *) info); + + switch (info_type) + { + case GI_INFO_TYPE_FUNCTION: + { + GIFunctionInfoFlags flags; + flags = g_function_info_get_flags ((GIFunctionInfo *)info); + is_method = (flags & GI_FUNCTION_IS_METHOD) != 0; + throws = (flags & GI_FUNCTION_THROWS) != 0; + } + break; + case GI_INFO_TYPE_VFUNC: + { + GIVFuncInfoFlags flags; + flags = g_vfunc_info_get_flags ((GIVFuncInfo *)info); + throws = (flags & GI_VFUNC_THROWS) != 0; + } + is_method = TRUE; + break; + case GI_INFO_TYPE_CALLBACK: + is_method = TRUE; + throws = FALSE; + break; + default: + g_assert_not_reached (); + } - tinfo = g_callable_info_get_return_type ((GICallableInfo *)info); + tinfo = g_callable_info_get_return_type (info); rtype = g_type_info_get_ffi_type (tinfo); g_base_info_unref ((GIBaseInfo *)tinfo); - n_args = g_callable_info_get_n_args ((GICallableInfo *)info); + n_args = g_callable_info_get_n_args (info); if (is_method) n_invoke_args = n_args+1; else @@ -282,7 +341,7 @@ g_function_info_prep_invoker (GIFunctionInfo *info, for (i = 0; i < n_args; i++) { int offset = (is_method ? 1 : 0); - ainfo = g_callable_info_get_arg ((GICallableInfo *)info, i); + ainfo = g_callable_info_get_arg (info, i); switch (g_arg_info_get_direction (ainfo)) { case GI_DIRECTION_IN: diff --git a/girepository/girffi.h b/girepository/girffi.h index a5cc9e46..e976f924 100644 --- a/girepository/girffi.h +++ b/girepository/girffi.h @@ -1,4 +1,5 @@ -/* GObject introspection: Helper functions for ffi integration +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Helper functions for ffi integration * * Copyright (C) 2008 Red Hat, Inc * @@ -53,6 +54,11 @@ gboolean g_function_info_prep_invoker (GIFunctionInfo *info, GIFunctionInvoker *invoker, GError **error); +gboolean g_function_invoker_new_for_address (gpointer addr, + GICallableInfo *info, + GIFunctionInvoker *invoker, + GError **error); + void g_function_invoker_destroy (GIFunctionInvoker *invoker); diff --git a/girepository/girmodule.c b/girepository/girmodule.c index f438a193..af71f369 100644 --- a/girepository/girmodule.c +++ b/girepository/girmodule.c @@ -1,4 +1,5 @@ -/* GObject introspection: Typelib creation +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Typelib creation * * Copyright (C) 2005 Matthias Clasen * diff --git a/girepository/girmodule.h b/girepository/girmodule.h index c81dec32..7837f2cf 100644 --- a/girepository/girmodule.h +++ b/girepository/girmodule.h @@ -1,4 +1,5 @@ -/* GObject introspection: Parsed IDL +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Parsed IDL * * Copyright (C) 2005 Matthias Clasen * diff --git a/girepository/girnode.c b/girepository/girnode.c index fcc8ce5e..881aa9be 100644 --- a/girepository/girnode.c +++ b/girepository/girnode.c @@ -1,4 +1,5 @@ -/* GObject introspection: Typelib creation +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Typelib creation * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. @@ -1784,6 +1785,7 @@ _g_ir_node_build_typelib (GIrNode *node, blob->must_be_implemented = 0; /* FIXME */ blob->must_not_be_implemented = 0; /* FIXME */ blob->class_closure = 0; /* FIXME */ + blob->throws = vfunc->throws; blob->reserved = 0; if (vfunc->invoker) diff --git a/girepository/girnode.h b/girepository/girnode.h index 32863455..d89847ac 100644 --- a/girepository/girnode.h +++ b/girepository/girnode.h @@ -1,4 +1,5 @@ -/* GObject introspection: Parsed GIR +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Parsed GIR * * Copyright (C) 2005 Matthias Clasen * @@ -206,6 +207,7 @@ struct _GIrNodeVFunc gboolean must_be_implemented; gboolean must_not_be_implemented; gboolean is_class_closure; + gboolean throws; char *invoker; diff --git a/girepository/giroffsets.c b/girepository/giroffsets.c index 2c84b707..e3c9d7f5 100644 --- a/girepository/giroffsets.c +++ b/girepository/giroffsets.c @@ -1,4 +1,5 @@ -/* GObject introspection: Compute structure offsets +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Compute structure offsets * * Copyright (C) 2008 Red Hat, Inc. * diff --git a/girepository/girparser.c b/girepository/girparser.c index fd742f94..fa0de1f8 100644 --- a/girepository/girparser.c +++ b/girepository/girparser.c @@ -1,4 +1,5 @@ -/* GObject introspection: A parser for the XML GIR format +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: A parser for the XML GIR format * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008 Philip Van Hoof @@ -2345,6 +2346,7 @@ start_vfunc (GMarkupParseContext *context, const gchar *is_class_closure; const gchar *offset; const gchar *invoker; + const gchar *throws; GIrNodeInterface *iface; GIrNodeVFunc *vfunc; @@ -2362,6 +2364,7 @@ start_vfunc (GMarkupParseContext *context, is_class_closure = find_attribute ("is-class-closure", attribute_names, attribute_values); offset = find_attribute ("offset", attribute_names, attribute_values); invoker = find_attribute ("invoker", attribute_names, attribute_values); + throws = find_attribute ("throws", attribute_names, attribute_values); if (name == NULL) { @@ -2400,6 +2403,11 @@ start_vfunc (GMarkupParseContext *context, else vfunc->is_class_closure = FALSE; + if (throws && strcmp (throws, "1") == 0) + vfunc->throws = TRUE; + else + vfunc->throws = FALSE; + if (offset) vfunc->offset = atoi (offset); else @@ -3503,10 +3511,11 @@ _g_ir_parser_parse_string (GIrParser *parser, if (ctx.modules) return ctx.modules->data; - g_set_error (error, - G_MARKUP_ERROR, - G_MARKUP_ERROR_INVALID_CONTENT, - "Expected namespace element in the gir file"); + if (error && *error == NULL) + g_set_error (error, + G_MARKUP_ERROR, + G_MARKUP_ERROR_INVALID_CONTENT, + "Expected namespace element in the gir file"); return NULL; } diff --git a/girepository/girparser.h b/girepository/girparser.h index e56c63b5..4f79c777 100644 --- a/girepository/girparser.h +++ b/girepository/girparser.h @@ -1,4 +1,5 @@ -/* GObject introspection: A parser for the XML GIR format +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: A parser for the XML GIR format * * Copyright (C) 2005 Matthias Clasen * diff --git a/girepository/girwriter.c b/girepository/girwriter.c index d9f916c5..73088a12 100644 --- a/girepository/girwriter.c +++ b/girepository/girwriter.c @@ -1,5 +1,5 @@ -/* -*- Mode: C; c-file-style: "gnu"; -*- */ -/* GObject introspection: IDL generator +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: IDL generator * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. @@ -916,6 +916,9 @@ write_vfunc_info (const gchar *namespace, else if (flags & GI_VFUNC_MUST_NOT_OVERRIDE) xml_printf (file, " override=\"never\""); + if (flags & GI_VFUNC_THROWS) + xml_printf (file, " throws=\"1\""); + xml_printf (file, " offset=\"%d\"", offset); if (invoker) diff --git a/girepository/girwriter.h b/girepository/girwriter.h index 3ca7418b..85f74a79 100644 --- a/girepository/girwriter.h +++ b/girepository/girwriter.h @@ -1,4 +1,5 @@ -/* GObject introspection: IDL writer +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: IDL writer * * Copyright (C) 2007 Johan Dahlin * diff --git a/girepository/gisignalinfo.c b/girepository/gisignalinfo.c index ddc891a4..f4110c38 100644 --- a/girepository/gisignalinfo.c +++ b/girepository/gisignalinfo.c @@ -1,4 +1,5 @@ -/* GObject introspection: Signal implementation +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Signal implementation * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/gisignalinfo.h b/girepository/gisignalinfo.h index 12054b00..e3a1e4a4 100644 --- a/girepository/gisignalinfo.h +++ b/girepository/gisignalinfo.h @@ -1,4 +1,5 @@ -/* GObject introspection: Signal +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Signal * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/gistructinfo.c b/girepository/gistructinfo.c index ad191683..dc17e322 100644 --- a/girepository/gistructinfo.c +++ b/girepository/gistructinfo.c @@ -1,4 +1,5 @@ -/* GObject introspection: Struct implementation +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Struct implementation * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/gistructinfo.h b/girepository/gistructinfo.h index 91296c1c..1d10708e 100644 --- a/girepository/gistructinfo.h +++ b/girepository/gistructinfo.h @@ -1,4 +1,5 @@ -/* GObject introspection: Struct +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Struct * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/gitypeinfo.c b/girepository/gitypeinfo.c index 5864f82f..a43fbc1b 100644 --- a/girepository/gitypeinfo.c +++ b/girepository/gitypeinfo.c @@ -1,4 +1,5 @@ -/* GObject introspection: Type implementation +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Type implementation * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/gitypeinfo.h b/girepository/gitypeinfo.h index 56e7309a..ef834b12 100644 --- a/girepository/gitypeinfo.h +++ b/girepository/gitypeinfo.h @@ -1,4 +1,5 @@ -/* GObject introspection: Type +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Type * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/gitypelib-internal.h b/girepository/gitypelib-internal.h index f450a2fb..ed8e6792 100644 --- a/girepository/gitypelib-internal.h +++ b/girepository/gitypelib-internal.h @@ -1,4 +1,5 @@ -/* GObject introspection: struct definitions for the binary +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: struct definitions for the binary * typelib format, validation * * Copyright (C) 2005 Matthias Clasen @@ -281,7 +282,7 @@ typedef struct { guint32 sections; /* <private> */ - guint16 padding[5]; + guint16 padding[6]; } Header; typedef enum { @@ -433,6 +434,10 @@ typedef struct { gint8 closure; gint8 destroy; + /* <private> */ + guint16 padding; + /* <public> */ + SimpleTypeBlob arg_type; } ArgBlob; @@ -925,7 +930,8 @@ typedef struct { guint16 must_be_implemented : 1; guint16 must_not_be_implemented : 1; guint16 class_closure : 1; - guint16 reserved :12; + guint16 throws : 1; + guint16 reserved :11; guint16 signal; guint16 struct_offset; @@ -1049,6 +1055,8 @@ typedef struct { guint16 n_vfuncs; guint16 n_constants; + guint16 padding; + guint32 reserved2; guint32 reserved3; diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c index 53a4bea8..ae6b8458 100644 --- a/girepository/gitypelib.c +++ b/girepository/gitypelib.c @@ -1,4 +1,5 @@ -/* GObject introspection: typelib validation, auxiliary functions +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: typelib validation, auxiliary functions * related to the binary typelib format * * Copyright (C) 2005 Matthias Clasen diff --git a/girepository/gitypelib.h b/girepository/gitypelib.h index 2906a8f2..52c5c400 100644 --- a/girepository/gitypelib.h +++ b/girepository/gitypelib.h @@ -1,4 +1,5 @@ -/* GObject introspection: Public typelib API +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Public typelib API * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/gitypes.h b/girepository/gitypes.h index cbe43168..486f20aa 100644 --- a/girepository/gitypes.h +++ b/girepository/gitypes.h @@ -1,4 +1,5 @@ -/* GObject introspection: types +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: types * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. @@ -403,6 +404,7 @@ typedef enum * @GI_VFUNC_MUST_CHAIN_UP: chains up to the parent type * @GI_VFUNC_MUST_OVERRIDE: overrides * @GI_VFUNC_MUST_NOT_OVERRIDE: does not override + * @GI_VFUNC_THROWS: Includes a #GError * * Flags of a #GIVFuncInfo struct. */ @@ -410,7 +412,8 @@ typedef enum { GI_VFUNC_MUST_CHAIN_UP = 1 << 0, GI_VFUNC_MUST_OVERRIDE = 1 << 1, - GI_VFUNC_MUST_NOT_OVERRIDE = 1 << 2 + GI_VFUNC_MUST_NOT_OVERRIDE = 1 << 2, + GI_VFUNC_THROWS = 1 << 3 } GIVFuncInfoFlags; /** diff --git a/girepository/giunioninfo.c b/girepository/giunioninfo.c index 15a4c7d1..95b71123 100644 --- a/girepository/giunioninfo.c +++ b/girepository/giunioninfo.c @@ -1,4 +1,5 @@ -/* GObject introspection: Union implementation +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Union implementation * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/giunioninfo.h b/girepository/giunioninfo.h index e42fe6f8..83696f76 100644 --- a/girepository/giunioninfo.h +++ b/girepository/giunioninfo.h @@ -1,4 +1,5 @@ -/* GObject introspection: Union +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Union * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/givfuncinfo.c b/girepository/givfuncinfo.c index 332655a0..f80396c0 100644 --- a/girepository/givfuncinfo.c +++ b/girepository/givfuncinfo.c @@ -1,4 +1,5 @@ -/* GObject introspection: Virtual Function implementation +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Virtual Function implementation * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. @@ -104,6 +105,9 @@ g_vfunc_info_get_flags (GIVFuncInfo *info) if (blob->must_not_be_implemented) flags = flags | GI_VFUNC_MUST_NOT_OVERRIDE; + if (blob->throws) + flags = flags | GI_VFUNC_THROWS; + return flags; } diff --git a/girepository/givfuncinfo.h b/girepository/givfuncinfo.h index 3c556cbe..d8a8533b 100644 --- a/girepository/givfuncinfo.h +++ b/girepository/givfuncinfo.h @@ -1,4 +1,5 @@ -/* GObject introspection: Virtual Functions +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Virtual Functions * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. diff --git a/girepository/glib-compat.h b/girepository/glib-compat.h index a4d3e499..2518092c 100644 --- a/girepository/glib-compat.h +++ b/girepository/glib-compat.h @@ -1,4 +1,5 @@ -/* GObject introspection: Compatibility definitions +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Compatibility definitions * * Copyright (C) 2009 Javier Jardón * diff --git a/girepository/gthash-test.c b/girepository/gthash-test.c index a2e3cf82..7909a0c8 100644 --- a/girepository/gthash-test.c +++ b/girepository/gthash-test.c @@ -1,4 +1,5 @@ -/* GObject introspection: Test typelib hashing +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Test typelib hashing * * Copyright (C) 2010 Red Hat, Inc. * diff --git a/girepository/gthash.c b/girepository/gthash.c index 5042ebe3..8a352959 100644 --- a/girepository/gthash.c +++ b/girepository/gthash.c @@ -1,4 +1,5 @@ -/* GObject introspection: Typelib hashing +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Typelib hashing * * Copyright (C) 2010 Red Hat, Inc. * diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py index a9eea8a1..3a35b0e7 100644 --- a/giscanner/maintransformer.py +++ b/giscanner/maintransformer.py @@ -684,33 +684,36 @@ usage is void (*_gtk_reserved1)(void);""" self._apply_annotations_param_ret_common(parent, return_, tag) def _apply_annotations_params(self, parent, params, block): - allparams = [] + declparams = set([]) if parent.instance_parameter: - allparams.append(parent.instance_parameter.argname) + declparams.add(parent.instance_parameter.argname) for param in params: if block: tag = block.get(param.argname) else: tag = None self._apply_annotations_param(parent, param, tag) - allparams.append(param.argname) + declparams.add(param.argname) if not block: return - docparams = block.params[:] - for doc_name in docparams: - if doc_name in allparams: - continue + docparams = set(block.params) + + unknown = docparams - declparams + unused = declparams - docparams + + for doc_name in unknown: # Skip varargs, see #629759 if doc_name.lower() in ['...', 'varargs', TAG_RETURNS]: continue - if len(allparams) == 0: + if len(unused) == 0: text = '' - elif len(allparams) == 1: - text = ', should be %r' % (allparams[0], ) + elif len(unused) == 1: + (param, ) = unused + text = ', should be %r' % (param, ) else: text = ', should be one of %s' % ( - ', '.join(repr(p) for p in allparams), ) + ', '.join(repr(p) for p in unused), ) tag = block.get(doc_name) message.warn( @@ -1224,6 +1227,10 @@ method or constructor of some type.""" vfunc = ast.VFunction.from_callback(callback) vfunc.instance_parameter = callback.parameters[0] vfunc.inherit_file_positions(callback) + + prefix = self._get_annotation_name(class_struct) + block = self._blocks.get('%s::%s' % (prefix, vfunc.name)) + self._apply_annotations_callable(vfunc, [node], block) node.virtual_methods.append(vfunc) # Take the set of virtual methods we found, and try diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c index 712e5080..7afe543a 100644 --- a/tests/gimarshallingtests.c +++ b/tests/gimarshallingtests.c @@ -1,4 +1,4 @@ -/* -*- Mode: C; c-basic-offset: 4 -*- +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- * vim: tabstop=4 shiftwidth=4 expandtab */ @@ -995,12 +995,25 @@ gi_marshalling_tests_gtype_return (void) return G_TYPE_NONE; } +GType +gi_marshalling_tests_gtype_string_return (void) +{ + return G_TYPE_STRING; +} + void gi_marshalling_tests_gtype_in (GType gtype) { g_assert(gtype == G_TYPE_NONE); } +void +gi_marshalling_tests_gtype_string_in (GType gtype) +{ + g_assert(gtype == G_TYPE_STRING); +} + + /** * gi_marshalling_tests_gtype_out: * @gtype: (out): @@ -1012,6 +1025,16 @@ gi_marshalling_tests_gtype_out (GType *gtype) } /** + * gi_marshalling_tests_gtype_string_out: + * @gtype: (out): + */ +void +gi_marshalling_tests_gtype_string_out (GType *gtype) +{ + *gtype = G_TYPE_STRING; +} + +/** * gi_marshalling_tests_gtype_inout: * @gtype: (inout): */ @@ -2877,6 +2900,17 @@ gi_marshalling_tests_gvalue_in (GValue *value) } /** + * gi_marshalling_tests_gvalue_in_with_type: + * @value: (transfer none): + * @type: + */ +void +gi_marshalling_tests_gvalue_in_with_type (GValue *value, GType type) +{ + g_assert(g_type_is_a(G_VALUE_TYPE(value), type)); +} + +/** * gi_marshalling_tests_gvalue_in_enum: * @value: (transfer none): */ @@ -3034,6 +3068,71 @@ gi_marshalling_tests_gclosure_return (void) return closure; } + +/** + * gi_marshalling_tests_callback_return_value_only: + * @callback: (scope call): + */ +glong +gi_marshalling_tests_callback_return_value_only (GIMarshallingTestsCallbackReturnValueOnly callback) +{ + return callback (); +} + +/** + * gi_marshalling_tests_callback_one_out_parameter: + * @callback: (scope call): + * @a: (out): + */ +void +gi_marshalling_tests_callback_one_out_parameter (GIMarshallingTestsCallbackOneOutParameter callback, + gfloat *a) +{ + callback (a); +} + +/** + * gi_marshalling_tests_callback_multiple_out_parameters: + * @callback: (scope call): + * @a: (out): + * @b: (out): + */ +void +gi_marshalling_tests_callback_multiple_out_parameters (GIMarshallingTestsCallbackMultipleOutParameters callback, + gfloat *a, + gfloat *b) +{ + callback (a, b); +} + +/** + * gi_marshalling_tests_callback_return_value_and_one_out_parameter: + * @callback: (scope call): + * @a: (out): + */ +glong +gi_marshalling_tests_callback_return_value_and_one_out_parameter (GIMarshallingTestsCallbackReturnValueAndOneOutParameter callback, + glong *a) +{ + return callback (a); +} + +/** + * gi_marshalling_tests_callback_return_value_and_multiple_out_parameters: + * @callback: (scope call): + * @a: (out): + * @b: (out): + */ +glong +gi_marshalling_tests_callback_return_value_and_multiple_out_parameters (GIMarshallingTestsCallbackReturnValueAndMultipleOutParameters callback, + glong *a, + glong *b) +{ + return callback (a, b); +} + + + /** * gi_marshalling_tests_pointer_in_return: * @@ -3787,6 +3886,87 @@ gi_marshalling_tests_object_int8_out (GIMarshallingTestsObject *object, gint8 *o gi_marshalling_tests_object_method_int8_out (object, out); } +/** + * gi_marshalling_tests_object_vfunc_return_value_only: + */ +glong +gi_marshalling_tests_object_vfunc_return_value_only (GIMarshallingTestsObject *self) +{ + /* make sure that local variables don't get smashed */ + glong return_value; + gulong local = 0x12345678; + return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_only (self); + g_assert_cmpint(local, ==, 0x12345678); + return return_value; +} + +/** + * gi_marshalling_tests_object_vfunc_one_out_parameter: + * @a: (out): + */ +void +gi_marshalling_tests_object_vfunc_one_out_parameter (GIMarshallingTestsObject *self, gfloat *a) +{ + /* make sure that local variables don't get smashed */ + gulong local = 0x12345678; + GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_one_out_parameter (self, a); + g_assert_cmpint(local, ==, 0x12345678); +} + +/** + * gi_marshalling_tests_object_vfunc_multiple_out_parameters: + * @a: (out): + * @b: (out): + */ +void +gi_marshalling_tests_object_vfunc_multiple_out_parameters (GIMarshallingTestsObject *self, gfloat *a, gfloat *b) +{ + /* make sure that local variables don't get smashed */ + gulong local = 0x12345678; + GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_multiple_out_parameters (self, a, b); + g_assert_cmpint(local, ==, 0x12345678); +} + +/** + * gi_marshalling_tests_object_vfunc_return_value_and_one_out_parameter: + * @a: (out): + */ +glong +gi_marshalling_tests_object_vfunc_return_value_and_one_out_parameter (GIMarshallingTestsObject *self, glong *a) +{ + /* make sure that local variables don't get smashed */ + gulong return_value; + gulong local = 0x12345678; + return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_one_out_parameter (self, a); + g_assert_cmpint(local, ==, 0x12345678); + return return_value; +} + +/** + * gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters: + * @a: (out): + * @b: (out): + */ +glong +gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters (GIMarshallingTestsObject *self, glong *a, glong *b) +{ + gulong return_value; + gulong local = 0x12345678; + return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_multiple_out_parameters (self, a, b); + g_assert_cmpint(local, ==, 0x12345678); + return return_value; +} + +gboolean +gi_marshalling_tests_object_vfunc_meth_with_error (GIMarshallingTestsObject *self, + gint x, + GError **error) +{ + gulong local = 0x12345678; + gboolean ret = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_meth_with_err (self, x, error); + g_assert_cmpint(local, ==, 0x12345678); + return ret; +} G_DEFINE_TYPE (GIMarshallingTestsSubObject, gi_marshalling_tests_sub_object, GI_MARSHALLING_TESTS_TYPE_OBJECT); @@ -4020,7 +4200,7 @@ gi_marshalling_tests_gerror_out_transfer_none(GError **err, const gchar **debug) * Returns: (transfer full): a GError */ GError * -gi_marshalling_tests_gerror_return() +gi_marshalling_tests_gerror_return(void) { GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN); @@ -4122,7 +4302,6 @@ gi_marshalling_tests_overrides_object_method (GIMarshallingTestsOverridesObject return 42; } - /** * gi_marshalling_tests_overrides_object_returnv: * @@ -4145,3 +4324,181 @@ gi_marshalling_tests_filename_list_return (void) return NULL; } + +enum { + DUMMY_PROPERTY, + SOME_BOOLEAN_PROPERTY, + SOME_CHAR_PROPERTY, + SOME_UCHAR_PROPERTY, + SOME_INT_PROPERTY, + SOME_UINT_PROPERTY, + SOME_LONG_PROPERTY, + SOME_ULONG_PROPERTY, + SOME_INT64_PROPERTY, + SOME_UINT64_PROPERTY, + SOME_FLOAT_PROPERTY, + SOME_DOUBLE_PROPERTY +}; + +G_DEFINE_TYPE (GIMarshallingTestsPropertiesObject, gi_marshalling_tests_properties_object, G_TYPE_OBJECT); + +static void +gi_marshalling_tests_properties_object_init (GIMarshallingTestsPropertiesObject * self) +{ +} + +static void +gi_marshalling_tests_properties_object_finalize (GObject* obj) +{ + G_OBJECT_CLASS (gi_marshalling_tests_properties_object_parent_class)->finalize (obj); +} + +static void +gi_marshalling_tests_properties_object_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) +{ + GIMarshallingTestsPropertiesObject * self; + self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (object); + switch (property_id) { + case SOME_BOOLEAN_PROPERTY: + g_value_set_boolean (value, self->some_boolean); + break; + case SOME_CHAR_PROPERTY: + g_value_set_schar (value, self->some_char); + break; + case SOME_UCHAR_PROPERTY: + g_value_set_uchar (value, self->some_uchar); + break; + case SOME_INT_PROPERTY: + g_value_set_int (value, self->some_int); + break; + case SOME_UINT_PROPERTY: + g_value_set_uint (value, self->some_uint); + break; + case SOME_LONG_PROPERTY: + g_value_set_long (value, self->some_long); + break; + case SOME_ULONG_PROPERTY: + g_value_set_ulong (value, self->some_ulong); + break; + case SOME_INT64_PROPERTY: + g_value_set_int64 (value, self->some_int64); + break; + case SOME_UINT64_PROPERTY: + g_value_set_uint64 (value, self->some_uint64); + break; + case SOME_FLOAT_PROPERTY: + g_value_set_float (value, self->some_float); + break; + case SOME_DOUBLE_PROPERTY: + g_value_set_double (value, self->some_double); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +gi_marshalling_tests_properties_object_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) +{ + GIMarshallingTestsPropertiesObject * self; + self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (object); + switch (property_id) { + case SOME_BOOLEAN_PROPERTY: + self->some_boolean = g_value_get_boolean (value); + break; + case SOME_CHAR_PROPERTY: + self->some_char = g_value_get_schar (value); + break; + case SOME_UCHAR_PROPERTY: + self->some_uchar = g_value_get_uchar (value); + break; + case SOME_INT_PROPERTY: + self->some_int = g_value_get_int (value); + break; + case SOME_UINT_PROPERTY: + self->some_uint = g_value_get_uint (value); + break; + case SOME_LONG_PROPERTY: + self->some_long = g_value_get_long (value); + break; + case SOME_ULONG_PROPERTY: + self->some_ulong = g_value_get_ulong (value); + break; + case SOME_INT64_PROPERTY: + self->some_int64 = g_value_get_int64 (value); + break; + case SOME_UINT64_PROPERTY: + self->some_uint64 = g_value_get_uint64 (value); + break; + case SOME_FLOAT_PROPERTY: + self->some_float = g_value_get_float (value); + break; + case SOME_DOUBLE_PROPERTY: + self->some_double = g_value_get_double (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +gi_marshalling_tests_properties_object_class_init (GIMarshallingTestsPropertiesObjectClass * klass) +{ + GObjectClass* object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = gi_marshalling_tests_properties_object_finalize; + object_class->get_property = gi_marshalling_tests_properties_object_get_property; + object_class->set_property = gi_marshalling_tests_properties_object_set_property; + + g_object_class_install_property (object_class, SOME_BOOLEAN_PROPERTY, + g_param_spec_boolean ("some-boolean", "some-boolean", "some-boolean", FALSE, + G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)); + + g_object_class_install_property (object_class, SOME_CHAR_PROPERTY, + g_param_spec_char ("some-char", "some-char", "some-char", G_MININT8, G_MAXINT8, 0, + G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)); + + g_object_class_install_property (object_class, SOME_UCHAR_PROPERTY, + g_param_spec_uchar ("some-uchar", "some-uchar", "some-uchar", 0, G_MAXUINT8, 0, + G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)); + + g_object_class_install_property (object_class, SOME_INT_PROPERTY, + g_param_spec_int ("some-int", "some-int", "some-int", G_MININT, G_MAXINT, 0, + G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)); + + g_object_class_install_property (object_class, SOME_UINT_PROPERTY, + g_param_spec_uint ("some-uint", "some-uint", "some-uint", 0, G_MAXUINT, 0, + G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)); + + g_object_class_install_property (object_class, SOME_LONG_PROPERTY, + g_param_spec_long ("some-long", "some-long", "some-long", G_MINLONG, G_MAXLONG, 0, + G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)); + + g_object_class_install_property (object_class, SOME_ULONG_PROPERTY, + g_param_spec_ulong ("some-ulong", "some-ulong", "some-ulong", 0, G_MAXULONG, 0, + G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)); + + g_object_class_install_property (object_class, SOME_INT64_PROPERTY, + g_param_spec_int64 ("some-int64", "some-int64", "some-int64", G_MININT64, G_MAXINT64, 0, + G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)); + + g_object_class_install_property (object_class, SOME_UINT64_PROPERTY, + g_param_spec_uint64 ("some-uint64", "some-uint64", "some-uint64", 0, G_MAXUINT64, 0, + G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)); + + g_object_class_install_property (object_class, SOME_FLOAT_PROPERTY, + g_param_spec_float ("some-float", "some-float", "some-float", -1 * G_MAXFLOAT, G_MAXFLOAT, 0, + G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)); + + g_object_class_install_property (object_class, SOME_DOUBLE_PROPERTY, + g_param_spec_double ("some-double", "some-double", "some-double", -1 * G_MAXDOUBLE, G_MAXDOUBLE, 0, + G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)); +} + +GIMarshallingTestsPropertiesObject* +gi_marshalling_tests_properties_object_new (void) +{ + return g_object_new (GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT, NULL); +} diff --git a/tests/gimarshallingtests.h b/tests/gimarshallingtests.h index e80a0e5e..0c889209 100644 --- a/tests/gimarshallingtests.h +++ b/tests/gimarshallingtests.h @@ -1,4 +1,4 @@ -/* -*- Mode: C; c-basic-offset: 4 -*- +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- * vim: tabstop=4 shiftwidth=4 expandtab */ @@ -236,10 +236,16 @@ void gi_marshalling_tests_time_t_inout (time_t *time_t_); GType gi_marshalling_tests_gtype_return (void); +GType gi_marshalling_tests_gtype_string_return (void); + void gi_marshalling_tests_gtype_in (GType gtype); +void gi_marshalling_tests_gtype_string_in (GType gtype); + void gi_marshalling_tests_gtype_out (GType *gtype); +void gi_marshalling_tests_gtype_string_out (GType *gtype); + void gi_marshalling_tests_gtype_inout (GType *gtype); @@ -520,6 +526,7 @@ void gi_marshalling_tests_ghashtable_utf8_full_inout (GHashTable **hash_table); GValue *gi_marshalling_tests_gvalue_return (void); void gi_marshalling_tests_gvalue_in (GValue *value); +void gi_marshalling_tests_gvalue_in_with_type (GValue *value, GType type); void gi_marshalling_tests_gvalue_in_enum (GValue *value); @@ -541,6 +548,55 @@ GValue *gi_marshalling_tests_gvalue_flat_array_round_trip (const GValue one, void gi_marshalling_tests_gclosure_in (GClosure *closure); GClosure *gi_marshalling_tests_gclosure_return (void); +/* Callback return values */ + +/** + * GIMarshallingTestsCallbackReturnValueOnly: + */ +typedef glong (* GIMarshallingTestsCallbackReturnValueOnly) (); + +glong gi_marshalling_tests_callback_return_value_only (GIMarshallingTestsCallbackReturnValueOnly callback); + +/** + * GIMarshallingTestsCallbackOneOutParameter: + * @a: (out): + */ +typedef void (* GIMarshallingTestsCallbackOneOutParameter) (gfloat *a); + +void gi_marshalling_tests_callback_one_out_parameter (GIMarshallingTestsCallbackOneOutParameter callback, + gfloat *a); + +/** + * GIMarshallingTestsCallbackMultipleOutParameters: + * @a: (out): + * @b: (out): + */ +typedef void (* GIMarshallingTestsCallbackMultipleOutParameters) (gfloat *a, gfloat *b); + +void gi_marshalling_tests_callback_multiple_out_parameters (GIMarshallingTestsCallbackMultipleOutParameters callback, + gfloat *a, + gfloat *b); + +/** + * GIMarshallingTestsCallbackReturnValueAndOneOutParameter: + * @a: (out): + */ +typedef glong (* GIMarshallingTestsCallbackReturnValueAndOneOutParameter) (glong *a); + +glong gi_marshalling_tests_callback_return_value_and_one_out_parameter (GIMarshallingTestsCallbackReturnValueAndOneOutParameter callback, + glong *a); + +/** + * GIMarshallingTestsCallbackReturnValueAndMultipleOutParameters: + * @a: (out): + * @b: (out): + */ +typedef glong (* GIMarshallingTestsCallbackReturnValueAndMultipleOutParameters) (glong *a, glong *b); + +glong gi_marshalling_tests_callback_return_value_and_multiple_out_parameters (GIMarshallingTestsCallbackReturnValueAndMultipleOutParameters callback, + glong *a, + glong *b); + /* Pointer */ gpointer gi_marshalling_tests_pointer_in_return (gpointer pointer); @@ -611,7 +667,7 @@ void gi_marshalling_tests_union_inout (GIMarshallingTestsUnion **union_); void gi_marshalling_tests_union_method (GIMarshallingTestsUnion *union_); -/* Object */ + /* Object */ #define GI_MARSHALLING_TESTS_TYPE_OBJECT (gi_marshalling_tests_object_get_type ()) #define GI_MARSHALLING_TESTS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GI_MARSHALLING_TESTS_TYPE_OBJECT, GIMarshallingTestsObject)) @@ -650,6 +706,44 @@ struct _GIMarshallingTestsObjectClass * @in: (in): */ void (* method_deep_hierarchy) (GIMarshallingTestsObject *self, gint8 in); + + /** + * GIMarshallingTestsObjectClass::vfunc_return_value_only: + */ + glong (* vfunc_return_value_only) (GIMarshallingTestsObject *self); + + /** + * GIMarshallingTestsObjectClass::vfunc_one_out_parameter: + * @a: (out): + */ + void (* vfunc_one_out_parameter) (GIMarshallingTestsObject *self, gfloat *a); + + /** + * GIMarshallingTestsObjectClass::vfunc_multiple_out_parameters: + * @a: (out): + * @b: (out): + */ + void (* vfunc_multiple_out_parameters) (GIMarshallingTestsObject *self, gfloat *a, gfloat *b); + + /** + * GIMarshallingTestsObjectClass::vfunc_return_value_and_one_out_parameter: + * @a: (out): + */ + glong (* vfunc_return_value_and_one_out_parameter) (GIMarshallingTestsObject *self, glong *a); + + /** + * GIMarshallingTestsObjectClass::vfunc_return_value_and_multiple_out_parameters: + * @a: (out): + * @b: (out): + */ + glong (* vfunc_return_value_and_multiple_out_parameters) (GIMarshallingTestsObject *self, glong *a, glong *b); + + /** + * GIMarshallingTestsObjectClass::vfunc_meth_with_err: + * @x: + * @error: A #GError + */ + gboolean (*vfunc_meth_with_err) (GIMarshallingTestsObject *object, gint x, GError **error); }; struct _GIMarshallingTestsObject @@ -674,6 +768,12 @@ void gi_marshalling_tests_object_method_int8_in (GIMarshallingTestsObject *objec void gi_marshalling_tests_object_method_int8_out (GIMarshallingTestsObject *object, gint8 *out); void gi_marshalling_tests_object_method_with_default_implementation (GIMarshallingTestsObject *object, gint8 in); +glong gi_marshalling_tests_object_vfunc_return_value_only (GIMarshallingTestsObject *self); +void gi_marshalling_tests_object_vfunc_one_out_parameter (GIMarshallingTestsObject *self, gfloat *a); +void gi_marshalling_tests_object_vfunc_multiple_out_parameters (GIMarshallingTestsObject *self, gfloat *a, gfloat *b); +glong gi_marshalling_tests_object_vfunc_return_value_and_one_out_parameter (GIMarshallingTestsObject *self, glong *a); +glong gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters (GIMarshallingTestsObject *self, glong *a, glong *b); +gboolean gi_marshalling_tests_object_vfunc_meth_with_error (GIMarshallingTestsObject *object, gint x, GError **error); GIMarshallingTestsObject *gi_marshalling_tests_object_none_return (void); GIMarshallingTestsObject *gi_marshalling_tests_object_full_return (void); @@ -807,7 +907,7 @@ void gi_marshalling_tests_gerror(GError **error); void gi_marshalling_tests_gerror_array_in(gint *in_ints, GError **error); void gi_marshalling_tests_gerror_out(GError **error, gchar **debug); void gi_marshalling_tests_gerror_out_transfer_none(GError **err, const gchar **debug); -GError *gi_marshalling_tests_gerror_return(); +GError *gi_marshalling_tests_gerror_return(void); /* Overrides */ @@ -839,12 +939,12 @@ typedef struct _GIMarshallingTestsOverridesObject GIMarshallingTestsOverridesObj struct _GIMarshallingTestsOverridesObjectClass { - GObjectClass parent_class; + GObjectClass parent_class; }; struct _GIMarshallingTestsOverridesObject { - GObject parent_instance; + GObject parent_instance; glong long_; }; @@ -855,7 +955,42 @@ GIMarshallingTestsOverridesObject *gi_marshalling_tests_overrides_object_new (vo glong gi_marshalling_tests_overrides_object_method (GIMarshallingTestsOverridesObject *object); - GIMarshallingTestsOverridesObject *gi_marshalling_tests_overrides_object_returnv (void); +/* Properties Object */ + +#define GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT (gi_marshalling_tests_properties_object_get_type ()) +#define GI_MARSHALLING_TESTS_PROPERTIES_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT, GIMarshallingTestsPropertiesObject)) +#define GI_MARSHALLING_TESTS_PROPERTIES_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT, GIMarshallingTestsPropertiesObjectClass)) +#define GI_MARSHALLING_TESTS_IS_PROPERTIES_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT)) +#define GI_MARSHALLING_TESTS_IS_PROPERTIES_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT)) +#define GI_MARSHALLING_TESTS_PROPERTIES_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT, GIMarshallingTestsPropertiesObjectClass)) + +typedef struct _GIMarshallingTestsPropertiesObject GIMarshallingTestsPropertiesObject; +typedef struct _GIMarshallingTestsPropertiesObjectClass GIMarshallingTestsPropertiesObjectClass; + +struct _GIMarshallingTestsPropertiesObject { + GObject parent_instance; + + gboolean some_boolean; + gchar some_char; + guchar some_uchar; + gint some_int; + guint some_uint; + glong some_long; + gulong some_ulong; + gint64 some_int64; + guint64 some_uint64; + gfloat some_float; + gdouble some_double; +}; + +struct _GIMarshallingTestsPropertiesObjectClass { + GObjectClass parent_class; +}; + +GType gi_marshalling_tests_properties_object_get_type (void) G_GNUC_CONST; + +GIMarshallingTestsPropertiesObject *gi_marshalling_tests_properties_object_new (void); + #endif /* _GI_MARSHALLING_TESTS_H_ */ diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir index ebdacf56..ae047256 100644 --- a/tests/scanner/Regress-1.0-expected.gir +++ b/tests/scanner/Regress-1.0-expected.gir @@ -141,6 +141,36 @@ use it should be.</doc> </parameters> </method> </record> + <record name="TestBoxedB" + c:type="RegressTestBoxedB" + glib:type-name="RegressTestBoxedB" + glib:get-type="regress_test_boxed_b_get_type" + c:symbol-prefix="test_boxed_b"> + <field name="some_int8" writable="1"> + <type name="gint8" c:type="gint8"/> + </field> + <field name="some_long" writable="1"> + <type name="glong" c:type="glong"/> + </field> + <constructor name="new" c:identifier="regress_test_boxed_b_new"> + <return-value transfer-ownership="full"> + <type name="TestBoxedB" c:type="RegressTestBoxedB*"/> + </return-value> + <parameters> + <parameter name="some_int8" transfer-ownership="none"> + <type name="gint8" c:type="gint8"/> + </parameter> + <parameter name="some_long" transfer-ownership="none"> + <type name="glong" c:type="glong"/> + </parameter> + </parameters> + </constructor> + <method name="copy" c:identifier="regress_test_boxed_b_copy"> + <return-value transfer-ownership="full"> + <type name="TestBoxedB" c:type="RegressTestBoxedB*"/> + </return-value> + </method> + </record> <record name="TestBoxedPrivate" c:type="RegressTestBoxedPrivate" disguised="1"> @@ -150,6 +180,29 @@ use it should be.</doc> <type name="gint" c:type="int"/> </return-value> </callback> + <callback name="TestCallbackArray" c:type="RegressTestCallbackArray"> + <return-value transfer-ownership="none"> + <type name="gint" c:type="int"/> + </return-value> + <parameters> + <parameter name="one" transfer-ownership="none"> + <array length="1" zero-terminated="0" c:type="int*"> + <type name="gint" c:type="int"/> + </array> + </parameter> + <parameter name="one_length" transfer-ownership="none"> + <type name="gsize" c:type="gsize"/> + </parameter> + <parameter name="two" transfer-ownership="none"> + <array length="3" zero-terminated="0" c:type="char**"> + <type name="utf8"/> + </array> + </parameter> + <parameter name="two_length" transfer-ownership="none"> + <type name="gint" c:type="int"/> + </parameter> + </parameters> + </callback> <callback name="TestCallbackFull" c:type="RegressTestCallbackFull"> <return-value transfer-ownership="none"> <type name="gint" c:type="int"/> @@ -529,6 +582,17 @@ use it should be.</doc> </parameter> </parameters> </function> + <virtual-method name="allow_none_vfunc"> + <return-value transfer-ownership="none"> + <type name="none" c:type="void"/> + </return-value> + <parameters> + <parameter name="two" transfer-ownership="none" allow-none="1"> + <doc xml:whitespace="preserve">Another object</doc> + <type name="TestObj" c:type="RegressTestObj*"/> + </parameter> + </parameters> + </virtual-method> <virtual-method name="matrix" invoker="do_matrix"> <doc xml:whitespace="preserve">This method is virtual. Notably its name differs from the virtual slot name, which makes it useful for testing bindings handle this @@ -1072,6 +1136,22 @@ Use with regress_test_obj_emit_sig_with_obj</doc> </parameters> </callback> </field> + <field name="allow_none_vfunc"> + <callback name="allow_none_vfunc"> + <return-value transfer-ownership="none"> + <type name="none" c:type="void"/> + </return-value> + <parameters> + <parameter name="obj" transfer-ownership="none"> + <type name="TestObj" c:type="RegressTestObj*"/> + </parameter> + <parameter name="two" transfer-ownership="none" allow-none="1"> + <doc xml:whitespace="preserve">Another object</doc> + <type name="TestObj" c:type="RegressTestObj*"/> + </parameter> + </parameters> + </callback> + </field> <field name="test_signal"> <type name="guint" c:type="guint"/> </field> @@ -1500,6 +1580,17 @@ Use with regress_test_obj_emit_sig_with_obj</doc> </parameter> </parameters> </function> + <function name="test_array_callback" + c:identifier="regress_test_array_callback"> + <return-value transfer-ownership="none"> + <type name="gint" c:type="int"/> + </return-value> + <parameters> + <parameter name="callback" transfer-ownership="none" scope="call"> + <type name="TestCallbackArray" c:type="RegressTestCallbackArray"/> + </parameter> + </parameters> + </function> <function name="test_array_fixed_out_objects" c:identifier="regress_test_array_fixed_out_objects"> <return-value transfer-ownership="none"> @@ -2073,6 +2164,14 @@ call and can be released on return.</doc> </array> </return-value> </function> + <function name="test_garray_full_return" + c:identifier="regress_test_garray_full_return"> + <return-value transfer-ownership="full"> + <array name="GLib.PtrArray" c:type="GPtrArray*"> + <type name="utf8"/> + </array> + </return-value> + </function> <function name="test_gerror_callback" c:identifier="regress_test_gerror_callback"> <return-value transfer-ownership="none"> @@ -2630,6 +2729,17 @@ What we're testing here is that the scanner ignores the @a nested inside XML.</d </parameter> </parameters> </function> + <function name="test_null_gerror_callback" + c:identifier="regress_test_null_gerror_callback"> + <return-value transfer-ownership="none"> + <type name="none" c:type="void"/> + </return-value> + <parameters> + <parameter name="callback" transfer-ownership="none" scope="call"> + <type name="TestCallbackGError" c:type="RegressTestCallbackGError"/> + </parameter> + </parameters> + </function> <function name="test_owned_gerror_callback" c:identifier="regress_test_owned_gerror_callback"> <return-value transfer-ownership="none"> diff --git a/tests/scanner/annotation.c b/tests/scanner/annotation.c index f28befac..a4e4efc4 100644 --- a/tests/scanner/annotation.c +++ b/tests/scanner/annotation.c @@ -1,3 +1,4 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ #include "annotation.h" char backslash_parsing_tester = '\\'; diff --git a/tests/scanner/barapp.c b/tests/scanner/barapp.c index b7ac119d..db4be8db 100644 --- a/tests/scanner/barapp.c +++ b/tests/scanner/barapp.c @@ -1,3 +1,4 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ #include "barapp.h" #include <girepository.h> diff --git a/tests/scanner/drawable.c b/tests/scanner/drawable.c index 0345b034..6ab8ecf7 100644 --- a/tests/scanner/drawable.c +++ b/tests/scanner/drawable.c @@ -1,3 +1,4 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ #include "drawable.h" G_DEFINE_ABSTRACT_TYPE (TestInheritDrawable, test_inherit_drawable, G_TYPE_OBJECT); diff --git a/tests/scanner/gtkfrob.c b/tests/scanner/gtkfrob.c index 286e4483..d1c2312c 100644 --- a/tests/scanner/gtkfrob.c +++ b/tests/scanner/gtkfrob.c @@ -1,3 +1,4 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ #include "gtkfrob.h" void diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index 0f00ec8d..7e838d34 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -1,3 +1,4 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ #include <string.h> #include <stdlib.h> #include <glib-object.h> @@ -1326,7 +1327,23 @@ regress_test_garray_container_return (void) { GPtrArray *array; - array = g_ptr_array_new_with_free_func (g_object_unref); + array = g_ptr_array_new_with_free_func (g_free); + g_ptr_array_add (array, g_strdup ("regress")); + + return array; +} + +/** + * regress_test_garray_full_return: + * + * Returns: (transfer full) (type GLib.PtrArray) (element-type utf8): + */ +GPtrArray * +regress_test_garray_full_return (void) +{ + GPtrArray *array; + + array = g_ptr_array_new (); g_ptr_array_add (array, g_strdup ("regress")); return array; @@ -1656,6 +1673,35 @@ regress_test_boxed_get_type (void) return our_type; } +RegressTestBoxedB * +regress_test_boxed_b_new (gint8 some_int8, glong some_long) +{ + RegressTestBoxedB *boxed; + + boxed = g_slice_new (RegressTestBoxedB); + boxed->some_int8 = some_int8; + boxed->some_long = some_long; + + return boxed; +} + +RegressTestBoxedB * +regress_test_boxed_b_copy (RegressTestBoxedB *boxed) +{ + return regress_test_boxed_b_new (boxed->some_int8, boxed->some_long); +} + +static void +regress_test_boxed_b_free (RegressTestBoxedB *boxed) +{ + g_slice_free (RegressTestBoxedB, boxed); +} + +G_DEFINE_BOXED_TYPE(RegressTestBoxedB, + regress_test_boxed_b, + regress_test_boxed_b_copy, + regress_test_boxed_b_free); + G_DEFINE_TYPE(RegressTestObj, regress_test_obj, G_TYPE_OBJECT); enum @@ -2842,7 +2888,22 @@ regress_test_multi_callback (RegressTestCallback callback) return sum; } +/** + * regress_test_array_callback: + * @callback: (scope call): + * + **/ +int regress_test_array_callback (RegressTestCallbackArray callback) +{ + static const char *strings[] = { "one", "two", "three" }; + static int ints[] = { -1, 0, 1, 2 }; + int sum = 0; + + sum += callback(ints, 4, strings, 3); + sum += callback(ints, 4, strings, 3); + return sum; +} /** * regress_test_simple_callback: @@ -3054,6 +3115,16 @@ regress_test_gerror_callback (RegressTestCallbackGError callback) } /** + * regress_test_null_gerror_callback: + * @callback: (scope call): + **/ +void +regress_test_null_gerror_callback (RegressTestCallbackGError callback) +{ + callback (NULL); +} + +/** * regress_test_owned_gerror_callback: * @callback: (scope call): **/ diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h index 8fe44e2b..65a158a1 100644 --- a/tests/scanner/regress.h +++ b/tests/scanner/regress.h @@ -113,6 +113,7 @@ GHashTable *regress_test_ghash_nested_everything_return2 (void); /* GPtrArray */ GPtrArray *regress_test_garray_container_return (void); +GPtrArray *regress_test_garray_full_return (void); /* error? */ @@ -313,6 +314,18 @@ RegressTestBoxed *regress_test_boxed_copy (RegressTestBoxed *boxed); gboolean regress_test_boxed_equals (RegressTestBoxed *boxed, RegressTestBoxed *other); +typedef struct _RegressTestBoxedB RegressTestBoxedB; + +struct _RegressTestBoxedB +{ + gint8 some_int8; + glong some_long; +}; + +GType regress_test_boxed_b_get_type (void); +RegressTestBoxedB *regress_test_boxed_b_new (gint8 some_int8, glong some_long); +RegressTestBoxedB *regress_test_boxed_b_copy (RegressTestBoxedB *boxed); + /* gobject */ #define REGRESS_TEST_TYPE_OBJ (regress_test_obj_get_type ()) #define REGRESS_TEST_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), REGRESS_TEST_TYPE_OBJ, RegressTestObj)) @@ -346,6 +359,12 @@ struct _RegressTestObjClass int (*matrix) (RegressTestObj *obj, const char *somestr); + /** + * RegressTestObjClass::allow_none_vfunc + * @two: (allow-none): Another object + */ + void (*allow_none_vfunc) (RegressTestObj *obj, RegressTestObj *two); + guint test_signal; guint test_signal_with_static_scope_arg; @@ -538,10 +557,19 @@ typedef void (*RegressTestCallbackOwnedGError) (GError *error); * @path: (type filename): Path to file */ typedef int (*RegressTestCallbackFull) (int foo, double bar, char *path); +/** + * RegressTestCallbackArray: + * @one: (array length=one_length): + * @one_length: + * @two: (array length=two_length) (element-type utf8): + * @two_length: + */ +typedef int (*RegressTestCallbackArray) (int *one, gsize one_length, const char** two, int two_length); void regress_test_simple_callback (RegressTestSimpleCallback callback); int regress_test_callback (RegressTestCallback callback); int regress_test_multi_callback (RegressTestCallback callback); +int regress_test_array_callback (RegressTestCallbackArray callback); int regress_test_callback_user_data (RegressTestCallbackUserData callback, gpointer user_data); int regress_test_callback_destroy_notify (RegressTestCallbackUserData callback, @@ -561,6 +589,7 @@ RegressTestObj *regress_test_obj_new_callback (RegressTestCallbackUserData callb GDestroyNotify notify); void regress_test_hash_table_callback (GHashTable *data, RegressTestCallbackHashtable callback); void regress_test_gerror_callback (RegressTestCallbackGError callback); +void regress_test_null_gerror_callback (RegressTestCallbackGError callback); void regress_test_owned_gerror_callback (RegressTestCallbackOwnedGError callback); typedef struct _RegressTestInterface RegressTestInterface; diff --git a/tests/scanner/utility.c b/tests/scanner/utility.c index aad0d08a..fb1cf5a0 100644 --- a/tests/scanner/utility.c +++ b/tests/scanner/utility.c @@ -1,3 +1,4 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ #include "utility.h" G_DEFINE_TYPE (UtilityObject, utility_object, G_TYPE_OBJECT); diff --git a/tests/warn/unknown-parameter.h b/tests/warn/unknown-parameter.h index 8d68dbbc..3d339b32 100644 --- a/tests/warn/unknown-parameter.h +++ b/tests/warn/unknown-parameter.h @@ -19,13 +19,23 @@ void test_param_mismatch2(int a, int *out2); // EXPECT:14: Warning: Test: test_param_mismatch2: unknown parameter 'wrong_name2' in documentation comment, should be one of 'a', 'out2' /** + * test_param_mismatch3: + * @a: an integer + * @wrong_name3: (out): + * + */ +void test_param_mismatch3(int a, int *out3); + +// EXPECT:24: Warning: Test: test_param_mismatch3: unknown parameter 'wrong_name3' in documentation comment, should be 'out3' + +/** * test_param_missing: * @missing: (out): * */ void test_param_missing(void); -// EXPECT:23: Warning: Test: test_param_missing: unknown parameter 'missing' in documentation comment +// EXPECT:33: Warning: Test: test_param_missing: unknown parameter 'missing' in documentation comment /** diff --git a/tools/compiler.c b/tools/compiler.c index e3c3c556..7e17f1bd 100644 --- a/tools/compiler.c +++ b/tools/compiler.c @@ -1,4 +1,5 @@ -/* GObject introspection: Typelib compiler +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Typelib compiler * * Copyright (C) 2005 Matthias Clasen * diff --git a/tools/generate.c b/tools/generate.c index 7fe1afb0..0426512f 100644 --- a/tools/generate.c +++ b/tools/generate.c @@ -1,6 +1,5 @@ - -/* -*- Mode: C; c-file-style: "gnu"; -*- */ -/* GObject introspection: IDL generator +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: IDL generator * * Copyright (C) 2005 Matthias Clasen * Copyright (C) 2008,2009 Red Hat, Inc. |