Sirikata
|
#include <JSObjectScript.hpp>
Classes | |
struct | EvalContext |
struct | ScopedEvalContext |
Public Member Functions | |
JSObjectScript (JSObjectScriptManager *jMan, OH::Storage *storage, OH::PersistedObjectSet *persisted_set, const UUID &internal_id, JSCtx *ctx) | |
virtual | ~JSObjectScript () |
v8::Handle< v8::Value > | debug_fileWrite (String &strToWrite, String &filename) |
v8::Handle< v8::Value > | debug_fileRead (String &filename) |
v8::Handle< v8::Value > | executeInSandbox (JSContextStruct *jscont, v8::Handle< v8::Function > funcToCall, int argc, v8::Handle< v8::Value > *argv) |
v8::Local< v8::Object > | createContext (JSPresenceStruct *jspres, const SpaceObjectReference &canSendTo, uint32 capNum, JSContextStruct *&internalContextField, JSContextStruct *creator) |
void | initialize (const String &args, const String &script, int32 maxResThresh) |
virtual void | start () |
virtual void | stop () |
void | print (const String &str) |
Print the given string to the current output. | |
v8::Handle< v8::Value > | import (const String &filename, bool isJS) |
Import a file, executing its contents in scope of most recent evaluation stack frame. | |
void | shimImportAndEvalScript (JSContextStruct *jscont, const String &toEval) |
Adds jscont to evalStack. | |
v8::Handle< v8::Value > | require (const String &filename, bool isJS) |
Require a file, executing its contents in the root object's scope iff it has not yet been imported. | |
virtual void | registerContextForClear (JSContextStruct *jscont) |
v8::Handle< v8::Value > | storageBeginTransaction (JSContextStruct *jscont) |
FIXME: instead of posting jscont through, instead post its id through. | |
v8::Handle< v8::Value > | storageCommit (JSContextStruct *jscont, v8::Handle< v8::Function > cb) |
v8::Handle< v8::Value > | storageWrite (const OH::Storage::Key &key, const String &toWrite, v8::Handle< v8::Function > cb, JSContextStruct *jscont) |
v8::Handle< v8::Value > | storageRead (const OH::Storage::Key &key, v8::Handle< v8::Function > cb, JSContextStruct *jscont) |
v8::Handle< v8::Value > | storageErase (const OH::Storage::Key &key, v8::Handle< v8::Function > cb, JSContextStruct *jscont) |
v8::Handle< v8::Value > | storageRangeRead (const OH::Storage::Key &start, const OH::Storage::Key &finish, v8::Handle< v8::Function > cb, JSContextStruct *jscont) |
v8::Handle< v8::Value > | storageRangeErase (const OH::Storage::Key &start, const OH::Storage::Key &finish, v8::Handle< v8::Function > cb, JSContextStruct *jscont) |
v8::Handle< v8::Value > | storageCount (const OH::Storage::Key &start, const OH::Storage::Key &finish, v8::Handle< v8::Function > cb, JSContextStruct *jscont) |
v8::Handle< v8::Value > | setRestoreScript (JSContextStruct *jscont, const String &script, v8::Handle< v8::Function > cb) |
v8::Handle< v8::Value > | pushEvalContextScopeDirectory (const String &newDir) |
v8::Handle< v8::Value > | popEvalContextScopeDirectory () |
bool | checkCurCtxtHasCapability (JSPresenceStruct *jspres, Capabilities::Caps whatCap) |
Returns true if context eval stack is not empty and if the top context on the stack allows operation associated with whatCap on jspres. | |
v8::Handle< v8::Value > | checkResources () |
We want to ensure that no sandboxes have while(1) loops. | |
bool | checkResourcesCPP () |
Handle< v8::Context > | context () |
bool | isRootContext (JSContextStruct *jscont) |
JSObjectScriptManager * | manager () const |
v8::Local< v8::Function > | functionValue (const String &em_script_str) |
v8::Handle< v8::Value > | invokeCallback (JSContextStruct *ctx, v8::Handle< v8::Object > *target, v8::Handle< v8::Function > &cb, int argc, v8::Handle< v8::Value > argv[]) |
v8::Handle< v8::Value > | invokeCallback (JSContextStruct *ctx, v8::Handle< v8::Function > &cb, int argc, v8::Handle< v8::Value > argv[]) |
v8::Handle< v8::Value > | invokeCallback (JSContextStruct *ctx, v8::Handle< v8::Function > &cb) |
virtual void | postCallbackChecks () |
JSContextStruct * | rootContext () const |
bool | isStopped () |
Returns true if stop has ever been called on JSObjectScript. | |
v8::Handle< v8::Value > | emersonCompileString (const String &toCompile) |
Runs the string toCompile through the emerson parser. | |
v8::Handle< v8::Value > | evalInGlobal (const String &contents, v8::ScriptOrigin *em_script_name, JSContextStruct *jscs) |
Eval a string, executing its contents in the root object's scope. | |
Public Attributes | |
JSCtx * | mCtx |
Protected Types | |
typedef std::map< uint32, std::set< String > > | ImportedFileMap |
typedef ImportedFileMap::iterator | ImportedFileMapIter |
typedef std::map< uint32, SuspendableVec > | ContIDToSuspMap |
Protected Member Functions | |
void | preEvalOps () |
Each time before we call an eval function into v8, we first call preEvalOps. | |
void | postEvalOps () |
Decrements mNestedEvalCounter. | |
bool | resolveImport (const String &filename, bool isJS, boost::filesystem::path *full_file_out, boost::filesystem::path *base_path_out) |
bool | resolveImport (const String &filename, boost::filesystem::path *full_file_out, boost::filesystem::path *base_path_out) |
v8::Handle< v8::Value > | absoluteImport (const boost::filesystem::path &full_filename, const boost::filesystem::path &full_base_dir, bool isJS) |
void | printStackFrame (std::stringstream &, v8::Local< v8::StackFrame >) |
void | storageCommitCallback (JSContextStruct *jscont, v8::Persistent< v8::Function > cb, OH::Storage::Result result, OH::Storage::ReadSet *rs, Liveness::Token objAlive, Liveness::Token ctxAlive) |
void | storageCountCallback (JSContextStruct *jscont, v8::Persistent< v8::Function > cb, OH::Storage::Result result, int32 count, Liveness::Token objAlive, Liveness::Token ctxAlive) |
void | iSetRestoreScriptCallback (JSContextStruct *jscont, v8::Persistent< v8::Function > cb, bool success, Liveness::Token, Liveness::Token ctxAlive) |
void | iStop (Liveness::Token alive, bool letDie) |
Protected Attributes | |
UUID | mInternalID |
int32 | mResourceCounter |
int32 | mNestedEvalCounter |
We want to keep track of whether we're in an eval loop or not. | |
uint32 | contIDTracker |
std::map< uint32, JSContextStruct * > | mContStructMap |
std::stack< EvalContext > | mEvalContextStack |
ImportedFileMap | mImportedFiles |
JSContextStruct * | mContext |
ContIDToSuspMap | toFixup |
JSObjectScriptManager * | mManager |
OH::Storage * | mStorage |
OH::PersistedObjectSet * | mPersistedObjectSet |
int32 | maxResourceThresh |
If we execute this number of cycles in one pass of event loop, throw a resource error. | |
bool | stopCalled |
Will be true after stop method is called. | |
Private Member Functions | |
v8::Handle< v8::Value > | compileFunctionInContext (v8::Handle< v8::Function > &cb) |
void | printExceptionToScript (const String &exc) |
v8::Handle< v8::Value > | protectedEval (const String &em_script_str, v8::ScriptOrigin *em_script_name, const EvalContext &new_ctx, bool return_exc=false, const String &cache_path="", bool isJS=false) |
v8::Handle< v8::Value > | internalEval (const String &em_script_str, v8::ScriptOrigin *em_script_name, bool is_emerson, bool return_exc=false, const String &cache_path="") |
v8::Handle< v8::Context > | getCurrentV8Context () |
void | eStorageBeginTransaction (JSContextStruct *jscont, Liveness::Token objAlive, Liveness::Token ctxAlive) |
void | eStorageCommit (JSContextStruct *jscont, v8::Persistent< v8::Function > cb, Liveness::Token objAlive, Liveness::Token ctxAlive) |
void | iStorageCommitCallback (JSContextStruct *jscont, v8::Persistent< v8::Function > cb, OH::Storage::Result result, OH::Storage::ReadSet *rs, Liveness::Token objAlive, Liveness::Token ctxAlive) |
void | iStorageCountCallback (JSContextStruct *jscont, v8::Persistent< v8::Function > cb, OH::Storage::Result result, int32 count, Liveness::Token objAlive, Liveness::Token ctxAlive) |
void | eStorageErase (const OH::Storage::Key &key, v8::Persistent< v8::Function > cb, JSContextStruct *jscont, Liveness::Token objAlive, Liveness::Token ctxAlive) |
void | eStorageWrite (const OH::Storage::Key &key, const String &toWrite, v8::Persistent< v8::Function > cb, JSContextStruct *jscont, Liveness::Token objAlive, Liveness::Token ctxAlive) |
void | eStorageRead (const OH::Storage::Key &key, v8::Persistent< v8::Function > cb, JSContextStruct *jscont, Liveness::Token objAlive, Liveness::Token ctxAlive) |
void | eStorageRangeRead (const OH::Storage::Key &start, const OH::Storage::Key &finish, v8::Persistent< v8::Function > cb, JSContextStruct *jscont, Liveness::Token objAlive, Liveness::Token ctxAlive) |
void | eStorageRangeErase (const OH::Storage::Key &start, const OH::Storage::Key &finish, v8::Persistent< v8::Function > cb, JSContextStruct *jscont, Liveness::Token objAlive, Liveness::Token ctxAlive) |
void | eStorageCount (const OH::Storage::Key &start, const OH::Storage::Key &finish, v8::Persistent< v8::Function > cb, JSContextStruct *jscont, Liveness::Token objAlive, Liveness::Token ctxAlive) |
void | eSetRestoreScript (JSContextStruct *jscont, const String &script, v8::Persistent< v8::Function > cb, Liveness::Token objAlive, Liveness::Token ctxAlive) |
void | iDelContext (JSContextStruct *toDel, Liveness::Token ctxLT) |
Friends | |
class | ScopedEvalContext |
typedef std::map<uint32, SuspendableVec> Sirikata::JS::JSObjectScript::ContIDToSuspMap [protected] |
typedef std::map<uint32,std::set<String> > Sirikata::JS::JSObjectScript::ImportedFileMap [protected] |
typedef ImportedFileMap::iterator Sirikata::JS::JSObjectScript::ImportedFileMapIter [protected] |
Sirikata::JS::JSObjectScript::JSObjectScript | ( | JSObjectScriptManager * | jMan, |
OH::Storage * | storage, | ||
OH::PersistedObjectSet * | persisted_set, | ||
const UUID & | internal_id, | ||
JSCtx * | ctx | ||
) |
Sirikata::JS::JSObjectScript::~JSObjectScript | ( | ) | [virtual] |
References Sirikata::Liveness::letDie(), Sirikata::Liveness::livenessAlive(), and mCtx.
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::absoluteImport | ( | const boost::filesystem::path & | full_filename, |
const boost::filesystem::path & | full_base_dir, | ||
bool | isJS | ||
) | [protected] |
References checkResourcesCPP(), Sirikata::JS::JSObjectScript::EvalContext::currentScriptBaseDir, Sirikata::JS::JSObjectScript::EvalContext::currentScriptDir, Sirikata::Logging::detailed, Sirikata::Path::DIR_TEMP, Sirikata::Logging::error, Sirikata::Path::Get(), Sirikata::JS::JSContextStruct::getContextID(), Sirikata::JS::JSObjectScript::EvalContext::getFullRelativeScriptDir(), JSLOG, JSSCRIPT_SERIAL_CHECK, Sirikata::JS::JSContextStruct::mContext, mEvalContextStack, mImportedFiles, and protectedEval().
bool Sirikata::JS::JSObjectScript::checkCurCtxtHasCapability | ( | JSPresenceStruct * | jspres, |
Capabilities::Caps | whatCap | ||
) |
Returns true if context eval stack is not empty and if the top context on the stack allows operation associated with whatCap on jspres.
Returns false otherwise.
References Sirikata::JS::JSContextStruct::getAssociatedPresenceStruct(), Sirikata::JS::JSContextStruct::getCapNum(), Sirikata::JS::Capabilities::givesCap(), JSSCRIPT_SERIAL_CHECK, and mEvalContextStack.
Referenced by Sirikata::JS::JSSystemStruct::checkCurCtxtHasCapability().
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::checkResources | ( | ) |
We want to ensure that no sandboxes have while(1) loops.
Roughly, the way we do this is that our compiler inserts a lot of calls to checkResources. If checkResources returns false, then we throw an uncatch-able error.
Using a stupid implementation for checkResources. Every time that we call eval, and are not currently executing code/handling an event, then we set mResourceCounter to zero. Every interleaving call to checkResources increments mResourceCounter. If mResourceCounter ever gets above a threshold value, the next checkResources call returns false, causing the script to throw an uncatchable error.
References checkResourcesCPP(), and JSSCRIPT_SERIAL_CHECK.
Referenced by Sirikata::JS::JSGlobal::checkResources().
bool Sirikata::JS::JSObjectScript::checkResourcesCPP | ( | ) |
References JSSCRIPT_SERIAL_CHECK, maxResourceThresh, and mResourceCounter.
Referenced by absoluteImport(), and checkResources().
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::compileFunctionInContext | ( | v8::Handle< v8::Function > & | cb | ) | [private] |
Handle<v8::Context> Sirikata::JS::JSObjectScript::context | ( | ) | [inline] |
Referenced by Sirikata::JS::EmersonScript::iInvokeInvokable().
v8::Local< v8::Object > Sirikata::JS::JSObjectScript::createContext | ( | JSPresenceStruct * | jspres, |
const SpaceObjectReference & | canSendTo, | ||
uint32 | capNum, | ||
JSContextStruct *& | internalContextField, | ||
JSContextStruct * | creator | ||
) |
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::debug_fileRead | ( | String & | filename | ) |
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::debug_fileWrite | ( | String & | strToWrite, |
String & | filename | ||
) |
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::emersonCompileString | ( | const String & | toCompile | ) |
Runs the string toCompile through the emerson parser.
If fails to compile, then returns syntax error.
References EmersonUtil::emerson_compile(), emerson_init(), Sirikata::Logging::error, Sirikata::Logging::insane, JSLOG, and JSSCRIPT_SERIAL_CHECK.
Referenced by Sirikata::JS::JSContextStruct::emersonCompileString().
void Sirikata::JS::JSObjectScript::eSetRestoreScript | ( | JSContextStruct * | jscont, |
const String & | script, | ||
v8::Persistent< v8::Function > | cb, | ||
Liveness::Token | objAlive, | ||
Liveness::Token | ctxAlive | ||
) | [private] |
void Sirikata::JS::JSObjectScript::eStorageBeginTransaction | ( | JSContextStruct * | jscont, |
Liveness::Token | objAlive, | ||
Liveness::Token | ctxAlive | ||
) | [private] |
References Sirikata::OH::Storage::beginTransaction(), mInternalID, and mStorage.
Referenced by storageBeginTransaction().
void Sirikata::JS::JSObjectScript::eStorageCommit | ( | JSContextStruct * | jscont, |
v8::Persistent< v8::Function > | cb, | ||
Liveness::Token | objAlive, | ||
Liveness::Token | ctxAlive | ||
) | [private] |
References Sirikata::OH::Storage::commitTransaction(), Sirikata::Liveness::livenessToken(), mInternalID, mStorage, and storageCommitCallback().
Referenced by storageCommit().
void Sirikata::JS::JSObjectScript::eStorageCount | ( | const OH::Storage::Key & | start, |
const OH::Storage::Key & | finish, | ||
v8::Persistent< v8::Function > | cb, | ||
JSContextStruct * | jscont, | ||
Liveness::Token | objAlive, | ||
Liveness::Token | ctxAlive | ||
) | [private] |
References Sirikata::OH::Storage::count(), Sirikata::Liveness::livenessToken(), mInternalID, mStorage, and storageCountCallback().
Referenced by storageCount().
void Sirikata::JS::JSObjectScript::eStorageErase | ( | const OH::Storage::Key & | key, |
v8::Persistent< v8::Function > | cb, | ||
JSContextStruct * | jscont, | ||
Liveness::Token | objAlive, | ||
Liveness::Token | ctxAlive | ||
) | [private] |
References Sirikata::OH::Storage::erase(), Sirikata::Liveness::livenessToken(), mInternalID, mStorage, and storageCommitCallback().
Referenced by storageErase().
void Sirikata::JS::JSObjectScript::eStorageRangeErase | ( | const OH::Storage::Key & | start, |
const OH::Storage::Key & | finish, | ||
v8::Persistent< v8::Function > | cb, | ||
JSContextStruct * | jscont, | ||
Liveness::Token | objAlive, | ||
Liveness::Token | ctxAlive | ||
) | [private] |
References Sirikata::Liveness::livenessToken(), mInternalID, mStorage, Sirikata::OH::Storage::rangeErase(), and storageCommitCallback().
Referenced by storageRangeErase().
void Sirikata::JS::JSObjectScript::eStorageRangeRead | ( | const OH::Storage::Key & | start, |
const OH::Storage::Key & | finish, | ||
v8::Persistent< v8::Function > | cb, | ||
JSContextStruct * | jscont, | ||
Liveness::Token | objAlive, | ||
Liveness::Token | ctxAlive | ||
) | [private] |
References Sirikata::Liveness::livenessToken(), mInternalID, mStorage, Sirikata::OH::Storage::rangeRead(), and storageCommitCallback().
Referenced by storageRangeRead().
void Sirikata::JS::JSObjectScript::eStorageRead | ( | const OH::Storage::Key & | key, |
v8::Persistent< v8::Function > | cb, | ||
JSContextStruct * | jscont, | ||
Liveness::Token | objAlive, | ||
Liveness::Token | ctxAlive | ||
) | [private] |
References Sirikata::Liveness::livenessToken(), mInternalID, mStorage, Sirikata::OH::Storage::read(), and storageCommitCallback().
Referenced by storageRead().
void Sirikata::JS::JSObjectScript::eStorageWrite | ( | const OH::Storage::Key & | key, |
const String & | toWrite, | ||
v8::Persistent< v8::Function > | cb, | ||
JSContextStruct * | jscont, | ||
Liveness::Token | objAlive, | ||
Liveness::Token | ctxAlive | ||
) | [private] |
References Sirikata::Liveness::livenessToken(), mInternalID, mStorage, storageCommitCallback(), and Sirikata::OH::Storage::write().
Referenced by storageWrite().
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::evalInGlobal | ( | const String & | contents, |
v8::ScriptOrigin * | em_script_name, | ||
JSContextStruct * | jscs | ||
) |
Eval a string, executing its contents in the root object's scope.
References JSSCRIPT_SERIAL_CHECK, mEvalContextStack, and protectedEval().
Referenced by Sirikata::JS::JSContextStruct::struct_evalInGlobal().
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::executeInSandbox | ( | JSContextStruct * | jscont, |
v8::Handle< v8::Function > | funcToCall, | ||
int | argc, | ||
v8::Handle< v8::Value > * | argv | ||
) |
v8::Local< v8::Function > Sirikata::JS::JSObjectScript::functionValue | ( | const String & | em_script_str | ) |
References internalEval(), and JSSCRIPT_SERIAL_CHECK.
Referenced by Sirikata::JS::JSSerializer::deserializeFieldValue(), and Sirikata::JS::JSSerializer::deserializeObject().
v8::Handle< v8::Context > Sirikata::JS::JSObjectScript::getCurrentV8Context | ( | ) | [private] |
References Sirikata::Logging::error, JSLOG, JSSCRIPT_SERIAL_CHECK, Sirikata::JS::JSContextStruct::mContext, mContext, and mEvalContextStack.
Referenced by compileFunctionInContext(), and internalEval().
void Sirikata::JS::JSObjectScript::iDelContext | ( | JSContextStruct * | toDel, |
Liveness::Token | ctxLT | ||
) | [private] |
References Sirikata::Logging::error, Sirikata::JS::JSSuspendable::getIsCleared(), and JSLOG.
Referenced by iStop().
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::import | ( | const String & | filename, |
bool | isJS | ||
) |
Import a file, executing its contents in scope of most recent evaluation stack frame.
Should not call import directly unless we are positive that we are inside a valid mEvalContext.
References absoluteImport(), Sirikata::Logging::detailed, JSLOG, JSSCRIPT_SERIAL_CHECK, and resolveImport().
Referenced by Sirikata::JS::JSContextStruct::struct_import().
void Sirikata::JS::JSObjectScript::initialize | ( | const String & | args, |
const String & | script, | ||
int32 | maxResThresh | ||
) |
References contIDTracker, Sirikata::Logging::detailed, Sirikata::Logging::error, Sirikata::JS::FromV8String(), Sirikata::JS::Capabilities::getFullCapabilities(), Sirikata::OptionSet::getOptions(), JSLOG, JSSCRIPT_SERIAL_CHECK, maxResourceThresh, Sirikata::JS::JSContextStruct::mContext, mContext, Sirikata::JS::JSCtx::mContextGlobalTemplate, mContStructMap, mCtx, mEvalContextStack, Sirikata::JS::JSCtx::mIsolate, Sirikata::SpaceObjectReference::null(), Sirikata::OptionSet::parse(), protectedEval(), and Sirikata::JS::JSContextStruct::struct_setScript().
Referenced by Sirikata::JS::JSObjectScriptManager::createHeadless(), and Sirikata::JS::EmersonScript::EmersonScript().
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::internalEval | ( | const String & | em_script_str, |
v8::ScriptOrigin * | em_script_name, | ||
bool | is_emerson, | ||
bool | return_exc = false , |
||
const String & | cache_path = "" |
||
) | [private] |
References Sirikata::Logging::detailed, Sirikata::Path::DIR_TEMP, EmersonUtil::emerson_compile(), emerson_init(), Sirikata::Logging::error, Sirikata::JS::FromV8String(), Sirikata::Path::Get(), getCurrentV8Context(), Sirikata::Path::GetTempFilename(), Sirikata::Logging::insane, JSLOG, JSSCRIPT_SERIAL_CHECK, postEvalOps(), preEvalOps(), and Sirikata::JS::printException().
Referenced by compileFunctionInContext(), functionValue(), protectedEval(), and shimImportAndEvalScript().
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::invokeCallback | ( | JSContextStruct * | ctx, |
v8::Handle< v8::Function > & | cb, | ||
int | argc, | ||
v8::Handle< v8::Value > | argv[] | ||
) |
References invokeCallback(), JSSCRIPT_SERIAL_CHECK, mCtx, and Sirikata::JS::JSCtx::mIsolate.
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::invokeCallback | ( | JSContextStruct * | ctx, |
v8::Handle< v8::Function > & | cb | ||
) |
References invokeCallback(), JSSCRIPT_SERIAL_CHECK, mCtx, and Sirikata::JS::JSCtx::mIsolate.
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::invokeCallback | ( | JSContextStruct * | ctx, |
v8::Handle< v8::Object > * | target, | ||
v8::Handle< v8::Function > & | cb, | ||
int | argc, | ||
v8::Handle< v8::Value > | argv[] | ||
) |
References JSSCRIPT_SERIAL_CHECK, Sirikata::JS::JSContextStruct::mContext, mCtx, mEvalContextStack, Sirikata::JS::JSCtx::mIsolate, postEvalOps(), preEvalOps(), and printExceptionToScript().
Referenced by Sirikata::JS::EmersonScript::fireProxEvent(), Sirikata::JS::EmersonScript::handlePresCallback(), Sirikata::JS::JSContextStruct::httpFail(), Sirikata::JS::JSContextStruct::httpSuccess(), Sirikata::JS::JSPositionListener::iFinishLoadMesh(), Sirikata::JS::EmersonScript::iHandleScriptCommRead(), Sirikata::JS::EmersonScript::iInvokeInvokable(), invokeCallback(), Sirikata::JS::EmersonScript::invokeCallbackInContext(), iSetRestoreScriptCallback(), iStorageCommitCallback(), iStorageCountCallback(), and Sirikata::JS::EmersonScript::processSandboxMessage().
void Sirikata::JS::JSObjectScript::iSetRestoreScriptCallback | ( | JSContextStruct * | jscont, |
v8::Persistent< v8::Function > | cb, | ||
bool | success, | ||
Liveness::Token | objAlive, | ||
Liveness::Token | ctxAlive | ||
) | [protected] |
bool Sirikata::JS::JSObjectScript::isRootContext | ( | JSContextStruct * | jscont | ) |
References mContext.
Referenced by Sirikata::JS::JSContextStruct::struct_setScript().
bool Sirikata::JS::JSObjectScript::isStopped | ( | ) |
Returns true if stop has ever been called on JSObjectScript.
References stopCalled.
Referenced by Sirikata::JS::EmersonScript::handlePresCallback(), Sirikata::JS::EmersonScript::handleScriptCommUnreliable(), Sirikata::JS::JSContextStruct::httpFail(), Sirikata::JS::JSContextStruct::httpSuccess(), Sirikata::JS::JSPositionListener::iFinishLoadMesh(), Sirikata::JS::EmersonScript::iHandleScriptCommRead(), Sirikata::JS::EmersonScript::iHandleScriptCommUnreliable(), iSetRestoreScriptCallback(), Sirikata::JS::EmersonScript::notifyProximateGone(), storageCommitCallback(), storageCountCallback(), and Sirikata::JS::EmersonScript::~EmersonScript().
void Sirikata::JS::JSObjectScript::iStop | ( | Liveness::Token | alive, |
bool | letDie | ||
) | [protected] |
Reimplemented in Sirikata::JS::EmersonScript.
References Sirikata::JS::JSContextStruct::clear(), iDelContext(), JSSCRIPT_SERIAL_CHECK, Sirikata::Liveness::letDie(), Sirikata::Liveness::livenessAlive(), Sirikata::Liveness::livenessToken(), mContext, mCtx, Sirikata::JS::JSCtx::mIsolate, Sirikata::JS::JSCtx::objStrand, Sirikata::JS::JSCtx::stop(), and stopCalled.
Referenced by stop().
void Sirikata::JS::JSObjectScript::iStorageCommitCallback | ( | JSContextStruct * | jscont, |
v8::Persistent< v8::Function > | cb, | ||
OH::Storage::Result | result, | ||
OH::Storage::ReadSet * | rs, | ||
Liveness::Token | objAlive, | ||
Liveness::Token | ctxAlive | ||
) | [private] |
References Sirikata::JS::JSCtx::initialized(), invokeCallback(), JSLOG, JSSCRIPT_SERIAL_CHECK, Sirikata::JS::JSContextStruct::mContext, mContext, mCtx, Sirikata::JS::JSCtx::mIsolate, postCallbackChecks(), Sirikata::JS::JSCtx::stopped(), Sirikata::JS::strToUint16Str(), Sirikata::OH::Storage::SUCCESS, and Sirikata::Logging::warn.
Referenced by storageCommitCallback().
void Sirikata::JS::JSObjectScript::iStorageCountCallback | ( | JSContextStruct * | jscont, |
v8::Persistent< v8::Function > | cb, | ||
OH::Storage::Result | result, | ||
int32 | count, | ||
Liveness::Token | objAlive, | ||
Liveness::Token | ctxAlive | ||
) | [private] |
References Sirikata::JS::JSCtx::initialized(), invokeCallback(), JSLOG, JSSCRIPT_SERIAL_CHECK, Sirikata::JS::JSContextStruct::mContext, mContext, mCtx, Sirikata::JS::JSCtx::mIsolate, postCallbackChecks(), Sirikata::JS::JSCtx::stopped(), Sirikata::OH::Storage::SUCCESS, and Sirikata::Logging::warn.
Referenced by storageCountCallback().
JSObjectScriptManager* Sirikata::JS::JSObjectScript::manager | ( | ) | const [inline] |
Reimplemented in Sirikata::JS::EmersonScript.
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::popEvalContextScopeDirectory | ( | ) |
References Sirikata::Logging::detailed, JSLOG, JSSCRIPT_SERIAL_CHECK, mEvalContextStack, and V8_EXCEPTION_CSTR.
Referenced by Sirikata::JS::JSContextStruct::popEvalContextScopeDirectory().
virtual void Sirikata::JS::JSObjectScript::postCallbackChecks | ( | ) | [inline, virtual] |
void Sirikata::JS::JSObjectScript::postEvalOps | ( | ) | [protected] |
Decrements mNestedEvalCounter.
Used for bookkeeping so that we can keep track of what level of eval nesting we're in.
References JSSCRIPT_SERIAL_CHECK, and mNestedEvalCounter.
Referenced by executeInSandbox(), internalEval(), invokeCallback(), and printExceptionToScript().
void Sirikata::JS::JSObjectScript::preEvalOps | ( | ) | [protected] |
Each time before we call an eval function into v8, we first call preEvalOps.
preEvalOps sets up mResourceCounter and mNestedEvalCounter before calling eval/run/call. (It increments mNestedEvalCounter and if this eval isn't called from inside another eval, then we set mResourceCounter to zero.)
References Sirikata::Logging::error, JSLOG, JSSCRIPT_SERIAL_CHECK, mNestedEvalCounter, and mResourceCounter.
Referenced by executeInSandbox(), internalEval(), invokeCallback(), and printExceptionToScript().
void Sirikata::JS::JSObjectScript::print | ( | const String & | str | ) |
Print the given string to the current output.
References JSSCRIPT_SERIAL_CHECK, and mEvalContextStack.
Referenced by Sirikata::JS::JSContextStruct::jsscript_print().
void Sirikata::JS::JSObjectScript::printExceptionToScript | ( | const String & | exc | ) | [private] |
void Sirikata::JS::JSObjectScript::printStackFrame | ( | std::stringstream & | , |
v8::Local< v8::StackFrame > | |||
) | [protected] |
Reimplemented in Sirikata::JS::EmersonScript.
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::protectedEval | ( | const String & | em_script_str, |
v8::ScriptOrigin * | em_script_name, | ||
const EvalContext & | new_ctx, | ||
bool | return_exc = false , |
||
const String & | cache_path = "" , |
||
bool | isJS = false |
||
) | [private] |
References internalEval(), and JSSCRIPT_SERIAL_CHECK.
Referenced by absoluteImport(), evalInGlobal(), and initialize().
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::pushEvalContextScopeDirectory | ( | const String & | newDir | ) |
References Sirikata::JS::JSObjectScript::EvalContext::currentScriptDir, Sirikata::Logging::detailed, JS_PLUGINS_DIR, JS_SCRIPTS_DIR, JSLOG, JSSCRIPT_SERIAL_CHECK, mEvalContextStack, Sirikata::Path::Placeholders::RESOURCE(), Sirikata::Path::SubstitutePlaceholders(), and V8_EXCEPTION_CSTR.
Referenced by Sirikata::JS::JSContextStruct::pushEvalContextScopeDirectory().
void Sirikata::JS::JSObjectScript::registerContextForClear | ( | JSContextStruct * | jscont | ) | [virtual] |
Reimplemented in Sirikata::JS::EmersonScript.
References Sirikata::JS::JSContextStruct::finishClear(), and JSSCRIPT_SERIAL_CHECK.
Referenced by Sirikata::JS::JSContextStruct::clear().
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::require | ( | const String & | filename, |
bool | isJS | ||
) |
Require a file, executing its contents in the root object's scope iff it has not yet been imported.
References absoluteImport(), Sirikata::Logging::detailed, Sirikata::Logging::error, Sirikata::JS::JSContextStruct::getContextID(), JSLOG, JSSCRIPT_SERIAL_CHECK, mEvalContextStack, mImportedFiles, and resolveImport().
Referenced by Sirikata::JS::JSContextStruct::struct_require().
bool Sirikata::JS::JSObjectScript::resolveImport | ( | const String & | filename, |
boost::filesystem::path * | full_file_out, | ||
boost::filesystem::path * | base_path_out | ||
) | [protected] |
bool Sirikata::JS::JSObjectScript::resolveImport | ( | const String & | filename, |
bool | isJS, | ||
boost::filesystem::path * | full_file_out, | ||
boost::filesystem::path * | base_path_out | ||
) | [protected] |
JSContextStruct* Sirikata::JS::JSObjectScript::rootContext | ( | ) | const [inline] |
Reimplemented in Sirikata::JS::EmersonScript.
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::setRestoreScript | ( | JSContextStruct * | jscont, |
const String & | script, | ||
v8::Handle< v8::Function > | cb | ||
) |
References eSetRestoreScript(), JSSCRIPT_SERIAL_CHECK, Sirikata::Liveness::livenessToken(), Sirikata::JS::JSCtx::mainStrand, mCtx, mPersistedObjectSet, and Sirikata::Network::IOStrand::post().
Referenced by Sirikata::JS::EmersonScript::killScript(), and Sirikata::JS::JSContextStruct::setRestoreScript().
void Sirikata::JS::JSObjectScript::shimImportAndEvalScript | ( | JSContextStruct * | jscont, |
const String & | toEval | ||
) |
Adds jscont to evalStack.
Imports shim files and evals toEval. Pops jscont after this.
References internalEval(), JSSCRIPT_SERIAL_CHECK, and mEvalContextStack.
Referenced by Sirikata::JS::JSContextStruct::createContextObjects().
void Sirikata::JS::JSObjectScript::start | ( | ) | [virtual] |
Reimplemented from Sirikata::ObjectScript.
Reimplemented in Sirikata::JS::EmersonScript.
void Sirikata::JS::JSObjectScript::stop | ( | ) | [virtual] |
Reimplemented from Sirikata::ObjectScript.
Reimplemented in Sirikata::JS::EmersonScript.
References iStop(), Sirikata::Liveness::livenessToken(), mCtx, and Sirikata::JS::JSCtx::objStrand.
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::storageBeginTransaction | ( | JSContextStruct * | jscont | ) |
FIXME: instead of posting jscont through, instead post its id through.
That way, it can't get deleted out from under us.
References eStorageBeginTransaction(), JSSCRIPT_SERIAL_CHECK, Sirikata::Liveness::livenessToken(), Sirikata::JS::JSCtx::mainStrand, mCtx, mStorage, and Sirikata::Network::IOStrand::post().
Referenced by Sirikata::JS::JSContextStruct::storageBeginTransaction().
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::storageCommit | ( | JSContextStruct * | jscont, |
v8::Handle< v8::Function > | cb | ||
) |
void Sirikata::JS::JSObjectScript::storageCommitCallback | ( | JSContextStruct * | jscont, |
v8::Persistent< v8::Function > | cb, | ||
OH::Storage::Result | result, | ||
OH::Storage::ReadSet * | rs, | ||
Liveness::Token | objAlive, | ||
Liveness::Token | ctxAlive | ||
) | [protected] |
References isStopped(), iStorageCommitCallback(), JSLOG, Sirikata::Liveness::livenessToken(), mCtx, Sirikata::JS::JSCtx::objStrand, and Sirikata::Logging::warn.
Referenced by eStorageCommit(), eStorageErase(), eStorageRangeErase(), eStorageRangeRead(), eStorageRead(), and eStorageWrite().
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::storageCount | ( | const OH::Storage::Key & | start, |
const OH::Storage::Key & | finish, | ||
v8::Handle< v8::Function > | cb, | ||
JSContextStruct * | jscont | ||
) |
void Sirikata::JS::JSObjectScript::storageCountCallback | ( | JSContextStruct * | jscont, |
v8::Persistent< v8::Function > | cb, | ||
OH::Storage::Result | result, | ||
int32 | count, | ||
Liveness::Token | objAlive, | ||
Liveness::Token | ctxAlive | ||
) | [protected] |
References isStopped(), iStorageCountCallback(), JSLOG, Sirikata::Liveness::livenessToken(), mCtx, Sirikata::JS::JSCtx::objStrand, and Sirikata::Logging::warn.
Referenced by eStorageCount().
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::storageErase | ( | const OH::Storage::Key & | key, |
v8::Handle< v8::Function > | cb, | ||
JSContextStruct * | jscont | ||
) |
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::storageRangeErase | ( | const OH::Storage::Key & | start, |
const OH::Storage::Key & | finish, | ||
v8::Handle< v8::Function > | cb, | ||
JSContextStruct * | jscont | ||
) |
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::storageRangeRead | ( | const OH::Storage::Key & | start, |
const OH::Storage::Key & | finish, | ||
v8::Handle< v8::Function > | cb, | ||
JSContextStruct * | jscont | ||
) |
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::storageRead | ( | const OH::Storage::Key & | key, |
v8::Handle< v8::Function > | cb, | ||
JSContextStruct * | jscont | ||
) |
v8::Handle< v8::Value > Sirikata::JS::JSObjectScript::storageWrite | ( | const OH::Storage::Key & | key, |
const String & | toWrite, | ||
v8::Handle< v8::Function > | cb, | ||
JSContextStruct * | jscont | ||
) |
friend class ScopedEvalContext [friend] |
uint32 Sirikata::JS::JSObjectScript::contIDTracker [protected] |
Referenced by createContext(), and initialize().
int32 Sirikata::JS::JSObjectScript::maxResourceThresh [protected] |
If we execute this number of cycles in one pass of event loop, throw a resource error.
Referenced by checkResourcesCPP(), and initialize().
JSContextStruct* Sirikata::JS::JSObjectScript::mContext [protected] |
Referenced by Sirikata::JS::EmersonScript::addConnectedPresence(), Sirikata::JS::EmersonScript::findVisible(), getCurrentV8Context(), initialize(), Sirikata::JS::EmersonScript::invokeCallbackInContext(), Sirikata::JS::EmersonScript::iOnConnected(), iSetRestoreScriptCallback(), isRootContext(), iStop(), iStorageCommitCallback(), iStorageCountCallback(), Sirikata::JS::EmersonScript::killScript(), Sirikata::JS::EmersonScript::requestReset(), Sirikata::JS::EmersonScript::resetScript(), Sirikata::JS::EmersonScript::rootContext(), and Sirikata::JS::EmersonScript::wrapPresence().
std::map<uint32,JSContextStruct*> Sirikata::JS::JSObjectScript::mContStructMap [protected] |
Referenced by createContext(), Sirikata::JS::EmersonScript::finishContextClear(), Sirikata::JS::EmersonScript::iHandleScriptCommRead(), initialize(), Sirikata::JS::EmersonScript::iNotifyProximate(), Sirikata::JS::EmersonScript::iNotifyProximateGone(), Sirikata::JS::EmersonScript::iResetProximateHelper(), and Sirikata::JS::EmersonScript::processSandboxMessage().
Referenced by Sirikata::JS::EmersonScript::addConnectedPresence(), Sirikata::JS::EmersonScript::create_entity(), Sirikata::JS::EmersonScript::create_event(), Sirikata::JS::EmersonScript::create_timeout(), createContext(), Sirikata::JS::EmersonScript::createVisibleWeakPersistent(), Sirikata::JS::EmersonScript::EmersonScript(), eSetRestoreScript(), Sirikata::JS::EmersonScript::handleScriptCommUnreliable(), Sirikata::JS::EmersonScript::iHandleScriptCommRead(), Sirikata::JS::EmersonScript::iHandleScriptCommUnreliable(), Sirikata::JS::EmersonScript::iInvokeInvokable(), initialize(), Sirikata::JS::EmersonScript::iNotifyProximate(), Sirikata::JS::EmersonScript::iNotifyProximateGone(), invokeCallback(), Sirikata::JS::EmersonScript::invokeCallbackInContext(), Sirikata::JS::EmersonScript::invokeInvokable(), Sirikata::JS::EmersonScript::iOnConnected(), Sirikata::JS::EmersonScript::iOnDisconnected(), iSetRestoreScriptCallback(), iStop(), Sirikata::JS::EmersonScript::iStop(), iStorageCommitCallback(), iStorageCountCallback(), Sirikata::JS::EmersonScript::killScript(), Sirikata::JS::EmersonScript::notifyProximate(), Sirikata::JS::EmersonScript::notifyProximateGone(), Sirikata::JS::EmersonScript::onConnected(), Sirikata::JS::EmersonScript::onDisconnected(), Sirikata::JS::EmersonScript::processSandboxMessage(), Sirikata::JS::EmersonScript::restorePresence(), Sirikata::JS::EmersonScript::runSimulation(), Sirikata::JS::EmersonScript::sendSandbox(), Sirikata::JS::EmersonScript::setBounds(), Sirikata::JS::EmersonScript::setLocation(), Sirikata::JS::EmersonScript::setOrientation(), Sirikata::JS::EmersonScript::setPhysicsFunction(), Sirikata::JS::EmersonScript::setQueryFunction(), setRestoreScript(), Sirikata::JS::EmersonScript::setVisual(), stop(), Sirikata::JS::EmersonScript::stop(), storageBeginTransaction(), storageCommit(), storageCommitCallback(), storageCount(), storageCountCallback(), storageErase(), storageRangeErase(), storageRangeRead(), storageRead(), storageWrite(), Sirikata::JS::EmersonScript::wrapPresence(), and ~JSObjectScript().
std::stack<EvalContext> Sirikata::JS::JSObjectScript::mEvalContextStack [protected] |
Referenced by absoluteImport(), checkCurCtxtHasCapability(), evalInGlobal(), Sirikata::JS::EmersonScript::fireProxEvent(), getCurrentV8Context(), Sirikata::JS::EmersonScript::iHandleScriptCommRead(), initialize(), invokeCallback(), popEvalContextScopeDirectory(), print(), printExceptionToScript(), Sirikata::JS::EmersonScript::processSandboxMessage(), pushEvalContextScopeDirectory(), require(), resolveImport(), Sirikata::JS::JSObjectScript::ScopedEvalContext::ScopedEvalContext(), and shimImportAndEvalScript().
Referenced by absoluteImport(), require(), and Sirikata::JS::EmersonScript::resetScript().
UUID Sirikata::JS::JSObjectScript::mInternalID [protected] |
int32 Sirikata::JS::JSObjectScript::mNestedEvalCounter [protected] |
We want to keep track of whether we're in an eval loop or not.
If we are, then mNestedEvalCounter keeps track of how many levels of evals we're in. Ie, if we call eval and from inside that eval, call eval again, then we're mNestedEvalCounter should be 2. If we are outside of all evals, then mNestedEvalCounter should be zero.
Referenced by postEvalOps(), and preEvalOps().
Referenced by eSetRestoreScript(), and setRestoreScript().
int32 Sirikata::JS::JSObjectScript::mResourceCounter [protected] |
Referenced by checkResourcesCPP(), and preEvalOps().
OH::Storage* Sirikata::JS::JSObjectScript::mStorage [protected] |
Referenced by eStorageBeginTransaction(), eStorageCommit(), eStorageCount(), eStorageErase(), eStorageRangeErase(), eStorageRangeRead(), eStorageRead(), eStorageWrite(), storageBeginTransaction(), storageCommit(), storageCount(), storageErase(), storageRangeErase(), storageRangeRead(), storageRead(), and storageWrite().
bool Sirikata::JS::JSObjectScript::stopCalled [protected] |
Will be true after stop method is called.
Referenced by isStopped(), and iStop().
ContIDToSuspMap Sirikata::JS::JSObjectScript::toFixup [protected] |
Referenced by Sirikata::JS::EmersonScript::registerFixupSuspendable().