Esempio n. 1
0
    def __init__(self, context):
        ModuleScope.__init__(self, u'cython', None, context)
        self.pxd_file_loaded = True

        self.shape_entry = self.declare_cfunction('shape',
                                                  shape_func_type,
                                                  pos=None,
                                                  defining=1,
                                                  cname='<error>')
Esempio n. 2
0
    def __init__(self, context):
        ModuleScope.__init__(self, u'cython', None, context)
        self.pxd_file_loaded = True

        self.shape_entry = self.declare_cfunction('shape',
                                                  shape_func_type,
                                                  pos=None,
                                                  defining = 1,
                                                  cname='<error>')
Esempio n. 3
0
    def __init__(self, context):
        ModuleScope.__init__(self, u"cython", None, None)
        self.pxd_file_loaded = True
        self.populate_cython_scope()
        # The Main.Context object
        self.context = context

        for fused_type in (cy_integral_type, cy_floating_type, cy_numeric_type):
            entry = self.declare_typedef(fused_type.name, fused_type, None, cname="<error>")
            entry.in_cinclude = True
Esempio n. 4
0
    def __init__(self, context):
        ModuleScope.__init__(self, u'cython', None, None)
        self.pxd_file_loaded = True
        self.populate_cython_scope()
        # The Main.Context object
        self.context = context

        for fused_type in (cy_integral_type, cy_floating_type,
                           cy_numeric_type):
            entry = self.declare_typedef(fused_type.name,
                                         fused_type,
                                         None,
                                         cname='<error>')
            entry.in_cinclude = True
Esempio n. 5
0
    def load_cythonscope(self):
        """
        Creates some entries for testing purposes and entries for
        cython.array() and for cython.view.*.
        """
        if self._cythonscope_initialized:
            return

        self._cythonscope_initialized = True
        cython_testscope_utility_code.declare_in_scope(self, cython_scope=self)
        cython_test_extclass_utility_code.declare_in_scope(self,
                                                           cython_scope=self)

        #
        # The view sub-scope
        #
        self.viewscope = viewscope = ModuleScope(u'view', self, None)
        self.declare_module('view', viewscope, None).as_module = viewscope
        viewscope.is_cython_builtin = True
        viewscope.pxd_file_loaded = True

        cythonview_testscope_utility_code.declare_in_scope(viewscope,
                                                           cython_scope=self)

        view_utility_scope = MemoryView.view_utility_code.declare_in_scope(
            self.viewscope,
            cython_scope=self,
            whitelist=MemoryView.view_utility_whitelist)
Esempio n. 6
0
 def find_submodule(self, name):
     # Find a top-level module, creating a new one if needed.
     scope = self.lookup_submodule(name)
     if not scope:
         scope = ModuleScope(name, parent_module=None, context=self)
         self.modules[name] = scope
     return scope
Esempio n. 7
0
def create_utility_scope(context):
    global utility_scope
    utility_scope = ModuleScope(u'utility', None, context)

    # These are used to optimize isinstance in FinalOptimizePhase
    type_object = utility_scope.declare_typedef('PyTypeObject', 
                                                base_type = c_void_type, 
                                                pos = None,
                                                cname = 'PyTypeObject')
    type_object.is_void = True
    
    utility_scope.declare_cfunction(
                'PyObject_TypeCheck',
                CFuncType(c_bint_type, [CFuncTypeArg("o", py_object_type, None),
                                        CFuncTypeArg("t", c_ptr_type(type_object), None)]),
                pos = None,
                defining = 1,
                cname = 'PyObject_TypeCheck')
    
    return utility_scope
Esempio n. 8
0
def create_utility_scope(context):
    global utility_scope
    utility_scope = ModuleScope(u'utility', None, context)

    # These are used to optimize isinstance in FinalOptimizePhase
    type_object = utility_scope.declare_typedef('PyTypeObject',
                                                base_type = c_void_type,
                                                pos = None,
                                                cname = 'PyTypeObject')
    type_object.is_void = True

    utility_scope.declare_cfunction(
                'PyObject_TypeCheck',
                CFuncType(c_bint_type, [CFuncTypeArg("o", py_object_type, None),
                                        CFuncTypeArg("t", c_ptr_type(type_object), None)]),
                pos = None,
                defining = 1,
                cname = 'PyObject_TypeCheck')

    return utility_scope
Esempio n. 9
0
    def test_cythonscope(self):
        # A special function just to make it easy to test the scope and
        # utility code functionality in isolation. It is available to
        # "end-users" but nobody will know it is there anyway...
        cython_testscope_utility_code.declare_in_scope(self)
        cython_test_extclass_utility_code.declare_in_scope(self)

        #
        # The view sub-scope
        #
        self.viewscope = viewscope = ModuleScope(u'cython.view', self, None)
        self.declare_module('view', viewscope, None)
        viewscope.is_cython_builtin = True
        viewscope.pxd_file_loaded = True

        cythonview_testscope_utility_code.declare_in_scope(viewscope)
Esempio n. 10
0
 def __init__(self, context):
     ModuleScope.__init__(self, u"cython", None, None)
     self.pxd_file_loaded = True
     self.populate_cython_scope()
     # The Main.Context object
     self.context = context
Esempio n. 11
0
 def find_module(self, module_name, relative_to=None, pos=None, need_pxd=1):
     if module_name != self.module_name:
         raise AssertionError(
             "Not yet supporting any cimports/includes from string code snippets"
         )
     return ModuleScope(module_name, parent_module=None, context=self)
Esempio n. 12
0
 def __init__(self, context):
     ModuleScope.__init__(self, u'cython', None, None)
     self.pxd_file_loaded = True
     self.populate_cython_scope()
     # The Main.Context object
     self.context = context
Esempio n. 13
0
 def __init__(self):
     ModuleScope.__init__(self, u'cython', None, None)
     self.pxd_file_loaded = True
     self.populate_cython_scope()