Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- michele:/home/devel/pyside/shiboken$ cat /home/devel/pyside/shiboken/tests/samplebinding/sample/abstractmodifications_wrapper.cpp
- //workaround to access protected functions
- #define protected public
- // default includes
- #include <shiboken.h>
- #include "sample_python.h"
- #include "abstractmodifications_wrapper.h"
- // Extra includes
- #include <point.h>
- #include <utility>
- using namespace Shiboken;
- // Native ---------------------------------------------------------
- AbstractModificationsWrapper::AbstractModificationsWrapper() : AbstractModifications() {
- // ... middle
- }
- void AbstractModificationsWrapper::pointlessPureVirtualMethod()
- {
- PyObject* py_override = BindingManager::instance().getOverride(this, "pointlessPureVirtualMethod");
- if (!py_override) {
- PyErr_SetString(PyExc_NotImplementedError, "pure virtual method 'AbstractModifications.pointlessPureVirtualMethod()' not implemented.");
- return;
- }
- PyObject* pyargs = PyTuple_New(0);
- PyGILState_STATE gil_state = PyGILState_Ensure();
- PyObject_Call(py_override, pyargs, NULL);
- PyGILState_Release(gil_state);
- Py_XDECREF(pyargs);
- Py_XDECREF(py_override);
- // check and set Python error here...
- }
- const char * AbstractModificationsWrapper::className()
- {
- PyObject* py_override = BindingManager::instance().getOverride(this, "name");
- if (!py_override) {
- return this->Modifications::className();
- }
- PyObject* pyargs = PyTuple_New(0);
- PyGILState_STATE gil_state = PyGILState_Ensure();
- PyObject* py_result = PyObject_Call(py_override, pyargs, NULL);
- PyGILState_Release(gil_state);
- Py_XDECREF(pyargs);
- Py_XDECREF(py_override);
- // check and set Python error here...
- return Shiboken::Converter<const char * >::toCpp(py_result);
- }
- AbstractModificationsWrapper::~AbstractModificationsWrapper()
- {
- BindingManager::instance().invalidateWrapper(this);
- }
- // Target ---------------------------------------------------------
- PyObject*
- SbkAbstractModifications_New(Shiboken::SbkBaseWrapperType* type, PyObject* args, PyObject* kwds)
- {
- PyObject* self;
- AbstractModificationsWrapper* cptr;
- if (type == &SbkAbstractModifications_Type) {
- PyErr_SetString(PyExc_NotImplementedError,
- "'AbstractModifications' represents a C++ abstract class and cannot be instanciated");
- return 0;
- }
- if (!PyType_IsSubtype((PyTypeObject*)type, (PyTypeObject*)&SbkAbstractModifications_Type))
- return 0;
- // AbstractModifications()
- cptr = new AbstractModificationsWrapper();
- self = Shiboken::SbkBaseWrapper_New(type, cptr, 1, 1);
- if (!self) {
- if (cptr) delete cptr;
- return 0;
- }
- return self;
- }
- static PyObject*
- SbkAbstractModifications_invert(PyObject* self, PyObject* arg)
- {
- if (Shiboken::cppObjectIsInvalid(self))
- return 0;
- PyObject* py_result = 0;
- if (PyBool_Check(arg)) {
- bool cpp_arg0 = Shiboken::Converter<bool >::toCpp(arg);
- // invert(bool)
- py_result = Shiboken::Converter<bool >::toPython(
- SbkAbstractModifications_cptr(self)->AbstractModifications::invert(cpp_arg0)
- );
- } else goto SbkAbstractModifications_invert_TypeError;
- if (PyErr_Occurred() || !py_result) {
- Py_XDECREF(py_result);
- return 0;
- }
- return py_result;
- SbkAbstractModifications_invert_TypeError:
- PyErr_SetString(PyExc_TypeError, "'invert()' called with wrong parameters.");
- return 0;
- }
- static PyObject*
- SbkAbstractModifications_pointlessPureVirtualMethod(PyObject* self)
- {
- PyErr_SetString(PyExc_NotImplementedError, "pure virtual method 'AbstractModifications.pointlessPureVirtualMethod()' not implemented.");
- return 0;
- }
- static PyMethodDef SbkAbstractModifications_methods[] = {
- {"invert", (PyCFunction)SbkAbstractModifications_invert, METH_O},
- {"pointlessPureVirtualMethod", (PyCFunction)SbkAbstractModifications_pointlessPureVirtualMethod, METH_NOARGS},
- {0} // Sentinel
- };
- extern "C"
- {
- // Class Definition -----------------------------------------------
- Shiboken::SbkBaseWrapperType SbkAbstractModifications_Type = { { {
- PyObject_HEAD_INIT(&Shiboken::SbkBaseWrapperType_Type)
- /*ob_size*/ 0,
- /*tp_name*/ "AbstractModifications",
- /*tp_basicsize*/ sizeof(Shiboken::SbkBaseWrapper),
- /*tp_itemsize*/ 0,
- /*tp_dealloc*/ (destructor)&(Shiboken::SbkBaseWrapper_Dealloc< AbstractModificationsWrapper >),
- /*tp_print*/ 0,
- /*tp_getattr*/ 0,
- /*tp_setattr*/ 0,
- /*tp_compare*/ 0,
- /*tp_repr*/ 0,
- /*tp_as_number*/ 0,
- /*tp_as_sequence*/ 0,
- /*tp_as_mapping*/ 0,
- /*tp_hash*/ 0,
- /*tp_call*/ 0,
- /*tp_str*/ 0,
- /*tp_getattro*/ 0,
- /*tp_setattro*/ 0,
- /*tp_as_buffer*/ 0,
- /*tp_flags*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES,
- /*tp_doc*/ 0,
- /*tp_traverse*/ 0,
- /*tp_clear*/ 0,
- /*tp_richcompare*/ 0,
- /*tp_weaklistoffset*/ 0,
- /*tp_iter*/ 0,
- /*tp_iternext*/ 0,
- /*tp_methods*/ SbkAbstractModifications_methods,
- /*tp_members*/ 0,
- /*tp_getset*/ 0,
- /*tp_base*/ (PyTypeObject*)&SbkModifications_Type,
- /*tp_dict*/ 0,
- /*tp_descr_get*/ 0,
- /*tp_descr_set*/ 0,
- /*tp_dictoffset*/ 0,
- /*tp_init*/ 0,
- /*tp_alloc*/ 0,
- /*tp_new*/ (newfunc)SbkAbstractModifications_New,
- /*tp_free*/ 0,
- /*tp_is_gc*/ 0,
- /*tp_bases*/ 0,
- /*tp_mro*/ 0,
- /*tp_cache*/ 0,
- /*tp_subclasses*/ 0,
- /*tp_weaklist*/ 0
- }, },
- /*mi_offsets*/ 0,
- /*mi_init*/ 0,
- /*mi_specialcast*/ 0
- };
- PyAPI_FUNC(void)
- init_abstractmodifications(PyObject* module)
- {
- if (PyType_Ready((PyTypeObject*)&SbkAbstractModifications_Type) < 0)
- return;
- Py_INCREF(&SbkAbstractModifications_Type);
- PyModule_AddObject(module, "AbstractModifications",
- ((PyObject*)&SbkAbstractModifications_Type));
- }
- } // extern "C"
- namespace Shiboken
- {
- // Copy C++ object implementation
- // Converter implementations
- } // namespace Shiboken
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement