Enumerations can be negative
[gnome.gobject-introspection] / girepository / gtypelib.h
index 9a78873..f02dcfc 100644 (file)
@@ -52,14 +52,15 @@ G_BEGIN_DECLS
  * 
  * The typelib has the following general format.
  *
- * typelib ::= header, directory, blobs, annotations
+ * typelib ::= header, directory, blobs, attributes, attributedata
  *
  * directory ::= list of entries
  *
  * entry ::= blob type, name, namespace, offset
  * blob ::= function|callback|struct|boxed|enum|flags|object|interface|constant|errordomain|union
- * annotations ::= list of annotations, sorted by offset 
- * annotation ::= offset, key, value
+ * attributes ::= list of attributes, sorted by offset
+ * attribute ::= offset, key, value
+ * attributedata ::= string data for attributes
  *
  * Details
  * 
@@ -72,6 +73,7 @@ G_BEGIN_DECLS
 TYPELIB HISTORY
 -----
 Version 1.0
+- Rename class_struct to gtype_struct, add to interfaces
 
 Changes since 0.9:
 - Add padding to structures
@@ -188,8 +190,8 @@ typedef enum {
  * @n_local_entries: The number of entries referring to blobs in this typelib. The
  * local entries must occur before the unresolved entries.
  * @directory: Offset of the directory in the typelib.
- * @n_annotations: Number of annotation blocks
- * @annotations: Offset of the list of annotations in the typelib. 
+ * @n_attributes: Number of attribute blocks
+ * @attributes: Offset of the list of attributes in the typelib.
  * @dependencies: Offset of a single string, which is the list of
  * dependencies, separated by the '|' character.  The
  * dependencies are required in order to avoid having programs
@@ -211,7 +213,7 @@ typedef enum {
  * @property_blob_size: See above.
  * @field_blob_size: See above.
  * @value_blob_size: See above.
- * @annotation_blob_size: See above.
+ * @attribute_blob_size: See above.
  * @constant_blob_size: See above.
  * @object_blob_size: See above.
  * @union_blob_size: See above.
@@ -236,8 +238,8 @@ typedef struct {
   guint16 n_entries;
   guint16 n_local_entries;
   guint32 directory;
-  guint32 n_annotations;
-  guint32 annotations;
+  guint32 n_attributes;
+  guint32 attributes;
 
   guint32 dependencies;
 
@@ -245,6 +247,7 @@ typedef struct {
   guint32 namespace;
   guint32 nsversion;
   guint32 shared_library;
+  guint32 c_prefix;
 
   guint16 entry_blob_size;
   guint16 function_blob_size;
@@ -255,7 +258,7 @@ typedef struct {
   guint16 property_blob_size;
   guint16 field_blob_size;
   guint16 value_blob_size;
-  guint16 annotation_blob_size;
+  guint16 attribute_blob_size;
   guint16 constant_blob_size;
   guint16 error_domain_blob_size;
 
@@ -300,6 +303,20 @@ typedef struct {
  * @offset:  Offset relative to header->types that points to a TypeBlob. 
  * Unlike other offsets, this is in words (ie 32bit units) rather
  * than bytes.
+ *
+ * The SimpleTypeBlob is the general purpose "reference to a type" construct, used
+ * in method parameters, returns, callback definitions, fields, constants, etc.
+ * It's actually just a 32 bit integer which you can see from the union definition.
+ * This is for efficiency reasons, since there are so many references to types.
+ *
+ * SimpleTypeBlob is divided into two cases; first, if "reserved" and "reserved2", the
+ * type tag for a basic type is embedded in the "tag" bits.  This allows e.g.
+ * GI_TYPE_TAG_UTF8, GI_TYPE_TAG_INT and the like to be embedded directly without
+ * taking up extra space.
+ *
+ * References to "interfaces" (objects, interfaces) are more complicated;  In this case,
+ * the integer is actually an offset into the directory (see above).  Because the header
+ * is larger than 2^8=256 bits, all offsets will have one of the upper 24 bits set.
  */
 typedef union
 {
@@ -310,7 +327,7 @@ typedef union
     guint pointer    : 1;
     guint reserved3  : 2;
     guint tag        : 5;    
-  };
+  } flags;
   guint32    offset;
 } SimpleTypeBlob;
 
@@ -489,7 +506,6 @@ typedef struct {
  * @tag: A #GITypeTag
  * @interface: Index of the directory entry for the interface.
  * 
- * Types which are described by an entry in the typelib have a tag value of 21. 
  * If the interface is an enum of flags type, is_pointer is 0, otherwise it is 1.
  */
 typedef struct {
@@ -513,8 +529,7 @@ typedef struct {
  * direction as this one. 
  * @type: The type of the array elements.
  * 
- * Arrays have a tag value of 20. They are passed by reference, thus is_pointer 
- * is always 1.
+ * Arrays are passed by reference, thus is_pointer is always 1.
  */
 typedef struct {
   guint16 pointer         :1;
@@ -529,7 +544,7 @@ typedef struct {
   union {
     guint16 length;
     guint16 size;
-  };
+  } dimensions;
 
   SimpleTypeBlob type;
 } ArrayTypeBlob;
@@ -599,7 +614,7 @@ typedef struct {
   guint32 deprecated : 1;
   guint32 reserved   :31;
   guint32 name;
-  guint32 value;
+  gint32 value;
 } ValueBlob;
 
 /**
@@ -607,6 +622,7 @@ typedef struct {
  * @name: The name of the field.
  * @readable:
  * @writable: How the field may be accessed.
+ * @has_embedded_type: An anonymous type follows the FieldBlob.
  * @bits: If this field is part of a bitfield, the number of bits which it
  * uses, otherwise 0.
  * @struct_offset:
@@ -619,7 +635,8 @@ typedef struct {
 
   guint8         readable :1; 
   guint8         writable :1;
-  guint8         reserved :6;
+  guint8         has_embedded_type :1;
+  guint8         reserved :5;
   guint8         bits;
 
   guint16        struct_offset;
@@ -651,7 +668,7 @@ typedef struct {
  * @deprecated: Whether this structure is deprecated
  * @unregistered: If this is set, the type is not registered with GType.
  * @alignment: The byte boundary that the struct is aligned to in memory
- * @is_class_struct: Whether this structure is the "class structure" for a GObject
+ * @is_gtype_struct: Whether this structure is the class or interface layout for a GObject
  * @size: The size of the struct in bytes.
  * @gtype_name: String name of the associated #GType
  * @gtype_init: String naming the symbol which gets the runtime #GType
@@ -666,7 +683,7 @@ typedef struct {
 
   guint16   deprecated   : 1;
   guint16   unregistered : 1;
-  guint16   is_class_struct : 1;
+  guint16   is_gtype_struct : 1;
   guint16   alignment    : 6;  
   guint16   reserved     : 7;
 
@@ -841,9 +858,10 @@ typedef struct {
  * @class_closure: Set if this virtual function is the class closure of a signal.
  * @signal: The index of the signal in the list of signals of the object or 
  * interface to which this virtual function belongs.
- * @struct_offset:
- * The offset of the function pointer in the class struct. The value
+ * @struct_offset: The offset of the function pointer in the class struct. The value
  * 0xFFFF indicates that the struct offset is unknown.
+ * @invoker: If a method invoker for this virtual exists, this is the offset in the
+ * class structure of the method.  If no method is known, this value will be 0x3ff.
  * @signature: 
  * Offset of the SignatureBlob describing the parameter types and the 
  * return value type. 
@@ -859,7 +877,8 @@ typedef struct {
   guint16 signal;
 
   guint16 struct_offset;
-  guint16 reserved2;
+  guint16 invoker : 10; /* Number of bits matches @index in FunctionBlob */
+  guint16 reserved2 : 6;
 
   guint32 reserved3;
   guint32 signature;
@@ -900,7 +919,7 @@ typedef struct {
   guint32   gtype_init;
 
   guint16   parent;
-  guint16   class_struct;
+  guint16   gtype_struct;
 
   guint16   n_interfaces;
   guint16   n_fields;
@@ -929,6 +948,7 @@ typedef struct {
 
 /**
  * InterfaceBlob:
+ * @gtype_struct: Name of the interface "class" C structure
  * @n_prerequisites: Number of prerequisites
  * @n_properties: Number of properties
  * @n_methods: Number of methods
@@ -952,6 +972,7 @@ typedef struct {
 
   guint32 gtype_name;
   guint32 gtype_init;
+  guint16 gtype_struct;
 
   guint16 n_prerequisites;
   guint16 n_properties;
@@ -997,18 +1018,18 @@ typedef struct {
 } ConstantBlob;
 
 /**
- * AnnotationBlob:
- * @offset: The offset of the typelib entry to which this annotation refers.
- * Annotations are kept sorted by offset, so that the annotations
+ * AttributeBlob:
+ * @offset: The offset of the typelib entry to which this attribute refers.
+ * Attributes are kept sorted by offset, so that the attributes
  * of an entry can be found by a binary search.
- * @name: The name of the annotation, a string.
- * @value: The value of the annotation (also a string)
+ * @name: The name of the attribute, a string.
+ * @value: The value of the attribute (also a string)
  */
 typedef struct {
   guint32 offset;
   guint32 name;
   guint32 value;
-} AnnotationBlob;
+} AttributeBlob;
 
 struct _GTypelib {
   guchar *data;
@@ -1016,6 +1037,7 @@ struct _GTypelib {
   gboolean owns_memory;
   GMappedFile *mfile;
   GList *modules;
+  gboolean open_attempted;
 };
 
 DirEntry *g_typelib_get_dir_entry (GTypelib *typelib,