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
|
#include "Ressource.class.h"
#include <SyscallManager/Res.ns.h>
Ressource::Ressource(u8int type) {
m_id = Res::registerRes(this);
m_type = type;
m_calls = 0;
addCall0(0, (call0)&Ressource::resType);
}
Ressource::~Ressource() {
Res::unregisterRes(m_id);
delete m_calls;
}
void Ressource::addCall0(u8int id, call0 c) {
call_t e = {0, id, {c}};
m_calls = m_calls->cons(e);
}
void Ressource::addCall1(u8int id, call1 c) {
call_t e = {1, id, {0}};
e.c1 = c;
m_calls = m_calls->cons(e);
}
void Ressource::addCall2(u8int id, call2 c) {
call_t e = {2, id, {0}};
e.c2 = c;
m_calls = m_calls->cons(e);
}
void Ressource::addCall3(u8int id, call3 c) {
call_t e = {3, id, {0}};
e.c3 = c;
m_calls = m_calls->cons(e);
}
void Ressource::addCall4(u8int id, call4 c) {
call_t e = {4, id, {0}};
e.c4 = c;
m_calls = m_calls->cons(e);
}
void Ressource::addCall5(u8int id, call5 c) {
call_t e = {5, id, {0}};
e.c5 = c;
m_calls = m_calls->cons(e);
}
u32int Ressource::doCall(u8int id, u32int a, u32int b, u32int c, u32int d, u32int e) {
for (SimpleList<call_t> *iter = m_calls; iter != 0; iter = iter->next()) {
call_t &ce = iter->v();
if (ce.id == id) {
if (ce.params == 0) return (this->*(ce.c0))();
if (ce.params == 1) return (this->*(ce.c1))(a);
if (ce.params == 2) return (this->*(ce.c2))(a, b);
if (ce.params == 3) return (this->*(ce.c3))(a, b, c);
if (ce.params == 4) return (this->*(ce.c4))(a, b, c, d);
if (ce.params == 5) return (this->*(ce.c5))(a, b, c, d, e);
}
}
return (u32int) - 1;
}
|