[Gtk-sharp-list] Upcoming problems.
Rachel Hestilow
rachel@nullenvoid.com
30 May 2003 02:41:19 -0500
--=-4YhnCzSALGK75DNn3APY
Content-Type: multipart/mixed; boundary="=-0/RsPbLrQruopYtPOmgg"
--=-0/RsPbLrQruopYtPOmgg
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
Ok, this took longer than I thought, but I believe I now have both const
and non-const strings handled correctly. It required making some more
extensive changes to the generator than I previously anticipated,
however, so I'm sending the patch to the list to get Mike's approval
first.
The problem is that there are a few signals and callback wrappers which
return allocated strings. So this requires the reverse mapping:
converting a managed string into an IntPtr (really just a matter of
calling g_strdup). The generator previously called CallByName to marshal
such a return, but that wouldn't work because string arguments are still
marshalled automatically as type 'string'. To fix this, I added a new
method ToNativeReturn to IGeneratable.
Okay to commit?
-- Rachel
--=-0/RsPbLrQruopYtPOmgg
Content-Disposition: inline; filename=strings.patch
Content-Type: text/x-patch; name=strings.patch; charset=ANSI_X3.4-1968
Content-Transfer-Encoding: quoted-printable
Index: ChangeLog
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/ChangeLog,v
retrieving revision 1.399
diff -u -r1.399 ChangeLog
--- ChangeLog 27 May 2003 06:58:41 -0000 1.399
+++ ChangeLog 30 May 2003 07:32:55 -0000
@@ -1,3 +1,37 @@
+2003-05-29 Rachel Hestilow <rachel@nullenvoid.com>
+
+ * gconf/Value.cs: Update to use new string marshalling.
+
+ * generator/StringGen.cs, ConstStringGen.cs: Added.
+ * generator/IGeneratable.cs: Add new method ToNativeReturn.
+ * generator/CallbackGen.cs: Implement ToNativeReturn. Call
+ ToNativeReturn for the return statement. Fix a couple of
+ places where s_ret was being used incorrectly for m_ret.
+ * generator/ClassGen.cs, EnumGen.cs, ManualGen.cs,
+ SimpleGen.cs, StructBase.cs: Implement ToNativeReturn.
+ * generator/SignalHandler.cs: Call ToNativeReturn for the
+ return statement, instead of CallByName.
+ * generator/SymbolTable.cs: Use StringGen for gchar, char,
+ and gunicar, and ConstStringGen for their const variants.
+ Add a new method wrapper for ToNativeReturn.
+ (Trim): Add a special-case for const strings so that the
+ const is not stripped. Otherwise there is no way of
+ resolving the const case.
+
+ * glade/XML.custom: Update to use new string marshalling.
+
+ * glib/Marshaller.cs: Added.
+ * glib/GException.cs, Markup.cs, ObjectManager.cs,
+ Value.cs: Update to use new string marshalling.
+ * glib/Object.cs: Remove old g_type_name DllImport
+ as it is no longer used.
+
+ * glue/fileselection.c (gtksharp_file_selection_get_fileop_entry):
+ Mark this as const return.
+
+ * gtk/ColorSelection.custom, FileSelection.custom,
+ SelectionData.custom: Update to use new string marshalling.
+
2003-05-27 Rachel Hestilow <rachel@nullenvoid.com>
=20
* sample/ManagedTreeViewDemo.cs: Remove debugging cruft.
Index: gconf/GConf/Value.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/gconf/GConf/Value.cs,v
retrieving revision 1.1
diff -u -r1.1 Value.cs
--- gconf/GConf/Value.cs 19 Oct 2002 09:31:19 -0000 1.1
+++ gconf/GConf/Value.cs 30 May 2003 07:32:57 -0000
@@ -88,7 +88,7 @@
}
=20
[DllImport("gconf-2")]
- static extern string gconf_value_get_string (IntPtr value);
+ static extern IntPtr gconf_value_get_string (IntPtr value);
=09
[DllImport("gconf-2")]
static extern int gconf_value_get_int (IntPtr value);
@@ -104,7 +104,7 @@
switch (val_type)
{
case ValueType.String:
- return gconf_value_get_string (Raw);
+ return Marshal.PtrToStringAnsi (gconf_value_get_string (Raw));
case ValueType.Int:
return gconf_value_get_int (Raw);
case ValueType.Float:
Index: generator/CallbackGen.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/generator/CallbackGen.cs,v
retrieving revision 1.21
diff -u -r1.21 CallbackGen.cs
--- generator/CallbackGen.cs 19 May 2003 02:45:17 -0000 1.21
+++ generator/CallbackGen.cs 30 May 2003 07:32:57 -0000
@@ -49,6 +49,11 @@
return FromNative (var);
}
=20
+ public virtual String ToNativeReturn(String var)
+ {
+ return CallByName (var);
+ }
+ =09
public void GenWrapper (string ns)
{
char sep =3D Path.DirectorySeparatorChar;
@@ -101,7 +106,7 @@
} else if (ret_wrapper !=3D null && (ret_wrapper is ObjectGen || ret_w=
rapper is OpaqueGen)) {
// Do nothing
} else if (!table.IsStruct (rettype) && !table.IsBoxed (rettype)) {
- sw.WriteLine ("\t\tstatic {0} _dummy;", s_ret);
+ sw.WriteLine ("\t\tstatic {0} _dummy;", m_ret);
}
}
=09
@@ -162,7 +167,7 @@
else if (table.IsEnum (rettype))
sw.WriteLine ("return (int) {0};", invoke);
else
- sw.WriteLine ("return ({0}) {1};", s_ret, invoke);
+ sw.WriteLine ("return ({0}) {1};", m_ret, table.ToNativeReturn (rett=
ype, invoke));
}
else
sw.WriteLine (invoke + ";");
Index: generator/ClassBase.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/generator/ClassBase.cs,v
retrieving revision 1.16
diff -u -r1.16 ClassBase.cs
--- generator/ClassBase.cs 19 May 2003 02:45:17 -0000 1.16
+++ generator/ClassBase.cs 30 May 2003 07:32:57 -0000
@@ -142,6 +142,11 @@
return FromNative (var);
}
=09
+ public virtual String ToNativeReturn(String var)
+ {
+ return CallByName (var);
+ }
+ =09
protected void GenProperties (StreamWriter sw)
{ =09
if (props =3D=3D null)
Index: generator/ConstStringGen.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: generator/ConstStringGen.cs
diff -N generator/ConstStringGen.cs
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ generator/ConstStringGen.cs 30 May 2003 07:32:57 -0000
@@ -0,0 +1,30 @@
+// GtkSharp.Generation.ConstStringGen.cs - The Const String type Generatab=
le.
+//
+// Author: Rachel Hestilow <rachel@nullenvoid.com>
+//
+// (c) 2003 Rachel Hestilow
+
+namespace GtkSharp.Generation {
+
+ using System;
+
+ public class ConstStringGen : SimpleGen {
+ =09
+ public ConstStringGen (string ctype) : base (ctype, "string")
+ {
+ }
+
+ public override String MarshalReturnType {
+ get
+ {
+ return "IntPtr";
+ }
+ }
+ =09
+ public override String FromNativeReturn(String var)
+ {
+ return "Marshal.PtrToStringAnsi(" + var + ")";
+ }
+ }
+}
+
Index: generator/EnumGen.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/generator/EnumGen.cs,v
retrieving revision 1.17
diff -u -r1.17 EnumGen.cs
--- generator/EnumGen.cs 19 May 2003 02:45:17 -0000 1.17
+++ generator/EnumGen.cs 30 May 2003 07:32:57 -0000
@@ -42,6 +42,11 @@
return FromNative (var);
}
=20
+ public virtual String ToNativeReturn(String var)
+ {
+ return CallByName (var);
+ }
+ =09
public void Generate ()
{
if (!DoGenerate)
Index: generator/IGeneratable.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/generator/IGeneratable.cs,v
retrieving revision 1.6
diff -u -r1.6 IGeneratable.cs
--- generator/IGeneratable.cs 20 Aug 2002 19:56:14 -0000 1.6
+++ generator/IGeneratable.cs 30 May 2003 07:32:57 -0000
@@ -26,6 +26,8 @@
=20
String FromNativeReturn (String var);
=20
+ String ToNativeReturn (String var);
+
bool DoGenerate {get;set;}
=20
void Generate ();
Index: generator/ManualGen.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/generator/ManualGen.cs,v
retrieving revision 1.1
diff -u -r1.1 ManualGen.cs
--- generator/ManualGen.cs 19 May 2003 02:46:15 -0000 1.1
+++ generator/ManualGen.cs 30 May 2003 07:32:57 -0000
@@ -81,6 +81,11 @@
return FromNative (var);
}
=20
+ public virtual String ToNativeReturn(String var)
+ {
+ return CallByName (var);
+ }
+ =09
public bool DoGenerate {
get {
return false;
Index: generator/SignalHandler.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/generator/SignalHandler.cs,v
retrieving revision 1.25
diff -u -r1.25 SignalHandler.cs
--- generator/SignalHandler.cs 19 May 2003 02:45:17 -0000 1.25
+++ generator/SignalHandler.cs 30 May 2003 07:32:57 -0000
@@ -162,7 +162,7 @@
else
sw.WriteLine ("\t\t\t\tthrow new Exception(\"args.RetVal unset in ca=
llback\");");
=20
- sw.WriteLine("\t\t\treturn (" + p_ret + ") " + table.CallByName (retv=
al, "((" + s_ret + ")args.RetVal)") + ";");
+ sw.WriteLine("\t\t\treturn (" + p_ret + ") " + table.ToNativeReturn (=
retval, "((" + s_ret + ")args.RetVal)") + ";");
}
sw.WriteLine("\t\t}");
sw.WriteLine();
Index: generator/SimpleGen.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/generator/SimpleGen.cs,v
retrieving revision 1.1
diff -u -r1.1 SimpleGen.cs
--- generator/SimpleGen.cs 19 May 2003 02:46:15 -0000 1.1
+++ generator/SimpleGen.cs 30 May 2003 07:32:57 -0000
@@ -68,6 +68,11 @@
return var;
}
=20
+ public String ToNativeReturn(String var)
+ {
+ return var;
+ }
+
public bool DoGenerate {
get {
return false;
Index: generator/StringGen.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: generator/StringGen.cs
diff -N generator/StringGen.cs
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ generator/StringGen.cs 30 May 2003 07:32:57 -0000
@@ -0,0 +1,28 @@
+// GtkSharp.Generation.StringGen.cs - The String type Generatable.
+//
+// Author: Rachel Hestilow <rachel@nullenvoid.com>
+//
+// (c) 2003 Rachel Hestilow
+
+namespace GtkSharp.Generation {
+
+ using System;
+
+ public class StringGen : ConstStringGen {
+
+ public StringGen (string ctype) : base (ctype)
+ {
+ }
+=09
+ public override String FromNativeReturn(String var)
+ {
+ return "GLibSharp.Marshaller.PtrToStringGFree(" + var + ")";
+ }
+
+ public override String ToNativeReturn(String var)
+ {
+ return "GLibSharp.Marshaller.StringToPtrGStrdup(" + var + ")";
+ }
+ }
+}
+
Index: generator/StructBase.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/generator/StructBase.cs,v
retrieving revision 1.34
diff -u -r1.34 StructBase.cs
--- generator/StructBase.cs 19 May 2003 02:45:17 -0000 1.34
+++ generator/StructBase.cs 30 May 2003 07:32:57 -0000
@@ -81,6 +81,12 @@
return QualifiedName + ".New (" + var + ")";
}
=20
+ public override String ToNativeReturn(String var)
+ {
+ // FIXME
+ return var;
+ }
+
bool IsBit (XmlElement field)
{
return (field.HasAttribute("bits") && (field.GetAttribute("bits") =3D=
=3D "1"));
Index: generator/SymbolTable.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/generator/SymbolTable.cs,v
retrieving revision 1.43
diff -u -r1.43 SymbolTable.cs
--- generator/SymbolTable.cs 19 May 2003 02:45:17 -0000 1.43
+++ generator/SymbolTable.cs 30 May 2003 07:32:59 -0000
@@ -39,9 +39,11 @@
AddType (new SimpleGen ("gushort", "ushort"));
AddType (new SimpleGen ("guint32", "uint"));
AddType (new SimpleGen ("guint64", "ulong"));
- AddType (new SimpleGen ("const-gchar", "string"));
- AddType (new SimpleGen ("const-char", "string"));
- AddType (new SimpleGen ("gchar", "string"));
+ // Const returned strings must be generated=20
+ // differently from memory-managed strings
+ AddType (new ConstStringGen ("const-gchar"));
+ AddType (new ConstStringGen ("const-char"));
+ AddType (new StringGen ("gchar"));
AddType (new SimpleGen ("gfloat", "float"));
AddType (new SimpleGen ("gdouble", "double"));
AddType (new SimpleGen ("gint8", "sbyte"));
@@ -57,10 +59,10 @@
AddType (new SimpleGen ("gulong", "ulong"));
AddType (new SimpleGen ("GQuark", "int"));
AddType (new SimpleGen ("int", "int"));
- AddType (new SimpleGen ("char", "string"));
+ AddType (new StringGen ("char"));
AddType (new SimpleGen ("double", "double"));
AddType (new SimpleGen ("float", "float"));
- AddType (new SimpleGen ("gunichar", "string"));
+ AddType (new StringGen ("gunichar"));
AddType (new SimpleGen ("uint1", "bool"));
AddType (new SimpleGen ("GPtrArray", "IntPtr[]"));
AddType (new SimpleGen ("GType", "uint"));
@@ -127,6 +129,10 @@
if (type =3D=3D "void*" || type =3D=3D "const-void*") return "gpointer"=
;
=20
string trim_type =3D type.TrimEnd('*');
+
+ // HACK: Similar to above, but for const strings
+ if (trim_type =3D=3D "const-gchar" || trim_type =3D=3D "const-char") re=
turn trim_type;
+ =09
if (trim_type.StartsWith("const-")) return trim_type.Substring(6);
return trim_type;
}
@@ -146,6 +152,14 @@
if (gen =3D=3D null)
return "";
return gen.FromNativeReturn (val);
+ }
+ =09
+ public string ToNativeReturn(string c_type, string val)
+ {
+ IGeneratable gen =3D this[c_type];
+ if (gen =3D=3D null)
+ return "";
+ return gen.ToNativeReturn (val);
}
=20
public string FromNative(string c_type, string val)
Index: glade/XML.custom
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/glade/XML.custom,v
retrieving revision 1.12
diff -u -r1.12 XML.custom
--- glade/XML.custom 2 May 2003 23:06:21 -0000 1.12
+++ glade/XML.custom 30 May 2003 07:32:59 -0000
@@ -23,14 +23,14 @@
}
=20
[DllImport("gtksharpglue")]
- static extern string gtksharp_glade_xml_get_filename (IntPtr raw);
+ static extern IntPtr gtksharp_glade_xml_get_filename (IntPtr raw);
=20
/// <summary>Filename Property</summary>
/// <remarks>Gets the filename used to create this GladeXML object
/// </remarks>
public string Filename {
get {
- string ret =3D gtksharp_glade_xml_get_filename (Handle);
+ string ret =3D Marshal.PtrToStringAnsi (gtksharp_glade_xml_get_filenam=
e (Handle));
return ret;
}
}
@@ -44,10 +44,10 @@
}
=20
[DllImport("libglade-2.0-0.dll")]
- static extern string glade_get_widget_name (IntPtr widget);
+ static extern IntPtr glade_get_widget_name (IntPtr widget);
=20
static public string GetWidgetName (Gtk.Widget w) {
- string ret =3D glade_get_widget_name (w.Handle);
+ string ret =3D Marshal.PtrToStringAnsi (glade_get_widget_name (w.Handle=
));
return ret;
}
=20
Index: glib/GException.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/glib/GException.cs,v
retrieving revision 1.4
diff -u -r1.4 GException.cs
--- glib/GException.cs 22 Feb 2003 04:34:55 -0000 1.4
+++ glib/GException.cs 30 May 2003 07:32:59 -0000
@@ -19,10 +19,10 @@
}
=20
[DllImport("gtksharpglue")]
- static extern string gtksharp_error_get_message (IntPtr errptr);
+ static extern IntPtr gtksharp_error_get_message (IntPtr errptr);
public override string Message {
get {
- return gtksharp_error_get_message (errptr);
+ return Marshal.PtrToStringAnsi (gtksharp_error_get_message (errptr));
}
}
=20
Index: glib/Markup.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/glib/Markup.cs,v
retrieving revision 1.1
diff -u -r1.1 Markup.cs
--- glib/Markup.cs 3 Mar 2003 01:42:26 -0000 1.1
+++ glib/Markup.cs 30 May 2003 07:32:59 -0000
@@ -14,14 +14,14 @@
=20
public class Markup {
[DllImport("libglib-2.0-0.dll")]
- static extern string g_markup_escape_text (string text, int len);
+ static extern IntPtr g_markup_escape_text (string text, int len);
=09
static public string EscapeText (string s)
{
if (s =3D=3D null)
return "";
=20
- return g_markup_escape_text (s, s.Length);
+ return GLibSharp.Marshaller.PtrToStringGFree (g_markup_escape_text (s, =
s.Length));
}
}
}
Index: glib/Marshaller.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: glib/Marshaller.cs
diff -N glib/Marshaller.cs
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ glib/Marshaller.cs 30 May 2003 07:32:59 -0000
@@ -0,0 +1,52 @@
+// GLibSharp.Marshaller.cs : Marshalling utils=20
+//
+// Author: Rachel Hestilow <rachel@nullenvoid.com>
+//
+// (c) 2002, 2003 Rachel Hestilow
+
+namespace GLibSharp {
+ using System;
+ using System.Runtime.InteropServices;
+=09
+ /// <summary>
+ /// Marshalling utilities=20
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Utility class for internal wrapper use
+ /// </remarks>
+=09
+ public class Marshaller {
+=09
+ [DllImport("libglib-2.0-0.dll")]
+ static extern void g_free (IntPtr mem);
+
+ public static string PtrToStringGFree (IntPtr ptr) {
+ string ret =3D Marshal.PtrToStringAnsi (ptr);
+ g_free (ptr);
+ return ret;
+ }
+
+ [DllImport("libglib-2.0-0.dll")]
+ static extern void g_strfreev (IntPtr mem);
+
+ public static string[] PtrToStringGFree (IntPtr[] ptrs) {
+ // The last pointer is a null terminator.
+ string[] ret =3D new string[ptrs.Length - 1];
+ for (int i =3D 0; i < ret.Length; i++) {
+ ret[i] =3D Marshal.PtrToStringAnsi (ptrs[i]);
+ g_free (ptrs[i]);
+ }
+ return ret;
+ }
+
+ [DllImport("libglib-2.0-0.dll")]
+ static extern IntPtr g_strdup (string str);
+
+ public static IntPtr StringToPtrGStrdup (string str) {
+ return g_strdup (str);
+ }
+
+ }
+}
+
Index: glib/Object.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/glib/Object.cs,v
retrieving revision 1.45
diff -u -r1.45 Object.cs
--- glib/Object.cs 9 Apr 2003 17:50:51 -0000 1.45
+++ glib/Object.cs 30 May 2003 07:32:59 -0000
@@ -236,9 +236,6 @@
/// Handle property.
/// </remarks>
=20
- [DllImport("libgobject-2.0.so")]
- private static extern string g_type_name (uint gtype);
-
protected virtual IntPtr Raw {
get {
return _obj;
Index: glib/ObjectManager.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/glib/ObjectManager.cs,v
retrieving revision 1.6
diff -u -r1.6 ObjectManager.cs
--- glib/ObjectManager.cs 5 Oct 2002 05:11:59 -0000 1.6
+++ glib/ObjectManager.cs 30 May 2003 07:32:59 -0000
@@ -13,14 +13,14 @@
private static Hashtable types =3D new Hashtable ();
=20
[DllImport("gtksharpglue")]
- static extern string gtksharp_get_type_name (IntPtr raw);
+ static extern IntPtr gtksharp_get_type_name (IntPtr raw);
=20
public static GLib.Object CreateObject (IntPtr raw)
{
if (raw =3D=3D IntPtr.Zero)
return null;
=20
- string typename =3D gtksharp_get_type_name (raw);
+ string typename =3D Marshal.PtrToStringAnsi (gtksharp_get_type_name (ra=
w));
string mangled;
if (types.ContainsKey(typename))=20
mangled =3D (string)types[typename];
@@ -88,7 +88,7 @@
static extern int gtksharp_get_parent_type (int typ);
=20
[DllImport("gtksharpglue")]
- static extern string gtksharp_get_type_name_for_id (int typ);
+ static extern IntPtr gtksharp_get_type_name_for_id (int typ);
=20
static Type GetValidParentType (IntPtr raw)
{
@@ -99,7 +99,7 @@
// We will always end up at GObject and will break this loop
while (true) {
type_id =3D gtksharp_get_parent_type (type_id);
- typename =3D gtksharp_get_type_name_for_id (type_id);
+ typename =3D Marshal.PtrToStringAnsi (gtksharp_get_type_name_for_id (t=
ype_id));
if (types.ContainsKey (typename))
mangled =3D (string)types[typename];
else
Index: glib/Value.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/glib/Value.cs,v
retrieving revision 1.23
diff -u -r1.23 Value.cs
--- glib/Value.cs 22 May 2003 23:39:04 -0000 1.23
+++ glib/Value.cs 30 May 2003 07:32:59 -0000
@@ -517,7 +517,7 @@
}
=20
[DllImport("libgobject-2.0-0.dll")]
- static extern string g_value_get_string (IntPtr val);
+ static extern IntPtr g_value_get_string (IntPtr val);
=20
/// <summary>
/// Value to String Conversion
@@ -533,7 +533,7 @@
{
// FIXME: Insert an appropriate exception here if
// _val.type indicates an error.
- return g_value_get_string (val._val);
+ return Marshal.PtrToStringAnsi (g_value_get_string (val._val));
}
=20
[DllImport("libgobject-2.0-0.dll")]
Index: glue/fileselection.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/glue/fileselection.c,v
retrieving revision 1.2
diff -u -r1.2 fileselection.c
--- glue/fileselection.c 22 Mar 2003 17:37:43 -0000 1.2
+++ glue/fileselection.c 30 May 2003 07:32:59 -0000
@@ -32,7 +32,7 @@
=20
GtkWidget *gtksharp_file_selection_get_fileop_entry (GtkFileSelection *fil=
e);
=20
-gchar *gtksharp_file_selection_get_fileop_file (GtkFileSelection *file=
);
+const gchar *gtksharp_file_selection_get_fileop_file (GtkFileSelection *fi=
le);
=20
GtkWidget *gtksharp_file_selection_get_fileop_c_dir (GtkFileSelection *fil=
e);
=20
@@ -117,7 +117,7 @@
return file->fileop_entry;
}
=20
-gchar*
+const gchar*
gtksharp_file_selection_get_fileop_file (GtkFileSelection *file)
{
return file->fileop_file;
Index: gtk/ColorSelection.custom
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/gtk/ColorSelection.custom,v
retrieving revision 1.1
diff -u -r1.1 ColorSelection.custom
--- gtk/ColorSelection.custom 14 Apr 2003 17:04:13 -0000 1.1
+++ gtk/ColorSelection.custom 30 May 2003 07:32:59 -0000
@@ -3,13 +3,13 @@
// Author: Justin Malcolm
=20
[DllImport("libgtk-win32-2.0-0.dll")]
- static extern string gtk_color_selection_palette_to_string(Gdk.Color[] c=
olors, int n_colors);
+ static extern IntPtr gtk_color_selection_palette_to_string(Gdk.Color[] c=
olors, int n_colors);
=20
/// <summary> PaletteToString Method </summary>
public static string PaletteToString(Gdk.Color[] colors) {
int n_colors =3D colors.Length;
- string raw_ret =3D gtk_color_selection_palette_to_string(colors, n_colo=
rs);
- string ret =3D raw_ret;
+ IntPtr raw_ret =3D gtk_color_selection_palette_to_string(colors, n_colo=
rs);
+ string ret =3D GLibSharp.Marshaller.PtrToStringGFree (raw_ret);
return ret;
}
=09
Index: gtk/FileSelection.custom
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/gtk/FileSelection.custom,v
retrieving revision 1.6
diff -u -r1.6 FileSelection.custom
--- gtk/FileSelection.custom 20 Feb 2003 04:03:15 -0000 1.6
+++ gtk/FileSelection.custom 30 May 2003 07:32:59 -0000
@@ -88,10 +88,10 @@
}
=20
[DllImport("gtksharpglue", CallingConvention=3DCallingConvention.Cdecl)]
-static extern string gtksharp_file_selection_get_fileop_file (IntPtr i);
+static extern IntPtr gtksharp_file_selection_get_fileop_file (IntPtr i);
public string FileopFile {
get {
- return gtksharp_file_selection_get_fileop_file (this.Handle);
+ return Marshal.PtrToStringAnsi (gtksharp_file_selection_get_fileop_file =
(this.Handle));
}
}
=20
Index: gtk/SelectionData.custom
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/gtk/SelectionData.custom,v
retrieving revision 1.2
diff -u -r1.2 SelectionData.custom
--- gtk/SelectionData.custom 22 Feb 2003 04:34:56 -0000 1.2
+++ gtk/SelectionData.custom 30 May 2003 07:32:59 -0000
@@ -1,13 +1,13 @@
=20
[DllImport("libgtk-win32-2.0-0.dll")]
- private static extern string gtk_selection_data_get_text (ref Gtk.Select=
ionData selection_data);
+ private static extern IntPtr gtk_selection_data_get_text (ref Gtk.Select=
ionData selection_data);
=20
[DllImport("libgtk-win32-2.0-0.dll")]
private static extern void gtk_selection_data_set_text (ref Gtk.Selectio=
nData selection_data, string str, int len);
=20
public string Text {
get {
- return gtk_selection_data_get_text (ref this);
+ return GLibSharp.Marshaller.PtrToStringGFree (gtk_selection_data_get_t=
ext (ref this));
}
set {
gtk_selection_data_set_text (ref this, value, value.Length);
--=-0/RsPbLrQruopYtPOmgg--
--=-4YhnCzSALGK75DNn3APY
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQA+1wsdapOJdUj74F4RAoIDAJ9yMJMHFvdJzyKkkT0c6ShgivMZpwCeM3En
BmI9/Z4G+pmHc5rnngxP/K0=
=JkI6
-----END PGP SIGNATURE-----
--=-4YhnCzSALGK75DNn3APY--