Blame docs/defsformat.txt

Packit Service fb6fa5
Packit Service fb6fa5
The overall syntax is:
Packit Service fb6fa5
Packit Service fb6fa5
     (type-of-thing-being-defined  name-used-to-refer-to-this-thing
Packit Service fb6fa5
       (attribute-name  attribute-value-depending-on-the-attribute)
Packit Service fb6fa5
       (attribute-name  attribute-value-depending-on-the-attribute)
Packit Service fb6fa5
       (attribute-name  attribute-value-depending-on-the-attribute))
Packit Service fb6fa5
Packit Service fb6fa5
Some definitions can have a c-declaration field that gives the C code
Packit Service fb6fa5
we parsed to arrive at the definition. The c-declaration is a quoted
Packit Service fb6fa5
string because it can contain parentheses and such.
Packit Service fb6fa5
Packit Service fb6fa5
Defined types and their attributes:
Packit Service fb6fa5
Packit Service fb6fa5
===
Packit Service fb6fa5
(module module-name
Packit Service fb6fa5
  (submodule-of module-name)) ;; submodule is optional
Packit Service fb6fa5
Packit Service fb6fa5
Ex: (module Gtk)
Packit Service fb6fa5
Ex: (module Rgb
Packit Service fb6fa5
      (submodule-of Gdk))
Packit Service fb6fa5
Packit Service fb6fa5
modules are later referred to with a list of module names, like 
Packit Service fb6fa5
(Gdk Rgb) or (Gtk)
Packit Service fb6fa5
Packit Service fb6fa5
Object and boxed type definitions automatically create a submodule.
Packit Service fb6fa5
For example, GtkCList creates the module (module CList (submodule-of
Packit Service fb6fa5
(Gtk))) which is referred to as module (Gtk CList).
Packit Service fb6fa5
Packit Service fb6fa5
===
Packit Service fb6fa5
Packit Service fb6fa5
(type
Packit Service fb6fa5
 (alias some-unique-identifier)
Packit Service fb6fa5
 (in-module module-name)   ;; optional, gchar* is not in a module
Packit Service fb6fa5
 (gtk-type-id gtk-type-system-id) ;; optional, absent if this is not
Packit Service fb6fa5
                                  ;; in the type system
Packit Service fb6fa5
 (is-parametric boolean)          ;; optional default to #f
Packit Service fb6fa5
 (in-c-name name-of-symbol-in-C)
Packit Service fb6fa5
 (out-c-name name-of-symbol-in-C)
Packit Service fb6fa5
 (inout-c-name name-of-symbol-in-C))
Packit Service fb6fa5
Packit Service fb6fa5
Ex: (type
Packit Service fb6fa5
     (alias string)
Packit Service fb6fa5
     (gtk-type-id GTK_TYPE_STRING)
Packit Service fb6fa5
     (in-c-name "const gchar*")
Packit Service fb6fa5
     (out-c-name "gchar**")      ;; actually I'm not sure how strings work out/inout
Packit Service fb6fa5
     (inout-c-name "gchar*"))
