blob: 88e06db76d7d9be80e6b7c704a17d5d1bcd709bf (
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
54
|
# Color.esh
package Color
r=
g=
b=
new(string class, int r, int g, int b)
{
local self=
self=$[malloc]
bless ${self} ${class}
self->r="${r}"
self->g="${g}"
self->b="${b}"
}
delete(int self)
{
unset self->r
unset self->g
unset self->b
free ${self}
}
get_r(int self)
{
retval=${self->r}
}
get_g(int self)
{
retval=${self->g}
}
get_b(int self)
{
retval=${self->b}
}
print(int self)
{
printf '(%d, %d, %d)' ${self->r} ${self->g} ${self->b}
}
# main.esh
c=$[${Color::new} 255 0 0]
printf 'R: %d\n' "$[${c->get_r}]"
printf 'G: %d\n' "$[${c->get_g}]"
printf 'B: %d\n' "$[${c->get_b}]"
${c->print}
|