-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcpps_dofunction.h
More file actions
179 lines (129 loc) · 4.36 KB
/
cpps_dofunction.h
File metadata and controls
179 lines (129 loc) · 4.36 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#ifndef CPPS_DOFUNCTION_CPPS_HEAD_
#define CPPS_DOFUNCTION_CPPS_HEAD_
//===================================
//@Author : Johnson
//@QQ : 88481106
//@Email : 88481106@qq.com
//@Date : 2015/12/16 (yy/mm/dd)
//@Module : CPPS_DOFUNCTION
//@Description : C++����Cpps��������
//@website : http://cppscript.org
//==================================
namespace cpps
{
void cpps_gc_check_step(C * c);
object dofunction(C *c, object func);
object doclassfunction(C *c, object leftdomain, object func);
object function_caller(C *c, object func, cpps_std_vector& paramlist);
object function_caller(C *c, object leftdomain, object func, cpps_std_vector& paramlist);
}
#define CPPS_DOFUNCTION_ITER_C 1
#include "cpps_dofunction.h"
#undef CPPS_DOFUNCTION_ITER_C
#define CPPS_DOFUNCTION_ITER_C 2
#include "cpps_dofunction.h"
#undef CPPS_DOFUNCTION_ITER_C
#define CPPS_DOFUNCTION_ITER_C 3
#include "cpps_dofunction.h"
#undef CPPS_DOFUNCTION_ITER_C
#define CPPS_DOFUNCTION_ITER_C 4
#include "cpps_dofunction.h"
#undef CPPS_DOFUNCTION_ITER_C
#define CPPS_DOFUNCTION_ITER_C 5
#include "cpps_dofunction.h"
#undef CPPS_DOFUNCTION_ITER_C
#define CPPS_DOFUNCTION_ITER_C 6
#include "cpps_dofunction.h"
#undef CPPS_DOFUNCTION_ITER_C
#define CPPS_DOFUNCTION_ITER_C 7
#include "cpps_dofunction.h"
#undef CPPS_DOFUNCTION_ITER_C
#define CPPS_DOFUNCTION_ITER_C 8
#include "cpps_dofunction.h"
#undef CPPS_DOFUNCTION_ITER_C
#define CPPS_DOFUNCTION_ITER_C 9
#include "cpps_dofunction.h"
#undef CPPS_DOFUNCTION_ITER_C
#define CPPS_DOFUNCTION_ITER_C 10
#include "cpps_dofunction.h"
#undef CPPS_DOFUNCTION_ITER_C
#define CPPS_DOFUNCTION_ITER_C 11
#include "cpps_dofunction.h"
#undef CPPS_DOFUNCTION_ITER_C
#define CPPS_DOFUNCTION_ITER_C 12
#include "cpps_dofunction.h"
#undef CPPS_DOFUNCTION_ITER_C
#define CPPS_DOFUNCTION_ITER_C 13
#include "cpps_dofunction.h"
#undef CPPS_DOFUNCTION_ITER_C
#define CPPS_DOFUNCTION_ITER_C 14
#include "cpps_dofunction.h"
#undef CPPS_DOFUNCTION_ITER_C
#define CPPS_DOFUNCTION_ITER_C 15
#include "cpps_dofunction.h"
#undef CPPS_DOFUNCTION_ITER_C
#define CPPS_DOFUNCTION_ITER_C 16
#include "cpps_dofunction.h"
#undef CPPS_DOFUNCTION_ITER_C
#endif // CPPS_DOFUNCTION_CPPS_HEAD_
#ifdef CPPS_DOFUNCTION_ITER_C
namespace cpps
{
template<class R>
struct cpps_converter;
template< CPPS_PP_ENUM_PARAMS(CPPS_DOFUNCTION_ITER_C, class A) >
object dofunction(C *c, object func, CPPS_PP_ENUM_VARS_PARAMS(CPPS_DOFUNCTION_ITER_C, A, p))
{
cpps_value ret;
if (func.value.tt == CPPS_TLAMBDAFUNCTION) {
cpps_cppsclassvar* cppsclassvar = (cpps_cppsclassvar*)func.value.value.domain;
cpps_lambda_function* pfunc = (cpps_lambda_function*)cppsclassvar->getclsptr();
func.value = pfunc;
func.value.tt = CPPS_TFUNCTION;
}
if (func.value.tt == CPPS_TFUNCTION)
{
cpps_function *f = func.value.value.func;
if (f)
{
cpps_std_vector paramlist;
CPPS_PP_ENUM_VARS_PARAMS_PUSHBACK(CPPS_DOFUNCTION_ITER_C, paramlist, A, p, c);
cpps_domain *execdomain2 = c->_G;
cpps_stack stack;
stack.init(__FILE__, __LINE__, f->funcname.c_str());
c->push_stack(&stack);
f->callfunction(c, &ret, execdomain2, ¶mlist, NULL,NULL);
c->pop_stack();
}
}
return ret;
}
template< CPPS_PP_ENUM_PARAMS(CPPS_DOFUNCTION_ITER_C, class A) >
object doclassfunction(C *c, object domain, object func, CPPS_PP_ENUM_VARS_PARAMS(CPPS_DOFUNCTION_ITER_C, A, p))
{
cpps_value ret;
if (func.value.tt == CPPS_TLAMBDAFUNCTION) {
cpps_cppsclassvar* cppsclassvar = (cpps_cppsclassvar*)func.value.value.domain;
cpps_lambda_function* pfunc = (cpps_lambda_function*)cppsclassvar->getclsptr();
func.value = pfunc;
func.value.tt = CPPS_TFUNCTION;
}
if (func.value.tt == CPPS_TFUNCTION)
{
cpps_function *f = func.value.value.func;
if (f)
{
cpps_std_vector paramlist;
CPPS_PP_ENUM_VARS_PARAMS_PUSHBACK(CPPS_DOFUNCTION_ITER_C, paramlist, A, p, c);
cpps_domain *execdomain2 = domain.value.value.domain;
cpps_stack stack;
stack.init(__FILE__, __LINE__, f->funcname.c_str());
c->push_stack(&stack);
f->callfunction(c, &ret, execdomain2, ¶mlist, NULL, NULL);
c->pop_stack();
}
}
return ret;
}
}
#endif