edits
[satune.git] / src / pycsolver.py
1 from ctypes import *
2
3 class LogicOps:
4         SATC_AND=0
5         SATC_OR=1
6         SATC_NOT=2
7         SATC_XOR=3
8         SATC_IFF=4
9         SATC_IMPLIES=5
10
11 class CompOp:
12         SATC_EQUALS = 0
13         SATC_LT=1
14         SATC_GT=2
15         SATC_LTE=3
16         SATC_GTE=4
17
18 class ArithOp:
19     SATC_ADD=0
20     SATC_SUB=1
21
22 class OverFlowBehavior:
23     SATC_IGNORE=0
24     SATC_WRAPAROUND=1
25     SATC_FLAGFORCESOVERFLOW=2
26     SATC_OVERFLOWSETSFLAG=3
27     SATC_FLAGIFFOVERFLOW=4
28     SATC_NOOVERFLOW=5
29
30
31 def loadCSolver():
32         csolverlb = cdll.LoadLibrary("lib_cons_comp.so")
33         csolverlb.createCCSolver.restype = c_void_p
34         csolverlb.createSet.argtypes = [c_void_p, c_uint, POINTER(c_long), c_uint]
35         csolverlb.createSet.restype = c_void_p
36         csolverlb.getElementVar.argtypes = [c_void_p, c_void_p]
37         csolverlb.getElementVar.restype = c_void_p
38         csolverlb.createPredicateOperator.argtypes = [c_void_p, c_uint, POINTER(c_void_p), c_uint]
39         csolverlb.createPredicateOperator.restype = c_void_p
40         csolverlb.applyPredicate.argtypes = [c_void_p, c_void_p, POINTER(c_void_p), c_uint]
41         csolverlb.applyPredicate.restype = c_void_p
42         csolverlb.addConstraint.argtypes = [c_void_p, c_void_p]
43         csolverlb.addConstraint.restype = None
44         csolverlb.solve.argtypes = [c_void_p]
45         csolverlb.solve.restype = c_int
46         csolverlb.getElementValue.argtypes = [c_void_p, c_void_p]
47         csolverlb.getElementValue.restype = c_long
48         csolverlb.deleteCCSolver.argtypes = [c_void_p]
49         csolverlb.deleteCCSolver.restype = None
50         csolverlb.createRangeSet.argtypes = [c_void_p, c_uint, c_long, c_long]
51         csolverlb.createRangeSet.restype = c_void_p
52         csolverlb.createRangeVar.argtypes = [c_void_p, c_uint, c_long, c_long]
53         csolverlb.createRangeVar.restype = c_void_p
54         csolverlb.createMutableSet.argtypes = [c_void_p, c_uint]
55         csolverlb.createMutableSet.restype = c_void_p
56         csolverlb.addItem.argtypes = [c_void_p, c_void_p, c_long]
57         csolverlb.addItem.restype = None
58         csolverlb.finalizeMutableSet.argtypes = [c_void_p, c_void_p]
59         csolverlb.finalizeMutableSet.restype = None
60         csolverlb.getElementVar.argtypes = [c_void_p, c_void_p]
61         csolverlb.getElementVar.restype = c_void_p
62         csolverlb.getElementConst.argtypes = [c_void_p, c_uint, c_long]
63         csolverlb.getElementConst.restype = c_void_p
64         csolverlb.getElementRange.argtypes = [c_void_p, c_void_p]
65         csolverlb.getElementRange.restype = c_void_p
66         csolverlb.getBooleanVar.argtypes = [c_void_p, c_uint]
67         csolverlb.getBooleanVar.restype = c_void_p
68         csolverlb.createFunctionOperator.argtypes = [c_void_p, c_uint, POINTER(c_void_p), c_uint, c_void_p, c_uint]
69         csolverlb.createFunctionOperator.restype = c_void_p
70         csolverlb.createPredicateOperator.argtypes = [c_void_p, c_uint, POINTER(c_void_p), c_uint]
71         csolverlb.createPredicateOperator.restype = c_void_p
72         csolverlb.createPredicateTable.argtypes = [c_void_p, c_void_p, c_uint]
73         csolverlb.createPredicateTable.restype = c_void_p
74         csolverlb.createTable.argtypes = [c_void_p, POINTER(c_void_p), c_uint, c_void_p]
75         csolverlb.createTable.restype = c_void_p
76         csolverlb.createTableForPredicate.argtypes = [c_void_p, POINTER(c_void_p), c_uint]
77         csolverlb.createTableForPredicate.restype = c_void_p
78         csolverlb.addTableEntry.argtypes = [c_void_p, c_void_p, c_void_p, c_uint, c_long]
79         csolverlb.addTableEntry.restype = None
80         csolverlb.completeTable.argtypes = [c_void_p, c_void_p, c_uint]
81         csolverlb.completeTable.restype = c_void_p
82         csolverlb.applyFunction.argtypes = [c_void_p, c_void_p, POINTER(c_void_p), c_uint, c_void_p]
83         csolverlb.applyFunction.restype = c_void_p
84         csolverlb.applyPredicateTable.argtypes = [c_void_p, c_void_p, POINTER(c_void_p), c_uint, c_void_p]
85         csolverlb.applyPredicateTable.restype = c_void_p
86         csolverlb.applyPredicate.argtypes = [c_void_p, c_void_p, POINTER(c_void_p), c_uint]
87         csolverlb.applyPredicate.restype = c_void_p
88         csolverlb.applyLogicalOperation.argtypes = [c_void_p, c_uint, c_void_p, c_uint]
89         csolverlb.applyLogicalOperation.restype = c_void_p
90         csolverlb.applyLogicalOperationTwo.argtypes = [c_void_p, c_uint, c_void_p, c_void_p]
91         csolverlb.applyLogicalOperationTwo.restype = c_void_p
92         csolverlb.applyLogicalOperationOne.argtypes = [c_void_p, c_uint, c_void_p]
93         csolverlb.applyLogicalOperationOne.restype = c_void_p
94         csolverlb.addConstraint.argtypes = [c_void_p, c_void_p]
95         csolverlb.addConstraint.restype = None
96         csolverlb.createOrder.argtypes = [c_void_p, c_uint, c_void_p]
97         csolverlb.createOrder.restype = c_void_p
98         csolverlb.orderConstraint.argtypes = [c_void_p, c_void_p, c_long, c_long]
99         csolverlb.orderConstraint.restype = c_void_p
100         csolverlb.solve.argtypes = [c_void_p]
101         csolverlb.solve.restype = c_int
102         csolverlb.getElementValue.argtypes = [c_void_p, c_void_p]
103         csolverlb.getElementValue.restype = c_long
104         csolverlb.getBooleanValue.argtypes = [c_void_p, c_void_p]
105         csolverlb.getBooleanValue.restype = c_int
106         csolverlb.getOrderConstraintValue.argtypes = [c_void_p, c_void_p, c_long, c_long]
107         csolverlb.getOrderConstraintValue.restype = c_int
108         csolverlb.printConstraints.argtypes = [c_void_p]
109         csolverlb.printConstraints.restype = None
110         csolverlb.serialize.argtypes = [c_void_p]
111         csolverlb.serialize.restype = None
112         return csolverlb
113