From 371c6c4af7b2a002c908b31add3f56ea0d6e1bb0 Mon Sep 17 00:00:00 2001 From: Hamed Gorjiara Date: Wed, 11 Apr 2018 13:08:22 -0700 Subject: [PATCH] Completing the python wrapper + editing the c APIs --- src/ccsolver.cc | 18 +++++++-------- src/ccsolver.h | 24 +++++++++---------- src/pycsolver.py | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 21 deletions(-) diff --git a/src/ccsolver.cc b/src/ccsolver.cc index 2535c7f..3d09bea 100644 --- a/src/ccsolver.cc +++ b/src/ccsolver.cc @@ -18,11 +18,11 @@ void *createRangeSet(void* solver,unsigned int type, long lowrange, long highran return CCSOLVER(solver)->createRangeSet((VarType) type, (uint64_t) lowrange, (uint64_t) highrange); } -void *createRangeVar(void* solver,unsigned type, long lowrange, long highrange){ +void *createRangeVar(void* solver,unsigned int type, long lowrange, long highrange){ return CCSOLVER(solver)->createRangeVar((VarType) type, (uint64_t) lowrange, (uint64_t) highrange); } -void *createMutableSet(void* solver,unsigned type){ +void *createMutableSet(void* solver,unsigned int type){ return CCSOLVER(solver)->createMutableSet((VarType) type); } @@ -38,7 +38,7 @@ void *getElementVar(void* solver,void *set){ return CCSOLVER(solver)->getElementVar((Set*) set); } -void *getElementConst(void* solver,unsigned type, long value){ +void *getElementConst(void* solver,unsigned int type, long value){ return CCSOLVER(solver)->getElementConst((VarType) type, (uint64_t) value); } @@ -50,7 +50,7 @@ void* getBooleanVar(void* solver,unsigned int type){ return CCSOLVER(solver)->getBooleanVar((VarType) type).getRaw(); } -void *createFunctionOperator(void* solver,unsigned int op, void *domain, unsigned int numDomain, void *range,unsigned int overflowbehavior){ +void *createFunctionOperator(void* solver,unsigned int op, void **domain, unsigned int numDomain, void *range,unsigned int overflowbehavior){ return CCSOLVER(solver)->createFunctionOperator((ArithOp) op, (Set **)domain, (uint) numDomain, (Set *)range, (OverFlowBehavior) overflowbehavior); } @@ -62,11 +62,11 @@ void *createPredicateTable(void* solver,void *table, unsigned int behavior){ return CCSOLVER(solver)->createPredicateTable((Table *)table, (UndefinedBehavior) behavior); } -void *createTable(void* solver,void*domains, unsigned int numDomain, void *range){ +void *createTable(void* solver,void**domains, unsigned int numDomain, void *range){ return CCSOLVER(solver)->createTable((Set **)domains, (uint) numDomain, (Set *)range); } -void *createTableForPredicate(void* solver,void*domains, unsigned int numDomain){ +void *createTableForPredicate(void* solver,void**domains, unsigned int numDomain){ return CCSOLVER(solver)->createTableForPredicate((Set **)domains, (uint) numDomain); } @@ -78,15 +78,15 @@ void *completeTable(void* solver,void *table, unsigned int behavior){ return CCSOLVER(solver)->completeTable((Table *) table, (UndefinedBehavior) behavior); } -void *applyFunction(void* solver,void *function, void*array, unsigned int numArrays, void* overflowstatus){ +void *applyFunction(void* solver,void *function, void**array, unsigned int numArrays, void* overflowstatus){ return CCSOLVER(solver)->applyFunction((Function *)function, (Element **)array, (uint) numArrays, BooleanEdge ((Boolean*)overflowstatus)); } -void* applyPredicateTable(void* solver,void *predicate, void *inputs, unsigned int numInputs, void* undefinedStatus){ +void* applyPredicateTable(void* solver,void *predicate, void **inputs, unsigned int numInputs, void* undefinedStatus){ return CCSOLVER(solver)->applyPredicateTable((Predicate *)predicate, (Element **)inputs, (uint) numInputs, BooleanEdge((Boolean*) undefinedStatus)).getRaw(); } -void* applyPredicate(void* solver,void *predicate, void *inputs, unsigned int numInputs){ +void* applyPredicate(void* solver,void *predicate, void **inputs, unsigned int numInputs){ return CCSOLVER(solver)->applyPredicate((Predicate *)predicate, (Element **)inputs, (uint) numInputs).getRaw(); } diff --git a/src/ccsolver.h b/src/ccsolver.h index 37f1183..e585855 100644 --- a/src/ccsolver.h +++ b/src/ccsolver.h @@ -10,33 +10,33 @@ void* createCCSolver(); void deleteCCSolver(void* solver); void *createSet(void* solver,unsigned int type, long *elements, unsigned int num); void *createRangeSet(void* solver,unsigned int type, long lowrange, long highrange); -void *createRangeVar(void* solver,unsigned type, long lowrange, long highrange); -void *createMutableSet(void* solver,unsigned type); +void *createRangeVar(void* solver,unsigned int type, long lowrange, long highrange); +void *createMutableSet(void* solver,unsigned int type); void addItem(void* solver,void *set, long element); void finalizeMutableSet(void* solver,void *set); void *getElementVar(void* solver,void *set); -void *getElementConst(void* solver,unsigned type, long value); +void *getElementConst(void* solver,unsigned int type, long value); void *getElementRange (void* solver,void *element); void* getBooleanVar(void* solver,unsigned int type); -void *createFunctionOperator(void* solver,unsigned int op, void *domain, unsigned int numDomain, void *range,unsigned int overflowbehavior); +void *createFunctionOperator(void* solver,unsigned int op, void **domain, unsigned int numDomain, void *range,unsigned int overflowbehavior); void *createPredicateOperator(void* solver,unsigned int op, void **domain, unsigned int numDomain); void *createPredicateTable(void* solver,void *table, unsigned int behavior); -void *createTable(void* solver,void*domains, unsigned int numDomain, void *range); -void *createTableForPredicate(void* solver,void*domains, unsigned int numDomain); +void *createTable(void* solver,void**domains, unsigned int numDomain, void *range); +void *createTableForPredicate(void* solver,void**domains, unsigned int numDomain); void addTableEntry(void* solver,void *table, void *inputs, unsigned int inputSize, long result); void *completeTable(void* solver,void *table, unsigned int behavior); -void *applyFunction(void* solver,void *function, void*array, unsigned int numArrays, long overflowstatus); -void* applyPredicateTable(void* solver,void *predicate, void *inputs, unsigned int numInputs, long undefinedStatus); -void* applyPredicate(void* solver,void *predicate, void *inputs, unsigned int numInputs); +void *applyFunction(void* solver,void *function, void**array, unsigned int numArrays, void* overflowstatus); +void* applyPredicateTable(void* solver,void *predicate, void **inputs, unsigned int numInputs, void* undefinedStatus); +void* applyPredicate(void* solver,void *predicate, void **inputs, unsigned int numInputs); void* applyLogicalOperation(void* solver,unsigned int op, void *array, unsigned int asize); -void* applyLogicalOperationTwo(void* solver,unsigned int op, long arg1, long arg2); -void* applyLogicalOperationOne(void* solver,unsigned int op, long arg); +void* applyLogicalOperationTwo(void* solver,unsigned int op, void* arg1, void* arg2); +void* applyLogicalOperationOne(void* solver,unsigned int op, void* arg); void addConstraint(void* solver,void* constraint); void *createOrder(void* solver,unsigned int type, void *set); void* orderConstraint(void* solver,void *order, long first, long second); int solve(void* solver); long getElementValue(void* solver,void *element); -int getBooleanValue(void* solver,long boolean); +int getBooleanValue(void* solver,void* boolean); int getOrderConstraintValue(void* solver,void *order, long first, long second); void printConstraints(void* solver); #ifdef __cplusplus diff --git a/src/pycsolver.py b/src/pycsolver.py index 0e7494c..e79905d 100644 --- a/src/pycsolver.py +++ b/src/pycsolver.py @@ -19,5 +19,65 @@ def loadCSolver(): csolverlb.getElementValue.restype = c_long csolverlb.deleteCCSolver.argtypes = [c_void_p] csolverlb.deleteCCSolver.restype = None + csolverlb.createRangeSet.argtypes = [c_void_p, c_uint, c_long, c_long] + csolverlb.createRangeSet.restype = c_void_p + csolverlb.createRangeVar.argtypes = [c_void_p, c_uint, c_long, c_long] + csolverlb.createRangeVar.restype = c_void_p + csolverlb.createMutableSet.argtypes = [c_void_p, c_uint] + csolverlb.createMutableSet.restype = c_void_p + csolverlb.addItem.argtypes = [c_void_p, c_void_p, c_long] + csolverlb.addItem.restype = None + csolverlb.finalizeMutableSet.argtypes = [c_void_p, c_void_p] + csolverlb.finalizeMutableSet.restype = None + csolverlb.getElementVar.argtypes = [c_void_p, c_void_p] + csolverlb.getElementVar.restype = c_void_p + csolverlb.getElementConst.argtypes = [c_void_p, c_uint, c_long] + csolverlb.getElementConst.restype = c_void_p + csolverlb.getElementRange.argtypes = [c_void_p, c_void_p] + csolverlb.getElementRange.restype = c_void_p + csolverlb.getBooleanVar.argtypes = [c_void_p, c_uint] + csolverlb.getBooleanVar.restype = c_void_p + csolverlb.createFunctionOperator.argtypes = [c_void_p, c_uint, POINTER(c_void_p), c_uint, c_void_p, c_uint] + csolverlb.createFunctionOperator.restype = c_void_p + csolverlb.createPredicateOperator.argtypes = [c_void_p, c_uint, POINTER(c_void_p), c_uint] + csolverlb.createPredicateOperator.restype = c_void_p + csolverlb.createPredicateTable.argtypes = [c_void_p, c_void_p, c_uint] + csolverlb.createPredicateTable.restype = c_void_p + csolverlb.createTable.argtypes = [c_void_p, POINTER(c_void_p), c_uint, c_void_p] + csolverlb.createTable.restype = c_void_p + csolverlb.createTableForPredicate.argtypes = [c_void_p, POINTER(c_void_p), c_uint] + csolverlb.createTableForPredicate.restype = c_void_p + csolverlb.addTableEntry.argtypes = [c_void_p, c_void_p, c_void_p, c_uint, c_long] + csolverlb.addTableEntry.restype = None + csolverlb.completeTable.argtypes = [c_void_p, c_void_p, c_uint] + csolverlb.completeTable.restype = c_void_p + csolverlb.applyFunction.argtypes = [c_void_p, c_void_p, POINTER(c_void_p), c_uint, c_void_p] + csolverlb.applyFunction.restype = c_void_p + csolverlb.applyPredicateTable.argtypes = [c_void_p, c_void_p, POINTER(c_void_p), c_uint, c_void_p] + csolverlb.applyPredicateTable.restype = c_void_p + csolverlb.applyPredicate.argtypes = [c_void_p, c_void_p, POINTER(c_void_p), c_uint] + csolverlb.applyPredicate.restype = c_void_p + csolverlb.applyLogicalOperation.argtypes = [c_void_p, c_uint, c_void_p, c_uint] + csolverlb.applyLogicalOperation.restype = c_void_p + csolverlb.applyLogicalOperationTwo.argtypes = [c_void_p, c_uint, c_void_p, c_void_p] + csolverlb.applyLogicalOperationTwo.restype = c_void_p + csolverlb.applyLogicalOperationOne.argtypes = [c_void_p, c_uint, c_void_p] + csolverlb.applyLogicalOperationOne.restype = c_void_p + csolverlb.addConstraint.argtypes = [c_void_p, c_void_p] + csolverlb.addConstraint.restype = None + csolverlb.createOrder.argtypes = [c_void_p, c_uint, c_void_p] + csolverlb.createOrder.restype = c_void_p + csolverlb.orderConstraint.argtypes = [c_void_p, c_void_p, c_long, c_long] + csolverlb.orderConstraint.restype = c_void_p + csolverlb.solve.argtypes = [c_void_p] + csolverlb.solve.restype = c_int + csolverlb.getElementValue.argtypes = [c_void_p, c_void_p] + csolverlb.getElementValue.restype = c_long + csolverlb.getBooleanValue.argtypes = [c_void_p, c_void_p] + csolverlb.getBooleanValue.restype = c_int + csolverlb.getOrderConstraintValue.argtypes = [c_void_p, c_void_p, c_long, c_long] + csolverlb.getOrderConstraintValue.restype = c_int + csolverlb.printConstraints.argtypes = [c_void_p] + csolverlb.printConstraints.restype = None return csolverlb -- 2.34.1