diff options
author | P. J. McDermott <pj@pehjota.net> | 2015-08-25 05:22:44 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2015-08-25 05:22:44 (EDT) |
commit | 970942b41aa603672e7589ecf3dbedf480b25a62 (patch) | |
tree | 659aed03ae4da15ab1f9336a3124ca12b6ec2cc2 | |
parent | 0fb9afa52e05a1b474fab2bfb267a9a6f7268cce (diff) | |
download | overworld-rpg-970942b41aa603672e7589ecf3dbedf480b25a62.zip overworld-rpg-970942b41aa603672e7589ecf3dbedf480b25a62.tar.gz overworld-rpg-970942b41aa603672e7589ecf3dbedf480b25a62.tar.bz2 |
Save pointer to namespace struct in bindings TU
-rw-r--r-- | src/scripting/bindings.c | 4 | ||||
-rw-r--r-- | src/scripting/ffi.c | 6 | ||||
-rw-r--r-- | src/scripting/ffi.h | 3 |
3 files changed, 9 insertions, 4 deletions
diff --git a/src/scripting/bindings.c b/src/scripting/bindings.c index 757a0c0..1edc1e3 100644 --- a/src/scripting/bindings.c +++ b/src/scripting/bindings.c @@ -20,8 +20,10 @@ #include "ffi.h" #include "bindings.h" +static struct ffi_namespace *ns; + void bindings_init(void) { - ffi_add_namespace(NULL, "bouken"); + ns = ffi_add_namespace(NULL, "bouken"); } diff --git a/src/scripting/ffi.c b/src/scripting/ffi.c index 9632893..6457f73 100644 --- a/src/scripting/ffi.c +++ b/src/scripting/ffi.c @@ -42,7 +42,7 @@ static int call_arg_index; static void ffi_register_functions_in_namespace(lua_State *l, struct ffi_namespace *parent); -void +struct ffi_namespace * ffi_add_namespace(struct ffi_namespace *parent, const char *name) { struct ffi_namespace *new_ns; @@ -54,7 +54,7 @@ ffi_add_namespace(struct ffi_namespace *parent, const char *name) new_ns = malloc(sizeof(*new_ns)); if (new_ns == NULL) { err(1, "Failed to allocate FFI namespace \"%s\"", name); - return; + return NULL; } new_ns->name = strdup(name); new_ns->ns_head = NULL; @@ -69,6 +69,8 @@ ffi_add_namespace(struct ffi_namespace *parent, const char *name) parent->ns_tail->next = new_ns; } parent->ns_tail = new_ns; + + return new_ns; } void diff --git a/src/scripting/ffi.h b/src/scripting/ffi.h index b635d6f..471cd16 100644 --- a/src/scripting/ffi.h +++ b/src/scripting/ffi.h @@ -35,7 +35,8 @@ struct ffi_namespace { struct ffi_namespace *next; }; -void ffi_add_namespace(struct ffi_namespace *parent, const char *name); +struct ffi_namespace *ffi_add_namespace(struct ffi_namespace *parent, + const char *name); void ffi_add_function(struct ffi_namespace *parent, const char *name, void (*func)(void)); void ffi_register_functions(struct script *script); |