Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# type: ignore
from pystencilssfg import SourceFileGenerator, SfgConfiguration, SfgComposer
from pystencilssfg.configuration import SfgCodeStyle
from pystencilssfg.composer import SfgClassComposer
from pystencilssfg.source_concepts import SrcObject
from pystencils import fields, kernel
sfg_config = SfgConfiguration(
output_directory="out/test_class_composer",
outer_namespace="gen_code",
codestyle=SfgCodeStyle(
code_style="Mozilla",
force_clang_format=True
)
)
f, g = fields("f, g(1): double[2D]")
with SourceFileGenerator(sfg_config) as ctx:
sfg = SfgComposer(ctx)
c = SfgClassComposer(ctx)
@kernel
def assignments():
f[0, 0] @= 3 * g[0, 0]
khandle = sfg.kernels.create(assignments)
c.struct("DataStruct")(
SrcObject("coord", "uint32_t"),
SrcObject("value", "float")
),
c.klass("MyClass", bases=("MyBaseClass",))(
# class body sequencer
c.private(
c.var("a_", "int"),
c.method("getX", returns="int")(
"return 2.0;"
)
),
c.constructor(SrcObject("a", "int"))
.init("a_(a)")
.body(
'cout << "Hi!" << endl;'
),
c.public(