mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-16 11:34:47 +02:00
2007-11-09 Mike Kestner <mkestner@novell.com>
* generator/Parameters.cs: support for null_term_array attribute. svn path=/trunk/gtk-sharp/; revision=89345
This commit is contained in:
parent
de78d57176
commit
373951876b
@ -1,3 +1,7 @@
|
|||||||
|
2007-11-09 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
|
* generator/Parameters.cs: support for null_term_array attribute.
|
||||||
|
|
||||||
2007-11-08 Mike Kestner <mkestner@novell.com>
|
2007-11-08 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
* glib/Marshaller.cs: new null-terminated string[] marshaler from
|
* glib/Marshaller.cs: new null-terminated string[] marshaler from
|
||||||
|
@ -81,7 +81,7 @@ namespace GtkSharp.Generation {
|
|||||||
|
|
||||||
public bool IsArray {
|
public bool IsArray {
|
||||||
get {
|
get {
|
||||||
return elem.HasAttribute("array");
|
return elem.HasAttribute("array") || elem.HasAttribute("null_term_array");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,7 +311,12 @@ namespace GtkSharp.Generation {
|
|||||||
|
|
||||||
public class ArrayParameter : Parameter {
|
public class ArrayParameter : Parameter {
|
||||||
|
|
||||||
public ArrayParameter (XmlElement elem) : base (elem) {}
|
bool null_terminated;
|
||||||
|
|
||||||
|
public ArrayParameter (XmlElement elem) : base (elem)
|
||||||
|
{
|
||||||
|
null_terminated = elem.HasAttribute ("null_term_array");
|
||||||
|
}
|
||||||
|
|
||||||
public override string MarshalType {
|
public override string MarshalType {
|
||||||
get {
|
get {
|
||||||
@ -322,6 +327,12 @@ namespace GtkSharp.Generation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NullTerminated {
|
||||||
|
get {
|
||||||
|
return null_terminated;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override string[] Prepare {
|
public override string[] Prepare {
|
||||||
get {
|
get {
|
||||||
if (CSType == MarshalType)
|
if (CSType == MarshalType)
|
||||||
@ -329,13 +340,16 @@ namespace GtkSharp.Generation {
|
|||||||
|
|
||||||
ArrayList result = new ArrayList ();
|
ArrayList result = new ArrayList ();
|
||||||
result.Add (String.Format ("int cnt_{0} = {0} == null ? 0 : {0}.Length;", CallName));
|
result.Add (String.Format ("int cnt_{0} = {0} == null ? 0 : {0}.Length;", CallName));
|
||||||
result.Add (String.Format ("{0}[] native_{1} = new {0} [cnt_{1}];", MarshalType.TrimEnd('[', ']'), CallName));
|
result.Add (String.Format ("{0}[] native_{1} = new {0} [cnt_{1}" + (NullTerminated ? " + 1" : "") + "];", MarshalType.TrimEnd('[', ']'), CallName));
|
||||||
result.Add (String.Format ("for (int i = 0; i < cnt_{0}; i++)", CallName));
|
result.Add (String.Format ("for (int i = 0; i < cnt_{0}; i++)", CallName));
|
||||||
IGeneratable gen = Generatable;
|
IGeneratable gen = Generatable;
|
||||||
if (gen is IManualMarshaler)
|
if (gen is IManualMarshaler)
|
||||||
result.Add (String.Format ("\tnative_{0} [i] = {1};", CallName, (gen as IManualMarshaler).AllocNative (CallName + "[i]")));
|
result.Add (String.Format ("\tnative_{0} [i] = {1};", CallName, (gen as IManualMarshaler).AllocNative (CallName + "[i]")));
|
||||||
else
|
else
|
||||||
result.Add (String.Format ("\tnative_{0} [i] = {1};", CallName, gen.CallByName (CallName + "[i]")));
|
result.Add (String.Format ("\tnative_{0} [i] = {1};", CallName, gen.CallByName (CallName + "[i]")));
|
||||||
|
|
||||||
|
if (NullTerminated)
|
||||||
|
result.Add (String.Format ("native_{0} [cnt_{0} + 1] = IntPtr.Zero;", CallName));
|
||||||
return (string[]) result.ToArray (typeof (string));
|
return (string[]) result.ToArray (typeof (string));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user