generator: Bumped parser_version to 3
Added support for new closure and destroy attributes from which we can determine which callback a parameter belongs to.
This commit is contained in:
parent
7ce1457c13
commit
3eefa37272
4 changed files with 48 additions and 7 deletions
|
@ -101,17 +101,26 @@ namespace GtkSharp.Generation {
|
|||
if (gen is CallbackGen) {
|
||||
CallbackGen cbgen = gen as CallbackGen;
|
||||
string wrapper = cbgen.GenWrapper(gen_info);
|
||||
|
||||
int closure = i + 1;
|
||||
if (p.Closure >= 0)
|
||||
closure = p.Closure;
|
||||
|
||||
int destroyNotify = i + 2;
|
||||
if (p.DestroyNotify >= 0)
|
||||
destroyNotify = p.DestroyNotify;
|
||||
|
||||
switch (p.Scope) {
|
||||
case "notified":
|
||||
sw.WriteLine (indent + "\t\t\t{0} {1}_wrapper = new {0} ({1});", wrapper, name);
|
||||
sw.WriteLine (indent + "\t\t\tIntPtr {0};", parameters [i + 1].Name);
|
||||
sw.WriteLine (indent + "\t\t\t{0} {1};", parameters [i + 2].CSType, parameters [i + 2].Name);
|
||||
sw.WriteLine (indent + "\t\t\tIntPtr {0};", parameters [closure].Name);
|
||||
sw.WriteLine (indent + "\t\t\t{0} {1};", parameters [destroyNotify].CSType, parameters [destroyNotify].Name);
|
||||
sw.WriteLine (indent + "\t\t\tif ({0} == null) {{", name);
|
||||
sw.WriteLine (indent + "\t\t\t\t{0} = IntPtr.Zero;", parameters [i + 1].Name);
|
||||
sw.WriteLine (indent + "\t\t\t\t{0} = null;", parameters [i + 2].Name);
|
||||
sw.WriteLine (indent + "\t\t\t\t{0} = IntPtr.Zero;", parameters [closure].Name);
|
||||
sw.WriteLine (indent + "\t\t\t\t{0} = null;", parameters [destroyNotify].Name);
|
||||
sw.WriteLine (indent + "\t\t\t} else {");
|
||||
sw.WriteLine (indent + "\t\t\t\t{0} = (IntPtr) GCHandle.Alloc ({1}_wrapper);", parameters [i + 1].Name, name);
|
||||
sw.WriteLine (indent + "\t\t\t\t{0} = GLib.DestroyHelper.NotifyHandler;", parameters [i + 2].Name, parameters [i + 2].CSType);
|
||||
sw.WriteLine (indent + "\t\t\t\t{0} = (IntPtr) GCHandle.Alloc ({1}_wrapper);", parameters [closure].Name, name);
|
||||
sw.WriteLine (indent + "\t\t\t\t{0} = GLib.DestroyHelper.NotifyHandler;", parameters [destroyNotify].Name, parameters [destroyNotify].CSType);
|
||||
sw.WriteLine (indent + "\t\t\t}");
|
||||
break;
|
||||
|
||||
|
|
|
@ -236,6 +236,30 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
int closure = -1;
|
||||
public int Closure {
|
||||
get {
|
||||
if(closure == -1 && elem.HasAttribute ("closure"))
|
||||
closure = int.Parse(elem.GetAttribute ("closure"));
|
||||
return closure;
|
||||
}
|
||||
set {
|
||||
closure = value;
|
||||
}
|
||||
}
|
||||
|
||||
int destroynotify = -1;
|
||||
public int DestroyNotify {
|
||||
get {
|
||||
if (destroynotify == -1 && elem.HasAttribute ("destroy"))
|
||||
destroynotify = int.Parse (elem.GetAttribute ("destroy"));
|
||||
return destroynotify;
|
||||
}
|
||||
set {
|
||||
destroynotify = value;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string[] Prepare {
|
||||
get {
|
||||
IGeneratable gen = Generatable;
|
||||
|
|
|
@ -80,6 +80,14 @@ namespace GtkSharp.Generation {
|
|||
return true;
|
||||
|
||||
if (HasCB || HideData) {
|
||||
|
||||
foreach (Parameter param in param_list) {
|
||||
if (param.Closure == idx)
|
||||
return true;
|
||||
else if (param.DestroyNotify == idx)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (p.IsUserData && (idx == Count - 1))
|
||||
return true;
|
||||
if (p.IsUserData && (idx == Count - 2) && this [Count - 1] is ErrorParameter)
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace GtkSharp.Generation {
|
|||
using System.Xml.Schema;
|
||||
|
||||
public class Parser {
|
||||
const int curr_parser_version = 2;
|
||||
const int curr_parser_version = 3;
|
||||
|
||||
private XmlDocument Load (string filename, string schema_file)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue