aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Carroll <thecarrolls@jiminger.com>2013-12-24 20:06:19 -0500
committerJim Carroll <thecarrolls@jiminger.com>2013-12-24 20:11:35 -0500
commit20d7a92e6bcc90167f836be23b22268d3fc69d96 (patch)
treef5c6710a8836edd16e1c68740982090bf6bea27d
parent121e096ed98a779b19a50b4f280185a435657f34 (diff)
Certain string in the ListItem need to be coerced from int values passed from python. This adds a new type that has a slightly different conversion than a string.
-rw-r--r--xbmc/interfaces/legacy/Dictionary.h7
-rw-r--r--xbmc/interfaces/legacy/ListItem.h4
-rw-r--r--xbmc/interfaces/python/PythonSwig.cpp.template4
3 files changed, 10 insertions, 5 deletions
diff --git a/xbmc/interfaces/legacy/Dictionary.h b/xbmc/interfaces/legacy/Dictionary.h
index 74eb97ad52..35d677ca35 100644
--- a/xbmc/interfaces/legacy/Dictionary.h
+++ b/xbmc/interfaces/legacy/Dictionary.h
@@ -25,6 +25,11 @@
namespace XBMCAddon
{
+ // This is a hack in order to handle int's as strings. The correct fix for
+ // this is to get rid of Alternative all togther and make the codegenerator
+ // finally handle overloading correctly.
+ typedef String StringOrInt;
+
/**
* This is a bit of a hack for dynamically typed languages. In somce
* cases python addon api calls handle dictionaries with variable
@@ -36,5 +41,5 @@ namespace XBMCAddon
*/
template<class T> class Dictionary : public std::map<String,T> {};
- typedef Dictionary<String> Properties;
+ typedef Dictionary<StringOrInt> Properties;
}
diff --git a/xbmc/interfaces/legacy/ListItem.h b/xbmc/interfaces/legacy/ListItem.h
index 388ee3d503..cc2ec4c011 100644
--- a/xbmc/interfaces/legacy/ListItem.h
+++ b/xbmc/interfaces/legacy/ListItem.h
@@ -45,10 +45,10 @@ namespace XBMCAddon
XBMCCOMMONS_STANDARD_EXCEPTION(ListItemException);
// This is a type that represents either a String or a String Tuple
- typedef Alternative<String,Tuple<String, String> > InfoLabelStringOrTuple;
+ typedef Alternative<StringOrInt,Tuple<String, StringOrInt> > InfoLabelStringOrTuple;
// This type is either a String or a list of InfoLabelStringOrTuple types
- typedef Alternative<String, std::vector<InfoLabelStringOrTuple> > InfoLabelValue;
+ typedef Alternative<StringOrInt, std::vector<InfoLabelStringOrTuple> > InfoLabelValue;
// The type contains the dictionary values for the ListItem::setInfo call.
// The values in the dictionary can be either a String, or a list of items.
diff --git a/xbmc/interfaces/python/PythonSwig.cpp.template b/xbmc/interfaces/python/PythonSwig.cpp.template
index 828d5fc031..3da5625b17 100644
--- a/xbmc/interfaces/python/PythonSwig.cpp.template
+++ b/xbmc/interfaces/python/PythonSwig.cpp.template
@@ -56,7 +56,6 @@ Helper.setup(this,classes,
* This is meant to contain mini-templates for converting the return type
* of the native call to be returned to the python caller.
*/
-// 'p.void' : '${result} = Py_BuildValue((char*)"s#",${api},readBytes);',
[ 'void' : 'Py_INCREF(Py_None);\n ${result} = Py_None;',
'long': '${result} = PyInt_FromLong(${api});',
'unsigned long': '${result} = PyInt_FromLong(${api});',
@@ -96,7 +95,8 @@ Helper.setup(this,classes,
'unsigned long long' : '${api} = PyLong_AsUnsignedLongLong(${slarg});',
'int' : '${api} = (int)PyInt_AsLong(${slarg});',
'double' : '${api} = PyFloat_AsDouble(${slarg});',
- 'float' : '${api} = (float)PyFloat_AsDouble(${slarg});'
+ 'float' : '${api} = (float)PyFloat_AsDouble(${slarg});',
+ 'XBMCAddon::StringOrInt' : 'if (${slarg}) PyXBMCGetUnicodeString(${api},${slarg},PyInt_Check(${slarg}) || PyLong_Check(${slarg}),"${api}","${method.@name}");'
], '${api} = (${swigTypeParser.SwigType_str(ltype)})retrieveApiInstance(${slarg},"${ltype}","${helper.findNamespace(method)}","${helper.callingName(method)}");')
// ---------------------------------------------------------