| 1 | """ |
|---|
| 2 | Standard SAGE Pyrex Helper Code |
|---|
| 3 | """ |
|---|
| 4 | |
|---|
| 5 | ################################################################################ |
|---|
| 6 | # stdsage.pxi |
|---|
| 7 | # Standard useful stuff for SAGE modules to include: |
|---|
| 8 | # See stdsage.h for macros and stdsage.c for C functions. |
|---|
| 9 | # |
|---|
| 10 | # Each module currently gets its own copy of this, which is why |
|---|
| 11 | # we call the initialization code below. |
|---|
| 12 | # |
|---|
| 13 | ################################################################################ |
|---|
| 14 | |
|---|
| 15 | ############################################################################### |
|---|
| 16 | # SAGE: System for Algebra and Geometry Experimentation |
|---|
| 17 | # Copyright (C) 2005, 2006 William Stein <wstein@gmail.com> |
|---|
| 18 | # Distributed under the terms of the GNU General Public License (GPL) |
|---|
| 19 | # The full text of the GPL is available at: |
|---|
| 20 | # http://www.gnu.org/licenses/ |
|---|
| 21 | ############################################################################### |
|---|
| 22 | |
|---|
| 23 | cdef extern from "stdsage.h": |
|---|
| 24 | ctypedef void PyObject |
|---|
| 25 | |
|---|
| 26 | # Global tuple -- useful optimization |
|---|
| 27 | void init_global_empty_tuple() |
|---|
| 28 | object PY_NEW(object t) |
|---|
| 29 | void* PY_TYPE(object o) |
|---|
| 30 | bint PY_TYPE_CHECK(object o, object t) |
|---|
| 31 | object IS_INSTANCE(object o, object t) |
|---|
| 32 | void PY_SET_TP_NEW(object t1, object t2) |
|---|
| 33 | bint HAS_DICTIONARY(object o) |
|---|
| 34 | bint PY_IS_NUMERIC(object o) |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | # Memory management |
|---|
| 38 | cdef extern from "stdlib.h": |
|---|
| 39 | ctypedef unsigned long size_t |
|---|
| 40 | |
|---|
| 41 | cdef extern from "stdsage.h": |
|---|
| 42 | void sage_free(void *p) |
|---|
| 43 | void* sage_realloc(void *p, size_t n) |
|---|
| 44 | void* sage_malloc(size_t) |
|---|
| 45 | void init_csage() |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | # Do this for every single module that links in stdsage. |
|---|
| 49 | # This is necessary on some platforms, e.g., Cygwin, so |
|---|
| 50 | # do not delete it! |
|---|
| 51 | init_csage() |
|---|
| 52 | |
|---|