1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
/*-----------------------------------------------------------------------------
| Copyright (c) 2013-2017, Nucleic Development Team.
|
| Distributed under the terms of the Modified BSD License.
|
| The full license is in the file COPYING.txt, distributed with this software.
|----------------------------------------------------------------------------*/
#include <Python.h>
#include <kiwi/kiwi.h>
#include "pythonhelpers.h"
#include "types.h"
#define PY_KIWI_VERSION "1.1.0"
using namespace PythonHelpers;
static PyMethodDef
kiwisolver_methods[] = {
{ 0 } // Sentinel
};
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef kiwisolver_moduledef = {
PyModuleDef_HEAD_INIT,
"kiwisolver",
NULL,
sizeof( struct module_state ),
kiwisolver_methods,
NULL
};
PyMODINIT_FUNC
PyInit_kiwisolver( void )
#else
PyMODINIT_FUNC
initkiwisolver( void )
#endif
{
#if PY_MAJOR_VERSION >= 3
PyObject *mod = PyModule_Create( &kiwisolver_moduledef );
#else
PyObject* mod = Py_InitModule( "kiwisolver", kiwisolver_methods );
#endif
if( !mod )
INITERROR;
if( import_variable() < 0 )
INITERROR;
if( import_term() < 0 )
INITERROR;
if( import_expression() < 0 )
INITERROR;
if( import_constraint() < 0 )
INITERROR;
if( import_solver() < 0 )
INITERROR;
if( import_strength() < 0 )
INITERROR;
PyObject* kiwiversion = FROM_STRING( KIWI_VERSION );
if( !kiwiversion )
INITERROR;
PyObject* pyversion = FROM_STRING( PY_KIWI_VERSION );
if( !pyversion )
INITERROR;
PyObject* pystrength = PyType_GenericNew( &strength_Type, 0, 0 );
if( !pystrength )
INITERROR;
PyModule_AddObject( mod, "__version__", pyversion );
PyModule_AddObject( mod, "__kiwi_version__", kiwiversion );
PyModule_AddObject( mod, "strength", pystrength );
PyModule_AddObject( mod, "Variable", newref( pyobject_cast( &Variable_Type ) ) );
PyModule_AddObject( mod, "Term", newref( pyobject_cast( &Term_Type ) ) );
PyModule_AddObject( mod, "Expression", newref( pyobject_cast( &Expression_Type ) ) );
PyModule_AddObject( mod, "Constraint", newref( pyobject_cast( &Constraint_Type ) ) );
PyModule_AddObject( mod, "Solver", newref( pyobject_cast( &Solver_Type ) ) );
PyModule_AddObject( mod, "DuplicateConstraint", newref( DuplicateConstraint ) );
PyModule_AddObject( mod, "UnsatisfiableConstraint", newref( UnsatisfiableConstraint ) );
PyModule_AddObject( mod, "UnknownConstraint", newref( UnknownConstraint ) );
PyModule_AddObject( mod, "DuplicateEditVariable", newref( DuplicateEditVariable ) );
PyModule_AddObject( mod, "UnknownEditVariable", newref( UnknownEditVariable ) );
PyModule_AddObject( mod, "BadRequiredStrength", newref( BadRequiredStrength ) );
#if PY_MAJOR_VERSION >= 3
return mod;
#endif
}
|