-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcpps_function.h
More file actions
203 lines (163 loc) · 5.59 KB
/
cpps_function.h
File metadata and controls
203 lines (163 loc) · 5.59 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#ifndef CPPS_FUNCTION_CPPS_HEAD_
#define CPPS_FUNCTION_CPPS_HEAD_
//===================================
//@Author : Johnson
//@QQ : 88481106
//@Email : 88481106@qq.com
//@Date : 2015/11/20 (yy/mm/dd)
//@Module : CPPS_FUNCTION
//@Description : Cppº¯Êýµ÷ÓÃ
//@website : http://cpps.wiki
//==================================
namespace cpps
{
struct cpps_domain;
template<class C>
struct cpps_classvar;
template<class R>
struct cpps_converter;
template<typename p1>
class dofunc
{
public:
dofunc()
{}
dofunc(p1 dofunc_param_p1)
: vec(dofunc_param_p1)
{
}
public:
p1 vec;
};
template<class context>
void call_normal(C *c_state, cpps_domain *domain, cpps_std_vector &o, context &c, void(*f)())
{
f();
}
template <class Ret, class context>
Ret call_member(C *c_state, cpps_domain *domain, cpps_std_vector &o, context &c, Ret(*f)())
{
return f();
}
template<class context,class CLS >
void call_normal(C *c_state, cpps_domain *domain, cpps_std_vector &o, context &c, void(CLS::*f)())
{
if (domain&& domain->domainType == cpps_domain_type_classvar)
{
cpps_classvar<CLS> *cls = (cpps_classvar<CLS> *)domain;
(cls->__class->*f)();
}
}
template < class Ret, class CLS, class context>
Ret call_member(C *c_state, cpps_domain *domain, cpps_std_vector &o, context &c, Ret(CLS::*f)())
{
if (domain&& domain->domainType == cpps_domain_type_classvar)
{
cpps_classvar<CLS> *cls = (cpps_classvar<CLS> *)domain;
return (cls->__class->*f)();
}
return Ret();
}
}
#define CPPS_FUNCTION_ITER_C 1
#include "cpps_function.h"
#undef CPPS_FUNCTION_ITER_C
#define CPPS_FUNCTION_ITER_C 2
#include "cpps_function.h"
#undef CPPS_FUNCTION_ITER_C
#define CPPS_FUNCTION_ITER_C 3
#include "cpps_function.h"
#undef CPPS_FUNCTION_ITER_C
#define CPPS_FUNCTION_ITER_C 4
#include "cpps_function.h"
#undef CPPS_FUNCTION_ITER_C
#define CPPS_FUNCTION_ITER_C 5
#include "cpps_function.h"
#undef CPPS_FUNCTION_ITER_C
#define CPPS_FUNCTION_ITER_C 6
#include "cpps_function.h"
#undef CPPS_FUNCTION_ITER_C
#define CPPS_FUNCTION_ITER_C 7
#include "cpps_function.h"
#undef CPPS_FUNCTION_ITER_C
#define CPPS_FUNCTION_ITER_C 8
#include "cpps_function.h"
#undef CPPS_FUNCTION_ITER_C
#define CPPS_FUNCTION_ITER_C 9
#include "cpps_function.h"
#undef CPPS_FUNCTION_ITER_C
#define CPPS_FUNCTION_ITER_C 10
#include "cpps_function.h"
#undef CPPS_FUNCTION_ITER_C
#define CPPS_FUNCTION_ITER_C 11
#include "cpps_function.h"
#undef CPPS_FUNCTION_ITER_C
#define CPPS_FUNCTION_ITER_C 12
#include "cpps_function.h"
#undef CPPS_FUNCTION_ITER_C
#define CPPS_FUNCTION_ITER_C 13
#include "cpps_function.h"
#undef CPPS_FUNCTION_ITER_C
#define CPPS_FUNCTION_ITER_C 14
#include "cpps_function.h"
#undef CPPS_FUNCTION_ITER_C
#define CPPS_FUNCTION_ITER_C 15
#include "cpps_function.h"
#undef CPPS_FUNCTION_ITER_C
#define CPPS_FUNCTION_ITER_C 16
#include "cpps_function.h"
#undef CPPS_FUNCTION_ITER_C
#endif
#ifdef CPPS_FUNCTION_ITER_C
namespace cpps
{
template<class context, CPPS_PP_ENUM_PARAMS(CPPS_FUNCTION_ITER_C, class A) >
void call_normal(C *c_state, cpps_domain *domain, cpps_std_vector &o, context c, void(*f)(CPPS_PP_ENUM_PARAMS(CPPS_FUNCTION_ITER_C, A)))
{
//if (domain && domain->domainType == cpps_domain_type_classvar)
//{
// cpps_cppsclassvar* classvar = (cpps_cppsclassvar *) domain;
// o.push_back(cpps_value(classvar));
// CPPS_PP_ENUM_SET_VARS_WITH_VECTOR(CPPS_FUNCTION_ITER_C, c.vec.param, o);
// f(CPPS_PP_ENUM_PARAMS(CPPS_FUNCTION_ITER_C, c.vec.param));
// return;
//}
CPPS_PP_ENUM_SET_VARS_WITH_VECTOR(CPPS_FUNCTION_ITER_C, c.vec.param, o);
f(CPPS_PP_ENUM_PARAMS(CPPS_FUNCTION_ITER_C, c.vec.param));
}
template <class Ret, class context, CPPS_PP_ENUM_PARAMS(CPPS_FUNCTION_ITER_C, class A) >
Ret call_member(C *c_state, cpps_domain *domain, cpps_std_vector &o, context c, Ret(*f)(CPPS_PP_ENUM_PARAMS(CPPS_FUNCTION_ITER_C, A)))
{
//if (domain && domain->domainType == cpps_domain_type_classvar)
//{
// cpps_cppsclassvar* classvar = (cpps_cppsclassvar*)domain;
// o.push_back(cpps_value(classvar));
// CPPS_PP_ENUM_SET_VARS_WITH_VECTOR(CPPS_FUNCTION_ITER_C, c.vec.param, o);
// return f(CPPS_PP_ENUM_PARAMS(CPPS_FUNCTION_ITER_C, c.vec.param));
//}
CPPS_PP_ENUM_SET_VARS_WITH_VECTOR(CPPS_FUNCTION_ITER_C, c.vec.param, o);
return f(CPPS_PP_ENUM_PARAMS(CPPS_FUNCTION_ITER_C, c.vec.param));
}
template<class context, class CLS, CPPS_PP_ENUM_PARAMS(CPPS_FUNCTION_ITER_C, class A) >
void call_normal(C *c_state, cpps_domain *domain, cpps_std_vector &o, context c, void(CLS::*f)(CPPS_PP_ENUM_PARAMS(CPPS_FUNCTION_ITER_C, A)))
{
if (domain && domain->domainType == cpps_domain_type_classvar)
{
cpps_classvar<CLS> *cls = (cpps_classvar<CLS> *)domain;
CPPS_PP_ENUM_SET_VARS_WITH_VECTOR(CPPS_FUNCTION_ITER_C, c.vec.param, o);
(cls->__class->*f)(CPPS_PP_ENUM_PARAMS(CPPS_FUNCTION_ITER_C, c.vec.param));
}
}
template < class Ret, class context, class CLS, CPPS_PP_ENUM_PARAMS(CPPS_FUNCTION_ITER_C, class A) >
Ret call_member(C *c_state, cpps_domain *domain, cpps_std_vector &o, context c, Ret(CLS::*f)(CPPS_PP_ENUM_PARAMS(CPPS_FUNCTION_ITER_C, A)))
{
if (domain&& domain->domainType == cpps_domain_type_classvar)
{
cpps_classvar<CLS> *cls = (cpps_classvar<CLS> *)domain;
CPPS_PP_ENUM_SET_VARS_WITH_VECTOR(CPPS_FUNCTION_ITER_C, c.vec.param, o);
return (cls->__class->*f)(CPPS_PP_ENUM_PARAMS(CPPS_FUNCTION_ITER_C, c.vec.param));
}
return Ret();
}
}
#endif // CPPS_FUNCTION_CPPS_HEAD_