aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJim Carroll <thecarrolls@jiminger.com>2013-10-21 06:45:14 -0700
committerJim Carroll <thecarrolls@jiminger.com>2013-10-21 06:45:14 -0700
commit1ae84d9dc57c1a71bfba41e4beada588b996424b (patch)
tree0541deaf068c8293661c7f580a0c2ae1b6d52204 /tools
parent96410e2d0148f901c1b7d34f6f14c5458878b70c (diff)
parent395e4cd618d13702c4cf5fc371e9d48156bdcaaf (diff)
Merge pull request #3463 from jimfcarroll/cleanup-control
Cleanup XBMCAddon::xbmcgui::Control class and related docs
Diffstat (limited to 'tools')
-rw-r--r--tools/codegenerator/GenerateSWIGBindings.bat2
-rw-r--r--tools/codegenerator/SwigTypeParser.groovy61
2 files changed, 49 insertions, 14 deletions
diff --git a/tools/codegenerator/GenerateSWIGBindings.bat b/tools/codegenerator/GenerateSWIGBindings.bat
index 73d4519824..822b0ca0f6 100644
--- a/tools/codegenerator/GenerateSWIGBindings.bat
+++ b/tools/codegenerator/GenerateSWIGBindings.bat
@@ -27,7 +27,7 @@ rem run doxygen
rem run swig to generate the XML used by groovy to generate the python bindings
"%bin_dir%\swig\swig.exe" -w401 -c++ -outdir "%python_generated_dir%" -o "%python_generated_dir%\%2.xml" -xml -I"%base_Dir%\xbmc" -xmllang python "%swig_dir%\%2.i"
rem run groovy to generate the python bindings
-java.exe -cp "%groovy_dir%\groovy-all-1.8.9.jar;%groovy_dir%\commons-lang-2.6.jar;%generator_dir%;%python_dir%" groovy.ui.GroovyMain "%generator_dir%\Generator.groovy" "%python_generated_dir%\%2.xml" "%python_dir%\PythonSwig.cpp.template" "%python_generated_dir%\%2.cpp" "%doxygen_dir%"
+java.exe -cp "%groovy_dir%\groovy-all-2.1.7.jar;%groovy_dir%\commons-lang-2.6.jar;%generator_dir%;%python_dir%" groovy.ui.GroovyMain "%generator_dir%\Generator.groovy" "%python_generated_dir%\%2.xml" "%python_dir%\PythonSwig.cpp.template" "%python_generated_dir%\%2.cpp" "%doxygen_dir%"
rem delete the XML file generated by SWIG as it's not needed anymore
del "%python_generated_dir%\%2.xml" > NUL
diff --git a/tools/codegenerator/SwigTypeParser.groovy b/tools/codegenerator/SwigTypeParser.groovy
index cb04277cd3..c7efb3f7d2 100644
--- a/tools/codegenerator/SwigTypeParser.groovy
+++ b/tools/codegenerator/SwigTypeParser.groovy
@@ -33,6 +33,10 @@ public class SwigTypeParser
*/
private static Map typeTable = [:]
+ /**
+ * Add a typedef node to the global list of typedefs to be used later in
+ * parsing types.
+ */
public static void appendTypeTable(Node typetab) { typetab.each { typeTable[it.@namespace + it.@type] = it.@basetype } }
/**
@@ -128,25 +132,56 @@ public class SwigTypeParser
return result.replaceAll('<\\(', '<').replaceAll('\\)>', '>')
}
+ /**
+ * This will resolve the typedefs given the parameter passed is a simple type.
+ * see SwigType_resolve_all_typedefs which will handle qualifiers, pointers,
+ * references, and typedef of typedefs to resolve all the way down to the
+ * most basic types.
+ */
public static String SwigType_typedef_resolve(String t)
{
String td = typeTable[t]
String ret = td == null ? t : td
-// System.out.println "trying to resolve ${t} and it appears to be typedefed to ${ret}"
return ret
}
- public static String SwigType_typedef_resolve_all(String t)
- {
- String prev = t
- t = SwigType_typedef_resolve(prev)
- while(prev != t)
- {
- String tmp = t
- t = SwigType_typedef_resolve(prev)
- prev = tmp
+ /**
+ * This will resolve typedefs anbd handle qualifiers, pointers,
+ * references, and typedef of typedefs to resolve all the way down to the
+ * most basic types.
+ */
+ public static String SwigType_resolve_all_typedefs(String s)
+ {
+ String result = ''
+ String tc = s
+
+ /* Nuke all leading qualifiers, appending them to the result*/
+ while (SwigType_isqualifier(tc)) {
+ List tmpl = SwigType_pop(tc)
+ tc = tmpl[1]
+ result += tmpl[0]
+ }
+
+ if (SwigType_issimple(tc)) {
+ /* Resolve any typedef definitions */
+ String tt = tc
+ String td
+ while ((td = SwigType_typedef_resolve(tt)) != tt) {
+ if (td != tt) {
+ tt = td
+ break
+ }
+ else if (td != tt) tt = td
+ }
+ tc = td
+
+ return tc
}
- return t
+
+ List tmpl = SwigType_pop(tc)
+ result += tmpl[0]
+ result += SwigType_resolve_all_typedefs(tmpl[1])
+ return result
}
/**
@@ -205,7 +240,7 @@ public class SwigTypeParser
firstarray = false
} else if (SwigType_isreference(element)) {
if (notypeconv) {
- result == element
+ result += element
} else {
result += "p."
}
@@ -216,7 +251,7 @@ public class SwigTypeParser
} else {
result += "p."
}
- firstarray = 0;
+ firstarray = false;
} else if (SwigType_isenum(element)) {
boolean anonymous_enum = (element == "enum ")
if (notypeconv || !anonymous_enum) {