2002-01-04 02:02:28 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
#
|
|
|
|
# gapi2xml.pl : Generates an XML representation of GObject based APIs.
|
|
|
|
#
|
|
|
|
# Author: Mike Kestner <mkestner@speakeasy.net>
|
|
|
|
#
|
|
|
|
# <c> 2001 Mike Kestner
|
|
|
|
##############################################################
|
|
|
|
|
|
|
|
$debug=1;
|
|
|
|
|
|
|
|
use XML::LibXML;
|
2002-08-19 Rachel Hestilow <hestilow@ximian.com>
* art/Makefile.in (clean): Change to avoid bugging out on generated/CVS.
* glib/ObjectManager.cs: Added. Used to be auto-generated, but
now it can infer names, and relies on per-namespace ObjectManager
classes to inform it of oddly-named classes.
* generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property.
* generator/*Gen.cs: Honor DoGenerate.
* generator/CodeGenerator.cs: Support including dependency files
which will not be generated.
* generator/ObjectGen.cs: Generate mapping file per-namespace, as one
that calls back to the one in glib. Only generate if the name does
not follow the normal conventions, otherwise, GtkSharp.ObjectManager
can infer the name.
* generator/Parser.cs: Accept 'generate' flag to pass on to the
IGeneratables. Parse a new toplevel element, "symbol", which adds
a type to the SymbolTable (instead of hard-coding it).
* generator/SignalHandler.cs: Do not optimize signal handler creation,
instead creating them in their own namespaces. Do not generate
if the calling Signal told us not to.
* generator/Signal.cs: Do not generate handlers if container's DoGenerate
is false. Adjust to the marshaller name being in a sub-namespace.
* generator/SymbolTable.cs (AddSimpleType, AddManualType): Used
to add simple and manually wrapped types at runtime instead of
compile-time.
(FromNative): Remove hard-coded cases for manually wrapped types, use
a generic case instead.
* api: Added. Move api files and generation targets here.
* source: Added. Move source parsing here.
* generator/makefile: Move actual generation to api/.
* glib/Makefile.in: Remove generated/* target.
* glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff
to GNOME target.
* gnome/CanvasProxy.cs: Update to work with SignalHandlers being
namespace-specific.
* parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc.
* parser/gapi2xml.pl: Use GAPI::Metadata.
* parser/makefile: Install scripts, remove source parse build target.
Rename formatXML to gapi_format_xml.
svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 19:56:18 +00:00
|
|
|
use GAPI::Metadata;
|
2002-01-04 02:02:28 +00:00
|
|
|
|
2002-06-21 20:25:43 +00:00
|
|
|
if (!$ARGV[2]) {
|
|
|
|
die "Usage: gapi_pp.pl <srcdir> | gapi2xml.pl <namespace> <outfile> <libname>\n";
|
2002-01-04 02:02:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$ns = $ARGV[0];
|
2002-06-21 20:25:43 +00:00
|
|
|
$libname = $ARGV[2];
|
2002-06-14 Rachel Hestilow <hestilow@ximian.com>
* glib/GException.cs: Added.
* generator/Ctor.cs, Method.cs: Tag function as unsafe if it throws
an exception. Call parms.HandleException.
* generator/Paramaters.cs: Add property ThrowsException (based
on a trailing GError**). If ThrowsException, mask GError in the
signature, initialize a GError in Initialize, and add new method
HandleException to throw an exception if error != null.
* generator/SymbolTable.cs: Add gdk-pixbuf DLL, and GError type.
* gdk.imaging, gdk.imaging/Makefile.in, gdk.imaging/makefile.win32:
Added.
* configure.in, Makefile, makefile.win32: Build gdk.imaging.
* gtk/Makefile.in, gtk/makefile.win32: Link against gdk.imaging.
* parser/gapi2xml.pl: Support namespace renaming.
* parser/build.pl: Build gdk-pixbuf as gdk.imaging.
svn path=/trunk/gtk-sharp/; revision=5281
2002-06-14 18:27:04 +00:00
|
|
|
|
2002-01-04 02:02:28 +00:00
|
|
|
##############################################################
|
2002-06-21 20:25:43 +00:00
|
|
|
# Check if the filename provided exists. We parse existing files into
|
2002-01-04 02:02:28 +00:00
|
|
|
# a tree and append the namespace to the root node. If the file doesn't
|
|
|
|
# exist, we create a doc tree and root node to work with.
|
|
|
|
##############################################################
|
|
|
|
|
2002-06-21 20:25:43 +00:00
|
|
|
if (-e $ARGV[1]) {
|
2002-01-04 02:02:28 +00:00
|
|
|
#parse existing file and get root node.
|
|
|
|
$doc = XML::LibXML->new->parse_file($ARGV[1]);
|
|
|
|
$root = $doc->getDocumentElement();
|
|
|
|
} else {
|
|
|
|
$doc = XML::LibXML::Document->new();
|
|
|
|
$root = $doc->createElement('api');
|
|
|
|
$doc->setDocumentElement($root);
|
|
|
|
}
|
|
|
|
|
|
|
|
$ns_elem = $doc->createElement('namespace');
|
2002-06-21 20:25:43 +00:00
|
|
|
$ns_elem->setAttribute('name', $ns);
|
|
|
|
$ns_elem->setAttribute('library', $libname);
|
2002-01-04 02:02:28 +00:00
|
|
|
$root->appendChild($ns_elem);
|
|
|
|
|
|
|
|
##############################################################
|
|
|
|
# First we parse the input for typedefs, structs, enums, and class_init funcs
|
|
|
|
# and put them into temporary hashes.
|
|
|
|
##############################################################
|
|
|
|
|
|
|
|
while ($line = <STDIN>) {
|
|
|
|
if ($line =~ /typedef\s+(struct\s+\w+\s+)\*+(\w+);/) {
|
|
|
|
$ptrs{$2} = $1;
|
|
|
|
} elsif ($line =~ /typedef\s+(struct\s+\w+)\s+(\w+);/) {
|
2002-07-19 04:07:50 +00:00
|
|
|
next if ($2 =~ /Private$/);
|
2002-07-30 23:02:12 +00:00
|
|
|
# fixme: siiigh
|
|
|
|
$2 = "GdkDrawable" if ($1 eq "_GdkDrawable");
|
2002-01-04 02:02:28 +00:00
|
|
|
$types{$2} = $1;
|
|
|
|
} elsif ($line =~ /typedef\s+(\w+\s+\**)(\w+);/) {
|
|
|
|
$types{$2} = $1;
|
|
|
|
} elsif ($line =~ /typedef\s+enum/) {
|
|
|
|
$ename = $1;
|
|
|
|
$edef = $line;
|
|
|
|
while ($line = <STDIN>) {
|
|
|
|
$edef .= $line;
|
|
|
|
last if ($line =~ /^}\s*(\w+);/);
|
|
|
|
}
|
|
|
|
$edef =~ s/\n\s*//g;
|
|
|
|
$edef =~ s|/\*.*?\*/||g;
|
|
|
|
$edef =~ /}\s*(\w+);/;
|
|
|
|
$ename = $1;
|
|
|
|
$edefs{$ename} = $edef;
|
2002-01-10 15:01:31 +00:00
|
|
|
} elsif ($line =~ /typedef\s+\w+\s*\**\s*\(\*\s*(\w+)\)\s*\(/) {
|
2002-01-04 02:02:28 +00:00
|
|
|
$fname = $1;
|
|
|
|
$fdef = "";
|
|
|
|
while ($line !~ /;/) {
|
|
|
|
$fdef .= $line;
|
|
|
|
$line = <STDIN>;
|
|
|
|
}
|
|
|
|
$fdef .= $line;
|
|
|
|
$fdef =~ s/\n\s+//g;
|
2002-01-10 15:01:31 +00:00
|
|
|
$fpdefs{$fname} = $fdef;
|
2002-01-04 02:02:28 +00:00
|
|
|
} elsif ($line =~ /struct\s+(\w+)/) {
|
|
|
|
$sname = $1;
|
|
|
|
$sdef = $line;
|
|
|
|
while ($line = <STDIN>) {
|
|
|
|
$sdef .= $line;
|
|
|
|
last if ($line =~ /^}/);
|
|
|
|
}
|
2002-01-10 15:01:31 +00:00
|
|
|
$sdef =~ s!/\*.*?(\*/|\n)!!g;
|
2002-01-04 02:02:28 +00:00
|
|
|
$sdef =~ s/\n\s*//g;
|
|
|
|
$sdefs{$sname} = $sdef;
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
} elsif ($line =~ /^(\w+)_(class|base)_init\b/) {
|
2002-01-04 02:02:28 +00:00
|
|
|
$class = StudlyCaps($1);
|
|
|
|
$pedef = $line;
|
|
|
|
while ($line = <STDIN>) {
|
|
|
|
$pedef .= $line;
|
|
|
|
last if ($line =~ /^}/);
|
|
|
|
}
|
2002-06-25 23:19:36 +00:00
|
|
|
$pedefs{lc($class)} = $pedef;
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
} elsif ($line =~ /^(\w+)_get_type\b/) {
|
|
|
|
$class = StudlyCaps($1);
|
|
|
|
$pedef = $line;
|
|
|
|
while ($line = <STDIN>) {
|
|
|
|
$pedef .= $line;
|
|
|
|
if ($line =~ /g_boxed_type_register_static/) {
|
|
|
|
$boxdef = $line;
|
|
|
|
while ($line !~ /;/) {
|
|
|
|
$boxdef .= ($line = <STDIN>);
|
|
|
|
}
|
|
|
|
$boxdef =~ s/\n\s*//g;
|
|
|
|
$boxdef =~ /\(\"(\w+)\"/;
|
|
|
|
my $boxtype = $1;
|
|
|
|
$boxtype =~ s/($ns)Type(\w+)/$ns$2/;
|
|
|
|
$boxdefs{$boxtype} = $boxdef;
|
|
|
|
}
|
|
|
|
last if ($line =~ /^}/);
|
2002-01-17 00:26:46 +00:00
|
|
|
}
|
2002-06-25 23:19:36 +00:00
|
|
|
$typefuncs{lc($class)} = $pedef;
|
2002-01-04 02:02:28 +00:00
|
|
|
} elsif ($line =~ /^(const|G_CONST_RETURN)?\s*\w+\s*\**\s*(\w+)\s*\(/) {
|
|
|
|
$fname = $2;
|
|
|
|
$fdef = "";
|
|
|
|
while ($line !~ /;/) {
|
|
|
|
$fdef .= $line;
|
|
|
|
$line = <STDIN>;
|
|
|
|
}
|
|
|
|
$fdef .= $line;
|
2002-01-17 Mike Kestner <mkestner@speakeasy.net>
* generator/BoxedGen.cs : Removed Name, CName, and QualifiedName.
* generator/ObjectGen.cs : Removed Name, CName, and QualifiedName.
* generator/StructBase.cs : Add Name, CName, and QualifiedName. Add
GenCtor method. Stub GetCallString, GetImportSig, and GetSignature
methods.
* generator/StructGen.cs : Removed Name, CName, and QualifiedName.
* generator/SymbolTable.cs : Add GetDllName method.
* parser/gapi2xml.pl : Fix a couple <parameters> bugs.
svn path=/trunk/gtk-sharp/; revision=2030
2002-01-17 23:44:56 +00:00
|
|
|
$fdef =~ s/\n\s*//g;
|
2002-01-04 02:02:28 +00:00
|
|
|
$fdefs{$fname} = $fdef;
|
|
|
|
} elsif ($line =~ /G_TYPE_CHECK_(\w+)_CAST.*,\s*(\w+),\s*(\w+)/) {
|
|
|
|
if ($1 eq "INSTANCE") {
|
|
|
|
$objects{$2} = $3 . $objects{$2};
|
|
|
|
} else {
|
|
|
|
$objects{$2} .= ":$3";
|
|
|
|
}
|
|
|
|
} elsif ($line =~ /GTK_CHECK_CAST.*,\s*(\w+),\s*(\w+)/) {
|
|
|
|
$objects{$1} = $2 . $objects{$1};
|
|
|
|
} elsif ($line =~ /GTK_CHECK_CLASS_CAST.*,\s*(\w+),\s*(\w+)/) {
|
|
|
|
$objects{$1} .= ":$2";
|
2002-01-07 23:30:01 +00:00
|
|
|
} elsif ($line =~ /INSTANCE_GET_INTERFACE.*,\s*(\w+),\s*(\w+)/) {
|
|
|
|
$ifaces{$1} = $2;
|
2002-01-17 00:26:46 +00:00
|
|
|
} elsif ($line =~ /^BUILTIN\s*\{\s*\"(\w+)\".*GTK_TYPE_BOXED/) {
|
|
|
|
$boxdefs{$1} = $line;
|
|
|
|
} elsif ($line =~ /^BUILTIN\s*\{\s*\"(\w+)\".*GTK_TYPE_(ENUM|FLAGS)/) {
|
|
|
|
# ignoring these for now.
|
2002-07-05 20:22:21 +00:00
|
|
|
} elsif ($line =~ /^\#define/) {
|
|
|
|
my $test_ns = uc ($ns);
|
|
|
|
if ($line =~ /\#define\s+(\w+)\s+\"(.*)\"/) {
|
|
|
|
$defines{$1} = $2;
|
|
|
|
}
|
2002-01-04 02:02:28 +00:00
|
|
|
} else {
|
|
|
|
print $line;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
##############################################################
|
|
|
|
# Produce the enum definitions.
|
|
|
|
##############################################################
|
|
|
|
|
|
|
|
foreach $cname (sort(keys(%edefs))) {
|
|
|
|
$ecnt++;
|
|
|
|
$enum_elem = addNameElem($ns_elem, 'enum', $cname, $ns);
|
|
|
|
$def = $edefs{$cname};
|
|
|
|
if ($def =~ /=\s*1\s*<<\s*\d+/) {
|
|
|
|
$enum_elem->setAttribute('type', "flags");
|
|
|
|
} else {
|
|
|
|
$enum_elem->setAttribute('type', "enum");
|
|
|
|
}
|
|
|
|
$def =~ /\{(.*)\}/;
|
|
|
|
@vals = split(/,\s*/, $1);
|
|
|
|
@v0 = split(/_/, $vals[0]);
|
|
|
|
if (@vals > 1) {
|
|
|
|
$done = 0;
|
|
|
|
for ($idx = 0, $regex = ""; $idx < @v0; $idx++) {
|
|
|
|
$regex .= ($v0[$idx] . "_");
|
|
|
|
foreach $val (@vals) {
|
|
|
|
$done = 1 if ($val !~ /$regex/);
|
|
|
|
}
|
|
|
|
last if $done;
|
|
|
|
}
|
|
|
|
$common = join("_", @v0[0..$idx-1]);
|
|
|
|
} else {
|
|
|
|
$common = join("_", @v0[0..$#v0-1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach $val (@vals) {
|
2002-09-21 14:21:15 +00:00
|
|
|
if ($val =~ /$common\_(\w+)\s*=\s*(\-?\d+.*)/) {
|
2002-01-04 02:02:28 +00:00
|
|
|
$name = $1;
|
|
|
|
if ($2 =~ /1u?\s*<<\s*(\d+)/) {
|
|
|
|
$enumval = "1 << $1";
|
|
|
|
} else {
|
|
|
|
$enumval = $2;
|
|
|
|
}
|
|
|
|
} elsif ($val =~ /$common\_(\w+)/) {
|
|
|
|
$name = $1; $enumval = "";
|
|
|
|
} else {
|
|
|
|
die "Unexpected enum value: $val\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
$val_elem = addNameElem($enum_elem, 'member');
|
|
|
|
$val_elem->setAttribute('cname', "$common\_$name");
|
|
|
|
$val_elem->setAttribute('name', StudlyCaps(lc($name)));
|
|
|
|
if ($enumval) {
|
|
|
|
$val_elem->setAttribute('value', $enumval);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
##############################################################
|
|
|
|
# Parse the callbacks.
|
|
|
|
##############################################################
|
|
|
|
|
|
|
|
foreach $cbname (sort(keys(%fpdefs))) {
|
2002-01-10 15:01:31 +00:00
|
|
|
next if ($cbname !~ /$ns/);
|
2002-01-04 02:02:28 +00:00
|
|
|
$cbcnt++;
|
|
|
|
$fdef = $cb = $fpdefs{$cbname};
|
|
|
|
$cb_elem = addNameElem($ns_elem, 'callback', $cbname, $ns);
|
|
|
|
$cb =~ /typedef\s+(.*)\(.*\).*\((.*)\);/;
|
|
|
|
$ret = $1; $params = $2;
|
|
|
|
addReturnElem($cb_elem, $ret);
|
|
|
|
if ($params && ($params ne "void")) {
|
|
|
|
addParamsElem($cb_elem, split(/,/, $params));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-01-07 23:30:01 +00:00
|
|
|
##############################################################
|
|
|
|
# Parse the interfaces list.
|
|
|
|
##############################################################
|
|
|
|
|
|
|
|
foreach $type (sort(keys(%ifaces))) {
|
|
|
|
|
|
|
|
$iface = $ifaces{$type};
|
|
|
|
($inst, $dontcare) = split(/:/, delete $objects{$type});
|
2002-06-25 23:19:36 +00:00
|
|
|
$initfunc = $pedefs{lc($inst)};
|
2002-01-07 23:30:01 +00:00
|
|
|
$ifacetype = delete $types{$iface};
|
|
|
|
delete $types{$inst};
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
|
2002-01-07 23:30:01 +00:00
|
|
|
$ifacecnt++;
|
|
|
|
$iface_el = addNameElem($ns_elem, 'interface', $inst, $ns);
|
2002-08-09 03:56:27 +00:00
|
|
|
|
|
|
|
$elem_table{lc($inst)} = $iface_el;
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
|
|
|
|
$classdef = $sdefs{$1} if ($ifacetype =~ /struct\s+(\w+)/);
|
|
|
|
if ($initfunc) {
|
|
|
|
parseInitFunc($iface_el, $initfunc);
|
|
|
|
} else {
|
|
|
|
warn "Don't have an init func for $inst.\n" if $debug;
|
|
|
|
}
|
2002-01-07 23:30:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-01-04 02:02:28 +00:00
|
|
|
##############################################################
|
|
|
|
# Parse the classes by walking the objects list.
|
|
|
|
##############################################################
|
|
|
|
|
|
|
|
foreach $type (sort(keys(%objects))) {
|
|
|
|
|
|
|
|
($inst, $class) = split(/:/, $objects{$type});
|
|
|
|
$class = $inst . "Class" if (!$class);
|
2002-06-25 23:19:36 +00:00
|
|
|
$initfunc = $pedefs{lc($inst)};
|
|
|
|
$typefunc = $typefuncs{lc($inst)};
|
2002-01-04 02:02:28 +00:00
|
|
|
$insttype = delete $types{$inst};
|
|
|
|
$classtype = delete $types{$class};
|
|
|
|
|
|
|
|
$instdef = $classdef = "";
|
|
|
|
$instdef = $sdefs{$1} if ($insttype =~ /struct\s+(\w+)/);
|
|
|
|
$classdef = $sdefs{$1} if ($classtype =~ /struct\s+(\w+)/);
|
|
|
|
$instdef =~ s/\s+(\*+)/\1 /g;
|
|
|
|
warn "Strange Class $inst\n" if (!$instdef && $debug);
|
|
|
|
|
|
|
|
$classcnt++;
|
|
|
|
$obj_el = addNameElem($ns_elem, 'object', $inst, $ns);
|
|
|
|
|
2002-07-23 22:23:40 +00:00
|
|
|
$elem_table{lc($inst)} = $obj_el;
|
|
|
|
|
2002-01-04 02:02:28 +00:00
|
|
|
# Extract parent and fields from the struct
|
|
|
|
if ($instdef =~ /^struct/) {
|
|
|
|
$instdef =~ /\{(.*)\}/;
|
|
|
|
@fields = split(/;/, $1);
|
|
|
|
$fields[0] =~ /(\w+)/;
|
|
|
|
$obj_el->setAttribute('parent', "$1");
|
|
|
|
addFieldElems($obj_el, @fields[1..$#fields]);
|
|
|
|
} elsif ($instdef =~ /privatestruct/) {
|
|
|
|
# just get the parent for private structs
|
|
|
|
$instdef =~ /\{\s*(\w+)/;
|
|
|
|
$obj_el->setAttribute('parent', "$1");
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get the props from the class_init func.
|
|
|
|
if ($initfunc) {
|
|
|
|
parseInitFunc($obj_el, $initfunc);
|
|
|
|
} else {
|
|
|
|
warn "Don't have an init func for $inst.\n" if $debug;
|
|
|
|
}
|
|
|
|
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
# Get the interfaces from the class_init func.
|
|
|
|
if ($typefunc) {
|
|
|
|
parseTypeFunc($obj_el, $typefunc);
|
|
|
|
} else {
|
|
|
|
warn "Don't have a GetType func for $inst.\n" if $debug;
|
|
|
|
}
|
|
|
|
|
2002-01-04 02:02:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
##############################################################
|
|
|
|
# Parse the remaining types.
|
|
|
|
##############################################################
|
|
|
|
|
|
|
|
foreach $key (sort (keys (%types))) {
|
|
|
|
|
|
|
|
$lasttype = $type = $key;
|
|
|
|
while ($type && ($types{$type} !~ /struct/)) {
|
|
|
|
$lasttype = $type;
|
|
|
|
$type = $types{$type};
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($types{$type} =~ /struct\s+(\w+)/) {
|
|
|
|
$type = $1;
|
|
|
|
} else {
|
|
|
|
$elem = addNameElem($ns_elem, 'alias', $key, $ns);
|
|
|
|
$elem->setAttribute('type', $lasttype);
|
|
|
|
warn "alias $key to $lasttype\n" if $debug;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (exists($sdefs{$type})) {
|
|
|
|
$def = $sdefs{$type};
|
|
|
|
} else {
|
2002-07-20 14:43:48 +00:00
|
|
|
$def = "privatestruct";
|
2002-01-04 02:02:28 +00:00
|
|
|
}
|
|
|
|
|
2002-07-30 23:02:12 +00:00
|
|
|
|
|
|
|
# fixme: hack
|
|
|
|
if ($key eq "GdkBitmap") {
|
|
|
|
$struct_el = addNameElem($ns_elem, 'object', $key, $ns);
|
|
|
|
} elsif (exists($boxdefs{$key})) {
|
2002-01-17 00:26:46 +00:00
|
|
|
$struct_el = addNameElem($ns_elem, 'boxed', $key, $ns);
|
|
|
|
} else {
|
|
|
|
$struct_el = addNameElem($ns_elem, 'struct', $key, $ns);
|
|
|
|
}
|
2002-07-23 22:23:40 +00:00
|
|
|
|
|
|
|
$elem_table{lc($key)} = $struct_el;
|
|
|
|
|
2002-01-04 02:02:28 +00:00
|
|
|
$def =~ s/\s+/ /g;
|
2002-07-19 05:44:32 +00:00
|
|
|
if ($def =~ /privatestruct/) {
|
|
|
|
$struct_el->setAttribute('opaque', 'true');
|
|
|
|
} else {
|
|
|
|
$def =~ /\{(.+)\}/;
|
|
|
|
addFieldElems($struct_el, split(/;/, $1));
|
|
|
|
}
|
2002-01-04 02:02:28 +00:00
|
|
|
}
|
2002-07-06 07:08:19 +00:00
|
|
|
|
2002-09-08 01:29:07 +00:00
|
|
|
# really, _really_ opaque structs that aren't even defined in sources. Lovely.
|
|
|
|
foreach $key (sort (keys (%ptrs))) {
|
|
|
|
next if $ptrs{$key} !~ /struct\s+(\w+)/;
|
|
|
|
$type = $1;
|
|
|
|
$struct_el = addNameElem ($ns_elem, 'struct', $key, $ns);
|
|
|
|
$struct_el->setAttribute('opaque', 'true');
|
|
|
|
$elem_table{lc($key)} = $struct_el;
|
|
|
|
}
|
|
|
|
|
2002-07-23 22:23:40 +00:00
|
|
|
addFuncElems();
|
|
|
|
|
2002-07-06 07:08:19 +00:00
|
|
|
# This should probably be done in a more generic way
|
|
|
|
foreach $define (sort (keys (%defines))) {
|
|
|
|
next if $define !~ /[A-Z]_STOCK_/;
|
|
|
|
if ($stocks{$ns}) {
|
|
|
|
$stock_el = $stocks{$ns};
|
|
|
|
} else {
|
|
|
|
$stock_el = addNameElem($ns_elem, "object", $ns . "Stock", $ns);
|
|
|
|
$stocks{$ns} = $stock_el;
|
|
|
|
}
|
|
|
|
$string_el = addNameElem ($stock_el, "static-string", $define);
|
|
|
|
$string_name = lc($define);
|
|
|
|
$string_name =~ s/\w+_stock_//;
|
|
|
|
$string_el->setAttribute('name', StudlyCaps($string_name));
|
|
|
|
$string_el->setAttribute('value', $defines{$define});
|
|
|
|
}
|
|
|
|
|
2002-06-10 12:34:09 +00:00
|
|
|
##############################################################
|
|
|
|
# Add metadata
|
|
|
|
##############################################################
|
2002-08-19 Rachel Hestilow <hestilow@ximian.com>
* art/Makefile.in (clean): Change to avoid bugging out on generated/CVS.
* glib/ObjectManager.cs: Added. Used to be auto-generated, but
now it can infer names, and relies on per-namespace ObjectManager
classes to inform it of oddly-named classes.
* generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property.
* generator/*Gen.cs: Honor DoGenerate.
* generator/CodeGenerator.cs: Support including dependency files
which will not be generated.
* generator/ObjectGen.cs: Generate mapping file per-namespace, as one
that calls back to the one in glib. Only generate if the name does
not follow the normal conventions, otherwise, GtkSharp.ObjectManager
can infer the name.
* generator/Parser.cs: Accept 'generate' flag to pass on to the
IGeneratables. Parse a new toplevel element, "symbol", which adds
a type to the SymbolTable (instead of hard-coding it).
* generator/SignalHandler.cs: Do not optimize signal handler creation,
instead creating them in their own namespaces. Do not generate
if the calling Signal told us not to.
* generator/Signal.cs: Do not generate handlers if container's DoGenerate
is false. Adjust to the marshaller name being in a sub-namespace.
* generator/SymbolTable.cs (AddSimpleType, AddManualType): Used
to add simple and manually wrapped types at runtime instead of
compile-time.
(FromNative): Remove hard-coded cases for manually wrapped types, use
a generic case instead.
* api: Added. Move api files and generation targets here.
* source: Added. Move source parsing here.
* generator/makefile: Move actual generation to api/.
* glib/Makefile.in: Remove generated/* target.
* glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff
to GNOME target.
* gnome/CanvasProxy.cs: Update to work with SignalHandlers being
namespace-specific.
* parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc.
* parser/gapi2xml.pl: Use GAPI::Metadata.
* parser/makefile: Install scripts, remove source parse build target.
Rename formatXML to gapi_format_xml.
svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 19:56:18 +00:00
|
|
|
GAPI::Metadata::fixup $doc;
|
2002-01-04 02:02:28 +00:00
|
|
|
|
|
|
|
##############################################################
|
|
|
|
# Output the tree
|
|
|
|
##############################################################
|
|
|
|
|
|
|
|
if ($ARGV[1]) {
|
|
|
|
open(XMLFILE, ">$ARGV[1]") ||
|
|
|
|
die "Couldn't open $ARGV[1] for writing.\n";
|
|
|
|
print XMLFILE $doc->toString();
|
|
|
|
close(XMLFILE);
|
|
|
|
} else {
|
|
|
|
print $doc->toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
##############################################################
|
|
|
|
# Generate a few stats from the parsed source.
|
|
|
|
##############################################################
|
|
|
|
|
|
|
|
$scnt = keys(%sdefs); $fcnt = keys(%fdefs); $tcnt = keys(%types);
|
|
|
|
print "structs: $scnt enums: $ecnt callbacks: $cbcnt\n";
|
|
|
|
print "funcs: $fcnt types: $tcnt classes: $classcnt\n";
|
|
|
|
print "props: $propcnt signals: $sigcnt\n";
|
|
|
|
|
|
|
|
sub addFieldElems
|
|
|
|
{
|
|
|
|
my ($parent, @fields) = @_;
|
|
|
|
|
|
|
|
foreach $field (@fields) {
|
|
|
|
next if ($field !~ /\S/);
|
|
|
|
$field =~ s/\s+(\*+)/\1 /g;
|
|
|
|
$field =~ s/const /const\-/g;
|
2002-07-26 06:08:52 +00:00
|
|
|
$field =~ s/struct /struct\-/g;
|
2002-07-13 Rachel Hestilow <hestilow@ximian.com>
* parser/Gnome.metadata, Gtk.metadata: More conflict
fixes.
* parser/build.pl: Fully qualify all lib names. (Gtk+ packages
are now LFS-compliant in Debian...)
* parser/gapi2xml.pl: Fix for whitespace in fields, defines,
and docs.
* generator/BoxedGen.cs: Remove extraneous CallByName definition,
add "override" keyword to FromNative.
(Generate): Generate methods after fields.
* generator/ClassBase.cs: Change CallByName, FromNative to virtual.
(.ctor): Ignore "hidden" nodes. Set container on signal.
(GenSignals, GenMethods): Add "implementor" argument for interface
use.
(Get(Method|Signal|Property)Recursively): Rework to correctly
recurse interfaces.
(Implements): Added.
* generator/Ctor.cs (Initialize): Move clash initialization completely
out of Generate, so we can check for collisions.
* generator/Method.cs (GenerateDeclCommon): Check for duplicates,
for "new" keyword.
(Generate): Add "implementor" argument.
* generator/ObjectGen.cs (Generate): Initialize ctor clashes on
this and all parents, before generating.
(Ctors, InitializeCtors): Added.
* generator/Signal.cs: Store the container_type, check for
collisions.
* generator/StructGen.cs: Add "override" keyword to overriden methods.
* gtk/FileSelection.custom (ActionArea): Add "new" keyword.
svn path=/trunk/gtk-sharp/; revision=5782
2002-07-13 20:31:23 +00:00
|
|
|
$field =~ s/.*\*\///g;
|
|
|
|
next if ($field !~ /\S/);
|
|
|
|
|
2002-01-04 02:02:28 +00:00
|
|
|
if ($field =~ /(\S+\s+\*?)\(\*\s*(.+)\)\s*\((.*)\)/) {
|
|
|
|
$elem = addNameElem($parent, 'callback', $2);
|
|
|
|
addReturnElem($elem, $1);
|
|
|
|
addParamsElem($elem, $3);
|
|
|
|
} elsif ($field =~ /(\S+)\s+(.+)/) {
|
|
|
|
$type = $1; $symb = $2;
|
|
|
|
foreach $tok (split (/,\s*/, $symb)) {
|
|
|
|
if ($tok =~ /(\w+)\s*\[(.*)\]/) {
|
|
|
|
$elem = addNameElem($parent, 'field', $1);
|
|
|
|
$elem->setAttribute('array_len', "$2");
|
2002-01-06 13:33:25 +00:00
|
|
|
} elsif ($tok =~ /(\w+)\s*\:\s*(\d+)/) {
|
|
|
|
$elem = addNameElem($parent, 'field', $1);
|
|
|
|
$elem->setAttribute('bits', "$2");
|
2002-01-04 02:02:28 +00:00
|
|
|
} else {
|
2002-01-07 00:25:51 +00:00
|
|
|
$elem = addNameElem($parent, 'field', $tok);
|
2002-01-04 02:02:28 +00:00
|
|
|
}
|
2002-01-06 13:33:25 +00:00
|
|
|
$elem->setAttribute('type', "$type");
|
2002-01-04 02:02:28 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
die "$field\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub addFuncElems
|
|
|
|
{
|
2002-07-23 22:23:40 +00:00
|
|
|
my ($obj_el, $inst, $prefix);
|
2002-01-04 02:02:28 +00:00
|
|
|
|
|
|
|
$fcnt = keys(%fdefs);
|
|
|
|
|
2002-07-23 22:23:40 +00:00
|
|
|
foreach $mname (sort (keys (%fdefs))) {
|
|
|
|
next if ($mname =~ /^_/);
|
|
|
|
$obj_el = "";
|
|
|
|
$prefix = $mname;
|
2002-08-03 22:24:37 +00:00
|
|
|
$prepend = undef;
|
2002-07-23 22:23:40 +00:00
|
|
|
while ($prefix =~ /(\w+)_/) {
|
|
|
|
$prefix = $key = $1;
|
|
|
|
$key =~ s/_//g;
|
2002-08-03 22:24:37 +00:00
|
|
|
# FIXME: lame Gdk API hack
|
|
|
|
if ($key eq "gdkdraw") {
|
|
|
|
$key = "gdkdrawable";
|
|
|
|
$prepend = "draw_";
|
|
|
|
}
|
2002-07-23 22:23:40 +00:00
|
|
|
if (exists ($elem_table{$key})) {
|
|
|
|
$prefix .= "_";
|
|
|
|
$obj_el = $elem_table{$key};
|
|
|
|
$inst = $key;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
next if (!$obj_el);
|
|
|
|
|
|
|
|
$mdef = delete $fdefs{$mname};
|
2002-01-04 02:02:28 +00:00
|
|
|
|
2002-02-08 23:56:27 +00:00
|
|
|
if ($mname =~ /$prefix(new)/) {
|
|
|
|
$el = addNameElem($obj_el, 'constructor', $mname);
|
|
|
|
$drop_1st = 0;
|
2002-07-23 22:23:40 +00:00
|
|
|
} else {
|
2002-08-03 22:24:37 +00:00
|
|
|
$el = addNameElem($obj_el, 'method', $mname, $prefix, $prepend);
|
2002-07-23 22:23:40 +00:00
|
|
|
$mdef =~ /(.*?)\w+\s*\(/;
|
2002-01-04 02:02:28 +00:00
|
|
|
addReturnElem($el, $1);
|
2002-07-23 22:23:40 +00:00
|
|
|
$mdef =~ /\(\s*(const)?\s*(\w+)/;
|
|
|
|
if (lc($2) ne $inst) {
|
|
|
|
$el->setAttribute("shared", "true");
|
|
|
|
$drop_1st = 0;
|
|
|
|
} else {
|
|
|
|
$drop_1st = 1;
|
|
|
|
}
|
2002-01-04 02:02:28 +00:00
|
|
|
}
|
|
|
|
|
2002-01-17 Mike Kestner <mkestner@speakeasy.net>
* generator/BoxedGen.cs : Removed Name, CName, and QualifiedName.
* generator/ObjectGen.cs : Removed Name, CName, and QualifiedName.
* generator/StructBase.cs : Add Name, CName, and QualifiedName. Add
GenCtor method. Stub GetCallString, GetImportSig, and GetSignature
methods.
* generator/StructGen.cs : Removed Name, CName, and QualifiedName.
* generator/SymbolTable.cs : Add GetDllName method.
* parser/gapi2xml.pl : Fix a couple <parameters> bugs.
svn path=/trunk/gtk-sharp/; revision=2030
2002-01-17 23:44:56 +00:00
|
|
|
if (($mdef =~ /\((.*)\)/) && ($1 ne "void")) {
|
2002-02-17 20:54:54 +00:00
|
|
|
@parms = ();
|
|
|
|
$parm = "";
|
|
|
|
$pcnt = 0;
|
|
|
|
foreach $char (split(//, $1)) {
|
|
|
|
if ($char eq "(") {
|
|
|
|
$pcnt++;
|
|
|
|
} elsif ($char eq ")") {
|
|
|
|
$pcnt--;
|
|
|
|
} elsif (($pcnt == 0) && ($char eq ",")) {
|
|
|
|
@parms = (@parms, $parm);
|
|
|
|
$parm = "";
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
$parm .= $char;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($parm) {
|
|
|
|
@parms = (@parms, $parm);
|
|
|
|
}
|
|
|
|
# @parms = split(/,/, $1);
|
|
|
|
($dump, @parms) = @parms if $drop_1st;
|
2002-01-04 02:02:28 +00:00
|
|
|
if (@parms > 0) {
|
|
|
|
addParamsElem($el, @parms);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub addNameElem
|
|
|
|
{
|
2002-08-03 22:24:37 +00:00
|
|
|
my ($node, $type, $cname, $prefix, $prepend) = @_;
|
2002-01-04 02:02:28 +00:00
|
|
|
|
|
|
|
my $elem = $doc->createElement($type);
|
|
|
|
$node->appendChild($elem);
|
|
|
|
if ($prefix) {
|
|
|
|
$cname =~ /$prefix(\w+)/;
|
2002-08-03 22:24:37 +00:00
|
|
|
if ($prepend) {
|
|
|
|
$name = $prepend . $1;
|
|
|
|
} else {
|
|
|
|
$name = $1;
|
|
|
|
}
|
|
|
|
$elem->setAttribute('name', StudlyCaps($name));
|
2002-01-04 02:02:28 +00:00
|
|
|
}
|
|
|
|
if ($cname) {
|
|
|
|
$elem->setAttribute('cname', $cname);
|
|
|
|
}
|
|
|
|
return $elem;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub addParamsElem
|
|
|
|
{
|
|
|
|
my ($parent, @params) = @_;
|
|
|
|
|
|
|
|
my $parms_elem = $doc->createElement('parameters');
|
|
|
|
$parent->appendChild($parms_elem);
|
|
|
|
foreach $parm (@params) {
|
2002-02-03 03:44:10 +00:00
|
|
|
$parm =~ s/\s+(\*+)/\1 /g;
|
2002-01-04 02:02:28 +00:00
|
|
|
$parm =~ s/const\s+/const-/g;
|
2002-02-17 20:54:54 +00:00
|
|
|
if ($parm =~ /(.*)\(\s*\**\s*(\w+)\)\s+\((.*)\)/) {
|
|
|
|
my $ret = $1; my $cbn = $2; my $params = $3;
|
|
|
|
$cb_elem = addNameElem($parms_elem, 'callback', $cbn);
|
|
|
|
addReturnElem($cb_elem, $ret);
|
|
|
|
if ($params && ($params ne "void")) {
|
|
|
|
addParamsElem($cb_elem, split(/,/, $params));
|
|
|
|
}
|
|
|
|
next;
|
2002-07-19 04:07:50 +00:00
|
|
|
} elsif ($parm =~ /\.\.\./) {
|
|
|
|
$parm_elem = $doc->createElement('parameter');
|
|
|
|
$parms_elem->appendChild($parm_elem);
|
|
|
|
$parm_elem->setAttribute('ellipsis', 'true');
|
|
|
|
next;
|
2002-02-17 20:54:54 +00:00
|
|
|
}
|
|
|
|
$parm_elem = $doc->createElement('parameter');
|
|
|
|
$parms_elem->appendChild($parm_elem);
|
2002-01-04 02:02:28 +00:00
|
|
|
$parm =~ /(\S+)\s+(\S+)/;
|
2002-02-03 03:44:10 +00:00
|
|
|
$parm_elem->setAttribute('type', $1);
|
|
|
|
my $name = $2;
|
2002-06-26 Rachel Hestilow <hestilow@ximian.com>
* configure.in, makefile, makefile.win32: add gnome.
* doc/index.html, netdoc.xsl: Add gnome.
* gdk/Event.cs: New manual wrap for GdkEvent.
* generator/ClassBase.cs: Add methods GetProperty,
GetPropertyRecursively, GetMethodRecursively.
Move Parent property here from ObjectGen.cs. Pass this pointer
into Property.
* generator/Ctor.cs: Generate docs.
* generator/Method.cs, Property.cs: Tag method as "new" if a
Method/Property with the same name is found in the class hierarchy.
* generator/SignalHandler.cs: Correctly wrap complex signal argument
types. Add gnome directory.
* generator/SymbolTable.cs: Add manually wrapped types hash
(contains GLib.GSList and Gdk.Event). Add method IsManuallyWrapped.
* glib/SList.cs: Add constructor from IntPtr.
* glue/slist.c, glue/event.c: Added (field accessor glue).
* glue/Makefile.am: Update.
* parser/Gtk.metadata: Add new signal renames for new signals
exposed by GdkEvent changes.
* parser/README, parser/build.pl: Add libgnome, libgnomecanvas,
libgnomeui.
* parser/gapi2xml.pl: Handle literal-length array parameters,
and NULL property doc strings.
* sample/: Add new test GnomeHelloWorld.cs.
* gnome/: Added.
* parser/Gnome.metadata: Added.
svn path=/trunk/gtk-sharp/; revision=5461
2002-06-26 08:36:05 +00:00
|
|
|
if ($name =~ /(\w+)\[.*\]/) {
|
2002-02-03 03:44:10 +00:00
|
|
|
$name = $1;
|
|
|
|
$parm_elem->setAttribute('array', "true");
|
|
|
|
}
|
|
|
|
$parm_elem->setAttribute('name', $name);
|
2002-01-04 02:02:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub addReturnElem
|
|
|
|
{
|
|
|
|
my ($parent, $ret) = @_;
|
|
|
|
|
|
|
|
$ret =~ s/const|G_CONST_RETURN/const-/g;
|
|
|
|
$ret =~ s/\s+//g;
|
|
|
|
my $ret_elem = $doc->createElement('return-type');
|
|
|
|
$parent->appendChild($ret_elem);
|
|
|
|
$ret_elem->setAttribute('type', $ret);
|
|
|
|
return $ret_elem;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub addPropElem
|
|
|
|
{
|
|
|
|
my ($spec, $node) = @_;
|
|
|
|
my ($name, $mode, $docs);
|
2002-01-12 02:08:16 +00:00
|
|
|
$spec =~ /g_param_spec_(\w+)\s*\((.*)\s*\)\s*\)/;
|
2002-01-04 02:02:28 +00:00
|
|
|
my $type = $1;
|
2002-01-12 02:08:16 +00:00
|
|
|
my @params = split(/,/, $2);
|
2002-01-04 02:02:28 +00:00
|
|
|
|
2002-01-12 02:08:16 +00:00
|
|
|
$name = $params[0];
|
2002-07-05 20:22:21 +00:00
|
|
|
if ($defines{$name}) {
|
|
|
|
$name = $defines{$name};
|
|
|
|
} else {
|
2002-07-13 Rachel Hestilow <hestilow@ximian.com>
* parser/Gnome.metadata, Gtk.metadata: More conflict
fixes.
* parser/build.pl: Fully qualify all lib names. (Gtk+ packages
are now LFS-compliant in Debian...)
* parser/gapi2xml.pl: Fix for whitespace in fields, defines,
and docs.
* generator/BoxedGen.cs: Remove extraneous CallByName definition,
add "override" keyword to FromNative.
(Generate): Generate methods after fields.
* generator/ClassBase.cs: Change CallByName, FromNative to virtual.
(.ctor): Ignore "hidden" nodes. Set container on signal.
(GenSignals, GenMethods): Add "implementor" argument for interface
use.
(Get(Method|Signal|Property)Recursively): Rework to correctly
recurse interfaces.
(Implements): Added.
* generator/Ctor.cs (Initialize): Move clash initialization completely
out of Generate, so we can check for collisions.
* generator/Method.cs (GenerateDeclCommon): Check for duplicates,
for "new" keyword.
(Generate): Add "implementor" argument.
* generator/ObjectGen.cs (Generate): Initialize ctor clashes on
this and all parents, before generating.
(Ctors, InitializeCtors): Added.
* generator/Signal.cs: Store the container_type, check for
collisions.
* generator/StructGen.cs: Add "override" keyword to overriden methods.
* gtk/FileSelection.custom (ActionArea): Add "new" keyword.
svn path=/trunk/gtk-sharp/; revision=5782
2002-07-13 20:31:23 +00:00
|
|
|
$name =~ s/\s*\"//g;
|
2002-07-05 20:22:21 +00:00
|
|
|
}
|
2002-01-12 02:08:16 +00:00
|
|
|
|
2002-06-26 Rachel Hestilow <hestilow@ximian.com>
* configure.in, makefile, makefile.win32: add gnome.
* doc/index.html, netdoc.xsl: Add gnome.
* gdk/Event.cs: New manual wrap for GdkEvent.
* generator/ClassBase.cs: Add methods GetProperty,
GetPropertyRecursively, GetMethodRecursively.
Move Parent property here from ObjectGen.cs. Pass this pointer
into Property.
* generator/Ctor.cs: Generate docs.
* generator/Method.cs, Property.cs: Tag method as "new" if a
Method/Property with the same name is found in the class hierarchy.
* generator/SignalHandler.cs: Correctly wrap complex signal argument
types. Add gnome directory.
* generator/SymbolTable.cs: Add manually wrapped types hash
(contains GLib.GSList and Gdk.Event). Add method IsManuallyWrapped.
* glib/SList.cs: Add constructor from IntPtr.
* glue/slist.c, glue/event.c: Added (field accessor glue).
* glue/Makefile.am: Update.
* parser/Gtk.metadata: Add new signal renames for new signals
exposed by GdkEvent changes.
* parser/README, parser/build.pl: Add libgnome, libgnomecanvas,
libgnomeui.
* parser/gapi2xml.pl: Handle literal-length array parameters,
and NULL property doc strings.
* sample/: Add new test GnomeHelloWorld.cs.
* gnome/: Added.
* parser/Gnome.metadata: Added.
svn path=/trunk/gtk-sharp/; revision=5461
2002-06-26 08:36:05 +00:00
|
|
|
while ($params[2] !~ /(\"|NULL)\s*\)?$/) {
|
2002-01-12 02:08:16 +00:00
|
|
|
die "Unable to reconstruct doc string.\n" if (!$params[3]);
|
|
|
|
$params[2] .= ",$params[3]";
|
|
|
|
@params = (@params[0..2],@params[4..$#params]);
|
|
|
|
}
|
|
|
|
$docs = $params[2];
|
2002-07-13 Rachel Hestilow <hestilow@ximian.com>
* parser/Gnome.metadata, Gtk.metadata: More conflict
fixes.
* parser/build.pl: Fully qualify all lib names. (Gtk+ packages
are now LFS-compliant in Debian...)
* parser/gapi2xml.pl: Fix for whitespace in fields, defines,
and docs.
* generator/BoxedGen.cs: Remove extraneous CallByName definition,
add "override" keyword to FromNative.
(Generate): Generate methods after fields.
* generator/ClassBase.cs: Change CallByName, FromNative to virtual.
(.ctor): Ignore "hidden" nodes. Set container on signal.
(GenSignals, GenMethods): Add "implementor" argument for interface
use.
(Get(Method|Signal|Property)Recursively): Rework to correctly
recurse interfaces.
(Implements): Added.
* generator/Ctor.cs (Initialize): Move clash initialization completely
out of Generate, so we can check for collisions.
* generator/Method.cs (GenerateDeclCommon): Check for duplicates,
for "new" keyword.
(Generate): Add "implementor" argument.
* generator/ObjectGen.cs (Generate): Initialize ctor clashes on
this and all parents, before generating.
(Ctors, InitializeCtors): Added.
* generator/Signal.cs: Store the container_type, check for
collisions.
* generator/StructGen.cs: Add "override" keyword to overriden methods.
* gtk/FileSelection.custom (ActionArea): Add "new" keyword.
svn path=/trunk/gtk-sharp/; revision=5782
2002-07-13 20:31:23 +00:00
|
|
|
$docs =~ s/\s*\"//g;
|
2002-01-12 02:08:16 +00:00
|
|
|
$docs =~ s/\s+/ /g;
|
|
|
|
$mode = $params[$#params];
|
|
|
|
|
|
|
|
if ($type =~ /boolean|float|double|^u?int|pointer/) {
|
2002-01-04 02:02:28 +00:00
|
|
|
$type = "g$type";
|
|
|
|
} elsif ($type =~ /string/) {
|
|
|
|
$type = "gchar*";
|
2002-01-17 00:26:46 +00:00
|
|
|
} elsif ($type =~ /boxed|enum|flags|object/) {
|
2002-01-12 02:08:16 +00:00
|
|
|
$type = $params[3];
|
2002-01-04 02:02:28 +00:00
|
|
|
$type =~ s/TYPE_//;
|
2002-01-12 02:08:16 +00:00
|
|
|
$type =~ s/\s+//g;
|
2002-01-04 02:02:28 +00:00
|
|
|
$type = StudlyCaps(lc($type));
|
|
|
|
}
|
|
|
|
|
|
|
|
$prop_elem = $doc->createElement('property');
|
|
|
|
$node->appendChild($prop_elem);
|
2002-01-12 02:08:16 +00:00
|
|
|
$prop_elem->setAttribute('name', StudlyCaps($name));
|
|
|
|
$prop_elem->setAttribute('cname', $name);
|
2002-01-04 02:02:28 +00:00
|
|
|
$prop_elem->setAttribute('type', $type);
|
|
|
|
$prop_elem->setAttribute('doc-string', $docs);
|
|
|
|
|
2002-01-12 02:08:16 +00:00
|
|
|
$prop_elem->setAttribute('readable', "true") if ($mode =~ /READ/);
|
|
|
|
$prop_elem->setAttribute('writeable', "true") if ($mode =~ /WRIT/);
|
|
|
|
$prop_elem->setAttribute('construct-only', "true") if ($mode =~ /CONS/);
|
2002-01-04 02:02:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub addSignalElem
|
|
|
|
{
|
|
|
|
my ($spec, $class, $node) = @_;
|
|
|
|
$spec =~ s/\n\s*//g; $class =~ s/\n\s*//g;
|
|
|
|
|
2002-06-25 23:19:36 +00:00
|
|
|
|
2002-01-04 02:02:28 +00:00
|
|
|
$sig_elem = $doc->createElement('signal');
|
|
|
|
$node->appendChild($sig_elem);
|
|
|
|
|
2002-02-15 01:08:57 +00:00
|
|
|
if ($spec =~ /\(\"([\w\-]+)\"/) {
|
|
|
|
$sig_elem->setAttribute('name', StudlyCaps($1));
|
|
|
|
$sig_elem->setAttribute('cname', $1);
|
|
|
|
}
|
2002-01-04 02:02:28 +00:00
|
|
|
$sig_elem->setAttribute('when', $1) if ($spec =~ /_RUN_(\w+)/);
|
|
|
|
|
|
|
|
my $method = "";
|
|
|
|
if ($spec =~ /_OFFSET\s*\(\w+,\s*(\w+)\)/) {
|
|
|
|
$method = $1;
|
|
|
|
} else {
|
|
|
|
@args = split(/,/, $spec);
|
|
|
|
$args[7] =~ s/_TYPE//; $args[7] =~ s/\s+//g;
|
|
|
|
addReturnElem($sig_elem, StudlyCaps(lc($args[7])));
|
|
|
|
$parmcnt = ($args[8] =~ /\d+/);
|
|
|
|
if ($parmcnt > 0) {
|
|
|
|
$parms_elem = $doc->createElement('parameters');
|
|
|
|
$sig_elem->appendChild($parms_elem);
|
|
|
|
for (my $idx = 0; $idx < $parmcnt; $idx++) {
|
|
|
|
$arg = $args[9+$idx];
|
|
|
|
$arg =~ s/_TYPE//; $arg =~ s/\s+//g;
|
|
|
|
$arg = StudlyCaps(lc($arg));
|
|
|
|
$parm_elem = $doc->createElement('parameter');
|
|
|
|
$parms_elem->appendChild($parm_elem);
|
|
|
|
$parm_elem->setAttribute('name', "p$idx");
|
|
|
|
$parm_elem->setAttribute('type', $arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-02-15 01:08:57 +00:00
|
|
|
if ($class =~ /;\s*(\S+\s*\**)\s*\(\*\s*$method\)\s*\((.*?)\);/) {
|
2002-01-04 02:02:28 +00:00
|
|
|
$ret = $1; $parms = $2;
|
|
|
|
addReturnElem($sig_elem, $ret);
|
|
|
|
if ($parms && ($parms ne "void")) {
|
|
|
|
addParamsElem($sig_elem, split(/,/, $parms));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
die "$method $class";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
sub addImplementsElem
|
|
|
|
{
|
|
|
|
my ($spec, $node) = @_;
|
|
|
|
$spec =~ s/\n\s*//g;
|
|
|
|
if ($spec =~ /,\s*(\w+)_TYPE_(\w+),/) {
|
|
|
|
$impl_elem = $doc->createElement('interface');
|
|
|
|
$name = StudlyCaps (lc ("$1_$2"));
|
|
|
|
$impl_elem->setAttribute ("cname", "$name");
|
|
|
|
$node->appendChild($impl_elem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-01-04 02:02:28 +00:00
|
|
|
|
|
|
|
sub parseInitFunc
|
|
|
|
{
|
|
|
|
my ($obj_el, $initfunc) = @_;
|
|
|
|
|
|
|
|
my @init_lines = split (/\n/, $initfunc);
|
|
|
|
|
|
|
|
my $linenum = 0;
|
|
|
|
while ($linenum < @init_lines) {
|
|
|
|
|
|
|
|
my $line = $init_lines[$linenum];
|
|
|
|
|
2002-01-12 02:08:16 +00:00
|
|
|
if ($line =~ /#define/) {
|
|
|
|
# FIXME: This ignores the bool helper macro thingie.
|
|
|
|
} elsif ($line =~ /g_object_class_install_prop/) {
|
|
|
|
my $prop = $line;
|
|
|
|
do {
|
|
|
|
$prop .= $init_lines[++$linenum];
|
|
|
|
} until ($init_lines[$linenum] =~ /;/);
|
|
|
|
addPropElem ($prop, $obj_el);
|
|
|
|
$propcnt++;
|
|
|
|
} elsif ($line =~ /g(tk)?_signal_new/) {
|
|
|
|
my $sig = $line;
|
|
|
|
do {
|
|
|
|
$sig .= $init_lines[++$linenum];
|
|
|
|
} until ($init_lines[$linenum] =~ /;/);
|
|
|
|
addSignalElem ($sig, $classdef, $obj_el);
|
|
|
|
$sigcnt++;
|
2002-01-04 02:02:28 +00:00
|
|
|
}
|
|
|
|
$linenum++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
sub parseTypeFunc
|
|
|
|
{
|
|
|
|
my ($obj_el, $typefunc) = @_;
|
|
|
|
|
|
|
|
my @type_lines = split (/\n/, $typefunc);
|
|
|
|
|
|
|
|
my $linenum = 0;
|
|
|
|
$impl_node = undef;
|
|
|
|
while ($linenum < @type_lines) {
|
|
|
|
|
|
|
|
my $line = $type_lines[$linenum];
|
|
|
|
|
|
|
|
if ($line =~ /#define/) {
|
|
|
|
# FIXME: This ignores the bool helper macro thingie.
|
|
|
|
} elsif ($line =~ /g_type_add_interface_static/) {
|
|
|
|
my $prop = $line;
|
|
|
|
do {
|
|
|
|
$prop .= $type_lines[++$linenum];
|
|
|
|
} until ($type_lines[$linenum] =~ /;/);
|
|
|
|
if (not $impl_node) {
|
|
|
|
$impl_node = $doc->createElement ("implements");
|
|
|
|
$obj_el->appendChild ($impl_node);
|
|
|
|
}
|
|
|
|
addImplementsElem ($prop, $impl_node);
|
|
|
|
}
|
|
|
|
$linenum++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-01-04 02:02:28 +00:00
|
|
|
##############################################################
|
|
|
|
# Converts a dash or underscore separated name to StudlyCaps.
|
|
|
|
##############################################################
|
|
|
|
|
|
|
|
%num2txt = ('1', "One", '2', "Two", '3', "Three", '4', "Four", '5', "Five",
|
|
|
|
'6', "Six", '7', "Seven", '8', "Eight", '9', "Nine", '0', "Zero");
|
|
|
|
|
|
|
|
sub StudlyCaps
|
|
|
|
{
|
|
|
|
my ($symb) = @_;
|
|
|
|
$symb =~ s/^([a-z])/\u\1/;
|
|
|
|
$symb =~ s/^(\d)/\1_/;
|
|
|
|
$symb =~ s/[-_]([a-z])/\u\1/g;
|
|
|
|
$symb =~ s/[-_](\d)/\1/g;
|
|
|
|
$symb =~ s/^2/Two/;
|
|
|
|
$symb =~ s/^3/Three/;
|
|
|
|
return $symb;
|
|
|
|
}
|
|
|
|
|