bool V8DOMWrapper::isWrapperOfType(v8::Handle<v8::Value> value, WrapperTypeInfo* type) { if (!isValidDOMObject(value)) return false; v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value); ASSERT(object->InternalFieldCount() >= v8DefaultWrapperInternalFieldCount); v8::Handle<v8::Value> wrapper = object->GetInternalField(v8DOMWrapperObjectIndex); ASSERT(wrapper->IsNumber() || wrapper->IsExternal()); WrapperTypeInfo* typeInfo = static_cast<WrapperTypeInfo*>(object->GetPointerFromInternalField(v8DOMWrapperTypeIndex)); return typeInfo == type; }
bool V8DOMWrapper::isWrapperOfType(v8::Handle<v8::Value> value, V8ClassIndex::V8WrapperType classType) { if (!isValidDOMObject(value)) return false; v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value); ASSERT(object->InternalFieldCount() >= v8DefaultWrapperInternalFieldCount); v8::Handle<v8::Value> wrapper = object->GetInternalField(v8DOMWrapperObjectIndex); ASSERT(wrapper->IsNumber() || wrapper->IsExternal()); v8::Handle<v8::Value> type = object->GetInternalField(v8DOMWrapperTypeIndex); ASSERT(type->IsInt32()); ASSERT(V8ClassIndex::INVALID_CLASS_INDEX < type->Int32Value() && type->Int32Value() < V8ClassIndex::CLASSINDEX_END); return V8ClassIndex::FromInt(type->Int32Value()) == classType; }