Example #1
0
    def _buildtree(self):
        assert self._name is None, '_buildtree can be called only on top-level CLR, not on namespaces'
        from rpython.translator.cli.support import getattr_ex
        load_assembly(mscorlib)
        load_pypylib()
        for fullname in sorted(list(Namespaces)):
            if '.' in fullname:
                parent, name = fullname.rsplit('.', 1)
                parent = getattr_ex(self, parent)
                setattr(parent, name, CliNamespace(fullname))
            else:
                setattr(self, fullname, CliNamespace(fullname))

        for fullname in Types.keys():
            parent, name = fullname.rsplit('.', 1)
            parent = getattr_ex(self, parent)
            setattr(parent, name, placeholder)
        self.System.Object # XXX hack
Example #2
0
def _create_NativeException(cliClass):
    from rpython.translator.cli.support import getattr_ex
    TYPE = cliClass._INSTANCE
    if PythonNet.__name__ in ('CLR', 'clr'):
        # we are using pythonnet -- use the .NET class
        name = '%s.%s' % (TYPE._namespace, TYPE._classname)
        res = getattr_ex(PythonNet, name)
    else:
        # we are not using pythonnet -- create a fake class
        res = types.ClassType(TYPE._classname, (Exception, ), {})
    res._rpython_hints = {'NATIVE_INSTANCE': TYPE}
    return res
Example #3
0
File: dotnet.py Project: sota/pypy
def _create_NativeException(cliClass):
    from rpython.translator.cli.support import getattr_ex
    TYPE = cliClass._INSTANCE
    if PythonNet.__name__ in ('CLR', 'clr'):
        # we are using pythonnet -- use the .NET class
        name = '%s.%s' % (TYPE._namespace, TYPE._classname)
        res = getattr_ex(PythonNet, name)
    else:
        # we are not using pythonnet -- create a fake class
        res = types.ClassType(TYPE._classname, (Exception,), {})
    res._rpython_hints = {'NATIVE_INSTANCE': TYPE}
    return res