本文整理汇总了C++中JSValue类的典型用法代码示例。如果您正苦于以下问题:C++ JSValue类的具体用法?C++ JSValue怎么用?C++ JSValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JSValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: valueToStringWithUndefinedOrNullCheck
String valueToStringWithUndefinedOrNullCheck(ExecState* exec, JSValue value)
{
if (value.isUndefinedOrNull())
return String();
return ustringToString(value.toString(exec)->value(exec));
}
示例2: setJSSVGSwitchElementXmlspace
void setJSSVGSwitchElementXmlspace(ExecState* exec, JSObject* thisObject, JSValue value)
{
JSSVGSwitchElement* castedThisObj = static_cast<JSSVGSwitchElement*>(thisObject);
SVGSwitchElement* imp = static_cast<SVGSwitchElement*>(castedThisObj->impl());
imp->setXmlspace(value.toString(exec));
}
示例3: setRegExpConstructorInput
void setRegExpConstructorInput(ExecState* exec, JSObject* baseObject, JSValue value)
{
asRegExpConstructor(baseObject)->setInput(exec, value.toString(exec));
}
示例4: setJSSVGTextContentElementXmlspace
void setJSSVGTextContentElementXmlspace(ExecState* exec, JSObject* thisObject, JSValue value)
{
SVGTextContentElement* imp = static_cast<SVGTextContentElement*>(static_cast<JSSVGTextContentElement*>(thisObject)->impl());
imp->setXmlspace(value.toString(exec));
}
示例5: ASSERT
// ECMA 8.6.2.2
void JSObject::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
ASSERT(value);
ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
if (propertyName == exec->propertyNames().underscoreProto) {
// Setting __proto__ to a non-object, non-null value is silently ignored to match Mozilla.
if (!value.isObject() && !value.isNull())
return;
JSValue nextPrototypeValue = value;
while (nextPrototypeValue && nextPrototypeValue.isObject()) {
JSObject* nextPrototype = asObject(nextPrototypeValue)->unwrappedObject();
if (nextPrototype == this) {
throwError(exec, GeneralError, "cyclic __proto__ value");
return;
}
nextPrototypeValue = nextPrototype->prototype();
}
setPrototype(value);
return;
}
// Check if there are any setters or getters in the prototype chain
JSValue prototype;
for (JSObject* obj = this; !obj->structure()->hasGetterSetterProperties(); obj = asObject(prototype)) {
prototype = obj->prototype();
if (prototype.isNull()) {
putDirectInternal(exec->globalData(), propertyName, value, 0, true, slot);
return;
}
}
unsigned attributes;
JSCell* specificValue;
if ((m_structure->get(propertyName, attributes, specificValue) != WTF::notFound) && attributes & ReadOnly)
return;
for (JSObject* obj = this; ; obj = asObject(prototype)) {
if (JSValue gs = obj->getDirect(propertyName)) {
if (gs.isGetterSetter()) {
JSObject* setterFunc = asGetterSetter(gs)->setter();
if (!setterFunc) {
throwSetterError(exec);
return;
}
CallData callData;
CallType callType = setterFunc->getCallData(callData);
MarkedArgumentBuffer args;
args.append(value);
call(exec, setterFunc, callType, callData, this, args);
return;
}
// If there's an existing property on the object or one of its
// prototypes it should be replaced, so break here.
break;
}
prototype = obj->prototype();
if (prototype.isNull())
break;
}
putDirectInternal(exec->globalData(), propertyName, value, 0, true, slot);
return;
}
示例6: convertValue
void JSDictionary::convertValue(ExecState* exec, JSValue value, String& result)
{
result = ustringToString(value.toString(exec)->value(exec));
}
示例7: readRotationRateArgument
static PassRefPtr<DeviceMotionData::RotationRate> readRotationRateArgument(JSValue value, ExecState* exec)
{
if (value.isUndefinedOrNull())
return 0;
// Given the above test, this will always yield an object.
JSObject* object = value.toObject(exec);
JSValue alphaValue = object->get(exec, Identifier(exec, "alpha"));
if (exec->hadException())
return 0;
bool canProvideAlpha = !alphaValue.isUndefinedOrNull();
double alpha = alphaValue.toNumber(exec);
if (exec->hadException())
return 0;
JSValue betaValue = object->get(exec, Identifier(exec, "beta"));
if (exec->hadException())
return 0;
bool canProvideBeta = !betaValue.isUndefinedOrNull();
double beta = betaValue.toNumber(exec);
if (exec->hadException())
return 0;
JSValue gammaValue = object->get(exec, Identifier(exec, "gamma"));
if (exec->hadException())
return 0;
bool canProvideGamma = !gammaValue.isUndefinedOrNull();
double gamma = gammaValue.toNumber(exec);
if (exec->hadException())
return 0;
if (!canProvideAlpha && !canProvideBeta && !canProvideGamma)
return 0;
return DeviceMotionData::RotationRate::create(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma);
}
示例8: setJSHTMLMediaElementWebkitPreservesPitch
void setJSHTMLMediaElementWebkitPreservesPitch(ExecState* exec, JSObject* thisObject, JSValue value)
{
JSHTMLMediaElement* castedThis = static_cast<JSHTMLMediaElement*>(thisObject);
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(castedThis->impl());
imp->setWebkitPreservesPitch(value.toBoolean(exec));
}
示例9: setJSHTMLMediaElementWebkitClosedCaptionsVisible
void setJSHTMLMediaElementWebkitClosedCaptionsVisible(ExecState* exec, JSObject* thisObject, JSValue value)
{
JSHTMLMediaElement* castedThis = static_cast<JSHTMLMediaElement*>(thisObject);
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(castedThis->impl());
imp->setWebkitClosedCaptionsVisible(value.toBoolean(exec));
}
示例10: setJSHTMLMediaElementLoop
void setJSHTMLMediaElementLoop(ExecState* exec, JSObject* thisObject, JSValue value)
{
JSHTMLMediaElement* castedThis = static_cast<JSHTMLMediaElement*>(thisObject);
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(castedThis->impl());
imp->setBooleanAttribute(WebCore::HTMLNames::loopAttr, value.toBoolean(exec));
}
示例11: setJSHTMLMediaElementControls
void setJSHTMLMediaElementControls(ExecState* exec, JSObject* thisObject, JSValue value)
{
JSHTMLMediaElement* castedThis = static_cast<JSHTMLMediaElement*>(thisObject);
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(castedThis->impl());
imp->setControls(value.toBoolean(exec));
}
示例12: setJSHTMLMediaElementPlaybackRate
void setJSHTMLMediaElementPlaybackRate(ExecState* exec, JSObject* thisObject, JSValue value)
{
JSHTMLMediaElement* castedThis = static_cast<JSHTMLMediaElement*>(thisObject);
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(castedThis->impl());
imp->setPlaybackRate(value.toFloat(exec));
}
示例13: setJSHTMLMediaElementPreload
void setJSHTMLMediaElementPreload(ExecState* exec, JSObject* thisObject, JSValue value)
{
JSHTMLMediaElement* castedThis = static_cast<JSHTMLMediaElement*>(thisObject);
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(castedThis->impl());
imp->setPreload(ustringToString(value.toString(exec)));
}
示例14: READ_COMPACT_UINT32_OR_FAIL
void WASMModuleParser::parseGlobalSection(ExecState* exec)
{
uint32_t numberOfInternalI32GlobalVariables;
uint32_t numberOfInternalF32GlobalVariables;
uint32_t numberOfInternalF64GlobalVariables;
uint32_t numberOfImportedI32GlobalVariables;
uint32_t numberOfImportedF32GlobalVariables;
uint32_t numberOfImportedF64GlobalVariables;
READ_COMPACT_UINT32_OR_FAIL(numberOfInternalI32GlobalVariables, "Cannot read the number of internal int32 global variables.");
READ_COMPACT_UINT32_OR_FAIL(numberOfInternalF32GlobalVariables, "Cannot read the number of internal float32 global variables.");
READ_COMPACT_UINT32_OR_FAIL(numberOfInternalF64GlobalVariables, "Cannot read the number of internal float64 global variables.");
READ_COMPACT_UINT32_OR_FAIL(numberOfImportedI32GlobalVariables, "Cannot read the number of imported int32 global variables.");
READ_COMPACT_UINT32_OR_FAIL(numberOfImportedF32GlobalVariables, "Cannot read the number of imported float32 global variables.");
READ_COMPACT_UINT32_OR_FAIL(numberOfImportedF64GlobalVariables, "Cannot read the number of imported float64 global variables.");
uint32_t numberOfGlobalVariables = numberOfInternalI32GlobalVariables + numberOfInternalF32GlobalVariables + numberOfInternalF64GlobalVariables +
numberOfImportedI32GlobalVariables + numberOfImportedF32GlobalVariables + numberOfImportedF64GlobalVariables;
Vector<WASMType>& globalVariableTypes = m_module->globalVariableTypes();
globalVariableTypes.reserveInitialCapacity(numberOfGlobalVariables);
Vector<JSWASMModule::GlobalVariable>& globalVariables = m_module->globalVariables();
globalVariables.reserveInitialCapacity(numberOfGlobalVariables);
for (uint32_t i = 0; i < numberOfInternalI32GlobalVariables; ++i) {
globalVariableTypes.uncheckedAppend(WASMType::I32);
globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(0));
}
for (uint32_t i = 0; i < numberOfInternalF32GlobalVariables; ++i) {
globalVariableTypes.uncheckedAppend(WASMType::F32);
globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(0.0f));
}
for (uint32_t i = 0; i < numberOfInternalF64GlobalVariables; ++i) {
globalVariableTypes.uncheckedAppend(WASMType::F64);
globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(0.0));
}
for (uint32_t i = 0; i < numberOfImportedI32GlobalVariables; ++i) {
String importName;
READ_STRING_OR_FAIL(importName, "Cannot read the import name of an int32 global variable.");
globalVariableTypes.uncheckedAppend(WASMType::I32);
JSValue value;
getImportedValue(exec, importName, value);
PROPAGATE_ERROR();
FAIL_IF_FALSE(value.isPrimitive() && !value.isSymbol(), "\"" + importName + "\" is not a primitive or is a Symbol.");
globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(value.toInt32(exec)));
}
for (uint32_t i = 0; i < numberOfImportedF32GlobalVariables; ++i) {
String importName;
READ_STRING_OR_FAIL(importName, "Cannot read the import name of a float32 global variable.");
globalVariableTypes.uncheckedAppend(WASMType::F32);
JSValue value;
getImportedValue(exec, importName, value);
PROPAGATE_ERROR();
FAIL_IF_FALSE(value.isPrimitive() && !value.isSymbol(), "\"" + importName + "\" is not a primitive or is a Symbol.");
globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(static_cast<float>(value.toNumber(exec))));
}
for (uint32_t i = 0; i < numberOfImportedF64GlobalVariables; ++i) {
String importName;
READ_STRING_OR_FAIL(importName, "Cannot read the import name of a float64 global variable.");
globalVariableTypes.uncheckedAppend(WASMType::F64);
JSValue value;
getImportedValue(exec, importName, value);
PROPAGATE_ERROR();
FAIL_IF_FALSE(value.isPrimitive() && !value.isSymbol(), "\"" + importName + "\" is not a primitive or is a Symbol.");
globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(value.toNumber(exec)));
}
}
示例15: objectProtoFuncValueOf
EncodedJSValue JSC_HOST_CALL objectProtoFuncValueOf(ExecState* exec)
{
JSValue thisValue = exec->hostThisValue();
return JSValue::encode(thisValue.toObject(exec));
}