Skip to content
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

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open

more random bindgen features #15832

wants to merge 21 commits into from

Conversation

paperdave
Copy link
Member

i had these on stash earlier, this adds new types:

  • zigEnum
  • zigCustom
  • cppCustom

other changes

  • remove is_bindgen
  • deprecate some JSValue.jsNumberFrom* functions. use JSValue.jsNumber(value)

@robobun
Copy link

robobun commented Dec 18, 2024

Updated 6:32 PM PT - Dec 19th, 2024

@paperdave, your commit b8f9a8a has some failures in #8271


🧪   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);
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is what ErrorCode.cpp has

image

Copy link
Member

@dylan-conway dylan-conway left a 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

@paperdave paperdave enabled auto-merge December 19, 2024 20:35
@paperdave paperdave added this pull request to the merge queue Dec 19, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Dec 19, 2024
@paperdave paperdave enabled auto-merge December 20, 2024 06:22
writer.print("{}", .{value.toFmt(&formatter)}) catch return ZigString.Empty;
buffered_writer.flush() catch return ZigString.Empty;

return ZigString.init(array.slice()).withEncoding();
Copy link
Collaborator

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 {
Copy link
Collaborator

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));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, it leaks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants