diff --git a/kcardgame/CMakeLists.txt b/kcardgame/CMakeLists.txt deleted file mode 100644 index b8b6417d..00000000 --- a/kcardgame/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -project(minimal) - -set(minimal_TYPESYSTEM -${CMAKE_CURRENT_SOURCE_DIR}/typesystem_minimal.xml -) - -set(minimal_SRC -${CMAKE_CURRENT_BINARY_DIR}/minimal/minimal_module_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/minimal/obj_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/minimal/val_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/minimal/listuser_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/minimal/minbooluser_wrapper.cpp -) - -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/minimal-binding.txt.in" - "${CMAKE_CURRENT_BINARY_DIR}/minimal-binding.txt" @ONLY) - -add_custom_command(OUTPUT ${minimal_SRC} -COMMAND shiboken2 --project-file=${CMAKE_CURRENT_BINARY_DIR}/minimal-binding.txt ${GENERATOR_EXTRA_FLAGS} -DEPENDS ${minimal_TYPESYSTEM} ${CMAKE_CURRENT_SOURCE_DIR}/global.h shiboken2 -WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} -COMMENT "Running generator for 'minimal' test binding..." -) - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR} - ${SBK_PYTHON_INCLUDE_DIR} - ${libminimal_SOURCE_DIR} - ${libshiboken_SOURCE_DIR} - ${libshiboken_BINARY_DIR}) -add_library(minimal MODULE ${minimal_SRC}) -set_property(TARGET minimal PROPERTY PREFIX "") -set_property(TARGET minimal PROPERTY OUTPUT_NAME "minimal${PYTHON_EXTENSION_SUFFIX}") -if(WIN32) - set_property(TARGET minimal PROPERTY SUFFIX ".pyd") -endif() -target_link_libraries(minimal - libminimal - ${SBK_PYTHON_LIBRARIES} - libshiboken) diff --git a/kcardgame/Makefile b/kcardgame/Makefile deleted file mode 100644 index 3fe34496..00000000 --- a/kcardgame/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# ---- Link --------------------------- -kcardgame.so: kcardgame.o Makefile - gcc -shared -o kcardgame.so kcardgame.o `pkg-config --libs python3` - -# ---- gcc C compile ------------------ -kcardgame.o: kcardgame.cpp kcardgame.hpp Makefile - gcc `pkg-config --cflags Qt5Gui pyside2` -I /usr/include/PySide2/QtCore/ -I /usr/include/PySide2/QtGui/ -I build-kpat/libkcardgame/ -I kpat/libkcardgame/include -I kpat/libkcardgame/ -g -fPIC -c kcardgame.cpp -I /usr/include/python3.7m/ -I /usr/lib64/python3.7/site-packages/numpy/core/include/numpy diff --git a/kcardgame/kcardgame.cpp b/kcardgame/kcardgame.cpp deleted file mode 100644 index 546806b0..00000000 --- a/kcardgame/kcardgame.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* A file to test imorting C modules for handling arrays to Python */ - -#include "Python.h" -#include "arrayobject.h" -#include "kcardgame.hpp" -#include -#include "QtGui/pyside2_qtgui_python.h" -#include - -/* #### Globals #################################### */ - -/* ==== Set up the methods table ====================== */ -static struct PyMethodDef _kcardgameMethods[] = { - {"np_kcardgame", np_kcardgame, METH_VARARGS, "kcardgame"}, - {NULL, NULL, 0, NULL} /* Sentinel - marks the end of this structure */ -}; - -static struct PyModuleDef _kcardgame_mod = { - PyModuleDef_HEAD_INIT, - "_kcardgame", - NULL, - -1, - _kcardgameMethods - }; - - -/* ==== Initialize the C_test functions ====================== */ -// Module name must be _kcardgame in compile and linked -PyMODINIT_FUNC -PyInit_kcardgame() { - PyObject* ret = PyModule_Create(&_kcardgame_mod); - import_array(); // Must be present for NumPy. Called first after above line. - return ret; -} - -/* ==== Create 1D Carray from PyArray ====================== - Assumes PyArray is contiguous in memory. */ -static inline uint64_t *pyvector_to_Carrayptrs(PyArrayObject *arrayin) { - return (uint64_t *) arrayin->data; /* pointer to arrayin data as double */ -} - -int my_kcardgame( - const uint64_t *const cin, - const size_t n) -{ - unsigned __int128 sum = 0; - /* Operate on the vectors */ - for ( size_t i=0; icardPixmap(i, true)); - return PyType_GenericNew(Shiboken::SbkType, ret, NULL); -} - -/* ==== Square vector components & multiply by a float ========================= -/* #### Vector Utility functions ######################### */ - -/* ==== Make a Python Array Obj. from a PyObject, ================ - generates a double vector w/ contiguous memory which may be a new allocation if - the original was not a double type or contiguous - !! Must DECREF the object returned from this routine unless it is returned to the - caller of this routines caller using return PyArray_Return(obj) or - PyArray_BuildValue with the "N" construct !!! -*/ -PyArrayObject *pyvector(PyObject *objin) { - return (PyArrayObject *) PyArray_ContiguousFromObject(objin, - NPY_DOUBLE, 1,1); -} -/* ==== Check that PyArrayObject is a double (Float) type and a vector ============== - return 1 if an error and raise exception */ -int not_doublevector(PyArrayObject *vec) { - if (vec->descr->type_num != NPY_UINT64 || vec->nd != 1) { - PyErr_SetString(PyExc_ValueError, - "In not_doublevector: array must be of type uint644 and 1 dimensional (n)."); - return 1; } - return 0; -} - -/* #### Matrix Extensions ############################## */ - diff --git a/kcardgame/kcardgame.hpp b/kcardgame/kcardgame.hpp deleted file mode 100644 index ab69ea83..00000000 --- a/kcardgame/kcardgame.hpp +++ /dev/null @@ -1,10 +0,0 @@ -/* Header to test of C modules for arrays for Python: C_test.c */ - -/* ==== Prototypes =================================== */ - -// .... Python callable Vector functions .................. -static PyObject *np_kcardgame(PyObject *self, PyObject *args); - -/* .... C vector utility functions ..................*/ -PyArrayObject *pyvector(PyObject *objin); -int not_doublevector(PyArrayObject *vec); diff --git a/kcardgame/minbool_test.py b/kcardgame/minbool_test.py deleted file mode 100644 index 020e9a41..00000000 --- a/kcardgame/minbool_test.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## GNU General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## included in the packaging of this file. Please review the following -## information to ensure the GNU General Public License requirements will -## be met: https://www.gnu.org/licenses/gpl-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# - -import unittest - -from minimal import MinBoolUser - -class DerivedMinBoolUser (MinBoolUser): - def returnMyselfVirtual(self): - return MinBoolUser() - -class MinBoolTest(unittest.TestCase): - - def testMinBoolUser(self): - mbuTrue = MinBoolUser() - mbuFalse = MinBoolUser() - mbuTrue.setMinBool(True) - self.assertEqual(mbuFalse.minBool(), False) - self.assertEqual(mbuTrue.minBool(), True) - self.assertEqual(mbuTrue.callInvertedMinBool(), False) - - self.assertEqual(mbuTrue.minBool() == True, True) - self.assertEqual(False == mbuFalse.minBool(), True) - self.assertEqual(mbuTrue.minBool() == mbuFalse.minBool(), False) - - self.assertEqual(mbuFalse.minBool() != True, True) - self.assertEqual(True != mbuFalse.minBool(), True) - self.assertEqual(mbuTrue.minBool() != mbuFalse.minBool(), True) - - def testVirtuals(self): - dmbu = DerivedMinBoolUser() - self.assertEqual(dmbu.invertedMinBool(), True) - -if __name__ == '__main__': - unittest.main() - diff --git a/kcardgame/minimal-binding.txt.in b/kcardgame/minimal-binding.txt.in deleted file mode 100644 index 85b13967..00000000 --- a/kcardgame/minimal-binding.txt.in +++ /dev/null @@ -1,15 +0,0 @@ -[generator-project] - -generator-set = shiboken - -header-file = @CMAKE_CURRENT_SOURCE_DIR@/global.h -typesystem-file = @minimal_TYPESYSTEM@ - -output-directory = @CMAKE_CURRENT_BINARY_DIR@ - -include-path = @libminimal_SOURCE_DIR@ - -typesystem-path = @CMAKE_CURRENT_SOURCE_DIR@ - -enable-parent-ctor-heuristic -use-isnull-as-nb_nonzero diff --git a/kcardgame/typesystem_minimal.xml b/kcardgame/typesystem_minimal.xml deleted file mode 100644 index 968b27c5..00000000 --- a/kcardgame/typesystem_minimal.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - return PyBool_FromLong(%in.value()); - - - - %out = %OUTTYPE(%in == Py_True); - - - - - - - - - - PyObject* %out = PyList_New((int) %in.size()); - %INTYPE::const_iterator it = %in.begin(); - for (int idx = 0; it != %in.end(); ++it, ++idx) { - %INTYPE_0 cppItem(*it); - PyList_SET_ITEM(%out, idx, %CONVERTTOPYTHON[%INTYPE_0](cppItem)); - } - return %out; - - - - Shiboken::AutoDecRef seq(PySequence_Fast(%in, 0)); - for (int i = 0; i < PySequence_Fast_GET_SIZE(seq.object()); i++) { - PyObject* pyItem = PySequence_Fast_GET_ITEM(seq.object(), i); - %OUTTYPE_0 cppItem = %CONVERTTOCPP[%OUTTYPE_0](pyItem); - %out.push_back(cppItem); - } - - - - - - - - - - - - - - - - - %INTYPE::size_type vectorSize = %in.size(); - PyObject* %out = PyList_New((int) vectorSize); - for (%INTYPE::size_type idx = 0; idx < vectorSize; ++idx) { - %INTYPE_0 cppItem(%in[idx]); - PyList_SET_ITEM(%out, idx, %CONVERTTOPYTHON[%INTYPE_0](cppItem)); - } - return %out; - - - - Shiboken::AutoDecRef seq(PySequence_Fast(%in, 0)); - int vectorSize = PySequence_Fast_GET_SIZE(seq.object()); - %out.reserve(vectorSize); - for (int idx = 0; idx < vectorSize; ++idx ) { - PyObject* pyItem = PySequence_Fast_GET_ITEM(seq.object(), idx); - %OUTTYPE_0 cppItem = %CONVERTTOCPP[%OUTTYPE_0](pyItem); - %out.push_back(cppItem); - } - - - - - - - - - - - - - - - - - - - -