Blame docs/generation.txt

Packit 98cdb6
Overview:
Packit 98cdb6
========
Packit 98cdb6
Packit 98cdb6
This file describes the way that autogeneration
Packit 98cdb6
works within the GTK+ source code.
Packit 98cdb6
Packit 98cdb6
The following files in the gdk/ subdirectory
Packit 98cdb6
are autogenerated:
Packit 98cdb6
Packit 98cdb6
  gdkkeysyms.h
Packit 98cdb6
  gdkcursors.h 
Packit 98cdb6
Packit 98cdb6
The following files in the gtk/ subdirectory 
Packit 98cdb6
are autogenerated:
Packit 98cdb6
Packit 98cdb6
 gtk.defs
Packit 98cdb6
   Description of GTK+ types (and some functions) in a lisp-style
Packit 98cdb6
   format.
Packit 98cdb6
 gtktypebuiltins.h
Packit 98cdb6
   Header file including declarations for internal types  
Packit 98cdb6
 gtktypebuiltins_vars.c
Packit 98cdb6
   Variables for type values for internal types.
Packit 98cdb6
 gtktypebuiltins_ids.c
Packit 98cdb6
   Arrays holding information about each internal type.
Packit 98cdb6
 gtktypebuiltins_evals.c
Packit 98cdb6
   Arrays holding mapping between enumeration values
Packit 98cdb6
   and strings.
Packit 98cdb6
Packit 98cdb6
 gtkmarshal.c
Packit 98cdb6
 gtkmarshal.h
Packit 98cdb6
   Autogenerated signal marshallers
Packit 98cdb6
Packit 98cdb6
GDK
Packit 98cdb6
===
Packit 98cdb6
Packit 98cdb6
gdkkeysyms.h and gdkcursors.h are generated from
Packit 98cdb6
the corresponding header files
Packit 98cdb6
Packit 98cdb6
  X11/cursorfont.h
Packit 98cdb6
  X11/keysymdef.h
Packit 98cdb6
Packit 98cdb6
by some simple sed scripts. These are not actually
Packit 98cdb6
run automatically because we want all the keysyms
Packit 98cdb6
even on systems with a limited set.
Packit 98cdb6
So the Gdk rule to generate both files (X-derived-headers)
Packit 98cdb6
only needs to be rerun for every new release of the X Window
Packit 98cdb6
System.
Packit 98cdb6
Packit 98cdb6
GTK+ - type definitions
Packit 98cdb6
=======================
Packit 98cdb6
Packit 98cdb6
The type definitions are generated from several sources:
Packit 98cdb6
Packit 98cdb6
 gtk-boxed.defs - definitions for boxed types
Packit 98cdb6
 GTK+ header files
Packit 98cdb6
 GDK header files
Packit 98cdb6
Packit 98cdb6
The makeenums.pl script does a heuristic parse of 
Packit 98cdb6
the header files and extracts all enumerations declarations.
Packit 98cdb6
It also recognizes a number of pseudo-comments in the
Packit 98cdb6
header files:
Packit 98cdb6
Packit 98cdb6
Two of these apply to individual enumeration values:
Packit 98cdb6
Packit 98cdb6
  /*< skip >*/
Packit 98cdb6
Packit 98cdb6
 This enumeration value should be skipped.
Packit 98cdb6
  
Packit 98cdb6
  /*< nick=NICK >*/
Packit 98cdb6
Packit 98cdb6
 The nickname for this value should NICK instead of the
Packit 98cdb6
 normally guessed value. For instance:
Packit 98cdb6
Packit 98cdb6
  typedef enum {
Packit 98cdb6
    GTK_TARGET_SAME_APP = 1 << 0,    /*< nick=same-app >*/
Packit 98cdb6
    GTK_TARGET_SAME_WIDGET = 1 << 1  /*< nick=same-widget >*/
Packit 98cdb6
  } GtkTargetFlags;
Packit 98cdb6
Packit 98cdb6
 makes the nicks "same-app" and "same-widget", instead of
Packit 98cdb6
 "app" and "widget" that would normally be used.
Packit 98cdb6
Packit 98cdb6
The other two apply to entire enumeration declarations.
Packit 98cdb6
 
Packit 98cdb6
  /*< prefix=PREFIX >*/
Packit 98cdb6
Packit 98cdb6
  Specifies the prefix to be removed from the enumeration
Packit 98cdb6
  values to generate nicknames.
Packit 98cdb6
Packit 98cdb6
  /*< flags >*/
Packit 98cdb6
Packit 98cdb6
 Specifies that this enumeration is used as a bitfield.
