本文整理汇总了C++中jsc::JSValue::toNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ JSValue::toNumber方法的具体用法?C++ JSValue::toNumber怎么用?C++ JSValue::toNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jsc::JSValue
的用法示例。
在下文中一共展示了JSValue::toNumber方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toVector
bool toVector(JSC::ExecState* exec, JSC::JSValue value, Vector<T, inlineCapacity>& vector)
{
if (!value.isObject())
return false;
JSC::JSObject* object = asObject(value);
int32_t length = object->get(exec, JSC::Identifier(exec, "length")).toInt32(exec);
vector.resize(length);
for (int32_t i = 0; i < length; ++i) {
JSC::JSValue v = object->get(exec, i);
if (exec->hadException())
return false;
vector[i] = static_cast<T>(v.toNumber(exec));
}
return true;
}
示例2: toVector
bool toVector(JSC::ExecState& state, JSC::JSValue value, Vector<T, inlineCapacity>& vector)
{
if (!value.isObject())
return false;
JSC::JSObject* object = asObject(value);
int32_t length = object->get(&state, state.vm().propertyNames->length).toInt32(&state);
if (!vector.tryReserveCapacity(length))
return false;
vector.resize(length);
for (int32_t i = 0; i < length; ++i) {
JSC::JSValue v = object->get(&state, i);
if (state.hadException())
return false;
vector[i] = static_cast<T>(v.toNumber(&state));
}
return true;
}
示例3: toArray
void toArray(JSC::ExecState* exec, JSC::JSValue value, T*& array, int& size)
{
array = 0;
if (!value.isObject())
return;
JSC::JSObject* object = asObject(value);
int length = object->get(exec, JSC::Identifier(exec, "length")).toInt32(exec);
void* tempValues;
if (!tryFastMalloc(length * sizeof(T)).getValue(tempValues))
return;
T* values = static_cast<T*>(tempValues);
for (int i = 0; i < length; ++i) {
JSC::JSValue v = object->get(exec, i);
if (exec->hadException())
return;
values[i] = static_cast<T>(v.toNumber(exec));
}
array = values;
size = length;
}
示例4: impl
void JSFloat32Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value)
{
impl()->set(index, static_cast<float>(value.toNumber(exec)));
}
示例5: impl
void JSFloat64Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value)
{
impl()->set(index, value.toNumber(exec));
}