Skip to content

Commit

Permalink
ACTIONSCRIPT: Add classes for native and dummy functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Nostritius authored and DrMcCoy committed Aug 19, 2018
1 parent fb940a1 commit 40c5379
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/aurora/actionscript/function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,19 @@ ScriptedFunction::~ScriptedFunction() {

Variable ScriptedFunction::operator()(AVM &avm) {
_buffer.run(avm);
return Variable();
return avm.getReturnValue();
}

NativeFunction::NativeFunction(boost::function<Variable(AVM &)> function, bool preloadThisFlag, bool preloadSuperFlag)
: Function(preloadThisFlag, preloadSuperFlag), _function(function) {
}

Variable NativeFunction::operator()(AVM &avm) {
return _function(avm);
}

DummyFunction::DummyFunction() : Function(false, false) {

}

} // End of namespace ActionScript
Expand Down
19 changes: 19 additions & 0 deletions src/aurora/actionscript/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

#include <vector>

#include <boost/function.hpp>

#include "src/aurora/actionscript/variable.h"
#include "src/aurora/actionscript/asbuffer.h"

Expand Down Expand Up @@ -69,6 +71,23 @@ class ScriptedFunction : public Function {
ASBuffer _buffer;
};

class NativeFunction : public Function {
public:
NativeFunction(boost::function<Variable(AVM &)> function, bool preloadThisFlag, bool preloadSuperFlag);

Variable operator()(AVM &avm);

private:
boost::function<Variable(AVM &)> _function;
};

class DummyFunction : public Function {
public:
DummyFunction();

Variable operator()(AVM &UNUSED(avm)){ return Variable(); };
};

} // End of namespace ActionScript

} // End of namespace Aurora
Expand Down

0 comments on commit 40c5379

Please sign in to comment.