Packit Service fb6fa5
Packit Service fb6fa5
 (type
Packit Service fb6fa5
     (alias list)
Packit Service fb6fa5
     (gtk-type-id GTK_TYPE_POINTER)
Packit Service fb6fa5
     (is-parametric #t)
Packit Service fb6fa5
     (in-c-name "GList*")
Packit Service fb6fa5
     (out-c-name "GList**")
Packit Service fb6fa5
     (inout-c-name "GList**"))
Packit Service fb6fa5
Packit Service fb6fa5
Packit Service fb6fa5
 ;; This one would be implied by the (object) def for GtkWidget I
Packit Service fb6fa5
 ;; think - (type) is only required for types that are not implied
Packit Service fb6fa5
 ;; by other definitions, such as int/boolean/etc.
Packit Service fb6fa5
 
Packit Service fb6fa5
    (type
Packit Service fb6fa5
     (alias GtkWidget)
Packit Service fb6fa5
     (in-module (Gtk))
Packit Service fb6fa5
     (gtk-type-id GTK_TYPE_WIDGET)
Packit Service fb6fa5
     (in-c-name "GtkWidget*")
Packit Service fb6fa5
     (inout-c-name "GtkWidget*")
Packit Service fb6fa5
     (out-c-name "GtkWidget**"))
Packit Service fb6fa5
Packit Service fb6fa5
"Type" bindings are automatically assumed for objects, boxed types,
Packit Service fb6fa5
etc. as defined below.
Packit Service fb6fa5
Packit Service fb6fa5
The alias field is used to refer to the type later on.
Packit Service fb6fa5
Packit Service fb6fa5
Whenever a type alias can be used, it is also possible to use the
Packit Service fb6fa5
keyword "native", which implies that the type in question is too
Packit Service fb6fa5
C-specific to represent. Then a c-declaration will typically be
Packit Service fb6fa5
available for use.
Packit Service fb6fa5
Packit Service fb6fa5
C types containing [] or () are function pointers or arrays. For
Packit Service fb6fa5
arrays that don't specify a size, we just treat them as pointers. For
Packit Service fb6fa5
function pointers, we need special (type) syntax/attributes of some
Packit Service fb6fa5
kind, but since there basically aren't any of these right now in the
Packit Service fb6fa5
libs we care about we can just ignore them. For arrays that specify a
Packit Service fb6fa5
size ditto, you would handle them by adding an (array-size) attribute
Packit Service fb6fa5
or something or using the "native" keyword and skipping the (type)
Packit Service fb6fa5
stuff.
Packit Service fb6fa5
Packit Service fb6fa5
===
Packit Service fb6fa5
(object object-name
Packit Service fb6fa5
   (in-module module-name-list)
Packit Service fb6fa5
   (parent object-name optional-module-name-if-different)
Packit Service fb6fa5
   (abstract boolean-is-abstract-class) ;; omit for default of #f
Packit Service fb6fa5
   (c-name name-of-the-object-in-C)
Packit Service fb6fa5
   (field (type-and-name type-alias-of-struct-field name-of-struct-field)
Packit Service fb6fa5
          (access read-or-write-or-readwrite)))
Packit Service fb6fa5
   
Packit Service fb6fa5
Packit Service fb6fa5
Ex: (object Widget
Packit Service fb6fa5
      (in-module (Gtk))
Packit Service fb6fa5
      (parent Object)      ;; could say (parent Object (Gtk))
Packit Service fb6fa5
      (abstract #t)
Packit Service fb6fa5
      (c-name GtkWidget)
Packit Service fb6fa5
      (field (type-and-name GdkWindow* window) (access read)))
Packit Service fb6fa5
Packit Service fb6fa5
An "object" declaration automatically implies the type definition:
Packit Service fb6fa5
Packit Service fb6fa5
(type
Packit Service fb6fa5
  (alias concat-module-elements-and-object-name)
Packit Service fb6fa5
  (in-c-name pointer-to-c-name)
Packit Service fb6fa5
  (out-c-name pointer-to-pointer-to-c-name)
Packit Service fb6fa5
  (inout-c-name pointer-to-c-name))
Packit Service fb6fa5
Packit Service fb6fa5
Ex: 
Packit Service fb6fa5
 (type (alias GtkWidget) 
Packit Service fb6fa5
       (in-c-name GtkWidget*) 
Packit Service fb6fa5
       (out-c-name GtkWidget**) 
Packit Service fb6fa5
       (inout-c-name GtkWidget*))
Packit Service fb6fa5
Packit Service fb6fa5
It also implies a module that is the name broken into parts:
Packit Service fb6fa5
 (module CTree
Packit Service fb6fa5
   (submodule-of Gtk))
Packit Service fb6fa5
Packit Service fb6fa5
===
Packit Service fb6fa5
Packit Service fb6fa5
(function function-name
Packit Service fb6fa5
  (in-module module-name-list) ;; "static methods" go in their
Packit Service fb6fa5
                               ;;  object's module
Packit Service fb6fa5
  (is-constructor-of object-type-alias) ;; optional, marks a constructor
Packit Service fb6fa5
  (c-name function-name)
Packit Service fb6fa5
  (return-type return-value-type) ;; defaults to void
Packit Service fb6fa5
  (caller-owns-return boolean-value) ;; defaults to #f
Packit Service fb6fa5
  (can-return-null boolean-value) ;; defaults to #t
Packit Service fb6fa5
  (parameter in-or-out-or-inout 
Packit Service fb6fa5
      (type-and-name parameter-type-alias parameter-name)
Packit Service fb6fa5
      (type-parameter name-of-contained-type) ;; optional, requires parametric type
Packit Service fb6fa5
      (c-declaration "c-type-and-name")) ;; c-declaration only required
Packit Service fb6fa5
                                         ;; if the type alias is "native"
Packit Service fb6fa5
  (varargs #t) ;; has varargs at the end
Packit Service fb6fa5
)
Packit Service fb6fa5
Packit Service fb6fa5
Ex:
Packit Service fb6fa5
  (function init
Packit Service fb6fa5
    (in-module (Gdk Rgb)
Packit Service fb6fa5
    (c-name gdk_rgb_init)))
Packit Service fb6fa5
Packit Service fb6fa5
Ex: 
Packit Service fb6fa5
  (function new
Packit Service fb6fa5
    (in-module (Gdk Rgb Cmap))
Packit Service fb6fa5
    (is-constructor-of GdkRgbCmap)
Packit Service fb6fa5
    (c-name gdk_rgb_cmap_new)
Packit Service fb6fa5
    (return-type GdkRgbCmap)
Packit Service fb6fa5
    (caller-owns-return #t)   ;; perhaps this could be implied by is-constructor-of
Packit Service fb6fa5
    (parameter in (type-and-name array-of-guint32 colors))
Packit Service fb6fa5
    (parameter in (type-and-name gint n_colors)))
Packit Service fb6fa5
Packit Service fb6fa5
Ex:
Packit Service fb6fa5
  (function config_set_set_handler
Packit Service fb6fa5
   (in-module (Gnome))
Packit Service fb6fa5
   (c-name gnome_config_set_set_handler)
Packit Service fb6fa5
   (parameter in (type-and-name native func)
Packit Service fb6fa5
                 (c-declaration "void (*func)(void*)"))
Packit Service fb6fa5
   (parameter in (type-and-name gpointer data)))  
Packit Service fb6fa5
Packit Service fb6fa5
===
Packit Service fb6fa5
(method method-name
Packit Service fb6fa5
  (of-object object-name module-name)
Packit Service fb6fa5
  ;; retval/arg attributes as for (function), but with first parameter
Packit Service fb6fa5
  ;; omitted for non-constructors
Packit Service fb6fa5
   )
Packit Service fb6fa5
 
Packit Service fb6fa5
Ex:
Packit Service fb6fa5
  (method set_text
Packit Service fb6fa5
     (of-object Label (Gtk))
Packit Service fb6fa5
     (parameter (type-and-name const-gchar* str)))
Packit Service fb6fa5
Packit Service fb6fa5
===
Packit Service fb6fa5
(object-argument arg-name
Packit Service fb6fa5
   (of-object object-we-are-an-argument-of optional-objects-module)
Packit Service fb6fa5
   (type-id argument-type)       ;; GTK_TYPE_OBJECT etc.
Packit Service fb6fa5
   ;; flags all default to #f
Packit Service fb6fa5
   (readable bool-value)
Packit Service fb6fa5
   (writeable bool-value)
Packit Service fb6fa5
   (construct-only bool-value))
Packit Service fb6fa5
Packit Service fb6fa5
Ex:
Packit Service fb6fa5
  (object-argument label
Packit Service fb6fa5
     (of-object Label (Gtk))
Packit Service fb6fa5
     (type GTK_TYPE_STRING)
Packit Service fb6fa5
     (readable #t)
Packit Service fb6fa5
     (writeable #t))
Packit Service fb6fa5
Packit Service fb6fa5
=== 
Packit Service fb6fa5
(signal signal-name
Packit Service fb6fa5
  (run-action bool-value)
Packit Service fb6fa5
  (run-first bool-value)
Packit Service fb6fa5
  (run-last bool-value)
Packit Service fb6fa5
  (of-object object-we-are-a-signal-of optional-objects-module)
Packit Service fb6fa5
  ;; return value and parameters as for a function, omitting the object
Packit Service fb6fa5
  ;; and user data parameters
Packit Service fb6fa5
Packit Service fb6fa5
  ;; what other properties matter for a signal?
Packit Service fb6fa5
)
Packit Service fb6fa5
Packit Service fb6fa5
Ex:
Packit Service fb6fa5
  (signal select_row
Packit Service fb6fa5
     (of-object CList (Gtk))
Packit Service fb6fa5
     (run-first #t)
Packit Service fb6fa5
     ;; return type defaults to void
Packit Service fb6fa5
     (parameter in (type-and-name gint row))
Packit Service fb6fa5
     (parameter in (type-and-name gint column))
Packit Service fb6fa5
     (parameter in (type-and-name GdkEvent* event)))
Packit Service fb6fa5
Packit Service fb6fa5
=== 
Packit Service fb6fa5
(enum enum-name
Packit Service fb6fa5
  (in-module modname)
Packit Service fb6fa5
  (c-name name-in-c)
Packit Service fb6fa5
  (value (nick value-name-noprefixes-hyphen-lowercase) (c-name value-c-name)))
Packit Service fb6fa5
Packit Service fb6fa5
Ex:
Packit Service fb6fa5
Packit Service fb6fa5
  (enum DirectionType
Packit Service fb6fa5
    (in-module Gtk)
Packit Service fb6fa5
    (c-name GtkDirectionType)
Packit Service fb6fa5
    (value (nick tab-forward) (c-name GTK_DIR_TAB_FORWARD))
Packit Service fb6fa5
    (value (nick tab-backward) (c-name GTK_DIR_TAB_BACKWARD))
Packit Service fb6fa5
    (value (nick up) (c-name GTK_DIR_UP))
Packit Service fb6fa5
    (value (nick down) (c-name GTK_DIR_DOWN))
Packit Service fb6fa5
    (value (nick left) (c-name GTK_DIR_LEFT))
Packit Service fb6fa5
    (value (nick right) (c-name GTK_DIR_RIGHT)))
Packit Service fb6fa5
Packit Service fb6fa5
  (enum Pos
Packit Service fb6fa5
    (in-module (Gtk CTree))
Packit Service fb6fa5
    (c-name GtkCTreePos)
Packit Service fb6fa5
    (value (nick before) (c-name GTK_CTREE_POS_BEFORE))
Packit Service fb6fa5
    (value (nick as-child) (c-name GTK_CTREE_POS_AS_CHILD))
Packit Service fb6fa5
    (value (nick after) (c-name GTK_CTREE_POS_AFTER)))
Packit Service fb6fa5
Packit Service fb6fa5
===
Packit Service fb6fa5
(flags) is just like enum, but some bindings may wrap enums and flags differently.
Packit Service fb6fa5
    
Packit Service fb6fa5
===
Packit Service fb6fa5
Packit Service fb6fa5
(boxed boxed-name
Packit Service fb6fa5
  (in-module modname)
Packit Service fb6fa5
  (c-name c-name)
Packit Service fb6fa5
  (ref-func func-to-increase-refcount)
Packit Service fb6fa5
  (copy-func func-to-copy)
Packit Service fb6fa5
  (release-func func-to-destroy-or-decrement-refcount)
Packit Service fb6fa5
  (field (type-and-name type-alias-of-struct-field name-of-struct-field) (access access-rule)))
Packit Service fb6fa5
Packit Service fb6fa5
It is never OK to use memcpy() to copy a boxed type, or use
Packit Service fb6fa5
malloc()/free() to alloc/free one.
Packit Service fb6fa5
Packit Service fb6fa5
Ex:
Packit Service fb6fa5
Packit Service fb6fa5
 (boxed Pixmap
Packit Service fb6fa5
   (in-module (Gdk))
Packit Service fb6fa5
   (c-name GdkPixmap)
Packit Service fb6fa5
   (ref-func pixmap_ref)
Packit Service fb6fa5
   (release-func pixmap_unref))
Packit Service fb6fa5
Packit Service fb6fa5
An "object" declaration automatically implies the type definition:
Packit Service fb6fa5
Packit Service fb6fa5
(type
Packit Service fb6fa5
  (alias concat-module-elements-and-boxed-name)
Packit Service fb6fa5
  (in-c-name pointer-to-c-name)
Packit Service fb6fa5
  (out-c-name pointer-to-pointer-to-c-name)
Packit Service fb6fa5
  (inout-c-name pointer-to-c-name))
Packit Service fb6fa5
Packit Service fb6fa5
Ex: 
Packit Service fb6fa5
 (type (alias GdkPixmap) 
Packit Service fb6fa5
       (in-c-name GdkPixmap*) 
Packit Service fb6fa5
       (out-c-name GdkPixmap**) 
Packit Service fb6fa5
       (inout-c-name GdkPixmap*))
Packit Service fb6fa5
Packit Service fb6fa5
Packit Service fb6fa5
===
Packit Service fb6fa5
Packit Service fb6fa5
(struct struct-name
Packit Service fb6fa5
  (in-module modname)
Packit Service fb6fa5
  (c-name c-name)
Packit Service fb6fa5
  (field (type-and-name type-alias-of-struct-field name-of-struct-field) (access access-rule)))
Packit Service fb6fa5
Packit Service fb6fa5
Unlike a boxed type, a struct type can be copied with memcpy() and
Packit Service fb6fa5
allocated on the stack or with g_malloc().
Packit Service fb6fa5
Packit Service fb6fa5
Ex:
Packit Service fb6fa5
 (struct Rectangle
Packit Service fb6fa5
   (in-module (Gdk))
Packit Service fb6fa5
   (c-name GdkRectangle)
Packit Service fb6fa5
   (field (type-and-name gint16 x) (access readwrite))
Packit Service fb6fa5
   (field (type-and-name gint16 y) (access readwrite))
Packit Service fb6fa5
   (field (type-and-name guint16 width) (access readwrite))
Packit Service fb6fa5
   (field (type-and-name guint16 height) (access readwrite)))
Packit Service fb6fa5
Packit Service fb6fa5
Implies GdkRectangle type alias:
Packit Service fb6fa5
Packit Service fb6fa5
 (type (alias GdkRectangle) 
Packit Service fb6fa5
       (in-c-name GdkRectangle*) 
Packit Service fb6fa5
       (out-c-name GdkRectangle*)    ;; note - not the same as boxed types 
Packit Service fb6fa5
       (inout-c-name GdkRectangle*))
Packit Service fb6fa5
Packit Service fb6fa5
===
Packit Service fb6fa5
Packit Service fb6fa5
(user-function name
Packit Service fb6fa5
  (in-module module)
Packit Service fb6fa5
  (c-name c-typedef-name)
Packit Service fb6fa5
  ;; return-type and parameters as for (function)
Packit Service fb6fa5
)
Packit Service fb6fa5
Packit Service fb6fa5
Ex:
Packit Service fb6fa5
Packit Service fb6fa5
 (user-function PrintFunc
Packit Service fb6fa5
    (in-module (Gtk))
Packit Service fb6fa5
    (parameter in (type-and-name gpointer func_data))
Packit Service fb6fa5
    (parameter in (type-and-name gchar* str)))
Packit Service fb6fa5
Packit Service fb6fa5
===
Packit Service fb6fa5
Packit Service fb6fa5
(typedef new-name
Packit Service fb6fa5
  (in-module module)
Packit Service fb6fa5
  (c-name c-full-name)
Packit Service fb6fa5
  (orig-type alias-of-orig-type))
Packit Service fb6fa5
Packit Service fb6fa5
Ex:
Packit Service fb6fa5
Packit Service fb6fa5
 (typedef Type
Packit Service fb6fa5
   (in-module (Gtk))
Packit Service fb6fa5
   (c-name GtkType)
Packit Service fb6fa5
   (orig-type guint))
Packit Service fb6fa5
Packit Service fb6fa5
Packit Service fb6fa5
Packit Service fb6fa5
Packit Service fb6fa5
  
Packit Service fb6fa5
   
Packit Service fb6fa5