mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-17 03:44:53 +02:00
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:
parent
dd71eaf3ea
commit
4d92d54b3f
47
ChangeLog
47
ChangeLog
@ -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>
|
2002-07-24 Mike Kestner <mkestner@speakeasy.net>
|
||||||
|
|
||||||
* generator/SignalHandler.cs : use ref parameters in signal cb's.
|
* generator/SignalHandler.cs : use ref parameters in signal cb's.
|
||||||
|
@ -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>
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||||
//
|
//
|
||||||
// (c) 2001-2002 Mike Kestner
|
// (c) 2001 Mike Kestner
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
@ -15,67 +14,9 @@ namespace GtkSharp.Generation {
|
|||||||
|
|
||||||
public BoxedGen (XmlElement ns, XmlElement elem) : base (ns, elem) {}
|
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 + ")";
|
base.Generate ();
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
Statistics.BoxedCount++;
|
Statistics.BoxedCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,13 @@ namespace GtkSharp.Generation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String MarshalReturnType {
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return MarshalType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String CallByName (String var_name)
|
public String CallByName (String var_name)
|
||||||
{
|
{
|
||||||
return var_name;
|
return var_name;
|
||||||
@ -37,6 +44,11 @@ namespace GtkSharp.Generation {
|
|||||||
return var;
|
return var;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String FromNativeReturn(String var)
|
||||||
|
{
|
||||||
|
return FromNative (var);
|
||||||
|
}
|
||||||
|
|
||||||
public void Generate ()
|
public void Generate ()
|
||||||
{
|
{
|
||||||
XmlElement ret_elem = Elem["return-type"];
|
XmlElement ret_elem = Elem["return-type"];
|
||||||
|
@ -17,6 +17,11 @@ namespace GtkSharp.Generation {
|
|||||||
protected Hashtable sigs = new Hashtable();
|
protected Hashtable sigs = new Hashtable();
|
||||||
protected Hashtable methods = new Hashtable();
|
protected Hashtable methods = new Hashtable();
|
||||||
protected ArrayList interfaces = null;
|
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 {
|
public Hashtable Methods {
|
||||||
get {
|
get {
|
||||||
@ -64,6 +69,14 @@ namespace GtkSharp.Generation {
|
|||||||
interfaces = ParseImplements (member);
|
interfaces = ParseImplements (member);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "constructor":
|
||||||
|
ctors.Add (new Ctor (LibraryName, member, this));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "disabledefaultconstructor":
|
||||||
|
hasDefaultConstructor = false;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -77,6 +90,8 @@ namespace GtkSharp.Generation {
|
|||||||
case "property":
|
case "property":
|
||||||
case "signal":
|
case "signal":
|
||||||
case "implements":
|
case "implements":
|
||||||
|
case "constructor":
|
||||||
|
case "disabledefaultconstructor":
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -91,16 +106,33 @@ namespace GtkSharp.Generation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual String MarshalReturnType {
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "IntPtr";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public virtual String CallByName (String var_name)
|
public virtual String CallByName (String var_name)
|
||||||
{
|
{
|
||||||
return var_name + ".Handle";
|
return var_name + ".Handle";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual String CallByName ()
|
||||||
|
{
|
||||||
|
return "Handle";
|
||||||
|
}
|
||||||
|
|
||||||
public virtual String FromNative(String var)
|
public virtual String FromNative(String var)
|
||||||
{
|
{
|
||||||
return "(" + QualifiedName + ") GLib.Object.GetObject(" + var + ")";
|
return "(" + QualifiedName + ") GLib.Object.GetObject(" + var + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual String FromNativeReturn(String var)
|
||||||
|
{
|
||||||
|
return FromNative (var);
|
||||||
|
}
|
||||||
|
|
||||||
protected void GenProperties (StreamWriter sw)
|
protected void GenProperties (StreamWriter sw)
|
||||||
{
|
{
|
||||||
if (props == null)
|
if (props == null)
|
||||||
@ -263,5 +295,61 @@ namespace GtkSharp.Generation {
|
|||||||
else
|
else
|
||||||
return false;
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,12 @@ namespace GtkSharp.Generation {
|
|||||||
return "int";
|
return "int";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public String MarshalReturnType {
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return MarshalType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String CallByName (String var_name)
|
public String CallByName (String var_name)
|
||||||
{
|
{
|
||||||
@ -31,6 +37,11 @@ namespace GtkSharp.Generation {
|
|||||||
return "(" + QualifiedName + ")" + var;
|
return "(" + QualifiedName + ")" + var;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String FromNativeReturn(String var)
|
||||||
|
{
|
||||||
|
return FromNative (var);
|
||||||
|
}
|
||||||
|
|
||||||
public void Generate ()
|
public void Generate ()
|
||||||
{
|
{
|
||||||
StreamWriter sw = CreateWriter ();
|
StreamWriter sw = CreateWriter ();
|
||||||
|
@ -14,6 +14,8 @@ namespace GtkSharp.Generation {
|
|||||||
|
|
||||||
String MarshalType {get;}
|
String MarshalType {get;}
|
||||||
|
|
||||||
|
String MarshalReturnType {get;}
|
||||||
|
|
||||||
String Name {get;}
|
String Name {get;}
|
||||||
|
|
||||||
String QualifiedName {get;}
|
String QualifiedName {get;}
|
||||||
@ -22,6 +24,8 @@ namespace GtkSharp.Generation {
|
|||||||
|
|
||||||
String FromNative (String var);
|
String FromNative (String var);
|
||||||
|
|
||||||
|
String FromNativeReturn (String var);
|
||||||
|
|
||||||
void Generate ();
|
void Generate ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ namespace GtkSharp.Generation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rettype = ret_elem.GetAttribute("type");
|
rettype = ret_elem.GetAttribute("type");
|
||||||
m_ret = SymbolTable.GetMarshalType(rettype);
|
m_ret = SymbolTable.GetMarshalReturnType(rettype);
|
||||||
s_ret = SymbolTable.GetCSType(rettype);
|
s_ret = SymbolTable.GetCSType(rettype);
|
||||||
cname = elem.GetAttribute("cname");
|
cname = elem.GetAttribute("cname");
|
||||||
bool is_shared = elem.HasAttribute("shared");
|
bool is_shared = elem.HasAttribute("shared");
|
||||||
@ -140,12 +140,12 @@ namespace GtkSharp.Generation {
|
|||||||
if (parms != null) {
|
if (parms != null) {
|
||||||
parms.CreateSignature (is_set);
|
parms.CreateSignature (is_set);
|
||||||
sig = "(" + parms.Signature + ")";
|
sig = "(" + parms.Signature + ")";
|
||||||
isig = "(" + (is_shared ? "" : "IntPtr raw, ") + parms.ImportSig + ");";
|
isig = "(" + (is_shared ? "" : container_type.MarshalType + " raw, ") + parms.ImportSig + ");";
|
||||||
call = "(" + (is_shared ? "" : "Handle, ") + parms.CallString + ")";
|
call = "(" + (is_shared ? "" : container_type.CallByName () + ", ") + parms.CallString + ")";
|
||||||
} else {
|
} else {
|
||||||
sig = "()";
|
sig = "()";
|
||||||
isig = "(" + (is_shared ? "" : "IntPtr raw") + ");";
|
isig = "(" + (is_shared ? "" : container_type.MarshalType + " raw") + ");";
|
||||||
call = "(" + (is_shared ? "" : "Handle") + ")";
|
call = "(" + (is_shared ? "" : container_type.CallByName ()) + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
@ -343,14 +343,14 @@ namespace GtkSharp.Generation {
|
|||||||
if (m_ret == "void") {
|
if (m_ret == "void") {
|
||||||
sw.WriteLine(cname + call + ";");
|
sw.WriteLine(cname + call + ";");
|
||||||
} else {
|
} else {
|
||||||
if (SymbolTable.IsObject (rettype))
|
if (SymbolTable.IsObject (rettype) || SymbolTable.IsOpaque (rettype))
|
||||||
{
|
{
|
||||||
sw.WriteLine(m_ret + " raw_ret = " + cname + call + ";");
|
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);");
|
sw.WriteLine(indent + "\t\t\tif (ret == null) ret = new " + s_ret + "(raw_ret);");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sw.WriteLine(s_ret + " ret = " + SymbolTable.FromNative(rettype, cname + call) + ";");
|
sw.WriteLine(s_ret + " ret = " + SymbolTable.FromNativeReturn(rettype, cname + call) + ";");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parms != null)
|
if (parms != null)
|
||||||
|
@ -13,11 +13,7 @@ namespace GtkSharp.Generation {
|
|||||||
|
|
||||||
public class ObjectGen : ClassBase, IGeneratable {
|
public class ObjectGen : ClassBase, IGeneratable {
|
||||||
|
|
||||||
private ArrayList ctors = new ArrayList();
|
|
||||||
private ArrayList strings = 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)
|
public ObjectGen (XmlElement ns, XmlElement elem) : base (ns, elem)
|
||||||
{
|
{
|
||||||
@ -32,14 +28,6 @@ namespace GtkSharp.Generation {
|
|||||||
Statistics.IgnoreCount++;
|
Statistics.IgnoreCount++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "constructor":
|
|
||||||
ctors.Add (new Ctor (LibraryName, member, this));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "disabledefaultconstructor":
|
|
||||||
hasDefaultConstructor = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "static-string":
|
case "static-string":
|
||||||
strings.Add (node);
|
strings.Add (node);
|
||||||
break;
|
break;
|
||||||
@ -178,64 +166,15 @@ namespace GtkSharp.Generation {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList Ctors { get { return ctors; } }
|
protected override void GenCtors (StreamWriter sw)
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
if (!Elem.HasAttribute("parent"))
|
if (!Elem.HasAttribute("parent"))
|
||||||
return;
|
return;
|
||||||
ObjectGen klass = this;
|
|
||||||
while (klass != null) {
|
|
||||||
klass.InitializeCtors ();
|
|
||||||
klass = (ObjectGen) klass.Parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
sw.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
|
sw.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
|
|
||||||
if (ctors != null) {
|
base.GenCtors (sw);
|
||||||
foreach (Ctor ctor in ctors) {
|
|
||||||
if (ctor.Validate ())
|
|
||||||
ctor.Generate (sw);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!clash_map.ContainsKey("") && hasDefaultConstructor) {
|
|
||||||
sw.WriteLine("\t\tprotected " + Name + "() : base(){}");
|
|
||||||
sw.WriteLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
78
generator/OpaqueGen.cs
Normal file
78
generator/OpaqueGen.cs
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -225,6 +225,9 @@ namespace GtkSharp.Generation {
|
|||||||
call_string += call_parm;
|
call_string += call_parm;
|
||||||
}
|
}
|
||||||
import_sig += (m_type + " " + name);
|
import_sig += (m_type + " " + name);
|
||||||
|
// FIXME: lame
|
||||||
|
call_string = call_string.Replace ("out ref", "ref");
|
||||||
|
import_sig = import_sig.Replace ("out ref", "ref");
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -247,7 +250,7 @@ namespace GtkSharp.Generation {
|
|||||||
sw.WriteLine (indent + "\t\t\t" + type + " " + name + ";");
|
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 + "();");
|
sw.WriteLine(indent + "\t\t\t" + name + " = new " + type + "();");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,9 @@ namespace GtkSharp.Generation {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "boxed":
|
case "boxed":
|
||||||
|
if (elem.HasAttribute ("opaque"))
|
||||||
|
SymbolTable.AddType (new OpaqueGen (ns, elem));
|
||||||
|
else
|
||||||
SymbolTable.AddType (new BoxedGen (ns, elem));
|
SymbolTable.AddType (new BoxedGen (ns, elem));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -92,6 +95,9 @@ namespace GtkSharp.Generation {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "struct":
|
case "struct":
|
||||||
|
if (elem.HasAttribute ("opaque"))
|
||||||
|
SymbolTable.AddType (new OpaqueGen (ns, elem));
|
||||||
|
else
|
||||||
SymbolTable.AddType (new StructGen (ns, elem));
|
SymbolTable.AddType (new StructGen (ns, elem));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -77,6 +77,8 @@ namespace GtkSharp.Generation {
|
|||||||
v_type = "(GLib.Object)";
|
v_type = "(GLib.Object)";
|
||||||
} else if (SymbolTable.IsBoxed (c_type)) {
|
} else if (SymbolTable.IsBoxed (c_type)) {
|
||||||
v_type = "(GLib.Boxed)";
|
v_type = "(GLib.Boxed)";
|
||||||
|
} else if (SymbolTable.IsOpaque (c_type)) {
|
||||||
|
v_type = "(GLib.Opaque)";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem.HasAttribute("construct-only") && !elem.HasAttribute("readable")) {
|
if (elem.HasAttribute("construct-only") && !elem.HasAttribute("readable")) {
|
||||||
@ -93,20 +95,22 @@ namespace GtkSharp.Generation {
|
|||||||
sw.WriteLine("\t\t\tget {");
|
sw.WriteLine("\t\t\tget {");
|
||||||
sw.WriteLine("\t\t\t\tGLib.Value val = new GLib.Value (Handle, " + cname + ");");
|
sw.WriteLine("\t\t\t\tGLib.Value val = new GLib.Value (Handle, " + cname + ");");
|
||||||
sw.WriteLine("\t\t\t\tGetProperty(" + cname + ", val);");
|
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\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);");
|
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("\t\t\t\t" + cs_type + " ret = ");
|
||||||
|
if (SymbolTable.IsBoxed (c_type)) {
|
||||||
|
sw.WriteLine ("({0}) (({1} val).Obj);", cs_type, v_type);
|
||||||
|
} else {
|
||||||
sw.Write ("(" + cs_type + ") ");
|
sw.Write ("(" + cs_type + ") ");
|
||||||
if (v_type != "") {
|
if (v_type != "") {
|
||||||
sw.Write(v_type + " ");
|
sw.Write(v_type + " ");
|
||||||
}
|
}
|
||||||
sw.WriteLine("val;");
|
sw.WriteLine("val;");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sw.WriteLine("\t\t\t\treturn ret;");
|
sw.WriteLine("\t\t\t\treturn ret;");
|
||||||
sw.WriteLine("\t\t\t}");
|
sw.WriteLine("\t\t\t}");
|
||||||
@ -117,6 +121,8 @@ namespace GtkSharp.Generation {
|
|||||||
sw.Write("\t\t\t\tSetProperty(" + cname + ", new GLib.Value(");
|
sw.Write("\t\t\t\tSetProperty(" + cname + ", new GLib.Value(");
|
||||||
if (SymbolTable.IsEnum(c_type)) {
|
if (SymbolTable.IsEnum(c_type)) {
|
||||||
sw.WriteLine("Handle, " + cname + ", new GLib.EnumWrapper ((int) value)));");
|
sw.WriteLine("Handle, " + cname + ", new GLib.EnumWrapper ((int) value)));");
|
||||||
|
} else if (SymbolTable.IsBoxed (c_type)) {
|
||||||
|
sw.WriteLine("Handle, " + cname + ", new GLib.Boxed (value)));");
|
||||||
} else {
|
} else {
|
||||||
if (v_type != "") {
|
if (v_type != "") {
|
||||||
sw.Write(v_type + " ");
|
sw.Write(v_type + " ");
|
||||||
|
@ -31,7 +31,7 @@ namespace GtkSharp.Generation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
string s_ret = SymbolTable.GetCSType(retval);
|
string s_ret = SymbolTable.GetCSType(retval);
|
||||||
string p_ret = SymbolTable.GetMarshalType(retval);
|
string p_ret = SymbolTable.GetMarshalReturnType(retval);
|
||||||
if ((s_ret == "") || (p_ret == "")) {
|
if ((s_ret == "") || (p_ret == "")) {
|
||||||
Console.Write("Funky type: " + retval);
|
Console.Write("Funky type: " + retval);
|
||||||
return "";
|
return "";
|
||||||
@ -66,8 +66,6 @@ namespace GtkSharp.Generation {
|
|||||||
pinv += ", ";
|
pinv += ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SymbolTable.IsStruct(type))
|
|
||||||
pinv += "ref ";
|
|
||||||
pinv += (ptype + " arg" + pcnt);
|
pinv += (ptype + " arg" + pcnt);
|
||||||
parms.Add(type);
|
parms.Add(type);
|
||||||
if (SymbolTable.IsObject(type)) {
|
if (SymbolTable.IsObject(type)) {
|
||||||
@ -156,7 +154,7 @@ namespace GtkSharp.Generation {
|
|||||||
string ctype = (string) parms[idx];
|
string ctype = (string) parms[idx];
|
||||||
sw.WriteLine("\t\t\targs.Args[" + (idx-1) + "] = " + SymbolTable.FromNative (ctype, "arg" + idx) + ";");
|
sw.WriteLine("\t\t\targs.Args[" + (idx-1) + "] = " + SymbolTable.FromNative (ctype, "arg" + idx) + ";");
|
||||||
ClassBase wrapper = SymbolTable.GetClassGen (ctype);
|
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\tif (args.Args[" + (idx-1) + "] == null)");
|
||||||
sw.WriteLine("\t\t\t\targs.Args[{0}] = new {1}(arg{2});", idx-1, SymbolTable.GetCSType (ctype), idx);
|
sw.WriteLine("\t\t\t\targs.Args[{0}] = new {1}(arg{2});", idx-1, SymbolTable.GetCSType (ctype), idx);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ namespace GtkSharp.Generation {
|
|||||||
static int objects = 0;
|
static int objects = 0;
|
||||||
static int structs = 0;
|
static int structs = 0;
|
||||||
static int boxed = 0;
|
static int boxed = 0;
|
||||||
|
static int opaques = 0;
|
||||||
static int interfaces = 0;
|
static int interfaces = 0;
|
||||||
static int methods = 0;
|
static int methods = 0;
|
||||||
static int ctors = 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 {
|
public static int CtorCount {
|
||||||
get {
|
get {
|
||||||
return ctors;
|
return ctors;
|
||||||
@ -138,6 +148,7 @@ namespace GtkSharp.Generation {
|
|||||||
Console.WriteLine("\tEnums: " + enums);
|
Console.WriteLine("\tEnums: " + enums);
|
||||||
Console.WriteLine("\tStructs: " + structs);
|
Console.WriteLine("\tStructs: " + structs);
|
||||||
Console.WriteLine("\tBoxed: " + boxed);
|
Console.WriteLine("\tBoxed: " + boxed);
|
||||||
|
Console.WriteLine("\tOpaques: " + opaques);
|
||||||
Console.WriteLine("\tInterfaces: " + interfaces);
|
Console.WriteLine("\tInterfaces: " + interfaces);
|
||||||
Console.WriteLine("\tCallbacks: " + cbs);
|
Console.WriteLine("\tCallbacks: " + cbs);
|
||||||
Console.WriteLine("\tObjects: " + objects);
|
Console.WriteLine("\tObjects: " + objects);
|
||||||
@ -147,7 +158,7 @@ namespace GtkSharp.Generation {
|
|||||||
Console.WriteLine("\tConstructors: " + ctors);
|
Console.WriteLine("\tConstructors: " + ctors);
|
||||||
Console.WriteLine("\tThrottled: " + throttled);
|
Console.WriteLine("\tThrottled: " + throttled);
|
||||||
Console.WriteLine("\tIgnored: " + ignored);
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,62 +16,38 @@ namespace GtkSharp.Generation {
|
|||||||
|
|
||||||
public StructBase (XmlElement ns, XmlElement elem) : base (ns, elem) {}
|
public StructBase (XmlElement ns, XmlElement elem) : base (ns, elem) {}
|
||||||
|
|
||||||
protected bool GenCtor(XmlElement ctor, StreamWriter sw, Hashtable clash_map)
|
public override String MarshalType {
|
||||||
|
get
|
||||||
{
|
{
|
||||||
String sig, isig, call, sigtypes;
|
return "ref " + QualifiedName;
|
||||||
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;
|
public override String MarshalReturnType {
|
||||||
if (clash_map.ContainsKey(sigtypes)) {
|
get
|
||||||
clash = true;
|
{
|
||||||
} else {
|
return "IntPtr";
|
||||||
clash_map[sigtypes] = ctor;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String cname = ctor.GetAttribute("cname");
|
public override String CallByName (String var_name)
|
||||||
|
{
|
||||||
sw.WriteLine("\t\t[DllImport(\"" + LibraryName + "\")]");
|
return "ref " + var_name;
|
||||||
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);
|
public override String CallByName ()
|
||||||
sw.WriteLine("\t\t{");
|
{
|
||||||
sw.WriteLine("\t\t\treturn new " + Name + "(" + cname + call + ");");
|
return "ref this";
|
||||||
} else {
|
|
||||||
sw.WriteLine("\t\tpublic " + Name + sig);
|
|
||||||
sw.WriteLine("\t\t{");
|
|
||||||
sw.WriteLine("\t\t\tRaw = " + cname + call + ";");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.WriteLine("\t\t}");
|
public override String FromNative(String var)
|
||||||
sw.WriteLine();
|
{
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
Statistics.CtorCount++;
|
public override String FromNativeReturn(String var)
|
||||||
return true;
|
{
|
||||||
|
return "new " + QualifiedName + " (" + var + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool GenField (XmlElement field, StreamWriter sw)
|
protected bool GenField (XmlElement field, StreamWriter sw)
|
||||||
@ -101,182 +77,6 @@ namespace GtkSharp.Generation {
|
|||||||
return true;
|
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)
|
private String MangleName(String name)
|
||||||
{
|
{
|
||||||
if (name == "string") {
|
if (name == "string") {
|
||||||
@ -291,6 +91,38 @@ namespace GtkSharp.Generation {
|
|||||||
return name;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,72 +14,9 @@ namespace GtkSharp.Generation {
|
|||||||
|
|
||||||
public StructGen (XmlElement ns, XmlElement elem) : base (ns, elem) {}
|
public StructGen (XmlElement ns, XmlElement elem) : base (ns, elem) {}
|
||||||
|
|
||||||
public override string MarshalType {
|
public override void Generate ()
|
||||||
get
|
|
||||||
{
|
{
|
||||||
return QualifiedName;
|
base.Generate ();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override String CallByName (String var_name)
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
Statistics.StructCount++;
|
Statistics.StructCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,17 @@ namespace GtkSharp.Generation {
|
|||||||
return type;
|
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)
|
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 = Trim(c_type);
|
||||||
c_type = DeAlias(c_type);
|
c_type = DeAlias(c_type);
|
||||||
@ -131,6 +141,9 @@ namespace GtkSharp.Generation {
|
|||||||
return val;
|
return val;
|
||||||
} else if (complex_types.ContainsKey(c_type)) {
|
} else if (complex_types.ContainsKey(c_type)) {
|
||||||
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
||||||
|
if (ret)
|
||||||
|
return gen.FromNativeReturn(val);
|
||||||
|
else
|
||||||
return gen.FromNative(val);
|
return gen.FromNative(val);
|
||||||
} else if (manually_wrapped_types.ContainsKey(c_type)) {
|
} else if (manually_wrapped_types.ContainsKey(c_type)) {
|
||||||
// FIXME: better way of handling this?
|
// FIXME: better way of handling this?
|
||||||
@ -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)
|
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 = Trim(c_type);
|
||||||
c_type = DeAlias(c_type);
|
c_type = DeAlias(c_type);
|
||||||
@ -194,6 +217,9 @@ namespace GtkSharp.Generation {
|
|||||||
return "IntPtr";
|
return "IntPtr";
|
||||||
} else if (complex_types.ContainsKey(c_type)) {
|
} else if (complex_types.ContainsKey(c_type)) {
|
||||||
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
||||||
|
if (ret)
|
||||||
|
return gen.MarshalReturnType;
|
||||||
|
else
|
||||||
return gen.MarshalType;
|
return gen.MarshalType;
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
@ -216,6 +242,19 @@ namespace GtkSharp.Generation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
public static bool IsBoxed(string c_type)
|
||||||
{
|
{
|
||||||
c_type = Trim(c_type);
|
c_type = Trim(c_type);
|
||||||
@ -272,10 +311,7 @@ namespace GtkSharp.Generation {
|
|||||||
{
|
{
|
||||||
c_type = Trim(c_type);
|
c_type = Trim(c_type);
|
||||||
c_type = DeAlias(c_type);
|
c_type = DeAlias(c_type);
|
||||||
if (IsInterface(c_type) || IsObject (c_type)) {
|
return (complex_types[c_type] as ClassBase);
|
||||||
return (ClassBase) complex_types[c_type];
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsObject(string c_type)
|
public static bool IsObject(string c_type)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<api>
|
<api>
|
||||||
<namespace name="Gnome" library="gnomecanvas-2">
|
<namespace name="Gnome" library="gnomecanvas-2">
|
||||||
<object name="Canvas" cname="GnomeCanvas" parent="GtkLayout">
|
<object name="Canvas" cname="GnomeCanvas" parent="GtkLayout">
|
||||||
@ -1659,7 +1659,7 @@
|
|||||||
<field cname="instance_init" type="GnomeModuleHook"/>
|
<field cname="instance_init" type="GnomeModuleHook"/>
|
||||||
<field cname="pre_args_parse" type="GnomeModuleHook"/>
|
<field cname="pre_args_parse" type="GnomeModuleHook"/>
|
||||||
<field cname="post_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="init_pass" type="GnomeModuleInitHook"/>
|
||||||
<field cname="class_init" type="GnomeModuleClassInitHook"/>
|
<field cname="class_init" type="GnomeModuleClassInitHook"/>
|
||||||
<field cname="opt_prefix" type="const-char*"/>
|
<field cname="opt_prefix" type="const-char*"/>
|
||||||
@ -1674,12 +1674,7 @@
|
|||||||
</struct>
|
</struct>
|
||||||
<struct name="Trigger" cname="GnomeTrigger">
|
<struct name="Trigger" cname="GnomeTrigger">
|
||||||
<field cname="type" type="GnomeTriggerType"/>
|
<field cname="type" type="GnomeTriggerType"/>
|
||||||
<field cname="{GnomeTriggerActionFunction function" type="union"/>
|
<field cname="function" type="GnomeTriggerActionFunction"/>
|
||||||
<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="level" type="gchar*"/>
|
<field cname="level" type="gchar*"/>
|
||||||
<method name="TypeGetType" cname="gnome_trigger_type_get_type" shared="true">
|
<method name="TypeGetType" cname="gnome_trigger_type_get_type" shared="true">
|
||||||
<return-type type="GType"/>
|
<return-type type="GType"/>
|
||||||
@ -3367,10 +3362,7 @@
|
|||||||
<field cname="send_event" type="gint8"/>
|
<field cname="send_event" type="gint8"/>
|
||||||
<field cname="message_type" type="GdkAtom"/>
|
<field cname="message_type" type="GdkAtom"/>
|
||||||
<field cname="data_format" type="gushort"/>
|
<field cname="data_format" type="gushort"/>
|
||||||
<field cname="b" array_len="20" type="union"/>
|
<field cname="b" array_len="20" type="char"/>
|
||||||
<field cname="s" array_len="10" type="short"/>
|
|
||||||
<field cname="l" array_len="5" type="long"/>
|
|
||||||
<field cname="data" type="}"/>
|
|
||||||
</struct>
|
</struct>
|
||||||
<struct name="EventConfigure" cname="GdkEventConfigure">
|
<struct name="EventConfigure" cname="GdkEventConfigure">
|
||||||
<field cname="type" type="GdkEventType"/>
|
<field cname="type" type="GdkEventType"/>
|
||||||
@ -10425,7 +10417,7 @@
|
|||||||
</method>
|
</method>
|
||||||
</object>
|
</object>
|
||||||
<object name="TextView" cname="GtkTextView" parent="GtkContainer">
|
<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="buffer" type="GtkTextBuffer*"/>
|
||||||
<field cname="selection_drag_handler" type="guint"/>
|
<field cname="selection_drag_handler" type="guint"/>
|
||||||
<field cname="scroll_timeout" type="guint"/>
|
<field cname="scroll_timeout" type="guint"/>
|
||||||
@ -13829,10 +13821,7 @@
|
|||||||
</struct>
|
</struct>
|
||||||
<struct name="BindingArg" cname="GtkBindingArg">
|
<struct name="BindingArg" cname="GtkBindingArg">
|
||||||
<field cname="arg_type" type="GtkType"/>
|
<field cname="arg_type" type="GtkType"/>
|
||||||
<field cname="{glong long_data" type="union"/>
|
<field cname="long_data" type="glong"/>
|
||||||
<field cname="double_data" type="gdouble"/>
|
|
||||||
<field cname="string_data" type="gchar*"/>
|
|
||||||
<field cname="d" type="}"/>
|
|
||||||
</struct>
|
</struct>
|
||||||
<struct name="BindingEntry" cname="GtkBindingEntry">
|
<struct name="BindingEntry" cname="GtkBindingEntry">
|
||||||
<field cname="keyval" type="guint"/>
|
<field cname="keyval" type="guint"/>
|
||||||
@ -14881,12 +14870,7 @@
|
|||||||
<field cname="next" type="GtkTextLineSegment*"/>
|
<field cname="next" type="GtkTextLineSegment*"/>
|
||||||
<field cname="char_count" type="int"/>
|
<field cname="char_count" type="int"/>
|
||||||
<field cname="byte_count" type="int"/>
|
<field cname="byte_count" type="int"/>
|
||||||
<field cname="chars" array_len="4" type="union"/>
|
<field cname="chars" array_len="4" type="char"/>
|
||||||
<field cname="toggle" type="GtkTextToggleBody"/>
|
|
||||||
<field cname="mark" type="GtkTextMarkBody"/>
|
|
||||||
<field cname="pixbuf" type="GtkTextPixbuf"/>
|
|
||||||
<field cname="child" type="GtkTextChildBody"/>
|
|
||||||
<field cname="body" type="}"/>
|
|
||||||
<method name="Split" cname="gtk_text_line_segment_split" shared="true">
|
<method name="Split" cname="gtk_text_line_segment_split" shared="true">
|
||||||
<return-type type="GtkTextLineSegment*"/>
|
<return-type type="GtkTextLineSegment*"/>
|
||||||
<parameters>
|
<parameters>
|
||||||
@ -14943,18 +14927,7 @@
|
|||||||
</struct>
|
</struct>
|
||||||
<struct name="TreeDataList" cname="GtkTreeDataList">
|
<struct name="TreeDataList" cname="GtkTreeDataList">
|
||||||
<field cname="next" type="GtkTreeDataList*"/>
|
<field cname="next" type="GtkTreeDataList*"/>
|
||||||
<field cname="{gint v_int" type="union"/>
|
<field cname="v_int" type="gint"/>
|
||||||
<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="}"/>
|
|
||||||
<method name="CompareFunc" cname="gtk_tree_data_list_compare_func" shared="true">
|
<method name="CompareFunc" cname="gtk_tree_data_list_compare_func" shared="true">
|
||||||
<return-type type="gint"/>
|
<return-type type="gint"/>
|
||||||
<parameters>
|
<parameters>
|
||||||
@ -17664,6 +17637,8 @@
|
|||||||
<member cname="GTK_HTML_COMMAND_KILL_WORD" name="KillWord"/>
|
<member cname="GTK_HTML_COMMAND_KILL_WORD" name="KillWord"/>
|
||||||
<member cname="GTK_HTML_COMMAND_KILL_WORD_BACKWARD" name="KillWordBackward"/>
|
<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_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>
|
||||||
<enum name="HTMLCursorSkipType" cname="GtkHTMLCursorSkipType" type="enum">
|
<enum name="HTMLCursorSkipType" cname="GtkHTMLCursorSkipType" type="enum">
|
||||||
<member cname="GTK_HTML_CURSOR_SKIP_ONE" name="One"/>
|
<member cname="GTK_HTML_CURSOR_SKIP_ONE" name="One"/>
|
||||||
|
@ -16,11 +16,8 @@ namespace GLib {
|
|||||||
/// An abstract base class to derive structures and marshal them.
|
/// An abstract base class to derive structures and marshal them.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
|
||||||
public abstract class Boxed {
|
public class Boxed {
|
||||||
|
object raw;
|
||||||
private IntPtr raw;
|
|
||||||
|
|
||||||
public Boxed () : this (IntPtr.Zero) {}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Boxed Constructor
|
/// Boxed Constructor
|
||||||
@ -30,7 +27,7 @@ namespace GLib {
|
|||||||
/// Constructs a Boxed type from a raw ref.
|
/// Constructs a Boxed type from a raw ref.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
|
||||||
public Boxed (IntPtr raw)
|
public Boxed (object o)
|
||||||
{
|
{
|
||||||
this.raw = raw;
|
this.raw = raw;
|
||||||
}
|
}
|
||||||
@ -43,7 +40,7 @@ namespace GLib {
|
|||||||
/// Gets a marshallable IntPtr.
|
/// Gets a marshallable IntPtr.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
|
||||||
public virtual IntPtr Handle {
|
public virtual object Obj {
|
||||||
get {
|
get {
|
||||||
return raw;
|
return raw;
|
||||||
}
|
}
|
||||||
@ -51,36 +48,5 @@ namespace GLib {
|
|||||||
raw = value;
|
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
138
glib/Opaque.cs
Normal 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 ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -95,6 +95,18 @@ namespace GLib {
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
|
||||||
public Value (GLib.Boxed val)
|
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);
|
_val = gtksharp_value_create(TypeFundamentals.TypeBoxed);
|
||||||
g_value_set_boxed (_val, val.Handle);
|
g_value_set_boxed (_val, val.Handle);
|
||||||
@ -259,6 +271,11 @@ namespace GLib {
|
|||||||
[DllImport("gobject-2.0")]
|
[DllImport("gobject-2.0")]
|
||||||
static extern IntPtr g_value_get_boxed (IntPtr val);
|
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>
|
/// <summary>
|
||||||
/// Value to Boxed Conversion
|
/// Value to Boxed Conversion
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -2,7 +2,6 @@ lib_LTLIBRARIES = libgtksharpglue.la
|
|||||||
|
|
||||||
BASESOURCES = \
|
BASESOURCES = \
|
||||||
value.c \
|
value.c \
|
||||||
textiter.c \
|
|
||||||
fileselection.c \
|
fileselection.c \
|
||||||
dialog.c \
|
dialog.c \
|
||||||
colorseldialog.c \
|
colorseldialog.c \
|
||||||
|
@ -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]);
|
|
||||||
}
|
|
@ -19,7 +19,7 @@ struct PropertyArg {
|
|||||||
|
|
||||||
[DllImport("gtksharpglue")]
|
[DllImport("gtksharpglue")]
|
||||||
static extern System.IntPtr
|
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,
|
public Program (string app_id, string app_version, ModuleInfo module,
|
||||||
string[] argv, params object[] props)
|
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? */
|
/* FIXME: Is there a way to access this in .NET? */
|
||||||
new_argv[0] = app_id;
|
new_argv[0] = app_id;
|
||||||
Array.Copy (argv, 0, new_argv, 1, argv.Length);
|
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 ()
|
public void Run ()
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
|
|
@ -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 {
|
sub addClassData {
|
||||||
my ($doc, $node, $class, $data_list_ref) = @_;
|
my ($doc, $node, $class, $data_list_ref) = @_;
|
||||||
|
|
||||||
foreach $data (@$data_list_ref) {
|
foreach $data (@$data_list_ref) {
|
||||||
if ($$data[1] eq "class") {
|
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) {
|
if (0 == scalar @nodes) {
|
||||||
print STDERR "DEBUG> $class $$data[0] $$data[1] $$data[2] $$data[3] $$data[4] $$data[5] $$data[6]\n";
|
print STDERR "DEBUG> $class $$data[0] $$data[1] $$data[2] $$data[3] $$data[4] $$data[5] $$data[6]\n";
|
||||||
|
@ -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 {
|
sub addClassData {
|
||||||
my ($doc, $node, $class, $data_list_ref) = @_;
|
my ($doc, $node, $class, $data_list_ref) = @_;
|
||||||
|
|
||||||
foreach $data (@$data_list_ref) {
|
foreach $data (@$data_list_ref) {
|
||||||
if ($$data[1] eq "class") {
|
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) {
|
if (0 == scalar @nodes) {
|
||||||
print STDERR "DEBUG> $class $$data[0] $$data[1] $$data[2] $$data[3] $$data[4] $$data[5] $$data[6]\n";
|
print STDERR "DEBUG> $class $$data[0] $$data[1] $$data[2] $$data[3] $$data[4] $$data[5] $$data[6]\n";
|
||||||
|
@ -3,9 +3,9 @@ Put source modules here to parse for the gtkapi.xml file.
|
|||||||
Currently supported:
|
Currently supported:
|
||||||
|
|
||||||
glib-2.0.3
|
glib-2.0.3
|
||||||
pango-1.0.2
|
pango-1.0.3
|
||||||
atk-1.0.2
|
atk-1.0.2
|
||||||
gtk+-2.0.3
|
gtk+-2.0.5
|
||||||
libgnome-2.0.1
|
libgnome-2.0.1
|
||||||
libgnomecanvas-2.0.1
|
libgnomecanvas-2.0.1
|
||||||
libgnomeui-2.0.1
|
libgnomeui-2.0.1
|
||||||
|
@ -394,6 +394,7 @@ sub addFieldElems
|
|||||||
next if ($field !~ /\S/);
|
next if ($field !~ /\S/);
|
||||||
$field =~ s/\s+(\*+)/\1 /g;
|
$field =~ s/\s+(\*+)/\1 /g;
|
||||||
$field =~ s/const /const\-/g;
|
$field =~ s/const /const\-/g;
|
||||||
|
$field =~ s/struct /struct\-/g;
|
||||||
$field =~ s/.*\*\///g;
|
$field =~ s/.*\*\///g;
|
||||||
next if ($field !~ /\S/);
|
next if ($field !~ /\S/);
|
||||||
|
|
||||||
|
@ -66,6 +66,16 @@ foreach $fname (@hdrs) {
|
|||||||
while ($line !~ /^}\s*\w+;/) {$line = <INFILE>;}
|
while ($line !~ /^}\s*\w+;/) {$line = <INFILE>;}
|
||||||
} elsif ($line =~ /^enum\s+\{/) {
|
} elsif ($line =~ /^enum\s+\{/) {
|
||||||
while ($line !~ /^};/) {$line = <INFILE>;}
|
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 {
|
} else {
|
||||||
if ($braces or $line =~ /;/) {
|
if ($braces or $line =~ /;/) {
|
||||||
print $line;
|
print $line;
|
||||||
|
@ -67,12 +67,12 @@ namespace WidgetViewer {
|
|||||||
static void Color_Selection_OK (object o, EventArgs args)
|
static void Color_Selection_OK (object o, EventArgs args)
|
||||||
{
|
{
|
||||||
Gdk.Color selected = window.ColorSelection.CurrentColor;
|
Gdk.Color selected = window.ColorSelection.CurrentColor;
|
||||||
|
/*
|
||||||
if (selected == null) {
|
if (selected == null) {
|
||||||
Console.WriteLine ("Color selection failed.");
|
Console.WriteLine ("Color selection failed.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
Display_Result (selected);
|
Display_Result (selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,10 +85,10 @@ namespace WidgetViewer {
|
|||||||
|
|
||||||
static void Display_Result (Gdk.Color color)
|
static void Display_Result (Gdk.Color color)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if (color == null)
|
if (color == null)
|
||||||
Console.WriteLine ("Null color");
|
Console.WriteLine ("Null color");
|
||||||
|
*/
|
||||||
dialog = new Dialog ();
|
dialog = new Dialog ();
|
||||||
dialog.Title = "Selected Color";
|
dialog.Title = "Selected Color";
|
||||||
|
|
||||||
|
@ -3,9 +3,9 @@ Put source modules here to parse for the gtkapi.xml file.
|
|||||||
Currently supported:
|
Currently supported:
|
||||||
|
|
||||||
glib-2.0.3
|
glib-2.0.3
|
||||||
pango-1.0.2
|
pango-1.0.3
|
||||||
atk-1.0.2
|
atk-1.0.2
|
||||||
gtk+-2.0.3
|
gtk+-2.0.5
|
||||||
libgnome-2.0.1
|
libgnome-2.0.1
|
||||||
libgnomecanvas-2.0.1
|
libgnomecanvas-2.0.1
|
||||||
libgnomeui-2.0.1
|
libgnomeui-2.0.1
|
||||||
|
Loading…
Reference in New Issue
Block a user