JSValue RuntimeArray::lengthGetter(ExecState*, JSValue slotBase, const Identifier&) { RuntimeArray* thisObj = static_cast<RuntimeArray*>(asObject(slotBase)); return jsNumber(thisObj->getLength()); }
JSValue jsSVGPathSegLinetoVerticalAbsY(ExecState* exec, JSValue slotBase, const Identifier&) { JSSVGPathSegLinetoVerticalAbs* castedThis = static_cast<JSSVGPathSegLinetoVerticalAbs*>(asObject(slotBase)); UNUSED_PARAM(exec); SVGPathSegLinetoVerticalAbs* imp = static_cast<SVGPathSegLinetoVerticalAbs*>(castedThis->impl()); JSValue result = jsNumber(imp->y()); return result; }
JSValuePtr JSHTMLCollection::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { JSHTMLCollection* thisObj = static_cast<JSHTMLCollection*>(asObject(slot.slotBase())); return getNamedItems(exec, thisObj->impl(), propertyName); }
JSValue jsStyleMediaConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { JSStyleMedia* domObject = static_cast<JSStyleMedia*>(asObject(slotBase)); return JSStyleMedia::getConstructor(exec, domObject->globalObject()); }
JSValue JSHTMLOptionsCollection::remove(ExecState* exec) { HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl()); JSHTMLSelectElement* base = static_cast<JSHTMLSelectElement*>(asObject(toJS(exec, globalObject(), imp->base()))); return base->remove(exec); }
JSValue jsDirectoryEntryConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { JSDirectoryEntry* domObject = static_cast<JSDirectoryEntry*>(asObject(slotBase)); return JSDirectoryEntry::getConstructor(exec, domObject->globalObject()); }
JSValue jsSVGAnimatedAngleConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { JSSVGAnimatedAngle* domObject = static_cast<JSSVGAnimatedAngle*>(asObject(slotBase)); return JSSVGAnimatedAngle::getConstructor(exec, domObject->globalObject()); }
bool JSValue::isValidCallee() { return asObject(asCell())->globalObject(); }
JSValue jsNotationConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { JSNotation* domObject = static_cast<JSNotation*>(asObject(slotBase)); return JSNotation::getConstructor(exec, domObject->globalObject()); }
AJValue JSC_HOST_CALL objectProtoFuncDefineSetter(ExecState* exec, AJObject*, AJValue thisValue, const ArgList& args) { CallData callData; if (args.at(1).getCallData(callData) == CallTypeNone) return throwError(exec, SyntaxError, "invalid setter usage"); thisValue.toThisObject(exec)->defineSetter(exec, Identifier(exec, args.at(0).toString(exec)), asObject(args.at(1))); return jsUndefined(); }
void JSValue::dumpInContextAssumingStructure( PrintStream& out, DumpContext* context, Structure* structure) const { if (!*this) out.print("<JSValue()>"); else if (isInt32()) out.printf("Int32: %d", asInt32()); else if (isDouble()) { #if USE(JSVALUE64) out.printf("Double: %lld, %lf", (long long)reinterpretDoubleToInt64(asDouble()), asDouble()); #else union { double asDouble; uint32_t asTwoInt32s[2]; } u; u.asDouble = asDouble(); out.printf("Double: %08x:%08x, %lf", u.asTwoInt32s[1], u.asTwoInt32s[0], asDouble()); #endif } else if (isCell()) { if (structure->classInfo()->isSubClassOf(JSString::info())) { JSString* string = asString(asCell()); out.print("String"); if (string->isRope()) out.print(" (rope)"); const StringImpl* impl = string->tryGetValueImpl(); if (impl) { if (impl->isAtomic()) out.print(" (atomic)"); if (impl->isAtomic()) out.print(" (identifier)"); if (impl->isSymbol()) out.print(" (symbol)"); } else out.print(" (unresolved)"); out.print(": ", impl); } else if (structure->classInfo()->isSubClassOf(Symbol::info())) out.print("Symbol: ", RawPointer(asCell())); else if (structure->classInfo()->isSubClassOf(Structure::info())) out.print("Structure: ", inContext(*jsCast<Structure*>(asCell()), context)); else if (structure->classInfo()->isSubClassOf(JSObject::info())) { out.print("Object: ", RawPointer(asCell())); out.print(" with butterfly ", RawPointer(asObject(asCell())->butterfly())); out.print(" (", inContext(*structure, context), ")"); } else { out.print("Cell: ", RawPointer(asCell())); out.print(" (", inContext(*structure, context), ")"); } #if USE(JSVALUE64) out.print(", ID: ", asCell()->structureID()); #endif } else if (isTrue()) out.print("True"); else if (isFalse()) out.print("False"); else if (isNull()) out.print("Null"); else if (isUndefined()) out.print("Undefined"); else out.print("INVALID"); }
EncodedJSValue JSC_HOST_CALL moduleNamespaceObjectSymbolIterator(ExecState* exec) { JSValue thisValue = exec->thisValue(); if (!thisValue.isObject()) return JSValue::encode(throwTypeError(exec, ASCIILiteral("|this| should be an object"))); return JSValue::encode(JSPropertyNameIterator::create(exec, exec->lexicalGlobalObject()->propertyNameIteratorStructure(), asObject(thisValue))); }
JSValue JSDOMStringMap::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) { JSDOMStringMap* thisObj = static_cast<JSDOMStringMap*>(asObject(slotBase)); return jsString(exec, thisObj->impl()->item(identifierToAtomicString(propertyName))); }
JSValue RuntimeArray::indexGetter(ExecState* exec, JSValue slotBase, unsigned index) { RuntimeArray* thisObj = static_cast<RuntimeArray*>(asObject(slotBase)); return thisObj->getConcreteArray()->valueAt(exec, index); }
JSObject* JSCell::getObject() { return isObject() ? asObject(this) : 0; }
JSValue jsDeviceOrientationEventGamma(ExecState* exec, JSValue slotBase, const Identifier&) { JSDeviceOrientationEvent* castedThis = static_cast<JSDeviceOrientationEvent*>(asObject(slotBase)); return castedThis->gamma(exec); }
JSValue jsHTMLAppletElementConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { JSHTMLAppletElement* domObject = static_cast<JSHTMLAppletElement*>(asObject(slotBase)); return JSHTMLAppletElement::getConstructor(exec, domObject->globalObject()); }
JSValue jsDeviceOrientationEventConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { JSDeviceOrientationEvent* domObject = static_cast<JSDeviceOrientationEvent*>(asObject(slotBase)); return JSDeviceOrientationEvent::getConstructor(exec, domObject->globalObject()); }
DirectoryEntry* toDirectoryEntry(JSC::JSValue value) { return value.inherits(&JSDirectoryEntry::s_info) ? static_cast<JSDirectoryEntry*>(asObject(value))->impl() : 0; }
JSValue JSInjectedScriptHost::subtype(ExecState* exec) { if (exec->argumentCount() < 1) return jsUndefined(); JSValue value = exec->uncheckedArgument(0); if (value.isString()) return exec->vm().smallStrings.stringString(); if (value.isBoolean()) return exec->vm().smallStrings.booleanString(); if (value.isNumber()) return exec->vm().smallStrings.numberString(); if (value.isSymbol()) return exec->vm().smallStrings.symbolString(); JSObject* object = asObject(value); if (object) { if (object->isErrorInstance()) return jsNontrivialString(exec, ASCIILiteral("error")); // Consider class constructor functions class objects. JSFunction* function = jsDynamicCast<JSFunction*>(value); if (function && function->isClassConstructorFunction()) return jsNontrivialString(exec, ASCIILiteral("class")); } if (value.inherits(JSArray::info())) return jsNontrivialString(exec, ASCIILiteral("array")); if (value.inherits(DirectArguments::info()) || value.inherits(ScopedArguments::info())) return jsNontrivialString(exec, ASCIILiteral("array")); if (value.inherits(DateInstance::info())) return jsNontrivialString(exec, ASCIILiteral("date")); if (value.inherits(RegExpObject::info())) return jsNontrivialString(exec, ASCIILiteral("regexp")); if (value.inherits(JSMap::info())) return jsNontrivialString(exec, ASCIILiteral("map")); if (value.inherits(JSSet::info())) return jsNontrivialString(exec, ASCIILiteral("set")); if (value.inherits(JSWeakMap::info())) return jsNontrivialString(exec, ASCIILiteral("weakmap")); if (value.inherits(JSWeakSet::info())) return jsNontrivialString(exec, ASCIILiteral("weakset")); if (value.inherits(JSArrayIterator::info()) || value.inherits(JSMapIterator::info()) || value.inherits(JSSetIterator::info()) || value.inherits(JSStringIterator::info()) || value.inherits(JSPropertyNameIterator::info())) return jsNontrivialString(exec, ASCIILiteral("iterator")); if (value.inherits(JSInt8Array::info()) || value.inherits(JSInt16Array::info()) || value.inherits(JSInt32Array::info())) return jsNontrivialString(exec, ASCIILiteral("array")); if (value.inherits(JSUint8Array::info()) || value.inherits(JSUint16Array::info()) || value.inherits(JSUint32Array::info())) return jsNontrivialString(exec, ASCIILiteral("array")); if (value.inherits(JSFloat32Array::info()) || value.inherits(JSFloat64Array::info())) return jsNontrivialString(exec, ASCIILiteral("array")); return impl().subtype(exec, value); }
SVGAnimatedAngle* toSVGAnimatedAngle(JSC::JSValue value) { return value.inherits(&JSSVGAnimatedAngle::s_info) ? static_cast<JSSVGAnimatedAngle*>(asObject(value))->impl() : 0; }
JSValue jsClientRectConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { JSClientRect* domObject = static_cast<JSClientRect*>(asObject(slotBase)); return JSClientRect::getConstructor(exec, domObject->globalObject()); }
StyleMedia* toStyleMedia(JSC::JSValue value) { return value.inherits(&JSStyleMedia::s_info) ? static_cast<JSStyleMedia*>(asObject(value))->impl() : 0; }
ClientRect* toClientRect(JSC::JSValue value) { return value.inherits(&JSClientRect::s_info) ? static_cast<JSClientRect*>(asObject(value))->impl() : 0; }
jvalue convertValueToJValue(ExecState* exec, JSValue value, JNIType jniType, const char* javaClassName) { JSLock lock(SilenceAssertionsOnly); jvalue result; switch (jniType) { case array_type: case object_type: { result.l = (jobject)0; // First see if we have a Java instance. if (value.isObject()) { JSObject* objectImp = asObject(value); if (objectImp->classInfo() == &RuntimeObjectImp::s_info) { RuntimeObjectImp* imp = static_cast<RuntimeObjectImp*>(objectImp); JavaInstance* instance = static_cast<JavaInstance*>(imp->getInternalInstance()); if (instance) result.l = instance->javaInstance(); } else if (objectImp->classInfo() == &RuntimeArray::s_info) { // Input is a JavaScript Array that was originally created from a Java Array RuntimeArray* imp = static_cast<RuntimeArray*>(objectImp); JavaArray* array = static_cast<JavaArray*>(imp->getConcreteArray()); result.l = array->javaArray(); } else if (objectImp->classInfo() == &JSArray::info) { // Input is a Javascript Array. We need to create it to a Java Array. result.l = convertArrayInstanceToJavaArray(exec, asArray(value), javaClassName); } } // Now convert value to a string if the target type is a java.lang.string, and we're not // converting from a Null. if (!result.l && !strcmp(javaClassName, "java.lang.String")) { #ifdef CONVERT_NULL_TO_EMPTY_STRING if (value->isNull()) { JNIEnv* env = getJNIEnv(); jchar buf[2]; jobject javaString = env->functions->NewString(env, buf, 0); result.l = javaString; } else #else if (!value.isNull()) #endif { UString stringValue = value.toString(exec); JNIEnv* env = getJNIEnv(); jobject javaString = env->functions->NewString(env, (const jchar *)stringValue.data(), stringValue.size()); result.l = javaString; } } else if (!result.l) // ANDROID memset(&result, 0, sizeof(jvalue)); // Handle it the same as a void case } break; case boolean_type: { result.z = (jboolean)value.toNumber(exec); } break; case byte_type: { result.b = (jbyte)value.toNumber(exec); } break; case char_type: { result.c = (jchar)value.toNumber(exec); } break; case short_type: { result.s = (jshort)value.toNumber(exec); } break; case int_type: { result.i = (jint)value.toNumber(exec); } break; case long_type: { result.j = (jlong)value.toNumber(exec); } break; case float_type: { result.f = (jfloat)value.toNumber(exec); } break; case double_type: { result.d = (jdouble)value.toNumber(exec); } break; break; case invalid_type: default: case void_type: { // ANDROID memset(&result, 0, sizeof(jvalue)); } break; } return result; }
JSValue jsTestInterfaceConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { JSTestInterface* domObject = static_cast<JSTestInterface*>(asObject(slotBase)); return JSTestInterface::getConstructor(exec, domObject->globalObject()); }
JSValue jsSVGPathSegLinetoVerticalAbsConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { JSSVGPathSegLinetoVerticalAbs* domObject = static_cast<JSSVGPathSegLinetoVerticalAbs*>(asObject(slotBase)); return JSSVGPathSegLinetoVerticalAbs::getConstructor(exec, domObject->globalObject()); }
TestInterface* toTestInterface(JSC::JSValue value) { return value.inherits(&JSTestInterface::s_info) ? static_cast<JSTestInterface*>(asObject(value))->impl() : 0; }
static JSValue* nativeCallFunction(ExecState* exec, JSObject* functionObject, JSValue* thisValue, const ArgList& args) { return static_cast<UserObjectImp*>(functionObject)->callAsFunction(exec, asObject(thisValue), args); }
bool JSValue::isValidCallee() { return asObject(asObject(asCell())->getAnonymousValue(0))->isGlobalObject(); }