Packit 98cdb6
 (makenums.pl normally guesses this from the presence of values
Packit 98cdb6
  with << operators). For instance:
Packit 98cdb6
Packit 98cdb6
  typedef enum                    /*< flags >*/
Packit 98cdb6
  {
Packit 98cdb6
    GDK_IM_PREEDIT_AREA      = 0x0001, 
Packit 98cdb6
    GDK_IM_PREEDIT_CALLBACKS = 0x0002, 
Packit 98cdb6
    [ ... ]
Packit 98cdb6
 } GdkIMStyle;
Packit 98cdb6
Packit 98cdb6
makeenums.pl can be run into two modes:
Packit 98cdb6
Packit 98cdb6
 1) Generate the gtktypebuiltins_eval.c file (this
Packit 98cdb6
    contains arrays holding the mapping of 
Packit 98cdb6
    string <=> enumeration value)
Packit 98cdb6
Packit 98cdb6
 2) Generate the enumeration portion of gtk.defs.
Packit 98cdb6
Packit 98cdb6
The enumeration portion is added to the boxed type 
Packit 98cdb6
declarations in gtk-boxed.defs to create gtk.defs.
Packit 98cdb6
Packit 98cdb6
The makeetypes.awk program takes the gtk.defs file, and
Packit 98cdb6
from that generates various files depending on the
Packit 98cdb6
third parameter passed to it:
Packit 98cdb6
Packit 98cdb6
 macros: gtktypebuiltins.h
Packit 98cdb6
 variables: gtktypebuiltins_vars.c
Packit 98cdb6
 entries: gtktypebuiltins_ids.c
Packit 98cdb6
Packit 98cdb6
GTK+ - marshallers
Packit 98cdb6
==================
Packit 98cdb6
Packit 98cdb6
The files gtkmarshal.c and gtkmarshal.h include declarations
Packit 98cdb6
and definitions for the marshallers needed inside of
Packit 98cdb6
GTK+. The marshallers to be generated are listed in
Packit 98cdb6
the file gtkmashal.list, which is processed
Packit 98cdb6
by genmarshal.pl.
Packit 98cdb6
Packit 98cdb6
The format of this file is a list of lines:
Packit 98cdb6
Packit 98cdb6
  <retval-type>:<arg1-type>,<arg2-type>,<arg3-type>
Packit 98cdb6
 
Packit 98cdb6
e.g.:
Packit 98cdb6
Packit 98cdb6
  BOOL:POINTER,STRING,STRING,POINTER
Packit 98cdb6
Packit 98cdb6
A marshaller is generated for each line in the file.
Packit 98cdb6
The possible types are:
Packit 98cdb6
Packit 98cdb6
 NONE
Packit 98cdb6
 BOOL
Packit 98cdb6
 CHAR
Packit 98cdb6
 INT
Packit 98cdb6
 UINT
Packit 98cdb6
 LONG
Packit 98cdb6
 ULONG
Packit 98cdb6
 FLOAT
Packit 98cdb6
 DOUBLE
Packit 98cdb6
 STRING
Packit 98cdb6
 ENUM
Packit 98cdb6
 FLAGS
Packit 98cdb6
 BOXED
Packit 98cdb6
 POINTER
Packit 98cdb6
 OBJECT
Packit 98cdb6
 FOREIGN    (gpointer data, GtkDestroyNotify notify)
Packit 98cdb6
 C_CALLBACK (GtkFunction func, gpointer func_data)
Packit 98cdb6
 SIGNAL     (GtkSignalFunc f, gpointer data)
Packit 98cdb6
 ARGS       (gint n_args, GtkArg *args)
Packit 98cdb6
 CALLBACK   (GtkCallBackMarshal marshall,
Packit 98cdb6
             gpointer data,
Packit 98cdb6
	     GtkDestroyNotify Notify)
Packit 98cdb6
Packit 98cdb6
Some of these types map to multiple return values - these
Packit 98cdb6
are marked above with the return types in parentheses.
Packit 98cdb6
Packit 98cdb6
NOTES
Packit 98cdb6
=====
Packit 98cdb6
Packit 98cdb6
When autogenerating GTK+ files, the autogenerated
Packit 98cdb6
files are often rebuild resulting in the same result.
Packit 98cdb6
Packit 98cdb6
To prevent unnecessary rebuilds of the entire directory, some files
Packit 98cdb6
that multiple other source files depend on are not actually written
Packit 98cdb6
to directly.  Instead, an intermediate file is written, which
Packit 98cdb6
is then compared to the old file, and only if it is different
Packit 98cdb6
is it copied into the final location.