aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2010-08-20 16:37:41 -0300
committerRenato Filho <renato.filho@openbossa.org>2010-08-20 18:10:30 -0300
commit662800956b935bf344dfb8cbfb47f2c3b5717aec (patch)
tree6fae6207088479b49e5995ede1a01eecf70997a4
parent0576d04403cd02e08bc6c8d71c30f4abc186f95e (diff)
Use AutoPointerArray to dynamic array creation.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Hugo Parente Lima <hugo.pl@gmail.com>
-rw-r--r--PySide/QtCore/typesystem_core.xml6
-rw-r--r--PySide/QtGui/typesystem_gui_common.xml9
-rw-r--r--libpyside/autoarraypointer.h58
3 files changed, 68 insertions, 5 deletions
diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml
index f1c4cf2f8..1e371f026 100644
--- a/PySide/QtCore/typesystem_core.xml
+++ b/PySide/QtCore/typesystem_core.xml
@@ -127,10 +127,12 @@
<primitive-type name="unsigned int" default-constructor="0"/>
<primitive-type name="signed long" default-constructor="0"/>
<primitive-type name="long"/>
- <primitive-type name="unsigned long" default-constructor="0"/>
- <primitive-type name="Qt::HANDLE" target-lang-api-name="PyLong">
+ <primitive-type name="unsigned long" default-constructor="0">
<!-- FIXME APIExtractor or shiboken do not support multiple includes by primitive type -->
<include file-name="signalmanager.h" location="global"/>
+ </primitive-type>
+ <primitive-type name="Qt::HANDLE" target-lang-api-name="PyLong">
+ <!-- FIXME APIExtractor or shiboken do not support multiple includes by primitive type -->
<include file-name="QTextDocument" location="global"/>
</primitive-type>
<primitive-type name="QBool" target-lang-api-name="PyBool">
diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml
index 111096488..80122c297 100644
--- a/PySide/QtGui/typesystem_gui_common.xml
+++ b/PySide/QtGui/typesystem_gui_common.xml
@@ -2587,7 +2587,10 @@
<!-- TODO: Support conversions on virtual function -->
<modify-function signature="drawItems(QPainter*, int, QGraphicsItem**, const QStyleOptionGraphicsItem*)">
-
+ <extra-includes>
+ <include file-name="autoarraypointer.h" location="global"/>
+ </extra-includes>
+
<modify-argument index="2">
<remove-argument/>
<conversion-rule class="native">
@@ -2599,7 +2602,7 @@
<replace-type modified-type="PySequence"/>
<conversion-rule class="native">
int numItems = PySequence_Size(%PYARG_1);
- QGraphicsItem *%out[numItems];
+ PySide::AutoArrayPointer&lt;QGraphicsItem*&gt; %out(numItems);
for (int i=0; i &lt; numItems; i++) {
%out[i] = %CONVERTTOCPP[QGraphicsItem*](PySequence_Fast_GET_ITEM(%PYARG_1, i));
}
@@ -2626,7 +2629,7 @@
<conversion-rule class="native">
int numOptions = PySequence_Size(%PYARG_2);
- QStyleOptionGraphicsItem %out[numOptions];
+ PySide::AutoArrayPointer&lt;QStyleOptionGraphicsItem&gt; %out(numOptions);
for (int i=0; i &lt; numOptions; i++) {
%out[i] = %CONVERTTOCPP[QStyleOptionGraphicsItem](PySequence_Fast_GET_ITEM(%PYARG_1, i));
}
diff --git a/libpyside/autoarraypointer.h b/libpyside/autoarraypointer.h
new file mode 100644
index 000000000..433401c43
--- /dev/null
+++ b/libpyside/autoarraypointer.h
@@ -0,0 +1,58 @@
+/*
+ * This file is part of the Shiboken Python Bindings Generator project.
+ *
+ * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * Contact: PySide team <contact@pyside.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation. Please
+ * review the following information to ensure the GNU Lesser General
+ * Public License version 2.1 requirements will be met:
+ * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ *
+ * As a special exception to the GNU Lesser General Public License
+ * version 2.1, the object code form of a "work that uses the Library"
+ * may incorporate material from a header file that is part of the
+ * Library. You may distribute such object code under terms of your
+ * choice, provided that the incorporated material (i) does not exceed
+ * more than 5% of the total size of the Library; and (ii) is limited to
+ * numerical parameters, data structure layouts, accessors, macros,
+ * inline functions and templates.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef AUTOARRAYPOINTER_H
+#define AUTOARRAYPOINTER_H
+
+
+namespace PySide
+{
+
+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;
+};
+
+} //namespace PySide
+
+
+#endif // AUTOARRAYPOINTER_H
+