Commit e5778e20 authored by Lisandro Dalcin's avatar Lisandro Dalcin

Python 3.2 now uses new C integral type Py_hash_t

parent 47f180f3
...@@ -366,7 +366,7 @@ builtin_function_table = [ ...@@ -366,7 +366,7 @@ builtin_function_table = [
BuiltinFunction('getattr3', "OOO", "O", "__Pyx_GetAttr3", "getattr", BuiltinFunction('getattr3', "OOO", "O", "__Pyx_GetAttr3", "getattr",
utility_code = getattr3_utility_code), # Pyrex compatibility utility_code = getattr3_utility_code), # Pyrex compatibility
BuiltinFunction('hasattr', "OO", "b", "PyObject_HasAttr"), BuiltinFunction('hasattr', "OO", "b", "PyObject_HasAttr"),
BuiltinFunction('hash', "O", "l", "PyObject_Hash"), BuiltinFunction('hash', "O", "h", "PyObject_Hash"),
#('hex', "", "", ""), #('hex', "", "", ""),
#('id', "", "", ""), #('id', "", "", ""),
#('input', "", "", ""), #('input', "", "", ""),
......
...@@ -610,6 +610,15 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -610,6 +610,15 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
#define PyBoolObject PyLongObject #define PyBoolObject PyLongObject
#endif #endif
#if PY_VERSION_HEX < 0x03020000
typedef long Py_hash_t;
#define __Pyx_PyInt_FromHash_t PyInt_FromLong
#define __Pyx_PyInt_AsHash_t PyInt_AsLong
#else
#define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
#define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
#endif
""") """)
code.put(""" code.put("""
......
...@@ -1056,6 +1056,14 @@ static CYTHON_INLINE Py_UNICODE __Pyx_PyObject_AsPy_UNICODE(PyObject* x) { ...@@ -1056,6 +1056,14 @@ static CYTHON_INLINE Py_UNICODE __Pyx_PyObject_AsPy_UNICODE(PyObject* x) {
''') ''')
class CPyHashTType(CIntType):
to_py_function = "__Pyx_PyInt_FromHash_t"
from_py_function = "__Pyx_PyInt_AsHash_t"
def sign_and_name(self):
return "Py_hash_t"
class CPySSizeTType(CIntType): class CPySSizeTType(CIntType):
to_py_function = "PyInt_FromSsize_t" to_py_function = "PyInt_FromSsize_t"
...@@ -2381,6 +2389,7 @@ c_returncode_type = CReturnCodeType(RANK_INT) ...@@ -2381,6 +2389,7 @@ c_returncode_type = CReturnCodeType(RANK_INT)
c_bint_type = CBIntType(RANK_INT) c_bint_type = CBIntType(RANK_INT)
c_py_unicode_type = CPyUnicodeIntType(RANK_INT-0.5, UNSIGNED) c_py_unicode_type = CPyUnicodeIntType(RANK_INT-0.5, UNSIGNED)
c_py_ucs4_type = CPyUCS4IntType(RANK_LONG-0.5, UNSIGNED) c_py_ucs4_type = CPyUCS4IntType(RANK_LONG-0.5, UNSIGNED)
c_py_hash_t_type = CPyHashTType(RANK_LONG+0.5, SIGNED)
c_py_ssize_t_type = CPySSizeTType(RANK_LONG+0.5, SIGNED) c_py_ssize_t_type = CPySSizeTType(RANK_LONG+0.5, SIGNED)
c_ssize_t_type = CSSizeTType(RANK_LONG+0.5, SIGNED) c_ssize_t_type = CSSizeTType(RANK_LONG+0.5, SIGNED)
c_size_t_type = CSizeTType(RANK_LONG+0.5, UNSIGNED) c_size_t_type = CSizeTType(RANK_LONG+0.5, UNSIGNED)
...@@ -2443,6 +2452,7 @@ modifiers_and_name_to_type = { ...@@ -2443,6 +2452,7 @@ modifiers_and_name_to_type = {
(1, 0, "bint"): c_bint_type, (1, 0, "bint"): c_bint_type,
(0, 0, "Py_UNICODE"): c_py_unicode_type, (0, 0, "Py_UNICODE"): c_py_unicode_type,
(0, 0, "Py_UCS4"): c_py_ucs4_type, (0, 0, "Py_UCS4"): c_py_ucs4_type,
(2, 0, "Py_hash_t"): c_py_hash_t_type,
(2, 0, "Py_ssize_t"): c_py_ssize_t_type, (2, 0, "Py_ssize_t"): c_py_ssize_t_type,
(2, 0, "ssize_t") : c_ssize_t_type, (2, 0, "ssize_t") : c_ssize_t_type,
(0, 0, "size_t") : c_size_t_type, (0, 0, "size_t") : c_size_t_type,
...@@ -2692,6 +2702,8 @@ def parse_basic_type(name): ...@@ -2692,6 +2702,8 @@ def parse_basic_type(name):
signed = 0 signed = 0
elif name == 'Py_UCS4': elif name == 'Py_UCS4':
signed = 0 signed = 0
elif name == 'Py_hash_t':
signed = 2
elif name == 'Py_ssize_t': elif name == 'Py_ssize_t':
signed = 2 signed = 2
elif name == 'ssize_t': elif name == 'ssize_t':
......
...@@ -32,6 +32,7 @@ class Signature(object): ...@@ -32,6 +32,7 @@ class Signature(object):
# 'b' bint # 'b' bint
# 'I' int * # 'I' int *
# 'l' long # 'l' long
# 'h' Py_hash_t
# 'z' Py_ssize_t # 'z' Py_ssize_t
# 'Z' Py_ssize_t * # 'Z' Py_ssize_t *
# 's' char * # 's' char *
...@@ -52,6 +53,7 @@ class Signature(object): ...@@ -52,6 +53,7 @@ class Signature(object):
'b': PyrexTypes.c_bint_type, 'b': PyrexTypes.c_bint_type,
'I': PyrexTypes.c_int_ptr_type, 'I': PyrexTypes.c_int_ptr_type,
'l': PyrexTypes.c_long_type, 'l': PyrexTypes.c_long_type,
'h': PyrexTypes.c_py_hash_t_type,
'z': PyrexTypes.c_py_ssize_t_type, 'z': PyrexTypes.c_py_ssize_t_type,
'Z': PyrexTypes.c_py_ssize_t_ptr_type, 'Z': PyrexTypes.c_py_ssize_t_ptr_type,
's': PyrexTypes.c_char_ptr_type, 's': PyrexTypes.c_char_ptr_type,
...@@ -69,6 +71,7 @@ class Signature(object): ...@@ -69,6 +71,7 @@ class Signature(object):
'b': "-1", 'b': "-1",
'l': "-1", 'l': "-1",
'r': "-1", 'r': "-1",
'h': "-1",
'z': "-1", 'z': "-1",
} }
...@@ -534,7 +537,7 @@ setattrofunc = Signature("TOO", 'r') # typedef int (*setattrofunc)(PyObjec ...@@ -534,7 +537,7 @@ setattrofunc = Signature("TOO", 'r') # typedef int (*setattrofunc)(PyObjec
delattrofunc = Signature("TO", 'r') delattrofunc = Signature("TO", 'r')
cmpfunc = Signature("TO", "i") # typedef int (*cmpfunc)(PyObject *, PyObject *); cmpfunc = Signature("TO", "i") # typedef int (*cmpfunc)(PyObject *, PyObject *);
reprfunc = Signature("T", "O") # typedef PyObject *(*reprfunc)(PyObject *); reprfunc = Signature("T", "O") # typedef PyObject *(*reprfunc)(PyObject *);
hashfunc = Signature("T", "l") # typedef long (*hashfunc)(PyObject *); hashfunc = Signature("T", "h") # typedef Py_hash_t (*hashfunc)(PyObject *);
# typedef PyObject *(*richcmpfunc) (PyObject *, PyObject *, int); # typedef PyObject *(*richcmpfunc) (PyObject *, PyObject *, int);
richcmpfunc = Signature("OOi", "O") # typedef PyObject *(*richcmpfunc) (PyObject *, PyObject *, int); richcmpfunc = Signature("OOi", "O") # typedef PyObject *(*richcmpfunc) (PyObject *, PyObject *, int);
getiterfunc = Signature("T", "O") # typedef PyObject *(*getiterfunc) (PyObject *); getiterfunc = Signature("T", "O") # typedef PyObject *(*getiterfunc) (PyObject *);
......
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