Commit abc5cbbe authored by Tim Janik's avatar Tim Janik Committed by Tim Janik
Browse files

made hook ids a gulong.

Sun Apr 29 00:37:34 2001  Tim Janik  <timj@gtk.org>

        * ghook.[hc]: made hook ids a gulong.

Sat Apr 28 23:39:42 2001  Tim Janik  <timj@gtk.org>

        * gsignal.[hc]: made signal handler and emission hook ids gulongs.
        (signal_handlers_foreach_matched_R): only invoke callback for handlers
        that are not disconnected (id>0).
        (signal_emit_R): prevent invocation of signal handlers during the
        emission they were connected within.

        * glib-mkenums: publically installed perl-script to parse C code
        enums and generate descriptions thereof.
        * glib-mkenums.1: assorted man page.
parent 655d4676
Sun Apr 29 00:37:34 2001 Tim Janik <timj@gtk.org>
* ghook.[hc]: made hook ids a gulong.
2001-04-20 Dan Winship <danw@ximian.com> 2001-04-20 Dan Winship <danw@ximian.com>
* configure.in: Add a check for the Darwin dynamic linker. Use * configure.in: Add a check for the Darwin dynamic linker. Use
......
Sun Apr 29 00:37:34 2001 Tim Janik <timj@gtk.org>
* ghook.[hc]: made hook ids a gulong.
2001-04-20 Dan Winship <danw@ximian.com> 2001-04-20 Dan Winship <danw@ximian.com>
* configure.in: Add a check for the Darwin dynamic linker. Use * configure.in: Add a check for the Darwin dynamic linker. Use
......
Sun Apr 29 00:37:34 2001 Tim Janik <timj@gtk.org>
* ghook.[hc]: made hook ids a gulong.
2001-04-20 Dan Winship <danw@ximian.com> 2001-04-20 Dan Winship <danw@ximian.com>
* configure.in: Add a check for the Darwin dynamic linker. Use * configure.in: Add a check for the Darwin dynamic linker. Use
......
Sun Apr 29 00:37:34 2001 Tim Janik <timj@gtk.org>
* ghook.[hc]: made hook ids a gulong.
2001-04-20 Dan Winship <danw@ximian.com> 2001-04-20 Dan Winship <danw@ximian.com>
* configure.in: Add a check for the Darwin dynamic linker. Use * configure.in: Add a check for the Darwin dynamic linker. Use
......
Sun Apr 29 00:37:34 2001 Tim Janik <timj@gtk.org>
* ghook.[hc]: made hook ids a gulong.
2001-04-20 Dan Winship <danw@ximian.com> 2001-04-20 Dan Winship <danw@ximian.com>
* configure.in: Add a check for the Darwin dynamic linker. Use * configure.in: Add a check for the Darwin dynamic linker. Use
......
Sun Apr 29 00:37:34 2001 Tim Janik <timj@gtk.org>
* ghook.[hc]: made hook ids a gulong.
2001-04-20 Dan Winship <danw@ximian.com> 2001-04-20 Dan Winship <danw@ximian.com>
* configure.in: Add a check for the Darwin dynamic linker. Use * configure.in: Add a check for the Darwin dynamic linker. Use
......
Sun Apr 29 00:37:34 2001 Tim Janik <timj@gtk.org>
* ghook.[hc]: made hook ids a gulong.
2001-04-20 Dan Winship <danw@ximian.com> 2001-04-20 Dan Winship <danw@ximian.com>
* configure.in: Add a check for the Darwin dynamic linker. Use * configure.in: Add a check for the Darwin dynamic linker. Use
......
Sun Apr 29 00:37:34 2001 Tim Janik <timj@gtk.org>
* ghook.[hc]: made hook ids a gulong.
2001-04-20 Dan Winship <danw@ximian.com> 2001-04-20 Dan Winship <danw@ximian.com>
* configure.in: Add a check for the Darwin dynamic linker. Use * configure.in: Add a check for the Darwin dynamic linker. Use
......
...@@ -66,6 +66,7 @@ only one statement is expected by the compiler. ...@@ -66,6 +66,7 @@ only one statement is expected by the compiler.
Portable way to copy <type>va_list</type> variables. Portable way to copy <type>va_list</type> variables.
</para> </para>
<!-- # Unused Parameters # -->
@ap1: the <type>va_list</type> variable to place a copy of @ap2 in. @ap1: the <type>va_list</type> variable to place a copy of @ap2 in.
@ap2: a <type>va_list</type>. @ap2: a <type>va_list</type>.
......
...@@ -157,7 +157,7 @@ g_hook_destroy_link (GHookList *hook_list, ...@@ -157,7 +157,7 @@ g_hook_destroy_link (GHookList *hook_list,
gboolean gboolean
g_hook_destroy (GHookList *hook_list, g_hook_destroy (GHookList *hook_list,
guint hook_id) gulong hook_id)
{ {
GHook *hook; GHook *hook;
...@@ -451,7 +451,7 @@ g_hook_next_valid (GHookList *hook_list, ...@@ -451,7 +451,7 @@ g_hook_next_valid (GHookList *hook_list,
GHook* GHook*
g_hook_get (GHookList *hook_list, g_hook_get (GHookList *hook_list,
guint hook_id) gulong hook_id)
{ {
GHook *hook; GHook *hook;
......
...@@ -60,7 +60,7 @@ typedef enum ...@@ -60,7 +60,7 @@ typedef enum
/* --- structures --- */ /* --- structures --- */
struct _GHookList struct _GHookList
{ {
guint seq_id; gulong seq_id;
guint hook_size : 16; guint hook_size : 16;
guint is_setup : 1; guint is_setup : 1;
GHook *hooks; GHook *hooks;
...@@ -73,7 +73,7 @@ struct _GHook ...@@ -73,7 +73,7 @@ struct _GHook
GHook *next; GHook *next;
GHook *prev; GHook *prev;
guint ref_count; guint ref_count;
guint hook_id; gulong hook_id;
guint flags; guint flags;
gpointer func; gpointer func;
GDestroyNotify destroy; GDestroyNotify destroy;
...@@ -109,7 +109,7 @@ void g_hook_ref (GHookList *hook_list, ...@@ -109,7 +109,7 @@ void g_hook_ref (GHookList *hook_list,
void g_hook_unref (GHookList *hook_list, void g_hook_unref (GHookList *hook_list,
GHook *hook); GHook *hook);
gboolean g_hook_destroy (GHookList *hook_list, gboolean g_hook_destroy (GHookList *hook_list,
guint hook_id); gulong hook_id);
void g_hook_destroy_link (GHookList *hook_list, void g_hook_destroy_link (GHookList *hook_list,
GHook *hook); GHook *hook);
void g_hook_prepend (GHookList *hook_list, void g_hook_prepend (GHookList *hook_list,
...@@ -121,7 +121,7 @@ void g_hook_insert_sorted (GHookList *hook_list, ...@@ -121,7 +121,7 @@ void g_hook_insert_sorted (GHookList *hook_list,
GHook *hook, GHook *hook,
GHookCompareFunc func); GHookCompareFunc func);
GHook* g_hook_get (GHookList *hook_list, GHook* g_hook_get (GHookList *hook_list,
guint hook_id); gulong hook_id);
GHook* g_hook_find (GHookList *hook_list, GHook* g_hook_find (GHookList *hook_list,
gboolean need_valids, gboolean need_valids,
GHookFindFunc func, GHookFindFunc func,
......
...@@ -157,7 +157,7 @@ g_hook_destroy_link (GHookList *hook_list, ...@@ -157,7 +157,7 @@ g_hook_destroy_link (GHookList *hook_list,
gboolean gboolean
g_hook_destroy (GHookList *hook_list, g_hook_destroy (GHookList *hook_list,
guint hook_id) gulong hook_id)
{ {
GHook *hook; GHook *hook;
...@@ -451,7 +451,7 @@ g_hook_next_valid (GHookList *hook_list, ...@@ -451,7 +451,7 @@ g_hook_next_valid (GHookList *hook_list,
GHook* GHook*
g_hook_get (GHookList *hook_list, g_hook_get (GHookList *hook_list,
guint hook_id) gulong hook_id)
{ {
GHook *hook; GHook *hook;
......
...@@ -60,7 +60,7 @@ typedef enum ...@@ -60,7 +60,7 @@ typedef enum
/* --- structures --- */ /* --- structures --- */
struct _GHookList struct _GHookList
{ {
guint seq_id; gulong seq_id;
guint hook_size : 16; guint hook_size : 16;
guint is_setup : 1; guint is_setup : 1;
GHook *hooks; GHook *hooks;
...@@ -73,7 +73,7 @@ struct _GHook ...@@ -73,7 +73,7 @@ struct _GHook
GHook *next; GHook *next;
GHook *prev; GHook *prev;
guint ref_count; guint ref_count;
guint hook_id; gulong hook_id;
guint flags; guint flags;
gpointer func; gpointer func;
GDestroyNotify destroy; GDestroyNotify destroy;
...@@ -109,7 +109,7 @@ void g_hook_ref (GHookList *hook_list, ...@@ -109,7 +109,7 @@ void g_hook_ref (GHookList *hook_list,
void g_hook_unref (GHookList *hook_list, void g_hook_unref (GHookList *hook_list,
GHook *hook); GHook *hook);
gboolean g_hook_destroy (GHookList *hook_list, gboolean g_hook_destroy (GHookList *hook_list,
guint hook_id); gulong hook_id);
void g_hook_destroy_link (GHookList *hook_list, void g_hook_destroy_link (GHookList *hook_list,
GHook *hook); GHook *hook);
void g_hook_prepend (GHookList *hook_list, void g_hook_prepend (GHookList *hook_list,
...@@ -121,7 +121,7 @@ void g_hook_insert_sorted (GHookList *hook_list, ...@@ -121,7 +121,7 @@ void g_hook_insert_sorted (GHookList *hook_list,
GHook *hook, GHook *hook,
GHookCompareFunc func); GHookCompareFunc func);
GHook* g_hook_get (GHookList *hook_list, GHook* g_hook_get (GHookList *hook_list,
guint hook_id); gulong hook_id);
GHook* g_hook_find (GHookList *hook_list, GHook* g_hook_find (GHookList *hook_list,
gboolean need_valids, gboolean need_valids,
GHookFindFunc func, GHookFindFunc func,
......
Sat Apr 28 23:39:42 2001 Tim Janik <timj@gtk.org>
* gsignal.[hc]: made signal handler and emission hook ids gulongs.
(signal_handlers_foreach_matched_R): only invoke callback for handlers
that are not disconnected (id>0).
(signal_emit_R): prevent invocation of signal handlers during the
emission they were connected within.
* glib-mkenums: publically installed perl-script to parse C code
enums and generate descriptions thereof.
* glib-mkenums.1: assorted man page.
2001-04-19 Havoc Pennington <hp@redhat.com> 2001-04-19 Havoc Pennington <hp@redhat.com>
* gobject.c (g_object_get_valist): We were returning junk memory * gobject.c (g_object_get_valist): We were returning junk memory
......
...@@ -155,10 +155,12 @@ libgobject_1_3_la_SOURCES = $(gruntime_target_sources) ...@@ -155,10 +155,12 @@ libgobject_1_3_la_SOURCES = $(gruntime_target_sources)
# #
# programs to compile and install # programs to compile and install
# #
bin_PROGRAMS = gobject-query glib-genmarshal testgruntime bin_PROGRAMS = gobject-query glib-genmarshal glib-mkenums
noinst_PROGRAMS = testgruntime
# source files # source files
gobject_query_SOURCES = gobject-query.c gobject_query_SOURCES = gobject-query.c
glib_genmarshal_SOURCES = glib-genmarshal.c glib_genmarshal_SOURCES = glib-genmarshal.c
glib_mkenums_SOURCES = glib-mkenums
testgruntime_SOURCES = testgruntime.c testgruntime_SOURCES = testgruntime.c
# link programs against libgobject # link programs against libgobject
progs_LDADD = libgobject-1.3.la $(libglib) progs_LDADD = libgobject-1.3.la $(libglib)
...@@ -169,7 +171,7 @@ testgruntime_LDADD = $(progs_LDADD) ...@@ -169,7 +171,7 @@ testgruntime_LDADD = $(progs_LDADD)
# #
# manual pages to install # manual pages to install
# #
man_MANS = glib-genmarshal.1 man_MANS = glib-genmarshal.1 glib-mkenums.1
# #
# auxillary files # auxillary files
...@@ -179,7 +181,8 @@ EXTRA_DIST += \ ...@@ -179,7 +181,8 @@ EXTRA_DIST += \
makefile.msc.in \ makefile.msc.in \
gobject.def \ gobject.def \
gobject.rc.in \ gobject.rc.in \
glib-genmarshal.1 glib-genmarshal.1 \
glib-mkenums.1
BUILT_EXTRA_DIST = \ BUILT_EXTRA_DIST = \
makefile.mingw \ makefile.mingw \
......
...@@ -190,7 +190,7 @@ g_closure_set_marshal (cc_baz, g_cclosure_marshal_FLOAT__BOOLEAN_UCHAR); ...@@ -190,7 +190,7 @@ g_closure_set_marshal (cc_baz, g_cclosure_marshal_FLOAT__BOOLEAN_UCHAR);
.SH SEE ALSO .SH SEE ALSO
\fB \fB
glib-config(1) glib-mkenums(1)
\fP \fP
.SH BUGS .SH BUGS
......
#!/usr/bin/perl -w
# glib-mkenums.pl
# Information about the current enumeration
my $flags; # Is enumeration a bitmask?
my $seenbitshift; # Have we seen bitshift operators?
my $enum_prefix; # Prefix for this enumeration
my $enumname; # Name for this enumeration
my $enumshort; # $enumname without prefix
my $enumindex = 0; # Global enum counter
my $firstenum = 1; # Is this the first enumeration per file?
my @entries; # [ $name, $val ] for each entry
sub parse_trigraph {
my $opts = shift;
my @opts;
for $opt (split /\s*,\s*/, $opts) {
$opt =~ s/^\s*//;
$opt =~ s/\s*$//;
my ($key,$val) = $opt =~ /(\w+)(?:=(.+))?/;
defined $val or $val = 1;
push @opts, $key, $val;
}
@opts;
}
sub parse_entries {
my $file = shift;
my $file_name = shift;
while (<$file>) {
# read lines until comment end is matched
while (m@/\*([^*]|\*[^/*])*\**$@x) {
my $new;
defined ($new = <>) || die "Unmatched comment in $ARGV";
$_ .= $new;
}
# strip comments w/o options
s@/\*[^<]([^*]|\*[^/*])*\**\*/@@gx;
# strip newlines
s/\n//;
# skip empty lines
next if m@^\s*$@;
# print STDERR "xxx $_\n";
# Handle include files
if (/^\#include\s*<([^>]*)>/ ) {
my $file= "../$1";
open NEWFILE, $file or die "Cannot open include file $file: $!\n";
# read lines until comment end is matched
while (m@/\*([^*]|\*[^/*])*\**$@x) {
my $new;
defined ($new = <>) || die "Unmatched comment in $file_name";
$_ .= $new;
}
# strip comments w/o options
s@/\*[^<]([^*]|\*[^/*])*\**\*/@@gx;
if (parse_entries (\*NEWFILE, $NEWFILE)) {
return 1;
} else {
next;
}
}
if (/^\s*\}\s*(\w+)/) {
$enumname = $1;
$enumindex++;
return 1;
}
if (m@^\s*
(\w+)\s* # name
(?:=( # value
(?:[^,/]|/(?!\*))*
))?,?\s*
(?:/\*< # options
(([^*]|\*(?!/))*)
>\s*\*/)?,?
\s*$
@x) {
my ($name, $value, $options) = ($1,$2,$3);
# print STDERR "xxx \"$name\" \"$value\" \"$otions\"\n";
if (!defined $flags && defined $value && $value =~ /<</) {
$seenbitshift = 1;
}
if (defined $options) {
my %options = parse_trigraph($options);
if (!defined $options{skip}) {
push @entries, [ $name, $options{nick} ];
}
} else {
push @entries, [ $name ];
}
} elsif (m@^\s*\#@) {
# ignore preprocessor directives
} else {
print STDERR "$0: $file_name:$.: Failed to parse `$_'\n";
}
}
return 0;
}
sub version {
print STDERR "glib-mkenums version glib-2.0\n"; # FIXME: autogen version?
print STDERR "glib-mkenums comes with ABSOLUTELY NO WARRANTY.\n";
print STDERR "You may redistribute copies of glib-mkenums under the terms of\n";
print STDERR "the GNU General Public License which can be found in the\n";
print STDERR "GLib source package. Sources, examples and contact\n";
print STDERR "information are available at http://www.gtk.org\n";
exit 0;
}
sub usage {
print STDERR "Usage: glib-mkenums [options] [files...]\n";
print STDERR " --fhead <text> output file header\n";
print STDERR " --fprod <text> per input file production\n";
print STDERR " --ftail <text> output file trailer\n";
print STDERR " --eprod <text> per enum text (produced prior to value itarations)\n";
print STDERR " --vhead <text> value header, produced before iterating over enum values\n";
print STDERR " --vprod <text> value text, produced for each enum value\n";
print STDERR " --vtail <text> value tail, produced after iterating over enum values\n";
print STDERR " --comments <text> comment structure\n";
print STDERR " -h, --help show this help message\n";
print STDERR " -v, --version print version informations\n";
print STDERR "Production text substitutions:\n";
print STDERR " \@EnumName\@ PrefixTheXEnum\n";
print STDERR " \@enum_name\@ prefix_the_xenum\n";
print STDERR " \@ENUMNAME\@ PREFIX_THE_XENUM\n";
print STDERR " \@ENUMSHORT\@ THE_XENUM\n";
print STDERR " \@VALUENAME\@ PREFIX_THE_XVALUE\n";
print STDERR " \@valuenick\@ the-xvalue\n";
print STDERR " \@type\@ either enum or flags\n";
print STDERR " \@Type\@ either Enum or Flags\n";
print STDERR " \@TYPE\@ either ENUM or FLAGS\n";
print STDERR " \@filename\@ name of current input file\n";
exit 0;
}
# production variables:
my $fhead = ""; # output file header
my $fprod = ""; # per input file production
my $ftail = ""; # output file trailer
my $eprod = ""; # per enum text (produced prior to value itarations)
my $vhead = ""; # value header, produced before iterating over enum values
my $vprod = ""; # value text, produced for each enum value
my $vtail = ""; # value tail, produced after iterating over enum values
# other options
my $comment_tmpl = "/* \@comment\@ */";
if (!defined $ARGV[0]) {
usage;
}
while ($_ = $ARGV[0], /^-/) {
shift;
last if /^--$/;
if (/^--fhead$/) { $fhead = $fhead . shift }
elsif (/^--fprod$/) { $fprod = $fprod . shift }
elsif (/^--ftail$/) { $ftail = $ftail . shift }
elsif (/^--eprod$/) { $eprod = $eprod . shift }
elsif (/^--vhead$/) { $vhead = $vhead . shift }
elsif (/^--vprod$/) { $vprod = $vprod . shift }
elsif (/^--vtail$/) { $vtail = $vtail . shift }
elsif (/^--comments$/) { $comment_tmpl = shift }
elsif (/^--help$/ || /^-h$/) { usage; }
elsif (/^--version$/ || /^-v$/) { version; }
else { usage; }
}
# put auto-generation comment
{
my $comment = $comment_tmpl;
$comment =~ s/\@comment\@/Generated data (by glib-mkenums)/;
print "\n" . $comment . "\n\n";
}
if (length($fhead)) {
my $prod = $fhead;
$prod =~ s/\@filename\@/$ARGV/g;
$prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
$prod =~ s/\\v/\v/g; $prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
print "$prod\n";
}
while (<>) {
if (eof) {
close (ARGV); # reset line numbering
$firstenum = 1; # Flag to print filename at next enum
}
# read lines until comment end is matched
while (m@/\*([^*]|\*[^/*])*\**$@x) {
my $new;
defined ($new = <>) || die "Unmatched comment in $ARGV";
$_ .= $new;
}
# strip comments w/o options
s@/\*[^<]([^*]|\*[^/*])*\**\*/@@gx;
# print STDERR "xxx $_\n";
if (m@^\s*typedef\s+enum\s*
({)?\s*
(?:/\*<
(([^*]|\*(?!/))*)
>\s*\*/)?
@x) {
if (defined $2) {
my %options = parse_trigraph ($2);
next if defined $options{skip};
$enum_prefix = $options{prefix};
$flags = $options{flags};
} else {
$enum_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, $ARGV);
# figure out if this was a flags or enums enumeration
if (!defined $flags) {
$flags = $seenbitshift;
}
# Autogenerate a prefix
if (!defined $enum_prefix) {
for (@entries) {
my $nick = $_->[1];
if (!defined $nick) {
my $name = $_->[0];
if (defined $enum_prefix) {
my $tmp = ~ ($name ^ $enum_prefix);
($tmp) = $tmp =~ /(^\xff*)/;
$enum_prefix = $enum_prefix & $tmp;
} else {
$enum_prefix = $name;
}
}
}
if (!defined $enum_prefix) {
$enum_prefix = "";
} else {
# Trim so that it ends in an underscore
$enum_prefix =~ s/_[^_]*$/_/;
}
} else {
# canonicalize user defined prefixes
$enum_prefix = uc($enum_prefix);
$enum_prefix =~ s/-/_/g;
$enum_prefix =~ s/(.*)([^_])$/$1$2_/;
}
for $entry (@entries) {
my ($name,$nick) = @{$entry};