Re: Introspection API

On Fri, 2005-02-18 at 15:34 -0600, Mike Kestner wrote:
>On Tue, 2005-02-15 at 15:38 -0500, Matthias Clasen wrote:
>> Comments would be appreciated,
>One more wrinkle for params...
>It would be nice for string params to identify encoding when they are
>not in utf8 encoding, such as in the filename case.  A case could
>probably be made for a GStringDef.

Are there any other common encodings besides filenames and UTF-8 ? 
I have reworked my initial api draft a bit (drawing some inspiration
from dbus-gidl.h), and the new draft includes generic annotations, which
could be used to associate encoding information with string parameters.

Here is a quick summary of the changes wrt to the first draft: 

- The names have changed from ...Def to ...Info, "FunctionType"
  has become "Signature".
- I have simplified the api a bit, by dropping the separate enum, flags,
  interface, object and boxed infos. There is now just a generic
  InterfaceInfo for all of these, and you can use
  g_interface_info_get_interface_type() to find out which one it is.
  Many of the separate boolean getters have been grouped into 
  get_flags() for the various info structs.
- A side-effect of the above change is that you can now call
  g_interface_get_value() on an interface which is not an enum/flags,
  and I think it makes sense to use this to allow constants in 
  interfaces which are not grouped in an enum (this was requested by
  Michael Meeks). Once we allow constants in interfaces, it probably
  makes sense to also allow freestanding constants which are not
  contained in any interface.
- There is now a generic annotation mechanism which allows to associate
  arbitrary key-value pairs of strings with interfaces (requested by
  Mathrick Katafiasz). 
- The explicit apis for deprecation and for marking out parameters as 
  "the return value" have been dropped, since these seem to be natural 
  candidates for using the annotation mechanism.   
