-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcpps_call_function.h
More file actions
37 lines (32 loc) · 1.24 KB
/
cpps_call_function.h
File metadata and controls
37 lines (32 loc) · 1.24 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
#ifndef CPPS_CALL_FUNCTION_CPPS_HEAD_
#define CPPS_CALL_FUNCTION_CPPS_HEAD_
//===================================
//@Author : Johnson
//@QQ : 88481106
//@Email : 88481106@qq.com
//@Date : 2015/11/20 (yy/mm/dd)
//@Module : CPPS_CALL_FUNCTION
//@Description : 调用Cpp函数
//@website : http://cppscript.org
//==================================
namespace cpps
{
template<class Type>
struct cpps_cpp_to_cpps_converter;
template<class retType, typename context, typename F, typename IsVoid>
void call_function(C *c_state, cpps_value &ret, cpps_domain *domain, cpps_std_vector &o, context &c, F &f, IsVoid)
{
retType r = call_member<retType>(c_state, domain, o, c, f);
if (!cpps_cpp_to_cpps_converter<retType>::match(c_state, r))
{
throw(cpps_error("0", 0, 0, "%s is not defined to script, conversion failed.",typeid(retType).name()));
}
ret = cpps_cpp_to_cpps_converter<retType>::apply(c_state,r); //c++的返回值 只有可以转换的才可以
}
template<class retType, typename context, typename F>
void call_function(C *c_state, cpps_value &ret, cpps_domain *domain, cpps_std_vector &o, context &c, F &f, cpps_is_void<void>)
{
call_normal(c_state, domain, o, c, f);
}
}
#endif // CPPS_CALL_FUNCTION_CPPS_HEAD_