4 #include "system/stacktrace.h"
5 #include "system/nth_alloc.h"
7 #include "ebisp/interpreter.h"
8 #include "ebisp/expr.h"
9 #include "ebisp/scope.h"
13 unknown_target(Gc *gc, const char *source, const char *target)
16 list(gc, "qqq", "unknown-target", source, target));
19 static struct EvalResult
20 send(void *param, Gc *gc, struct Scope *scope, struct Expr args)
26 Broadcast *broadcast = (Broadcast*) param;
28 struct Expr path = void_expr();
29 struct EvalResult result = match_list(gc, "e", args, &path);
30 if (result.is_error) {
34 return broadcast_send(broadcast, gc, scope, path);
42 Broadcast *create_broadcast(Game *game)
46 Broadcast *broadcast = nth_calloc(1, sizeof(Broadcast));
47 if (broadcast == NULL) {
51 broadcast->game = game;
56 void destroy_broadcast(Broadcast *broadcast)
58 trace_assert(broadcast);
63 broadcast_send(Broadcast *broadcast,
68 trace_assert(broadcast);
72 const char *target = NULL;
73 struct Expr rest = void_expr();
74 struct EvalResult res = match_list(gc, "q*", path, &target, &rest);
79 if (strcmp(target, "game") == 0) {
80 return game_send(broadcast->game, gc, scope, rest);
83 return unknown_target(gc, "game", target);
86 void broadcast_load_library(Broadcast *broadcast,
92 trace_assert(broadcast);
94 set_scope_value(gc, scope, SYMBOL(gc, "send"), NATIVE(gc, send, broadcast));