-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
more random bindgen features #15832
base: main
Are you sure you want to change the base?
more random bindgen features #15832
Conversation
Updated 6:32 PM PT - Dec 19th, 2024
❌ @paperdave, your commit b8f9a8a has some failures in 🧪 try this PR locally: bunx bun-pr 15832 |
|
||
JSC::EncodedJSValue throwNodeInvalidArgTypeErrorForBindgen(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, const WTF::ASCIILiteral& arg_name, const WTF::ASCIILiteral& expected_type, JSC::JSValue val_actual_value) | ||
{ | ||
auto actual_value = Bun::JSValueToStringSafe(globalObject, val_actual_value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haven't seen this function, is handling Symbol what makes it safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good, but seems there's a build issue with bindgen_test.zig
writer.print("{}", .{value.toFmt(&formatter)}) catch return ZigString.Empty; | ||
buffered_writer.flush() catch return ZigString.Empty; | ||
|
||
return ZigString.init(array.slice()).withEncoding(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what frees this memory?
@@ -624,6 +623,30 @@ pub const StringOrBuffer = union(enum) { | |||
}; | |||
return fromJSWithEncodingMaybeAsync(global, allocator, value, encoding, maybe_async); | |||
} | |||
|
|||
pub fn validateForBindgen(value: JSC.JSValue) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a bit confusing
@@ -217,34 +216,132 @@ WTF::String JSValueToStringSafe(JSC::JSGlobalObject* globalObject, JSValue arg) | |||
} | |||
} | |||
|
|||
return arg.toWTFStringForConsole(globalObject); | |||
ZigString zstring = Bun__inspect(globalObject, arg); | |||
BunString bstring(BunStringTag::ZigString, BunStringImpl(zstring)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, it leaks
i had these on stash earlier, this adds new types:
other changes