Skip to content
Snippets Groups Projects
Commit dd19905b authored by Frederik Hennig's avatar Frederik Hennig
Browse files

quick-fix: print base classes

parent e37859ff
No related branches found
No related tags found
1 merge request!18quick-fix: print base classes
Pipeline #73988 passed
......@@ -154,7 +154,10 @@ class SfgFilePrinter:
return code
case SfgClassBody(cls, vblocks):
code = f"{cls.class_keyword} {cls.name} {{\n"
code = f"{cls.class_keyword} {cls.name}"
if cls.base_classes:
code += " : " + ", ".join(cls.base_classes)
code += " {\n"
vblocks_str = [self._visibility_block(b) for b in vblocks]
code += "\n\n".join(vblocks_str)
code += "\n};\n"
......
......@@ -7,4 +7,7 @@ int main(void){
Point p { 3, 1, -4 };
assert(p.getX() == 3);
SpecialPoint q { 0, 1, 2 };
assert(q.getY() == 1);
}
......@@ -11,18 +11,19 @@ with SourceFileGenerator() as sfg:
sfg.klass("Point")(
sfg.public(
sfg.constructor(x, y, z)
.init(x_)(x)
.init(y_)(y)
.init(z_)(z),
sfg.constructor(x, y, z).init(x_)(x).init(y_)(y).init(z_)(z),
sfg.method("getX", returns="const int64_t", const=True, inline=True)(
"return this->x_;"
)
),
),
sfg.private(
x_,
y_,
z_
sfg.protected(x_, y_, z_),
)
sfg.klass("SpecialPoint", bases=["public Point"])(
sfg.public(
"using Point::Point;",
sfg.method("getY", returns="const int64_t", const=True, inline=True)(
"return this->y_;"
),
)
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment