summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2023-02-24 19:25:04 (EST)
committer P. J. McDermott <pj@pehjota.net>2023-02-24 19:25:04 (EST)
commit6333a37011368ce65b5804b0c698257559a6e41a (patch)
tree1be1484a3a9448b9a2c74008b071a994e17d293a
parent1362c0c581980b0cd5d9540e91ba5458910653f7 (diff)
downloadoverworld-rpg-6333a37011368ce65b5804b0c698257559a6e41a.zip
overworld-rpg-6333a37011368ce65b5804b0c698257559a6e41a.tar.gz
overworld-rpg-6333a37011368ce65b5804b0c698257559a6e41a.tar.bz2
bindings: Make variables not static global
-rw-r--r--src/scripting/bindings.c8
-rw-r--r--src/scripting/bindings.h6
-rw-r--r--src/scripting/bindings/viewport.c6
3 files changed, 8 insertions, 12 deletions
diff --git a/src/scripting/bindings.c b/src/scripting/bindings.c
index 7e45146..4efe584 100644
--- a/src/scripting/bindings.c
+++ b/src/scripting/bindings.c
@@ -16,17 +16,15 @@
* <http://www.gnu.org/licenses/>.
*/
-#define _SCRIPTING_BINDINGS_C_
-
#include <stdlib.h>
#include "ffi.h"
#include "bindings.h"
-struct ffi_namespace *top_ns;
-
void
bindings_init(void)
{
+ struct ffi_namespace *top_ns;
+
top_ns = ffi_add_namespace(NULL, "bouken");
- bindings_viewport_init();
+ bindings_viewport_init(top_ns);
}
diff --git a/src/scripting/bindings.h b/src/scripting/bindings.h
index 4ad7386..725580b 100644
--- a/src/scripting/bindings.h
+++ b/src/scripting/bindings.h
@@ -19,11 +19,9 @@
#ifndef _SCRIPTING_BINDINGS_H_
#define _SCRIPTING_BINDINGS_H_
-#ifndef _SCRIPTING_BINDINGS_C_
-extern struct ffi_namespace *top_ns;
-#endif
+#include "ffi.h"
void bindings_init(void);
-void bindings_viewport_init(void);
+void bindings_viewport_init(struct ffi_namespace *top_ns);
#endif
diff --git a/src/scripting/bindings/viewport.c b/src/scripting/bindings/viewport.c
index 8fcc041..7e23d7d 100644
--- a/src/scripting/bindings/viewport.c
+++ b/src/scripting/bindings/viewport.c
@@ -21,8 +21,6 @@
#include "../ffi.h"
#include "../bindings.h"
-static struct ffi_namespace *ns;
-
static void
binding_set_size(struct ffi_function *fn)
{
@@ -36,8 +34,10 @@ binding_set_size(struct ffi_function *fn)
}
void
-bindings_viewport_init(void)
+bindings_viewport_init(struct ffi_namespace *top_ns)
{
+ struct ffi_namespace *ns;
+
ns = ffi_add_namespace(top_ns, "viewport");
ffi_add_function(ns, "set_size", binding_set_size);
}