def test_multi_functions(self): mod = ext_tools.ext_module('module_multi_function') var_specs = [] code = "" test = ext_tools.ext_function_from_specs('test',code,var_specs) mod.add_function(test) test2 = ext_tools.ext_function_from_specs('test2',code,var_specs) mod.add_function(test2) mod.compile(location = build_dir) import module_multi_function module_multi_function.test() module_multi_function.test2()
def test_multi_functions(self): mod = ext_tools.ext_module('module_multi_function') var_specs = [] code = "" test = ext_tools.ext_function_from_specs('test',code,var_specs) mod.add_function(test) test2 = ext_tools.ext_function_from_specs('test2',code,var_specs) mod.add_function(test2) mod.compile(location=build_dir) import module_multi_function module_multi_function.test() module_multi_function.test2()
def test_simple(self): """ Simplest possible function """ mod = ext_tools.ext_module('simple_ext_function') var_specs = [] code = "" test = ext_tools.ext_function_from_specs('test',code,var_specs) mod.add_function(test) mod.compile(location=build_dir) import simple_ext_function simple_ext_function.test()
def test_simple(self): """ Simplest possible function """ mod = ext_tools.ext_module('simple_ext_function') var_specs = [] code = "" test = ext_tools.ext_function_from_specs('test',code,var_specs) mod.add_function(test) mod.compile(location = build_dir) import simple_ext_function simple_ext_function.test()
def test_with_include(self): # decalaring variables a = 2.; # declare module mod = ext_tools.ext_module('ext_module_with_include') mod.customize.add_header('<iostream>') # function 2 --> a little more complex expression var_specs = ext_tools.assign_variable_types(['a'],locals(),globals()) code = """ std::cout << std::endl; std::cout << "test printing a value:" << a << std::endl; """ test = ext_tools.ext_function_from_specs('test',code,var_specs) mod.add_function(test) # build module mod.compile(location = build_dir) import ext_module_with_include ext_module_with_include.test(a)
def test_with_include(self): # decalaring variables a = 2. # declare module mod = ext_tools.ext_module('ext_module_with_include') mod.customize.add_header('<iostream>') # function 2 --> a little more complex expression var_specs = ext_tools.assign_variable_types(['a'], locals(), globals()) code = """ std::cout << std::endl; std::cout << "test printing a value:" << a << std::endl; """ test = ext_tools.ext_function_from_specs('test', code, var_specs) mod.add_function(test) # build module mod.compile(location=build_dir) import ext_module_with_include ext_module_with_include.test(a)
def test_with_include(self): # decalaring variables a = 2.0 # declare module mod = ext_tools.ext_module("ext_module_with_include") mod.customize.add_header("<iostream>") # function 2 --> a little more complex expression var_specs = ext_tools.assign_variable_types(["a"], locals(), globals()) code = """ std::cout.clear(std::ios_base::badbit); std::cout << std::endl; std::cout << "test printing a value:" << a << std::endl; std::cout.clear(std::ios_base::goodbit); """ test = ext_tools.ext_function_from_specs("test", code, var_specs) mod.add_function(test) # build module mod.compile(location=build_dir) import ext_module_with_include ext_module_with_include.test(a)