diff --git a/ChangeLog b/ChangeLog index 9c65c1e80..2bc62dc4f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2002-07-06 Rachel Hestilow + + * ObjectGen.cs: Support static string elements. Do + not generate Ctors or Signals if it is not a GObject. + + * parser/gapi2xml.pl: Add stock defines. + 2002-07-05 Rachel Hestilow * glue/Makefile.am: Make this work cleanly, with all automake. diff --git a/generator/ObjectGen.cs b/generator/ObjectGen.cs index 8170d5e29..e5117f1b5 100644 --- a/generator/ObjectGen.cs +++ b/generator/ObjectGen.cs @@ -14,6 +14,7 @@ namespace GtkSharp.Generation { public class ObjectGen : ClassBase, IGeneratable { private ArrayList ctors = new ArrayList(); + private ArrayList strings = new ArrayList(); public ObjectGen (XmlElement ns, XmlElement elem) : base (ns, elem) { @@ -32,6 +33,10 @@ namespace GtkSharp.Generation { ctors.Add (new Ctor (LibraryName, member)); break; + case "static-string": + strings.Add (node); + break; + default: if (!IsNodeNameHandled (node.Name)) Console.WriteLine ("Unexpected node " + node.Name + " in " + CName); @@ -78,7 +83,7 @@ namespace GtkSharp.Generation { } } - if (has_sigs) + if (has_sigs && Elem.HasAttribute("parent")) { sw.WriteLine("\t\tprivate Hashtable Signals = new Hashtable();"); GenSignals (sw, true); @@ -106,6 +111,11 @@ namespace GtkSharp.Generation { } } + foreach (XmlElement str in strings) { + sw.Write ("\t\tpublic static string " + str.GetAttribute ("name")); + sw.WriteLine (" {\n\t\t\t get { return \"" + str.GetAttribute ("value") + "\"; }\n\t\t}"); + } + AppendCustom(sw); sw.WriteLine ("\t}"); @@ -151,6 +161,8 @@ namespace GtkSharp.Generation { private void GenCtors (StreamWriter sw) { + if (!Elem.HasAttribute("parent")) + return; sw.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}"); sw.WriteLine(); diff --git a/generator/gtkapi.xml b/generator/gtkapi.xml index 513c2ba42..2463ed742 100644 --- a/generator/gtkapi.xml +++ b/generator/gtkapi.xml @@ -4706,6 +4706,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -21014,6 +21047,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/parser/gapi2xml.pl b/parser/gapi2xml.pl index bd1b3990a..4b3608ca8 100755 --- a/parser/gapi2xml.pl +++ b/parser/gapi2xml.pl @@ -333,6 +333,23 @@ foreach $key (sort (keys (%types))) { addFieldElems($struct_el, split(/;/, $1)); addFuncElems($struct_el, $key); } + +# 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}); +} + ############################################################## # Add metadata ##############################################################