Native "Syscall" Interface for Kym #21
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "kym-native-function"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #20.
By default, the following syscalls are exposed:
log_infoWrites an entry to the info log.log_warnWrites an entry to the warning log.log_failWrites an entry to the failure log.WIP: Native Function Calling and Binding for Kymto Native Function Calling and Binding for KymNative Function Calling and Binding for Kymto Native "Syscall" Interface for Kym@ -16,6 +16,16 @@ pub fn Stack(comptime Value: type) type {self.values = self.values[0 .. 0];}pub fn drop(self: *Self, amount: usize) bool {Unused function.
@ -77,0 +128,4 @@}fn write_stack(stack: *ByteStack, bytes: []const io.Byte) ?usize {stack.push_all(bytes) catch return null;Can be simplified to single expression
@ -89,1 +110,4 @@});}pub fn Table(comptime Key: type, comptime Value: type, comptime traits: TableTraits(Key)) type {A lot of duplication with
@typeInfo(usize).Intand getting min / max limits of int types in general. These could be reduced into a constants declared in function body to reduce repetition.@ -13,41 +13,55 @@ pub const Manifest = struct {tick_rate: f32 = 60.0,pub fn load(self: *Manifest, env: *kym.RuntimeEnv, file_access: file.Access) kym.RuntimeError!void {Resolve TODOs in the function body.
@ -70,2 +77,2 @@severity: LogSeverity,write_buffer: coral.list.ByteStack,pub fn log_info(message: []const coral.io.Byte) void {ext.SDL_LogInfo(ext.SDL_LOG_CATEGORY_APPLICATION, "%.*s", @as(c_int, @intCast(message.len)), message.ptr);Potentially (but very unlikely to ever trigger) unsafe length cast.
Could do with clamping the length to the max buffer to be safe.
@ -75,2 +81,2 @@fn write(writable_log: *WritableLog, bytes: []const coral.io.Byte) ?usize {writable_log.write(bytes) catch return null;pub fn log_warn(message: []const coral.io.Byte) void {ext.SDL_LogWarn(ext.SDL_LOG_CATEGORY_APPLICATION, "%.*s", @as(c_int, @intCast(message.len)), message.ptr);Potentially (but very unlikely to ever trigger) unsafe length cast.
Could do with clamping the length to the max buffer to be safe.
@ -127,2 +85,2 @@}};pub fn log_fail(message: []const coral.io.Byte) void {ext.SDL_LogError(ext.SDL_LOG_CATEGORY_APPLICATION, "%.*s", @as(c_int, @intCast(message.len)), message.ptr);Potentially (but very unlikely to ever trigger) unsafe length cast.
Could do with clamping the length to the max buffer to be safe.
@ -419,3 +239,3 @@}const return_value = try self.state.pop_value();return self.local_refs.values[local];Does this operation "get" like the name suggests (acquiring a reference) or is it an immutable view like the current implementation suggests?
@ -209,6 +221,45 @@ pub fn parse(self: *Self, tokenizer: *tokens.Tokenizer) ParseError!void {}},.global => |identifier| {Inaccurate name for syscall.
@ -264,6 +333,48 @@ fn parse_factor(self: *Self, tokenizer: *tokens.Tokenizer) ParseError!Expressionreturn Expression{.string_literal = value};},.global => |identifier| {Inaccurate name for syscall.
@ -25,2 +24,3 @@}const Self = @This();pub const typeinfo = kym.Typeinfo{Does this need to be public?
@ -52,0 +67,4 @@.caller = kym.Caller.from(kym_log_fail),},}) catch {return app.log_fail("failed to initialize script runtime");Inaccurate log message.
@ -2,3 +2,2 @@pub fn main() ona.RuntimeError!void {try ona.run_app(.{.sandboxed_path = &ona.file.Path.cwd});pub fn main() anyerror!void {Error union is unused.