2002-05-23 23:43:25 +00:00
|
|
|
// GtkSharp.Generation.Parameters.cs - The Parameters Generation Class.
|
|
|
|
//
|
|
|
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
|
|
|
//
|
|
|
|
// (c) 2001-2002 Mike Kestner
|
|
|
|
|
|
|
|
namespace GtkSharp.Generation {
|
|
|
|
|
|
|
|
using System;
|
2003-09-11 06:10:03 +00:00
|
|
|
using System.Collections;
|
2002-06-10 12:34:09 +00:00
|
|
|
using System.IO;
|
2002-05-23 23:43:25 +00:00
|
|
|
using System.Xml;
|
|
|
|
|
2002-07-16 23:14:35 +00:00
|
|
|
public class Parameter {
|
|
|
|
|
|
|
|
private XmlElement elem;
|
|
|
|
|
|
|
|
public Parameter (XmlElement e)
|
|
|
|
{
|
|
|
|
elem = e;
|
|
|
|
}
|
|
|
|
|
2002-08-28 20:58:01 +00:00
|
|
|
public string CType {
|
|
|
|
get {
|
2002-10-11 00:27:46 +00:00
|
|
|
string type = elem.GetAttribute("type");
|
|
|
|
if (type == "void*")
|
|
|
|
type = "gpointer";
|
|
|
|
return type;
|
2002-08-28 20:58:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-16 23:14:35 +00:00
|
|
|
public string CSType {
|
|
|
|
get {
|
2003-05-19 02:45:17 +00:00
|
|
|
string cstype = SymbolTable.Table.GetCSType( elem.GetAttribute("type"));
|
2002-10-11 00:27:46 +00:00
|
|
|
if (cstype == "void")
|
|
|
|
cstype = "System.IntPtr";
|
2003-09-12 06:38:29 +00:00
|
|
|
if (IsArray) {
|
2002-08-28 20:58:01 +00:00
|
|
|
cstype += "[]";
|
2003-02-24 03:13:08 +00:00
|
|
|
cstype = cstype.Replace ("ref ", "");
|
|
|
|
}
|
2002-08-28 20:58:01 +00:00
|
|
|
return cstype;
|
2002-07-16 23:14:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-14 17:30:32 +00:00
|
|
|
public IGeneratable Generatable {
|
|
|
|
get {
|
|
|
|
return SymbolTable.Table[CType];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-12 06:38:29 +00:00
|
|
|
public bool IsArray {
|
|
|
|
get {
|
|
|
|
return elem.HasAttribute("array");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-11 06:10:03 +00:00
|
|
|
public bool IsEllipsis {
|
|
|
|
get {
|
|
|
|
return elem.HasAttribute("ellipsis");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-17 03:44:32 +00:00
|
|
|
public bool IsCount {
|
|
|
|
get {
|
|
|
|
|
|
|
|
if (Name.StartsWith("n_"))
|
|
|
|
switch (CSType) {
|
|
|
|
case "int":
|
|
|
|
case "uint":
|
|
|
|
case "long":
|
|
|
|
case "ulong":
|
|
|
|
case "short":
|
|
|
|
case "ushort":
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-02-24 03:13:08 +00:00
|
|
|
public bool IsLength {
|
|
|
|
get {
|
2003-09-11 05:11:18 +00:00
|
|
|
|
|
|
|
if (Name.EndsWith("len") || Name.EndsWith("length"))
|
|
|
|
switch (CSType) {
|
|
|
|
case "int":
|
|
|
|
case "uint":
|
|
|
|
case "long":
|
|
|
|
case "ulong":
|
|
|
|
case "short":
|
|
|
|
case "ushort":
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
2003-02-24 03:13:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool IsString {
|
|
|
|
get {
|
|
|
|
return (CSType == "string");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-12 06:38:29 +00:00
|
|
|
public bool IsUserData {
|
|
|
|
get {
|
|
|
|
return CType == "gpointer" && (Name.EndsWith ("data") || Name.EndsWith ("data_or_owner"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-04 04:23:13 +00:00
|
|
|
public string MarshalType {
|
|
|
|
get {
|
2003-05-19 02:45:17 +00:00
|
|
|
string type = SymbolTable.Table.GetMarshalType( elem.GetAttribute("type"));
|
2002-10-11 00:27:46 +00:00
|
|
|
if (type == "void")
|
|
|
|
type = "System.IntPtr";
|
2003-09-12 06:38:29 +00:00
|
|
|
if (IsArray) {
|
2003-02-24 03:13:08 +00:00
|
|
|
type += "[]";
|
|
|
|
type = type.Replace ("ref ", "");
|
|
|
|
}
|
2002-10-11 00:27:46 +00:00
|
|
|
return type;
|
2002-08-04 04:23:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-16 23:14:35 +00:00
|
|
|
public string Name {
|
|
|
|
get {
|
2003-08-28 16:49:29 +00:00
|
|
|
return SymbolTable.Table.MangleName (elem.GetAttribute("name"));
|
2002-07-16 23:14:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-14 17:30:32 +00:00
|
|
|
public bool NullOk {
|
|
|
|
get {
|
|
|
|
return elem.HasAttribute ("null_ok");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public string PassAs {
|
|
|
|
get {
|
2003-10-13 21:53:40 +00:00
|
|
|
if (elem.HasAttribute ("pass_as"))
|
|
|
|
return elem.GetAttribute ("pass_as");
|
|
|
|
|
|
|
|
if (IsArray)
|
|
|
|
return "";
|
|
|
|
|
|
|
|
if (Generatable is SimpleGen && !(Generatable is ConstStringGen) && CType.EndsWith ("*") && !CSType.EndsWith ("IntPtr"))
|
|
|
|
return "out";
|
|
|
|
|
2003-10-17 23:06:37 +00:00
|
|
|
if (Generatable is EnumGen && CType.EndsWith ("*"))
|
|
|
|
return "out";
|
|
|
|
|
2003-10-13 21:53:40 +00:00
|
|
|
return "";
|
2003-06-14 17:30:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-16 23:14:35 +00:00
|
|
|
public string StudlyName {
|
|
|
|
get {
|
|
|
|
string name = elem.GetAttribute("name");
|
|
|
|
string[] segs = name.Split('_');
|
|
|
|
string studly = "";
|
|
|
|
foreach (string s in segs) {
|
2003-07-15 05:52:09 +00:00
|
|
|
if (s.Trim () == "")
|
|
|
|
continue;
|
2002-07-16 23:14:35 +00:00
|
|
|
studly += (s.Substring(0,1).ToUpper() + s.Substring(1));
|
|
|
|
}
|
|
|
|
return studly;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
public class Parameters {
|
|
|
|
|
2003-09-11 06:10:03 +00:00
|
|
|
private ArrayList param_list;
|
2002-05-23 23:43:25 +00:00
|
|
|
private XmlElement elem;
|
2003-06-14 17:30:32 +00:00
|
|
|
private string impl_ns;
|
2003-09-11 06:10:03 +00:00
|
|
|
private string import_sig = "";
|
|
|
|
private string call_string = "";
|
|
|
|
private string signature = "";
|
|
|
|
private string signature_types = "";
|
2002-08-28 20:58:01 +00:00
|
|
|
private bool hide_data;
|
2003-04-06 09:21:15 +00:00
|
|
|
private bool is_static;
|
2002-05-23 23:43:25 +00:00
|
|
|
|
2003-06-14 17:30:32 +00:00
|
|
|
public Parameters (XmlElement elem, string impl_ns) {
|
2002-05-23 23:43:25 +00:00
|
|
|
|
|
|
|
this.elem = elem;
|
2003-06-14 17:30:32 +00:00
|
|
|
this.impl_ns = impl_ns;
|
2003-09-11 06:10:03 +00:00
|
|
|
param_list = new ArrayList ();
|
|
|
|
foreach (XmlNode node in elem.ChildNodes) {
|
|
|
|
XmlElement parm = node as XmlElement;
|
|
|
|
if (parm != null && parm.Name == "parameter")
|
|
|
|
param_list.Add (new Parameter (parm));
|
|
|
|
}
|
2002-05-23 23:43:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public string CallString {
|
|
|
|
get {
|
|
|
|
return call_string;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-11 06:10:03 +00:00
|
|
|
public int Count {
|
|
|
|
get {
|
|
|
|
return param_list.Count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-16 23:14:35 +00:00
|
|
|
public Parameter this [int idx] {
|
|
|
|
get {
|
2003-09-11 06:10:03 +00:00
|
|
|
return param_list [idx] as Parameter;
|
2002-07-16 23:14:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
public string ImportSig {
|
|
|
|
get {
|
|
|
|
return import_sig;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public string Signature {
|
|
|
|
get {
|
|
|
|
return signature;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public string SignatureTypes {
|
|
|
|
get {
|
|
|
|
return signature_types;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-28 20:58:01 +00:00
|
|
|
public bool HideData {
|
|
|
|
get { return hide_data; }
|
|
|
|
set { hide_data = value; }
|
|
|
|
}
|
|
|
|
|
2003-04-06 09:21:15 +00:00
|
|
|
public bool Static {
|
|
|
|
set { is_static = value; }
|
|
|
|
}
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
public bool Validate ()
|
|
|
|
{
|
2003-09-11 06:10:03 +00:00
|
|
|
foreach (Parameter p in param_list) {
|
|
|
|
|
|
|
|
if (p.IsEllipsis) {
|
2002-07-20 14:43:48 +00:00
|
|
|
Console.Write("Ellipsis parameter ");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2003-02-24 03:13:08 +00:00
|
|
|
if ((p.CSType == "") || (p.Name == "") ||
|
2003-05-19 02:45:17 +00:00
|
|
|
(p.MarshalType == "") || (SymbolTable.Table.CallByName(p.CType, p.Name) == "")) {
|
2003-02-24 03:13:08 +00:00
|
|
|
Console.Write("Name: " + p.Name + " Type: " + p.CType + " ");
|
2002-05-23 23:43:25 +00:00
|
|
|
return false;
|
|
|
|
}
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void CreateSignature (bool is_set)
|
|
|
|
{
|
2003-09-11 06:10:03 +00:00
|
|
|
import_sig = call_string = signature = signature_types = "";
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
bool need_sep = false;
|
2002-08-28 20:58:01 +00:00
|
|
|
bool has_callback = hide_data;
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
|
2003-05-19 02:45:17 +00:00
|
|
|
SymbolTable table = SymbolTable.Table;
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
|
2003-09-12 06:38:29 +00:00
|
|
|
for (int i = 0; i < Count; i++) {
|
2003-02-24 03:13:08 +00:00
|
|
|
|
2003-09-12 06:38:29 +00:00
|
|
|
string type = this [i].CType;
|
|
|
|
string cs_type = this [i].CSType;
|
|
|
|
string m_type = this [i].MarshalType;
|
|
|
|
string name = this [i].Name;
|
2003-02-24 03:13:08 +00:00
|
|
|
|
2003-11-17 03:44:32 +00:00
|
|
|
if (i > 0 && this [i - 1].IsArray && this [i].IsCount) {
|
|
|
|
call_string += ", " + (cs_type != "int" ? "(" + cs_type + ") " : "") + this [i - 1].Name + ".Length";
|
|
|
|
import_sig += ", " + m_type + " " + name;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2003-09-12 06:38:29 +00:00
|
|
|
if (i > 0 && this [i - 1].IsString && this [i].IsLength) {
|
2003-10-20 17:33:05 +00:00
|
|
|
call_string += ", " + (cs_type != "int" ? "(" + cs_type + ") " : "") + this [i - 1].Name + ".Length";
|
2003-02-24 03:13:08 +00:00
|
|
|
import_sig += ", " + m_type + " " + name;
|
|
|
|
continue;
|
2002-08-28 20:58:01 +00:00
|
|
|
}
|
2003-02-24 03:13:08 +00:00
|
|
|
|
|
|
|
string call_parm_name = name;
|
2002-07-14 01:32:18 +00:00
|
|
|
if (is_set && i == 0)
|
|
|
|
call_parm_name = "value";
|
|
|
|
|
2003-02-24 03:13:08 +00:00
|
|
|
string call_parm;
|
2003-05-19 02:45:17 +00:00
|
|
|
if (table.IsCallback (type)) {
|
2003-02-24 03:13:08 +00:00
|
|
|
has_callback = true;
|
2003-05-19 02:45:17 +00:00
|
|
|
call_parm = table.CallByName (type, call_parm_name + "_wrapper");
|
2002-08-28 20:58:01 +00:00
|
|
|
} else
|
2003-05-19 02:45:17 +00:00
|
|
|
call_parm = table.CallByName(type, call_parm_name);
|
2002-07-14 01:32:18 +00:00
|
|
|
|
2003-10-11 20:53:10 +00:00
|
|
|
if (this [i].NullOk && !cs_type.EndsWith ("IntPtr") && !table.IsStruct (type))
|
2003-05-19 02:45:17 +00:00
|
|
|
call_parm = String.Format ("({0} != null) ? {1} : {2}", call_parm_name, call_parm, table.IsCallback (type) ? "null" : "IntPtr.Zero");
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
|
2003-09-12 06:38:29 +00:00
|
|
|
if (this [i].IsArray)
|
2002-08-28 20:58:01 +00:00
|
|
|
call_parm = call_parm.Replace ("ref ", "");
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
|
2003-09-12 06:38:29 +00:00
|
|
|
if (IsVarArgs && i == (Count - 1) && VAType == "length_param") {
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
cs_type = "params " + cs_type + "[]";
|
|
|
|
m_type += "[]";
|
|
|
|
}
|
2002-05-23 23:43:25 +00:00
|
|
|
|
|
|
|
if (need_sep) {
|
|
|
|
call_string += ", ";
|
|
|
|
import_sig += ", ";
|
2003-09-12 06:38:29 +00:00
|
|
|
if (type != "GError**" && !(IsVarArgs && i == (Count - 1) && VAType == "length_param"))
|
2002-06-14 Rachel Hestilow <hestilow@ximian.com>
* glib/GException.cs: Added.
* generator/Ctor.cs, Method.cs: Tag function as unsafe if it throws
an exception. Call parms.HandleException.
* generator/Paramaters.cs: Add property ThrowsException (based
on a trailing GError**). If ThrowsException, mask GError in the
signature, initialize a GError in Initialize, and add new method
HandleException to throw an exception if error != null.
* generator/SymbolTable.cs: Add gdk-pixbuf DLL, and GError type.
* gdk.imaging, gdk.imaging/Makefile.in, gdk.imaging/makefile.win32:
Added.
* configure.in, Makefile, makefile.win32: Build gdk.imaging.
* gtk/Makefile.in, gtk/makefile.win32: Link against gdk.imaging.
* parser/gapi2xml.pl: Support namespace renaming.
* parser/build.pl: Build gdk-pixbuf as gdk.imaging.
svn path=/trunk/gtk-sharp/; revision=5281
2002-06-14 18:27:04 +00:00
|
|
|
{
|
|
|
|
signature += ", ";
|
|
|
|
signature_types += ":";
|
|
|
|
}
|
2002-05-23 23:43:25 +00:00
|
|
|
} else {
|
|
|
|
need_sep = true;
|
|
|
|
}
|
|
|
|
|
2003-10-13 21:53:40 +00:00
|
|
|
if (type == "GError**") {
|
|
|
|
call_string += "out ";
|
|
|
|
import_sig += "out ";
|
|
|
|
} else if (this [i].PassAs != "" && !IsVarArgs) {
|
2003-09-12 06:38:29 +00:00
|
|
|
signature += this [i].PassAs + " ";
|
2002-08-03 22:24:37 +00:00
|
|
|
// We only need to do this for value types
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
if (type != "GError**" && m_type != "IntPtr" && m_type != "System.IntPtr")
|
|
|
|
{
|
2003-09-12 06:38:29 +00:00
|
|
|
import_sig += this [i].PassAs + " ";
|
|
|
|
call_string += this [i].PassAs + " ";
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
}
|
2002-08-03 22:24:37 +00:00
|
|
|
|
2003-05-19 02:45:17 +00:00
|
|
|
if (table.IsEnum (type))
|
2002-08-03 22:24:37 +00:00
|
|
|
call_parm = name + "_as_int";
|
2003-10-20 21:27:38 +00:00
|
|
|
else if (table.IsObject (type) || table.IsInterface (type) || table.IsOpaque (type) || cs_type == "GLib.Value") {
|
2003-10-11 20:53:10 +00:00
|
|
|
call_parm = this [i].PassAs + " " + call_parm.Replace (".Handle", "_handle");
|
|
|
|
import_sig += this [i].PassAs + " ";
|
|
|
|
}
|
2002-06-14 Rachel Hestilow <hestilow@ximian.com>
* glib/GException.cs: Added.
* generator/Ctor.cs, Method.cs: Tag function as unsafe if it throws
an exception. Call parms.HandleException.
* generator/Paramaters.cs: Add property ThrowsException (based
on a trailing GError**). If ThrowsException, mask GError in the
signature, initialize a GError in Initialize, and add new method
HandleException to throw an exception if error != null.
* generator/SymbolTable.cs: Add gdk-pixbuf DLL, and GError type.
* gdk.imaging, gdk.imaging/Makefile.in, gdk.imaging/makefile.win32:
Added.
* configure.in, Makefile, makefile.win32: Build gdk.imaging.
* gtk/Makefile.in, gtk/makefile.win32: Link against gdk.imaging.
* parser/gapi2xml.pl: Support namespace renaming.
* parser/build.pl: Build gdk-pixbuf as gdk.imaging.
svn path=/trunk/gtk-sharp/; revision=5281
2002-06-14 18:27:04 +00:00
|
|
|
}
|
2003-10-13 21:53:40 +00:00
|
|
|
|
2003-09-12 06:38:29 +00:00
|
|
|
if (IsVarArgs && i == (Count - 2) && VAType == "length_param") {
|
|
|
|
call_string += this [Count - 1].Name + ".Length";
|
|
|
|
} else {
|
2002-10-11 00:27:46 +00:00
|
|
|
if (!(type == "GError**" || (has_callback && (type == "gpointer" || type == "void*") && (i == Count - 1) && (name.EndsWith ("data") || name.EndsWith ("data_or_owner"))))) {
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
signature += (cs_type + " " + name);
|
|
|
|
signature_types += cs_type;
|
2002-08-28 20:58:01 +00:00
|
|
|
} else if (type == "GError**") {
|
|
|
|
call_parm = call_parm.Replace (name, "error");
|
2002-10-11 00:27:46 +00:00
|
|
|
} else if ((type == "gpointer" || type == "void*") && (i == Count - 1) && (name.EndsWith ("data") || name.EndsWith ("data_or_owner"))) {
|
2002-08-28 20:58:01 +00:00
|
|
|
call_parm = "IntPtr.Zero";
|
2003-09-12 06:38:29 +00:00
|
|
|
}
|
2002-08-28 20:58:01 +00:00
|
|
|
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
call_string += call_parm;
|
|
|
|
}
|
2003-06-14 17:30:32 +00:00
|
|
|
if (table.IsCallback (type))
|
|
|
|
m_type = impl_ns + "Sharp" + m_type.Substring(m_type.IndexOf("."));
|
2002-05-23 23:43:25 +00:00
|
|
|
import_sig += (m_type + " " + name);
|
|
|
|
}
|
2002-08-28 20:58:01 +00:00
|
|
|
|
|
|
|
// FIXME: lame
|
|
|
|
call_string = call_string.Replace ("out ref", "out");
|
|
|
|
import_sig = import_sig.Replace ("out ref", "out");
|
2003-02-24 07:36:30 +00:00
|
|
|
call_string = call_string.Replace ("ref ref", "ref");
|
|
|
|
import_sig = import_sig.Replace ("ref ref", "ref");
|
2002-08-28 20:58:01 +00:00
|
|
|
|
|
|
|
// FIXME: this is also lame, I need to fix the need_sep algo
|
|
|
|
if (signature.EndsWith (", "))
|
|
|
|
signature = signature.Remove (signature.Length - 2, 2);
|
2002-05-23 23:43:25 +00:00
|
|
|
}
|
2002-06-10 12:34:09 +00:00
|
|
|
|
2003-10-05 00:20:17 +00:00
|
|
|
public void Initialize (GenerationInfo gen_info, bool is_get, bool is_set, string indent)
|
2002-06-10 12:34:09 +00:00
|
|
|
{
|
2003-10-05 00:20:17 +00:00
|
|
|
StreamWriter sw = gen_info.Writer;
|
2003-09-12 06:38:29 +00:00
|
|
|
foreach (Parameter p in param_list) {
|
2002-11-01 05:01:22 +00:00
|
|
|
|
2003-06-14 17:30:32 +00:00
|
|
|
IGeneratable gen = p.Generatable;
|
|
|
|
string name = p.Name;
|
|
|
|
if (is_set)
|
2002-11-01 05:01:22 +00:00
|
|
|
name = "value";
|
|
|
|
|
2003-10-11 20:53:10 +00:00
|
|
|
if (is_get) {
|
2003-06-14 17:30:32 +00:00
|
|
|
sw.WriteLine (indent + "\t\t\t" + p.CSType + " " + name + ";");
|
2003-10-11 20:53:10 +00:00
|
|
|
if (gen is ObjectGen || gen is OpaqueGen || p.CSType == "GLib.Value")
|
|
|
|
sw.WriteLine(indent + "\t\t\t" + name + " = new " + p.CSType + "();");
|
|
|
|
}
|
2002-06-10 12:34:09 +00:00
|
|
|
|
2003-10-20 21:27:38 +00:00
|
|
|
if ((is_get || p.PassAs == "out") && (gen is ObjectGen || gen is InterfaceGen || gen is OpaqueGen || p.CSType == "GLib.Value"))
|
2003-10-11 20:53:10 +00:00
|
|
|
sw.WriteLine(indent + "\t\t\tIntPtr " + name + "_handle;");
|
2002-08-03 22:24:37 +00:00
|
|
|
|
2003-06-14 17:30:32 +00:00
|
|
|
if (p.PassAs == "out" && gen is EnumGen)
|
2002-08-03 22:24:37 +00:00
|
|
|
sw.WriteLine(indent + "\t\t\tint " + name + "_as_int;");
|
2002-06-14 Rachel Hestilow <hestilow@ximian.com>
* glib/GException.cs: Added.
* generator/Ctor.cs, Method.cs: Tag function as unsafe if it throws
an exception. Call parms.HandleException.
* generator/Paramaters.cs: Add property ThrowsException (based
on a trailing GError**). If ThrowsException, mask GError in the
signature, initialize a GError in Initialize, and add new method
HandleException to throw an exception if error != null.
* generator/SymbolTable.cs: Add gdk-pixbuf DLL, and GError type.
* gdk.imaging, gdk.imaging/Makefile.in, gdk.imaging/makefile.win32:
Added.
* configure.in, Makefile, makefile.win32: Build gdk.imaging.
* gtk/Makefile.in, gtk/makefile.win32: Link against gdk.imaging.
* parser/gapi2xml.pl: Support namespace renaming.
* parser/build.pl: Build gdk-pixbuf as gdk.imaging.
svn path=/trunk/gtk-sharp/; revision=5281
2002-06-14 18:27:04 +00:00
|
|
|
|
2003-06-14 17:30:32 +00:00
|
|
|
if (gen is CallbackGen) {
|
|
|
|
CallbackGen cbgen = gen as CallbackGen;
|
2003-10-05 00:20:17 +00:00
|
|
|
string wrapper = cbgen.GenWrapper(impl_ns, gen_info);
|
2003-06-14 17:30:32 +00:00
|
|
|
sw.WriteLine (indent + "\t\t\t{0} {1}_wrapper = null;", wrapper, name);
|
2002-09-12 20:25:29 +00:00
|
|
|
sw.Write (indent + "\t\t\t");
|
2003-06-14 17:30:32 +00:00
|
|
|
if (p.NullOk)
|
2002-09-12 20:25:29 +00:00
|
|
|
sw.Write ("if ({0} != null) ", name);
|
2003-06-14 17:30:32 +00:00
|
|
|
sw.WriteLine ("{1}_wrapper = new {0} ({1}, {2});", wrapper, name, is_static ? "null" : "this");
|
2002-08-28 20:58:01 +00:00
|
|
|
}
|
|
|
|
}
|
2003-06-14 17:30:32 +00:00
|
|
|
|
|
|
|
if (ThrowsException)
|
|
|
|
sw.WriteLine (indent + "\t\t\tIntPtr error = IntPtr.Zero;");
|
2002-06-10 12:34:09 +00:00
|
|
|
}
|
2002-08-03 22:24:37 +00:00
|
|
|
|
|
|
|
public void Finish (StreamWriter sw, string indent)
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
{
|
2003-10-11 20:53:10 +00:00
|
|
|
bool ref_owned_needed = true;
|
2003-09-11 06:10:03 +00:00
|
|
|
foreach (Parameter p in param_list) {
|
2002-06-10 12:34:09 +00:00
|
|
|
|
2003-06-14 17:30:32 +00:00
|
|
|
if (p.PassAs == "out" && p.Generatable is EnumGen) {
|
|
|
|
sw.WriteLine(indent + "\t\t\t" + p.Name + " = (" + p.CSType + ") " + p.Name + "_as_int;");
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
}
|
2003-10-11 20:53:10 +00:00
|
|
|
|
|
|
|
IGeneratable gen = p.Generatable;
|
2003-10-20 21:27:38 +00:00
|
|
|
if (ref_owned_needed && (gen is ObjectGen || gen is InterfaceGen) && p.PassAs == "out") {
|
2003-10-11 20:53:10 +00:00
|
|
|
ref_owned_needed = false;
|
|
|
|
sw.WriteLine(indent + "\t\t\tbool ref_owned = false;");
|
|
|
|
}
|
|
|
|
|
2003-10-20 21:27:38 +00:00
|
|
|
if (p.PassAs == "out" && (gen is ObjectGen || gen is InterfaceGen || gen is OpaqueGen || p.CSType == "GLib.Value"))
|
2003-10-11 20:53:10 +00:00
|
|
|
sw.WriteLine(indent + "\t\t\t" + p.Name + " = " + gen.FromNativeReturn (p.Name + "_handle") + ";");
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-03 22:24:37 +00:00
|
|
|
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
|
|
|
|
public void HandleException (StreamWriter sw, string indent)
|
2002-06-14 Rachel Hestilow <hestilow@ximian.com>
* glib/GException.cs: Added.
* generator/Ctor.cs, Method.cs: Tag function as unsafe if it throws
an exception. Call parms.HandleException.
* generator/Paramaters.cs: Add property ThrowsException (based
on a trailing GError**). If ThrowsException, mask GError in the
signature, initialize a GError in Initialize, and add new method
HandleException to throw an exception if error != null.
* generator/SymbolTable.cs: Add gdk-pixbuf DLL, and GError type.
* gdk.imaging, gdk.imaging/Makefile.in, gdk.imaging/makefile.win32:
Added.
* configure.in, Makefile, makefile.win32: Build gdk.imaging.
* gtk/Makefile.in, gtk/makefile.win32: Link against gdk.imaging.
* parser/gapi2xml.pl: Support namespace renaming.
* parser/build.pl: Build gdk-pixbuf as gdk.imaging.
svn path=/trunk/gtk-sharp/; revision=5281
2002-06-14 18:27:04 +00:00
|
|
|
{
|
|
|
|
if (!ThrowsException)
|
|
|
|
return;
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
sw.WriteLine (indent + "\t\t\tif (error != IntPtr.Zero) throw new GLib.GException (error);");
|
2002-06-14 Rachel Hestilow <hestilow@ximian.com>
* glib/GException.cs: Added.
* generator/Ctor.cs, Method.cs: Tag function as unsafe if it throws
an exception. Call parms.HandleException.
* generator/Paramaters.cs: Add property ThrowsException (based
on a trailing GError**). If ThrowsException, mask GError in the
signature, initialize a GError in Initialize, and add new method
HandleException to throw an exception if error != null.
* generator/SymbolTable.cs: Add gdk-pixbuf DLL, and GError type.
* gdk.imaging, gdk.imaging/Makefile.in, gdk.imaging/makefile.win32:
Added.
* configure.in, Makefile, makefile.win32: Build gdk.imaging.
* gtk/Makefile.in, gtk/makefile.win32: Link against gdk.imaging.
* parser/gapi2xml.pl: Support namespace renaming.
* parser/build.pl: Build gdk-pixbuf as gdk.imaging.
svn path=/trunk/gtk-sharp/; revision=5281
2002-06-14 18:27:04 +00:00
|
|
|
}
|
|
|
|
|
2002-06-10 12:34:09 +00:00
|
|
|
public bool IsAccessor {
|
|
|
|
get {
|
2003-09-11 06:10:03 +00:00
|
|
|
return Count == 1 && this [0].PassAs == "out";
|
2002-06-10 12:34:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-14 Rachel Hestilow <hestilow@ximian.com>
* glib/GException.cs: Added.
* generator/Ctor.cs, Method.cs: Tag function as unsafe if it throws
an exception. Call parms.HandleException.
* generator/Paramaters.cs: Add property ThrowsException (based
on a trailing GError**). If ThrowsException, mask GError in the
signature, initialize a GError in Initialize, and add new method
HandleException to throw an exception if error != null.
* generator/SymbolTable.cs: Add gdk-pixbuf DLL, and GError type.
* gdk.imaging, gdk.imaging/Makefile.in, gdk.imaging/makefile.win32:
Added.
* configure.in, Makefile, makefile.win32: Build gdk.imaging.
* gtk/Makefile.in, gtk/makefile.win32: Link against gdk.imaging.
* parser/gapi2xml.pl: Support namespace renaming.
* parser/build.pl: Build gdk-pixbuf as gdk.imaging.
svn path=/trunk/gtk-sharp/; revision=5281
2002-06-14 18:27:04 +00:00
|
|
|
public bool ThrowsException {
|
|
|
|
get {
|
2003-09-11 06:10:03 +00:00
|
|
|
if (Count < 1)
|
2002-06-14 Rachel Hestilow <hestilow@ximian.com>
* glib/GException.cs: Added.
* generator/Ctor.cs, Method.cs: Tag function as unsafe if it throws
an exception. Call parms.HandleException.
* generator/Paramaters.cs: Add property ThrowsException (based
on a trailing GError**). If ThrowsException, mask GError in the
signature, initialize a GError in Initialize, and add new method
HandleException to throw an exception if error != null.
* generator/SymbolTable.cs: Add gdk-pixbuf DLL, and GError type.
* gdk.imaging, gdk.imaging/Makefile.in, gdk.imaging/makefile.win32:
Added.
* configure.in, Makefile, makefile.win32: Build gdk.imaging.
* gtk/Makefile.in, gtk/makefile.win32: Link against gdk.imaging.
* parser/gapi2xml.pl: Support namespace renaming.
* parser/build.pl: Build gdk-pixbuf as gdk.imaging.
svn path=/trunk/gtk-sharp/; revision=5281
2002-06-14 18:27:04 +00:00
|
|
|
return false;
|
2002-06-20 01:45:13 +00:00
|
|
|
|
2003-09-11 06:10:03 +00:00
|
|
|
return this [Count - 1].CType == "GError**";
|
2002-06-14 Rachel Hestilow <hestilow@ximian.com>
* glib/GException.cs: Added.
* generator/Ctor.cs, Method.cs: Tag function as unsafe if it throws
an exception. Call parms.HandleException.
* generator/Paramaters.cs: Add property ThrowsException (based
on a trailing GError**). If ThrowsException, mask GError in the
signature, initialize a GError in Initialize, and add new method
HandleException to throw an exception if error != null.
* generator/SymbolTable.cs: Add gdk-pixbuf DLL, and GError type.
* gdk.imaging, gdk.imaging/Makefile.in, gdk.imaging/makefile.win32:
Added.
* configure.in, Makefile, makefile.win32: Build gdk.imaging.
* gtk/Makefile.in, gtk/makefile.win32: Link against gdk.imaging.
* parser/gapi2xml.pl: Support namespace renaming.
* parser/build.pl: Build gdk-pixbuf as gdk.imaging.
svn path=/trunk/gtk-sharp/; revision=5281
2002-06-14 18:27:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
public bool IsVarArgs {
|
|
|
|
get {
|
|
|
|
return elem.HasAttribute ("va_type");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public string VAType {
|
|
|
|
get {
|
|
|
|
return elem.GetAttribute ("va_type");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-10 12:34:09 +00:00
|
|
|
public string AccessorReturnType {
|
|
|
|
get {
|
2003-09-11 06:10:03 +00:00
|
|
|
if (Count > 0)
|
|
|
|
return this [0].CSType;
|
|
|
|
else
|
|
|
|
return null;
|
2002-06-10 12:34:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public string AccessorName {
|
|
|
|
get {
|
2003-09-11 06:10:03 +00:00
|
|
|
if (Count > 0)
|
|
|
|
return this [0].Name;
|
|
|
|
else
|
|
|
|
return null;
|
2002-06-10 12:34:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|