2002-07-25 Rachel Hestilow <hestilow@ximian.com>

[about 60% of the marshalling patch that I lost.
	 The rest to come tomorrow.]

	* generator/BoxedGen.cs, StructGen.cs: Move most of this to StructBase,
	delete large chunks duplicated from ClassBase.

	* generator/IGeneratable.cs: Add MarshalReturnType, FromNativeReturn.

	* generator/ClassBase.cs: Move ctor stuff here. Add a CallByName
	overload with no parameters for the "self" reference.

	* generator/EnumGen.cs, CallbackGen.cs: Implement new MarshalReturnType,
	  FromNativeReturn.

   * generator/Method.cs: Use container_type.MarshalType, CallByName, and
	  SymbolTable.FromNativeReturn when generating call and import sigs.

	* generator/OpaqueGen.cs: Added.

	* generator/Property.cs: Handle boxed and opaques differently.

	* generator/SymbolTable.cs: Update for the opaque stuff and the new Return
	methods. Also change GetClassGen to simply call the as operator.

	* glib/Boxed.cs: Update for struct usage -- this is now a wrapper for
	  the purposes of using with Value.

   * glib/Opaque.cs: Added. New base class for opaque structs.

	* glue/textiter.c, gtk/TextIter.custom: Remove.

	* gnome/Program.cs: Update for new struct marshalling.

	* parser/Metadata.pm: Use our own getChildrenByTagName.

	* parser/README: Update for new requirements (was out of sync with
	  build.pl)

	* parser/gapi2xml.pl: Hide struct like const in field elements.

	* parser/gapi_pp.pl: Handle embedded union fields (poorly).

	* sample/test/TestColorSelection.cs: Comment out null color tests
     for now.

svn path=/trunk/gtk-sharp/; revision=6186
This commit is contained in:
Rachel Hestilow 2002-07-26 06:08:52 +00:00
parent dd71eaf3ea
commit 4d92d54b3f
32 changed files with 627 additions and 597 deletions

View file

@ -1,3 +1,50 @@
2002-07-25 Rachel Hestilow <hestilow@ximian.com>
[about 60% of the marshalling patch that I lost.
The rest to come tomorrow.]
* generator/BoxedGen.cs, StructGen.cs: Move most of this to StructBase,
delete large chunks duplicated from ClassBase.
* generator/IGeneratable.cs: Add MarshalReturnType, FromNativeReturn.
* generator/ClassBase.cs: Move ctor stuff here. Add a CallByName
overload with no parameters for the "self" reference.
* generator/EnumGen.cs, CallbackGen.cs: Implement new MarshalReturnType,
FromNativeReturn.
* generator/Method.cs: Use container_type.MarshalType, CallByName, and
SymbolTable.FromNativeReturn when generating call and import sigs.
* generator/OpaqueGen.cs: Added.
* generator/Property.cs: Handle boxed and opaques differently.
* generator/SymbolTable.cs: Update for the opaque stuff and the new Return
methods. Also change GetClassGen to simply call the as operator.
* glib/Boxed.cs: Update for struct usage -- this is now a wrapper for
the purposes of using with Value.
* glib/Opaque.cs: Added. New base class for opaque structs.
* glue/textiter.c, gtk/TextIter.custom: Remove.
* gnome/Program.cs: Update for new struct marshalling.
* parser/Metadata.pm: Use our own getChildrenByTagName.
* parser/README: Update for new requirements (was out of sync with
build.pl)
* parser/gapi2xml.pl: Hide struct like const in field elements.
* parser/gapi_pp.pl: Handle embedded union fields (poorly).
* sample/test/TestColorSelection.cs: Comment out null color tests
for now.
2002-07-24 Mike Kestner <mkestner@speakeasy.net>
* generator/SignalHandler.cs : use ref parameters in signal cb's.

View file

