Re: introspection



I found in your GIR file, it don't detect (for example) confi_new() as a function of Confi object and it is not introspectable. Also, all functions are "free" no related to any GObject. Then you haven't provided enough information to detect namespace and its GObjects.

You should add a prefix, as a namespace, to your object and its functions. If you have any problem, please let me check if your C code is GObject compliant.

Prefix is not for instrospection, is a way allow GI to parse your C code correctly and generate valid GIR files.

Another way is to use meta information, but I recommend to avoid that. Is better to use annotations to fix things. But for you, if use metadata, you should add lot of metainformation.


2014-11-20 8:02 GMT-06:00 Andrea Zagli <azagli libero it>:
Il giorno mer 19 nov 2014 18:20:17 CET, Daniel Espinosa ha scritto:

1. Could you share your Gir file?


<?xml version="1.0"?>
<!-- This file was automatically generated from C sources - DO NOT EDIT!
To affect the contents of this file, edit the original C definitions,
and/or use gtk-doc annotations.  -->
<repository version="1.2"
            xmlns="http://www.gtk.org/introspection/core/1.0"
            xmlns:c="http://www.gtk.org/introspection/c/1.0"
            xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
  <include name="Gda" version="5.0"/>
  <namespace name="Confi"
             version="1.0"
             shared-library="libconfi-0.dll"
             c:identifier-prefixes="Confi"
             c:symbol-prefixes="confi">
    <record name="Class" c:type="ConfiClass">
      <field name="parent_class" writable="1">
        <type name="GObject.ObjectClass" c:type="GObjectClass"/>
      </field>
    </record>
    <record name="Key" c:type="ConfiKey">
      <field name="id_config" writable="1">
        <type name="gint" c:type="gint"/>
      </field>
      <field name="id" writable="1">
        <type name="gint" c:type="gint"/>
      </field>
      <field name="id_parent" writable="1">
        <type name="gint" c:type="gint"/>
      </field>
      <field name="key" writable="1">
        <type name="utf8" c:type="gchar*"/>
      </field>
      <field name="value" writable="1">
        <type name="utf8" c:type="gchar*"/>
      </field>
      <field name="description" writable="1">
        <type name="utf8" c:type="gchar*"/>
      </field>
      <field name="path" writable="1">
        <type name="utf8" c:type="gchar*"/>
      </field>
      <function name="set_key" c:identifier="confi_key_set_key">
        <return-value transfer-ownership="none">
          <type name="gboolean" c:type="gboolean"/>
        </return-value>
        <parameters>
          <parameter name="confi" transfer-ownership="none">
            <doc xml:space="preserve">a #Confi object.</doc>
            <type name="_" c:type="Confi*"/>
          </parameter>
          <parameter name="ck" transfer-ownership="none">
            <doc xml:space="preserve">a #ConfiKey struct.</doc>
            <type name="Key" c:type="ConfiKey*"/>
          </parameter>
        </parameters>
      </function>
    </record>
    <record name="_" c:type="Confi">
      <field name="parent" writable="1">
        <type name="GObject.Object" c:type="GObject"/>
      </field>
    </record>
    <function name="add_key" c:identifier="confi_add_key" introspectable="0">
      <return-value>
        <doc xml:space="preserve">a #ConfigKey struct filled with data from the key just added.</doc>
        <type name="Key" c:type="ConfiKey*"/>
      </return-value>
      <parameters>
        <parameter name="confi" transfer-ownership="none">
          <doc xml:space="preserve">a #Confi object.</doc>
          <type name="_" c:type="Confi*"/>
        </parameter>
        <parameter name="parent" transfer-ownership="none">
          <doc xml:space="preserve">the path where add the key.</doc>
          <type name="utf8" c:type="const gchar*"/>
        </parameter>
        <parameter name="key" transfer-ownership="none">
          <doc xml:space="preserve">the key's name.</doc>
          <type name="utf8" c:type="const gchar*"/>
        </parameter>
      </parameters>
    </function>
    <function name="add_key_with_value"
              c:identifier="confi_add_key_with_value"
              introspectable="0">
      <return-value>
        <doc xml:space="preserve">a #ConfigKey struct filled with data from the key just added.</doc>
        <type name="Key" c:type="ConfiKey*"/>
      </return-value>
      <parameters>
        <parameter name="confi" transfer-ownership="none">
          <doc xml:space="preserve">a #Confi object.</doc>
          <type name="_" c:type="Confi*"/>
        </parameter>
        <parameter name="parent" transfer-ownership="none">
          <doc xml:space="preserve">the path where add the key.</doc>
          <type name="utf8" c:type="const gchar*"/>
        </parameter>
        <parameter name="key" transfer-ownership="none">
          <doc xml:space="preserve">the key's name.</doc>
          <type name="utf8" c:type="const gchar*"/>
        </parameter>
        <parameter name="value" transfer-ownership="none">
          <doc xml:space="preserve">the key's value.</doc>
          <type name="utf8" c:type="const gchar*"/>
        </parameter>
      </parameters>
    </function>
    <function name="destroy" c:identifier="confi_destroy">
      <doc xml:space="preserve">Destroy the #Confi object, freeing memory.</doc>
      <return-value transfer-ownership="none">
        <type name="none" c:type="void"/>
      </return-value>
      <parameters>
        <parameter name="confi" transfer-ownership="none">
          <doc xml:space="preserve">a #Confi object.</doc>
          <type name="_" c:type="Confi*"/>
        </parameter>
      </parameters>
    </function>
    <function name="get_configs_list"
              c:identifier="confi_get_configs_list"
              introspectable="0">
      <return-value>
        <doc xml:space="preserve">a #GList of #Confi. If there's no configurations, returns a valid
