const std = @import("std"); const StaticExport = @import("./static_export.zig"); const Sizes = @import("./sizes.zig"); pub const is_bindgen: bool = std.meta.globalOption("bindgen", bool) orelse false; const headers = @import("./headers.zig"); fn isNullableType(comptime Type: type) bool { return @typeInfo(Type) == .Optional or (@typeInfo(Type) == .Pointer and @typeInfo(Type).Pointer.is_allowzero); } const log = @import("../../output.zig").scoped(.CPP, true); pub fn Shimmer(comptime _namespace: []const u8, comptime _name: []const u8, comptime Parent: type) type { return struct { pub const namespace = _namespace; pub const name = _name; pub fn ref() void { if (comptime @hasDecl(Parent, "Export")) { inline for (Parent.Export) |exp| { _ = exp; } } if (comptime @hasDecl(Parent, "Extern")) { inline for (Parent.Extern) |exp| { _ = @field(Parent, exp); } } } // fn toCppType(comptime FromType: type) type { // var NewReturnType = FromType; // if (NewReturnType == anyopaque) { // return FromType; // } // var ReturnTypeInfo: std.builtin.Type = @typeInfo(FromType); // if (ReturnTypeInfo == .Pointer and NewReturnType != *anyopaque) { // NewReturnType = ReturnTypeInfo.Pointer.child; // ReturnTypeInfo = @typeInfo(NewReturnType); // } // switch (ReturnTypeInfo) { // .Union, // .Struct, // .Enum, // => { // if (@hasDecl(ReturnTypeInfo., "Type")) { // return NewReturnType; // } // }, // else => {}, // } // return FromType; // } pub const align_of_symbol = std.fmt.comptimePrint("{s}__{s}_object_align_", .{ namespace, name }); pub const size_of_symbol = std.fmt.comptimePrint("{s}__{s}_object_size_", .{ namespace, name }); const align_symbol = std.fmt.comptimePrint("{s}__{s}_align", .{ namespace, name }); pub const byte_size = brk: { const identifier = std.fmt.comptimePrint("{s}__{s}", .{ namespace, name }); if (@hasDecl(Sizes, identifier)) { break :brk @field(Sizes, identifier); } else { break :brk 0; } }; pub const align_size = brk: { const identifier = std.fmt.comptimePrint("{s}__{s}_align", .{ namespace, name }); if (@hasDecl(Sizes, identifier)) { break :brk @field(Sizes, identifier); } else { break :brk 0; } }; pub const Bytes = if (byte_size > 16) [byte_size]u8 else std.meta.Int(.unsigned, byte_size * 8); pub const Return = struct { pub const Type = Parent; pub const is_return = true; }; fn pointerChild(comptime Type: type) type { if (@typeInfo(Type) == .Pointer) { return @typeInfo(Type).Pointer.child_type; } return Type; } pub fn symbolName(comptime typeName: []const u8) []const u8 { if (comptime namespace.len > 0) { return comptime std.fmt.comptimePrint("{s}__{s}__{s}", .{ namespace, name, typeName }); } else { return comptime std.fmt.comptimePrint("{s}__{s}", .{ name, typeName }); } } pub fn exportFunctions(comptime Functions: anytype) [std.meta.fieldNames(@TypeOf(Functions)).len]StaticExport { const FunctionsType = @TypeOf(Functions); return comptime brk: { var functions: [std.meta.fieldNames(FunctionsType).len]StaticExport = undefined; for (std.meta.fieldNames(FunctionsType), 0..) |fn_name, i| { const Function = @TypeOf(@field(Functions, fn_name)); if (@typeInfo(Function) != .Fn) { @compileError("Expected " ++ @typeName(Parent) ++ "." ++ @typeName(Function) ++ " to be a function but received " ++ @tagName(@typeInfo(Function))); } var Fn: std.builtin.Type.Fn = @typeInfo(Function).Fn; if (Fn.calling_convention != .C) { @compileError("Expected " ++ @typeName(Parent) ++ "." ++ @typeName(Function) ++ " to have a C Calling Convention."); } const export_name = symbolName(fn_name); functions[i] = StaticExport{ .Type = Function, .symbol_name = export_name, .local_name = fn_name, .Parent = Parent, }; } break :brk functions; }; } pub fn thenables(comptime Functions: anytype) [std.meta.fieldNames(@TypeOf(Functions)).len * 2]StaticExport { const FunctionsType = @TypeOf(Functions); return comptime brk: { var functions: [std.meta.fieldNames(FunctionsType).len * 2]StaticExport = undefined; var j: usize = 0; inline for (Functions) |thenable| { inline for ([_][]const u8{ "resolve", "reject" }) |fn_name| { const Function = @TypeOf(@field(thenable, fn_name)); if (@typeInfo(Function) != .Fn) { @compileError("Expected " ++ @typeName(Parent) ++ "." ++ @typeName(Function) ++ " to be a function but received " ++ @tagName(@typeInfo(Function))); } var Fn: std.builtin.Type.Fn = @typeInfo(Function).Fn; if (Fn.calling_convention != .C) { @compileError("Expected " ++ @typeName(Parent) ++ "." ++ @typeName(Function) ++ " to have a C Calling Convention."); } const export_name = symbolName(fn_name); functions[j] = StaticExport{ .Type = Function, .symbol_name = export_name, .local_name = fn_name, .Parent = thenable, }; j += 1; } } break :brk functions; }; } pub inline fn matchNullable(comptime ExpectedReturnType: type, comptime ExternReturnType: type, value: ExternReturnType) ExpectedReturnType { if (comptime isNullableType(ExpectedReturnType) != isNullableType(ExternReturnType)) { return value.?; } else if (comptime (@typeInfo(ExpectedReturnType) == .Enum) and (@typeInfo(ExternReturnType) != .Enum)) { return @as(ExpectedReturnType, @enumFromInt(value)); } else { return value; } } pub inline fn cppFn(comptime typeName: []const u8, args: anytype) (ret: { @setEvalBranchQuota(99999); if (!@hasDecl(Parent, typeName)) { @compileError(@typeName(Parent) ++ " is missing cppFn: " ++ typeName); } break :ret @typeInfo(@TypeOf(@field(Parent, typeName))).Fn.return_type.?; }) { log(comptime name ++ "__" ++ typeName, .{}); @setEvalBranchQuota(99999); if (comptime is_bindgen) { unreachable; } else { const Fn = comptime @field(headers, symbolName(typeName)); if (@typeInfo(@TypeOf(Fn)).Fn.params.len > 0) return matchNullable( comptime @typeInfo(@TypeOf(@field(Parent, typeName))).Fn.return_type.?, comptime @typeInfo(@TypeOf(Fn)).Fn.return_type.?, @call(.auto, Fn, args), ); return matchNullable( comptime @typeInfo(@TypeOf(@field(Parent, typeName))).Fn.return_type.?, comptime @typeInfo(@TypeOf(Fn)).Fn.return_type.?, @call(.auto, Fn, .{}), ); } } }; } legacy-markdown-flag'>feat/legacy-markdown-flag Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/packages/astro/test/fixtures/astro-markdown-shiki (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2022-02-07feat: Added the ability to add custom themes/languages to Shiki (#2518)Gravatar Juan Martín Seery 42-56/+1429
2022-02-07Delete robots.txt (#2540)Gravatar Marcus Otterström 2-3/+0
2022-02-07[ci] yarn formatGravatar matthewp 1-1/+1
2022-02-07[ci] update lockfile (#2543)Gravatar Fred K. Schott 1-171/+178
2022-02-07improve debug logs (#2537)Gravatar Fred K. Schott 3-4/+19
2022-02-07[ci] collect statsGravatar FredKSchott 1-0/+1
2022-02-06[ci] update lockfile (#2527)Gravatar Fred K. Schott 1-208/+238
2022-02-06[ci] collect statsGravatar FredKSchott 1-0/+1
2022-02-05[ci] collect statsGravatar FredKSchott 1-0/+1
2022-02-04[ci] yarn formatGravatar natemoo-re 1-2/+3
2022-02-04fix: HTML/SVG boolean attributes (#2538)Gravatar Nate Moore 2-3/+21
2022-02-04[ci] yarn formatGravatar matthewp 1-4/+2
2022-02-04fix: import local plugins into markdown (#2534)Gravatar Juan Martín Seery 9-22/+41
2022-02-04[ci] collect statsGravatar FredKSchott 1-0/+1
2022-02-03Append to list of HMR modules, don't override (#2532)Gravatar Matthew Phillips 2-1/+6
2022-02-03add back dev server host support (#2531)Gravatar Fred K. Schott 2-1/+14
2022-02-03simplify status code regexGravatar Fred K. Schott 2-87/+4
2022-02-03Adding StackUp Digital to the list of sponsors (#2521)Gravatar Astroalex 3-0/+10
2022-02-03[ci] collect statsGravatar FredKSchott 1-0/+1
2022-02-03[ci] yarn formatGravatar FredKSchott 2-3/+85
2022-02-02Handles all http error code file names the same as 404 files. (#2525)Gravatar Zade Viggers 2-4/+7
2022-02-02fix(sitemap): remove debug if sitemap disabled (#2514)Gravatar Mark Pinero 1-2/+2
2022-02-02[ci] update lockfile (#2515)Gravatar Fred K. Schott 1-276/+279
2022-02-02[ci] yarn formatGravatar matthewp 1-8/+8
2022-02-02[ci] release (next) (#2523)astro@0.23.0-next.1Gravatar github-actions[bot] 28-34/+41
2022-02-02[ci] yarn formatGravatar matthewp 2-17/+29
2022-02-02Fix support for scss in static build (#2522)Gravatar Matthew Phillips 6-20/+114
2022-02-02[ci] collect statsGravatar FredKSchott 1-0/+1
2022-02-01[ci] yarn formatGravatar matthewp 2-12/+12
2022-02-01[ci] release (next) (#2492)astro@0.23.0-next.0@astrojs/test-static-build-pkg@0.0.2@astrojs/markdown-remark@0.6.1-next.0Gravatar github-actions[bot] 31-43/+93
2022-02-01[ci] collect statsGravatar FredKSchott 1-0/+1
2022-01-31update congratsbot format againGravatar Fred K. Schott 1-1/+1
2022-01-31update congratsbot againGravatar Fred K. Schott 1-1/+1
2022-01-31Remove SVG animation on GitHub/NPM (#2512)Gravatar Nate Moore 1-21/+0
2022-01-31[ci] yarn formatGravatar natemoo-re 2-4/+6
2022-01-31Add Shiki as an alternative to Prism (#2497)Gravatar Juan Martín Seery 26-9/+356
2022-01-31Deprecate unescaped HTML inside of expressions (#2489)Gravatar Nate Moore 9-31/+74