mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2025-03-31 04:27:02 +00:00
2007-08-01 Mike Kestner <mkestner@novell.com>
* generator/CallbackGen.cs : use Parameters.NativeCallbackSignature. * generator/Ctor.cs : use Parameters.ImportSignature prop. * generator/ImportSignature.cs : kill * generator/MethodBase.cs : kill ImportSignature prop. * generator/Method.cs : use Parameters.ImportSignature prop. * generator/NativeCallbackSignature.cs : kill * generator/Parameters.cs : add ImportSig and NativeCallbackSig. * generator/Signal.cs : use Parameters.NativeCallbackSignature prop. * generator/VirtualMethod.cs : use Parameters.ImportSignature prop. svn path=/trunk/gtk-sharp/; revision=83214
This commit is contained in:
parent
296c948db1
commit
d24e54974d
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2007-08-01 Mike Kestner <mkestner@novell.com>
|
||||
|
||||
* generator/CallbackGen.cs : use Parameters.NativeCallbackSignature.
|
||||
* generator/Ctor.cs : use Parameters.ImportSignature prop.
|
||||
* generator/ImportSignature.cs : kill
|
||||
* generator/MethodBase.cs : kill ImportSignature prop.
|
||||
* generator/Method.cs : use Parameters.ImportSignature prop.
|
||||
* generator/NativeCallbackSignature.cs : kill
|
||||
* generator/Parameters.cs : add ImportSig and NativeCallbackSig.
|
||||
* generator/Signal.cs : use Parameters.NativeCallbackSignature prop.
|
||||
* generator/VirtualMethod.cs : use Parameters.ImportSignature prop.
|
||||
|
||||
2007-07-31 Mike Kestner <mkestner@novell.com>
|
||||
|
||||
* generator/Ctor.cs : Validate before generating and adjust protection
|
||||
|
|
|
@ -30,7 +30,6 @@ namespace GtkSharp.Generation {
|
|||
|
||||
private Parameters parms;
|
||||
private Signature sig = null;
|
||||
private NativeCallbackSignature native_sig = null;
|
||||
private ReturnValue retval;
|
||||
private bool valid = true;
|
||||
|
||||
|
@ -92,8 +91,6 @@ namespace GtkSharp.Generation {
|
|||
string wrapper = Name + "Native";
|
||||
string qualname = MarshalType;
|
||||
|
||||
native_sig = new NativeCallbackSignature (parms);
|
||||
|
||||
StreamWriter sw = gen_info.OpenStream (qualname);
|
||||
|
||||
sw.WriteLine ("namespace " + NS + "Sharp {");
|
||||
|
@ -103,11 +100,11 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine ();
|
||||
sw.WriteLine ("#region Autogenerated code");
|
||||
sw.WriteLine ("\t[GLib.CDeclCallback]");
|
||||
sw.WriteLine ("\tinternal delegate " + retval.MarshalType + " " + wrapper + "(" + native_sig + ");");
|
||||
sw.WriteLine ("\tinternal delegate " + retval.MarshalType + " " + wrapper + "(" + parms.NativeCallbackSignature + ");");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("\tinternal class " + Name + "Wrapper {");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("\t\tpublic " + retval.MarshalType + " NativeCallback (" + native_sig + ")");
|
||||
sw.WriteLine ("\t\tpublic " + retval.MarshalType + " NativeCallback (" + parms.NativeCallbackSignature + ")");
|
||||
sw.WriteLine ("\t\t{");
|
||||
sw.WriteLine ("\t\t\ttry {");
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace GtkSharp.Generation {
|
|||
void GenerateImport (StreamWriter sw)
|
||||
{
|
||||
sw.WriteLine("\t\t[DllImport(\"" + LibraryName + "\")]");
|
||||
sw.WriteLine("\t\tstatic extern " + Safety + "IntPtr " + CName + "(" + ImportSignature + ");");
|
||||
sw.WriteLine("\t\tstatic extern " + Safety + "IntPtr " + CName + "(" + Parameters.ImportSignature + ");");
|
||||
sw.WriteLine();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
// GtkSharp.Generation.ImportSignature.cs - The ImportSignature Generation Class.
|
||||
//
|
||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||
//
|
||||
// Copyright (c) 2001-2003 Mike Kestner
|
||||
// Copyright (c) 2003-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;
|
||||
using System.Collections;
|
||||
|
||||
public class ImportSignature {
|
||||
|
||||
Parameters parameters;
|
||||
|
||||
public ImportSignature (Parameters parms)
|
||||
{
|
||||
parameters = parms;
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
if (parameters.Count == 0)
|
||||
return "";
|
||||
|
||||
string[] parms = new string [parameters.Count];
|
||||
for (int i = 0; i < parameters.Count; i++) {
|
||||
Parameter p = parameters [i];
|
||||
|
||||
parms [i] = "";
|
||||
if (p.PassAs != "")
|
||||
parms [i] += p.PassAs + " ";
|
||||
parms [i] += p.NativeSignature;
|
||||
}
|
||||
|
||||
string import_sig = String.Join (", ", parms);
|
||||
import_sig = import_sig.Replace ("out ref", "out");
|
||||
import_sig = import_sig.Replace ("ref ref", "ref");
|
||||
return import_sig;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -26,7 +26,6 @@ sources = \
|
|||
IAccessor.cs \
|
||||
IGeneratable.cs \
|
||||
IManualMarshaler.cs \
|
||||
ImportSignature.cs \
|
||||
InterfaceGen.cs \
|
||||
LPGen.cs \
|
||||
LPUGen.cs \
|
||||
|
@ -36,7 +35,6 @@ sources = \
|
|||
MethodBase.cs \
|
||||
MethodBody.cs \
|
||||
Method.cs \
|
||||
NativeCallbackSignature.cs \
|
||||
ObjectField.cs \
|
||||
ObjectBase.cs \
|
||||
ObjectGen.cs \
|
||||
|
|
|
@ -201,7 +201,7 @@ namespace GtkSharp.Generation {
|
|||
{
|
||||
string import_sig = IsStatic ? "" : container_type.MarshalType + " raw";
|
||||
import_sig += !IsStatic && Parameters.Count > 0 ? ", " : "";
|
||||
import_sig += ImportSignature.ToString();
|
||||
import_sig += Parameters.ImportSignature.ToString();
|
||||
sw.WriteLine("\t\t[DllImport(\"" + LibraryName + "\")]");
|
||||
if (retval.MarshalType.StartsWith ("[return:"))
|
||||
sw.WriteLine("\t\t" + retval.MarshalType + " static extern " + Safety + retval.CSType + " " + CName + "(" + import_sig + ");");
|
||||
|
|
|
@ -58,15 +58,6 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
ImportSignature isig;
|
||||
public ImportSignature ImportSignature {
|
||||
get {
|
||||
if (isig == null)
|
||||
isig = new ImportSignature (parms);
|
||||
return isig;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsStatic {
|
||||
get {
|
||||
return is_static;
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
// GtkSharp.Generation.NativeCallbackSignature.cs - The NativeCallbackSignature Generation Class.
|
||||
//
|
||||
// Author: Mike Kestner <mkestner@novell.com>
|
||||
//
|
||||
// Copyright (c) 2007 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;
|
||||
using System.Collections;
|
||||
|
||||
public class NativeCallbackSignature {
|
||||
|
||||
Parameters parameters;
|
||||
|
||||
public NativeCallbackSignature (Parameters parms)
|
||||
{
|
||||
parameters = parms;
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
if (parameters.Count == 0)
|
||||
return "";
|
||||
|
||||
string[] parms = new string [parameters.Count];
|
||||
for (int i = 0; i < parameters.Count; i++) {
|
||||
Parameter p = parameters [i];
|
||||
|
||||
parms [i] = "";
|
||||
if (p.CType == "GError**")
|
||||
parms [i] += "out ";
|
||||
else if (p.PassAs != "" && !(p.Generatable is StructBase))
|
||||
parms [i] += p.PassAs + " ";
|
||||
parms [i] += p.NativeCallbackType + " " + p.Name;
|
||||
}
|
||||
|
||||
string import_sig = String.Join (", ", parms);
|
||||
return import_sig;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -192,9 +192,25 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
public virtual string NativeCallbackSignature {
|
||||
get {
|
||||
string sig = NativeCallbackType + " " + Name;
|
||||
if (PassAs != String.Empty && !(Generatable is StructBase))
|
||||
sig = PassAs + " " + sig;
|
||||
sig = sig.Replace ("out ref", "out");
|
||||
sig = sig.Replace ("ref ref", "ref");
|
||||
return sig;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string NativeSignature {
|
||||
get {
|
||||
return MarshalType + " " + Name;
|
||||
string sig = MarshalType + " " + Name;
|
||||
if (PassAs != String.Empty)
|
||||
sig = PassAs + " " + sig;
|
||||
sig = sig.Replace ("out ref", "out");
|
||||
sig = sig.Replace ("ref ref", "ref");
|
||||
return sig;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -629,6 +645,32 @@ namespace GtkSharp.Generation {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public string ImportSignature {
|
||||
get {
|
||||
if (Count == 0)
|
||||
return String.Empty;
|
||||
|
||||
string[] result = new string [Count];
|
||||
for (int i = 0; i < Count; i++)
|
||||
result [i] = this [i].NativeSignature;
|
||||
|
||||
return String.Join (", ", result);
|
||||
}
|
||||
}
|
||||
|
||||
public string NativeCallbackSignature {
|
||||
get {
|
||||
if (Count == 0)
|
||||
return String.Empty;
|
||||
|
||||
string[] result = new string [Count];
|
||||
for (int i = 0; i < Count; i++)
|
||||
result [i] = this [i].NativeCallbackSignature;
|
||||
|
||||
return String.Join (", ", result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -372,12 +372,11 @@ namespace GtkSharp.Generation {
|
|||
|
||||
private void GenDefaultHandlerDelegate (StreamWriter sw, ClassBase implementor)
|
||||
{
|
||||
NativeCallbackSignature sig = new NativeCallbackSignature (parms);
|
||||
ManagedCallString call = new ManagedCallString (parms);
|
||||
sw.WriteLine ("\t\t[GLib.CDeclCallback]");
|
||||
sw.WriteLine ("\t\tdelegate " + retval.ToNativeType + " " + Name + "VMDelegate (" + sig.ToString () + ");\n");
|
||||
sw.WriteLine ("\t\tdelegate " + retval.ToNativeType + " " + Name + "VMDelegate (" + parms.NativeCallbackSignature + ");\n");
|
||||
sw.WriteLine ("\t\tstatic {0} {1};\n", Name + "VMDelegate", Name + "VMCallback");
|
||||
sw.WriteLine ("\t\tstatic " + retval.ToNativeType + " " + Name.ToLower() + "_cb (" + sig.ToString () + ")");
|
||||
sw.WriteLine ("\t\tstatic " + retval.ToNativeType + " " + Name.ToLower() + "_cb (" + parms.NativeCallbackSignature + ")");
|
||||
sw.WriteLine ("\t\t{");
|
||||
sw.WriteLine ("\t\t\ttry {");
|
||||
sw.WriteLine ("\t\t\t\t{0} {1}_managed = GLib.Object.GetObject ({1}, false) as {0};", implementor != null ? implementor.Name : container_type.Name, parms[0].Name);
|
||||
|
|
|
@ -32,14 +32,12 @@ namespace GtkSharp.Generation {
|
|||
XmlElement elem;
|
||||
ReturnValue retval;
|
||||
Parameters parms;
|
||||
ImportSignature isig;
|
||||
|
||||
public VirtualMethod (XmlElement elem, ClassBase container_type)
|
||||
{
|
||||
this.elem = elem;
|
||||
retval = new ReturnValue (elem ["return-type"]);
|
||||
parms = new Parameters (elem["parameters"]);
|
||||
isig = new ImportSignature (parms);
|
||||
}
|
||||
|
||||
public string CName {
|
||||
|
@ -69,7 +67,7 @@ namespace GtkSharp.Generation {
|
|||
|
||||
public string NativeDelegate {
|
||||
get {
|
||||
return "delegate " + MarshalReturnType + " " + Name + "Delegate (" + isig + ");";
|
||||
return "delegate " + MarshalReturnType + " " + Name + "Delegate (" + parms.ImportSignature + ");";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +77,7 @@ namespace GtkSharp.Generation {
|
|||
string type = parms [0].CSType;
|
||||
string name = parms [0].Name;
|
||||
string call_string = "__obj." + Name + " (" + call + ")";
|
||||
sw.WriteLine ("\t\tstatic " + MarshalReturnType + " " + Name + "Callback (" + isig + ")");
|
||||
sw.WriteLine ("\t\tstatic " + MarshalReturnType + " " + Name + "Callback (" + parms.ImportSignature + ")");
|
||||
sw.WriteLine ("\t\t{");
|
||||
sw.WriteLine ("\t\t\t" + type + " __obj = GLib.Object.GetObject (" + name + ", false) as " + type + ";");
|
||||
sw.Write (call.Setup ("\t\t\t"));
|
||||
|
|
Loading…
Reference in a new issue