xoreos  0.0.5
function.cpp
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 #include "function.h"
26 
27 namespace Aurora {
28 
29 namespace ActionScript {
30 
31 Function::Function(bool preloadThisFlag, bool preloadSuperFlag, bool preloadRootFlag) :
32  _preloadThisFlag(preloadThisFlag), _preloadSuperFlag(preloadSuperFlag), _preloadRootFlag(preloadRootFlag) {
33 }
34 
36  return _preloadThisFlag;
37 }
38 
40  return _preloadSuperFlag;
41 }
42 
44  return _preloadRootFlag;
45 }
46 
47 ScriptedFunction::ScriptedFunction(Common::SeekableReadStream *as, std::vector<Common::UString> constants,
48  bool preloadThisFlag, bool preloadSuperFlag, bool preloadRootFlag) :
49  Function(preloadThisFlag, preloadSuperFlag, preloadRootFlag), _stream(as), _buffer(as) {
50  _buffer.setConstantPool(constants);
51 }
52 
54  delete _stream;
55 }
56 
58  _buffer.run(avm);
59  return avm.getReturnValue();
60 }
61 
62 NativeFunction::NativeFunction(boost::function<Variable(AVM &)> function, bool preloadThisFlag, bool preloadSuperFlag, bool preloadRootFlag)
63  : Function(preloadThisFlag, preloadSuperFlag, preloadRootFlag), _function(function) {
64 }
65 
67  return _function(avm);
68 }
69 
70 DummyFunction::DummyFunction() : Function(false, false, false) {
71 
72 }
73 
74 } // End of namespace ActionScript
75 
76 } // End of namespace Aurora
NativeFunction(boost::function< Variable(AVM &)> function, bool preloadThisFlag, bool preloadSuperFlag, bool preloadRootFlag)
Definition: function.cpp:62
void setConstantPool(std::vector< Common::UString > constantPool)
Definition: asbuffer.cpp:97
ScriptedFunction(Common::SeekableReadStream *as, std::vector< Common::UString > constantPool, bool preloadThisFlag, bool preloadSuperFlag, bool preloadRootFlag)
Definition: function.cpp:47
Function objects for ActionScript.
Function(bool preloadThisFlag, bool preloadSuperFlag, bool preloadRootFlag)
Definition: function.cpp:31
An action script variable.
Definition: variable.h:44
boost::function< Variable(AVM &)> _function
Definition: function.h:84
Common::SeekableReadStream * _stream
Definition: function.h:73
Variable getReturnValue()
Definition: avm.cpp:160
Interface for a seekable & readable data stream.
Definition: readstream.h:265
The Action script virtual machine (AVM).
Definition: avm.h:46