mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 04:18:58 +00:00
fix instanceof checks for classes
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
#include <JavaScriptCore/AggregateError.h>
|
||||
#include <JavaScriptCore/BytecodeIndex.h>
|
||||
#include <JavaScriptCore/CallFrameInlines.h>
|
||||
|
||||
#include <JavaScriptCore/ClassInfo.h>
|
||||
#include <JavaScriptCore/CodeBlock.h>
|
||||
#include <JavaScriptCore/CodeCache.h>
|
||||
@@ -23,6 +22,7 @@
|
||||
#include <JavaScriptCore/IteratorOperations.h>
|
||||
#include <JavaScriptCore/JSArray.h>
|
||||
#include <JavaScriptCore/JSCInlines.h>
|
||||
#include <JavaScriptCore/JSCallbackConstructor.h>
|
||||
#include <JavaScriptCore/JSCallbackObject.h>
|
||||
#include <JavaScriptCore/JSCast.h>
|
||||
#include <JavaScriptCore/JSClassRef.h>
|
||||
@@ -231,13 +231,15 @@ extern "C" JSC__JSValue JSC__JSValue__makeWithNameAndPrototype(JSC__JSGlobalObje
|
||||
auto& vm = globalObject->vm();
|
||||
JSClassRef jsClass = reinterpret_cast<JSClassRef>(arg1);
|
||||
JSClassRef protoClass = reinterpret_cast<JSClassRef>(arg2);
|
||||
JSObjectRef objectRef = JSObjectMake(reinterpret_cast<JSContextRef>(globalObject), jsClass, nullptr);
|
||||
JSObjectRef objectRef = JSObjectMakeConstructor(reinterpret_cast<JSContextRef>(globalObject), protoClass, jsClass->callAsConstructor);
|
||||
JSObjectRef wrappedRef = JSObjectMake(reinterpret_cast<JSContextRef>(globalObject), jsClass, nullptr);
|
||||
JSC::JSObject* object = JSC::JSValue::decode(reinterpret_cast<JSC__JSValue>(objectRef)).getObject();
|
||||
JSC::JSObject* wrapped = JSC::JSValue::decode(reinterpret_cast<JSC__JSValue>(wrappedRef)).getObject();
|
||||
object->setPrototypeDirect(vm, wrapped);
|
||||
JSString* nameString = JSC::jsNontrivialString(vm, Zig::toString(*visibleInterfaceName));
|
||||
object->putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
|
||||
object->putDirect(vm, vm.propertyNames->toStringTagSymbol,
|
||||
nameString, JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly);
|
||||
object->putDirect(vm, vm.propertyNames->prototype, JSC::JSValue::decode(reinterpret_cast<JSC__JSValue>(JSObjectMake(reinterpret_cast<JSContextRef>(globalObject), protoClass, nullptr))), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete);
|
||||
|
||||
return JSC::JSValue::encode(JSC::JSValue(object));
|
||||
}
|
||||
@@ -590,17 +592,14 @@ static JSC_DEFINE_HOST_FUNCTION(functionReportError,
|
||||
// and any other objects available globally.
|
||||
void GlobalObject::installAPIGlobals(JSClassRef* globals, int count)
|
||||
{
|
||||
|
||||
auto clientData = Bun::clientData(vm());
|
||||
size_t constructor_count = 0;
|
||||
JSC__JSValue const* constructors = Zig__getAPIConstructors(&constructor_count, this);
|
||||
WTF::Vector<GlobalPropertyInfo> extraStaticGlobals;
|
||||
extraStaticGlobals.reserveCapacity((size_t)count + constructor_count + 3 + 9);
|
||||
extraStaticGlobals.reserveCapacity((size_t)count + constructor_count + 3 + 10);
|
||||
int i = 0;
|
||||
for (; i < constructor_count; i++) {
|
||||
auto* object = JSC::jsDynamicCast<JSC::JSCallbackObject<JSNonFinalObject>*>(vm(), JSC::JSValue::decode(constructors[i]).asCell()->getObject());
|
||||
if (JSObject* prototype = object->classRef()->prototype(this))
|
||||
object->setPrototypeDirect(vm(), prototype);
|
||||
auto* object = JSC::jsDynamicCast<JSC::JSCallbackConstructor*>(vm(), JSC::JSValue::decode(constructors[i]).asCell()->getObject());
|
||||
|
||||
extraStaticGlobals.uncheckedAppend(
|
||||
GlobalPropertyInfo { JSC::Identifier::fromString(vm(), object->get(this, vm().propertyNames->name).toWTFString(this)),
|
||||
|
||||
Reference in New Issue
Block a user