4679.3.62
by John Arbash Meinel
Move some of the information into the pxd header file. |
1 |
# Copyright (C) 2009 Canonical Ltd
|
2 |
#
|
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16 |
||
17 |
"""Interface definition of a class to intern StaticTuple objects."""
|
|
18 |
||
19 |
cdef extern from "python-compat.h": |
|
20 |
ctypedef long Py_ssize_t |
|
21 |
||
22 |
cdef extern from "Python.h": |
|
23 |
ctypedef struct PyObject: |
|
24 |
pass
|
|
25 |
||
26 |
cdef public api class StaticTupleInterner [object StaticTupleInternerObject, |
|
27 |
type StaticTupleInterner_type]: |
|
28 |
||
29 |
cdef readonly Py_ssize_t used # active |
|
30 |
cdef readonly Py_ssize_t fill # active + dummy |
|
31 |
cdef readonly Py_ssize_t mask # Table contains (mask+1) slots, a power |
|
32 |
# of 2
|
|
33 |
cdef PyObject **table # Pyrex/Cython doesn't support arrays to 'object' |
|
34 |
# so we manage it manually
|
|
35 |
||
36 |
cdef PyObject *_get(self, object key) except? NULL |
|
37 |
cpdef object add(self, key) |
|
38 |
cpdef int discard(self, key) except -1 |
|
4679.3.63
by John Arbash Meinel
Implement resizing. |
39 |
cdef int _insert_clean(self, PyObject *key) except -1 |
40 |
cpdef Py_ssize_t _resize(self, Py_ssize_t min_unused) except -1 |
|
4679.3.66
by John Arbash Meinel
Implement the C variant of __iter__ |
41 |
|
42 |
# TODO: might want to export the C api here, though it is all available from
|
|
43 |
# the class object...
|
|
44 |
cdef api object StaticTupleInterner_Add(object self, object key) |