本文整理汇总了C++中RuntimeArray类的典型用法代码示例。如果您正苦于以下问题:C++ RuntimeArray类的具体用法?C++ RuntimeArray怎么用?C++ RuntimeArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RuntimeArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lengthGetter
EncodedJSValue RuntimeArray::lengthGetter(ExecState* exec, JSObject*, EncodedJSValue thisValue, PropertyName)
{
RuntimeArray* thisObject = jsDynamicCast<RuntimeArray*>(JSValue::decode(thisValue));
if (!thisObject)
return throwVMTypeError(exec);
return JSValue::encode(jsNumber(thisObject->getLength()));
}
示例2: putByIndex
void RuntimeArray::putByIndex(JSCell* cell, ExecState* exec, unsigned index, JSValue value, bool)
{
RuntimeArray* thisObject = jsCast<RuntimeArray*>(cell);
if (index >= thisObject->getLength()) {
exec->vm().throwException(exec, createRangeError(exec, "Range error"));
return;
}
thisObject->getConcreteArray()->setValueAt(exec, index, value);
}
示例3: DECLARE_THROW_SCOPE
EncodedJSValue RuntimeArray::lengthGetter(ExecState* exec, EncodedJSValue thisValue, PropertyName)
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
RuntimeArray* thisObject = jsDynamicDowncast<RuntimeArray*>(JSValue::decode(thisValue));
if (!thisObject)
return throwVMTypeError(exec, scope);
return JSValue::encode(jsNumber(thisObject->getLength()));
}
示例4: getOwnPropertySlotByIndex
bool RuntimeArray::getOwnPropertySlotByIndex(JSCell* cell, ExecState *exec, unsigned index, PropertySlot& slot)
{
RuntimeArray* thisObject = jsCast<RuntimeArray*>(cell);
if (index < thisObject->getLength()) {
slot.setCustomIndex(thisObject, index, thisObject->indexGetter);
return true;
}
return JSObject::getOwnPropertySlotByIndex(thisObject, exec, index, slot);
}
示例5: getOwnPropertySlotByIndex
bool RuntimeArray::getOwnPropertySlotByIndex(JSObject* object, ExecState *exec, unsigned index, PropertySlot& slot)
{
RuntimeArray* thisObject = jsCast<RuntimeArray*>(object);
if (index < thisObject->getLength()) {
slot.setValue(thisObject, DontDelete | DontEnum,
thisObject->getConcreteArray()->valueAt(exec, index));
return true;
}
return JSObject::getOwnPropertySlotByIndex(thisObject, exec, index, slot);
}
示例6: getOwnPropertyNames
void RuntimeArray::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
RuntimeArray* thisObject = jsCast<RuntimeArray*>(object);
unsigned length = thisObject->getLength();
for (unsigned i = 0; i < length; ++i)
propertyNames.add(Identifier::from(exec, i));
if (mode.includeDontEnumProperties())
propertyNames.add(exec->propertyNames().length);
JSObject::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
}
示例7: put
void RuntimeArray::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
{
RuntimeArray* thisObject = jsCast<RuntimeArray*>(cell);
if (propertyName == exec->propertyNames().length) {
exec->vm().throwException(exec, createRangeError(exec, "Range error"));
return;
}
if (Optional<uint32_t> index = parseIndex(propertyName)) {
thisObject->getConcreteArray()->setValueAt(exec, index.value(), value);
return;
}
JSObject::put(thisObject, exec, propertyName, value, slot);
}
示例8: put
void RuntimeArray::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
{
RuntimeArray* thisObject = jsCast<RuntimeArray*>(cell);
if (propertyName == exec->propertyNames().length) {
throwError(exec, createRangeError(exec, "Range error"));
return;
}
unsigned index = propertyName.asIndex();
if (index != PropertyName::NotAnIndex) {
thisObject->getConcreteArray()->setValueAt(exec, index, value);
return;
}
JSObject::put(thisObject, exec, propertyName, value, slot);
}
示例9: getOwnPropertySlot
bool RuntimeArray::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
RuntimeArray* thisObject = jsCast<RuntimeArray*>(object);
if (propertyName == exec->propertyNames().length) {
slot.setCacheableCustom(thisObject, DontDelete | ReadOnly | DontEnum, thisObject->lengthGetter);
return true;
}
Optional<uint32_t> index = parseIndex(propertyName);
if (index && index.value() < thisObject->getLength()) {
slot.setValue(thisObject, DontDelete | DontEnum,
thisObject->getConcreteArray()->valueAt(exec, index.value()));
return true;
}
return JSObject::getOwnPropertySlot(thisObject, exec, propertyName, slot);
}
示例10: put
void RuntimeArray::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
RuntimeArray* thisObject = static_cast<RuntimeArray*>(cell);
if (propertyName == exec->propertyNames().length) {
throwError(exec, createRangeError(exec, "Range error"));
return;
}
bool ok;
unsigned index = propertyName.toArrayIndex(ok);
if (ok) {
thisObject->getConcreteArray()->setValueAt(exec, index, value);
return;
}
JSObject::put(thisObject, exec, propertyName, value, slot);
}
示例11: getOwnPropertySlot
bool RuntimeArray::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
RuntimeArray* thisObject = jsCast<RuntimeArray*>(cell);
if (propertyName == exec->propertyNames().length) {
slot.setCacheableCustom(thisObject, thisObject->lengthGetter);
return true;
}
unsigned index = propertyName.asIndex();
if (index < thisObject->getLength()) {
ASSERT(index != PropertyName::NotAnIndex);
slot.setCustomIndex(thisObject, index, thisObject->indexGetter);
return true;
}
return JSObject::getOwnPropertySlot(thisObject, exec, propertyName, slot);
}
示例12: getOwnPropertySlot
bool RuntimeArray::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
RuntimeArray* thisObject = static_cast<RuntimeArray*>(cell);
if (propertyName == exec->propertyNames().length) {
slot.setCacheableCustom(thisObject, thisObject->lengthGetter);
return true;
}
bool ok;
unsigned index = propertyName.toArrayIndex(ok);
if (ok) {
if (index < thisObject->getLength()) {
slot.setCustomIndex(thisObject, index, thisObject->indexGetter);
return true;
}
}
return JSObject::getOwnPropertySlot(thisObject, exec, propertyName, slot);
}
示例13: getOwnPropertyDescriptor
bool RuntimeArray::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
RuntimeArray* thisObject = jsCast<RuntimeArray*>(object);
if (propertyName == exec->propertyNames().length) {
PropertySlot slot;
slot.setCustom(thisObject, lengthGetter);
descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
return true;
}
unsigned index = propertyName.asIndex();
if (index < thisObject->getLength()) {
ASSERT(index != PropertyName::NotAnIndex);
PropertySlot slot;
slot.setCustomIndex(thisObject, index, indexGetter);
descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | DontEnum);
return true;
}
return JSObject::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
}
示例14: convertValueToJValue
jvalue convertValueToJValue(ExecState* exec, RootObject* rootObject, JSValue value, JavaType javaType, const char* javaClassName)
{
JSLock lock(SilenceAssertionsOnly);
jvalue result;
memset(&result, 0, sizeof(jvalue));
switch (javaType) {
case JavaTypeArray:
case JavaTypeObject:
{
// FIXME: JavaJSObject::convertValueToJObject functionality is almost exactly the same,
// these functions should use common code.
if (value.isObject()) {
JSObject* object = asObject(value);
if (object->inherits(&JavaRuntimeObject::s_info)) {
// Unwrap a Java instance.
JavaRuntimeObject* runtimeObject = static_cast<JavaRuntimeObject*>(object);
JavaInstance* instance = runtimeObject->getInternalJavaInstance();
if (instance)
result.l = instance->javaInstance();
} else if (object->classInfo() == &RuntimeArray::s_info) {
// Input is a JavaScript Array that was originally created from a Java Array
RuntimeArray* imp = static_cast<RuntimeArray*>(object);
JavaArray* array = static_cast<JavaArray*>(imp->getConcreteArray());
result.l = array->javaArray();
} else if (object->classInfo() == &JSArray::s_info) {
// Input is a Javascript Array. We need to create it to a Java Array.
result.l = convertArrayInstanceToJavaArray(exec, asArray(value), javaClassName);
} else if ((!result.l && (!strcmp(javaClassName, "java.lang.Object")))
|| (!strcmp(javaClassName, "netscape.javascript.JSObject"))) {
// Wrap objects in JSObject instances.
JNIEnv* env = getJNIEnv();
jclass jsObjectClass = env->FindClass("sun/plugin/javascript/webkit/JSObject");
jmethodID constructorID = env->GetMethodID(jsObjectClass, "<init>", "(J)V");
if (constructorID) {
jlong nativeHandle = ptr_to_jlong(object);
rootObject->gcProtect(object);
result.l = env->NewObject(jsObjectClass, constructorID, nativeHandle);
}
}
}
// Create an appropriate Java object if target type is java.lang.Object.
if (!result.l && !strcmp(javaClassName, "java.lang.Object")) {
if (value.isString()) {
UString stringValue = asString(value)->value(exec);
JNIEnv* env = getJNIEnv();
jobject javaString = env->functions->NewString(env, (const jchar*)stringValue.characters(), stringValue.length());
result.l = javaString;
} else if (value.isNumber()) {
double doubleValue = value.asNumber();
JNIEnv* env = getJNIEnv();
jclass clazz = env->FindClass("java/lang/Double");
jmethodID constructor = env->GetMethodID(clazz, "<init>", "(D)V");
jobject javaDouble = env->functions->NewObject(env, clazz, constructor, doubleValue);
result.l = javaDouble;
} else if (value.isBoolean()) {
bool boolValue = value.asBoolean();
JNIEnv* env = getJNIEnv();
jclass clazz = env->FindClass("java/lang/Boolean");
jmethodID constructor = env->GetMethodID(clazz, "<init>", "(Z)V");
jobject javaBoolean = env->functions->NewObject(env, clazz, constructor, boolValue);
result.l = javaBoolean;
} else if (value.isUndefined()) {
UString stringValue = "undefined";
JNIEnv* env = getJNIEnv();
jobject javaString = env->functions->NewString(env, (const jchar*)stringValue.characters(), stringValue.length());
result.l = javaString;
}
}
// 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")) {
if (!value.isNull()) {
UString stringValue = value.toString(exec);
JNIEnv* env = getJNIEnv();
jobject javaString = env->functions->NewString(env, (const jchar*)stringValue.characters(), stringValue.length());
result.l = javaString;
}
}
}
break;
case JavaTypeBoolean:
{
result.z = (jboolean)value.toNumber(exec);
}
break;
case JavaTypeByte:
{
result.b = (jbyte)value.toNumber(exec);
}
break;
case JavaTypeChar:
{
//.........这里部分代码省略.........
示例15: lengthGetter
JSValue* RuntimeArray::lengthGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
RuntimeArray* thisObj = static_cast<RuntimeArray*>(asObject(slot.slotBase()));
return jsNumber(exec, thisObj->getLength());
}