Next: , Previous: gnome gw support gobject, Up: Top


13 (gnome gw support defs)

13.1 Overview

This module serves as a way to automatically populate G-Wrap wrapsets using information parsed out of C header files.

First, the C header files are parsed into S-expression API description forms and written into .defs files. These files are typically included in the distribution, and regenerated infrequently. Then, the binding author includes a call to load-defs in their G-Wrap wrapset definition, which loads those API definitions into the wrapset.

The .defs files are usually produced using the API scanner script, h2defs.py, included in the Guile-GNOME source distribution.

Code in this module is only loaded when generating wrapsets; as such, it is not for end users.

As an example, ATK is wrapped with the following code, from atk/gnome/gw/atk-spec.scm:

 (define-module (gnome gw atk-spec)
 #:use-module (oop goops)
 #:use-module (gnome gw support g-wrap)
 #:use-module (gnome gw gobject-spec)
 #:use-module (gnome gw support gobject)
 #:use-module (gnome gw support defs))
 
 (define-class <atk-wrapset> (<gobject-wrapset-base>)
 #:id 'gnome-atk
 #:dependencies '(standard gnome-glib gnome-gobject))
 
 (define-method (global-declarations-cg (self <atk-wrapset>))
 (list
 (next-method)
 "#include <atk/atk.h>\n"
 "#include <atk/atk-enum-types.h>\n"))
 
 (define-method (initialize (ws <atk-wrapset>) initargs)
 (next-method ws (append '(#:module (gnome gw atk)) initargs))
 ;; manually wrap AtkState as a 64 bit uint
 (add-type-alias! ws "AtkState" 'unsigned-int64)
 (load-defs-with-overrides ws "gnome/defs/atk.defs"))
 

The wrapper-specifiction modules are actually installed, along with the .defs files, so that other wrappers which use ATK's types, such as GTK+, can have them available.

A full discussion of the Makefile mechanics of how to generate and compile the C file, or how to interact with the wrapset objects, is probably prone to bitrot here. Your best bet is to poke at Guile-GNOME's source, or especially the source of a module distributed independently of guile-gnome-platform, such as guile-gnome-libwnck.

Further details about the procedural API available for use e.g. within the wrapset's initialize function can be found in the documentation for (gnome gw support gobject), and in G-Wrap's documentation.

13.2 Usage

— Function: load-defs ws file [overrides = #f]

Load G-Wrap type and function information from file into the G-Wrap wrapset ws.

file should be a relative path, which will be searched in the vicinity of Guile's %load-path. include directives in the file will be searched relative to the absolute path of the file.

The following forms are understood: define-enum, define-flags, define-object, define-interface, define-pointer, define-boxed, define-function, define-method, ignore, ignore-glob, and ignore-types.

The optional argument, overrides, specifies the location of an overrides file that will be spliced into the .defs file at the point of an (include overrides) form.

— Function: load-defs-with-overrides ws defs

Equivalent to:

 (load-defs ws defs
 (string-append "gnome/overrides/"
 (basename defs)))

AltStyle によって変換されたページ (->オリジナル) /