Example #1
0
class DllDef:
    def __init__(self,
                 name,
                 namespace,
                 functions=[],
                 dontmangle=True,
                 isnetmodule=False):
        self.name = name
        self.namespace = namespace
        self.functions = functions  # [(function, annotation), ...]
        self.isnetmodule = isnetmodule
        self.driver = TranslationDriver()
        if dontmangle:
            self.driver.config.translation.ootype.mangle = False
        self.driver.setup_library(self)

    def add_function(self, func, inputtypes):
        self.functions.append((func, inputtypes))

    def get_entrypoint(self, bk):
        graphs = [bk.getdesc(f).cachedgraph(None) for f, _ in self.functions]
        return DllEntryPoint(self.name, graphs, self.isnetmodule)

    def compile(self):
        # add all functions to the appropriate namespace
        if self.namespace:
            for func, _ in self.functions:
                if not hasattr(func, '_namespace_'):
                    func._namespace_ = self.namespace
        self.driver.proceed(['compile_cli'])
Example #2
0
class DllDef:
    def __init__(self, name, namespace, functions=[], dontmangle=True, isnetmodule=False):
        self.name = name
        self.namespace = namespace
        self.functions = functions # [(function, annotation), ...]
        self.isnetmodule = isnetmodule
        self.driver = TranslationDriver()
        if dontmangle:
            self.driver.config.translation.ootype.mangle = False
        self.driver.setup_library(self)

    def add_function(self, func, inputtypes):
        self.functions.append((func, inputtypes))

    def get_entrypoint(self, bk):
        graphs = [bk.getdesc(f).cachedgraph(None) for f, _ in self.functions]
        return DllEntryPoint(self.name, graphs, self.isnetmodule)

    def compile(self):
        # add all functions to the appropriate namespace
        if self.namespace:
            for func, _ in self.functions:
                if not hasattr(func, '_namespace_'):
                    func._namespace_ = self.namespace
        self.driver.proceed(['compile_cli'])
Example #3
0
class DLLDef(object):
    def __init__(self, name, functions=[], policy=None, config=None):
        self.name = name
        self.functions = functions # [(function, annotation), ...]
        self.driver = TranslationDriver(config=config)
        self.driver.setup_library(self, policy=policy)

    def compile(self):
        self.driver.proceed(['compile_c'])
        return self.driver.c_entryp

    def getcbuilder(self, translator, config):
        return CLibraryBuilder(translator, None, config,
                               functions=self.functions, name=self.name)
Example #4
0
class DLLDef(object):
    def __init__(self, name, functions=[], policy=None, config=None):
        self.name = name
        self.functions = functions  # [(function, annotation), ...]
        self.driver = TranslationDriver(config=config)
        self.driver.setup_library(self, policy=policy)

    def compile(self):
        self.driver.proceed(['compile_c'])
        return self.driver.c_entryp

    def getcbuilder(self, translator, config):
        return CLibraryBuilder(translator,
                               None,
                               config,
                               functions=self.functions,
                               name=self.name)