bool V8Value::compare(ScriptValuePtr other) { assert(isValid()); assert(other->isValid()); return value->StrictEquals( (dynamic_cast<V8Value*>(other.get()))->value ); }
void TraceMonkeyValue::setProperty(std::string propertyName, ScriptValuePtr propertyValue) { assert(isValid()); assert(JSVAL_IS_OBJECT(value)); jsval ret = (dynamic_cast<TraceMonkeyValue*>(propertyValue.get())->value); JS_SetProperty(TraceMonkeyEngine::context, JSVAL_TO_OBJECT(value), propertyName.c_str(), &ret); }
ScriptValuePtr TraceMonkeyEngine::getGlobal() { assert(globalValue.get()); Logging::log(Logging::DEBUG, "TME::getGlobal\r\n"); // ((TraceMonkeyValue*)(globalValue.get()))->debugPrint(); return globalValue; }
ScriptValuePtr V8Engine::getGlobal() { assert(globalValue.get()); Logging::log(Logging::INFO, "V8E::getGlobal\r\n"); // ((V8Value*)(globalValue.get()))->debugPrint(); return globalValue; }
void V8Value::setProperty(std::string propertyName, ScriptValuePtr propertyValue) { assert(isValid()); assert(value->IsObject() && !value->IsNull()); HandleScope handleScope; Handle<Object> obj = value->ToObject(); obj->Set(String::New(propertyName.c_str()), dynamic_cast<V8Value*>(propertyValue.get())->value); }
bool TraceMonkeyValue::compare(ScriptValuePtr other) { assert(isValid()); assert(other->isValid()); jsval otherValue = (dynamic_cast<TraceMonkeyValue*>(other.get()))->value; if (JSVAL_IS_INT(value)) return (JSVAL_IS_INT(otherValue) && JSVAL_TO_INT(value) == JSVAL_TO_INT(otherValue)); else if (JSVAL_IS_NULL(value)) return (JSVAL_IS_NULL(otherValue)); else if (JSVAL_IS_VOID(value)) return (JSVAL_IS_VOID(otherValue)); else if (JSVAL_IS_BOOLEAN(value)) return (JSVAL_IS_BOOLEAN(otherValue) && JSVAL_TO_BOOLEAN(value) == JSVAL_TO_BOOLEAN(otherValue)); else if (JSVAL_IS_DOUBLE(value)) return (JSVAL_IS_DOUBLE(otherValue) && *(JSVAL_TO_DOUBLE(value)) == *(JSVAL_TO_DOUBLE(otherValue))); else if (JSVAL_IS_STRING(value)) { if (!JSVAL_IS_STRING(otherValue)) return false; else assert(0 && "TODO: compare TM strings"); } else if (JSVAL_IS_OBJECT(value)) { if (JSVAL_IS_NULL(otherValue)) // NULLs are objects, in TraceMonkey return false; if (!JSVAL_IS_OBJECT(otherValue)) return false; else assert(0 && "TODO: compare TM objects"); } else { Logging::log(Logging::INFO, "Can't compare uncertain jsvals\r\n"); } assert(0); return false; }