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)