Ruby embedded
This commit is contained in:
parent
760765d350
commit
2e7da5c4e6
15
Makefile
15
Makefile
|
@ -12,7 +12,8 @@ UNAME_P != uname -m
|
|||
CCACHE = #ccache
|
||||
|
||||
#CC specifies which compiler we're using
|
||||
CC = $(CCACHE) tcc -DSDL_DISABLE_IMMINTRIN_H
|
||||
CC = $(CCACHE) clang -DSDL_DISABLE_IMMINTRIN_H
|
||||
CLINK = clang
|
||||
|
||||
MUSL = /usr/local/musl/include
|
||||
|
||||
|
@ -96,8 +97,8 @@ ifeq ($(UNAME), Windows_NT)
|
|||
CLIBS = glew32
|
||||
EXT = .exe
|
||||
else
|
||||
LINKER_FLAGS = -g /usr/lib64/pipewire-0.3/jack/libjack.so.0 #/usr/local/lib/tcc/bcheck.o /usr/local/lib/tcc/bt-exe.o /usr/local/lib/tcc/bt-log.o
|
||||
ELIBS = m c engine editor glfw3 portaudio rt asound pthread SDL2 yughc
|
||||
LINKER_FLAGS = -g /usr/lib64/pipewire-0.3/jack/libjack.so.0
|
||||
ELIBS = m c engine editor glfw3 portaudio rt asound pthread SDL2 yughc mruby
|
||||
CLIBS =
|
||||
EXT =
|
||||
endif
|
||||
|
@ -122,12 +123,12 @@ LINK = $(LIBPATH) $(LINKER_FLAGS) $(LELIBS) -o $@
|
|||
|
||||
engine: tags $(yuginec:.%.c=$(objprefix)%.o) $(ENGINE)
|
||||
@echo Linking engine
|
||||
@$(CC) $@ $(LINK)
|
||||
@$(CLINK) $@ $(LINK)
|
||||
@echo Finished build
|
||||
|
||||
editor: tags $(yuginec:.%.c=$(objprefix)%.o) $(EDITOR) $(ENGINE)
|
||||
@echo Linking editor
|
||||
@$(CC) $^ $(LINK)
|
||||
@$(CLINK) $^ $(LINK)
|
||||
@echo Finished build
|
||||
|
||||
$(ENGINE): $(eobjects) bin/libglfw3.a
|
||||
|
@ -142,12 +143,12 @@ $(EDITOR): $(edobjects)
|
|||
|
||||
xbrainstorm: $(bsobjects) $(ENGINE) $(EDITOR)
|
||||
@echo Making brainstorm
|
||||
$(CC) $^ $(LINK)
|
||||
$(CLINK) $^ $(LINK)
|
||||
@mv xbrainstorm brainstorm/brainstorm$(EXT)
|
||||
|
||||
pinball: tags $(ENGINE) $(pinobjects)
|
||||
@echo Making pinball
|
||||
@$(CC) $(pinobjects) $(LINK) -o $@
|
||||
@$(CLINK) $(pinobjects) $(LINK) -o $@
|
||||
@mv pinball paladin/pinball
|
||||
|
||||
bin/libglfw3.a:
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
#include "circbuf.h"
|
||||
|
||||
struct dsp_iir;
|
||||
|
||||
|
||||
void dsp_rectify(short *in, short *out, int n);
|
||||
|
||||
|
|
|
@ -1,59 +1,34 @@
|
|||
#include "script.h"
|
||||
|
||||
#include "gameobject.h"
|
||||
#include "stdio.h"
|
||||
|
||||
#include "mruby.h"
|
||||
#include "mruby/compile.h"
|
||||
|
||||
/*#include <s7.h>
|
||||
static mrb_state *mrb;
|
||||
|
||||
s7_scheme *s7 = NULL;
|
||||
|
||||
s7_pointer s7square(s7_scheme * sc, s7_pointer args)
|
||||
{
|
||||
if (s7_is_integer(s7_car(args)))
|
||||
return (s7_make_integer
|
||||
(sc, s7_integer(s7_car(args)) * s7_integer(s7_car(args))));
|
||||
|
||||
return (s7_wrong_type_arg_error
|
||||
(sc, "square", 1, s7_car(args), "an integer"));
|
||||
int fib(int n) {
|
||||
if (n < 2) return n;
|
||||
return fib(n-1) + fib(n-2);
|
||||
}
|
||||
|
||||
s7_pointer s7move(s7_scheme * sc, s7_pointer args)
|
||||
{
|
||||
if (s7_is_number(s7_car(args)) && s7_is_number(s7_cadr(args))) {
|
||||
gameobject_move(updateGO, s7_real(s7_car(args)),
|
||||
s7_real(s7_cadr(args)));
|
||||
return args;
|
||||
mrb_value mrb_fib(mrb_state *mrb, mrb_value self) {
|
||||
int n;
|
||||
mrb_get_args(mrb, "i", &n);
|
||||
return mrb_fixnum_value(fib(n));
|
||||
}
|
||||
|
||||
return args;
|
||||
void script_init() {
|
||||
mrb = mrb_open();
|
||||
mrb_define_method(mrb, mrb->object_class, "fib", mrb_fib, MRB_ARGS_REQ(1));
|
||||
}
|
||||
|
||||
s7_pointer s7rotate(s7_scheme * sc, s7_pointer args)
|
||||
{
|
||||
if (s7_is_number(s7_car(args))) {
|
||||
gameobject_rotate(updateGO, s7_real(s7_car(args)));
|
||||
return (s7_make_real(sc, cpBodyGetAngle(updateGO->body)));
|
||||
void script_run(const char *script) {
|
||||
mrb_load_string(mrb, script);
|
||||
}
|
||||
|
||||
return (s7_wrong_type_arg_error
|
||||
(sc, "rotate", 1, s7_car(args), "a number"));
|
||||
}
|
||||
*/
|
||||
|
||||
void script_init()
|
||||
{
|
||||
/*
|
||||
s7 = s7_init();
|
||||
s7_define_function(s7, "square", s7square, 1, 0, 0,
|
||||
"(square int) squares int");
|
||||
s7_define_function(s7, "move", s7move, 1, 0, 0,
|
||||
"(move (xs ys)) moves at xs and ys pixels per second");
|
||||
s7_define_function(s7, "rotate", s7rotate, 1, 0, 0,
|
||||
"(rotate ms) rotates at ms meters per second");
|
||||
*/
|
||||
}
|
||||
|
||||
void script_run(const char *script)
|
||||
{
|
||||
//s7_eval_c_string(s7, script);
|
||||
void script_dofile(const char *file) {
|
||||
FILE *mrbf = fopen(file, "r");
|
||||
mrb_load_file(mrb, mrbf);
|
||||
fclose(mrbf);
|
||||
}
|
|
@ -1,10 +1,8 @@
|
|||
#ifndef SCRIPT_H
|
||||
#define SCRIPT_H
|
||||
|
||||
struct s7_scheme;
|
||||
extern struct s7_scheme *s7;
|
||||
|
||||
void script_init();
|
||||
void script_run(const char *script);
|
||||
void script_dofile(const char *file);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue