Use AutoPointerArray to dynamic array creation.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org>
Hugo Parente Lima <hugo.pl@gmail.com>
This commit is contained in:
parent
0576d04403
commit
662800956b
3 changed files with 68 additions and 5 deletions
|
|
@ -127,10 +127,12 @@
|
||||||
<primitive-type name="unsigned int" default-constructor="0"/>
|
<primitive-type name="unsigned int" default-constructor="0"/>
|
||||||
<primitive-type name="signed long" default-constructor="0"/>
|
<primitive-type name="signed long" default-constructor="0"/>
|
||||||
<primitive-type name="long"/>
|
<primitive-type name="long"/>
|
||||||
<primitive-type name="unsigned long" default-constructor="0"/>
|
<primitive-type name="unsigned long" default-constructor="0">
|
||||||
<primitive-type name="Qt::HANDLE" target-lang-api-name="PyLong">
|
|
||||||
<!-- FIXME APIExtractor or shiboken do not support multiple includes by primitive type -->
|
<!-- FIXME APIExtractor or shiboken do not support multiple includes by primitive type -->
|
||||||
<include file-name="signalmanager.h" location="global"/>
|
<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"/>
|
<include file-name="QTextDocument" location="global"/>
|
||||||
</primitive-type>
|
</primitive-type>
|
||||||
<primitive-type name="QBool" target-lang-api-name="PyBool">
|
<primitive-type name="QBool" target-lang-api-name="PyBool">
|
||||||
|
|
|
||||||
|
|
@ -2587,7 +2587,10 @@
|
||||||
|
|
||||||
<!-- TODO: Support conversions on virtual function -->
|
<!-- TODO: Support conversions on virtual function -->
|
||||||
<modify-function signature="drawItems(QPainter*, int, QGraphicsItem**, const QStyleOptionGraphicsItem*)">
|
<modify-function signature="drawItems(QPainter*, int, QGraphicsItem**, const QStyleOptionGraphicsItem*)">
|
||||||
|
<extra-includes>
|
||||||
|
<include file-name="autoarraypointer.h" location="global"/>
|
||||||
|
</extra-includes>
|
||||||
|
|
||||||
<modify-argument index="2">
|
<modify-argument index="2">
|
||||||
<remove-argument/>
|
<remove-argument/>
|
||||||
<conversion-rule class="native">
|
<conversion-rule class="native">
|
||||||
|
|
@ -2599,7 +2602,7 @@
|
||||||
<replace-type modified-type="PySequence"/>
|
<replace-type modified-type="PySequence"/>
|
||||||
<conversion-rule class="native">
|
<conversion-rule class="native">
|
||||||
int numItems = PySequence_Size(%PYARG_1);
|
int numItems = PySequence_Size(%PYARG_1);
|
||||||
QGraphicsItem *%out[numItems];
|
PySide::AutoArrayPointer<QGraphicsItem*> %out(numItems);
|
||||||
for (int i=0; i < numItems; i++) {
|
for (int i=0; i < numItems; i++) {
|
||||||
%out[i] = %CONVERTTOCPP[QGraphicsItem*](PySequence_Fast_GET_ITEM(%PYARG_1, i));
|
%out[i] = %CONVERTTOCPP[QGraphicsItem*](PySequence_Fast_GET_ITEM(%PYARG_1, i));
|
||||||
}
|
}
|
||||||
|
|
@ -2626,7 +2629,7 @@
|
||||||
|
|
||||||
<conversion-rule class="native">
|
<conversion-rule class="native">
|
||||||
int numOptions = PySequence_Size(%PYARG_2);
|
int numOptions = PySequence_Size(%PYARG_2);
|
||||||
QStyleOptionGraphicsItem %out[numOptions];
|
PySide::AutoArrayPointer<QStyleOptionGraphicsItem> %out(numOptions);
|
||||||
for (int i=0; i < numOptions; i++) {
|
for (int i=0; i < numOptions; i++) {
|
||||||
%out[i] = %CONVERTTOCPP[QStyleOptionGraphicsItem](PySequence_Fast_GET_ITEM(%PYARG_1, i));
|
%out[i] = %CONVERTTOCPP[QStyleOptionGraphicsItem](PySequence_Fast_GET_ITEM(%PYARG_1, i));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
58
libpyside/autoarraypointer.h
Normal file
58
libpyside/autoarraypointer.h
Normal file
|
|
@ -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
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue