diff options
author | montellese <montellese@xbmc.org> | 2015-01-15 20:36:55 +0100 |
---|---|---|
committer | montellese <montellese@xbmc.org> | 2015-03-01 14:52:01 +0100 |
commit | 55ba0c476f0044e370a4ecd3af77958fb15c4601 (patch) | |
tree | 5a826b57b6bf6972273a6862b10080a6aff0c24b | |
parent | 436a59d23e074384892ac6a252622068ac6b0a1e (diff) |
python: fix property getters/setters for custom API types
-rw-r--r-- | tools/codegenerator/Helper.groovy | 13 | ||||
-rw-r--r-- | xbmc/interfaces/python/PythonSwig.cpp.template | 10 |
2 files changed, 19 insertions, 4 deletions
diff --git a/tools/codegenerator/Helper.groovy b/tools/codegenerator/Helper.groovy index 8b471067f7..920c7d1b95 100644 --- a/tools/codegenerator/Helper.groovy +++ b/tools/codegenerator/Helper.groovy @@ -665,6 +665,19 @@ public class Helper } /** + * Because the return type of a property is a combination of the function + * 'decl' and the function 'type,' this method will construct a valid Swig + * typestring from the two. + */ + public static String getPropertyReturnSwigType(Node method) + { + // we're going to take a shortcut here because it appears only the pointer indicator + // ends up attached to the decl. + String prefix = (method.@decl != null && method.@decl == 'p.') ? 'p.' : '' + return method.@type != null ? prefix + method.@type : 'void' + } + + /** * Because the return type is a combination of the function 'decl' and the * function 'type,' this method will construct a valid Swig typestring from * the two. diff --git a/xbmc/interfaces/python/PythonSwig.cpp.template b/xbmc/interfaces/python/PythonSwig.cpp.template index fb0d96a41b..6a4a9d3703 100644 --- a/xbmc/interfaces/python/PythonSwig.cpp.template +++ b/xbmc/interfaces/python/PythonSwig.cpp.template @@ -460,10 +460,11 @@ void doClassMethodInfo(Node clazz, List initTypeCalls) PyObject* result = NULL; <% properties.each { + String returns = Helper.getPropertyReturnSwigType(it); %> if (strcmp((char*)name, "${it.@sym_name}") == 0) { - ${SwigTypeParser.SwigType_lstr(it.@type)} apiResult = (${SwigTypeParser.SwigType_lstr(it.@type)})theObj->${it.@sym_name}; - ${Helper.getOutConversion(it.@type, 'result', it)} + ${SwigTypeParser.SwigType_lstr(returns)} apiResult = (${SwigTypeParser.SwigType_lstr(returns)})theObj->${it.@sym_name}; + ${Helper.getOutConversion(returns, 'result', it)} } else<% } %> @@ -529,10 +530,11 @@ void doClassMethodInfo(Node clazz, List initTypeCalls) <% properties_set.each { + String returns = Helper.getPropertyReturnSwigType(it); %> if (strcmp((char*)name, "${it.@sym_name}") == 0) { - ${SwigTypeParser.SwigType_lstr(it.@type)} tmp; - ${Helper.getInConversion(it.@type, 'tmp', 'value', it)} + ${SwigTypeParser.SwigType_lstr(returns)} tmp; + ${Helper.getInConversion(returns, 'tmp', 'value', it)} if (PyErr_Occurred()) throw PythonBindings::PythonToCppException(); |