32 #ifndef _QORE_BUILTINFUNCTION_H
34 #define _QORE_BUILTINFUNCTION_H
42 class BuiltinSignature :
public AbstractFunctionSignature {
44 DLLLOCAL BuiltinSignature(
bool extra_args,
const QoreTypeInfo* n_returnTypeInfo,
const type_vec_t& n_typeList,
46 : AbstractFunctionSignature(n_returnTypeInfo, n_typeList, n_defaultArgList, n_names) {
47 for (
unsigned i = 0; i < typeList.size(); ++i) {
48 bool hasDefaultArg = i < defaultArgList.size() && defaultArgList[i];
49 if (QoreTypeInfo::hasType(typeList[i])) {
55 str.append(QoreTypeInfo::getPath(typeList[i]));
56 if (names.size() > i && !names[i].empty()) {
62 addDefaultArgument(str, defaultArgList[i]);
66 if (i != (typeList.size() - 1))
70 if (!typeList.empty())
76 DLLLOCAL
virtual ~BuiltinSignature() {
79 DLLLOCAL
virtual const QoreTypeInfo* parseGetReturnTypeInfo(
int& err)
const {
80 return returnTypeInfo;
83 DLLLOCAL
virtual const QoreParseTypeInfo* getParseParamTypeInfo(
unsigned num)
const {
89 #define COMMON_BUILTIN_VARIANT_FUNCTIONS DLLLOCAL virtual int64 getFunctionality() const { return functionality; } \
90 DLLLOCAL virtual AbstractFunctionSignature* getSignature() const { return const_cast<BuiltinSignature*>(&signature); } \
91 DLLLOCAL virtual const QoreTypeInfo* parseGetReturnTypeInfo(int& err) const { return signature.getReturnTypeInfo(); }
93 class BuiltinFunctionVariantBase {
95 BuiltinSignature signature;
102 signature(n_functionality & QCF_USES_EXTRA_ARGS, n_returnTypeInfo, n_typeList, n_defaultArgList, n_names),
103 functionality(n_functionality) {
108 class BuiltinFunctionValueVariant :
public AbstractQoreFunctionVariant,
public BuiltinFunctionVariantBase {
116 AbstractQoreFunctionVariant(n_flags), BuiltinFunctionVariantBase(n_functionality, n_returnTypeInfo,
117 n_typeList, n_defaultArgList, n_names), func(m) {
121 COMMON_BUILTIN_VARIANT_FUNCTIONS
123 DLLLOCAL
virtual QoreValue evalFunction(
const char* name, CodeEvaluationHelper& ceh,
ExceptionSink* xsink)
const {
124 CodeContextHelper cch(xsink, CT_BUILTIN, name);
126 return func(ceh.getArgs(), ceh.getRuntimeFlags(), xsink);
142 AbstractQoreFunctionVariant(n_flags), BuiltinFunctionVariantBase(n_functionality, n_returnTypeInfo,
143 n_typeList, n_defaultArgList, n_names), func(m), ptr(ptr) {
147 COMMON_BUILTIN_VARIANT_FUNCTIONS
149 DLLLOCAL
virtual QoreValue evalFunction(
const char* name, CodeEvaluationHelper& ceh,
ExceptionSink* xsink)
const {
150 CodeContextHelper cch(xsink, CT_BUILTIN, name);
152 return func(ptr, ceh.getArgs(), ceh.getRuntimeFlags(), xsink);
#define QDOM_DEFAULT
the default domain (no domain)
Definition: Restrictions.h:159
External function variable.
Definition: BuiltinFunction.h:133
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
QoreValue(* q_func_n_t)(const QoreListNode *args, q_rt_flags_t flags, ExceptionSink *xsink)
the type used for builtin function signatures
Definition: common.h:307
std::vector< const QoreTypeInfo * > type_vec_t
vector of type information for parameter lists
Definition: common.h:251
std::vector< std::string > name_vec_t
vector of parameter names for parameter lists
Definition: common.h:257
long long int64
64bit integer type, cannot use int64_t here since it breaks the API on some 64-bit systems due to equ...
Definition: common.h:260
QoreValue(* q_external_func_t)(const void *ptr, const QoreListNode *args, q_rt_flags_t flags, ExceptionSink *xsink)
the type used for builtin function signatures for external functions
Definition: common.h:319
std::vector< QoreValue > arg_vec_t
vector of value information for default argument lists
Definition: common.h:254
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:275