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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
#include "ivl.h"
#include "dnn.h"
#include <stdio.h>
#include "Loop.h"
#include "Disposable.h"
#if 0
#if 0
class A {
public:
void foo (IvlEvent&);
};
main ()
{
A a;
IvlReactionOf <A> r (a, &A::foo);
}
#else
IvlEventFeature evf [] = {{"X", sizeof (int)}, {"Y", sizeof (int)}};
IvlEventType click ("click", 2, evf);
class IvlClickEvent : public IvlEvent {
public:
int X, Y;
inline IvlClickEvent (int x, int y) : IvlEvent (&click, false), X (x), Y (y) {}
inline void SetX (int x) { X = x; }
inline void SetY (int y) { Y = y; }
inline int GetX () const { return X; }
inline int GetY () const { return Y; }
};
main ()
{
IvlEvent ev (&click);
int x = 3, y = 5;
ev.SetFeature (0, &x);
ev.SetFeature (1, &y);
int x2, y2;
ev.GetFeature (0, &x2);
ev.GetFeature (1, &y2);
printf ("(%d, %d)\n", x2, y2);
IvlClickEvent ev2 (3, 5);
int x22, y22;
ev.GetFeature (0, &x22);
ev.GetFeature (1, &y22);
printf ("(%d, %d)\n", x22, y22);
}
#endif
#else
class A : public IvlDisposable {
public:
A () { printf ("A::A\n"); }
~A () { printf ("A::~A\n"); }
};
A* a;
void
foo ()
{
static int i = 0;
printf ("%d\n", i);
if (i >= 5) {
a->Trash ();
IvlStop ();
}
i++;
}
main ()
{
IvlOpen ();
a = new A;
IvlMpx->AddHook (foo);
IvlLoop ();
IvlClose ();
}
#endif
|