v8::Local<v8::Value> v8InternalValueTypeFrom(v8::Local<v8::Context> context, v8::Local<v8::Object> object)
{
    v8::Isolate* isolate = context->GetIsolate();
    v8::Local<v8::Private> privateValue = internalSubtypePrivate(isolate);
    if (!object->HasPrivate(context, privateValue).FromMaybe(false))
        return v8::Null(isolate);
    v8::Local<v8::Value> subtypeValue;
    if (!object->GetPrivate(context, privateValue).ToLocal(&subtypeValue) || !subtypeValue->IsString())
        return v8::Null(isolate);
    return subtypeValue;
}
Exemple #2
0
v8::Local<v8::Value> V8HiddenValue::getHiddenValue(ScriptState* scriptState,
        v8::Local<v8::Object> object,
        v8::Local<v8::String> key) {
    v8::Local<v8::Context> context = scriptState->context();
    v8::Local<v8::Private> privateKey =
        v8::Private::ForApi(scriptState->isolate(), key);
    v8::Local<v8::Value> value;
    // Callsites interpret an empty handle has absence of a result.
    if (!v8CallBoolean(object->HasPrivate(context, privateKey)))
        return v8::Local<v8::Value>();
    if (object->GetPrivate(context, privateKey).ToLocal(&value))
        return value;
    return v8::Local<v8::Value>();
}