From f0579eb53d1c54e4e952fbd5ce0aabc5858c013b Mon Sep 17 00:00:00 2001 From: Olivier Dufour Date: Sat, 30 Jul 2011 11:47:44 +0200 Subject: [PATCH 1/2] parser: Add property support for ginterface --- gio/gio-api.raw | 2 +- gtk/gtk-api.raw | 32 +++++++++++------------ parser/gapi2xml.pl | 64 +++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 80 insertions(+), 18 deletions(-) diff --git a/gio/gio-api.raw b/gio/gio-api.raw index f63dff8ba..c138eddcc 100644 --- a/gio/gio-api.raw +++ b/gio/gio-api.raw @@ -6789,7 +6789,7 @@ - + diff --git a/gtk/gtk-api.raw b/gtk/gtk-api.raw index d0f3d292f..72587bc9e 100644 --- a/gtk/gtk-api.raw +++ b/gtk/gtk-api.raw @@ -2578,10 +2578,10 @@ - - - - + + + + @@ -4443,8 +4443,8 @@ - - + + @@ -4504,8 +4504,8 @@ - - + + @@ -4558,12 +4558,12 @@ - - - - - - + + + + + + @@ -13627,7 +13627,7 @@ - + @@ -18427,7 +18427,7 @@ - + diff --git a/parser/gapi2xml.pl b/parser/gapi2xml.pl index e6dfeca34..53210c921 100755 --- a/parser/gapi2xml.pl +++ b/parser/gapi2xml.pl @@ -1015,6 +1015,53 @@ sub addPropElem $prop_elem->setAttribute('construct-only', "true") if ($mode =~ /CONSTRUCT_ONLY/); } +sub addPropElem2 +{ + my ($spec, $node, $is_child) = @_; + my ($name, $mode, $docs); + + $spec =~ /g_param_spec_(\w+)\s*\((.*)\s*\);/; + my $type = $1; + my @params = split(/,/, $2); + + $name = $params[0]; + + if ($defines{$name}) { + $name = $defines{$name}; + } else { + $name =~ s/\s*\"//g; + } + + $mode = $params[$#params]; + + if ($type =~ /boolean|float|double|^u?int|pointer|unichar/) { + $type = "g$type"; + } elsif ($type =~ /string/) { + $type = "gchar*"; + } elsif ($type =~ /boxed|object/) { + $type = $params[$#params-1]; + $type =~ s/TYPE_//; + $type =~ s/\s+//g; + $type = StudlyCaps(lc($type)); + } elsif ($type =~ /enum|flags/) { + $type = $params[$#params-2]; + $type =~ s/TYPE_//; + $type =~ s/\s+//g; + $type = StudlyCaps(lc($type)); + } + + $prop_elem = $doc->createElement($is_child ? "childprop" : "property"); + $node->appendChild($prop_elem); + $prop_elem->setAttribute('name', StudlyCaps($name)); + $prop_elem->setAttribute('cname', $name); + $prop_elem->setAttribute('type', $type); + + $prop_elem->setAttribute('readable', "true") if ($mode =~ /READ/); + $prop_elem->setAttribute('writeable', "true") if ($mode =~ /WRIT/); + $prop_elem->setAttribute('construct', "true") if ($mode =~ /CONSTRUCT(?!_)/); + $prop_elem->setAttribute('construct-only', "true") if ($mode =~ /CONSTRUCT_ONLY/); +} + sub parseTypeToken { my ($tok) = @_; @@ -1115,6 +1162,8 @@ sub parseInitFunc my @signal_vms = (); my $linenum = 0; + my $pspec = ""; + my $pspec_use = 0; while ($linenum < @init_lines) { my $line = $init_lines[$linenum]; @@ -1123,10 +1172,18 @@ sub parseInitFunc # FIXME: This ignores the bool helper macro thingie. } elsif ($line =~ /g_object_(class|interface)_install_prop/) { my $prop = $line; + $pspec_use = 1; while ($prop !~ /\)\s*;/) { $prop .= $init_lines[++$linenum]; + if ($init_lines[$linenum] =~ /g_param_spec_/) { + $pspec_use = 0; + } + } + if ($pspec_use) { + addPropElem2 ($prop.$pspec, $obj_el, 0); + } else { + addPropElem ($prop, $obj_el, 0); } - addPropElem ($prop, $obj_el, 0); $propcnt++; } elsif ($line =~ /gtk_container_class_install_child_property/) { my $prop = $line; @@ -1143,6 +1200,11 @@ sub parseInitFunc $signal_vm = addSignalElem ($sig, $classdef, $obj_el); push (@signal_vms, $signal_vm) if $signal_vm; $sigcnt++; + } elsif ($line =~ /g_param_spec_/) { + $pspec = $line; + do { + $pspec .= $init_lines[++$linenum]; + } until ($init_lines[$linenum] =~ /\)\s*;/); } $linenum++; } From b14746d85658ce04fbde3bd4979bf5fc548c5904 Mon Sep 17 00:00:00 2001 From: Olivier Dufour Date: Tue, 2 Aug 2011 19:27:22 +0200 Subject: [PATCH 2/2] Fix build of gtk# by avoiding colision introduced with properties for ginterface --- gtk/Gtk.metadata | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gtk/Gtk.metadata b/gtk/Gtk.metadata index 25493197e..056aaac6c 100644 --- a/gtk/Gtk.metadata +++ b/gtk/Gtk.metadata @@ -427,6 +427,10 @@ 1 label LineWrapMode + 1 + 1 + 1 + 1 1 1 @@ -696,15 +700,19 @@ ref ref true + 1 out out out + 1 out ref Toggle 1 Toggle EmitToolbarReconfigured + 1 + 1 virtual-root out 1 @@ -758,11 +766,13 @@ true out GetEnableGridLines + 1 out 1 out out out + 1 out out true @@ -772,10 +782,16 @@ ActivateRow GetRowExpanded SetEnableGridLines + 1 + 1 1 true 1 1 + 1 + 1 + 1 + 1 1 [GLib.TypeInitializer (typeof (Gtk.Widget), "ClassInit")] 1