aboutsummaryrefslogtreecommitdiff
path: root/src/javascript/jsc
diff options
context:
space:
mode:
Diffstat (limited to 'src/javascript/jsc')
-rw-r--r--src/javascript/jsc/bindings/DefaultGlobal.zig131
-rw-r--r--src/javascript/jsc/bindings/header-gen.zig47
-rw-r--r--src/javascript/jsc/bindings/headers.h55
3 files changed, 188 insertions, 45 deletions
diff --git a/src/javascript/jsc/bindings/DefaultGlobal.zig b/src/javascript/jsc/bindings/DefaultGlobal.zig
index fc548e1be..7a401fec1 100644
--- a/src/javascript/jsc/bindings/DefaultGlobal.zig
+++ b/src/javascript/jsc/bindings/DefaultGlobal.zig
@@ -444,7 +444,7 @@ pub const JSFunction = opaque {
function: *JSFunction,
thisValue: *JSValue,
globalThis: *JSGlobalObject,
- arguments_ptr: **JSValue,
+ arguments_ptr: [*]*JSValue,
arguments_len: usize,
exception: *?*Exception,
error_message: ?*const u8,
@@ -463,7 +463,7 @@ pub const JSFunction = opaque {
pub fn callWithArguments(
function: *JSFunction,
globalThis: *JSGlobalObject,
- arguments_ptr: **JSValue,
+ arguments_ptr: [*]*JSValue,
arguments_len: usize,
exception: *?*Exception,
error_message: ?*const u8,
@@ -500,7 +500,7 @@ pub const JSFunction = opaque {
function: *JSFunction,
newTarget: *JSValue,
globalThis: *JSGlobalObject,
- arguments_ptr: **JSValue,
+ arguments_ptr: [*]*JSValue,
arguments_len: usize,
exception: *?*Exception,
error_message: ?*const u8,
@@ -519,7 +519,7 @@ pub const JSFunction = opaque {
pub fn constructWithArguments(
function: *JSFunction,
globalThis: *JSGlobalObject,
- arguments_ptr: **JSValue,
+ arguments_ptr: [*]*JSValue,
arguments_len: usize,
exception: *?*Exception,
error_message: ?*const u8,
@@ -984,6 +984,9 @@ pub const JSValue = opaque {
pub fn isNumber(this: *JSValue) bool {
return cppFn("isNumber", .{this});
}
+ pub fn isError(this: *JSValue) bool {
+ return cppFn("isError", .{this});
+ }
pub fn isString(this: *JSValue) bool {
return cppFn("isString", .{this});
}
@@ -1059,7 +1062,31 @@ pub const JSValue = opaque {
return cppFn("eqlCell", .{ this, other });
}
- pub const Extern = [_][]const u8{ "jsNull", "jsUndefined", "jsTDZValue", "jsBoolean", "jsDoubleNumber", "jsNumberFromDouble", "jsNumberFromChar", "jsNumberFromU16", "jsNumberFromInt32", "jsNumberFromInt64", "jsNumberFromUint64", "isUndefined", "isNull", "isUndefinedOrNull", "isBoolean", "isAnyInt", "isUInt32AsAnyInt", "isInt32AsAnyInt", "isNumber", "isString", "isBigInt", "isHeapBigInt", "isBigInt32", "isSymbol", "isPrimitive", "isGetterSetter", "isCustomGetterSetter", "isObject", "isCell", "asCell", "toString", "toStringOrNull", "toPropertyKey", "toPropertyKeyValue", "toObject", "toWTFString", "getPrototype", "getPropertyByPropertyName", "eqlValue", "eqlCell" };
+ pub fn asString(this: *JSValue) *JSString {
+ return cppFn("asString", .{
+ this,
+ });
+ }
+
+ pub fn asObject(this: *JSValue) *JSString {
+ return cppFn("asString", .{
+ this,
+ });
+ }
+
+ pub fn asNumber(this: *JSValue) *JSString {
+ return cppFn("asNumber", .{
+ this,
+ });
+ }
+
+ pub fn encode(this: *JSValue) u64 {
+ return cppFn("encode", .{
+ this,
+ });
+ }
+
+ pub const Extern = [_][]const u8{ "encode", "asString", "asObject", "asNumber", "isError", "jsNull", "jsUndefined", "jsTDZValue", "jsBoolean", "jsDoubleNumber", "jsNumberFromDouble", "jsNumberFromChar", "jsNumberFromU16", "jsNumberFromInt32", "jsNumberFromInt64", "jsNumberFromUint64", "isUndefined", "isNull", "isUndefinedOrNull", "isBoolean", "isAnyInt", "isUInt32AsAnyInt", "isInt32AsAnyInt", "isNumber", "isString", "isBigInt", "isHeapBigInt", "isBigInt32", "isSymbol", "isPrimitive", "isGetterSetter", "isCustomGetterSetter", "isObject", "isCell", "asCell", "toString", "toStringOrNull", "toPropertyKey", "toPropertyKeyValue", "toObject", "toWTFString", "getPrototype", "getPropertyByPropertyName", "eqlValue", "eqlCell" };
};
pub const PropertyName = opaque {
@@ -1071,13 +1098,27 @@ pub const PropertyName = opaque {
pub const name = "JSC::PropertyName";
pub const namespace = "JSC";
- pub fn eqlToPropertyName(property_name: *PropertyName, other: *PropertyName) bool {
+ pub fn eqlToPropertyName(property_name: *PropertyName, other: *const PropertyName) bool {
return cppFn("eqlToPropertyName", .{ property_name, other });
}
- pub fn eqlToIdentifier(property_name: *PropertyName, other: *Identifier) bool {
+ pub fn eqlToIdentifier(property_name: *PropertyName, other: *const Identifier) bool {
return cppFn("eqlToIdentifier", .{ property_name, other });
}
+
+ pub fn publicName(property_name: *PropertyName) ?*StringImpl {
+ return cppFn("publicName", .{
+ property_name,
+ });
+ }
+
+ pub fn uid(property_name: *PropertyName) ?*StringImpl {
+ return cppFn("uid", .{
+ property_name,
+ });
+ }
+
+ pub const Extern = [_][]const u8{ "eqlToPropertyName", "eqlToIdentifier", "publicName", "uid" };
};
pub const Error = opaque {
@@ -1161,7 +1202,7 @@ pub const VM = opaque {
SmallHeap = 0,
LargeHeap = 1,
};
- pub fn create(heap_type: *HeapType) *VM {
+ pub fn create(heap_type: HeapType) *VM {
return cppFn("create", .{@enumToInt(heap_type)});
}
@@ -1184,8 +1225,66 @@ pub const VM = opaque {
vm,
});
}
+
+ pub fn throwError(vm: *VM, scope: *ThrowScope, message: [*]const u8, len: usize) bool {
+ return cppFn("throwError", .{
+ vm,
+ });
+ }
+
+ pub const Extern = [_][]const u8{ "create", "deinit", "setExecutionForbidden", "executionForbidden", "isEntered", "throwError" };
+};
+
+pub const ExceptionScope = opaque {
+ pub const shim = Shimmer("JSC", "ExceptionScope", @This());
+
+ const cppFn = shim.cppFn;
+
+ pub const include = "<JavaScriptCore/ExceptionScope.h>";
+ pub const name = "JSC::ExceptionScope";
+ pub const namespace = "JSC";
+
+ pub fn declareThrowScope(
+ vm: *VM,
+ function_name: [*]u8,
+ file: [*]u8,
+ line: usize,
+ ) *ThrowScope {
+ return cppFn("declareThrowScope", .{ vm, file, line });
+ }
+
+ pub fn declareCatchScope(
+ vm: *VM,
+ function_name: [*]u8,
+ file: [*]u8,
+ line: usize,
+ ) *CatchScope {
+ return cppFn("declareCatchScope", .{ vm, file, line });
+ }
+
+ pub fn release(this: *ExceptionScope) void {
+ return cppFn("release", .{this});
+ }
+
+ pub fn exception(this: *ExceptionScope) ?*Exception {
+ return cppFn("exception", .{this});
+ }
+
+ pub fn clearException(this: *ExceptionScope) void {
+ return cppFn("clearException", .{this});
+ }
+
+ pub const Extern = [_][]const u8{
+ "release",
+ "declareThrowScope", "declareCatchScope",
+ "release", "exception",
+ "clearException",
+ };
};
+pub const ThrowScope = ExceptionScope;
+pub const CatchScope = ExceptionScope;
+
pub const CallFrame = opaque {
pub const shim = Shimmer("JSC", "CallFrame", @This());
@@ -1195,30 +1294,30 @@ pub const CallFrame = opaque {
pub const name = "JSC::CallFrame";
pub const namespace = "JSC";
- pub fn argumentsCount(call_frame: *const CallFrame) usize {
+ pub inline fn argumentsCount(call_frame: *const CallFrame) usize {
return cppFn("argumentsCount", .{
call_frame,
});
}
- pub fn uncheckedArgument(call_frame: *const CallFrame, i: u16) *JSValue {
+ pub inline fn uncheckedArgument(call_frame: *const CallFrame, i: u16) *JSValue {
return cppFn("uncheckedArgument", .{ call_frame, i });
}
- pub fn argument(call_frame: *const CallFrame, i: u16) *JSValue {
+ pub inline fn argument(call_frame: *const CallFrame, i: u16) *JSValue {
return cppFn("argument", .{
call_frame,
});
}
- pub fn thisValue(call_frame: *const CallFrame) ?*JSValue {
+ pub inline fn thisValue(call_frame: *const CallFrame) ?*JSValue {
return cppFn("thisValue", .{
call_frame,
});
}
- pub fn newTarget(call_frame: *const CallFrame) ?*JSValue {
+ pub inline fn newTarget(call_frame: *const CallFrame) ?*JSValue {
return cppFn("newTarget", .{
call_frame,
});
}
- pub fn jsCallee(call_frame: *const CallFrame) *JSObject {
+ pub inline fn jsCallee(call_frame: *const CallFrame) *JSObject {
return cppFn("jsCallee", .{
call_frame,
});
@@ -1261,8 +1360,6 @@ pub const EncodedJSValue = opaque {
pub const include = "<JavaScriptCore/VM.h>";
pub const name = "JSC::VM";
pub const namespace = "JSC";
-
- // pub const Extern = [_][]const u8{};
};
pub const Identifier = opaque {
@@ -1463,7 +1560,7 @@ pub const StringView = opaque {
};
};
-pub const Cpp = opaque {
+pub const Cpp = struct {
pub const Function = fn (
globalObject: *JSGlobalObject,
callframe: CallFrame,
diff --git a/src/javascript/jsc/bindings/header-gen.zig b/src/javascript/jsc/bindings/header-gen.zig
index 3a8d11040..6155c5d1a 100644
--- a/src/javascript/jsc/bindings/header-gen.zig
+++ b/src/javascript/jsc/bindings/header-gen.zig
@@ -375,33 +375,38 @@ pub fn HeaderGen(comptime import: type, comptime fname: []const u8) type {
validateGenerator(Generator);
file.writeAll("#pragma once\n#include <stddef.h>\n#include <stdint.h>\n#include <stdbool.h>\n#define ZIG_DECL extern\n#define CPP_DECL extern \n\n") catch {};
-
+ var bufset = std.BufSet.init(std.heap.c_allocator);
inline for (all_decls) |_decls| {
if (comptime _decls.is_pub) {
switch (_decls.data) {
.Type => |Type| {
@setEvalBranchQuota(99999);
if (@hasDecl(Type, "Extern")) {
- self.startFile(Type, Type.shim.name, file);
- var gen = C_Generator.init(Type.name, file);
- defer gen.deinit();
- inline for (Type.Extern) |extern_decl| {
- if (@hasDecl(Type, extern_decl)) {
- const normalized_name = comptime brk: {
- var _normalized_name: [Type.name.len]u8 = undefined;
- _ = std.mem.replace(u8, Type.name, ":", "_", std.mem.span(&_normalized_name));
- break :brk _normalized_name;
- };
-
- processDecl(
- self,
- file,
- &gen,
- Type,
- comptime std.meta.declarationInfo(Type, extern_decl),
- comptime extern_decl,
- comptime std.mem.span(&normalized_name),
- );
+ const identifier = comptime std.fmt.comptimePrint("{s}_{s}", .{ Type.shim.name, Type.shim.namespace });
+ if (!bufset.contains(identifier)) {
+ self.startFile(Type, Type.shim.name, file);
+ bufset.insert(identifier) catch unreachable;
+
+ var gen = C_Generator.init(Type.name, file);
+ defer gen.deinit();
+ inline for (Type.Extern) |extern_decl| {
+ if (@hasDecl(Type, extern_decl)) {
+ const normalized_name = comptime brk: {
+ var _normalized_name: [Type.name.len]u8 = undefined;
+ _ = std.mem.replace(u8, Type.name, ":", "_", std.mem.span(&_normalized_name));
+ break :brk _normalized_name;
+ };
+
+ processDecl(
+ self,
+ file,
+ &gen,
+ Type,
+ comptime std.meta.declarationInfo(Type, extern_decl),
+ comptime extern_decl,
+ comptime std.mem.span(&normalized_name),
+ );
+ }
}
}
}
diff --git a/src/javascript/jsc/bindings/headers.h b/src/javascript/jsc/bindings/headers.h
index 422c687a0..112b3a11f 100644
--- a/src/javascript/jsc/bindings/headers.h
+++ b/src/javascript/jsc/bindings/headers.h
@@ -252,6 +252,11 @@ namespace JSC {
}
#endif
+CPP_DECL "C" uint64_t JSC__JSValue__encode(JSC::JSValue arg0);
+CPP_DECL "C" JSC::JSString* JSC__JSValue__asString(JSC::JSValue arg0);
+CPP_DECL "C" JSC::JSString* JSC__JSValue__asObject(JSC::JSValue arg0);
+CPP_DECL "C" JSC::JSString* JSC__JSValue__asNumber(JSC::JSValue arg0);
+CPP_DECL "C" bool JSC__JSValue__isError(JSC::JSValue arg0);
CPP_DECL "C" JSC::JSValue JSC__JSValue__jsNull();
CPP_DECL "C" JSC::JSValue JSC__JSValue__jsUndefined();
CPP_DECL "C" JSC::JSValue JSC__JSValue__jsTDZValue();
@@ -293,18 +298,20 @@ CPP_DECL "C" JSC::JSValue JSC__JSValue__getPropertyByPropertyName(JSC::JSValue a
CPP_DECL "C" bool JSC__JSValue__eqlValue(JSC::JSValue arg0, JSC::JSValue arg1);
CPP_DECL "C" bool JSC__JSValue__eqlCell(JSC::JSValue arg0, JSC::JSCell* arg1);
-#pragma mark - JSC::JSGlobalObject
+#pragma mark - JSC::PropertyName
-#ifndef BINDINGS__decls__JavaScriptCore_Error_h
-#define BINDINGS__decls__JavaScriptCore_Error_h
-#include <JavaScriptCore/Error.h>
+#ifndef BINDINGS__decls__JavaScriptCore_PropertyName_h
+#define BINDINGS__decls__JavaScriptCore_PropertyName_h
+#include <JavaScriptCore/PropertyName.h>
namespace JSC {
- class JSGlobalObject;
+ class PropertyName;
}
#endif
-CPP_DECL "C" JSC::JSObject* JSC__JSGlobalObject__throwError(JSC::JSGlobalObject* arg0, JSC::JSObject* arg1);
-CPP_DECL "C" JSC::JSObject* JSC__JSGlobalObject__createError(JSC::JSGlobalObject* arg0, char ErrorType1, WTF::WTFString* arg2);
+CPP_DECL "C" bool JSC__PropertyName__eqlToPropertyName(JSC::PropertyName* arg0, const JSC::PropertyName* arg1);
+CPP_DECL "C" bool JSC__PropertyName__eqlToIdentifier(JSC::PropertyName* arg0, const JSC::Identifier* arg1);
+CPP_DECL "C" WTF::StringImpl* JSC__PropertyName__publicName(JSC::PropertyName* arg0);
+CPP_DECL "C" WTF::StringImpl* JSC__PropertyName__uid(JSC::PropertyName* arg0);
#pragma mark - JSC::Exception
@@ -318,6 +325,40 @@ namespace JSC {
CPP_DECL "C" JSC::Exception* JSC__Exception__create(JSC::JSGlobalObject* arg0, JSC::JSObject* arg1, char StackCaptureAction2);
+#pragma mark - JSC::VM
+
+#ifndef BINDINGS__decls__JavaScriptCore_VM_h
+#define BINDINGS__decls__JavaScriptCore_VM_h
+#include <JavaScriptCore/VM.h>
+namespace JSC {
+ class VM;
+}
+#endif
+
+CPP_DECL "C" JSC::VM* JSC__VM__create(char HeapType0);
+CPP_DECL "C" void JSC__VM__deinit(JSC::VM* arg0);
+CPP_DECL "C" void JSC__VM__setExecutionForbidden(JSC::VM* arg0, bool arg1);
+CPP_DECL "C" bool JSC__VM__executionForbidden(JSC::VM* arg0);
+CPP_DECL "C" bool JSC__VM__isEntered(JSC::VM* arg0);
+CPP_DECL "C" bool JSC__VM__throwError(JSC::VM* arg0, JSC::ExceptionScope* arg1, const char* arg2, size_t arg3);
+
+#pragma mark - JSC::ExceptionScope
+
+#ifndef BINDINGS__decls__JavaScriptCore_ExceptionScope_h
+#define BINDINGS__decls__JavaScriptCore_ExceptionScope_h
+#include <JavaScriptCore/ExceptionScope.h>
+namespace JSC {
+ class ExceptionScope;
+}
+#endif
+
+CPP_DECL "C" void JSC__ExceptionScope__release(JSC::ExceptionScope* arg0);
+CPP_DECL "C" JSC::ExceptionScope* JSC__ExceptionScope__declareThrowScope(JSC::VM* arg0, char* arg1, char* arg2, size_t arg3);
+CPP_DECL "C" JSC::ExceptionScope* JSC__ExceptionScope__declareCatchScope(JSC::VM* arg0, char* arg1, char* arg2, size_t arg3);
+CPP_DECL "C" void JSC__ExceptionScope__release(JSC::ExceptionScope* arg0);
+CPP_DECL "C" JSC::Exception* JSC__ExceptionScope__exception(JSC::ExceptionScope* arg0);
+CPP_DECL "C" void JSC__ExceptionScope__clearException(JSC::ExceptionScope* arg0);
+
#pragma mark - JSC::CallFrame
#ifndef BINDINGS__decls__JavaScriptCore_CallFrame_h