mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2025-02-28 17:47:00 +00:00
2003-02-23 Mike Kestner <mkestner@speakeasy.net>
* generator/CallbackGen.cs : suppress len params from string/len pairs. * generator/Parameters.cs : begin the refactoring to use Parameter class. Suppress len params from string/len pairs. */*.custom : remove all overrides of string/len pairs */*.cs : ditto. Thanks to Alp Toker for the foundation patch that this change was built upon. svn path=/trunk/gtk-sharp/; revision=11913
This commit is contained in:
parent
2f10faa83d
commit
554450a33a
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2003-02-23 Mike Kestner <mkestner@speakeasy.net>
|
||||||
|
|
||||||
|
* generator/CallbackGen.cs : suppress len params from
|
||||||
|
string/len pairs.
|
||||||
|
* generator/Parameters.cs : begin the refactoring to use
|
||||||
|
Parameter class. Suppress len params from string/len pairs.
|
||||||
|
*/*.custom : remove all overrides of string/len pairs
|
||||||
|
*/*.cs : ditto. Thanks to Alp Toker for the foundation
|
||||||
|
patch that this change was built upon.
|
||||||
|
|
||||||
2003-02-22 Mike Kestner <mkestner@speakeasy.net>
|
2003-02-22 Mike Kestner <mkestner@speakeasy.net>
|
||||||
|
|
||||||
* sources/makefile : patch from Charles Krempeaux to add
|
* sources/makefile : patch from Charles Krempeaux to add
|
||||||
|
|
|
@ -103,8 +103,13 @@ namespace GtkSharp.Generation {
|
||||||
{
|
{
|
||||||
string parm_name = parms[i].Name;
|
string parm_name = parms[i].Name;
|
||||||
string ctype = parms[i].CType;
|
string ctype = parms[i].CType;
|
||||||
|
|
||||||
|
if (i > 0 && parms[i].IsLength && parms[i-1].IsString)
|
||||||
|
continue;
|
||||||
|
|
||||||
if ((i == count - 1) && ctype == "gpointer" && (parm_name.EndsWith ("data") || parm_name.EndsWith ("data_or_owner")))
|
if ((i == count - 1) && ctype == "gpointer" && (parm_name.EndsWith ("data") || parm_name.EndsWith ("data_or_owner")))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
string cstype = parms[i].CSType;
|
string cstype = parms[i].CSType;
|
||||||
// FIXME: Too much code copy/pasted here. Refactor?
|
// FIXME: Too much code copy/pasted here. Refactor?
|
||||||
ClassBase parm_wrapper = SymbolTable.GetClassGen (ctype);
|
ClassBase parm_wrapper = SymbolTable.GetClassGen (ctype);
|
||||||
|
|
|
@ -33,39 +33,73 @@ namespace GtkSharp.Generation {
|
||||||
string cstype = SymbolTable.GetCSType( elem.GetAttribute("type"));
|
string cstype = SymbolTable.GetCSType( elem.GetAttribute("type"));
|
||||||
if (cstype == "void")
|
if (cstype == "void")
|
||||||
cstype = "System.IntPtr";
|
cstype = "System.IntPtr";
|
||||||
if (elem.HasAttribute("array"))
|
if (elem.HasAttribute("array")) {
|
||||||
cstype += "[]";
|
cstype += "[]";
|
||||||
|
cstype = cstype.Replace ("ref ", "");
|
||||||
|
}
|
||||||
return cstype;
|
return cstype;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsLength {
|
||||||
|
get {
|
||||||
|
return (CSType == "int" &&
|
||||||
|
(Name.EndsWith("len") || Name.EndsWith("length")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsString {
|
||||||
|
get {
|
||||||
|
return (CSType == "string");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string MarshalType {
|
public string MarshalType {
|
||||||
get {
|
get {
|
||||||
string type = SymbolTable.GetMarshalType( elem.GetAttribute("type"));
|
string type = SymbolTable.GetMarshalType( elem.GetAttribute("type"));
|
||||||
if (type == "void")
|
if (type == "void")
|
||||||
type = "System.IntPtr";
|
type = "System.IntPtr";
|
||||||
|
if (elem.HasAttribute("array")) {
|
||||||
|
type += "[]";
|
||||||
|
type = type.Replace ("ref ", "");
|
||||||
|
}
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name {
|
public string Name {
|
||||||
get {
|
get {
|
||||||
string name = elem.GetAttribute("name");
|
return MangleName (elem.GetAttribute("name"));
|
||||||
switch (name) {
|
|
||||||
case "string":
|
|
||||||
return "str1ng";
|
|
||||||
case "event":
|
|
||||||
return "evnt";
|
|
||||||
case "object":
|
|
||||||
return "objekt";
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return name;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string MangleName(string name)
|
||||||
|
{
|
||||||
|
switch (name) {
|
||||||
|
case "string":
|
||||||
|
return "str1ng";
|
||||||
|
case "event":
|
||||||
|
return "evnt";
|
||||||
|
case "null":
|
||||||
|
return "is_null";
|
||||||
|
case "object":
|
||||||
|
return "objekt";
|
||||||
|
case "params":
|
||||||
|
return "parms";
|
||||||
|
case "ref":
|
||||||
|
return "reference";
|
||||||
|
case "in":
|
||||||
|
return "in_param";
|
||||||
|
case "out":
|
||||||
|
return "out_param";
|
||||||
|
case "fixed":
|
||||||
|
return "mfixed";
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
public string StudlyName {
|
public string StudlyName {
|
||||||
get {
|
get {
|
||||||
string name = elem.GetAttribute("name");
|
string name = elem.GetAttribute("name");
|
||||||
|
@ -149,15 +183,11 @@ namespace GtkSharp.Generation {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
string type = p_elem.GetAttribute("type");
|
Parameter p = new Parameter (p_elem);
|
||||||
string cs_type = SymbolTable.GetCSType(type);
|
|
||||||
string m_type = SymbolTable.GetMarshalType(type);
|
|
||||||
string name = MangleName(p_elem.GetAttribute("name"));
|
|
||||||
string call_parm = SymbolTable.CallByName(type, name);
|
|
||||||
|
|
||||||
if ((cs_type == "") || (name == "") ||
|
if ((p.CSType == "") || (p.Name == "") ||
|
||||||
(m_type == "") || (call_parm == "")) {
|
(p.MarshalType == "") || (SymbolTable.CallByName(p.CType, p.Name) == "")) {
|
||||||
Console.Write("Name: " + name + " Type: " + type + " ");
|
Console.Write("Name: " + p.Name + " Type: " + p.CType + " ");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,10 +202,9 @@ namespace GtkSharp.Generation {
|
||||||
bool has_callback = hide_data;
|
bool has_callback = hide_data;
|
||||||
bool last_was_user_data = false;
|
bool last_was_user_data = false;
|
||||||
bool has_user_data = false;
|
bool has_user_data = false;
|
||||||
string callback_type = "";
|
|
||||||
|
|
||||||
int len = 0;
|
int len = 0;
|
||||||
XmlElement last_param = null;
|
Parameter last_param = null;
|
||||||
foreach (XmlNode parm in elem.ChildNodes) {
|
foreach (XmlNode parm in elem.ChildNodes) {
|
||||||
if (parm.Name != "parameter") {
|
if (parm.Name != "parameter") {
|
||||||
continue;
|
continue;
|
||||||
|
@ -184,51 +213,49 @@ namespace GtkSharp.Generation {
|
||||||
if (p_elem.GetAttribute("type") == "gpointer" && (p_elem.GetAttribute("name").EndsWith ("data") || p_elem.GetAttribute("name").EndsWith ("data_or_owner")))
|
if (p_elem.GetAttribute("type") == "gpointer" && (p_elem.GetAttribute("name").EndsWith ("data") || p_elem.GetAttribute("name").EndsWith ("data_or_owner")))
|
||||||
has_user_data = true;
|
has_user_data = true;
|
||||||
len++;
|
len++;
|
||||||
last_param = (XmlElement) parm;
|
last_param = new Parameter ((XmlElement) parm);
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
Parameter prev = null;
|
||||||
|
|
||||||
foreach (XmlNode parm in elem.ChildNodes) {
|
foreach (XmlNode parm in elem.ChildNodes) {
|
||||||
if (parm.Name != "parameter") {
|
if (parm.Name != "parameter") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlElement p_elem = (XmlElement) parm;
|
XmlElement p_elem = (XmlElement) parm;
|
||||||
string type = p_elem.GetAttribute("type");
|
Parameter curr = new Parameter (p_elem);
|
||||||
string cs_type = SymbolTable.GetCSType(type);
|
|
||||||
if (cs_type == "void")
|
|
||||||
cs_type = "System.IntPtr";
|
|
||||||
string m_type = SymbolTable.GetMarshalType(type);
|
|
||||||
if (m_type == "void")
|
|
||||||
m_type = "System.IntPtr";
|
|
||||||
string name = MangleName(p_elem.GetAttribute("name"));
|
|
||||||
string call_parm, call_parm_name;
|
|
||||||
|
|
||||||
if (SymbolTable.IsCallback (type)) {
|
string type = curr.CType;
|
||||||
has_callback = true;
|
string cs_type = curr.CSType;
|
||||||
|
string m_type = curr.MarshalType;
|
||||||
|
string name = curr.Name;
|
||||||
|
|
||||||
|
if (prev != null && prev.IsString && curr.IsLength) {
|
||||||
|
call_string += ", " + prev.Name + ".Length";
|
||||||
|
import_sig += ", " + m_type + " " + name;
|
||||||
|
prev = curr;
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string call_parm_name = name;
|
||||||
if (is_set && i == 0)
|
if (is_set && i == 0)
|
||||||
call_parm_name = "value";
|
call_parm_name = "value";
|
||||||
else
|
|
||||||
call_parm_name = name;
|
|
||||||
|
|
||||||
|
string call_parm;
|
||||||
if (SymbolTable.IsCallback (type)) {
|
if (SymbolTable.IsCallback (type)) {
|
||||||
|
has_callback = true;
|
||||||
call_parm = SymbolTable.CallByName (type, call_parm_name + "_wrapper");
|
call_parm = SymbolTable.CallByName (type, call_parm_name + "_wrapper");
|
||||||
callback_type = type.Replace(".", "Sharp.") + "Wrapper";
|
|
||||||
} else
|
} else
|
||||||
call_parm = SymbolTable.CallByName(type, call_parm_name);
|
call_parm = SymbolTable.CallByName(type, call_parm_name);
|
||||||
|
|
||||||
if (p_elem.HasAttribute ("null_ok") && cs_type != "IntPtr" && cs_type != "System.IntPtr" && !SymbolTable.IsStruct (type))
|
if (p_elem.HasAttribute ("null_ok") && cs_type != "IntPtr" && cs_type != "System.IntPtr" && !SymbolTable.IsStruct (type))
|
||||||
call_parm = String.Format ("({0} != null) ? {1} : {2}", call_parm_name, call_parm, SymbolTable.IsCallback (type) ? "null" : "IntPtr.Zero");
|
call_parm = String.Format ("({0} != null) ? {1} : {2}", call_parm_name, call_parm, SymbolTable.IsCallback (type) ? "null" : "IntPtr.Zero");
|
||||||
|
|
||||||
if (p_elem.HasAttribute("array")) {
|
if (p_elem.HasAttribute("array"))
|
||||||
cs_type += "[]";
|
|
||||||
m_type += "[]";
|
|
||||||
cs_type = cs_type.Replace ("ref ", "");
|
|
||||||
m_type = m_type.Replace ("ref ", "");
|
|
||||||
call_parm = call_parm.Replace ("ref ", "");
|
call_parm = call_parm.Replace ("ref ", "");
|
||||||
}
|
|
||||||
|
|
||||||
if (IsVarArgs && i == (len - 1) && VAType == "length_param") {
|
if (IsVarArgs && i == (len - 1) && VAType == "length_param") {
|
||||||
cs_type = "params " + cs_type + "[]";
|
cs_type = "params " + cs_type + "[]";
|
||||||
|
@ -268,7 +295,7 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
if (IsVarArgs && i == (len - 2) && VAType == "length_param")
|
if (IsVarArgs && i == (len - 2) && VAType == "length_param")
|
||||||
{
|
{
|
||||||
call_string += MangleName(last_param.GetAttribute("name")) + ".Length";
|
call_string += last_param.Name + ".Length";
|
||||||
last_was_user_data = false;
|
last_was_user_data = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -289,6 +316,7 @@ namespace GtkSharp.Generation {
|
||||||
call_string += call_parm;
|
call_string += call_parm;
|
||||||
}
|
}
|
||||||
import_sig += (m_type + " " + name);
|
import_sig += (m_type + " " + name);
|
||||||
|
prev = curr;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,14 +341,15 @@ namespace GtkSharp.Generation {
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlElement p_elem = (XmlElement) parm;
|
XmlElement p_elem = (XmlElement) parm;
|
||||||
|
Parameter p = new Parameter (p_elem);
|
||||||
|
|
||||||
string c_type = p_elem.GetAttribute ("type");
|
string c_type = p.CType;
|
||||||
string type = SymbolTable.GetCSType(c_type);
|
string type = p.CSType;
|
||||||
|
|
||||||
if (is_set) {
|
if (is_set) {
|
||||||
name = "value";
|
name = "value";
|
||||||
} else {
|
} else {
|
||||||
name = MangleName(p_elem.GetAttribute("name"));
|
name = p.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_get) {
|
if (is_get) {
|
||||||
|
@ -345,14 +374,15 @@ namespace GtkSharp.Generation {
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlElement p_elem = (XmlElement) parm;
|
XmlElement p_elem = (XmlElement) parm;
|
||||||
|
Parameter p = new Parameter (p_elem);
|
||||||
|
|
||||||
string c_type = p_elem.GetAttribute ("type");
|
string c_type = p.CType;
|
||||||
string type = SymbolTable.GetCSType(c_type);
|
string type = p.CSType;
|
||||||
|
|
||||||
if (is_set) {
|
if (is_set) {
|
||||||
name = "value";
|
name = "value";
|
||||||
} else {
|
} else {
|
||||||
name = MangleName(p_elem.GetAttribute("name"));
|
name = p.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SymbolTable.IsCallback (c_type)) {
|
if (SymbolTable.IsCallback (c_type)) {
|
||||||
|
@ -377,9 +407,10 @@ namespace GtkSharp.Generation {
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlElement p_elem = (XmlElement) parm;
|
XmlElement p_elem = (XmlElement) parm;
|
||||||
string c_type = p_elem.GetAttribute ("type");
|
Parameter p = new Parameter (p_elem);
|
||||||
string name = MangleName(p_elem.GetAttribute("name"));
|
string c_type = p.CType;
|
||||||
string type = SymbolTable.GetCSType(c_type);
|
string name = p.Name;
|
||||||
|
string type = p.CSType;
|
||||||
|
|
||||||
if (p_elem.HasAttribute("pass_as") && p_elem.GetAttribute ("pass_as") == "out" && SymbolTable.IsEnum (c_type)) {
|
if (p_elem.HasAttribute("pass_as") && p_elem.GetAttribute ("pass_as") == "out" && SymbolTable.IsEnum (c_type)) {
|
||||||
sw.WriteLine(indent + "\t\t\t" + name + " = (" + type + ") " + name + "_as_int;");
|
sw.WriteLine(indent + "\t\t\t" + name + " = (" + type + ") " + name + "_as_int;");
|
||||||
|
@ -476,39 +507,13 @@ namespace GtkSharp.Generation {
|
||||||
if (parm.Name != "parameter")
|
if (parm.Name != "parameter")
|
||||||
continue;
|
continue;
|
||||||
XmlElement p_elem = (XmlElement) parm;
|
XmlElement p_elem = (XmlElement) parm;
|
||||||
return MangleName (p_elem.GetAttribute("name"));
|
Parameter p = new Parameter (p_elem);
|
||||||
|
return p.Name;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string MangleName(string name)
|
|
||||||
{
|
|
||||||
switch (name) {
|
|
||||||
case "string":
|
|
||||||
return "str1ng";
|
|
||||||
case "event":
|
|
||||||
return "evnt";
|
|
||||||
case "null":
|
|
||||||
return "is_null";
|
|
||||||
case "object":
|
|
||||||
return "objekt";
|
|
||||||
case "params":
|
|
||||||
return "parms";
|
|
||||||
case "ref":
|
|
||||||
return "reference";
|
|
||||||
case "in":
|
|
||||||
return "in_param";
|
|
||||||
case "out":
|
|
||||||
return "out_param";
|
|
||||||
case "fixed":
|
|
||||||
return "mfixed";
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,9 +51,3 @@
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetText (string new_text)
|
|
||||||
{
|
|
||||||
SetText (new_text, new_text.Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ public int InsertText (string new_text)
|
||||||
{
|
{
|
||||||
int position = 0;
|
int position = 0;
|
||||||
|
|
||||||
InsertText (new_text, new_text.Length, ref position);
|
InsertText (new_text, ref position);
|
||||||
|
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
//
|
|
||||||
// Pango.GlyphString.custom - Allow customization of values in the GtkAdjustment
|
|
||||||
//
|
|
||||||
// This code is inserted after the automatically generated code.
|
|
||||||
//
|
|
||||||
|
|
||||||
public void GetLogicalWidths (string text, int embedding_level, int logical_widths)
|
|
||||||
{
|
|
||||||
pango_glyph_string_get_logical_widths(ref this, text, text.Length, embedding_level, logical_widths);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void XToIndex (string text, Pango.Analysis analysis, int x_pos, int index, int trailing)
|
|
||||||
{
|
|
||||||
pango_glyph_string_x_to_index(ref this, text, text.Length, ref analysis, x_pos, index, trailing);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void IndexToX (string text, Pango.Analysis analysis, int index, bool trailing, int x_pos)
|
|
||||||
{
|
|
||||||
pango_glyph_string_index_to_x(ref this, text, text.Length, ref analysis, index, trailing, x_pos);
|
|
||||||
}
|
|
|
@ -15,13 +15,3 @@ public System.Drawing.Size Size {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> SetText Method, overloaded to not having to calculate string length </summary>
|
|
||||||
public void SetText(string text) {
|
|
||||||
SetText(text, text.Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> SetMarkup Method, overloaded to not having to calculate string length </summary>
|
|
||||||
public void SetMarkup(string markup) {
|
|
||||||
SetText(markup, markup.Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue