UDP support (#7271)

Co-authored-by: Georgijs Vilums <georgijs@bun.sh>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: gvilums <gvilums@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred-Sumner <Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Georgijs <48869301+gvilums@users.noreply.github.com>
Co-authored-by: Georgijs Vilums <=>
This commit is contained in:
Ashcon Partovi
2024-04-26 15:25:24 -07:00
committed by GitHub
parent a6d39e14fc
commit 589f941aea
31 changed files with 3066 additions and 309 deletions

View File

@@ -995,6 +995,13 @@ pub fn toUTF8Alloc(allocator: std.mem.Allocator, js: []const u16) ![]u8 {
return try toUTF8AllocWithType(allocator, []const u16, js);
}
pub fn toUTF8AllocZ(allocator: std.mem.Allocator, js: []const u16) ![:0]u8 {
var list = std.ArrayList(u8).init(allocator);
try toUTF8AppendToList(&list, js);
try list.append(0);
return list.items[0 .. list.items.len - 1 :0];
}
pub inline fn appendUTF8MachineWordToUTF16MachineWord(output: *[@sizeOf(usize) / 2]u16, input: *const [@sizeOf(usize) / 2]u8) void {
output[0 .. @sizeOf(usize) / 2].* = @as(
[4]u16,
@@ -1859,6 +1866,19 @@ pub fn toUTF8FromLatin1(allocator: std.mem.Allocator, latin1: []const u8) !?std.
return try allocateLatin1IntoUTF8WithList(list, 0, []const u8, latin1);
}
pub fn toUTF8FromLatin1Z(allocator: std.mem.Allocator, latin1: []const u8) !?std.ArrayList(u8) {
if (bun.JSC.is_bindgen)
unreachable;
if (isAllASCII(latin1))
return null;
const list = try std.ArrayList(u8).initCapacity(allocator, latin1.len + 1);
var list1 = try allocateLatin1IntoUTF8WithList(list, 0, []const u8, latin1);
try list1.append(0);
return list1;
}
pub fn toUTF8ListWithTypeBun(list: *std.ArrayList(u8), comptime Type: type, utf16: Type) !std.ArrayList(u8) {
var utf16_remaining = utf16;