#GList but with a unique NULL element.</doc>
        <type name="GLib.List" c:type="GList*">
          <type name="gpointer" c:type="gpointer"/>
        </type>
      </return-value>
      <parameters>
        <parameter name="cnc_string" transfer-ownership="none">
          <doc xml:space="preserve">the connection string to use to connect to database that
contains configuration.</doc>
          <type name="utf8" c:type="const gchar*"/>
        </parameter>
        <parameter name="filter" transfer-ownership="none">
          <type name="utf8" c:type="const gchar*"/>
        </parameter>
      </parameters>
    </function>
    <function name="get_tree" c:identifier="confi_get_tree" introspectable="0">
      <return-value>
        <type name="GLib.Node" c:type="GNode*"/>
      </return-value>
      <parameters>
        <parameter name="confi" transfer-ownership="none">
          <doc xml:space="preserve">a #Confi object.</doc>
          <type name="_" c:type="Confi*"/>
        </parameter>
      </parameters>
    </function>
    <function name="get_type" c:identifier="confi_get_type">
      <return-value transfer-ownership="none">
        <type name="GType" c:type="GType"/>
      </return-value>
    </function>
    <function name="key_set_key"
              c:identifier="confi_key_set_key"
              moved-to="Key.set_key">
      <return-value transfer-ownership="none">
        <type name="gboolean" c:type="gboolean"/>
      </return-value>
      <parameters>
        <parameter name="confi" transfer-ownership="none">
          <doc xml:space="preserve">a #Confi object.</doc>
          <type name="_" c:type="Confi*"/>
        </parameter>
        <parameter name="ck" transfer-ownership="none">
          <doc xml:space="preserve">a #ConfiKey struct.</doc>
          <type name="Key" c:type="ConfiKey*"/>
        </parameter>
      </parameters>
    </function>
    <function name="new" c:identifier="confi_new" introspectable="0">
      <return-value>
        <doc xml:space="preserve">the newly created #Confi object, or NULL if it fails.</doc>
        <type name="_" c:type="Confi*"/>
      </return-value>
      <parameters>
        <parameter name="cnc_string" transfer-ownership="none">
          <doc xml:space="preserve">the connection string to use to connect to database that
