xoreos  0.0.5
function.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_FUNCTION_H
26 #define AURORA_ACTIONSCRIPT_FUNCTION_H
27 
28 #include <vector>
29 
30 #include <boost/function.hpp>
31 
34 
35 namespace Aurora {
36 
37 namespace ActionScript {
38 
39 class Function;
40 
41 typedef boost::shared_ptr<Function> FunctionPtr;
42 
43 class Function : public Object {
44 public:
45  Function(bool preloadThisFlag, bool preloadSuperFlag, bool preloadRootFlag);
46 
47  bool getPreloadThisFlag();
48  bool getPreloadSuperFlag();
49  bool getPreloadRootFlag();
50 
51  virtual Variable operator()(AVM &avm) = 0;
52 
53 private:
57 };
58 
59 class ScriptedFunction : public Function {
60 public:
63  std::vector<Common::UString> constantPool,
64  bool preloadThisFlag,
65  bool preloadSuperFlag,
66  bool preloadRootFlag
67  );
69 
70  Variable operator()(AVM &avm);
71 
72 private:
75 };
76 
77 class NativeFunction : public Function {
78 public:
79  NativeFunction(boost::function<Variable(AVM &)> function, bool preloadThisFlag, bool preloadSuperFlag, bool preloadRootFlag);
80 
81  Variable operator()(AVM &avm);
82 
83 private:
84  boost::function<Variable(AVM &)> _function;
85 };
86 
87 class DummyFunction : public Function {
88 public:
89  DummyFunction();
90 
91  Variable operator()(AVM &UNUSED(avm)){ return Variable(); };
92 };
93 
94 } // End of namespace ActionScript
95 
96 } // End of namespace Aurora
97 
98 #endif // AURORA_ACTIONSCRIPT_FUNCTION_H
A variable used in the execution context.
Buffer for handling actionscript byte code.
NativeFunction(boost::function< Variable(AVM &)> function, bool preloadThisFlag, bool preloadSuperFlag, bool preloadRootFlag)
Definition: function.cpp:62
Variable operator()(AVM &avm)
Definition: function.h:91
#define UNUSED(x)
Definition: system.h:170
ScriptedFunction(Common::SeekableReadStream *as, std::vector< Common::UString > constantPool, bool preloadThisFlag, bool preloadSuperFlag, bool preloadRootFlag)
Definition: function.cpp:47
Function(bool preloadThisFlag, bool preloadSuperFlag, bool preloadRootFlag)
Definition: function.cpp:31
boost::shared_ptr< Function > FunctionPtr
Definition: function.h:39
An action script variable.
Definition: variable.h:44
virtual Variable operator()(AVM &avm)=0
boost::function< Variable(AVM &)> _function
Definition: function.h:84
Common::SeekableReadStream * _stream
Definition: function.h:73
Interface for a seekable & readable data stream.
Definition: readstream.h:265
The Action script virtual machine (AVM).
Definition: avm.h:46