2009-01-08 Mike Kestner <mkestner@novell.com>
* generator/InterfaceGen.cs: generate Adapters for consume_only ifaces too. This seems unusual, but is primarily to produce at least one 'generic' implementation of every interface and a GetObject method so that the marshaling code can always return an object which implements the interface, even if no public object wrapper exists for the underlying c GObject type. svn path=/trunk/gtk-sharp/; revision=122814
This commit is contained in:
parent
1a16f66803
commit
756e0c49b9
2 changed files with 45 additions and 31 deletions
|
@ -1,3 +1,12 @@
|
|||
2009-01-08 Mike Kestner <mkestner@novell.com>
|
||||
|
||||
* generator/InterfaceGen.cs: generate Adapters for consume_only ifaces
|
||||
too. This seems unusual, but is primarily to produce at least one
|
||||
'generic' implementation of every interface and a GetObject method
|
||||
so that the marshaling code can always return an object which
|
||||
implements the interface, even if no public object wrapper exists for
|
||||
the underlying c GObject type.
|
||||
|
||||
2009-01-08 Mike Kestner <mkestner@novell.com>
|
||||
|
||||
* generator/ReturnValue.cs: map gfilename* list elements to type
|
||||
|
|
|
@ -65,9 +65,6 @@ namespace GtkSharp.Generation {
|
|||
|
||||
public override string FromNative (string var, bool owned)
|
||||
{
|
||||
if (IsConsumeOnly)
|
||||
return "GLib.Object.GetObject (" + var + ", " + (owned ? "true" : "false") + ") as " + QualifiedName;
|
||||
else
|
||||
return QualifiedName + "Adapter.GetObject (" + var + ", " + (owned ? "true" : "false") + ")";
|
||||
}
|
||||
|
||||
|
@ -161,6 +158,7 @@ namespace GtkSharp.Generation {
|
|||
|
||||
void GenerateCtors (StreamWriter sw)
|
||||
{
|
||||
if (!IsConsumeOnly) {
|
||||
sw.WriteLine ("\t\tpublic " + Name + "Adapter ()");
|
||||
sw.WriteLine ("\t\t{");
|
||||
sw.WriteLine ("\t\t\tInitHandler = new GLib.GInterfaceInitHandler (Initialize);");
|
||||
|
@ -175,6 +173,7 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine ("\t\t\tthis.implementor = implementor;");
|
||||
sw.WriteLine ("\t\t}");
|
||||
sw.WriteLine ();
|
||||
}
|
||||
sw.WriteLine ("\t\tpublic " + Name + "Adapter (IntPtr handle)");
|
||||
sw.WriteLine ("\t\t{");
|
||||
sw.WriteLine ("\t\t\tif (!_gtype.IsInstance (handle))");
|
||||
|
@ -203,9 +202,13 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine ("\t\tIntPtr handle;");
|
||||
sw.WriteLine ("\t\tpublic override IntPtr Handle {");
|
||||
sw.WriteLine ("\t\t\tget {");
|
||||
if (IsConsumeOnly) {
|
||||
sw.WriteLine ("\t\t\t\treturn handle;");
|
||||
} else {
|
||||
sw.WriteLine ("\t\t\t\tif (handle != IntPtr.Zero)");
|
||||
sw.WriteLine ("\t\t\t\t\treturn handle;");
|
||||
sw.WriteLine ("\t\t\t\treturn implementor == null ? IntPtr.Zero : implementor.Handle;");
|
||||
}
|
||||
sw.WriteLine ("\t\t\t}");
|
||||
sw.WriteLine ("\t\t}");
|
||||
sw.WriteLine ();
|
||||
|
@ -223,8 +226,10 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine ("\t\t{");
|
||||
sw.WriteLine ("\t\t\tif (obj == null)");
|
||||
sw.WriteLine ("\t\t\t\treturn null;");
|
||||
if (!IsConsumeOnly) {
|
||||
sw.WriteLine ("\t\t\telse if (obj is " + Name + "Implementor)");
|
||||
sw.WriteLine ("\t\t\t\treturn new {0}Adapter (obj as {0}Implementor);", Name);
|
||||
}
|
||||
sw.WriteLine ("\t\t\telse if (obj as " + Name + " == null)");
|
||||
sw.WriteLine ("\t\t\t\treturn new {0}Adapter (obj.Handle);", Name);
|
||||
sw.WriteLine ("\t\t\telse");
|
||||
|
@ -245,9 +250,6 @@ namespace GtkSharp.Generation {
|
|||
|
||||
void GenerateAdapter (GenerationInfo gen_info)
|
||||
{
|
||||
if (IsConsumeOnly)
|
||||
return;
|
||||
|
||||
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name + "Adapter");
|
||||
|
||||
sw.WriteLine ("namespace " + NS + " {");
|
||||
|
@ -259,14 +261,17 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine ("\tpublic class " + Name + "Adapter : GLib.GInterfaceAdapter, " + QualifiedName + " {");
|
||||
sw.WriteLine ();
|
||||
|
||||
if (!IsConsumeOnly) {
|
||||
GenerateIfaceStruct (sw);
|
||||
GenerateStaticCtor (sw);
|
||||
GenerateCallbacks (sw);
|
||||
GenerateInitialize (sw);
|
||||
}
|
||||
GenerateCtors (sw);
|
||||
GenerateGType (sw);
|
||||
GenerateHandleProp (sw);
|
||||
GenerateGetObject (sw);
|
||||
if (!IsConsumeOnly)
|
||||
GenerateImplementorProp (sw);
|
||||
|
||||
GenProperties (gen_info, null);
|
||||
|
|
Loading…
Reference in a new issue