diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-08-03 14:35:35 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:17:08 -0300 |
commit | f2e0002c8ebc7a68fca731bfbde1d32415f5a240 (patch) | |
tree | 54bd01c50ada4bb89e71f24a2dedb7cb7c91dc64 /libshiboken | |
parent | 699f6db172df37631dec7a884a25df8cc62343b8 (diff) |
Fixed type system variable replacement for arguments removed with conversion rule.
Also added an array argument modification test, and moved
AutoArrayPointer from libpyside to libshiboken.
Reviewed by Hugo Parente <hugo.lima@openbossa.org>
Reviewed by Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'libshiboken')
-rw-r--r-- | libshiboken/helper.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/libshiboken/helper.h b/libshiboken/helper.h index b5e0b624e..f179b2d7c 100644 --- a/libshiboken/helper.h +++ b/libshiboken/helper.h @@ -92,6 +92,20 @@ LIBSHIBOKEN_API bool sequenceToArgcArgv(PyObject* argList, int* argc, char*** ar */ LIBSHIBOKEN_API int* sequenceToIntArray(PyObject* obj, bool zeroTerminated = false); +/** + * Creates and automatically deallocates C++ arrays. + */ +template<class T> +class AutoArrayPointer +{ + public: + AutoArrayPointer(int size) { data = new T[size]; } + T& operator[](int pos) { return data[pos]; } + operator T*() const { return data; } + ~AutoArrayPointer() { delete[] data; } + private: + T* data; +}; /** * An utility function used to call PyErr_WarnEx with a formatted message. @@ -101,4 +115,3 @@ LIBSHIBOKEN_API int warning(PyObject *category, int stacklevel, const char *form } // namespace Shiboken #endif // HELPER_H - |