diff options
18 files changed, 140 insertions, 145 deletions
diff --git a/xbmc/interfaces/legacy/Dictionary.h b/xbmc/interfaces/legacy/Dictionary.h index 021c30b744..74eb97ad52 100644 --- a/xbmc/interfaces/legacy/Dictionary.h +++ b/xbmc/interfaces/legacy/Dictionary.h @@ -34,5 +34,7 @@ namespace XBMCAddon * native api handles these calls by converting the string to the * appropriate types. */ - typedef std::map<String,String> Dictionary; + template<class T> class Dictionary : public std::map<String,T> {}; + + typedef Dictionary<String> Properties; } diff --git a/xbmc/interfaces/legacy/ListItem.cpp b/xbmc/interfaces/legacy/ListItem.cpp index f19574f0e3..0e2f1844c6 100644 --- a/xbmc/interfaces/legacy/ListItem.cpp +++ b/xbmc/interfaces/legacy/ListItem.cpp @@ -129,12 +129,12 @@ namespace XBMCAddon } } - void ListItem::setArt(const Dictionary& dictionary) + void ListItem::setArt(const Properties& dictionary) { if (!item) return; { LOCKGUI; - for (Dictionary::const_iterator it = dictionary.begin(); it != dictionary.end(); ++it) + for (Properties::const_iterator it = dictionary.begin(); it != dictionary.end(); ++it) { CStdString artName = it->first; StringUtils::ToLower(artName); @@ -170,7 +170,7 @@ namespace XBMCAddon void ListItem::setProperty(const char * key, const String& value) { LOCKGUI; - CStdString lowerKey = key; + String lowerKey = key; StringUtils::ToLower(lowerKey); if (lowerKey == "startoffset") { // special case for start offset - don't actually store in a property, @@ -201,7 +201,7 @@ namespace XBMCAddon String ListItem::getProperty(const char* key) { LOCKGUI; - CStdString lowerKey = key; + String lowerKey = key; StringUtils::ToLower(lowerKey); CStdString value; if (lowerKey == "startoffset") @@ -261,17 +261,19 @@ namespace XBMCAddon return item->GetPath(); } - void ListItem::setInfo(const char* type, const Dictionary& infoLabels) + void ListItem::setInfo(const char* type, const InfoLabelDict& infoLabels) throw (WrongTypeException) { LOCKGUI; if (strcmpi(type, "video") == 0) { - for (Dictionary::const_iterator it = infoLabels.begin(); it != infoLabels.end(); ++it) + for (InfoLabelDict::const_iterator it = infoLabels.begin(); it != infoLabels.end(); ++it) { - CStdString key = it->first; + String key = it->first; StringUtils::ToLower(key); - const CStdString value(it->second.c_str()); + + const InfoLabelValue& alt = it->second; + const String value(alt.which() == first ? alt.former() : emptyString); if (key == "year") item->GetVideoInfoTag()->m_iYear = strtol(value.c_str(), NULL, 10); @@ -299,45 +301,41 @@ namespace XBMCAddon if (overlay >= 0 && overlay <= 8) item->SetOverlayImage((CGUIListItem::GUIIconOverlay)overlay); } -// TODO: This is a dynamic type for the value where a list is expected as the -// Dictionary value. -// else if (key == "cast" || key == "castandrole") -// { -// if (!PyObject_TypeCheck(value, &PyList_Type)) continue; -// item->GetVideoInfoTag()->m_cast.clear(); -// for (int i = 0; i < PyList_Size(value); i++) -// { -// PyObject *pTuple = NULL; -// pTuple = PyList_GetItem(value, i); -// if (pTuple == NULL) continue; -// PyObject *pActor = NULL; -// PyObject *pRole = NULL; -// if (PyObject_TypeCheck(pTuple, &PyTuple_Type)) -// { -// if (!PyArg_ParseTuple(pTuple, (char*)"O|O", &pActor, &pRole)) continue; -// } -// else -// pActor = pTuple; -// SActorInfo info; -// if (!PyXBMCGetUnicodeString(info.strName, pActor, 1)) continue; -// if (pRole != NULL) -// PyXBMCGetUnicodeString(info.strRole, pRole, 1); -// item->GetVideoInfoTag()->m_cast.push_back(info); -// } -// } -// else if (strcmpi(PyString_AsString(key), "artist") == 0) -// { -// if (!PyObject_TypeCheck(value, &PyList_Type)) continue; -// self->item->GetVideoInfoTag()->m_artist.clear(); -// for (int i = 0; i < PyList_Size(value); i++) -// { -// PyObject *pActor = PyList_GetItem(value, i); -// if (pActor == NULL) continue; -// String actor; -// if (!PyXBMCGetUnicodeString(actor, pActor, 1)) continue; -// self->item->GetVideoInfoTag()->m_artist.push_back(actor); -// } -// } + else if (key == "cast" || key == "castandrole") + { + if (alt.which() != second) + throw WrongTypeException("When using \"cast\" or \"castandrole\" you need to supply a list of tuples for the value in the dictionary"); + + item->GetVideoInfoTag()->m_cast.clear(); + const std::vector<InfoLabelStringOrTuple>& listValue = alt.later(); + for (std::vector<InfoLabelStringOrTuple>::const_iterator viter = listValue.begin(); viter != listValue.end(); ++viter) + { + const InfoLabelStringOrTuple& castEntry = *viter; + // castEntry can be a string meaning it's the actor or it can be a tuple meaning it's the + // actor and the role. + const String& actor = castEntry.which() == first ? castEntry.former() : castEntry.later().first(); + SActorInfo info; + info.strName = actor; + if (castEntry.which() == second) + info.strRole = (const String&)(castEntry.later().second()); + } + } + else if (key == "artist") + { + if (alt.which() != second) + throw WrongTypeException("When using \"artist\" you need to supply a list of strings for the value in the dictionary"); + + item->GetVideoInfoTag()->m_artist.clear(); + + const std::vector<InfoLabelStringOrTuple>& listValue = alt.later(); + for (std::vector<InfoLabelStringOrTuple>::const_iterator viter = listValue.begin(); viter != listValue.end(); ++viter) + { + + const InfoLabelStringOrTuple& castEntry = *viter; + const String& actor = castEntry.which() == first ? castEntry.former() : castEntry.later().first(); + item->GetVideoInfoTag()->m_artist.push_back(actor); + } + } else if (key == "genre") item->GetVideoInfoTag()->m_genre = StringUtils::Split(value, g_advancedSettings.m_videoItemSeparator); else if (key == "director") @@ -400,28 +398,29 @@ namespace XBMCAddon } else if (strcmpi(type, "music") == 0) { - for (Dictionary::const_iterator it = infoLabels.begin(); it != infoLabels.end(); ++it) + for (InfoLabelDict::const_iterator it = infoLabels.begin(); it != infoLabels.end(); ++it) { - CStdString key = it->first; - + String key = it->first; StringUtils::ToLower(key); - const CStdString value(it->second.c_str()); + + const InfoLabelValue& alt = it->second; + const String value(alt.which() == first ? alt.former() : emptyString); // TODO: add the rest of the infolabels if (key == "tracknumber") - item->GetMusicInfoTag()->SetTrackNumber(strtol(value, NULL, 10)); + item->GetMusicInfoTag()->SetTrackNumber(strtol(value.c_str(), NULL, 10)); else if (key == "count") - item->m_iprogramCount = strtol(value, NULL, 10); + item->m_iprogramCount = strtol(value.c_str(), NULL, 10); else if (key == "size") - item->m_dwSize = (int64_t)strtoll(value, NULL, 10); + item->m_dwSize = (int64_t)strtoll(value.c_str(), NULL, 10); else if (key == "duration") - item->GetMusicInfoTag()->SetDuration(strtol(value, NULL, 10)); + item->GetMusicInfoTag()->SetDuration(strtol(value.c_str(), NULL, 10)); else if (key == "year") - item->GetMusicInfoTag()->SetYear(strtol(value, NULL, 10)); + item->GetMusicInfoTag()->SetYear(strtol(value.c_str(), NULL, 10)); else if (key == "listeners") - item->GetMusicInfoTag()->SetListeners(strtol(value, NULL, 10)); + item->GetMusicInfoTag()->SetListeners(strtol(value.c_str(), NULL, 10)); else if (key == "playcount") - item->GetMusicInfoTag()->SetPlayCount(strtol(value, NULL, 10)); + item->GetMusicInfoTag()->SetPlayCount(strtol(value.c_str(), NULL, 10)); else if (key == "genre") item->GetMusicInfoTag()->SetGenre(value); else if (key == "album") @@ -431,7 +430,7 @@ namespace XBMCAddon else if (key == "title") item->GetMusicInfoTag()->SetTitle(value); else if (key == "rating") - item->GetMusicInfoTag()->SetRating(*value); + item->GetMusicInfoTag()->SetRating(value[0]); else if (key == "lyrics") item->GetMusicInfoTag()->SetLyrics(value); else if (key == "lastplayed") @@ -450,12 +449,13 @@ namespace XBMCAddon item->GetMusicInfoTag()->SetComment(value); else if (key == "date") { - if (strlen(value) == 10) + if (strlen(value.c_str()) == 10) { int year = atoi(value.substr(value.size() - 4).c_str()); int month = atoi(value.substr(3, 4).c_str()); int day = atoi(value.substr(0, 2).c_str()); - item->m_dateTime.SetDate(year, month, day); } + item->m_dateTime.SetDate(year, month, day); + } } else CLog::Log(LOGERROR,"NEWADDON Unknown Music Info Key \"%s\"", key.c_str()); @@ -467,23 +467,25 @@ namespace XBMCAddon } else if (strcmpi(type,"pictures") == 0) { - for (Dictionary::const_iterator it = infoLabels.begin(); it != infoLabels.end(); ++it) + for (InfoLabelDict::const_iterator it = infoLabels.begin(); it != infoLabels.end(); ++it) { - CStdString key = it->first; + String key = it->first; StringUtils::ToLower(key); - const CStdString value(it->second.c_str()); + + const InfoLabelValue& alt = it->second; + const String value(alt.which() == first ? alt.former() : emptyString); if (key == "count") - item->m_iprogramCount = strtol(value, NULL, 10); + item->m_iprogramCount = strtol(value.c_str(), NULL, 10); else if (key == "size") - item->m_dwSize = (int64_t)strtoll(value, NULL, 10); + item->m_dwSize = (int64_t)strtoll(value.c_str(), NULL, 10); else if (key == "title") item->m_strTitle = value; else if (key == "picturepath") item->SetPath(value); else if (key == "date") { - if (strlen(value) == 10) + if (strlen(value.c_str()) == 10) { int year = atoi(value.substr(value.size() - 4).c_str()); int month = atoi(value.substr(3, 4).c_str()); @@ -493,37 +495,37 @@ namespace XBMCAddon } else { - const CStdString& exifkey = key; + const String& exifkey = key; if (!StringUtils::StartsWithNoCase(exifkey, "exif:") || exifkey.length() < 6) continue; - int info = CPictureInfoTag::TranslateString(exifkey.substr(5)); + int info = CPictureInfoTag::TranslateString(StringUtils::Mid(exifkey,5)); item->GetPictureInfoTag()->SetInfo(info, value); } } } } // end ListItem::setInfo - void ListItem::addStreamInfo(const char* cType, const Dictionary& dictionary) + void ListItem::addStreamInfo(const char* cType, const Properties& dictionary) { LOCKGUI; if (strcmpi(cType, "video") == 0) { CStreamDetailVideo* video = new CStreamDetailVideo; - for (Dictionary::const_iterator it = dictionary.begin(); it != dictionary.end(); ++it) + for (Properties::const_iterator it = dictionary.begin(); it != dictionary.end(); ++it) { const String& key = it->first; - const CStdString value(it->second.c_str()); + const String value(it->second.c_str()); if (key == "codec") video->m_strCodec = value; else if (key == "aspect") - video->m_fAspect = (float)atof(value); + video->m_fAspect = (float)atof(value.c_str()); else if (key == "width") - video->m_iWidth = strtol(value, NULL, 10); + video->m_iWidth = strtol(value.c_str(), NULL, 10); else if (key == "height") - video->m_iHeight = strtol(value, NULL, 10); + video->m_iHeight = strtol(value.c_str(), NULL, 10); else if (key == "duration") - video->m_iDuration = strtol(value, NULL, 10); + video->m_iDuration = strtol(value.c_str(), NULL, 10); else if (key == "stereomode") video->m_strStereoMode = value; } @@ -532,7 +534,7 @@ namespace XBMCAddon else if (strcmpi(cType, "audio") == 0) { CStreamDetailAudio* audio = new CStreamDetailAudio; - for (Dictionary::const_iterator it = dictionary.begin(); it != dictionary.end(); ++it) + for (Properties::const_iterator it = dictionary.begin(); it != dictionary.end(); ++it) { const String& key = it->first; const String& value = it->second; @@ -549,7 +551,7 @@ namespace XBMCAddon else if (strcmpi(cType, "subtitle") == 0) { CStreamDetailSubtitle* subtitle = new CStreamDetailSubtitle; - for (Dictionary::const_iterator it = dictionary.begin(); it != dictionary.end(); ++it) + for (Properties::const_iterator it = dictionary.begin(); it != dictionary.end(); ++it) { const String& key = it->first; const String& value = it->second; @@ -574,7 +576,7 @@ namespace XBMCAddon std::string uAction = tuple.second(); LOCKGUI; - CStdString property; + String property; property = StringUtils::Format("contextmenulabel(%i)", itemCount); item->SetProperty(property, uText); diff --git a/xbmc/interfaces/legacy/ListItem.h b/xbmc/interfaces/legacy/ListItem.h index 40fa95ceb9..388ee3d503 100644 --- a/xbmc/interfaces/legacy/ListItem.h +++ b/xbmc/interfaces/legacy/ListItem.h @@ -26,7 +26,9 @@ #include "cores/playercorefactory/PlayerCoreFactory.h" #include "AddonClass.h" +#include "Tuple.h" #include "Dictionary.h" +#include "Alternative.h" #include "CallbackHandler.h" #include "ListItem.h" #include "music/tags/MusicInfoTag.h" @@ -42,6 +44,17 @@ 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; + + // This type is either a String or a list of InfoLabelStringOrTuple types + typedef Alternative<String, 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. + // If it's a list of items then the items can be either a String or a Tuple. + typedef Dictionary<InfoLabelValue> InfoLabelDict; + class ListItem : public AddonClass { public: @@ -141,7 +154,7 @@ namespace XBMCAddon * example: * - self.list.getSelectedItem().setArt({ 'poster': 'poster.png', 'banner' : 'banner.png' }) */ - void setArt(const Dictionary& dictionary); + void setArt(const Properties& dictionary); /** * select(selected) -- Sets the listitem's selected status.\n @@ -234,7 +247,7 @@ namespace XBMCAddon * example:\n * - self.list.getSelectedItem().setInfo('video', { 'Genre': 'Comedy' })n\n */ - void setInfo(const char* type, const Dictionary& infoLabels); + void setInfo(const char* type, const InfoLabelDict& infoLabels) throw (WrongTypeException); /** * addStreamInfo(type, values) -- Add a stream with details.\n @@ -258,7 +271,7 @@ namespace XBMCAddon * example: * - self.list.getSelectedItem().addStreamInfo('video', { 'Codec': 'h264', 'Width' : 1280 }) */ - void addStreamInfo(const char* cType, const Dictionary& dictionary); + void addStreamInfo(const char* cType, const Properties& dictionary); /** * addContextMenuItems([(label, action,)*], replaceItems) -- Adds item(s) to the context menu for media lists.\n diff --git a/xbmc/interfaces/python/PythonSwig.cpp.template b/xbmc/interfaces/python/PythonSwig.cpp.template index 9e1d66cd1b..828d5fc031 100644 --- a/xbmc/interfaces/python/PythonSwig.cpp.template +++ b/xbmc/interfaces/python/PythonSwig.cpp.template @@ -65,7 +65,7 @@ Helper.setup(this,classes, 'int': '${result} = Py_BuildValue((char*)"i", ${api});', 'double': '${result} = PyFloat_FromDouble(${api});', 'float': '${result} = Py_BuildValue((char*)"f", ${api});', - 'String' : new File('typemaps/python.string.outtm'), + 'std::string' : new File('typemaps/python.string.outtm'), 'p.q(const).char' : '${result} = PyString_FromString(${api});', (Pattern.compile('''(p.){0,1}XbmcCommons::Buffer''')) : new File('typemaps/python.buffer.outtm'), (Pattern.compile('''boost::shared_ptr<\\(.*\\)>''')) : new File('typemaps/python.boost_shared_ptr.outtm'), @@ -82,16 +82,13 @@ Helper.setup(this,classes, * call. */ [ - 'String' : 'if (${slarg}) PyXBMCGetUnicodeString(${api},${slarg},false,"${api}","${method.@name}");', + 'std::string' : 'if (${slarg}) PyXBMCGetUnicodeString(${api},${slarg},false,"${api}","${method.@name}");', (Pattern.compile('''(p.){0,1}std::vector<\\(.*\\)>''')) : new File('typemaps/python.vector.intm'), (Pattern.compile('''(p.){0,1}Tuple(3){0,1}<\\(.*\\)>''')) : new File('typemaps/python.Tuple.intm'), (Pattern.compile('''(p.){0,1}Alternative<\\(.*\\)>''')) : new File('typemaps/python.Alternative.intm'), - // I shouldn't need both of these but my parser doesn't resolve namespaces within - // parameter declarations. TODO: Maybe I should fix this. - 'r.q(const).Dictionary' : new File('typemaps/python.dict.intm'), - 'r.q(const).XBMCAddon::Dictionary' : new File('typemaps/python.dict.intm'), (Pattern.compile('''(r.){0,1}XbmcCommons::Buffer''')) : new File('typemaps/python.buffer.intm'), (Pattern.compile('''(p.){0,1}std::map<\\(.*\\)>''')) : new File('typemaps/python.map.intm'), + (Pattern.compile('''(r.){0,1}XBMCAddon::Dictionary<\\(.*\\)>''')) : new File('typemaps/python.dict.intm'), 'bool' : '${api} = (PyInt_AsLong(${slarg}) == 0L ? false : true);', 'long' : '${api} = PyInt_AsLong(${slarg});', 'unsigned long' : '${api} = PyLong_AsUnsignedLong(${slarg});', diff --git a/xbmc/interfaces/python/typemaps/python.Alternative.intm b/xbmc/interfaces/python/typemaps/python.Alternative.intm index 0a3c34a101..1ccffadcda 100644 --- a/xbmc/interfaces/python/typemaps/python.Alternative.intm +++ b/xbmc/interfaces/python/typemaps/python.Alternative.intm @@ -20,16 +20,13 @@ */ %> <% - type = swigTypeParser.SwigType_resolve_all_typedefs(type) - matcher = type =~ /Alternative<\((.*)\)>/ - vectype = '(' + matcher[0][1] + ')' - boolean ispointer = swigTypeParser.SwigType_ispointer(type) + boolean ispointer = swigTypeParser.SwigType_ispointer(ltype) String accessor = ispointer ? '->' : '.' int seq = sequence.increment() altAccess = [ 'former', 'later' ] altSwitch = [ 'first', 'second' ] - List types = swigTypeParser.SwigType_parmlist(vectype) + List types = swigTypeParser.SwigType_templateparmlist(ltype) %> { // we need to check the parameter type and see if it matches @@ -38,10 +35,7 @@ { ${swigTypeParser.SwigType_str(swigTypeParser.SwigType_ltype(types[0]))} entry0_${seq}; ${helper.getInConversion(types[0], 'entry0' + '_' + seq, 'pyentry' + '_' + seq, method, - [ 'type' : vectype, - 'ltype' : swigTypeParser.SwigType_ltype(types[0]), - 'sequence' : sequence - ])} + [ 'sequence' : sequence ])} ${api}${accessor}${altAccess[0]}() = entry0_${seq}; } catch (XBMCAddon::WrongTypeException wte) @@ -50,10 +44,7 @@ { ${swigTypeParser.SwigType_str(swigTypeParser.SwigType_ltype(types[1]))} entry1_${seq}; ${helper.getInConversion(types[1], 'entry1' + '_' + seq, 'pyentry' + '_' + seq, method, - [ 'type' : vectype, - 'ltype' : swigTypeParser.SwigType_ltype(types[1]), - 'sequence' : sequence - ])} + [ 'sequence' : sequence ])} ${api}${accessor}${altAccess[1]}() = entry1_${seq}; } catch (XBMCAddon::WrongTypeException wte2) diff --git a/xbmc/interfaces/python/typemaps/python.Alternative.outtm b/xbmc/interfaces/python/typemaps/python.Alternative.outtm index 8c7b80b4cf..20cef34183 100644 --- a/xbmc/interfaces/python/typemaps/python.Alternative.outtm +++ b/xbmc/interfaces/python/typemaps/python.Alternative.outtm @@ -20,8 +20,7 @@ */ %> <% - matcher = type =~ /Alternative<\((.*)\)>/ - vectype = '(' + matcher[0][1] + ')' + List types = swigTypeParser.SwigType_templateparmlist(type) boolean ispointer = swigTypeParser.SwigType_ispointer(type) int seq = sequence.increment() String accessor = ispointer ? '->' : '.' @@ -32,7 +31,7 @@ if (<%if (ispointer) { %>${api} != NULL && <%}%>pos != XBMCAddon::none) { <% - swigTypeParser.SwigType_parmlist(vectype).eachWithIndex { curType, entryIndex -> + types.eachWithIndex { curType, entryIndex -> %> if (pos == XBMCAddon::${altSwitch[entryIndex]}) { diff --git a/xbmc/interfaces/python/typemaps/python.Tuple.intm b/xbmc/interfaces/python/typemaps/python.Tuple.intm index 01e1fb7584..d164893346 100644 --- a/xbmc/interfaces/python/typemaps/python.Tuple.intm +++ b/xbmc/interfaces/python/typemaps/python.Tuple.intm @@ -20,8 +20,7 @@ */ %> <% -matcher = ltype =~ /Tuple<\((.*)\)>/ - vectype = '(' + matcher[0][1] + ')' + List types = swigTypeParser.SwigType_templateparmlist(ltype) boolean ispointer = swigTypeParser.SwigType_ispointer(type) String accessor = ispointer ? '->' : '.' int seq = sequence.increment() @@ -30,24 +29,17 @@ matcher = ltype =~ /Tuple<\((.*)\)>/ { bool isTuple = PyObject_TypeCheck(${slarg},&PyTuple_Type); if (!isTuple && !PyObject_TypeCheck(${slarg},&PyList_Type)) - { - PyErr_SetString(PyExc_TypeError, "the parameter \"${api}\" must be either a Tuple or a List."); - return NULL; // short circuit the rest of this python method - } + throw WrongTypeException("The parameter \"${api}\" must be either a Tuple or a List."); int vecSize = (isTuple ? PyTuple_Size(${slarg}) : PyList_Size(${slarg})); <% - swigTypeParser.SwigType_parmlist(vectype).eachWithIndex { curType, entryIndex -> + types.eachWithIndex { curType, entryIndex -> %> if (vecSize > ${entryIndex}) { PyObject *pyentry${entryIndex}_${seq} = NULL; pyentry${entryIndex}_${seq} = (isTuple ? PyTuple_GetItem(${slarg}, ${entryIndex}) : PyList_GetItem(${slarg}, ${entryIndex})); ${swigTypeParser.SwigType_str(swigTypeParser.SwigType_ltype(curType))} entry${entryIndex}_${seq}; - ${helper.getInConversion(curType, 'entry' + entryIndex + '_' + seq, 'pyentry' + entryIndex + '_' + seq, method, - [ 'type' : vectype, - 'ltype' : swigTypeParser.SwigType_ltype(curType), - 'sequence' : sequence - ])} + ${helper.getInConversion(curType, 'entry' + entryIndex + '_' + seq, 'pyentry' + entryIndex + '_' + seq, method,[ 'sequence' : sequence ])} ${api}${accessor}${tupleAccess[entryIndex]}() = entry${entryIndex}_${seq}; } <% diff --git a/xbmc/interfaces/python/typemaps/python.Tuple.outtm b/xbmc/interfaces/python/typemaps/python.Tuple.outtm index 2e5f41a5f0..135505972b 100644 --- a/xbmc/interfaces/python/typemaps/python.Tuple.outtm +++ b/xbmc/interfaces/python/typemaps/python.Tuple.outtm @@ -20,8 +20,7 @@ */ %> <% - matcher = type =~ /Tuple<\((.*)\)>/ - vectype = '(' + matcher[0][1] + ')' + List types = swigTypeParser.SwigType_templateparmlist(type) boolean ispointer = swigTypeParser.SwigType_ispointer(type) int seq = sequence.increment() String accessor = ispointer ? '->' : '.' @@ -38,7 +37,7 @@ <% } // this ends the if (ispointer) %> { PyObject* pyentry${seq}; <% - swigTypeParser.SwigType_parmlist(vectype).eachWithIndex { curType, entryIndex -> + types.eachWithIndex { curType, entryIndex -> %> if (vecSize > ${entryIndex}) diff --git a/xbmc/interfaces/python/typemaps/python.boost_shared_ptr.outtm b/xbmc/interfaces/python/typemaps/python.boost_shared_ptr.outtm index f625e16b5f..0e01849bd6 100644 --- a/xbmc/interfaces/python/typemaps/python.boost_shared_ptr.outtm +++ b/xbmc/interfaces/python/typemaps/python.boost_shared_ptr.outtm @@ -20,8 +20,7 @@ */ %> <% - matcher = type =~ /shared_ptr<\((.*)\)>/ - itype = matcher[0][1] + itype = swigTypeParser.SwigType_templateparmlist(type)[0] pointertype = swigTypeParser.SwigType_makepointer(itype) int seq = sequence.increment() %> diff --git a/xbmc/interfaces/python/typemaps/python.dict.intm b/xbmc/interfaces/python/typemaps/python.dict.intm index 99716c6b85..e9a65605bc 100644 --- a/xbmc/interfaces/python/typemaps/python.dict.intm +++ b/xbmc/interfaces/python/typemaps/python.dict.intm @@ -19,15 +19,19 @@ * */ %> +<% + List templateArgs = swigTypeParser.SwigType_templateparmlist(ltype) + valtype = templateArgs[0] +%> { PyObject *pykey, *pyvalue; Py_ssize_t pos = 0; while(PyDict_Next(${slarg}, &pos, &pykey, &pyvalue)) { - CStdString key; - CStdString value; + std::string key; PyXBMCGetUnicodeString(key,pykey,false,"${api}","${method.@name}"); - PyXBMCGetUnicodeString(value,pyvalue,true,"${api}","${method.@name}"); + ${swigTypeParser.SwigType_str(swigTypeParser.SwigType_ltype(valtype))} value; + ${helper.getInConversion(valtype, 'value', 'pyvalue' ,method)} ${api}[key] = value; } } diff --git a/xbmc/interfaces/python/typemaps/python.map.intm b/xbmc/interfaces/python/typemaps/python.map.intm index 1a1ad805fc..3e13677272 100644 --- a/xbmc/interfaces/python/typemaps/python.map.intm +++ b/xbmc/interfaces/python/typemaps/python.map.intm @@ -20,9 +20,9 @@ */ %> <% - matcher = ltype =~ /std::map<\((.*),(.*)\)>/ - keytype = matcher[0][1] - valtype = matcher[0][2] + List templateArgs = swigTypeParser.SwigType_templateparmlist(ltype) + keytype = templateArgs[0] + valtype = templateArgs[1] %> { @@ -32,14 +32,8 @@ { ${swigTypeParser.SwigType_str(swigTypeParser.SwigType_ltype(keytype))} key; ${swigTypeParser.SwigType_str(swigTypeParser.SwigType_ltype(valtype))} value; - ${helper.getInConversion(keytype, 'key', 'pykey', method, - [ 'type' : swigTypeParser.SwigType_str(keytype), - 'ltype' : swigTypeParser.SwigType_str(swigTypeParser.SwigType_ltype(keytype)) - ])} - ${helper.getInConversion(valtype, 'value', 'pyvalue' ,method, - [ 'type' : swigTypeParser.SwigType_str(valtype), - 'ltype' : swigTypeParser.SwigType_str(swigTypeParser.SwigType_ltype(valtype)) - ])} + ${helper.getInConversion(keytype, 'key', 'pykey', method)} + ${helper.getInConversion(valtype, 'value', 'pyvalue' ,method)} ${api}[key] = value; } } diff --git a/xbmc/interfaces/python/typemaps/python.vector.intm b/xbmc/interfaces/python/typemaps/python.vector.intm index 4086e52551..4181b7b92a 100644 --- a/xbmc/interfaces/python/typemaps/python.vector.intm +++ b/xbmc/interfaces/python/typemaps/python.vector.intm @@ -20,8 +20,8 @@ */ %> <% - matcher = ltype =~ /std::vector<\((.*)\)>/ - vectype = matcher[0][1] + List templateArgs = swigTypeParser.SwigType_templateparmlist(ltype) + vectype = templateArgs[0] boolean ispointer = swigTypeParser.SwigType_ispointer(type) String accessor = ispointer ? '->' : '.' int seq = sequence.increment() @@ -29,10 +29,7 @@ { bool isTuple = PyObject_TypeCheck(${slarg},&PyTuple_Type); if (!isTuple && !PyObject_TypeCheck(${slarg},&PyList_Type)) - { - PyErr_SetString(PyExc_TypeError, "the parameter \"${api}\" must be either a Tuple or a List."); - return NULL; // short circuit the rest of this python method - } + throw WrongTypeException("The parameter \"${api}\" must be either a Tuple or a List."); <% if (ispointer) print("${api} = new std::vector<${swigTypeParser.SwigType_str(vectype)}>();") %> PyObject *pyentry${seq} = NULL; diff --git a/xbmc/interfaces/python/typemaps/python.vector.outtm b/xbmc/interfaces/python/typemaps/python.vector.outtm index d147b61649..a841283485 100644 --- a/xbmc/interfaces/python/typemaps/python.vector.outtm +++ b/xbmc/interfaces/python/typemaps/python.vector.outtm @@ -20,8 +20,8 @@ */ %> <% - matcher = type =~ /std::vector<\((.*)\)>/ - vectype = matcher[0][1] + List templateArgs = swigTypeParser.SwigType_templateparmlist(type) + vectype = templateArgs[0] boolean ispointer = swigTypeParser.SwigType_ispointer(type) String accessor = ispointer ? '->' : '.' seq = sequence.increment() diff --git a/xbmc/interfaces/swig/AddonModuleXbmc.i b/xbmc/interfaces/swig/AddonModuleXbmc.i index 7a0e27f3c2..9628e2e57d 100644 --- a/xbmc/interfaces/swig/AddonModuleXbmc.i +++ b/xbmc/interfaces/swig/AddonModuleXbmc.i @@ -44,6 +44,7 @@ using namespace xbmc; %feature("python:coerceToUnicode") XBMCAddon::xbmc::getLocalizedString "true" +%include "interfaces/legacy/AddonString.h" %include "interfaces/legacy/ModuleXbmc.h" %feature("director") Player; diff --git a/xbmc/interfaces/swig/AddonModuleXbmcaddon.i b/xbmc/interfaces/swig/AddonModuleXbmcaddon.i index 23135b090b..f42169a869 100644 --- a/xbmc/interfaces/swig/AddonModuleXbmcaddon.i +++ b/xbmc/interfaces/swig/AddonModuleXbmcaddon.i @@ -37,6 +37,7 @@ using namespace xbmcaddon; %feature("knownbasetypes") XBMCAddon::xbmcaddon "AddonClass" %include "interfaces/legacy/swighelper.h" +%include "interfaces/legacy/AddonString.h" %feature("python:coerceToUnicode") XBMCAddon::xbmcaddon::Addon::getLocalizedString "true" %include "interfaces/legacy/Addon.h" diff --git a/xbmc/interfaces/swig/AddonModuleXbmcgui.i b/xbmc/interfaces/swig/AddonModuleXbmcgui.i index b8e8fbc909..1a6f91d9e6 100644 --- a/xbmc/interfaces/swig/AddonModuleXbmcgui.i +++ b/xbmc/interfaces/swig/AddonModuleXbmcgui.i @@ -44,11 +44,14 @@ using namespace xbmcgui; %feature("knownbasetypes") XBMCAddon::xbmcgui "AddonClass,AddonCallback" %include "interfaces/legacy/swighelper.h" +%include "interfaces/legacy/AddonString.h" %include "interfaces/legacy/ModuleXbmcgui.h" %include "interfaces/legacy/Exception.h" +%include "interfaces/legacy/Dictionary.h" + %include "interfaces/legacy/ListItem.h" %feature("python:coerceToUnicode") XBMCAddon::xbmcgui::ControlButton::getLabel "true" diff --git a/xbmc/interfaces/swig/AddonModuleXbmcplugin.i b/xbmc/interfaces/swig/AddonModuleXbmcplugin.i index 37a0d86933..32a144d91d 100644 --- a/xbmc/interfaces/swig/AddonModuleXbmcplugin.i +++ b/xbmc/interfaces/swig/AddonModuleXbmcplugin.i @@ -35,5 +35,6 @@ using namespace xbmcplugin; %feature("knownapitypes") XBMCAddon::xbmcplugin "XBMCAddon::xbmcgui::ListItem" %include "interfaces/legacy/swighelper.h" +%include "interfaces/legacy/AddonString.h" %include "interfaces/legacy/ModuleXbmcplugin.h" diff --git a/xbmc/interfaces/swig/AddonModuleXbmcvfs.i b/xbmc/interfaces/swig/AddonModuleXbmcvfs.i index ac09158cf1..78a010ca38 100644 --- a/xbmc/interfaces/swig/AddonModuleXbmcvfs.i +++ b/xbmc/interfaces/swig/AddonModuleXbmcvfs.i @@ -36,7 +36,7 @@ using namespace xbmcvfs; %} %include "interfaces/legacy/swighelper.h" - +%include "interfaces/legacy/AddonString.h" %include "interfaces/legacy/File.h" %rename ("st_atime") XBMCAddon::xbmcvfs::Stat::atime; |