Commit 3bd45ec2 authored by Robert Bradshaw's avatar Robert Bradshaw

arrayarray utility code hack

parent c2101ebc
......@@ -6390,6 +6390,10 @@ class CImportStatNode(StatNode):
else:
name = self.as_name or self.module_name
env.declare_module(name, module_scope, self.pos)
if self.module_name == "cpython.array":
# TODO: Consider a generic user-level mechanism for importing
# utility code (or inlining c) in a pxd (or pyx) file.
env.use_utility_code(UtilityCode.load("ArrayAPI", "arrayarray.h"))
def analyse_expressions(self, env):
pass
......@@ -6440,6 +6444,12 @@ class FromCImportStatNode(StatNode):
if entry:
local_name = as_name or name
env.add_imported_entry(local_name, entry, pos)
if self.module_name == "cpython":
# TODO: Consider a generic user-level mechanism for importing
# utility code (or inlining c) in a pxd (or pyx) file.
for _, name, _, _ in self.imported_names:
if name == "array":
env.use_utility_code(UtilityCode.load("ArrayAPI", "arrayarray.h"))
def declaration_matches(self, entry, kind):
if not entry.is_type:
......
......@@ -41,14 +41,10 @@
mem.leaks; seamless Python compatibility, buffer() optional
IMPORTANT: arrayarray.h (arrayobject, arraydescr) is not part of
the official Python C-API so far; arrayarray.h is located
next to this file copy it to PythonXX/include or local or
somewhere on your -I path
last changes: 2009-05-15 rk
: 2009-12-06 bp
: 2012-05-02 andreasvc
: (see revision control)
"""
from libc cimport stdlib
from libc.string cimport strcat, strncat, \
......@@ -57,7 +53,7 @@ from libc.string cimport strcat, strncat, \
from cpython.ref cimport PyTypeObject
from cpython.exc cimport PyErr_BadArgument
cdef extern from "arrayarray.h":
cdef extern from *: # Hard-coded utility code hack.
ctypedef class array.array [object arrayobject]
ctypedef object GETF(array a, Py_ssize_t ix)
ctypedef object SETF(array a, Py_ssize_t ix, object o)
......
/////////////// ArrayAPI.proto ///////////////
/* arrayarray.h
artificial C-API for Python's
<array.array> type.
copy this file to your -I path, e.g. .../pythonXX/include
See array.pxd next to this file
Artificial C-API for Python's <array.array> type,
used by array.pxd
last changes: 2009-05-15 rk
2012-05-02 andreasvc
(see revision control)
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment