diff options
| author | Tyge Løvset <[email protected]> | 2022-05-19 22:37:11 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-05-19 22:37:11 +0200 |
| commit | fa5c3a40738d5fca515ab1d581566355b8e05430 (patch) | |
| tree | ec3b7fb8beb5c64eb22f6d8ea9582fb982a5452a /examples/shape.c | |
| parent | 9e1421e5ed0e93cebecfb2a8fe423d01ba1d08e8 (diff) | |
| download | STC-modified-fa5c3a40738d5fca515ab1d581566355b8e05430.tar.gz STC-modified-fa5c3a40738d5fca515ab1d581566355b8e05430.zip | |
Some extra test on template params. Update shape.c example.
Diffstat (limited to 'examples/shape.c')
| -rw-r--r-- | examples/shape.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/examples/shape.c b/examples/shape.c index ec1998c0..69c8ca70 100644 --- a/examples/shape.c +++ b/examples/shape.c @@ -83,8 +83,8 @@ c_vtable(Shape, Polygon, api); static void Polygon_drop(Shape** shape)
{
- puts("drop poly");
c_self(shape, Polygon, api);
+ puts("drop poly");
PVec_drop(&self->points);
}
@@ -123,18 +123,27 @@ void testShape(Shape** shape) (*shape)->draw(shape);
}
+#define i_type Shapes
+#define i_val Shape**
+#define i_opt c_no_clone
+#define i_valdrop(x) Shape_delete(*x)
+#include <stc/cstack.h>
+
int main(void)
{
- c_autovar (Shape** tria = NULL, Shape_delete(tria))
- c_autovar (Shape** poly = Polygon_new(), Shape_delete(poly))
+ c_auto (Shapes, shapes)
{
- tria = Triangle_new((Point){5, 7}, (Point){12, 7}, (Point){12, 20});
+ Shape** tria = Triangle_new((Point){5, 7}, (Point){12, 7}, (Point){12, 20});
+ Shape** poly = Polygon_new();
c_apply(p, Polygon_addPoint(poly, p), Point, {
{5, 7}, {12, 7}, {12, 20}, {82, 33}, {17, 56},
});
- testShape(tria);
- testShape(poly);
+ Shapes_push(&shapes, tria);
+ Shapes_push(&shapes, poly);
+
+ c_foreach (i, Shapes, shapes)
+ testShape(*i.ref);
}
}
|
