/[svn]/linuxsampler/trunk/src/scriptvm/CoreVMFunctions.h
ViewVC logotype

Contents of /linuxsampler/trunk/src/scriptvm/CoreVMFunctions.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2598 - (show annotations) (download) (as text)
Fri Jun 6 12:38:54 2014 UTC (9 years, 10 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 3074 byte(s)
* ScriptVM (WIP): Built-in script function "play_note()" now returns the
  event ID of the triggered note.
* ScriptVM (WIP): Implemented built-in script int variable $EVENT_ID.
* ScriptVM (WIP): Implemented built-in script function "ignore_event()".
* ScriptVM (WIP): Implemented built-in script function
  "ignore_controller()" (accepts one and no argument).
* Bumped version (1.0.0.svn44).

1 /*
2 * Copyright (c) 2014 Christian Schoenebeck
3 *
4 * http://www.linuxsampler.org
5 *
6 * This file is part of LinuxSampler and released under the same terms.
7 * See README file for details.
8 */
9
10 #ifndef LS_COREVMFUNCTIONS_H
11 #define LS_COREVMFUNCTIONS_H
12
13 #include "../common/global.h"
14 #include "common.h"
15
16 namespace LinuxSampler {
17
18 class ScriptVM;
19
20 class VMEmptyResult : public VMFnResult, public VMExpr {
21 public:
22 StmtFlags_t flags;
23
24 VMEmptyResult() : flags(STMT_SUCCESS) {}
25 ExprType_t exprType() const { return EMPTY_EXPR; }
26 VMExpr* resultValue() { return this; }
27 StmtFlags_t resultFlags() { return flags; }
28 };
29
30 class VMIntResult : public VMFnResult, public VMIntExpr {
31 public:
32 StmtFlags_t flags;
33 int value;
34
35 VMIntResult() : flags(STMT_SUCCESS) {}
36 int evalInt() { return value; }
37 VMExpr* resultValue() { return this; }
38 StmtFlags_t resultFlags() { return flags; }
39 };
40
41 class VMStringResult : public VMFnResult, public VMStringExpr {
42 public:
43 StmtFlags_t flags;
44 String value;
45
46 VMStringResult() : flags(STMT_SUCCESS) {}
47 String evalStr() { return value; }
48 VMExpr* resultValue() { return this; }
49 StmtFlags_t resultFlags() { return flags; }
50 };
51
52 class VMEmptyResultFunction : public VMFunction {
53 protected:
54 ExprType_t returnType() { return EMPTY_EXPR; }
55 VMFnResult* errorResult();
56 VMFnResult* successResult();
57 protected:
58 VMEmptyResult result;
59 };
60
61 class VMIntResultFunction : public VMFunction {
62 protected:
63 ExprType_t returnType() { return INT_EXPR; }
64 VMFnResult* errorResult(int i = 0);
65 VMFnResult* successResult(int i = 0);
66 protected:
67 VMIntResult result;
68 };
69
70 class VMStringResultFunction : public VMFunction {
71 protected:
72 ExprType_t returnType() { return STRING_EXPR; }
73 VMFnResult* errorResult(const String& s = "");
74 VMFnResult* successResult(const String& s = "");
75 protected:
76 VMStringResult result;
77 };
78
79 class CoreVMFunction_message : public VMEmptyResultFunction {
80 public:
81 int minRequiredArgs() const { return 1; }
82 int maxAllowedArgs() const { return 1; }
83 bool acceptsArgType(int iArg, ExprType_t type) const;
84 ExprType_t argType(int iArg) const { return STRING_EXPR; }
85 VMFnResult* exec(VMFnArgs* args);
86 };
87
88 class CoreVMFunction_exit : public VMEmptyResultFunction {
89 public:
90 int minRequiredArgs() const { return 0; }
91 int maxAllowedArgs() const { return 0; }
92 bool acceptsArgType(int iArg, ExprType_t type) const { return false; }
93 ExprType_t argType(int iArg) const { return INT_EXPR; /*whatever*/ }
94 VMFnResult* exec(VMFnArgs* args);
95 };
96
97 class CoreVMFunction_wait : public VMEmptyResultFunction {
98 public:
99 CoreVMFunction_wait(ScriptVM* vm) : vm(vm) {}
100 int minRequiredArgs() const { return 1; }
101 int maxAllowedArgs() const { return 1; }
102 bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR; }
103 ExprType_t argType(int iArg) const { return INT_EXPR; }
104 VMFnResult* exec(VMFnArgs* args);
105 protected:
106 ScriptVM* vm;
107 };
108
109 } // namespace LinuxSampler
110
111 #endif // LS_COREVMFUNCTIONS_H

  ViewVC Help
Powered by ViewVC