mirror of
https://github.com/oven-sh/bun
synced 2026-02-16 22:01:47 +00:00
Fixes for AARCH64:
This commit is contained in:
@@ -168,7 +168,7 @@ pub const Instance = NewClass(
|
||||
},
|
||||
},
|
||||
.{
|
||||
.@"pathname" = .{
|
||||
.pathname = .{
|
||||
.get = getPathname,
|
||||
.ro = true,
|
||||
.ts = d.ts{
|
||||
@@ -204,8 +204,8 @@ pub const Instance = NewClass(
|
||||
.@"return" = "\"exact\" | \"dynamic\" | \"catch-all\" | \"optional-catch-all\"",
|
||||
},
|
||||
},
|
||||
.@"name" = .{
|
||||
.@"get" = getRoute,
|
||||
.name = .{
|
||||
.get = getRoute,
|
||||
.ro = true,
|
||||
.ts = d.ts{
|
||||
.@"return" = "string",
|
||||
@@ -219,7 +219,7 @@ pub const Instance = NewClass(
|
||||
},
|
||||
},
|
||||
.query = .{
|
||||
.@"get" = getQuery,
|
||||
.get = getQuery,
|
||||
.ro = true,
|
||||
.ts = d.ts{
|
||||
.@"return" = "Record<string, string | string[]>",
|
||||
@@ -236,7 +236,7 @@ pub const Instance = NewClass(
|
||||
},
|
||||
},
|
||||
.params = .{
|
||||
.@"get" = getParams,
|
||||
.get = getParams,
|
||||
.ro = true,
|
||||
.ts = d.ts{
|
||||
.@"return" = "Record<string, string | string[]>",
|
||||
|
||||
@@ -724,17 +724,51 @@ pub fn NewClass(
|
||||
var function_name_refs: [function_names.len]js.JSStringRef = undefined;
|
||||
var class_name_str = name[0.. :0].ptr;
|
||||
|
||||
const class_name_literal = std.unicode.utf8ToUtf16LeStringLiteral(name);
|
||||
var static_functions: [function_name_refs.len + 1]js.JSStaticFunction = undefined;
|
||||
var instance_functions: [function_names.len]js.JSObjectRef = undefined;
|
||||
var static_functions = brk: {
|
||||
var funcs: [function_name_refs.len + 1]js.JSStaticFunction = undefined;
|
||||
std.mem.set(js.JSStaticFunction, &funcs, js.JSStaticFunction{
|
||||
.name = @intToPtr([*c]const u8, 0),
|
||||
.callAsFunction = null,
|
||||
.attributes = js.JSPropertyAttributes.kJSPropertyAttributeNone,
|
||||
},);
|
||||
break :brk funcs;
|
||||
};
|
||||
var instance_functions = std.mem.zeroes([function_names.len]js.JSObjectRef);
|
||||
const property_names = std.meta.fieldNames(@TypeOf(properties));
|
||||
var property_name_refs: [property_names.len]js.JSStringRef = undefined;
|
||||
var property_name_refs = std.mem.zeroes([property_names.len]js.JSStringRef);
|
||||
const property_name_literals = property_names;
|
||||
var static_properties: [property_names.len]js.JSStaticValue = undefined;
|
||||
var static_properties = brk: {
|
||||
var props: [property_names.len]js.JSStaticValue = undefined;
|
||||
std.mem.set(js.JSStaticValue, &props, js.JSStaticValue{
|
||||
.name = @intToPtr([*c]const u8, 0),
|
||||
.getProperty = null,
|
||||
.setProperty = null,
|
||||
.attributes = js.JSPropertyAttributes.kJSPropertyAttributeNone,
|
||||
},);
|
||||
break :brk props;
|
||||
};
|
||||
|
||||
pub var ref: js.JSClassRef = null;
|
||||
pub var loaded = false;
|
||||
pub var definition: js.JSClassDefinition = undefined;
|
||||
pub var definition: js.JSClassDefinition =.{
|
||||
.version = 0,
|
||||
.attributes = js.JSClassAttributes.kJSClassAttributeNone,
|
||||
.className = name[0..:0].ptr,
|
||||
.parentClass = null,
|
||||
.staticValues = null,
|
||||
.staticFunctions = null,
|
||||
.initialize = null,
|
||||
.finalize = null,
|
||||
.hasProperty = null,
|
||||
.getProperty = null,
|
||||
.setProperty = null,
|
||||
.deleteProperty = null,
|
||||
.getPropertyNames = null,
|
||||
.callAsFunction = null,
|
||||
.callAsConstructor = null,
|
||||
.hasInstance = null,
|
||||
.convertToType = null,
|
||||
};
|
||||
const ConstructorWrapper = struct {
|
||||
pub fn rfn(
|
||||
ctx: js.JSContextRef,
|
||||
@@ -1274,7 +1308,25 @@ pub fn NewClass(
|
||||
}
|
||||
|
||||
pub fn define() js.JSClassDefinition {
|
||||
var def = js.kJSClassDefinitionEmpty;
|
||||
var def = js.JSClassDefinition{
|
||||
.version = 0,
|
||||
.attributes = js.JSClassAttributes.kJSClassAttributeNone,
|
||||
.className = class_name_str,
|
||||
.parentClass = null,
|
||||
.staticValues = null,
|
||||
.staticFunctions = null,
|
||||
.initialize = null,
|
||||
.finalize = null,
|
||||
.hasProperty = null,
|
||||
.getProperty = null,
|
||||
.setProperty = null,
|
||||
.deleteProperty = null,
|
||||
.getPropertyNames = null,
|
||||
.callAsFunction = null,
|
||||
.callAsConstructor = null,
|
||||
.hasInstance = null,
|
||||
.convertToType = null,
|
||||
};
|
||||
|
||||
if (static_functions.len > 0) {
|
||||
std.mem.set(js.JSStaticFunction, &static_functions, std.mem.zeroes(js.JSStaticFunction));
|
||||
|
||||
@@ -221,9 +221,11 @@ JSC::Identifier GlobalObject::moduleLoaderResolve(JSGlobalObject *globalObject,
|
||||
JSValue referrer, JSValue origin) {
|
||||
ErrorableZigString res;
|
||||
res.success = false;
|
||||
Zig__GlobalObject__resolve(&res, globalObject, toZigString(key, globalObject),
|
||||
referrer.isString() ? toZigString(referrer, globalObject)
|
||||
: ZigStringEmpty);
|
||||
ZigString keyZ = toZigString(key, globalObject);
|
||||
ZigString referrerZ = referrer.isString() ? toZigString(referrer, globalObject) : ZigStringEmpty;
|
||||
Zig__GlobalObject__resolve(&res, globalObject, &keyZ,
|
||||
&referrerZ
|
||||
);
|
||||
|
||||
if (res.success) {
|
||||
return toIdentifier(res.result.value, globalObject);
|
||||
@@ -247,10 +249,12 @@ JSC::JSInternalPromise *GlobalObject::moduleLoaderImportModule(JSGlobalObject *g
|
||||
|
||||
auto sourceURL = sourceOrigin.url();
|
||||
ErrorableZigString resolved;
|
||||
auto moduleNameZ = toZigString(moduleNameValue, globalObject);
|
||||
auto sourceOriginZ = sourceURL.isEmpty() ? ZigStringCwd
|
||||
: toZigString(sourceURL.fileSystemPath());
|
||||
resolved.success = false;
|
||||
Zig__GlobalObject__resolve(&resolved, globalObject, toZigString(moduleNameValue, globalObject),
|
||||
sourceURL.isEmpty() ? ZigStringCwd
|
||||
: toZigString(sourceURL.fileSystemPath()));
|
||||
Zig__GlobalObject__resolve(&resolved, globalObject, &moduleNameZ, &sourceOriginZ
|
||||
);
|
||||
if (!resolved.success) {
|
||||
throwException(scope, resolved.result.err, globalObject);
|
||||
return promise->rejectWithCaughtException(globalObject, scope);
|
||||
@@ -372,13 +376,14 @@ JSC::JSInternalPromise *GlobalObject::moduleLoaderFetch(JSGlobalObject *globalOb
|
||||
auto moduleKey = key.toWTFString(globalObject);
|
||||
RETURN_IF_EXCEPTION(scope, promise->rejectWithCaughtException(globalObject, scope));
|
||||
auto moduleKeyZig = toZigString(moduleKey);
|
||||
auto source = Zig::toZigString(value1, globalObject);
|
||||
ErrorableResolvedSource res;
|
||||
res.success = false;
|
||||
res.result.err.code = 0;
|
||||
res.result.err.ptr = nullptr;
|
||||
|
||||
Zig__GlobalObject__fetch(&res, globalObject, moduleKeyZig,
|
||||
Zig::toZigString(value1, globalObject));
|
||||
Zig__GlobalObject__fetch(&res, globalObject, &moduleKeyZig,
|
||||
&source );
|
||||
|
||||
if (!res.success) {
|
||||
throwException(scope, res.result.err, globalObject);
|
||||
|
||||
@@ -257,22 +257,22 @@ pub fn NewGlobalObject(comptime Type: type) type {
|
||||
const importNotImpl = "Import not implemented";
|
||||
const resolveNotImpl = "resolve not implemented";
|
||||
const moduleNotImpl = "Module fetch not implemented";
|
||||
pub fn import(global: *JSGlobalObject, specifier: ZigString, source: ZigString) callconv(.C) ErrorableZigString {
|
||||
pub fn import(global: *JSGlobalObject, specifier: *ZigString, source: *ZigString) callconv(.C) ErrorableZigString {
|
||||
if (comptime @hasDecl(Type, "import")) {
|
||||
return @call(.{ .modifier = .always_inline }, Type.import, .{ global, specifier, source });
|
||||
return @call(.{ .modifier = .always_inline }, Type.import, .{ global, specifier.*, source.* });
|
||||
}
|
||||
return ErrorableZigString.err(error.ImportFailed, ZigString.init(importNotImpl).toErrorInstance(global).asVoid());
|
||||
}
|
||||
pub fn resolve(res: *ErrorableZigString, global: *JSGlobalObject, specifier: ZigString, source: ZigString) callconv(.C) void {
|
||||
pub fn resolve(res: *ErrorableZigString, global: *JSGlobalObject, specifier: *ZigString, source: *ZigString) callconv(.C) void {
|
||||
if (comptime @hasDecl(Type, "resolve")) {
|
||||
@call(.{ .modifier = .always_inline }, Type.resolve, .{ res, global, specifier, source });
|
||||
@call(.{ .modifier = .always_inline }, Type.resolve, .{ res, global, specifier.*, source.* });
|
||||
return;
|
||||
}
|
||||
res.* = ErrorableZigString.err(error.ResolveFailed, ZigString.init(resolveNotImpl).toErrorInstance(global).asVoid());
|
||||
}
|
||||
pub fn fetch(ret: *ErrorableResolvedSource, global: *JSGlobalObject, specifier: ZigString, source: ZigString) callconv(.C) void {
|
||||
pub fn fetch(ret: *ErrorableResolvedSource, global: *JSGlobalObject, specifier: *ZigString, source: *ZigString) callconv(.C) void {
|
||||
if (comptime @hasDecl(Type, "fetch")) {
|
||||
@call(.{ .modifier = .always_inline }, Type.fetch, .{ ret, global, specifier, source });
|
||||
@call(.{ .modifier = .always_inline }, Type.fetch, .{ ret, global, specifier.*, source.* });
|
||||
return;
|
||||
}
|
||||
ret.* = ErrorableResolvedSource.err(error.FetchFailed, ZigString.init(moduleNotImpl).toErrorInstance(global).asVoid());
|
||||
|
||||
@@ -61,20 +61,20 @@ pub const ZigGlobalObject = extern struct {
|
||||
return shim.cppFn("resetModuleRegistryMap", .{ global, map });
|
||||
}
|
||||
|
||||
pub fn import(global: *JSGlobalObject, specifier: ZigString, source: ZigString) callconv(.C) ErrorableZigString {
|
||||
pub fn import(global: *JSGlobalObject, specifier: *ZigString, source: *ZigString) callconv(.C) ErrorableZigString {
|
||||
if (comptime is_bindgen) {
|
||||
unreachable;
|
||||
}
|
||||
|
||||
return @call(.{ .modifier = .always_inline }, Interface.import, .{ global, specifier, source });
|
||||
}
|
||||
pub fn resolve(res: *ErrorableZigString, global: *JSGlobalObject, specifier: ZigString, source: ZigString) callconv(.C) void {
|
||||
pub fn resolve(res: *ErrorableZigString, global: *JSGlobalObject, specifier: *ZigString, source: *ZigString) callconv(.C) void {
|
||||
if (comptime is_bindgen) {
|
||||
unreachable;
|
||||
}
|
||||
@call(.{ .modifier = .always_inline }, Interface.resolve, .{ res, global, specifier, source });
|
||||
}
|
||||
pub fn fetch(ret: *ErrorableResolvedSource, global: *JSGlobalObject, specifier: ZigString, source: ZigString) callconv(.C) void {
|
||||
pub fn fetch(ret: *ErrorableResolvedSource, global: *JSGlobalObject, specifier: *ZigString, source: *ZigString) callconv(.C) void {
|
||||
if (comptime is_bindgen) {
|
||||
unreachable;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//-- AUTOGENERATED FILE -- 1630884061
|
||||
//-- AUTOGENERATED FILE -- 1631085611
|
||||
// clang-format off
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//-- AUTOGENERATED FILE -- 1630884061
|
||||
//-- AUTOGENERATED FILE -- 1631085611
|
||||
// clang-format: off
|
||||
#pragma once
|
||||
|
||||
@@ -578,12 +578,12 @@ CPP_DECL bool Zig__GlobalObject__resetModuleRegistryMap(JSC__JSGlobalObject* arg
|
||||
#ifdef __cplusplus
|
||||
|
||||
ZIG_DECL JSC__JSValue Zig__GlobalObject__createImportMetaProperties(JSC__JSGlobalObject* arg0, JSC__JSModuleLoader* arg1, JSC__JSValue JSValue2, JSC__JSModuleRecord* arg3, JSC__JSValue JSValue4);
|
||||
ZIG_DECL void Zig__GlobalObject__fetch(ErrorableResolvedSource* arg0, JSC__JSGlobalObject* arg1, ZigString arg2, ZigString arg3);
|
||||
ZIG_DECL ErrorableZigString Zig__GlobalObject__import(JSC__JSGlobalObject* arg0, ZigString arg1, ZigString arg2);
|
||||
ZIG_DECL void Zig__GlobalObject__fetch(ErrorableResolvedSource* arg0, JSC__JSGlobalObject* arg1, ZigString* arg2, ZigString* arg3);
|
||||
ZIG_DECL ErrorableZigString Zig__GlobalObject__import(JSC__JSGlobalObject* arg0, ZigString* arg1, ZigString* arg2);
|
||||
ZIG_DECL void Zig__GlobalObject__onCrash();
|
||||
ZIG_DECL JSC__JSValue Zig__GlobalObject__promiseRejectionTracker(JSC__JSGlobalObject* arg0, JSC__JSPromise* arg1, uint32_t JSPromiseRejectionOperation2);
|
||||
ZIG_DECL JSC__JSValue Zig__GlobalObject__reportUncaughtException(JSC__JSGlobalObject* arg0, JSC__Exception* arg1);
|
||||
ZIG_DECL void Zig__GlobalObject__resolve(ErrorableZigString* arg0, JSC__JSGlobalObject* arg1, ZigString arg2, ZigString arg3);
|
||||
ZIG_DECL void Zig__GlobalObject__resolve(ErrorableZigString* arg0, JSC__JSGlobalObject* arg1, ZigString* arg2, ZigString* arg3);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -299,7 +299,6 @@ pub const Bun = struct {
|
||||
},
|
||||
},
|
||||
.{
|
||||
.Route = Router.Instance.GetClass(void){},
|
||||
.main = .{
|
||||
.get = getMain,
|
||||
.ts = d.ts{ .name = "main", .@"return" = "string" },
|
||||
|
||||
Reference in New Issue
Block a user