mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-02 14:36:41 +00:00
Update code generator from gtk-sharp trunk
This commit is contained in:
parent
a4e2955c7c
commit
1841f75917
5 changed files with 38 additions and 25 deletions
|
@ -58,6 +58,11 @@ namespace GtkSharp.Generation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string CallByName (string var, bool owned)
|
||||||
|
{
|
||||||
|
return String.Format ("{0} == null ? IntPtr.Zero : (({0} is GLib.Object) ? ({0} as GLib.Object).{1} : ({0} as {2}Adapter).{1})", var, owned ? "OwnedHandle" : "Handle", QualifiedName);
|
||||||
|
}
|
||||||
|
|
||||||
public override string FromNative (string var, bool owned)
|
public override string FromNative (string var, bool owned)
|
||||||
{
|
{
|
||||||
return QualifiedName + "Adapter.GetObject (" + var + ", " + (owned ? "true" : "false") + ")";
|
return QualifiedName + "Adapter.GetObject (" + var + ", " + (owned ? "true" : "false") + ")";
|
||||||
|
@ -121,19 +126,23 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
void GenerateCtors (StreamWriter sw)
|
void GenerateCtors (StreamWriter sw)
|
||||||
{
|
{
|
||||||
|
// Native GObjects do not implement the *Implementor interfaces
|
||||||
|
sw.WriteLine ("\t\tGLib.Object implementor;", Name);
|
||||||
|
sw.WriteLine ();
|
||||||
|
|
||||||
if (!IsConsumeOnly) {
|
if (!IsConsumeOnly) {
|
||||||
sw.WriteLine ("\t\tpublic " + Name + "Adapter ()");
|
sw.WriteLine ("\t\tpublic " + Name + "Adapter ()");
|
||||||
sw.WriteLine ("\t\t{");
|
sw.WriteLine ("\t\t{");
|
||||||
sw.WriteLine ("\t\t\tInitHandler = new GLib.GInterfaceInitHandler (Initialize);");
|
sw.WriteLine ("\t\t\tInitHandler = new GLib.GInterfaceInitHandler (Initialize);");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\t{0}Implementor implementor;", Name);
|
|
||||||
sw.WriteLine ();
|
|
||||||
sw.WriteLine ("\t\tpublic {0}Adapter ({0}Implementor implementor)", Name);
|
sw.WriteLine ("\t\tpublic {0}Adapter ({0}Implementor implementor)", Name);
|
||||||
sw.WriteLine ("\t\t{");
|
sw.WriteLine ("\t\t{");
|
||||||
sw.WriteLine ("\t\t\tif (implementor == null)");
|
sw.WriteLine ("\t\t\tif (implementor == null)");
|
||||||
sw.WriteLine ("\t\t\t\tthrow new ArgumentNullException (\"implementor\");");
|
sw.WriteLine ("\t\t\t\tthrow new ArgumentNullException (\"implementor\");");
|
||||||
sw.WriteLine ("\t\t\tthis.implementor = implementor;");
|
sw.WriteLine ("\t\t\telse if (!(implementor is GLib.Object))");
|
||||||
|
sw.WriteLine ("\t\t\t\tthrow new ArgumentException (\"implementor must be a subclass of GLib.Object\");");
|
||||||
|
sw.WriteLine ("\t\t\tthis.implementor = implementor as GLib.Object;");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
}
|
}
|
||||||
|
@ -142,7 +151,7 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine ("\t\t{");
|
sw.WriteLine ("\t\t{");
|
||||||
sw.WriteLine ("\t\t\tif (!_gtype.IsInstance (handle))");
|
sw.WriteLine ("\t\t\tif (!_gtype.IsInstance (handle))");
|
||||||
sw.WriteLine ("\t\t\t\tthrow new ArgumentException (\"The gobject doesn't implement the GInterface of this adapter\", \"handle\");");
|
sw.WriteLine ("\t\t\t\tthrow new ArgumentException (\"The gobject doesn't implement the GInterface of this adapter\", \"handle\");");
|
||||||
sw.WriteLine ("\t\t\tthis.handle = handle;");
|
sw.WriteLine ("\t\t\timplementor = GLib.Object.GetObject (handle);");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
}
|
}
|
||||||
|
@ -163,16 +172,15 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
void GenerateHandleProp (StreamWriter sw)
|
void GenerateHandleProp (StreamWriter sw)
|
||||||
{
|
{
|
||||||
sw.WriteLine ("\t\tIntPtr handle;");
|
|
||||||
sw.WriteLine ("\t\tpublic override IntPtr Handle {");
|
sw.WriteLine ("\t\tpublic override IntPtr Handle {");
|
||||||
sw.WriteLine ("\t\t\tget {");
|
sw.WriteLine ("\t\t\tget {");
|
||||||
if (IsConsumeOnly) {
|
sw.WriteLine ("\t\t\t\treturn implementor.Handle;");
|
||||||
sw.WriteLine ("\t\t\t\treturn handle;");
|
sw.WriteLine ("\t\t\t}");
|
||||||
} else {
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ("\t\t\t\tif (handle != IntPtr.Zero)");
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\t\t\t\treturn handle;");
|
sw.WriteLine ("\t\tpublic IntPtr OwnedHandle {");
|
||||||
sw.WriteLine ("\t\t\t\treturn implementor == null ? IntPtr.Zero : implementor.Handle;");
|
sw.WriteLine ("\t\t\tget {");
|
||||||
}
|
sw.WriteLine ("\t\t\t\treturn implementor.OwnedHandle;");
|
||||||
sw.WriteLine ("\t\t\t}");
|
sw.WriteLine ("\t\t\t}");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
@ -206,7 +214,7 @@ namespace GtkSharp.Generation {
|
||||||
{
|
{
|
||||||
sw.WriteLine ("\t\tpublic " + Name + "Implementor Implementor {");
|
sw.WriteLine ("\t\tpublic " + Name + "Implementor Implementor {");
|
||||||
sw.WriteLine ("\t\t\tget {");
|
sw.WriteLine ("\t\t\tget {");
|
||||||
sw.WriteLine ("\t\t\t\treturn implementor;");
|
sw.WriteLine ("\t\t\t\treturn implementor as {0}Implementor;", Name);
|
||||||
sw.WriteLine ("\t\t\t}");
|
sw.WriteLine ("\t\t\t}");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
|
@ -59,6 +59,11 @@ namespace GtkSharp.Generation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string CallByName (string var, bool owned)
|
||||||
|
{
|
||||||
|
return String.Format ("{0} == null ? IntPtr.Zero : {0}.{1}", var, owned ? "OwnedHandle" : "Handle");
|
||||||
|
}
|
||||||
|
|
||||||
public override bool Validate ()
|
public override bool Validate ()
|
||||||
{
|
{
|
||||||
ArrayList invalids = new ArrayList ();
|
ArrayList invalids = new ArrayList ();
|
||||||
|
@ -312,11 +317,6 @@ namespace GtkSharp.Generation {
|
||||||
sw.Close ();
|
sw.Close ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string CallByName (string name, bool owned)
|
|
||||||
{
|
|
||||||
return name + " == null ? IntPtr.Zero : " + name + (owned ? ".OwnedHandle" : ".Handle");
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string FromNative (string var, bool owned)
|
public override string FromNative (string var, bool owned)
|
||||||
{
|
{
|
||||||
return "Gst.MiniObject.GetObject(" + var + (owned ? ", true" : "") + ") as " + QualifiedName;
|
return "Gst.MiniObject.GetObject(" + var + (owned ? ", true" : "") + ") as " + QualifiedName;
|
||||||
|
|
|
@ -155,11 +155,13 @@ namespace GtkSharp.Generation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string CallByName (string var, bool owned)
|
public override string CallByName (string var)
|
||||||
{
|
{
|
||||||
return String.Format ("{0} == null ? IntPtr.Zero : ({0} as GLib.Object).{1}", var, owned ? "OwnedHandle" : "Handle");
|
return CallByName (var, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract string CallByName (string var, bool owned);
|
||||||
|
|
||||||
public override string FromNative (string var, bool owned)
|
public override string FromNative (string var, bool owned)
|
||||||
{
|
{
|
||||||
return "GLib.Object.GetObject(" + var + (owned ? ", true" : "") + ") as " + QualifiedName;
|
return "GLib.Object.GetObject(" + var + (owned ? ", true" : "") + ") as " + QualifiedName;
|
||||||
|
|
|
@ -70,6 +70,11 @@ namespace GtkSharp.Generation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string CallByName (string var, bool owned)
|
||||||
|
{
|
||||||
|
return String.Format ("{0} == null ? IntPtr.Zero : {0}.{1}", var, owned ? "OwnedHandle" : "Handle");
|
||||||
|
}
|
||||||
|
|
||||||
public override bool Validate ()
|
public override bool Validate ()
|
||||||
{
|
{
|
||||||
ArrayList invalids = new ArrayList ();
|
ArrayList invalids = new ArrayList ();
|
||||||
|
|
|
@ -262,10 +262,8 @@ namespace GtkSharp.Generation {
|
||||||
call_parm += CallName;
|
call_parm += CallName;
|
||||||
} else if (gen is IManualMarshaler)
|
} else if (gen is IManualMarshaler)
|
||||||
call_parm = "native_" + CallName;
|
call_parm = "native_" + CallName;
|
||||||
else if (gen is MiniObjectGen)
|
else if (gen is ObjectBase)
|
||||||
call_parm = ((MiniObjectGen) gen).CallByName(CallName, Owned);
|
call_parm = (gen as ObjectBase).CallByName(CallName, Owned);
|
||||||
else if (gen is ObjectGen)
|
|
||||||
call_parm = ((ObjectGen) gen).CallByName(CallName, Owned);
|
|
||||||
else
|
else
|
||||||
call_parm = gen.CallByName(CallName);
|
call_parm = gen.CallByName(CallName);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue