[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/beardbolt d257e51fce 244/323: starters/zig: Automatical
From: |
ELPA Syncer |
Subject: |
[elpa] externals/beardbolt d257e51fce 244/323: starters/zig: Automatically export functions |
Date: |
Thu, 9 Mar 2023 10:58:35 -0500 (EST) |
branch: externals/beardbolt
commit d257e51fce1bc6796be93854048bdcab65106ecc
Author: Erik Arvstedt <erik.arvstedt@gmail.com>
Commit: Erik Arvstedt <erik.arvstedt@gmail.com>
starters/zig: Automatically export functions
This is makes experimenting in the starter file much more convenient.
Previously, each Zig fn had to be manually exported by referencing it in
the separate `export` fn.
---
starters/rmsbolt.zig | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/starters/rmsbolt.zig b/starters/rmsbolt.zig
index ace2786ec6..4f4ad1c52e 100644
--- a/starters/rmsbolt.zig
+++ b/starters/rmsbolt.zig
@@ -16,20 +16,33 @@ export fn isRMS(a: u8) u8 {
};
}
-// Functions marked with `export` use the C calling convention, so its
parameters and
-// return value can only have C types.
-// To export a native Zig fn, use the following pattern:
-fn zigFn(xs: []u8) []u8 {
+// Exported by `exportFns` below
+pub fn zigFn(xs: []u8) []u8 {
for (xs) |*x| {
x.* *= 2;
}
return xs;
}
-export fn exportZigFn() usize {
- return @ptrToInt(zigFn);
+// Export all public, non-generic functions in this file.
+// This is needed because functions that accept or return Zig-specific types
can't be marked
+// with `export`.
+// `export` is limited to functions that only accept or return C types, which
makes them
+// compatible with the C calling convention.
+export fn exportPubFns() usize {
+ var fns: usize = 0;
+ inline for (@typeInfo((@This())).Struct.decls) |decl| {
+ if (!decl.is_pub) continue;
+ const field = @field(@This(), decl.name);
+ const info = @typeInfo(@TypeOf(field));
+ if (info == .Fn and !info.Fn.is_generic) {
+ fns += @ptrToInt(field);
+ }
+ }
+ return fns;
}
+
// In some cases, Zig embeds a panic handler that prints stack traces, causing
a
// disassembly much larger than normal.
// You can optionally place this function in files you disassemble to make
them easier to digest.
- [elpa] externals/beardbolt 0d61c2edac 311/323: Add support for rustc, (continued)
- [elpa] externals/beardbolt 0d61c2edac 311/323: Add support for rustc, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt be3cf0a712 318/323: Fix problems with beardbolt-compile when file is saved, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 349ace7310 164/323: Merge branch 'master' of gitlab.com:jgkamat/rmsbolt, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 5aeda6f846 155/323: Add basic documentation for compile_commands.json, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 246377bbff 173/323: Add dummy panic handler to reduce size of zig diassembly, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 73dcaca98d 177/323: Remove unneeded variables, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 28ccabf318 190/323: Clean up overlays and simplify hook when asm buffer is closed, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 3a8964d537 204/323: Update Readme, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 7c81d55d3e 202/323: Format go block, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 9b1a5abbdf 208/323: Strip -flto flag from compile_commands.json by default, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt d257e51fce 244/323: starters/zig: Automatically export functions,
ELPA Syncer <=
- [elpa] externals/beardbolt ebbdebc66f 239/323: Improve compilation buffer display UX, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt f6b72fe0eb 248/323: First stab at rainbow overlays, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 3cace942b8 251/323: Fix buffer selection problems, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 041234b499 241/323: Improve auto-compilation, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 2421b29094 255/323: Remove .ert-runner, .gitlab-ci.yml and Cask, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 49e2500be1 259/323: Use shorthands so I can just type bb- instead of beardbolt-, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 58b07a215c 268/323: Simplify some code, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 9f6d1cf10c 269/323: Remove some rmsbolt remnants, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 5deed3972e 276/323: * beardbolt.el (bb--reachable-p, bb--process-asm): Use obarrays., ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 291f82a324 266/323: Continue rewriting, ELPA Syncer, 2023/03/09