1 from Symtab import ModuleScope
2 from PyrexTypes import *
4 shape_func_type = CFuncType(
5 c_ptr_type(c_py_ssize_t_type),
6 [CFuncTypeArg("buffer", py_object_type, None)])
8 class CythonScope(ModuleScope):
9 def __init__(self, context):
10 ModuleScope.__init__(self, u'cython', None, context)
11 self.pxd_file_loaded = True
13 self.shape_entry = self.declare_cfunction('shape',
19 def lookup_type(self, name):
20 # This function should go away when types are all first-level objects.
21 type = parse_basic_type(name)
25 def create_cython_scope(context):
26 create_utility_scope(context)
27 return CythonScope(context)
30 def create_utility_scope(context):
32 utility_scope = ModuleScope(u'utility', None, context)
34 # These are used to optimize isinstance in FinalOptimizePhase
35 type_object = utility_scope.declare_typedef('PyTypeObject',
36 base_type = c_void_type,
38 cname = 'PyTypeObject')
39 type_object.is_void = True
41 utility_scope.declare_cfunction(
43 CFuncType(c_bint_type, [CFuncTypeArg("o", py_object_type, None),
44 CFuncTypeArg("t", c_ptr_type(type_object), None)]),
47 cname = 'PyObject_TypeCheck')