2002-01-17 Mike Kestner <mkestner@speakeasy.net>
* generator/BoxedGen.cs : Removed Name, CName, and QualifiedName. * generator/ObjectGen.cs : Removed Name, CName, and QualifiedName. * generator/StructBase.cs : Add Name, CName, and QualifiedName. Add GenCtor method. Stub GetCallString, GetImportSig, and GetSignature methods. * generator/StructGen.cs : Removed Name, CName, and QualifiedName. * generator/SymbolTable.cs : Add GetDllName method. * parser/gapi2xml.pl : Fix a couple <parameters> bugs. svn path=/trunk/gtk-sharp/; revision=2030
This commit is contained in:
parent
88175147cf
commit
2a29390caf
8 changed files with 132 additions and 66 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2002-01-17 Mike Kestner <mkestner@speakeasy.net>
|
||||
|
||||
* generator/BoxedGen.cs : Removed Name, CName, and QualifiedName.
|
||||
* generator/ObjectGen.cs : Removed Name, CName, and QualifiedName.
|
||||
* generator/StructBase.cs : Add Name, CName, and QualifiedName. Add
|
||||
GenCtor method. Stub GetCallString, GetImportSig, and GetSignature
|
||||
methods.
|
||||
* generator/StructGen.cs : Removed Name, CName, and QualifiedName.
|
||||
* generator/SymbolTable.cs : Add GetDllName method.
|
||||
* parser/gapi2xml.pl : Fix a couple <parameters> bugs.
|
||||
|
||||
2002-01-16 Mike Kestner <mkestner@speakeasy.net>
|
||||
|
||||
* generator/BoxedGen.cs : New boxed type generatable.
|
||||
|
|
|
@ -14,27 +14,6 @@ namespace GtkSharp.Generation {
|
|||
|
||||
public BoxedGen (String ns, XmlElement elem) : base (ns, elem) {}
|
||||
|
||||
public String Name {
|
||||
get
|
||||
{
|
||||
return elem.GetAttribute("name");
|
||||
}
|
||||
}
|
||||
|
||||
public String QualifiedName {
|
||||
get
|
||||
{
|
||||
return ns + "." + elem.GetAttribute("name");
|
||||
}
|
||||
}
|
||||
|
||||
public String CName {
|
||||
get
|
||||
{
|
||||
return elem.GetAttribute("cname");
|
||||
}
|
||||
}
|
||||
|
||||
public String MarshalType {
|
||||
get
|
||||
{
|
||||
|
|
|
@ -14,27 +14,6 @@ namespace GtkSharp.Generation {
|
|||
|
||||
public ObjectGen (String ns, XmlElement elem) : base (ns, elem) {}
|
||||
|
||||
public String Name {
|
||||
get
|
||||
{
|
||||
return elem.GetAttribute("name");
|
||||
}
|
||||
}
|
||||
|
||||
public String QualifiedName {
|
||||
get
|
||||
{
|
||||
return ns + "." + elem.GetAttribute("name");
|
||||
}
|
||||
}
|
||||
|
||||
public String CName {
|
||||
get
|
||||
{
|
||||
return elem.GetAttribute("cname");
|
||||
}
|
||||
}
|
||||
|
||||
public String MarshalType {
|
||||
get
|
||||
{
|
||||
|
@ -95,6 +74,9 @@ namespace GtkSharp.Generation {
|
|||
break;
|
||||
|
||||
case "constructor":
|
||||
if (!GenCtor(member, table, sw)) {
|
||||
Console.WriteLine("in object " + CName);
|
||||
}
|
||||
break;
|
||||
|
||||
case "method":
|
||||
|
|
|
@ -20,7 +20,62 @@ namespace GtkSharp.Generation {
|
|||
this.ns = ns;
|
||||
this.elem = elem;
|
||||
}
|
||||
|
||||
public String Name {
|
||||
get
|
||||
{
|
||||
return elem.GetAttribute("name");
|
||||
}
|
||||
}
|
||||
|
||||
public String QualifiedName {
|
||||
get
|
||||
{
|
||||
return ns + "." + elem.GetAttribute("name");
|
||||
}
|
||||
}
|
||||
|
||||
public String CName {
|
||||
get
|
||||
{
|
||||
return elem.GetAttribute("cname");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected bool GenCtor(XmlElement ctor, SymbolTable table, StreamWriter sw)
|
||||
{
|
||||
String sig, isig, call;
|
||||
XmlElement parms = ctor["parameters"];
|
||||
|
||||
if (parms == null) {
|
||||
sig = "()";
|
||||
isig = call = "();";
|
||||
//} else if (!GetSignature(parms, table, out sig) ||
|
||||
// !GetImportSig(parms, table, out isig) ||
|
||||
// !GetCallString(parms, table, out call)) {
|
||||
// Console.Write("ctor ");
|
||||
// return false;
|
||||
} else {
|
||||
Console.Write("ctor with parms ");
|
||||
return false;
|
||||
}
|
||||
|
||||
String cname = ctor.GetAttribute("cname");
|
||||
|
||||
sw.WriteLine("\t\t[DllImport(\"" + table.GetDllName(ns) +
|
||||
"\", CallingConvention=CallingConvention.Cdecl)]");
|
||||
sw.WriteLine("\t\tstatic extern IntPtr " + cname + isig);
|
||||
sw.WriteLine();
|
||||
sw.WriteLine("\t\tpublic " + Name + sig);
|
||||
sw.WriteLine("\t\t{");
|
||||
sw.WriteLine("\t\t\tRawObject = " + cname + call);
|
||||
sw.WriteLine("\t\t}");
|
||||
sw.WriteLine();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected bool GenField (XmlElement field, SymbolTable table, StreamWriter sw)
|
||||
{
|
||||
String c_type;
|
||||
|
@ -46,7 +101,54 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine (" " + field.GetAttribute("cname") + ";");
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool GetCallString(XmlElement parms, SymbolTable table, out String call)
|
||||
{
|
||||
call = "(";
|
||||
|
||||
foreach (XmlNode parm in parms.ChildNodes) {
|
||||
if (parm.Name != "parameter") {
|
||||
continue;
|
||||
}
|
||||
|
||||
XmlElement elem = (XmlElement) parm;
|
||||
}
|
||||
|
||||
call += ");";
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool GetImportSig(XmlElement parms, SymbolTable table, out String isig)
|
||||
{
|
||||
isig = "(";
|
||||
|
||||
foreach (XmlNode parm in parms.ChildNodes) {
|
||||
if (parm.Name != "namespace") {
|
||||
continue;
|
||||
}
|
||||
|
||||
XmlElement elem = (XmlElement) parm;
|
||||
}
|
||||
|
||||
isig += ");";
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool GetSignature(XmlElement parms, SymbolTable table, out String sig)
|
||||
{
|
||||
sig = "(";
|
||||
|
||||
foreach (XmlNode parm in parms.ChildNodes) {
|
||||
if (parm.Name != "parameter") {
|
||||
continue;
|
||||
}
|
||||
|
||||
XmlElement elem = (XmlElement) parm;
|
||||
}
|
||||
|
||||
sig += ")";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,27 +14,6 @@ namespace GtkSharp.Generation {
|
|||
|
||||
public StructGen (String ns, XmlElement elem) : base (ns, elem) {}
|
||||
|
||||
public String Name {
|
||||
get
|
||||
{
|
||||
return elem.GetAttribute("name");
|
||||
}
|
||||
}
|
||||
|
||||
public String QualifiedName {
|
||||
get
|
||||
{
|
||||
return ns + "." + elem.GetAttribute("name");
|
||||
}
|
||||
}
|
||||
|
||||
public String CName {
|
||||
get
|
||||
{
|
||||
return elem.GetAttribute("cname");
|
||||
}
|
||||
}
|
||||
|
||||
public String MarshalType {
|
||||
get
|
||||
{
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace GtkSharp.Generation {
|
|||
|
||||
private Hashtable complex_types = new Hashtable ();
|
||||
private Hashtable simple_types;
|
||||
private Hashtable dlls;
|
||||
|
||||
public SymbolTable ()
|
||||
{
|
||||
|
@ -62,6 +63,12 @@ namespace GtkSharp.Generation {
|
|||
simple_types.Add ("GHashTable", "IntPtr");
|
||||
simple_types.Add ("va_list", "IntPtr");
|
||||
simple_types.Add ("GParamSpec", "IntPtr");
|
||||
|
||||
dlls = new Hashtable();
|
||||
dlls.Add("Atk", "atk.dll");
|
||||
dlls.Add("Gdk", "gdk-1.3.dll");
|
||||
dlls.Add("Gtk", "gtk-1.3.dll");
|
||||
dlls.Add("Pango", "pango.dll");
|
||||
}
|
||||
|
||||
public void AddType (IGeneratable gen)
|
||||
|
@ -93,6 +100,11 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
public String GetDllName(String ns)
|
||||
{
|
||||
return (String) dlls[ns];
|
||||
}
|
||||
|
||||
public String GetMarshalType(String c_type)
|
||||
{
|
||||
if (simple_types.ContainsKey(c_type)) {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -105,6 +105,7 @@ while ($line = <STDIN>) {
|
|||
$line = <STDIN>;
|
||||
}
|
||||
$fdef .= $line;
|
||||
$fdef =~ s/\n\s*//g;
|
||||
$fdefs{$fname} = $fdef;
|
||||
} elsif ($line =~ /G_TYPE_CHECK_(\w+)_CAST.*,\s*(\w+),\s*(\w+)/) {
|
||||
if ($1 eq "INSTANCE") {
|
||||
|
@ -381,9 +382,9 @@ sub addFuncElems
|
|||
|
||||
$mdef = delete $fdefs{$mname};
|
||||
|
||||
if (($mdef =~ /\(.*\)/) && ($1 ne "void")) {
|
||||
if (($mdef =~ /\((.*)\)/) && ($1 ne "void")) {
|
||||
@parms = split(/,/, $1);
|
||||
($dump, @parms) = @params if $dump_1st;
|
||||
($dump, @parms) = @params if $drop_1st;
|
||||
if (@parms > 0) {
|
||||
addParamsElem($el, @parms);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue