File: Python.pxi

package info (click to toggle)
python-enable 4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 7,220 kB
  • sloc: cpp: 57,417; python: 28,437; makefile: 314; sh: 43
file content (50 lines) | stat: -rw-r--r-- 1,522 bytes parent folder | download | duplicates (2)
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
# :Author:    Robert Kern
# :Copyright: 2004, Enthought, Inc.
# :License:   BSD Style

ctypedef void (*cobject_destr)(void *)

cdef extern from "Python.h":
    ctypedef int size_t
    ctypedef int Py_ssize_t
    char* PyString_AsString(object string)
    object PyString_FromString(char* c_string)
    object PyString_FromStringAndSize(char* v, Py_ssize_t len)
    int PyString_AsStringAndSize(object obj, char **buffer, Py_ssize_t *length)
    int PyObject_AsCharBuffer(object obj, char **buffer, Py_ssize_t *buffer_len)
    int PyObject_AsReadBuffer(object obj, void **buffer, Py_ssize_t *buffer_len)
    int PyObject_CheckReadBuffer(object o)
    int PyObject_AsWriteBuffer(object obj, void **buffer, Py_ssize_t *buffer_len)

    void* PyMem_Malloc(size_t n)
    void* PyMem_Realloc(void* buf, size_t n)
    void PyMem_Free(void* buf)

    void Py_DECREF(object obj)
    void Py_XDECREF(object obj)
    void Py_INCREF(object obj)
    void Py_XINCREF(object obj)

    int PyUnicode_Check(ob)
    int PyString_Check(ob)

    ctypedef int Py_UNICODE
    Py_UNICODE *PyUnicode_AS_UNICODE(ob)
    int PyUnicode_GET_SIZE(ob)
    char *PyString_AS_STRING(ob)


    object PyCObject_FromVoidPtr(void* cobj, cobject_destr destr)
    void* PyCObject_AsVoidPtr(object self)

cdef extern from "string.h":
    void *memcpy(void *s1, void *s2, int n)

cdef extern from "math.h":
    double fabs(double x)

cdef extern from "stdlib.h":
    void free(void *ptr)
    void *malloc(size_t size)
    void *realloc(void *ptr, size_t size)