mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
Refactor Zig imports and file structure (part 1) (#21270)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -20,7 +20,7 @@ flags: packed struct(u8) {
|
||||
_padding: u1 = 0,
|
||||
} = .{},
|
||||
|
||||
pub fn getTarget(this: *PostgresSQLQuery, globalObject: *JSC.JSGlobalObject, clean_target: bool) JSC.JSValue {
|
||||
pub fn getTarget(this: *PostgresSQLQuery, globalObject: *jsc.JSGlobalObject, clean_target: bool) jsc.JSValue {
|
||||
const thisValue = this.thisValue.get();
|
||||
if (thisValue == .zero) {
|
||||
return .zero;
|
||||
@@ -90,7 +90,7 @@ pub fn ref(this: *@This()) void {
|
||||
pub fn onWriteFail(
|
||||
this: *@This(),
|
||||
err: AnyPostgresError,
|
||||
globalObject: *JSC.JSGlobalObject,
|
||||
globalObject: *jsc.JSGlobalObject,
|
||||
queries_array: JSValue,
|
||||
) void {
|
||||
this.status = .fail;
|
||||
@@ -101,7 +101,7 @@ pub fn onWriteFail(
|
||||
return;
|
||||
}
|
||||
|
||||
const vm = JSC.VirtualMachine.get();
|
||||
const vm = jsc.VirtualMachine.get();
|
||||
const function = vm.rareData().postgresql_context.onQueryRejectFn.get().?;
|
||||
const event_loop = vm.eventLoop();
|
||||
event_loop.runCallback(function, globalObject, thisValue, &.{
|
||||
@@ -110,7 +110,7 @@ pub fn onWriteFail(
|
||||
queries_array,
|
||||
});
|
||||
}
|
||||
pub fn onJSError(this: *@This(), err: JSC.JSValue, globalObject: *JSC.JSGlobalObject) void {
|
||||
pub fn onJSError(this: *@This(), err: jsc.JSValue, globalObject: *jsc.JSGlobalObject) void {
|
||||
this.status = .fail;
|
||||
this.ref();
|
||||
defer this.deref();
|
||||
@@ -122,7 +122,7 @@ pub fn onJSError(this: *@This(), err: JSC.JSValue, globalObject: *JSC.JSGlobalOb
|
||||
return;
|
||||
}
|
||||
|
||||
var vm = JSC.VirtualMachine.get();
|
||||
var vm = jsc.VirtualMachine.get();
|
||||
const function = vm.rareData().postgresql_context.onQueryRejectFn.get().?;
|
||||
const event_loop = vm.eventLoop();
|
||||
event_loop.runCallback(function, globalObject, thisValue, &.{
|
||||
@@ -130,11 +130,11 @@ pub fn onJSError(this: *@This(), err: JSC.JSValue, globalObject: *JSC.JSGlobalOb
|
||||
err,
|
||||
});
|
||||
}
|
||||
pub fn onError(this: *@This(), err: PostgresSQLStatement.Error, globalObject: *JSC.JSGlobalObject) void {
|
||||
pub fn onError(this: *@This(), err: PostgresSQLStatement.Error, globalObject: *jsc.JSGlobalObject) void {
|
||||
this.onJSError(err.toJS(globalObject), globalObject);
|
||||
}
|
||||
|
||||
pub fn allowGC(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject) void {
|
||||
pub fn allowGC(thisValue: jsc.JSValue, globalObject: *jsc.JSGlobalObject) void {
|
||||
if (thisValue == .zero) {
|
||||
return;
|
||||
}
|
||||
@@ -145,13 +145,13 @@ pub fn allowGC(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject) void {
|
||||
js.targetSetCached(thisValue, globalObject, .zero);
|
||||
}
|
||||
|
||||
fn consumePendingValue(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject) ?JSValue {
|
||||
fn consumePendingValue(thisValue: jsc.JSValue, globalObject: *jsc.JSGlobalObject) ?JSValue {
|
||||
const pending_value = js.pendingValueGetCached(thisValue) orelse return null;
|
||||
js.pendingValueSetCached(thisValue, globalObject, .zero);
|
||||
return pending_value;
|
||||
}
|
||||
|
||||
pub fn onResult(this: *@This(), command_tag_str: []const u8, globalObject: *JSC.JSGlobalObject, connection: JSC.JSValue, is_last: bool) void {
|
||||
pub fn onResult(this: *@This(), command_tag_str: []const u8, globalObject: *jsc.JSGlobalObject, connection: jsc.JSValue, is_last: bool) void {
|
||||
this.ref();
|
||||
defer this.deref();
|
||||
|
||||
@@ -170,7 +170,7 @@ pub fn onResult(this: *@This(), command_tag_str: []const u8, globalObject: *JSC.
|
||||
return;
|
||||
}
|
||||
|
||||
const vm = JSC.VirtualMachine.get();
|
||||
const vm = jsc.VirtualMachine.get();
|
||||
const function = vm.rareData().postgresql_context.onQueryResolveFn.get().?;
|
||||
const event_loop = vm.eventLoop();
|
||||
const tag = CommandTag.init(command_tag_str);
|
||||
@@ -185,7 +185,7 @@ pub fn onResult(this: *@This(), command_tag_str: []const u8, globalObject: *JSC.
|
||||
});
|
||||
}
|
||||
|
||||
pub fn constructor(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!*PostgresSQLQuery {
|
||||
pub fn constructor(globalThis: *jsc.JSGlobalObject, callframe: *jsc.CallFrame) bun.JSError!*PostgresSQLQuery {
|
||||
_ = callframe;
|
||||
return globalThis.throw("PostgresSQLQuery cannot be constructed directly", .{});
|
||||
}
|
||||
@@ -195,9 +195,9 @@ pub fn estimatedSize(this: *PostgresSQLQuery) usize {
|
||||
return @sizeOf(PostgresSQLQuery);
|
||||
}
|
||||
|
||||
pub fn call(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
pub fn call(globalThis: *jsc.JSGlobalObject, callframe: *jsc.CallFrame) bun.JSError!jsc.JSValue {
|
||||
const arguments = callframe.arguments_old(6).slice();
|
||||
var args = JSC.CallFrame.ArgumentsSlice.init(globalThis.bunVM(), arguments);
|
||||
var args = jsc.CallFrame.ArgumentsSlice.init(globalThis.bunVM(), arguments);
|
||||
defer args.deinit();
|
||||
const query = args.nextEat() orelse {
|
||||
return globalThis.throw("query must be a string", .{});
|
||||
@@ -256,22 +256,22 @@ pub fn call(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSEr
|
||||
return this_value;
|
||||
}
|
||||
|
||||
pub fn push(this: *PostgresSQLQuery, globalThis: *JSC.JSGlobalObject, value: JSValue) void {
|
||||
pub fn push(this: *PostgresSQLQuery, globalThis: *jsc.JSGlobalObject, value: JSValue) void {
|
||||
var pending_value = this.pending_value.get() orelse return;
|
||||
pending_value.push(globalThis, value);
|
||||
}
|
||||
|
||||
pub fn doDone(this: *@This(), globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) bun.JSError!JSValue {
|
||||
pub fn doDone(this: *@This(), globalObject: *jsc.JSGlobalObject, _: *jsc.CallFrame) bun.JSError!JSValue {
|
||||
_ = globalObject;
|
||||
this.flags.is_done = true;
|
||||
return .js_undefined;
|
||||
}
|
||||
pub fn setPendingValue(this: *PostgresSQLQuery, globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSValue {
|
||||
pub fn setPendingValue(this: *PostgresSQLQuery, globalObject: *jsc.JSGlobalObject, callframe: *jsc.CallFrame) bun.JSError!JSValue {
|
||||
const result = callframe.argument(0);
|
||||
js.pendingValueSetCached(this.thisValue.get(), globalObject, result);
|
||||
return .js_undefined;
|
||||
}
|
||||
pub fn setMode(this: *PostgresSQLQuery, globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSValue {
|
||||
pub fn setMode(this: *PostgresSQLQuery, globalObject: *jsc.JSGlobalObject, callframe: *jsc.CallFrame) bun.JSError!JSValue {
|
||||
const js_mode = callframe.argument(0);
|
||||
if (js_mode.isEmptyOrUndefinedOrNull() or !js_mode.isNumber()) {
|
||||
return globalObject.throwInvalidArgumentType("setMode", "mode", "Number");
|
||||
@@ -284,7 +284,7 @@ pub fn setMode(this: *PostgresSQLQuery, globalObject: *JSC.JSGlobalObject, callf
|
||||
return .js_undefined;
|
||||
}
|
||||
|
||||
pub fn doRun(this: *PostgresSQLQuery, globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSValue {
|
||||
pub fn doRun(this: *PostgresSQLQuery, globalObject: *jsc.JSGlobalObject, callframe: *jsc.CallFrame) bun.JSError!JSValue {
|
||||
var arguments_ = callframe.arguments_old(2);
|
||||
const arguments = arguments_.slice();
|
||||
const connection: *PostgresSQLConnection = arguments[0].as(PostgresSQLConnection) orelse {
|
||||
@@ -465,7 +465,7 @@ pub fn doRun(this: *PostgresSQLQuery, globalObject: *JSC.JSGlobalObject, callfra
|
||||
return .js_undefined;
|
||||
}
|
||||
|
||||
pub fn doCancel(this: *PostgresSQLQuery, globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSValue {
|
||||
pub fn doCancel(this: *PostgresSQLQuery, globalObject: *jsc.JSGlobalObject, callframe: *jsc.CallFrame) bun.JSError!JSValue {
|
||||
_ = callframe;
|
||||
_ = globalObject;
|
||||
_ = this;
|
||||
@@ -474,13 +474,13 @@ pub fn doCancel(this: *PostgresSQLQuery, globalObject: *JSC.JSGlobalObject, call
|
||||
}
|
||||
|
||||
comptime {
|
||||
const jscall = JSC.toJSHostFn(call);
|
||||
const jscall = jsc.toJSHostFn(call);
|
||||
@export(&jscall, .{ .name = "PostgresSQLQuery__createInstance" });
|
||||
}
|
||||
|
||||
const debug = bun.Output.scoped(.Postgres, false);
|
||||
|
||||
pub const js = JSC.Codegen.JSPostgresSQLQuery;
|
||||
pub const js = jsc.Codegen.JSPostgresSQLQuery;
|
||||
pub const fromJS = js.fromJS;
|
||||
pub const fromJSDirect = js.fromJSDirect;
|
||||
pub const toJS = js.toJS;
|
||||
@@ -498,7 +498,7 @@ const PostgresSQLQueryResultMode = @import("./PostgresSQLQueryResultMode.zig").P
|
||||
const AnyPostgresError = @import("./AnyPostgresError.zig").AnyPostgresError;
|
||||
const postgresErrorToJS = @import("./AnyPostgresError.zig").postgresErrorToJS;
|
||||
|
||||
const JSC = bun.JSC;
|
||||
const JSGlobalObject = JSC.JSGlobalObject;
|
||||
const JSRef = JSC.JSRef;
|
||||
const JSValue = JSC.JSValue;
|
||||
const jsc = bun.jsc;
|
||||
const JSGlobalObject = jsc.JSGlobalObject;
|
||||
const JSRef = jsc.JSRef;
|
||||
const JSValue = jsc.JSValue;
|
||||
|
||||
Reference in New Issue
Block a user