summaryrefslogtreecommitdiff
path: root/Tests/SwigTest/runme.pike
blob: ec28dd70e187e8e1c626cb85070ae58cfa7f0ad2 (plain)
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
53
import .example;

int main()
{
    // ----- Object creation -----

    write("Creating some objects:\n");
    Circle c = Circle(10.0);
    write("    Created circle.\n");
    Square s = Square(10.0);
    write("    Created square.\n");

    // ----- Access a static member -----

    write("\nA total of " + Shape_nshapes_get() + " shapes were created\n");

    // ----- Member data access -----

    // Set the location of the object

    c->x_set(20.0);
    c->y_set(30.0);

    s->x_set(-10.0);
    s->y_set(5.0);

    write("\nHere is their current position:\n");
    write("    Circle = (%f, %f)\n", c->x_get(), c->y_get());
    write("    Square = (%f, %f)\n", s->x_get(), s->y_get());

    // ----- Call some methods -----

    write("\nHere are some properties of the shapes:\n");
    write("   The circle:\n");
    write("        area      = %f.\n", c->area());
    write("        perimeter = %f.\n", c->perimeter());
    write("   The square:\n");
    write("        area      = %f.\n", s->area());
    write("        perimeter = %f.\n", s->perimeter());

    write("\nGuess I'll clean up now\n");

    /* See if we can force 's' to be garbage-collected */
    s = 0;

    /* Now we should be down to only 1 shape */
    write("%d shapes remain\n", Shape_nshapes_get());

    /* Done */
    write("Goodbye\n");

    return 0;
}