Changeset View
Changeset View
Standalone View
Standalone View
plugins/extensions/pykrita/plugin/utilities.h
Context not available. | |||||
34 | /// Save us some ruddy time when printing out QStrings with UTF-8 | 34 | /// Save us some ruddy time when printing out QStrings with UTF-8 | ||
---|---|---|---|---|---|
35 | # define PQ(x) x.toUtf8().constData() | 35 | # define PQ(x) x.toUtf8().constData() | ||
36 | 36 | | |||
37 | class PythonPluginManager; | ||||
38 | | ||||
37 | namespace PyKrita | 39 | namespace PyKrita | ||
38 | { | 40 | { | ||
41 | enum InitResult { | ||||
42 | INIT_UNINITIALIZED, | ||||
43 | INIT_OK, | ||||
44 | INIT_CANNOT_LOAD_PYTHON_LIBRARY, | ||||
45 | INIT_CANNOT_SET_PYTHON_PATHS, | ||||
46 | INIT_CANNOT_LOAD_PYKRITA_MODULE, | ||||
47 | }; | ||||
48 | | ||||
49 | /** | ||||
50 | * Initialize the Python environment and plugin manager. | ||||
51 | * This should be called first before using the manager | ||||
52 | * or the Python class. | ||||
53 | */ | ||||
54 | InitResult initialize(); | ||||
55 | | ||||
56 | /** | ||||
57 | * Gets the instance of the plugin manager. | ||||
58 | * Note: PyKrita::initialize() must be called | ||||
59 | * before using this function. | ||||
60 | */ | ||||
61 | PythonPluginManager *pluginManager(); | ||||
62 | | ||||
63 | /** | ||||
64 | * Cleanup after Python. | ||||
65 | * Note: doing this as part of static/global destruction will not | ||||
66 | * work. The call to Py_Finalize() would happen after the Python | ||||
67 | * runtime has already been finalized, leading to a segfault. | ||||
68 | */ | ||||
69 | void finalize(); | ||||
39 | 70 | | |||
40 | /** | 71 | /** | ||
41 | * Instantiate this class on the stack to automatically get and release the | 72 | * Instantiate this class on the stack to automatically get and release the | ||
Context not available. | |||||
115 | QString lastTraceback(void) const; | 146 | QString lastTraceback(void) const; | ||
116 | 147 | | |||
117 | /** | 148 | /** | ||
118 | * Create a Python dictionary from a KConfigBase instance, writing the | | |||
119 | * string representation of the values. | | |||
120 | */ | | |||
121 | void updateDictionaryFromConfiguration(PyObject* dictionary, const KConfigBase* config); | | |||
122 | | ||||
123 | /** | | |||
124 | * Write a Python dictionary to a configuration object, converting objects | | |||
125 | * to their string representation along the way. | | |||
126 | */ | | |||
127 | void updateConfigurationFromDictionary(KConfigBase* config, PyObject* dictionary); | | |||
128 | | ||||
129 | /** | | |||
130 | * Call the named module's named entry point. | 149 | * Call the named module's named entry point. | ||
131 | */ | 150 | */ | ||
132 | bool functionCall(const char* functionName, const char* moduleName = PYKRITA_ENGINE); | 151 | bool functionCall(const char* functionName, const char* moduleName = PYKRITA_ENGINE); | ||
Context not available. |