Ditch some long dead perl cruft

This commit is contained in:
Matthias Clasen 2011-07-23 13:42:52 -04:00
parent 07f525368d
commit 2937a875a0
4 changed files with 0 additions and 673 deletions

View File

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

View File

@ -25,7 +25,6 @@ EXTRA_DIST += \
gdk.def \
gdkmarshalers.list \
gdkwindowimpl.h \
makeenums.pl \
makefile.msc \
gdk.symbols \
gdkenumtypes.c.template \

View File

@ -1,279 +0,0 @@
#!/usr/bin/perl -w
# Information about the current enumeration
my $flags; # Is enumeration a bitmask
my $seenbitshift; # Have we seen bitshift operators?
my $prefix; # Prefix for this enumeration
my $enumname; # Name for this enumeration
my $firstenum = 1; # Is this the first enumeration in file?
my @entries; # [ $name, $val ] for each entry
sub parse_options {
my $opts = shift;
my @opts;
for $opt (split /\s*,\s*/, $opts) {
my ($key,$val) = $opt =~ /\s*(\w+)(?:=(\S+))?/;
defined $val or $val = 1;
push @opts, $key, $val;
}
@opts;
}
sub parse_entries {
my $file = shift;
while (<$file>) {
# Read lines until we have no open comments
while (m@/\*
([^*]|\*(?!/))*$
@x) {
my $new;
defined ($new = <$file>) || die "Unmatched comment";
$_ .= $new;
}
# Now strip comments
s@/\*(?!<)
([^*]+|\*(?!/))*
\*/@@gx;
s@\n@ @;
next if m@^\s*$@;
# Handle include files
if (/^\#include\s*<([^>]*)>/ ) {
my $file= "../$1";
open NEWFILE, $file or die "Cannot open include file $file: $!\n";
if (parse_entries (\*NEWFILE)) {
return 1;
} else {
next;
}
}
if (/^\s*\}\s*(\w+)/) {
$enumname = $1;
return 1;
}
if (m@^\s*
(\w+)\s* # name
(?:=( # value
(?:[^,/]|/(?!\*))*
))?,?\s*
(?:/\*< # options
(([^*]|\*(?!/))*)
>\*/)?
\s*$
@x) {
my ($name, $value, $options) = ($1,$2,$3);
if (!defined $flags && defined $value && $value =~ /<</) {
$seenbitshift = 1;
}
if (defined $options) {
my %options = parse_options($options);
if (!defined $options{skip}) {
push @entries, [ $name, $options{nick} ];
}
} else {
push @entries, [ $name ];
}
} else {
print STDERR "Can't understand: $_\n";
}
}
return 0;
}
my $gen_arrays = 0;
my $gen_defs = 0;
my $gen_includes = 0;
my $gen_cfile = 0;
# Parse arguments
if (@ARGV) {
if ($ARGV[0] eq "arrays") {
shift @ARGV;
$gen_arrays = 1;
} elsif ($ARGV[0] eq "defs") {
shift @ARGV;
$gen_defs = 1;
} elsif ($ARGV[0] eq "include") {
shift @ARGV;
$gen_includes = 1;
} elsif ($ARGV[0] eq "cfile") {
shift @ARGV;
$gen_cfile = 1;
}
}
if ($gen_defs) {
print ";; generated by makeenums.pl ; -*- scheme -*-\n\n";
} else {
print "/* Generated by makeenums.pl */\n\n";
}
if ($gen_includes) {
print "#ifndef __GDK_ENUM_TYPES_H__\n";
print "#define __GDK_ENUM_TYPES_H__\n";
}
if ($gen_cfile) {
print "#include \"gdk.h\"\n";
}
ENUMERATION:
while (<>) {
if (eof) {
close (ARGV); # reset line numbering
$firstenum = 1; # Flag to print filename at next enum
}
if (m@^\s*typedef\s+enum\s*
({)?\s*
(?:/\*<
(([^*]|\*(?!/))*)
>\*/)?
@x) {
print "\n";
if (defined $2) {
my %options = parse_options($2);
$prefix = $options{prefix};
$flags = $options{flags};
} else {
$prefix = undef;
$flags = undef;
}
# Didn't have trailing '{' look on next lines
if (!defined $1) {
while (<>) {
if (s/^\s*\{//) {
last;
}
}
}
$seenbitshift = 0;
@entries = ();
# Now parse the entries
parse_entries (\*ARGV);
# figure out if this was a flags or enums enumeration
if (!defined $flags) {
$flags = $seenbitshift;
}
# Autogenerate a prefix
if (!defined $prefix) {
for (@entries) {
my $name = $_->[0];
if (defined $prefix) {
my $tmp = ~ ($name ^ $prefix);
($tmp) = $tmp =~ /(^\xff*)/;
$prefix = $prefix & $tmp;
} else {
$prefix = $name;
}
}
# Trim so that it ends in an underscore
$prefix =~ s/_[^_]*$/_/;
}
for $entry (@entries) {
my ($name,$nick) = @{$entry};
if (!defined $nick) {
($nick = $name) =~ s/^$prefix//;
$nick =~ tr/_/-/;
$nick = lc($nick);
@{$entry} = ($name, $nick);
}
}
# Spit out the output
my $valuename = $enumname;
$valuename =~ s/([^A-Z])([A-Z])/$1_$2/g;
$valuename =~ s/([A-Z][A-Z])([A-Z][0-9a-z])/$1_$2/g;
$valuename = lc($valuename);
my $typemacro = $enumname;
$typemacro =~ s/([^A-Z])([A-Z])/$1_$2/g;
$typemacro =~ s/([A-Z][A-Z])([A-Z][0-9a-z])/$1_$2/g;
$typemacro = uc($valuename);
$typemacro =~ s/GDK_/GDK_TYPE_/g;
if ($gen_defs) {
if ($firstenum) {
print qq(\n; enumerations from "$ARGV"\n);
$firstenum = 0;
}
print "\n(define-".($flags ? "flags" : "enum")." $enumname";
for (@entries) {
my ($name,$nick) = @{$_};
print "\n ($nick $name)";
}
print ")\n";
} elsif ($gen_arrays) {
print "static const GtkEnumValue _${valuename}_values[] = {\n";
for (@entries) {
my ($name,$nick) = @{$_};
print qq( { $name, "$name", "$nick" },\n);
}
print " { 0, NULL, NULL }\n";
print "};\n";
} elsif ($gen_includes) {
print "GType ${valuename}_get_type (void);\n";
print "#define ${typemacro} ${valuename}_get_type ()\n";
} elsif ($gen_cfile) {
print (<<EOF);
GType
${valuename}_get_type (void)
{
static GType etype = 0;
if (etype == 0)
{
EOF
if ($flags) {
print " static const GFlagsValue values[] = {\n";
} else {
print " static const GEnumValue values[] = {\n";
}
for (@entries) {
my ($name,$nick) = @{$_};
print qq( { $name, "$name", "$nick" },\n);
}
print " { 0, NULL, NULL }\n";
print " };\n";
if ($flags) {
print " etype = g_flags_register_static (\"$enumname\", values);\n";
} else {
print " etype = g_enum_register_static (\"$enumname\", values);\n";
}
print (<<EOF);
}
return etype;
}
EOF
}
print "\n";
}
}
if ($gen_includes) {
print "#endif /* __GDK_ENUMS_H__ */\n";
}

View File

@ -1,216 +0,0 @@
#!/usr/bin/perl -w
# Information about the current enumeration
my $flags; # Is enumeration a bitmask
my $seenbitshift; # Have we seen bitshift operators?
my $prefix; # Prefix for this enumeration
my $enumname; # Name for this enumeration
my $firstenum = 1; # Is this the first enumeration in file?
my @entries; # [ $name, $val ] for each entry
sub parse_options {
my $opts = shift;
my @opts;
for $opt (split /\s*,\s*/, $opts) {
my ($key,$val) = $opt =~ /\s*(\w+)(?:=(\S+))?/;
defined $val or $val = 1;
push @opts, $key, $val;
}
@opts;
}
sub parse_entries {
my $file = shift;
while (<$file>) {
# Read lines until we have no open comments
while (m@/\*
([^*]|\*(?!/))*$
@x) {
my $new;
defined ($new = <$file>) || die "Unmatched comment";
$_ .= $new;
}
# Now strip comments
s@/\*(?!<)
([^*]+|\*(?!/))*
\*/@@gx;
s@\n@ @;
next if m@^\s*$@;
# Handle include files
if (/^\#include\s*<([^>]*)>/ ) {
my $file= "../$1";
open NEWFILE, $file or die "Cannot open include file $file: $!\n";
if (parse_entries (\*NEWFILE)) {
return 1;
} else {
next;
}
}
if (/^\s*\}\s*(\w+)/) {
$enumname = $1;
return 1;
}
if (m@^\s*
(\w+)\s* # name
(?:=( # value
(?:[^,/]|/(?!\*))*
))?,?\s*
(?:/\*< # options
(([^*]|\*(?!/))*)
>\*/)?
\s*$
@x) {
my ($name, $value, $options) = ($1,$2,$3);
if (!defined $flags && defined $value && $value =~ /<</) {
$seenbitshift = 1;
}
if (defined $options) {
my %options = parse_options($options);
if (!defined $options{skip}) {
push @entries, [ $name, $options{nick} ];
}
} else {
push @entries, [ $name ];
}
} else {
print STDERR "Can't understand: $_\n";
}
}
return 0;
}
my $gen_arrays = 0;
my $gen_defs = 0;
# Parse arguments
if (@ARGV) {
if ($ARGV[0] eq "arrays") {
shift @ARGV;
$gen_arrays = 1;
} elsif ($ARGV[0] eq "defs") {
shift @ARGV;
$gen_defs = 1;
} else {
$gen_defs = 1;
}
}
if ($gen_defs) {
print ";; generated by makeenums.pl ; -*- scheme -*-\n\n";
} else {
print "/* Generated by makeenums.pl */\n\n";
}
ENUMERATION:
while (<>) {
if (eof) {
close (ARGV); # reset line numbering
$firstenum = 1; # Flag to print filename at next enum
}
if (m@^\s*typedef\s+enum\s*
({)?\s*
(?:/\*<
(([^*]|\*(?!/))*)
>\*/)?
@x) {
if (defined $2) {
my %options = parse_options($2);
$prefix = $options{prefix};
$flags = $options{flags};
} else {
$prefix = undef;
$flags = undef;
}
# Didn't have trailing '{' look on next lines
if (!defined $1) {
while (<>) {
if (s/^\s*\{//) {
last;
}
}
}
$seenbitshift = 0;
@entries = ();
# Now parse the entries
parse_entries (\*ARGV);
# figure out if this was a flags or enums enumeration
if (!defined $flags) {
$flags = $seenbitshift;
}
# Autogenerate a prefix
if (!defined $prefix) {
for (@entries) {
my $name = $_->[0];
if (defined $prefix) {
my $tmp = ~ ($name ^ $prefix);
($tmp) = $tmp =~ /(^\xff*)/;
$prefix = $prefix & $tmp;
} else {
$prefix = $name;
}
}
# Trim so that it ends in an underscore
$prefix =~ s/_[^_]*$/_/;
}
for $entry (@entries) {
my ($name,$nick) = @{$entry};
if (!defined $nick) {
($nick = $name) =~ s/^$prefix//;
$nick =~ tr/_/-/;
$nick = lc($nick);
@{$entry} = ($name, $nick);
}
}
# Spit out the output
if ($gen_defs) {
if ($firstenum) {
print qq(\n; enumerations from "$ARGV"\n);
$firstenum = 0;
}
print "\n(define-".($flags ? "flags" : "enum")." $enumname";
for (@entries) {
my ($name,$nick) = @{$_};
print "\n ($nick $name)";
}
print ")\n";
} else {
my $valuename = $enumname;
$valuename =~ s/([^A-Z])([A-Z])/$1_$2/g;
$valuename =~ s/([A-Z][A-Z])([A-Z][0-9a-z])/$1_$2/g;
$valuename = lc($valuename);
print "static const GtkEnumValue _${valuename}_values[] = {\n";
for (@entries) {
my ($name,$nick) = @{$_};
print qq( { $name, "$name", "$nick" },\n);
}
print " { 0, NULL, NULL }\n";
print "};\n";
}
}
}