blob: 60a73a0760d5711a3618d1b866b63e086869be42 (
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
|
// preprocess using luam -C -llc class1.lc > class1.c
module "class1" {
class A {
int handle;
constructor (Int i) {
this->handle = i;
}
def geth () {
lua_pushinteger(L, this->handle);
return 1;
}
def __eq(A other) {
lua_pushboolean(L, this->handle == other->handle);
return 1;
}
}
def A (Int i) {
push_new_A(L,i);
return 1;
}
constants {
Int MAGIC = 42
}
}
lua_tests {
require 'class1'
M = class1.MAGIC
o = class1.A(M)
assert(o:geth() == M)
a = class1.A(M)
assert(a == o);
}
|