Newer
Older
from pystencilssfg import SourceFileGenerator, SfgConfiguration, SfgComposer
from pystencilssfg.configuration import SfgCodeStyle
from pystencilssfg.source_concepts import SrcObject
from pystencilssfg.source_components import SfgClass, SfgMemberVariable, SfgConstructor, SfgMethod, SfgVisibility
from pystencils import fields, kernel
sfg_config = SfgConfiguration(
output_directory="out/test_classes",
outer_namespace="gen_code",
codestyle=SfgCodeStyle(
code_style="Mozilla",
force_clang_format=True
)
with SourceFileGenerator(sfg_config) as ctx:
sfg = SfgComposer(ctx)
@kernel
def assignments():
f[0,0] @= 3 * g[0,0]
khandle = sfg.kernels.create(assignments)
cls = SfgClass("MyClass")
"inlineConst",
sfg.seq(
"return -1.0;"
),
return_type=SrcType("double"),
inline=True,
const=True
))
"awesomeMethod",
sfg.seq(
"return 2.0f;"
),
return_type=SrcType("float"),
inline=False,
const=True
))
[SrcObject("stuff", "std::vector< int > &")],