@ -1,13 +1,12 @@
// GtkSharp.Generation.BoxedGen.cs - The Boxed Type Generatable.
// GtkSharp.Generation.BoxedGen.cs - The Boxed Generatable.
//
// Author: Mike Kestner <mkestner@speakeasy.net>
//
// (c) 2001-2002 Mike Kestner
// (c) 2001 Mike Kestner
namespace GtkSharp.Generation {
using System;
using System.Collections;
using System.IO;
using System.Xml;
@ -15,67 +14,9 @@ namespace GtkSharp.Generation {
public BoxedGen (XmlElement ns, XmlElement elem) : base (ns, elem) {}
public override String FromNative(String var)
public override void Generate ()
{
return "(" + QualifiedName + ") GLib.Boxed.FromNative(" + var + ")";
}
public void Generate ()
{
StreamWriter sw = CreateWriter ();
sw.WriteLine ("\tusing System;");
sw.WriteLine ("\tusing System.Collections;");
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
sw.WriteLine ();
sw.WriteLine("\t\t/// <summary> " + Name + " Boxed Struct</summary>");
sw.WriteLine("\t\t/// <remarks>");
sw.WriteLine("\t\t/// </remarks>");
sw.WriteLine ("\t[StructLayout(LayoutKind.Sequential)]");
sw.WriteLine ("\tpublic class " + Name + " : GLib.Boxed {");
sw.WriteLine ();
sw.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
sw.WriteLine();
Hashtable clash_map = new Hashtable();
foreach (XmlNode node in Elem.ChildNodes) {
if (!(node is XmlElement)) continue;
XmlElement member = (XmlElement) node;
switch (node.Name) {
case "field":
Statistics.IgnoreCount++;
// GenField(member, sw);
break;
case "callback":
Statistics.IgnoreCount++;
break;
case "constructor":
if (!GenCtor(member, sw, clash_map)) {
Console.WriteLine(" in boxed " + CName);
}
break;
case "method":
//Console.WriteLine ("HIYA {0}", ((Method) member).Name);
break;
default:
Console.WriteLine ("Unexpected node");
break;
}
}
GenMethods (sw, null, null, false);
AppendCustom(sw);
sw.WriteLine ("\t}");
CloseWriter (sw);
base.Generate ();
Statistics.BoxedCount++;
}
}

View file

@ -27,6 +27,13 @@ namespace GtkSharp.Generation {
}
}
public String MarshalReturnType {
get
{
return MarshalType;
}
}
public String CallByName (String var_name)
{
return var_name;
@ -37,6 +44,11 @@ namespace GtkSharp.Generation {
return var;
}
public String FromNativeReturn(String var)
{
return FromNative (var);
}
public void Generate ()
{
XmlElement ret_elem = Elem["return-type"];

View file

@ -17,6 +17,11 @@ namespace GtkSharp.Generation {
protected Hashtable sigs = new Hashtable();
protected Hashtable methods = new Hashtable();
protected ArrayList interfaces = null;
protected ArrayList ctors = new ArrayList();
private bool hasDefaultConstructor = true;
private bool ctors_initted = false;
private Hashtable clash_map;
public Hashtable Methods {
get {
@ -64,6 +69,14 @@ namespace GtkSharp.Generation {
interfaces = ParseImplements (member);
break;
case "constructor":
ctors.Add (new Ctor (LibraryName, member, this));
break;
case "disabledefaultconstructor":
hasDefaultConstructor = false;
break;
default:
break;
}
@ -77,6 +90,8 @@ namespace GtkSharp.Generation {
case "property":
case "signal":
case "implements":
case "constructor":
case "disabledefaultconstructor":
return true;
default:
@ -91,16 +106,33 @@ namespace GtkSharp.Generation {
}
}
public virtual String MarshalReturnType {
get
{
return "IntPtr";
}
}
public virtual String CallByName (String var_name)
{
return var_name + ".Handle";
}
public virtual String CallByName ()
{
return "Handle";
}
public virtual String FromNative(String var)
{
return "(" + QualifiedName + ") GLib.Object.GetObject(" + var + ")";
}
public virtual String FromNativeReturn(String var)
{
return FromNative (var);
}
protected void GenProperties (StreamWriter sw)
{
if (props == null)
@ -263,5 +295,61 @@ namespace GtkSharp.Generation {
else
return false;
}
public ArrayList Ctors { get { return ctors; } }
private void InitializeCtors ()
{
if (ctors_initted)
return;
clash_map = new Hashtable();
if (ctors != null) {
bool has_preferred = false;
foreach (Ctor ctor in ctors) {
if (ctor.Validate ()) {
ctor.InitClashMap (clash_map);
if (ctor.Preferred)
has_preferred = true;
}
else
Console.WriteLine(" in Object " + Name);
}
if (!has_preferred && ctors.Count > 0)
((Ctor) ctors[0]).Preferred = true;
foreach (Ctor ctor in ctors)
if (ctor.Validate ()) {
ctor.Initialize (clash_map);
}
}
ctors_initted = true;
}
protected virtual void GenCtors (StreamWriter sw)
{
ClassBase klass = this;
while (klass != null) {
klass.InitializeCtors ();
klass = klass.Parent;
}
if (ctors != null) {
foreach (Ctor ctor in ctors) {
if (ctor.Validate ())
ctor.Generate (sw);
}
}
if (!clash_map.ContainsKey("") && hasDefaultConstructor) {
sw.WriteLine("\t\tprotected " + Name + "() : base(){}");
sw.WriteLine();
}
}
}
}

View file

@ -20,7 +20,13 @@ namespace GtkSharp.Generation {
return "int";
}
}
public String MarshalReturnType {
get
{
return MarshalType;
}
}
public String CallByName (String var_name)
{
return "(int) " + var_name;
@ -31,6 +37,11 @@ namespace GtkSharp.Generation {
return "(" + QualifiedName + ")" + var;
}
public String FromNativeReturn(String var)
{
return FromNative (var);
}
public void Generate ()
{
StreamWriter sw = CreateWriter ();

View file

@ -14,6 +14,8 @@ namespace GtkSharp.Generation {
String MarshalType {get;}
String MarshalReturnType {get;}
String Name {get;}
String QualifiedName {get;}
@ -22,6 +24,8 @@ namespace GtkSharp.Generation {
String FromNative (String var);
String FromNativeReturn (String var);
void Generate ();
}
}

View file

@ -119,7 +119,7 @@ namespace GtkSharp.Generation {
}
rettype = ret_elem.GetAttribute("type");
m_ret = SymbolTable.GetMarshalType(rettype);
m_ret = SymbolTable.GetMarshalReturnType(rettype);
s_ret = SymbolTable.GetCSType(rettype);
cname = elem.GetAttribute("cname");
bool is_shared = elem.HasAttribute("shared");
@ -140,12 +140,12 @@ namespace GtkSharp.Generation {
if (parms != null) {
parms.CreateSignature (is_set);
sig = "(" + parms.Signature + ")";
isig = "(" + (is_shared ? "" : "IntPtr raw, ") + parms.ImportSig + ");";
call = "(" + (is_shared ? "" : "Handle, ") + parms.CallString + ")";
isig = "(" + (is_shared ? "" : container_type.MarshalType + " raw, ") + parms.ImportSig + ");";
call = "(" + (is_shared ? "" : container_type.CallByName () + ", ") + parms.CallString + ")";
} else {
sig = "()";
isig = "(" + (is_shared ? "" : "IntPtr raw") + ");";
call = "(" + (is_shared ? "" : "Handle") + ")";
isig = "(" + (is_shared ? "" : container_type.MarshalType + " raw") + ");";
call = "(" + (is_shared ? "" : container_type.CallByName ()) + ")";
}
initialized = true;
@ -343,14 +343,14 @@ namespace GtkSharp.Generation {
if (m_ret == "void") {
sw.WriteLine(cname + call + ";");
} else {
if (SymbolTable.IsObject (rettype))
if (SymbolTable.IsObject (rettype) || SymbolTable.IsOpaque (rettype))
{
sw.WriteLine(m_ret + " raw_ret = " + cname + call + ";");
sw.WriteLine(indent +"\t\t\t" + s_ret + " ret = " + SymbolTable.FromNative(rettype, "raw_ret") + ";");
sw.WriteLine(indent +"\t\t\t" + s_ret + " ret = " + SymbolTable.FromNativeReturn(rettype, "raw_ret") + ";");
sw.WriteLine(indent + "\t\t\tif (ret == null) ret = new " + s_ret + "(raw_ret);");
}
else
sw.WriteLine(s_ret + " ret = " + SymbolTable.FromNative(rettype, cname + call) + ";");
sw.WriteLine(s_ret + " ret = " + SymbolTable.FromNativeReturn(rettype, cname + call) + ";");
}
if (parms != null)

View file

@ -13,11 +13,7 @@ namespace GtkSharp.Generation {
public class ObjectGen : ClassBase, IGeneratable {
private ArrayList ctors = new ArrayList();
private ArrayList strings = new ArrayList();
private bool hasDefaultConstructor = true;
private bool ctors_initted = false;
private Hashtable clash_map;
public ObjectGen (XmlElement ns, XmlElement elem) : base (ns, elem)
{
@ -32,14 +28,6 @@ namespace GtkSharp.Generation {
Statistics.IgnoreCount++;
break;
case "constructor":
ctors.Add (new Ctor (LibraryName, member, this));
break;
case "disabledefaultconstructor":
hasDefaultConstructor = false;
break;
case "static-string":
strings.Add (node);
break;
@ -177,65 +165,16 @@ namespace GtkSharp.Generation {
return true;
}
public ArrayList Ctors { get { return ctors; } }
private void InitializeCtors ()
{
if (ctors_initted)
return;
clash_map = new Hashtable();
if (ctors != null) {
bool has_preferred = false;
foreach (Ctor ctor in ctors) {
if (ctor.Validate ()) {
ctor.InitClashMap (clash_map);
if (ctor.Preferred)
has_preferred = true;
}
else
Console.WriteLine(" in Object " + Name);
}
if (!has_preferred && ctors.Count > 0)
((Ctor) ctors[0]).Preferred = true;
foreach (Ctor ctor in ctors)
if (ctor.Validate ()) {
ctor.Initialize (clash_map);
}
}
ctors_initted = true;
}
private void GenCtors (StreamWriter sw)
protected override void GenCtors (StreamWriter sw)
{
if (!Elem.HasAttribute("parent"))
return;
ObjectGen klass = this;
while (klass != null) {
klass.InitializeCtors ();
klass = (ObjectGen) klass.Parent;
}
sw.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
sw.WriteLine();
if (ctors != null) {
foreach (Ctor ctor in ctors) {
if (ctor.Validate ())
ctor.Generate (sw);
}
}
if (!clash_map.ContainsKey("") && hasDefaultConstructor) {
sw.WriteLine("\t\tprotected " + Name + "() : base(){}");
sw.WriteLine();
}
base.GenCtors (sw);
}
}
}

78
generator/OpaqueGen.cs Normal file
View file

@ -0,0 +1,78 @@
// GtkSharp.Generation.ObjectGen.cs - The Object Generatable.
//
// Author: Mike Kestner <mkestner@speakeasy.net>
//
// (c) 2001-2002 Mike Kestner
namespace GtkSharp.Generation {
using System;
using System.Collections;
using System.IO;
using System.Xml;
public class OpaqueGen : ClassBase, IGeneratable {
public OpaqueGen (XmlElement ns, XmlElement elem) : base (ns, elem)
{
}
public override String FromNative(String var)
{
return "(" + QualifiedName + ") GLib.Opaque.GetOpaque(" + var + ")";
}
public override String FromNativeReturn(String var)
{
return FromNative (var);
}
public void Generate ()
{
StreamWriter sw = CreateWriter ();
sw.WriteLine ("\tusing System;");
sw.WriteLine ("\tusing System.Collections;");
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
sw.WriteLine ();
sw.WriteLine("\t\t/// <summary> " + Name + " Opaque Struct</summary>");
sw.WriteLine("\t\t/// <remarks>");
sw.WriteLine("\t\t/// </remarks>");
sw.Write ("\tpublic class {0} : GLib.Opaque", Name);
sw.WriteLine (" {");
sw.WriteLine ();
GenMethods (sw, null, null, true);
GenCtors (sw);
AppendCustom(sw);
sw.WriteLine ("\t}");
CloseWriter (sw);
Statistics.OpaqueCount++;
}
private bool Validate ()
{
if (methods != null)
foreach (Method method in methods.Values)
if (!method.Validate()) {
Console.WriteLine ("in Opaque" + QualifiedName);
return false;
}
return true;
}
protected override void GenCtors (StreamWriter sw)
{
sw.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
sw.WriteLine();
base.GenCtors (sw);
}
}
}

View file

@ -225,6 +225,9 @@ namespace GtkSharp.Generation {
call_string += call_parm;
}
import_sig += (m_type + " " + name);
// FIXME: lame
call_string = call_string.Replace ("out ref", "ref");
import_sig = import_sig.Replace ("out ref", "ref");
i++;
}
@ -247,7 +250,7 @@ namespace GtkSharp.Generation {
sw.WriteLine (indent + "\t\t\t" + type + " " + name + ";");
}
if ((is_get || (p_elem.HasAttribute("pass_as") && p_elem.GetAttribute ("pass_as") == "out")) && (SymbolTable.IsObject (c_type) || SymbolTable.IsBoxed (c_type))) {
if ((is_get || (p_elem.HasAttribute("pass_as") && p_elem.GetAttribute ("pass_as") == "out")) && (SymbolTable.IsObject (c_type) || SymbolTable.IsOpaque (c_type))) {
sw.WriteLine(indent + "\t\t\t" + name + " = new " + type + "();");
}
}

View file

@ -72,7 +72,10 @@ namespace GtkSharp.Generation {
break;
case "boxed":
SymbolTable.AddType (new BoxedGen (ns, elem));
if (elem.HasAttribute ("opaque"))
SymbolTable.AddType (new OpaqueGen (ns, elem));
else
SymbolTable.AddType (new BoxedGen (ns, elem));
break;
case "callback":
@ -92,7 +95,10 @@ namespace GtkSharp.Generation {
break;
case "struct":
SymbolTable.AddType (new StructGen (ns, elem));
if (elem.HasAttribute ("opaque"))
SymbolTable.AddType (new OpaqueGen (ns, elem));
else
SymbolTable.AddType (new StructGen (ns, elem));
break;
default:

View file

@ -77,6 +77,8 @@ namespace GtkSharp.Generation {
v_type = "(GLib.Object)";
} else if (SymbolTable.IsBoxed (c_type)) {
v_type = "(GLib.Boxed)";
} else if (SymbolTable.IsOpaque (c_type)) {
v_type = "(GLib.Opaque)";
}
if (elem.HasAttribute("construct-only") && !elem.HasAttribute("readable")) {
@ -93,19 +95,21 @@ namespace GtkSharp.Generation {
sw.WriteLine("\t\t\tget {");
sw.WriteLine("\t\t\t\tGLib.Value val = new GLib.Value (Handle, " + cname + ");");
sw.WriteLine("\t\t\t\tGetProperty(" + cname + ", val);");
if (SymbolTable.IsObject (c_type))
{
if (SymbolTable.IsObject (c_type) || SymbolTable.IsOpaque (c_type)) {
sw.WriteLine("\t\t\t\tSystem.IntPtr raw_ret = (System.IntPtr) (GLib.UnwrappedObject) val;");
sw.WriteLine("\t\t\t\t" + cs_type + " ret = " + SymbolTable.FromNative(c_type, "raw_ret") + ";");
sw.WriteLine("\t\t\t\t" + cs_type + " ret = " + SymbolTable.FromNativeReturn(c_type, "raw_ret") + ";");
sw.WriteLine("\t\t\t\tif (ret == null) ret = new " + cs_type + "(raw_ret);");
}
else {
} else {
sw.Write("\t\t\t\t" + cs_type + " ret = ");
sw.Write ("(" + cs_type + ") ");
if (v_type != "") {
sw.Write(v_type + " ");
if (SymbolTable.IsBoxed (c_type)) {
sw.WriteLine ("({0}) (({1} val).Obj);", cs_type, v_type);
} else {
sw.Write ("(" + cs_type + ") ");
if (v_type != "") {
sw.Write(v_type + " ");
}
sw.WriteLine("val;");
}
sw.WriteLine("val;");
}
sw.WriteLine("\t\t\t\treturn ret;");
@ -117,6 +121,8 @@ namespace GtkSharp.Generation {
sw.Write("\t\t\t\tSetProperty(" + cname + ", new GLib.Value(");
if (SymbolTable.IsEnum(c_type)) {
sw.WriteLine("Handle, " + cname + ", new GLib.EnumWrapper ((int) value)));");
} else if (SymbolTable.IsBoxed (c_type)) {
sw.WriteLine("Handle, " + cname + ", new GLib.Boxed (value)));");
} else {
if (v_type != "") {
sw.Write(v_type + " ");

View file

@ -31,7 +31,7 @@ namespace GtkSharp.Generation {
}
string s_ret = SymbolTable.GetCSType(retval);
string p_ret = SymbolTable.GetMarshalType(retval);
string p_ret = SymbolTable.GetMarshalReturnType(retval);
if ((s_ret == "") || (p_ret == "")) {
Console.Write("Funky type: " + retval);
return "";
@ -66,8 +66,6 @@ namespace GtkSharp.Generation {
pinv += ", ";
}
if (SymbolTable.IsStruct(type))
pinv += "ref ";
pinv += (ptype + " arg" + pcnt);
parms.Add(type);
if (SymbolTable.IsObject(type)) {
@ -156,7 +154,7 @@ namespace GtkSharp.Generation {
string ctype = (string) parms[idx];
sw.WriteLine("\t\t\targs.Args[" + (idx-1) + "] = " + SymbolTable.FromNative (ctype, "arg" + idx) + ";");
ClassBase wrapper = SymbolTable.GetClassGen (ctype);
if ((wrapper != null && !(wrapper is InterfaceGen)) || SymbolTable.IsManuallyWrapped (ctype) || SymbolTable.IsBoxed (ctype)) {
if ((wrapper != null && ((wrapper is ObjectGen) || (wrapper is OpaqueGen))) || SymbolTable.IsManuallyWrapped (ctype)) {
sw.WriteLine("\t\t\tif (args.Args[" + (idx-1) + "] == null)");
sw.WriteLine("\t\t\t\targs.Args[{0}] = new {1}(arg{2});", idx-1, SymbolTable.GetCSType (ctype), idx);
}

View file

@ -16,6 +16,7 @@ namespace GtkSharp.Generation {
static int objects = 0;
static int structs = 0;
static int boxed = 0;
static int opaques = 0;
static int interfaces = 0;
static int methods = 0;
static int ctors = 0;
@ -69,6 +70,15 @@ namespace GtkSharp.Generation {
}
}
public static int OpaqueCount {
get {
return opaques;
}
set {
opaques = value;
}
}
public static int CtorCount {
get {
return ctors;
@ -138,6 +148,7 @@ namespace GtkSharp.Generation {
Console.WriteLine("\tEnums: " + enums);
Console.WriteLine("\tStructs: " + structs);
Console.WriteLine("\tBoxed: " + boxed);
Console.WriteLine("\tOpaques: " + opaques);
Console.WriteLine("\tInterfaces: " + interfaces);
Console.WriteLine("\tCallbacks: " + cbs);
Console.WriteLine("\tObjects: " + objects);
@ -147,7 +158,7 @@ namespace GtkSharp.Generation {
Console.WriteLine("\tConstructors: " + ctors);
Console.WriteLine("\tThrottled: " + throttled);
Console.WriteLine("\tIgnored: " + ignored);
Console.WriteLine("Total Nodes: " + (enums+structs+boxed+interfaces+cbs+objects+props+sigs+methods+ctors+throttled+ignored));
Console.WriteLine("Total Nodes: " + (enums+structs+boxed+opaques+interfaces+cbs+objects+props+sigs+methods+ctors+throttled+ignored));
}
}
}

View file

@ -16,62 +16,38 @@ namespace GtkSharp.Generation {
public StructBase (XmlElement ns, XmlElement elem) : base (ns, elem) {}
protected bool GenCtor(XmlElement ctor, StreamWriter sw, Hashtable clash_map)
public override String MarshalType {
get
{
return "ref " + QualifiedName;
}
}
public override String MarshalReturnType {
get
{
return "IntPtr";
}
}
public override String CallByName (String var_name)
{
String sig, isig, call, sigtypes;
XmlElement parms = ctor["parameters"];
if (parms == null) {
call = sig = "()";
isig = "();";
sigtypes = "";
} else if (GetSignature(parms, out sig, out sigtypes) &&
GetImportSig(parms, out isig) &&
GetCallString(parms, out call)) {
sig = "(" + sig + ")";
isig = "(" + isig + ");";
call = "(" + call + ")";
} else {
Console.Write("ctor ");
Statistics.ThrottledCount++;
return false;
}
bool clash = false;
if (clash_map.ContainsKey(sigtypes)) {
clash = true;
} else {
clash_map[sigtypes] = ctor;
}
String cname = ctor.GetAttribute("cname");
sw.WriteLine("\t\t[DllImport(\"" + LibraryName + "\")]");
sw.WriteLine("\t\tstatic extern IntPtr " + cname + isig);
sw.WriteLine();
if (clash) {
String mname = cname.Substring(cname.IndexOf("new"));
mname = mname.Substring(0,1).ToUpper() + mname.Substring(1);
int idx;
while ((idx = mname.IndexOf("_")) > 0) {
mname = mname.Substring(0, idx) + mname.Substring(idx+1, 1).ToUpper() + mname.Substring(idx+2);
}
sw.WriteLine("\t\tpublic static " + Name + " " + mname + sig);
sw.WriteLine("\t\t{");
sw.WriteLine("\t\t\treturn new " + Name + "(" + cname + call + ");");
} else {
sw.WriteLine("\t\tpublic " + Name + sig);
sw.WriteLine("\t\t{");
sw.WriteLine("\t\t\tRaw = " + cname + call + ";");
}
sw.WriteLine("\t\t}");
sw.WriteLine();
Statistics.CtorCount++;
return true;
return "ref " + var_name;
}
public override String CallByName ()
{
return "ref this";
}
public override String FromNative(String var)
{
return var;
}
public override String FromNativeReturn(String var)
{
return "new " + QualifiedName + " (" + var + ")";
}
protected bool GenField (XmlElement field, StreamWriter sw)
@ -101,182 +77,6 @@ namespace GtkSharp.Generation {
return true;
}
protected bool GenMethod(XmlElement method, StreamWriter sw)
{
String sig, isig, call, sigtypes;
XmlElement parms = method["parameters"];
if (parms == null) {
call = "(Handle)";
sig = "()";
isig = "(IntPtr raw);";
sigtypes = "";
} else if (GetSignature(parms, out sig, out sigtypes) &&
GetImportSig(parms, out isig) &&
GetCallString(parms, out call)) {
sig = "(" + sig + ")";
isig = "(IntPtr raw, " + isig + ");";
call = "(Handle, " + call + ")";
} else {
Console.Write("method ");
Statistics.ThrottledCount++;
return false;
}
XmlElement ret_elem = method["return-type"];
if (ret_elem == null) {
Console.Write("Missing return type in method ");
Statistics.ThrottledCount++;
return false;
}
String rettype = ret_elem.GetAttribute("type");
String m_ret = SymbolTable.GetMarshalType(rettype);
String s_ret = SymbolTable.GetCSType(rettype);
if (m_ret == "" || s_ret == "") {
Console.Write("rettype: " + rettype + " method ");
Statistics.ThrottledCount++;
return false;
}
String cname = method.GetAttribute("cname");
String name = method.GetAttribute("name");
if (cname[0] == '_') {
Statistics.ThrottledCount++;
return true;
}
sw.WriteLine("\t\t[DllImport(\"" + LibraryName + "\")]");
sw.Write("\t\tstatic extern " + m_ret + " " + cname + isig);
sw.WriteLine();
sw.WriteLine("\t\tpublic " + s_ret + " " + name + sig);
sw.WriteLine("\t\t{");
sw.Write("\t\t\t");
if (m_ret == "void") {
sw.WriteLine(cname + call + ";");
} else {
sw.WriteLine("return " + SymbolTable.FromNative(rettype, cname + call) + ";");
}
sw.WriteLine("\t\t}");
sw.WriteLine();
Statistics.MethodCount++;
return true;
}
private bool GetCallString(XmlElement parms, out String call)
{
call = "";
bool need_comma = false;
foreach (XmlNode parm in parms.ChildNodes) {
if (!(parm is XmlElement) || parm.Name != "parameter") {
Console.Write(parm.Name + " node ");
return false;
}
XmlElement elem = (XmlElement) parm;
String type = elem.GetAttribute("type");
String name = elem.GetAttribute("name");
name = MangleName(name);
String call_parm = SymbolTable.CallByName(type, name);
if (call_parm == "") {
Console.Write("Name: " + name + " Type: " + type + " ");
return false;
}
if (need_comma) {
call += ", ";
} else {
need_comma = true;
}
call += call_parm;
}
return true;
}
private bool GetImportSig(XmlElement parms, out String isig)
{
isig = "";
bool need_comma = false;
foreach (XmlNode parm in parms.ChildNodes) {
if (!(parm is XmlElement) || parm.Name != "parameter") {
continue;
}
XmlElement elem = (XmlElement) parm;
String type = elem.GetAttribute("type");
String m_type = SymbolTable.GetMarshalType(type);
String name = elem.GetAttribute("name");
name = MangleName(name);
if ((m_type == "") || (name == "")) {
Console.Write("Name: " + name + " Type: " + type + " ");
return false;
}
if (elem.HasAttribute("array")) {
m_type += "[]";
}
if (need_comma) {
isig += ", ";
} else {
need_comma = true;
}
isig += (m_type + " " + name);
}
return true;
}
private bool GetSignature(XmlElement parms, out String sig, out String sigtypes)
{
sigtypes = sig = "";
bool need_comma = false;
foreach (XmlNode parm in parms.ChildNodes) {
if (parm.Name != "parameter") {
continue;
}
XmlElement elem = (XmlElement) parm;
String type = elem.GetAttribute("type");
String cs_type = SymbolTable.GetCSType(type);
String name = elem.GetAttribute("name");
name = MangleName(name);
if ((cs_type == "") || (name == "")) {
Console.Write("Name: " + name + " Type: " + type + " ");
return false;
}
if (elem.HasAttribute("array")) {
cs_type += "[]";
}
if (need_comma) {
sig += ", ";
sigtypes += ":";
} else {
need_comma = true;
}
sig += (cs_type + " " + name);
sigtypes += cs_type;
}
return true;
}
private String MangleName(String name)
{
if (name == "string") {
@ -291,6 +91,38 @@ namespace GtkSharp.Generation {
return name;
}
}
public virtual void Generate ()
{
StreamWriter sw = CreateWriter ();
sw.WriteLine ("\tusing System;");
sw.WriteLine ("\tusing System.Collections;");
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
sw.WriteLine ();
sw.WriteLine("\t\t/// <summary> " + Name + " Struct </summary>");
sw.WriteLine("\t\t/// <remarks>");
sw.WriteLine("\t\t/// </remarks>");
sw.WriteLine ("\t[StructLayout(LayoutKind.Sequential)]");
sw.WriteLine ("\tpublic struct " + Name + " {");
sw.WriteLine ();
GenCtors (sw);
AppendCustom(sw);
sw.WriteLine ("\t}");
CloseWriter (sw);
}
protected override void GenCtors (StreamWriter sw)
{
sw.WriteLine("\t\tpublic " + Name + "(IntPtr raw) {}");
sw.WriteLine();
//base.GenCtors (sw);
}
}
}

View file

@ -14,72 +14,9 @@ namespace GtkSharp.Generation {
public StructGen (XmlElement ns, XmlElement elem) : base (ns, elem) {}
public override string MarshalType {
get
{
return QualifiedName;
}
}
public override String CallByName (String var_name)
public override void Generate ()
{
return var_name;
}
public override String FromNative(String var)
{
return var;
}
public void Generate ()
{
StreamWriter sw = CreateWriter ();
sw.WriteLine ("\tusing System;");
sw.WriteLine ("\tusing System.Collections;");
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
sw.WriteLine ();
sw.WriteLine("\t\t/// <summary> " + Name + " Struct </summary>");
sw.WriteLine("\t\t/// <remarks>");
sw.WriteLine("\t\t/// </remarks>");
sw.WriteLine ("\t[StructLayout(LayoutKind.Sequential)]");
sw.WriteLine ("\tpublic struct " + Name + " {");
sw.WriteLine ();
foreach (XmlNode node in Elem.ChildNodes) {
if (!(node is XmlElement)) continue;
XmlElement member = (XmlElement) node;
switch (node.Name) {
case "field":
Statistics.IgnoreCount++;
// GenField(member, sw);
break;
case "callback":
Statistics.IgnoreCount++;
break;
case "constructor":
Statistics.IgnoreCount++;
break;
case "method":
Statistics.IgnoreCount++;
break;
default:
Console.WriteLine ("Unexpected node");
break;
}
}
AppendCustom(sw);
sw.WriteLine ("\t}");
CloseWriter (sw);
base.Generate ();
Statistics.StructCount++;
}
}

View file

@ -123,7 +123,17 @@ namespace GtkSharp.Generation {
return type;
}
public static string FromNativeReturn(string c_type, string val)
{
return FromNative (c_type, val, true);
}
public static string FromNative(string c_type, string val)
{
return FromNative (c_type, val, false);
}
public static string FromNative(string c_type, string val, bool ret)
{
c_type = Trim(c_type);
c_type = DeAlias(c_type);
@ -131,7 +141,10 @@ namespace GtkSharp.Generation {
return val;
} else if (complex_types.ContainsKey(c_type)) {
IGeneratable gen = (IGeneratable) complex_types[c_type];
return gen.FromNative(val);
if (ret)
return gen.FromNativeReturn(val);
else
return gen.FromNative(val);
} else if (manually_wrapped_types.ContainsKey(c_type)) {
// FIXME: better way of handling this?
if (c_type == "GSList") {
@ -184,7 +197,17 @@ namespace GtkSharp.Generation {
}
}
public static string GetMarshalReturnType(string c_type)
{
return GetMarshalType (c_type, true);
}
public static string GetMarshalType(string c_type)
{
return GetMarshalType (c_type, false);
}
public static string GetMarshalType(string c_type, bool ret)
{
c_type = Trim(c_type);
c_type = DeAlias(c_type);
@ -194,7 +217,10 @@ namespace GtkSharp.Generation {
return "IntPtr";
} else if (complex_types.ContainsKey(c_type)) {
IGeneratable gen = (IGeneratable) complex_types[c_type];
return gen.MarshalType;
if (ret)
return gen.MarshalReturnType;
else
return gen.MarshalType;
} else {
return "";
}
@ -215,7 +241,20 @@ namespace GtkSharp.Generation {
return "";
}
}
public static bool IsOpaque(string c_type)
{
c_type = Trim(c_type);
c_type = DeAlias(c_type);
if (complex_types.ContainsKey(c_type)) {
IGeneratable gen = (IGeneratable) complex_types[c_type];
if (gen is OpaqueGen) {
return true;
}
}
return false;
}
public static bool IsBoxed(string c_type)
{
c_type = Trim(c_type);
@ -272,10 +311,7 @@ namespace GtkSharp.Generation {
{
c_type = Trim(c_type);
c_type = DeAlias(c_type);
if (IsInterface(c_type) || IsObject (c_type)) {
return (ClassBase) complex_types[c_type];
}
return null;
return (complex_types[c_type] as ClassBase);
}
public static bool IsObject(string c_type)

View file

@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<api>
<namespace name="Gnome" library="gnomecanvas-2">
<object name="Canvas" cname="GnomeCanvas" parent="GtkLayout">
@ -1659,7 +1659,7 @@
<field cname="instance_init" type="GnomeModuleHook"/>
<field cname="pre_args_parse" type="GnomeModuleHook"/>
<field cname="post_args_parse" type="GnomeModuleHook"/>
<field cname="poptOption* options" type="struct"/>
<field cname="options" type="struct-poptOption*"/>
<field cname="init_pass" type="GnomeModuleInitHook"/>
<field cname="class_init" type="GnomeModuleClassInitHook"/>
<field cname="opt_prefix" type="const-char*"/>
@ -1674,12 +1674,7 @@
</struct>
<struct name="Trigger" cname="GnomeTrigger">
<field cname="type" type="GnomeTriggerType"/>
<field cname="{GnomeTriggerActionFunction function" type="union"/>
<field cname="command" type="gchar*"/>
<field cname="{gchar* file" type="struct"/>
<field cname="cache_id" type="int"/>
<field cname="media" type="}"/>
<field cname="u" type="}"/>
<field cname="function" type="GnomeTriggerActionFunction"/>
<field cname="level" type="gchar*"/>
<method name="TypeGetType" cname="gnome_trigger_type_get_type" shared="true">
<return-type type="GType"/>
@ -3367,10 +3362,7 @@
<field cname="send_event" type="gint8"/>
<field cname="message_type" type="GdkAtom"/>
<field cname="data_format" type="gushort"/>
<field cname="b" array_len="20" type="union"/>
<field cname="s" array_len="10" type="short"/>
<field cname="l" array_len="5" type="long"/>
<field cname="data" type="}"/>
<field cname="b" array_len="20" type="char"/>
</struct>
<struct name="EventConfigure" cname="GdkEventConfigure">
<field cname="type" type="GdkEventType"/>
@ -10425,7 +10417,7 @@
</method>
</object>
<object name="TextView" cname="GtkTextView" parent="GtkContainer">
<field cname="_GtkTextLayout* layout" type="struct"/>
<field cname="layout" type="struct-_GtkTextLayout*"/>
<field cname="buffer" type="GtkTextBuffer*"/>
<field cname="selection_drag_handler" type="guint"/>
<field cname="scroll_timeout" type="guint"/>
@ -13829,10 +13821,7 @@
</struct>
<struct name="BindingArg" cname="GtkBindingArg">
<field cname="arg_type" type="GtkType"/>
<field cname="{glong long_data" type="union"/>
<field cname="double_data" type="gdouble"/>
<field cname="string_data" type="gchar*"/>
<field cname="d" type="}"/>
<field cname="long_data" type="glong"/>
</struct>
<struct name="BindingEntry" cname="GtkBindingEntry">
<field cname="keyval" type="guint"/>
@ -14881,12 +14870,7 @@
<field cname="next" type="GtkTextLineSegment*"/>
<field cname="char_count" type="int"/>
<field cname="byte_count" type="int"/>
<field cname="chars" array_len="4" type="union"/>
<field cname="toggle" type="GtkTextToggleBody"/>
<field cname="mark" type="GtkTextMarkBody"/>
<field cname="pixbuf" type="GtkTextPixbuf"/>
<field cname="child" type="GtkTextChildBody"/>
<field cname="body" type="}"/>
<field cname="chars" array_len="4" type="char"/>
<method name="Split" cname="gtk_text_line_segment_split" shared="true">
<return-type type="GtkTextLineSegment*"/>
<parameters>
@ -14943,18 +14927,7 @@
</struct>
<struct name="TreeDataList" cname="GtkTreeDataList">
<field cname="next" type="GtkTreeDataList*"/>
<field cname="{gint v_int" type="union"/>
<field cname="v_char" type="gint8"/>
<field cname="v_uchar" type="guint8"/>
<field cname="v_uint" type="guint"/>
<field cname="v_long" type="glong"/>
<field cname="v_ulong" type="gulong"/>
<field cname="v_int64" type="gint64"/>
<field cname="v_uint64" type="guint64"/>
<field cname="v_float" type="gfloat"/>
<field cname="v_double" type="gdouble"/>
<field cname="v_pointer" type="gpointer"/>
<field cname="data" type="}"/>
<field cname="v_int" type="gint"/>
<method name="CompareFunc" cname="gtk_tree_data_list_compare_func" shared="true">
<return-type type="gint"/>
<parameters>
@ -17664,6 +17637,8 @@
<member cname="GTK_HTML_COMMAND_KILL_WORD" name="KillWord"/>
<member cname="GTK_HTML_COMMAND_KILL_WORD_BACKWARD" name="KillWordBackward"/>
<member cname="GTK_HTML_COMMAND_TEXT_COLOR_APPLY" name="TextColorApply"/>
<member cname="GTK_HTML_COMMAND_SAVE_DATA_ON" name="SaveDataOn"/>
<member cname="GTK_HTML_COMMAND_SAVE_DATA_OFF" name="SaveDataOff"/>
</enum>
<enum name="HTMLCursorSkipType" cname="GtkHTMLCursorSkipType" type="enum">
<member cname="GTK_HTML_CURSOR_SKIP_ONE" name="One"/>

View file

@ -16,11 +16,8 @@ namespace GLib {
/// An abstract base class to derive structures and marshal them.
/// </remarks>
public abstract class Boxed {
private IntPtr raw;
public Boxed () : this (IntPtr.Zero) {}
public class Boxed {
object raw;
/// <summary>
/// Boxed Constructor
@ -30,7 +27,7 @@ namespace GLib {
/// Constructs a Boxed type from a raw ref.
/// </remarks>
public Boxed (IntPtr raw)
public Boxed (object o)
{
this.raw = raw;
}
@ -43,7 +40,7 @@ namespace GLib {
/// Gets a marshallable IntPtr.
/// </remarks>
public virtual IntPtr Handle {
public virtual object Obj {
get {
return raw;
}
@ -51,36 +48,5 @@ namespace GLib {
raw = value;
}
}
/// <summary>
/// Raw Property
/// </summary>
///
/// <remarks>
/// Gets or sets a marshallable IntPtr.
/// </remarks>
protected IntPtr Raw {
get {
return raw;
}
set {
raw = value;
}
}
/// <summary>
/// FromNative Method
/// </summary>
///
/// <remarks>
/// Gets a Boxed type from a raw IntPtr.
/// </remarks>
public static GLib.Boxed FromNative (IntPtr raw)
{
// FIXME:
return null;
}
}
}

138
glib/Opaque.cs Normal file
View file

@ -0,0 +1,138 @@
// Object.cs - GObject class wrapper implementation
//
// Authors: Bob Smith <bob@thestuff.net>
// Mike Kestner <mkestner@speakeasy.net>
//
// (c) 2001 Bob Smith and Mike Kestner
namespace GLib {
using System;
using System.Collections;
using System.ComponentModel;
using System.Runtime.InteropServices;
/// <summary>
/// Object Class
/// </summary>
///
/// <remarks>
/// Wrapper class for GObject.
/// </remarks>
public class Opaque : IWrapper {
// Private class and instance members
IntPtr _obj;
EventHandlerList _events;
Hashtable Data;
static Hashtable Opaques = new Hashtable();
/// <summary>
/// GetObject Shared Method
/// </summary>
///
/// <remarks>
/// Used to obtain a CLI typed object associated with a
/// given raw object pointer. This method is primarily
/// used to wrap object references that are returned
/// by either the signal system or raw class methods that
/// return GObject references.
/// </remarks>
///
/// <returns>
/// The wrapper instance.
/// </returns>
public static Opaque GetOpaque(IntPtr o)
{
Opaque obj = (Opaque)Opaques[(int)o];
if (obj != null) return obj;
return null; //FIXME: Call TypeParser here eventually.
}
/// <summary>
/// Object Constructor
/// </summary>
///
/// <remarks>
/// Dummy constructor needed for derived classes.
/// </remarks>
public Opaque () {}
/// <summary>
/// Object Constructor
/// </summary>
///
/// <remarks>
/// Creates an object from a raw object reference.
/// </remarks>
public Opaque (IntPtr raw)
{
Raw = raw;
}
/// <summary>
/// Raw Property
/// </summary>
///
/// <remarks>
/// The raw GObject reference associated with this wrapper.
/// Only subclasses of Object can access this read/write
/// property. For public read-only access, use the
/// Handle property.
/// </remarks>
protected IntPtr Raw {
get {
return _obj;
}
set {
Opaques [value] = this;
_obj = value;
}
}
/// <summary>
/// Handle Property
/// </summary>
///
/// <remarks>
/// The raw GObject reference associated with this object.
/// Subclasses can use Raw property for read/write
/// access.
/// </remarks>
public IntPtr Handle {
get {
return _obj;
}
set {
_obj = value;
}
}
public override bool Equals (object o)
{
if (!(o is Opaque))
return false;
return (Handle == ((Opaque) o).Handle);
}
/// <summary>
/// GetHashCode Method
/// </summary>
///
/// <remarks>
/// Calculates a hashing value.
/// </remarks>
public override int GetHashCode ()
{
return Handle.GetHashCode ();
}
}
}

View file

@ -95,6 +95,18 @@ namespace GLib {
/// </remarks>
public Value (GLib.Boxed val)
{
_val = gtksharp_value_create(TypeFundamentals.TypeBoxed);
//g_value_set_boxed (_val, val.Handle);
}
public Value (IntPtr obj, string prop_name, Boxed val)
{
_val = gtksharp_value_create_from_property (obj, prop_name);
//g_value_set_boxed (_val, val.Handle);
}
public Value (GLib.Opaque val)
{
_val = gtksharp_value_create(TypeFundamentals.TypeBoxed);
g_value_set_boxed (_val, val.Handle);
@ -259,6 +271,11 @@ namespace GLib {
[DllImport("gobject-2.0")]
static extern IntPtr g_value_get_boxed (IntPtr val);
public static explicit operator GLib.Opaque (Value val)
{
return GLib.Opaque.GetOpaque (g_value_get_boxed (val._val));
}
/// <summary>
/// Value to Boxed Conversion
/// </summary>

View file

@ -2,7 +2,6 @@ lib_LTLIBRARIES = libgtksharpglue.la
BASESOURCES = \
value.c \
textiter.c \
fileselection.c \
dialog.c \
colorseldialog.c \

View file

@ -1,23 +0,0 @@
/* textiter.c : Glue to allocate GtkTextIters on the heap.
*
* Author: Rachel Hestilow <hestilow@ximian.com>
*
* <c> 2002 Rachel Hestilow, Mike Kestner
*/
#include <gtk/gtktextiter.h>
GtkTextIter*
gtksharp_text_iter_create (void)
{
GtkTextIter *iter = g_new0 (GtkTextIter, 1);
return iter;
}
void
gtksharp_test_array (int len, int* types)
{
int i;
for (i = 0; i < len; i++)
g_print ("type %i\n", types[i]);
}

View file

@ -19,7 +19,7 @@ struct PropertyArg {
[DllImport("gtksharpglue")]
static extern System.IntPtr
gtksharp_gnome_program_init (string app_id, string app_version, System.IntPtr module, int argc, string[] argv, int nargs, PropertyArg[] args);
gtksharp_gnome_program_init (string app_id, string app_version, ref ModuleInfo module, int argc, string[] argv, int nargs, PropertyArg[] args);
public Program (string app_id, string app_version, ModuleInfo module,
string[] argv, params object[] props)
@ -51,7 +51,7 @@ public Program (string app_id, string app_version, ModuleInfo module,
/* FIXME: Is there a way to access this in .NET? */
new_argv[0] = app_id;
Array.Copy (argv, 0, new_argv, 1, argv.Length);
Raw = gtksharp_gnome_program_init (app_id, app_version, module.Handle, new_argv.Length, new_argv, nargs, args);
Raw = gtksharp_gnome_program_init (app_id, app_version, ref module, new_argv.Length, new_argv, nargs, args);
}
public void Run ()

View file

@ -1,30 +0,0 @@
// Gtk.TextIter.custom - Gtk TextIter class customizations
//
// Author: Rachel Hestilow <hestilow@ximian.com>
//
// (c) 2001 Mike Kestner, 2002 Rachel Hestilow
//
// This code is inserted after the automatically generated code.
/// <summary>
/// TextIter Constructor
/// </summary>
///
/// <remarks>
/// Constructs a new TextIter.
[DllImport("gtksharpglue")]
static extern IntPtr gtksharp_text_iter_create();
public TextIter () : this (gtksharp_text_iter_create ())
{
}
[DllImport("glib-2.0")]
static extern void g_free (IntPtr mem);
~TextIter ()
{
g_free (Handle);
}

View file

@ -127,12 +127,26 @@ sub fixupParams {
}
}
sub myGetChildrenByTagName {
my ($node, $tagname) = @_;
my ($child);
my (@nodes) = ();
for ($child = $node->firstChild; $child; $child = $child->nextSibling ()) {
if ($child->nodeName eq $tagname) {
push @nodes, $child;
}
}
return @nodes;
}
sub addClassData {
my ($doc, $node, $class, $data_list_ref) = @_;
foreach $data (@$data_list_ref) {
if ($$data[1] eq "class") {
my @nodes = $node->getChildrenByTagName ($$data[5]);
# my copy of XML::LibXML doesn't have this method.
#my @nodes = $node->getChildrenByTagName ($$data[5]);
my @nodes = myGetChildrenByTagName ($node, $$data[5]);
if (0 == scalar @nodes) {
print STDERR "DEBUG> $class $$data[0] $$data[1] $$data[2] $$data[3] $$data[4] $$data[5] $$data[6]\n";

View file

@ -127,12 +127,26 @@ sub fixupParams {
}
}
sub myGetChildrenByTagName {
my ($node, $tagname) = @_;
my ($child);
my (@nodes) = ();
for ($child = $node->firstChild; $child; $child = $child->nextSibling ()) {
if ($child->nodeName eq $tagname) {
push @nodes, $child;
}
}
return @nodes;
}
sub addClassData {
my ($doc, $node, $class, $data_list_ref) = @_;
foreach $data (@$data_list_ref) {
if ($$data[1] eq "class") {
my @nodes = $node->getChildrenByTagName ($$data[5]);
# my copy of XML::LibXML doesn't have this method.
#my @nodes = $node->getChildrenByTagName ($$data[5]);
my @nodes = myGetChildrenByTagName ($node, $$data[5]);
if (0 == scalar @nodes) {
print STDERR "DEBUG> $class $$data[0] $$data[1] $$data[2] $$data[3] $$data[4] $$data[5] $$data[6]\n";

View file

@ -3,9 +3,9 @@ Put source modules here to parse for the gtkapi.xml file.
Currently supported:
glib-2.0.3
pango-1.0.2
pango-1.0.3
atk-1.0.2
gtk+-2.0.3
gtk+-2.0.5
libgnome-2.0.1
libgnomecanvas-2.0.1
libgnomeui-2.0.1

View file

@ -394,6 +394,7 @@ sub addFieldElems
next if ($field !~ /\S/);
$field =~ s/\s+(\*+)/\1 /g;
$field =~ s/const /const\-/g;
$field =~ s/struct /struct\-/g;
$field =~ s/.*\*\///g;
next if ($field !~ /\S/);

View file

@ -66,6 +66,16 @@ foreach $fname (@hdrs) {
while ($line !~ /^}\s*\w+;/) {$line = <INFILE>;}
} elsif ($line =~ /^enum\s+\{/) {
while ($line !~ /^};/) {$line = <INFILE>;}
} elsif ($line =~ /(\s+)union\s*{/) {
# this is a hack for now, but I need it for the fields to work
$indent = $1;
$do_print = 1;
while ($line !~ /^$indent}\s*\w+;/) {
$line = <INFILE>;
next if ($line !~ /;/);
print $line if $do_print;
$do_print = 0;
}
} else {
if ($braces or $line =~ /;/) {
print $line;

View file

@ -67,12 +67,12 @@ namespace WidgetViewer {
static void Color_Selection_OK (object o, EventArgs args)
{
Gdk.Color selected = window.ColorSelection.CurrentColor;
/*
if (selected == null) {
Console.WriteLine ("Color selection failed.");
return;
}
*/
Display_Result (selected);
}
@ -85,10 +85,10 @@ namespace WidgetViewer {
static void Display_Result (Gdk.Color color)
{
/*
if (color == null)
Console.WriteLine ("Null color");
*/
dialog = new Dialog ();
dialog.Title = "Selected Color";

View file

@ -3,9 +3,9 @@ Put source modules here to parse for the gtkapi.xml file.
Currently supported:
glib-2.0.3
pango-1.0.2
pango-1.0.3
atk-1.0.2
gtk+-2.0.3
gtk+-2.0.5
libgnome-2.0.1
libgnomecanvas-2.0.1
libgnomeui-2.0.1