Krita Source Code Documentation
Loading...
Searching...
No Matches
PykritaModule.cpp
Go to the documentation of this file.
1// This file is part of PyKrita, Krita' Python scripting plugin.
2//
3// SPDX-FileCopyrightText: 2006 Paul Giannaros <paul@giannaros.org>
4// SPDX-FileCopyrightText: 2012, 2013 Shaheed Haque <srhaque@theiet.org>
5// SPDX-FileCopyrightText: 2013 Alex Turbov <i.zaufi@gmail.com>
6// SPDX-FileCopyrightText: 2021 L. E. Segovia <amy@amyspark.me>
7//
8// SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
9//
10
11#include "PykritaModule.h"
12
13#include "kis_debug.h"
14
16 PyObject *error;
17};
18
19#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
20
23namespace PYKRITA
24{
25 PyObject* debug(PyObject* /*self*/, PyObject* args)
26 {
27 const char* text;
28
29 if (PyArg_ParseTuple(args, "s", &text))
30 dbgScript << text;
31 Py_INCREF(Py_None);
32 return Py_None;
33 }
34
35 PyObject* qt_major_version(PyObject* /*self*/, PyObject* args)
36 {
37 Q_UNUSED(args);
38 return PyLong_FromLong(QT_VERSION_MAJOR);
39 }
40} // namespace PYKRITA
41
42namespace
43{
44 PyMethodDef pykritaMethods[] = {
45 {
46 "qDebug"
48 , METH_VARARGS
49 , "True KDE way to show debug info"
50 }
51 , {
52 "qt_major_version"
54 , METH_VARARGS
55 , "Qt major version number"
56 }
57 , { 0, 0, 0, 0 }
58 };
59} // anonymous namespace
60
61//BEGIN Python module registration
62static struct PyModuleDef moduledef = {
63 PyModuleDef_HEAD_INIT
64 , "pykrita"
65 , "The pykrita module"
66 , -1
67 , pykritaMethods
68 , 0
69 , 0
70 , 0
71 , 0
72};
73
74#define INITERROR return NULL
75
76PyMODINIT_FUNC PYKRITA_INIT()
77{
78 PyObject *pykritaModule = PyModule_Create(&moduledef);
79
80 if (pykritaModule == NULL)
82
83 PyModule_AddStringConstant(pykritaModule, "__file__", __FILE__);
84
85 return pykritaModule;
86}
87
88//END Python module registration
89
90// krita: space-indent on; indent-width 4;
91#undef PYKRITA_INIT
static struct PyModuleDef moduledef
#define INITERROR
PyMODINIT_FUNC PYKRITA_INIT()
#define dbgScript
Definition kis_debug.h:56
PyObject * qt_major_version(PyObject *, PyObject *args)
PyObject * debug(PyObject *, PyObject *args)
PyObject * error