|  | 
|  | 1 | +# distutils: language = c++ | 
|  | 2 | + | 
|  | 3 | +from libcpp.string cimport string | 
|  | 4 | +from sage.libs.gmp.types cimport mpz_t, mpq_t | 
|  | 5 | + | 
|  | 6 | +cdef extern from "wrap.h" namespace "polymake": | 
|  | 7 | +    pass | 
|  | 8 | + | 
|  | 9 | +cdef extern from "polymake/Main.h" namespace "polymake": | 
|  | 10 | +    cdef cppclass Main: | 
|  | 11 | +        Main(char*) | 
|  | 12 | +        void set_application(char*) | 
|  | 13 | +        void set_preference(char*) | 
|  | 14 | +        void set_custom(char*, int) except +ValueError | 
|  | 15 | + | 
|  | 16 | +cdef extern from "polymake/Main.h": | 
|  | 17 | +    cdef cppclass PropertyValue: | 
|  | 18 | +        pass | 
|  | 19 | + | 
|  | 20 | + | 
|  | 21 | +cdef extern from "polymake/Rational.h" namespace 'polymake': | 
|  | 22 | +    cdef cppclass Integer: | 
|  | 23 | +        mpz_t get_rep() | 
|  | 24 | +        Py_ssize_t strsize(int) | 
|  | 25 | +        int compare(int) | 
|  | 26 | + | 
|  | 27 | +    cdef cppclass Rational: | 
|  | 28 | +        Rational() | 
|  | 29 | +        Rational(mpq_t) | 
|  | 30 | +        mpq_t get_rep() | 
|  | 31 | +        Rational set(mpq_t) | 
|  | 32 | + | 
|  | 33 | +cdef extern from "polymake/client.h": | 
|  | 34 | +    cdef extern PerlObject load "perl::Object::load" (char*) except + | 
|  | 35 | +    cdef cppclass PerlObject "perl::Object": | 
|  | 36 | +        PerlObject() | 
|  | 37 | +        PerlObject(char*) except +ValueError | 
|  | 38 | +        void VoidCallPolymakeMethod(char*) except +ValueError | 
|  | 39 | +        void save(char*) | 
|  | 40 | +        PropertyValue take(char*) | 
|  | 41 | +        PropertyValue give(char*) # do not add except here, see pm_get for why | 
|  | 42 | + | 
|  | 43 | +    PerlObject CallPolymakeFunction (char*) except +ValueError | 
|  | 44 | +    PerlObject CallPolymakeFunction1 "CallPolymakeFunction" \ | 
|  | 45 | +            (char*, int) except +ValueError | 
|  | 46 | +    PerlObject CallPolymakeFunction2 "CallPolymakeFunction" \ | 
|  | 47 | +            (char*, int, int) except +ValueError | 
|  | 48 | +    PerlObject CallPolymakeFunction3 "CallPolymakeFunction" \ | 
|  | 49 | +            (char*, int, int, int) except +ValueError | 
|  | 50 | +    PerlObject* new_PerlObject_from_PerlObject "new perl::Object" (PerlObject) | 
|  | 51 | +    PerlObject CallPolymakeFunction_PerlObject2 "CallPolymakeFunction" (char*, PerlObject, PerlObject) except +ValueError | 
|  | 52 | +    bint BoolCallPolymakeFunction_PerlObject2 "CallPolymakeFunction" (char*, PerlObject, PerlObject) except +ValueError | 
|  | 53 | + | 
|  | 54 | +cdef extern from "polymake/SparseMatrix.h" namespace "polymake": | 
|  | 55 | +    pass | 
|  | 56 | + | 
|  | 57 | +cdef extern from "polymake/Matrix.h" namespace 'polymake': | 
|  | 58 | +    cdef cppclass MatrixRational "Matrix<Rational>": | 
|  | 59 | +        MatrixRational() | 
|  | 60 | +        MatrixRational(int nr, int nc) | 
|  | 61 | +        void assign(int r, int c, Rational val) | 
|  | 62 | +        MatrixRational operator|(MatrixRational) | 
|  | 63 | +        Py_ssize_t rows() | 
|  | 64 | +        Py_ssize_t cols() | 
|  | 65 | + | 
|  | 66 | +    Rational get_element "WRAP_CALL"(MatrixRational, int i, int j) | 
|  | 67 | + | 
|  | 68 | +#cdef extern from "polymake/GenericVector.h" namespace 'polymake': | 
|  | 69 | +    MatrixRational ones_vector_Rational "ones_vector<Rational>" () | 
|  | 70 | + | 
|  | 71 | +#cdef extern from "polymake/GenericMatrix.h" namespace 'polymake': | 
|  | 72 | +    MatrixRational unit_matrix_Rational "unit_matrix<Rational>" (int dim) | 
|  | 73 | + | 
|  | 74 | + | 
|  | 75 | +    void pm_assign "WRAP_OUT" (PropertyValue, MatrixRational) | 
|  | 76 | + | 
|  | 77 | +    # the except clause below is fake | 
|  | 78 | +    # it is used to catch errors in PerlObject.give(), however adding | 
|  | 79 | +    # the except statement to the declaration of give() makes cython | 
|  | 80 | +    # split lines like | 
|  | 81 | +    #        pm_get(self.pm_obj.give(prop), pm_res) | 
|  | 82 | +    # and store the result of give() first. This causes problems since | 
|  | 83 | +    # PropertyValue doesn't have a default constructor. | 
|  | 84 | +    void pm_get "WRAP_IN" (PropertyValue, Integer) except +ValueError | 
|  | 85 | +    void pm_get_String "WRAP_IN" (PropertyValue, string) except +ValueError | 
|  | 86 | +    void pm_get_Rational "WRAP_IN" (PropertyValue, Rational) except +ValueError | 
|  | 87 | +    void pm_get_MatrixRational "WRAP_IN" (PropertyValue, MatrixRational) \ | 
|  | 88 | +            except +ValueError | 
|  | 89 | +    void pm_get_VectorInteger "WRAP_IN" (PropertyValue, VectorInteger) \ | 
|  | 90 | +            except +ValueError | 
|  | 91 | +    void pm_get_PerlObject "WRAP_IN" (PropertyValue, PerlObject) \ | 
|  | 92 | +            except +ValueError | 
|  | 93 | + | 
|  | 94 | +cdef extern from "polymake/Vector.h" namespace 'polymake': | 
|  | 95 | +    cdef cppclass VectorInteger "Vector<Integer>": | 
|  | 96 | +        VectorInteger() | 
|  | 97 | +        VectorInteger(int nr) | 
|  | 98 | +        #void assign(int r, int val) | 
|  | 99 | +        Integer get "operator[]" (int i) | 
|  | 100 | +        int size() | 
0 commit comments