Further comments on this api proposal would be appreciated (don't be
surprised if I don't respond immediately, I'll be on vacation until next

/* Should be a singleton, all metadata blobs of loaded libraries 
 * will be registered with the repository.
typedef struct _GIRepository GIRepository;

/* Types of objects registered in the repository
typedef struct _GBaseInfo GBaseInfo;
typedef struct _GFunctionInfo GFunctionInfo;
typedef struct _GSignatureInfo GSignatureInfo;
typedef struct _GTypeInfo GTypeInfo;
typedef struct _GArgInfo GArgInfo;
typedef struct _GInterfaceInfo GInterfaceInfo;
typedef struct _GStructInfo GStructInfo;
typedef struct _GValueInfo GValueInfo;
typedef struct _GFieldInfo GFieldInfo;
typedef struct _GPropertyInfo GPropertyInfo;
typedef struct _GSignalInfo GSignalInfo;
typedef struct _GVFuncInfo GVFuncInfo;

/* GIRepository functions */ 
GBaseInfo * g_irepository_find_by_name     (GIRepository *repository,
					    const gchar  *namespace,
					    const gchar  *name);
GBaseInfo * g_irepository_find_by_gtype    (GIRepository *repository,
					    GType         type);

gint        g_irepository_get_n_infos      (GIRepository *repository,
					    const gchar  *namespace);
GBaseInfo * g_irepository_get_info         (GIRepository *repository,
					    const gchar  *namespace,
					    gint          index);

/* GBaseInfo functions */
const gchar *          g_base_info_get_name         (GBaseInfo   *info);
const gchar *          g_base_info_get_namespace    (GBaseInfo   *info);
const gchar *          g_base_info_get_annotation   (GBaseInfo   *info,
                                                     const gchar *key);

/* GFunctionInfo functions */
typedef enum {
} GFunctionFlags;
const gchar *          g_function_info_get_symbol     (GFunctionInfo *info);
GSignatureInfo *       g_function_info_get_signature  (GFunctionInfo *info);
GBaseInfo *            g_function_info_get_interface  (GFunctionInfo *info);
GFunctionFlags         g_function_info_get_flags      (GFunctionInfo *info);
GPropertyInfo *        g_function_info_get_property   (GFunctionInfo *info);

/* GSignatureInfo functions */
typedef enum {
} Transfer;

GTypeInfo *            g_signature_info_get_return_type (GSignatureInfo *info);
Transfer               g_signature_info_get_caller_owns (GSignatureInfo *info);
gint                   g_signature_info_get_n_args      (GSignatureInfo *info);
GArgInfo *             g_signature_info_get_arg         (GSignatureInfo *info,
							 gint            n);

/* GArgInfo function */
typedef enum {
} Direction;

Direction              g_arg_info_get_direction     (GArgInfo *info);
gboolean               g_arg_info_is_shared         (GArgInfo *info);
GTypeInfo *            g_arg_info_get_type          (GArgInfo *info);

/* GTypeInfo functions */
typedef enum {
} Tag;
gboolean               g_type_info_is_pointer         (GTypeInfo *info);
Tag                    g_type_info_get_tag            (GTypeInfo *info);
GTypeInfo *            g_type_info_get_param_type     (GTypeInfo *info,
						       gint       n);
GBaseInfo *            g_type_info_get_interface      (GTypeInfo *info);
gint                   g_type_info_get_array_length   (GTypeInfo *info);
gboolean               g_type_info_is_zero_terminated (GTypeInfo *info);

/* GValueInfo functions */ 
const gchar *          g_value_info_get_short_name (GValueInfo *info);
glong                  g_value_info_get_value      (GValueInfo *info);

/* GFieldInfo functions */
typedef enum {
  READABLE = 1 << 0, 
  WRITABLE = 1 << 1
} FieldFlags;
gint                   g_field_info_get_size       (GFieldInfo *info);
FieldFlags             g_field_info_get_flags      (GFieldInfo *info);
GTypeInfo *            g_field_info_get_type       (GFieldInfo *info);

/* GStructInfo functions */
gint                   g_struct_info_get_n_fields  (GStructInfo *info);
GFieldInfo *           g_struct_info_get_field     (GStructInfo *info,
						    gint         n);
gint                   g_struct_info_get_n_methods (GStructInfo *info);
GFunctionInfo *        g_struct_info_get_method    (GStructInfo *info,
						    gint         n);

/* GInterfaceInfo functions */
typedef enum {
} InterfaceType;

InterfaceType          g_interface_info_get_interface_type  (GInterfaceInfo *info);
const gchar *          g_interface_info_get_type_name       (GInterfaceInfo *info);
const gchar *          g_interface_info_get_type_init       (GInterfaceInfo *info);
GInterfaceInfo *       g_interface_info_get_parent          (GInterfaceInfo *info);
gint                   g_interface_info_get_n_interfaces    (GInterfaceInfo *info);
GInterfaceInfo *       g_interface_info_get_interface       (GInterfaceInfo *info,
							     gint            n);
gint                   g_interface_info_get_n_prerequisites (GInterfaceInfo *info);
GInterfaceInfo *       g_interface_info_get_prerequisite    (GInterfaceInfo *info,
							     gint            n);

gint                   g_interface_info_get_n_values        (GInterfaceInfo *info);
GValueInfo  *          g_interface_info_get_value           (GInterfaceInfo *info,
							     gint            n);
gint                   g_interface_info_get_n_fields        (GInterfaceInfo *info);
GFieldInfo *           g_interface_info_get_field           (GInterfaceInfo *info,
							     gint            n);
gint                   g_interface_info_get_n_properties    (GInterfaceInfo *info);
GPropertyInfo *        g_interface_info_get_property        (GInterfaceInfo *info,
							     gint            n);
gint                   g_interface_info_get_n_methods       (GInterfaceInfo *info);
GFunctionInfo *        g_interface_info_get_method          (GInterfaceInfo *info,
							     gint            n);
gint                   g_interface_info_get_n_signals       (GInterfaceInfo *info);
GSignalInfo *          g_interface_info_get_signal          (GInterfaceInfo *info,
							     gint            n);
gint                   g_interface_info_get_n_vfuncs        (GInterfaceInfo *info);
GVFuncInfo *           g_interface_info_get_vfunc           (GInterfaceInfo *info,
							     gint            n);

/* GPropertyInfo functions */
GParamFlags            g_property_info_get_flags                (GPropertyInfo         *info);
GTypeInfo *            g_property_info_get_type                 (GPropertyInfo         *info);

/* GSignalInfo functions */
typedef enum {
} RunWhen;
GInterfaceInfo *       g_signal_info_get_interface              (GSignalInfo           *info);
GSignalFlags           g_signal_info_get_flags                  (GSignalInfo           *info);
GVFuncInfo *           g_signal_info_get_class_closure          (GSignalInfo           *info);
GSignatureInfo *       g_signal_info_get_signature              (GSignalInfo           *info);

/* GVFuncInfo functions */
typedef enum {
} GVFuncFlags;
GInterfaceInfo *       g_vfunc_info_get_interface               (GVFuncInfo            *info);
GVFuncFlags            g_vfunc_info_get_flags                   (GVFuncInfo            *info);
GSignalInfo *          g_vfunc_info_get_signal                  (GVFuncInfo            *info);

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