mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-24 00:25:32 +00:00
2005-08-23 Ben Maurer <bmaurer@novell.com>
* glib/Object.cs: Escape names and ensure stuff is unique. svn path=/trunk/gtk-sharp/; revision=48772
This commit is contained in:
parent
5f89b3da2f
commit
cbe9bad936
|
@ -1,3 +1,7 @@
|
|||
2005-08-23 Ben Maurer <bmaurer@novell.com>
|
||||
|
||||
* glib/Object.cs: Escape names and ensure stuff is unique.
|
||||
|
||||
2005-08-23 Joe Shaw <joeshaw@novell.com>
|
||||
|
||||
* generator/SymbolTable.cs: Add "unsigned" as a type
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace GLib {
|
|||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
public class Object : IWrapper, IDisposable {
|
||||
|
||||
|
@ -162,10 +163,36 @@ namespace GLib {
|
|||
[DllImport("glibsharpglue-2")]
|
||||
static extern IntPtr gtksharp_register_type (IntPtr name, IntPtr parent_type);
|
||||
|
||||
|
||||
static int type_uid;
|
||||
static string BuildEscapedName (System.Type t)
|
||||
{
|
||||
string qn = t.FullName;
|
||||
// Just a random guess
|
||||
StringBuilder sb = new StringBuilder (20 + qn.Length);
|
||||
sb.Append ("__gtksharp_");
|
||||
sb.Append (type_uid++);
|
||||
sb.Append ("_");
|
||||
foreach (char c in qn) {
|
||||
if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
|
||||
sb.Append (c);
|
||||
else if (c == '.')
|
||||
sb.Append ('_');
|
||||
else if ((uint) c <= byte.MaxValue) {
|
||||
sb.Append ('+');
|
||||
sb.Append (((byte) c).ToString ("x2"));
|
||||
} else {
|
||||
sb.Append ('-');
|
||||
sb.Append (((uint) c).ToString ("x4"));
|
||||
}
|
||||
}
|
||||
return sb.ToString ();
|
||||
}
|
||||
|
||||
protected static GType RegisterGType (System.Type t)
|
||||
{
|
||||
GType parent_gtype = LookupGType (t.BaseType);
|
||||
string name = t.FullName.Replace(".", "_");
|
||||
string name = BuildEscapedName (t);
|
||||
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
|
||||
GType gtype = new GType (gtksharp_register_type (native_name, parent_gtype.Val));
|
||||
GLib.Marshaller.Free (native_name);
|
||||
|
|
Loading…
Reference in a new issue