summaryrefslogtreecommitdiffstats
path: root/libshiboken
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-10-14 11:15:29 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2011-12-09 20:28:06 -0300
commit1b32cda8e2e2df1004e5bcc3deeef614e1424f53 (patch)
tree20fa9427c2098a246b9c41d3b0147cbeea25eaa4 /libshiboken
parent9bc3d8b776c00850391918ff03c376217e188a63 (diff)
downloadshiboken-1b32cda8e2e2df1004e5bcc3deeef614e1424f53.tar.gz
shiboken-1b32cda8e2e2df1004e5bcc3deeef614e1424f53.tar.xz
shiboken-1b32cda8e2e2df1004e5bcc3deeef614e1424f53.zip
Updates creation of QFlags types at runtime.
Diffstat (limited to 'libshiboken')
-rw-r--r--libshiboken/basewrapper_p.h2
-rw-r--r--libshiboken/sbkconverter.h2
-rw-r--r--libshiboken/sbkenum.cpp19
-rw-r--r--libshiboken/sbkenum.h7
-rw-r--r--libshiboken/sbkenum_p.h38
5 files changed, 12 insertions, 56 deletions
diff --git a/libshiboken/basewrapper_p.h b/libshiboken/basewrapper_p.h
index c943a2a0..64e290bf 100644
--- a/libshiboken/basewrapper_p.h
+++ b/libshiboken/basewrapper_p.h
@@ -101,6 +101,7 @@ struct SbkObjectPrivate
struct SbkObjectTypePrivate
{
+ SbkConverter* converter;
int* mi_offsets;
MultipleInheritanceInitFunction mi_init;
@@ -121,7 +122,6 @@ struct SbkObjectTypePrivate
void* user_data;
DeleteUserDataFunc d_func;
void (*subtype_init)(SbkObjectType*, PyObject*, PyObject*);
- SbkConverter* converter;
};
diff --git a/libshiboken/sbkconverter.h b/libshiboken/sbkconverter.h
index ba8dc8f2..a91d14e6 100644
--- a/libshiboken/sbkconverter.h
+++ b/libshiboken/sbkconverter.h
@@ -23,8 +23,8 @@
#ifndef SBK_CONVERTER_H
#define SBK_CONVERTER_H
+#include "sbkpython.h"
#include <limits>
-#include <Python.h>
#include "shibokenmacros.h"
#include "basewrapper.h"
diff --git a/libshiboken/sbkenum.cpp b/libshiboken/sbkenum.cpp
index 5810a41c..2caae92f 100644
--- a/libshiboken/sbkenum.cpp
+++ b/libshiboken/sbkenum.cpp
@@ -22,7 +22,6 @@
#include "sbkenum.h"
#include "sbkstring.h"
-#include "sbkenum_p.h"
#include "sbkconverter.h"
#include "basewrapper.h"
#include "sbkdbg.h"
@@ -39,6 +38,12 @@
extern "C"
{
+struct SbkEnumType
+{
+ PyHeapTypeObject super;
+ SbkConverter* converter;
+};
+
struct SbkEnumObject
{
PyObject_HEAD
@@ -349,10 +354,8 @@ void SbkEnumTypeDealloc(PyObject* pyObj)
PyObject_GC_UnTrack(pyObj);
Py_TRASHCAN_SAFE_BEGIN(pyObj);
- if (sbkType->d) {
- Shiboken::Conversions::deleteConverter(sbkType->d->converter);
- delete sbkType->d;
- sbkType->d = 0;
+ if (sbkType->converter) {
+ Shiboken::Conversions::deleteConverter(sbkType->converter);
}
Py_TRASHCAN_SAFE_END(pyObj);
}
@@ -362,8 +365,6 @@ PyObject* SbkEnumTypeTpNew(PyTypeObject* metatype, PyObject* args, PyObject* kwd
SbkEnumType* newType = reinterpret_cast<SbkEnumType*>(PyType_Type.tp_new(metatype, args, kwds));
if (!newType)
return 0;
- newType->d = new SbkEnumTypePrivate;
- memset(newType->d, 0, sizeof(SbkEnumTypePrivate));
return reinterpret_cast<PyObject*>(newType);
}
@@ -520,8 +521,8 @@ PyTypeObject* newType(const char* name)
PyTypeObject* newTypeWithName(const char* name, const char* cppName)
{
- PyTypeObject* type = new PyTypeObject;
- ::memset(type, 0, sizeof(PyTypeObject));
+ PyTypeObject* type = reinterpret_cast<PyTypeObject*>(new SbkEnumType);
+ ::memset(type, 0, sizeof(SbkEnumType));
Py_TYPE(type) = &SbkEnumType_Type;
type->tp_basicsize = sizeof(SbkEnumObject);
type->tp_print = &SbkEnumObject_print;
diff --git a/libshiboken/sbkenum.h b/libshiboken/sbkenum.h
index 19250b4e..afe91416 100644
--- a/libshiboken/sbkenum.h
+++ b/libshiboken/sbkenum.h
@@ -32,13 +32,6 @@ extern "C"
extern LIBSHIBOKEN_API PyTypeObject SbkEnumType_Type;
struct SbkObjectType;
-struct SbkEnumTypePrivate;
-struct LIBSHIBOKEN_API SbkEnumType
-{
- PyHeapTypeObject super;
- SbkEnumTypePrivate* d;
-};
-
} // extern "C"
namespace Shiboken
diff --git a/libshiboken/sbkenum_p.h b/libshiboken/sbkenum_p.h
deleted file mode 100644
index c173f0b7..00000000
--- a/libshiboken/sbkenum_p.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * This file is part of the Shiboken Python Bindings Generator project.
- *
- * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
- *
- * Contact: PySide team <contact@pyside.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef SBKENUM_P_H
-#define SBKENUM_P_H
-
-struct SbkConverter;
-
-extern "C"
-{
-
-struct SbkEnumTypePrivate
-{
- SbkConverter* converter;
-};
-
-} // extern "C"
-
-#endif // SKB_PYENUM_P_H