generator: new --gapidir flag to search for xml files

This commit is contained in:
Stephan Sundermann 2013-10-09 20:00:14 +02:00 committed by Andrés G. Aragoneses
parent f958b2247b
commit 5eea00f705
2 changed files with 22 additions and 3 deletions

View File

@ -34,6 +34,7 @@ namespace GtkSharp.Generation {
bool show_help = false; bool show_help = false;
string dir = ""; string dir = "";
string assembly_name = ""; string assembly_name = "";
string gapidir = "";
string glue_filename = ""; string glue_filename = "";
string glue_includes = ""; string glue_includes = "";
string gluelib_name = ""; string gluelib_name = "";
@ -54,6 +55,8 @@ namespace GtkSharp.Generation {
(string v) => { dir = v; } }, (string v) => { dir = v; } },
{ "assembly-name=", "Name of the assembly for which the code is generated.", { "assembly-name=", "Name of the assembly for which the code is generated.",
(string v) => { assembly_name = v; } }, (string v) => { assembly_name = v; } },
{ "gapidir=", "GAPI xml data folder.",
(string v) => { gapidir = v; } },
{ "glue-filename=", "Filename for the generated C glue code.", { "glue-filename=", "Filename for the generated C glue code.",
(string v) => { glue_filename = v; } }, (string v) => { glue_filename = v; } },
{ "glue-includes=", "Content of #include directive to add in the generated C glue code.", { "glue-includes=", "Content of #include directive to add in the generated C glue code.",
@ -101,12 +104,12 @@ namespace GtkSharp.Generation {
Parser p = new Parser (); Parser p = new Parser ();
foreach (string include in includes) { foreach (string include in includes) {
IGeneratable[] curr_gens = p.Parse (include, schema_name); IGeneratable[] curr_gens = p.Parse (include, schema_name, gapidir);
table.AddTypes (curr_gens); table.AddTypes (curr_gens);
} }
foreach (string filename in filenames) { foreach (string filename in filenames) {
IGeneratable[] curr_gens = p.Parse (filename, schema_name); IGeneratable[] curr_gens = p.Parse (filename, schema_name, gapidir);
table.AddTypes (curr_gens); table.AddTypes (curr_gens);
gens.AddRange (curr_gens); gens.AddRange (curr_gens);
} }

View File

@ -77,6 +77,11 @@ namespace GtkSharp.Generation {
} }
public IGeneratable[] Parse (string filename, string schema_file) public IGeneratable[] Parse (string filename, string schema_file)
{
return Parse (filename, schema_file, String.Empty);
}
public IGeneratable[] Parse (string filename, string schema_file, string gapidir)
{ {
XmlDocument doc = Load (filename, schema_file); XmlDocument doc = Load (filename, schema_file);
if (doc == null) if (doc == null)
@ -112,7 +117,18 @@ namespace GtkSharp.Generation {
switch (child.Name) { switch (child.Name) {
case "include": case "include":
IGeneratable[] curr_gens = Parse (elem.GetAttribute ("xml")); string xmlpath;
if (File.Exists (Path.Combine (gapidir, elem.GetAttribute ("xml"))))
xmlpath = Path.Combine (gapidir, elem.GetAttribute ("xml"));
else if (File.Exists (elem.GetAttribute ("xml")))
xmlpath = elem.GetAttribute ("xml");
else {
Console.WriteLine ("Parser: Could not find include " + elem.GetAttribute ("xml"));
break;
}
IGeneratable[] curr_gens = Parse (xmlpath);
SymbolTable.Table.AddTypes (curr_gens); SymbolTable.Table.AddTypes (curr_gens);
break; break;
case "namespace": case "namespace":