56 |
|
|
57 |
/** |
/** |
58 |
* An instance of this class is returned by built-in function implementations |
* An instance of this class is returned by built-in function implementations |
59 |
|
* which return a real number (floating point) value as function return value. |
60 |
|
*/ |
61 |
|
class VMRealResult : public VMFnResult, public VMRealExpr { |
62 |
|
public: |
63 |
|
StmtFlags_t flags; ///< general completion status (i.e. success or failure) of the function call |
64 |
|
vmfloat value; ///< result value of the function call |
65 |
|
|
66 |
|
VMRealResult() : flags(STMT_SUCCESS), value(0) {} |
67 |
|
vmfloat evalReal() OVERRIDE { return value; } |
68 |
|
VMExpr* resultValue() OVERRIDE { return this; } |
69 |
|
StmtFlags_t resultFlags() OVERRIDE { return flags; } |
70 |
|
bool isConstExpr() const OVERRIDE { return false; } |
71 |
|
MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE { return VM_NO_PREFIX; } |
72 |
|
StdUnit_t unitType() const OVERRIDE { return VM_NO_UNIT; } |
73 |
|
bool isFinal() const OVERRIDE { return false; } |
74 |
|
}; |
75 |
|
|
76 |
|
/** |
77 |
|
* An instance of this class is returned by built-in function implementations |
78 |
* which return a string value as function return value. |
* which return a string value as function return value. |
79 |
*/ |
*/ |
80 |
class VMStringResult : public VMFnResult, public VMStringExpr { |
class VMStringResult : public VMFnResult, public VMStringExpr { |
120 |
}; |
}; |
121 |
|
|
122 |
/** |
/** |
123 |
|
* Abstract base class for built-in script functions which return a real number |
124 |
|
* (floating point scalar) as their function return value. |
125 |
|
*/ |
126 |
|
class VMRealResultFunction : public VMFunction { |
127 |
|
protected: |
128 |
|
virtual ~VMRealResultFunction() {} |
129 |
|
ExprType_t returnType() OVERRIDE { return REAL_EXPR; } |
130 |
|
VMFnResult* errorResult(vmfloat f = 0); |
131 |
|
VMFnResult* successResult(vmfloat f = 0); |
132 |
|
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
133 |
|
protected: |
134 |
|
VMRealResult result; |
135 |
|
}; |
136 |
|
|
137 |
|
/** |
138 |
* Abstract base class for built-in script functions which return a string as |
* Abstract base class for built-in script functions which return a string as |
139 |
* their function return value. |
* their function return value. |
140 |
*/ |
*/ |
356 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
357 |
}; |
}; |
358 |
|
|
359 |
|
/** |
360 |
|
* Implements the built-in real_to_int() script function and its short hand |
361 |
|
* variant int(). The behaviour of the two built-in script functions are |
362 |
|
* identical ATM. |
363 |
|
*/ |
364 |
|
class CoreVMFunction_real_to_int : public VMIntResultFunction { |
365 |
|
public: |
366 |
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
367 |
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
368 |
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
369 |
|
ExprType_t argType(vmint iArg) const OVERRIDE { return REAL_EXPR; } |
370 |
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
371 |
|
}; |
372 |
|
|
373 |
|
/** |
374 |
|
* Implements the built-in int_to_real() script function and its short hand |
375 |
|
* variant real(). The behaviour of the two built-in script functions are |
376 |
|
* identical ATM. |
377 |
|
*/ |
378 |
|
class CoreVMFunction_int_to_real : public VMRealResultFunction { |
379 |
|
public: |
380 |
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
381 |
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
382 |
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
383 |
|
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
384 |
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
385 |
|
}; |
386 |
|
|
387 |
} // namespace LinuxSampler |
} // namespace LinuxSampler |
388 |
|
|
389 |
#endif // LS_COREVMFUNCTIONS_H |
#endif // LS_COREVMFUNCTIONS_H |