mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-09 00:13:20 +02:00
2005-03-04 Mike Kestner <mkestner@novell.com>
* generator/ImportSignature.cs : out param handling fix. * generator/Makefile.am : kill StringGen.cs. * generator/MethodBody.cs : simplify out param handling. * generator/StringGen.cs : kill it, now using MarshalGen. * generator/SymbolTable.cs : make non-const strings use an appropriate MarshalGen. Non-const strings are now correctly marshaled as Utf8. * glib/Marshaller.cs : add some utf8-fu for strdup/free marshaling. Add a method to alloc/copy structs to native memory, unused yet. * gtk/Gtk.metadata : partially fix a broken delegate. svn path=/trunk/gtk-sharp/; revision=41459
This commit is contained in:
parent
2fcb8f1b79
commit
0b0700bae6
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
2005-03-04 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
|
* generator/ImportSignature.cs : out param handling fix.
|
||||||
|
* generator/Makefile.am : kill StringGen.cs.
|
||||||
|
* generator/MethodBody.cs : simplify out param handling.
|
||||||
|
* generator/StringGen.cs : kill it, now using MarshalGen.
|
||||||
|
* generator/SymbolTable.cs : make non-const strings use an appropriate
|
||||||
|
MarshalGen. Non-const strings are now correctly marshaled as Utf8.
|
||||||
|
* glib/Marshaller.cs : add some utf8-fu for strdup/free marshaling.
|
||||||
|
Add a method to alloc/copy structs to native memory, unused yet.
|
||||||
|
* gtk/Gtk.metadata : partially fix a broken delegate.
|
||||||
|
|
||||||
2005-03-04 Mike Kestner <mkestner@novell.com>
|
2005-03-04 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
* generator/Method.cs : refactor out some retval logic.
|
* generator/Method.cs : refactor out some retval logic.
|
||||||
|
@ -56,7 +56,7 @@ namespace GtkSharp.Generation {
|
|||||||
parms [i] = "";
|
parms [i] = "";
|
||||||
if (p.CType == "GError**")
|
if (p.CType == "GError**")
|
||||||
parms [i] += "out ";
|
parms [i] += "out ";
|
||||||
else if (p.PassAs != "" && (!m_type.EndsWith ("IntPtr") || p.Generatable is LPGen || p.Generatable is LPUGen || UsesHandle (p.Generatable)))
|
else if (p.PassAs != "")
|
||||||
parms [i] += p.PassAs + " ";
|
parms [i] += p.PassAs + " ";
|
||||||
parms [i] += m_type + " " + p.Name;
|
parms [i] += m_type + " " + p.Name;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,6 @@ sources = \
|
|||||||
SimpleBase.cs \
|
SimpleBase.cs \
|
||||||
SimpleGen.cs \
|
SimpleGen.cs \
|
||||||
Statistics.cs \
|
Statistics.cs \
|
||||||
StringGen.cs \
|
|
||||||
StructBase.cs \
|
StructBase.cs \
|
||||||
StructGen.cs \
|
StructGen.cs \
|
||||||
SymbolTable.cs \
|
SymbolTable.cs \
|
||||||
|
@ -86,16 +86,10 @@ namespace GtkSharp.Generation {
|
|||||||
if (p.CType == "GError**") {
|
if (p.CType == "GError**") {
|
||||||
result [i] += "out ";
|
result [i] += "out ";
|
||||||
} else if (p.PassAs != "") {
|
} else if (p.PassAs != "") {
|
||||||
if (p.Generatable is LPGen || p.Generatable is LPUGen || !p.MarshalType.EndsWith ("IntPtr"))
|
result [i] += p.PassAs + " ";
|
||||||
result [i] += p.PassAs + " ";
|
|
||||||
|
if (p.CSType != p.MarshalType && !(igen is StructBase || igen is ByRefGen))
|
||||||
if (igen is EnumGen)
|
call_parm = p.Name + "_as_native";
|
||||||
call_parm = p.Name + "_as_int";
|
|
||||||
else if (igen is LPUGen || igen is LPGen)
|
|
||||||
call_parm = p.Name + "_as_ptr";
|
|
||||||
else if (UsesHandle (igen)) {
|
|
||||||
call_parm = p.PassAs + " " + p.Name + "_handle";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p.CType == "GError**") {
|
if (p.CType == "GError**") {
|
||||||
@ -128,14 +122,8 @@ namespace GtkSharp.Generation {
|
|||||||
if (is_set)
|
if (is_set)
|
||||||
name = "value";
|
name = "value";
|
||||||
|
|
||||||
if ((is_get || p.PassAs == "out") && UsesHandle (gen))
|
if ((is_get || p.PassAs == "out") && p.CSType != p.MarshalType && !(gen is StructBase || gen is ByRefGen))
|
||||||
sw.WriteLine(indent + "\t\t\tIntPtr " + name + "_handle;");
|
sw.WriteLine(indent + "\t\t\t" + gen.MarshalType + " " + name + "_as_native;");
|
||||||
|
|
||||||
if (p.PassAs == "out" && gen is EnumGen)
|
|
||||||
sw.WriteLine(indent + "\t\t\tint " + name + "_as_int;");
|
|
||||||
|
|
||||||
if (p.PassAs == "out" && (gen is LPGen || gen is LPUGen))
|
|
||||||
sw.WriteLine(indent + "\t\t\t" + gen.MarshalType + " " + name + "_as_ptr;");
|
|
||||||
|
|
||||||
if (p.IsArray && p.MarshalType != p.CSType) {
|
if (p.IsArray && p.MarshalType != p.CSType) {
|
||||||
sw.WriteLine(indent + "\t\t\t{0}[] native_{1} = new {0} [{1}.Length];", p.MarshalType.TrimEnd('[', ']'), name);
|
sw.WriteLine(indent + "\t\t\t{0}[] native_{1} = new {0} [{1}.Length];", p.MarshalType.TrimEnd('[', ']'), name);
|
||||||
@ -170,14 +158,9 @@ namespace GtkSharp.Generation {
|
|||||||
|
|
||||||
IGeneratable gen = p.Generatable;
|
IGeneratable gen = p.Generatable;
|
||||||
|
|
||||||
if (p.PassAs == "out" && gen is EnumGen)
|
string name = p.Name;
|
||||||
sw.WriteLine(indent + "\t\t\t" + p.Name + " = (" + p.CSType + ") " + p.Name + "_as_int;");
|
if (p.PassAs == "out" && p.CSType != p.MarshalType && !(gen is StructBase || gen is ByRefGen))
|
||||||
|
sw.WriteLine(indent + "\t\t\t" + p.Name + " = " + gen.FromNative (p.Name + "_as_native") + ";");
|
||||||
if (p.PassAs == "out" && (gen is LPGen || gen is LPUGen))
|
|
||||||
sw.WriteLine(indent + "\t\t\t" + p.Name + " = (" + p.CSType + ") " + p.Name + "_as_ptr;");
|
|
||||||
|
|
||||||
if (p.PassAs == "out" && UsesHandle (gen))
|
|
||||||
sw.WriteLine(indent + "\t\t\t" + p.Name + " = " + gen.FromNativeReturn (p.Name + "_handle") + ";");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
// GtkSharp.Generation.StringGen.cs - The String type Generatable.
|
|
||||||
//
|
|
||||||
// Author: Rachel Hestilow <rachel@nullenvoid.com>
|
|
||||||
// Mike Kestner <mkestner@novell.com>
|
|
||||||
//
|
|
||||||
// Copyright (c) 2003 Rachel Hestilow
|
|
||||||
// Copyright (c) 2004 Novell, Inc.
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
|
||||||
// License as published by the Free Software Foundation.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
// General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public
|
|
||||||
// License along with this program; if not, write to the
|
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
// Boston, MA 02111-1307, USA.
|
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
|
||||||
|
|
||||||
using System;
|
|
||||||
|
|
||||||
public class StringGen : ConstStringGen {
|
|
||||||
|
|
||||||
public StringGen (string ctype) : base (ctype)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToNativeReturnType {
|
|
||||||
get {
|
|
||||||
return "IntPtr";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string FromNativeReturn(String var)
|
|
||||||
{
|
|
||||||
return "GLib.Marshaller.PtrToStringGFree(" + var + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToNativeReturn(String var)
|
|
||||||
{
|
|
||||||
return "GLib.Marshaller.StringToPtrGStrdup(" + var + ")";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
// GtkSharp.Generation.SymbolTable.cs - The Symbol Table Class.
|
// GtkSharp.Generation.SymbolTable.cs - The Symbol Table Class.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
// Author: Mike Kestner <mkestner@novell.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001-2003 Mike Kestner
|
// Copyright (c) 2001-2003 Mike Kestner
|
||||||
// Copyright (c) 2004 Novell, Inc.
|
// Copyright (c) 2004-2005 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
@ -90,8 +90,8 @@ namespace GtkSharp.Generation {
|
|||||||
AddType (new ConstStringGen ("const-gchar"));
|
AddType (new ConstStringGen ("const-gchar"));
|
||||||
AddType (new ConstStringGen ("const-xmlChar"));
|
AddType (new ConstStringGen ("const-xmlChar"));
|
||||||
AddType (new ConstStringGen ("const-char"));
|
AddType (new ConstStringGen ("const-char"));
|
||||||
AddType (new StringGen ("gchar"));
|
AddType (new MarshalGen ("gchar", "string", "IntPtr", "GLib.Marshaller.StringToPtrGStrdup({0})", "GLib.Marshaller.PtrToStringGFree({0})"));
|
||||||
AddType (new StringGen ("char"));
|
AddType (new MarshalGen ("char", "string", "IntPtr", "GLib.Marshaller.StringToPtrGStrdup({0})", "GLib.Marshaller.PtrToStringGFree({0})"));
|
||||||
|
|
||||||
// manually wrapped types requiring more complex marshaling
|
// manually wrapped types requiring more complex marshaling
|
||||||
AddType (new ManualGen ("GObject", "GLib.Object", "GLib.Object.GetObject ({0})"));
|
AddType (new ManualGen ("GObject", "GLib.Object", "GLib.Object.GetObject ({0})"));
|
||||||
|
@ -32,8 +32,20 @@ namespace GLib {
|
|||||||
[DllImport("libglib-2.0-0.dll")]
|
[DllImport("libglib-2.0-0.dll")]
|
||||||
static extern void g_free (IntPtr mem);
|
static extern void g_free (IntPtr mem);
|
||||||
|
|
||||||
public static string PtrToStringGFree (IntPtr ptr) {
|
[DllImport("libglib-2.0-0.dll")]
|
||||||
string ret = Marshal.PtrToStringAnsi (ptr);
|
static extern IntPtr g_utf8_strlen (IntPtr mem, int size);
|
||||||
|
|
||||||
|
public static string Utf8PtrToString (IntPtr ptr)
|
||||||
|
{
|
||||||
|
int len = (int) g_utf8_strlen (ptr, -1);
|
||||||
|
byte[] bytes = new byte [len];
|
||||||
|
Marshal.Copy (ptr, bytes, 0, len);
|
||||||
|
return System.Text.Encoding.UTF8.GetString (bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string PtrToStringGFree (IntPtr ptr)
|
||||||
|
{
|
||||||
|
string ret = Utf8PtrToString (ptr);
|
||||||
g_free (ptr);
|
g_free (ptr);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -45,17 +57,18 @@ namespace GLib {
|
|||||||
// The last pointer is a null terminator.
|
// The last pointer is a null terminator.
|
||||||
string[] ret = new string[ptrs.Length - 1];
|
string[] ret = new string[ptrs.Length - 1];
|
||||||
for (int i = 0; i < ret.Length; i++) {
|
for (int i = 0; i < ret.Length; i++) {
|
||||||
ret[i] = Marshal.PtrToStringAnsi (ptrs[i]);
|
ret[i] = Utf8PtrToString (ptrs[i]);
|
||||||
g_free (ptrs[i]);
|
g_free (ptrs[i]);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("libglib-2.0-0.dll")]
|
[DllImport("libglib-2.0-0.dll")]
|
||||||
static extern IntPtr g_strdup (string str);
|
static extern IntPtr g_strdup (byte[] bytes);
|
||||||
|
|
||||||
public static IntPtr StringToPtrGStrdup (string str) {
|
public static IntPtr StringToPtrGStrdup (string str) {
|
||||||
return g_strdup (str);
|
byte[] bytes = System.Text.Encoding.UTF8.GetBytes (str);
|
||||||
|
return g_strdup (bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string StringFormat (string format, params object[] args) {
|
public static string StringFormat (string format, params object[] args) {
|
||||||
@ -204,6 +217,12 @@ namespace GLib {
|
|||||||
return glibsharp_utf16_to_unichar ((ushort) c);
|
return glibsharp_utf16_to_unichar ((ushort) c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IntPtr PtrToStructureAlloc (object o)
|
||||||
|
{
|
||||||
|
IntPtr result = Marshal.AllocHGlobal (Marshal.SizeOf (o));
|
||||||
|
Marshal.StructureToPtr (o, result, false);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
<attr path="/api/namespace/boxed[@cname='GtkTextIter']/method[@name='GetToggledTags']" name="hidden">1</attr>
|
<attr path="/api/namespace/boxed[@cname='GtkTextIter']/method[@name='GetToggledTags']" name="hidden">1</attr>
|
||||||
<attr path="/api/namespace/boxed[@cname='GtkTreePath']/method[@name='GetIndices']" name="hidden">1</attr>
|
<attr path="/api/namespace/boxed[@cname='GtkTreePath']/method[@name='GetIndices']" name="hidden">1</attr>
|
||||||
<attr path="/api/namespace/callback[@cname='GtkItemFactoryCallback2']" name="hidden">1</attr>
|
<attr path="/api/namespace/callback[@cname='GtkItemFactoryCallback2']" name="hidden">1</attr>
|
||||||
|
<attr path="/api/namespace/callback[@cname='GtkModuleInitFunc']/*/*[@name='argv']" name="array">1</attr>
|
||||||
<attr path="/api/namespace/class[@cname='GtkAccel_']/method[@name='GroupsFromObject']" name="hidden">1</attr>
|
<attr path="/api/namespace/class[@cname='GtkAccel_']/method[@name='GroupsFromObject']" name="hidden">1</attr>
|
||||||
<attr path="/api/namespace/class[@cname='GtkAccelerator_']/method[@name='GetDefaultModMask']/return-type" name="type">GdkModifierType</attr>
|
<attr path="/api/namespace/class[@cname='GtkAccelerator_']/method[@name='GetDefaultModMask']/return-type" name="type">GdkModifierType</attr>
|
||||||
<attr path="/api/namespace/class[@cname='GtkBindings_']/method[@name='Activate']" name="name">BindingsActivate</attr>
|
<attr path="/api/namespace/class[@cname='GtkBindings_']/method[@name='Activate']" name="name">BindingsActivate</attr>
|
||||||
|
Loading…
Reference in New Issue
Block a user