xoreos  0.0.5
avm.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef AURORA_ACTIONSCRIPT_AVM_H
26 #define AURORA_ACTIONSCRIPT_AVM_H
27 
28 #include <boost/function.hpp>
29 
30 #include "src/common/ustring.h"
31 
33 #include "object.h"
34 
35 namespace Aurora {
36 
37 namespace ActionScript {
38 
40 typedef boost::function<Variable(const Common::UString &, const Common::UString &)> FSCommandFunction;
41 
43 typedef boost::function<void (const Common::UString &, ObjectPtr)> RegisterClassFunction;
44 
46 class AVM {
47 public:
48  AVM();
49 
54 
62  void fsCommand(const Common::UString &name, const Common::UString &value);
63 
64  void storeRegister(Variable value, byte index);
65  Variable getRegister(byte index);
66 
68  bool hasVariable(const Common::UString &name);
70  void setVariable(const Common::UString &name, Variable value);
72 
74  std::vector<Variable> arguments = std::vector<Variable>());
75 
76  void setStopFlag();
77  bool getStopFlag();
78 
79  void setReturnValue(Variable returnValue = Variable());
81 
82 private:
84 
87 
88  std::vector<Variable> _registers;
89  std::map<Common::UString, Variable> _variables;
90 
91  bool _stopFlag;
93 };
94 
95 } // End of namespace ActionScript
96 
97 } // End of namespace Aurora
98 
99 #endif // AURORA_ACTIONSCRIPT_AVM_H
RegisterClassFunction _registerClass
Definition: avm.h:85
void setReturnValue(Variable returnValue=Variable())
Definition: avm.cpp:156
A class holding an UTF-8 string.
Definition: ustring.h:48
void storeRegister(Variable value, byte index)
Definition: avm.cpp:69
A variable used in the execution context.
boost::function< void(const Common::UString &, ObjectPtr)> RegisterClassFunction
Function for registering classes for widgets.
Definition: avm.h:43
Variable getVariable(const Common::UString &name)
Definition: avm.cpp:96
Variable registerClass(AVM &avm)
Definition: avm.cpp:164
void fsCommand(const Common::UString &name, const Common::UString &value)
fscommand is used for communicating with the host program.
Definition: avm.cpp:77
Variable createNewObject(const Common::UString &name, std::vector< Variable > arguments=std::vector< Variable >())
Definition: avm.cpp:107
std::map< Common::UString, Variable > _variables
Definition: avm.h:89
void setFSCommandCallback(FSCommandFunction)
Set a callback for the fscommand() function.
Definition: avm.cpp:65
boost::function< Variable(const Common::UString &, const Common::UString &)> FSCommandFunction
Function for receiving fscommand().
Definition: avm.h:40
Unicode string handling.
Abstract object which is inherited by every other class.
FSCommandFunction _fscommand
Definition: avm.h:86
An action script variable.
Definition: variable.h:44
std::vector< Variable > _registers
Definition: avm.h:88
bool hasVariable(const Common::UString &name)
Check if a specific variable exists.
Definition: avm.cpp:83
Variable getReturnValue()
Definition: avm.cpp:160
Variable getRegister(byte index)
Definition: avm.cpp:73
void setVariable(const Common::UString &name, Variable value)
Set a specific variable.
Definition: avm.cpp:92
Variable _returnValue
Definition: avm.h:92
void setRegisterClassFunction(RegisterClassFunction)
Set a callback for the Object.registerClass() function.
Definition: avm.cpp:61
uint8 byte
Definition: types.h:209
The Action script virtual machine (AVM).
Definition: avm.h:46