aboutsummaryrefslogtreecommitdiff
path: root/src/methods/execute_squirrel.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/methods/execute_squirrel.zig')
-rw-r--r--src/methods/execute_squirrel.zig42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/methods/execute_squirrel.zig b/src/methods/execute_squirrel.zig
new file mode 100644
index 0000000..91a975f
--- /dev/null
+++ b/src/methods/execute_squirrel.zig
@@ -0,0 +1,42 @@
+const std = @import("std");
+
+const squirrel = @import("../squirrel.zig");
+
+const Allocator = std.mem.Allocator;
+
+pub const method = .{
+ .name = "execute_squirrel",
+ .func = execute_squirrel,
+};
+
+fn execute_squirrel(allocator: Allocator, params: ?std.json.Value) !?std.json.Value {
+ if (params == null or params.? != .object) {
+ return error.InvalidParameters;
+ }
+
+ const object = params.?.object;
+
+ const context = blk: {
+ const context_object = object.get("context");
+ if (context_object != null and context_object.? == .string) {
+ const context_string = context_object.?.string;
+
+ if (std.mem.eql(u8, context_string, "server")) {
+ break :blk squirrel.ScriptContext.SC_SERVER;
+ } else if (std.mem.eql(u8, context_string, "client")) {
+ break :blk squirrel.ScriptContext.SC_CLIENT;
+ } else if (std.mem.eql(u8, context_string, "ui")) {
+ break :blk squirrel.ScriptContext.SC_UI;
+ }
+
+ return error.InvalidContext;
+ }
+
+ break :blk squirrel.ScriptContext.SC_UI;
+ };
+ _ = context;
+
+ return .{
+ .string = "test",
+ };
+}