summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-10-21 17:22:36 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2011-12-09 20:28:07 -0300
commit3522a207cc2307e331cb85c25afabc355fe50a78 (patch)
tree2c2c2a7638b4d0443c854b0e5b19d31ed93142bb
parent333703fd5adf573808a81ab190b393ff121de0bc (diff)
downloadshiboken-3522a207cc2307e331cb85c25afabc355fe50a78.tar.gz
shiboken-3522a207cc2307e331cb85c25afabc355fe50a78.tar.xz
shiboken-3522a207cc2307e331cb85c25afabc355fe50a78.zip
Fixes SBK_CONVERTER macro and SbkEnumType structure.
Fixes provided by Hugo Parente Lima. Unit test added.
-rw-r--r--libshiboken/sbkconverter.h4
-rw-r--r--libshiboken/sbkenum.cpp5
-rw-r--r--tests/libsample/mapuser.h3
-rw-r--r--tests/samplebinding/map_test.py9
4 files changed, 16 insertions, 5 deletions
diff --git a/libshiboken/sbkconverter.h b/libshiboken/sbkconverter.h
index 0edd5abb..463014fd 100644
--- a/libshiboken/sbkconverter.h
+++ b/libshiboken/sbkconverter.h
@@ -282,7 +282,7 @@ template<> inline SbkConverter* PrimitiveTypeConverter<void*>() { return primiti
} } // namespace Shiboken::Conversions
-struct _SbkGenericType { PyHeapTypeObject super; SbkConverter* converter; };
-#define SBK_CONVERTER(objType) (reinterpret_cast<_SbkGenericType*>(objType)->converter)
+struct _SbkGenericType { PyHeapTypeObject super; SbkConverter** converter; };
+#define SBK_CONVERTER(pyType) (*reinterpret_cast<_SbkGenericType*>(pyType)->converter)
#endif // SBK_CONVERTER_H
diff --git a/libshiboken/sbkenum.cpp b/libshiboken/sbkenum.cpp
index c2f6ce0c..306ffc8d 100644
--- a/libshiboken/sbkenum.cpp
+++ b/libshiboken/sbkenum.cpp
@@ -41,6 +41,7 @@ extern "C"
struct SbkEnumType
{
PyHeapTypeObject super;
+ SbkConverter** converterPtr;
SbkConverter* converter;
const char* cppName;
};
@@ -533,7 +534,9 @@ PyTypeObject* newTypeWithName(const char* name, const char* cppName)
type->tp_richcompare = &enum_richcompare;
type->tp_hash = &enum_hash;
- reinterpret_cast<SbkEnumType*>(type)->cppName = cppName;
+ SbkEnumType* enumType = reinterpret_cast<SbkEnumType*>(type);
+ enumType->cppName = cppName;
+ enumType->converterPtr = &enumType->converter;
DeclaredEnumTypes::instance().addEnumType(type);
return type;
}
diff --git a/tests/libsample/mapuser.h b/tests/libsample/mapuser.h
index e08525ab..938c6c14 100644
--- a/tests/libsample/mapuser.h
+++ b/tests/libsample/mapuser.h
@@ -28,6 +28,7 @@
#include <utility>
#include <string>
#include "complex.h"
+#include "bytearray.h"
#include "libsamplemacros.h"
@@ -45,6 +46,8 @@ public:
inline void setMap(std::map<std::string, std::list<int> > map) { m_map = map; }
inline std::map<std::string, std::list<int> > getMap() { return m_map; }
+ inline const std::map<int, ByteArray>& passMapIntValueType(const std::map<int, ByteArray>& arg) { return arg; }
+
private:
std::map<std::string, std::list<int> > m_map;
};
diff --git a/tests/samplebinding/map_test.py b/tests/samplebinding/map_test.py
index 02b9496c..8623907e 100644
--- a/tests/samplebinding/map_test.py
+++ b/tests/samplebinding/map_test.py
@@ -26,7 +26,6 @@
'''Test cases for std::map container conversions'''
-import sys
import unittest
from sample import MapUser
@@ -65,6 +64,12 @@ class MapConversionTest(unittest.TestCase):
result = mu.getMap()
self.assertEqual(result, map_)
+ def testConversionMapIntKeyValueTypeValue(self):
+ '''C++ signature: MapUser::passMapIntValueType(const std::map<int, const ByteArray>&)'''
+ mu = MapUser()
+ map_ = {0 : 'string'}
+ result = mu.passMapIntValueType(map_)
+ self.assertEqual(map_, result)
+
if __name__ == '__main__':
unittest.main()
-