contains configuration.</doc>
          <type name="utf8" c:type="const gchar*"/>
        </parameter>
        <parameter name="name" transfer-ownership="none">
          <doc xml:space="preserve">configuration's name.</doc>
          <type name="utf8" c:type="const gchar*"/>
        </parameter>
        <parameter name="root" transfer-ownership="none">
          <type name="utf8" c:type="const gchar*"/>
        </parameter>
        <parameter name="create" transfer-ownership="none">
          <doc xml:space="preserve">whether create a config into database if @name doesn't exists.</doc>
          <type name="gboolean" c:type="gboolean"/>
        </parameter>
      </parameters>
    </function>
    <function name="path_get_confi_key"
              c:identifier="confi_path_get_confi_key"
              introspectable="0">
      <return-value>
        <type name="Key" c:type="ConfiKey*"/>
      </return-value>
      <parameters>
        <parameter name="confi" transfer-ownership="none">
          <doc xml:space="preserve">a #Confi object.</doc>
          <type name="_" c:type="Confi*"/>
        </parameter>
        <parameter name="path" transfer-ownership="none">
          <doc xml:space="preserve">the key's path to get.</doc>
          <type name="utf8" c:type="const gchar*"/>
        </parameter>
      </parameters>
    </function>
    <function name="path_get_value" c:identifier="confi_path_get_value">
      <return-value transfer-ownership="full">
        <doc xml:space="preserve">the configuration's value as a string.</doc>
        <type name="utf8" c:type="gchar*"/>
      </return-value>
      <parameters>
        <parameter name="confi" transfer-ownership="none">
          <doc xml:space="preserve">a #Confi object.</doc>
          <type name="_" c:type="Confi*"/>
        </parameter>
        <parameter name="path" transfer-ownership="none">
          <doc xml:space="preserve">the path from which retrieving the value.</doc>
          <type name="utf8" c:type="const gchar*"/>
        </parameter>
      </parameters>
    </function>
    <function name="path_move" c:identifier="confi_path_move">
      <return-value transfer-ownership="none">
        <type name="gboolean" c:type="gboolean"/>
      </return-value>
      <parameters>
        <parameter name="confi" transfer-ownership="none">
          <doc xml:space="preserve">a #Confi object.</doc>
          <type name="_" c:type="Confi*"/>
        </parameter>
        <parameter name="path" transfer-ownership="none">
          <doc xml:space="preserve">the key's path to move.</doc>
          <type name="utf8" c:type="const gchar*"/>
        </parameter>
        <parameter name="parent" transfer-ownership="none">
          <doc xml:space="preserve">the path where add the key.</doc>
          <type name="utf8" c:type="const gchar*"/>
        </parameter>
      </parameters>
    </function>
    <function name="path_set_value" c:identifier="confi_path_set_value">
      <return-value transfer-ownership="none">
        <type name="gboolean" c:type="gboolean"/>
      </return-value>
      <parameters>
        <parameter name="confi" transfer-ownership="none">
          <doc xml:space="preserve">a #Confi object.</doc>
          <type name="_" c:type="Confi*"/>
        </parameter>
        <parameter name="path" transfer-ownership="none">
          <doc xml:space="preserve">the key's path.</doc>
          <type name="utf8" c:type="const gchar*"/>
        </parameter>
        <parameter name="value" transfer-ownership="none">
          <doc xml:space="preserve">the value to set.</doc>
          <type name="utf8" c:type="const gchar*"/>
        </parameter>
      </parameters>
    </function>
    <function name="remove" c:identifier="confi_remove">
      <doc xml:space="preserve">Remove a configuration from databases and destroy the relative object.</doc>
      <return-value transfer-ownership="none">
        <type name="gboolean" c:type="gboolean"/>
      </return-value>
      <parameters>
        <parameter name="confi" transfer-ownership="none">
          <doc xml:space="preserve">a #Confi object.</doc>
          <type name="_" c:type="Confi*"/>
        </parameter>
      </parameters>
    </function>
    <function name="remove_path" c:identifier="confi_remove_path">
      <doc xml:space="preserve">Removes @path and every child key.</doc>
      <return-value transfer-ownership="none">
        <type name="gboolean" c:type="gboolean"/>
      </return-value>
      <parameters>
        <parameter name="confi" transfer-ownership="none">
          <doc xml:space="preserve">a #Confi object.</doc>
          <type name="_" c:type="Confi*"/>
        </parameter>
        <parameter name="path" transfer-ownership="none">
          <doc xml:space="preserve">the path to remove.</doc>
          <type name="utf8" c:type="const gchar*"/>
        </parameter>
      </parameters>
    </function>
    <function name="set_root" c:identifier="confi_set_root">
      <return-value transfer-ownership="none">
        <type name="gboolean" c:type="gboolean"/>
      </return-value>
      <parameters>
        <parameter name="confi" transfer-ownership="none">
          <doc xml:space="preserve">a #Confi object.</doc>
          <type name="_" c:type="Confi*"/>
        </parameter>
        <parameter name="root" transfer-ownership="none">
          <doc xml:space="preserve">the root.</doc>
          <type name="utf8" c:type="const gchar*"/>
        </parameter>
      </parameters>
    </function>
  </namespace>
</repository>



2. Is a good idea to add a namespace. Like your main project prefix. This
avoids introspection function and objects name collisions.

but is it mandatory to make introspection works?



El 19/11/2014 05:13, "Andrea Zagli" <azagli libero it> escribió:
[...]



--
Trabajar, la mejor arma para tu superación
"de grano en grano, se hace la arena" (R) (en trámite, pero para los cuates: LIBRE)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]