diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-09-13 16:32:47 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:18:27 -0300 |
commit | ff0b861b59b41387e771d9cd565e13de8b2750d1 (patch) | |
tree | fccaea50e4150a8345494833f97aaf0d147f7177 /tests | |
parent | 0adc55471d864d307034dd995d6c70c18952b279 (diff) |
Shiboken exits with error for not handled pointers to primitive types.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/libsample/str.cpp | 11 | ||||
-rw-r--r-- | tests/libsample/str.h | 2 | ||||
-rw-r--r-- | tests/samplebinding/typesystem_sample.xml | 38 |
3 files changed, 51 insertions, 0 deletions
diff --git a/tests/libsample/str.cpp b/tests/libsample/str.cpp index 20c2084a9..db8bf2ec7 100644 --- a/tests/libsample/str.cpp +++ b/tests/libsample/str.cpp @@ -166,3 +166,14 @@ unsigned int strHash(const Str& str) return result; } +void changePStr(PStr* pstr, const char* suffix) +{ + pstr->append(suffix); +} + +void duplicatePStr(PStr* pstr) +{ + if (!pstr) + return; + pstr->append(*pstr); +} diff --git a/tests/libsample/str.h b/tests/libsample/str.h index 65fc18349..38b41db60 100644 --- a/tests/libsample/str.h +++ b/tests/libsample/str.h @@ -66,5 +66,7 @@ LIBSAMPLE_API Str operator+(int number, const Str& str); LIBSAMPLE_API unsigned int strHash(const Str& str); typedef Str PStr; +LIBSAMPLE_API void changePStr(PStr* pstr, const char* suffix); +LIBSAMPLE_API void duplicatePStr(PStr* pstr = 0); #endif // STR_H diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml index ac865df69..ae24245fc 100644 --- a/tests/samplebinding/typesystem_sample.xml +++ b/tests/samplebinding/typesystem_sample.xml @@ -118,6 +118,44 @@ </conversion-rule> </primitive-type> + <function signature="changePStr(PStr*, const char*)"> + <!-- + Comment out these modifications and the Shiboken generator + will issue a fatal error, because it can't handle a pointer + to a primitive type (PStr*) without help from the binding + developer. + --> + <modify-function signature="changePStr(PStr*, const char*)"> + <modify-argument index="1"> + <replace-type modified-type="PStr"/> + </modify-argument> + <modify-argument index="return"> + <replace-type modified-type="PyObject"/> + </modify-argument> + <inject-code class="target" position="beginning"> + %FUNCTION_NAME(&%1, %2); + %PYARG_0 = %CONVERTTOPYTHON[PStr](%1); + </inject-code> + </modify-function> + </function> + + <function signature="duplicatePStr(PStr*)"> + <modify-function signature="duplicatePStr(PStr*)"> + <modify-argument index="return"> + <replace-type modified-type="PyObject"/> + </modify-argument> + <modify-argument index="1"> + <replace-type modified-type="PStr"/> + <remove-default-expression/> + <replace-default-expression with="PStr()"/> + </modify-argument> + <inject-code class="target" position="end"> + %FUNCTION_NAME(&%1); + %PYARG_0 = %CONVERTTOPYTHON[PStr](%1); + </inject-code> + </modify-function> + </function> + <primitive-type name="PStrList"> <include file-name="strlist.h" location="global"/> <conversion-rule> |