Rename some slot internal functions and structures and remove C linkage from init_slot function.

This commit is contained in:
Hugo Parente Lima 2010-10-06 18:29:05 -03:00
commit 740137e51a
3 changed files with 61 additions and 27 deletions

View file

@ -22,18 +22,17 @@
#include "pyside.h" #include "pyside.h"
#include "signalmanager.h"
#include "qproperty_p.h"
#include "qproperty.h"
#include "qsignal.h"
#include "qsignal_p.h"
#include <basewrapper.h> #include <basewrapper.h>
#include <conversions.h> #include <conversions.h>
#include <algorithm> #include <algorithm>
#include <cctype> #include <cctype>
#include <QStack> #include <QStack>
#include "signalmanager.h"
extern "C" void init_slot(PyObject* module); #include "qproperty_p.h"
#include "qproperty.h"
#include "qsignal.h"
#include "qsignal_p.h"
#include "qslot_p.h"
static QStack<PySide::CleanupFunction> cleanupFunctionList; static QStack<PySide::CleanupFunction> cleanupFunctionList;
@ -43,7 +42,7 @@ namespace PySide
void init(PyObject *module) void init(PyObject *module)
{ {
initSignalSupport(module); initSignalSupport(module);
init_slot(module); initSlotSupport(module);
initQProperty(module); initQProperty(module);
// Init signal manager, so it will register some meta types used by QVariant. // Init signal manager, so it will register some meta types used by QVariant.
SignalManager::instance(); SignalManager::instance();

View file

@ -38,11 +38,11 @@ typedef struct
extern "C" extern "C"
{ {
static int slot_init(PyObject*, PyObject*, PyObject*); static int slotTpInit(PyObject*, PyObject*, PyObject*);
static PyObject* slot_call(PyObject*, PyObject*, PyObject*); static PyObject* slotCall(PyObject*, PyObject*, PyObject*);
// Class Definition ----------------------------------------------- // Class Definition -----------------------------------------------
static PyTypeObject Slot_Type = { static PyTypeObject PySideSlotType = {
PyObject_HEAD_INIT(NULL) PyObject_HEAD_INIT(NULL)
0, /*ob_size*/ 0, /*ob_size*/
"PySide.QtCore."SLOT_DEC_NAME, /*tp_name*/ "PySide.QtCore."SLOT_DEC_NAME, /*tp_name*/
@ -58,7 +58,7 @@ static PyTypeObject Slot_Type = {
0, /*tp_as_sequence*/ 0, /*tp_as_sequence*/
0, /*tp_as_mapping*/ 0, /*tp_as_mapping*/
0, /*tp_hash */ 0, /*tp_hash */
slot_call, /*tp_call*/ slotCall, /*tp_call*/
0, /*tp_str*/ 0, /*tp_str*/
0, /*tp_getattro*/ 0, /*tp_getattro*/
0, /*tp_setattro*/ 0, /*tp_setattro*/
@ -79,7 +79,7 @@ static PyTypeObject Slot_Type = {
0, /*tp_descr_get */ 0, /*tp_descr_get */
0, /*tp_descr_set */ 0, /*tp_descr_set */
0, /*tp_dictoffset */ 0, /*tp_dictoffset */
(initproc)slot_init, /*tp_init */ slotTpInit, /*tp_init */
0, /*tp_alloc */ 0, /*tp_alloc */
PyType_GenericNew, /*tp_new */ PyType_GenericNew, /*tp_new */
0, /*tp_free */ 0, /*tp_free */
@ -92,19 +92,7 @@ static PyTypeObject Slot_Type = {
0, /*tp_del */ 0, /*tp_del */
}; };
void init_slot(PyObject *module) int slotTpInit(PyObject *self, PyObject *args, PyObject *kw)
{
if (PyType_Ready(&Slot_Type) < 0)
return;
Py_INCREF(&Slot_Type);
PyModule_AddObject(module, SLOT_DEC_NAME, ((PyObject*)&Slot_Type));
}
} // extern "C"
int slot_init(PyObject *self, PyObject *args, PyObject *kw)
{ {
static PyObject *emptyTuple = 0; static PyObject *emptyTuple = 0;
static const char *kwlist[] = {"name", "result", 0}; static const char *kwlist[] = {"name", "result", 0};
@ -144,7 +132,7 @@ int slot_init(PyObject *self, PyObject *args, PyObject *kw)
return 1; return 1;
} }
PyObject* slot_call(PyObject* self, PyObject* args, PyObject* kw) PyObject* slotCall(PyObject* self, PyObject* args, PyObject* kw)
{ {
static PyObject* pySlotName = 0; static PyObject* pySlotName = 0;
PyObject* callback; PyObject* callback;
@ -190,3 +178,18 @@ PyObject* slot_call(PyObject* self, PyObject* args, PyObject* kw)
return callback; return callback;
} }
} // extern "C"
namespace PySide
{
void initSlotSupport(PyObject* module)
{
if (PyType_Ready(&PySideSlotType) < 0)
return;
Py_INCREF(&PySideSlotType);
PyModule_AddObject(module, SLOT_DEC_NAME, ((PyObject*)&PySideSlotType));
}
} // namespace PySide

32
libpyside/qslot_p.h Normal file
View file

@ -0,0 +1,32 @@
/*
* This file is part of the PySide project.
*
* Copyright (C) 2009-2010 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 PYSIDE_SLOT_P_H
#define PYSIDE_SLOT_P_H
#include <Python.h>
namespace PySide
{
void initSlotSupport(PyObject* module);
}
#endif