Binding-MRuby: Make stuff work with latest mruby git
This commit is contained in:
parent
ccba946973
commit
48db6fbeda
|
@ -140,7 +140,7 @@ mkxpTimeOp(mrb_state *mrb, mrb_value)
|
||||||
printf("<%s> [%f ms]\n", opName, ms);
|
printf("<%s> [%f ms]\n", opName, ms);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
return mrb__float_value(ms);
|
return mrb_float_value(mrb, ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
|
|
|
@ -112,6 +112,12 @@ getMrbData(mrb_state *mrb)
|
||||||
return static_cast<MrbData*>(mrb->ud);
|
return static_cast<MrbData*>(mrb->ud);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline RClass*
|
||||||
|
defineClass(mrb_state *mrb, const char *name)
|
||||||
|
{
|
||||||
|
return mrb_define_class(mrb, name, mrb->object_class);
|
||||||
|
}
|
||||||
|
|
||||||
#define GUARD_EXC(exp) \
|
#define GUARD_EXC(exp) \
|
||||||
{ try { exp } catch (Exception &exc) { raiseMrbExc(mrb, exc); } }
|
{ try { exp } catch (Exception &exc) { raiseMrbExc(mrb, exc); } }
|
||||||
|
|
||||||
|
@ -237,7 +243,7 @@ mrb__float_value(mrb_float f)
|
||||||
{
|
{
|
||||||
mrb_value v;
|
mrb_value v;
|
||||||
|
|
||||||
MRB_SET_VALUE(v, MRB_TT_FLOAT, value.f, f);
|
SET_FLOAT_VALUE(0, v, f);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -306,7 +306,7 @@ CLONE_FUN(Bitmap)
|
||||||
void
|
void
|
||||||
bitmapBindingInit(mrb_state *mrb)
|
bitmapBindingInit(mrb_state *mrb)
|
||||||
{
|
{
|
||||||
RClass *klass = mrb_define_class(mrb, "Bitmap", 0);
|
RClass *klass = defineClass(mrb, "Bitmap");
|
||||||
|
|
||||||
disposableBindingInit<Bitmap>(mrb, klass);
|
disposableBindingInit<Bitmap>(mrb, klass);
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,7 @@ CLONE_FUN(Rect)
|
||||||
|
|
||||||
#define INIT_BIND(Klass) \
|
#define INIT_BIND(Klass) \
|
||||||
{ \
|
{ \
|
||||||
klass = mrb_define_class(mrb, #Klass, 0); \
|
klass = defineClass(mrb, #Klass); \
|
||||||
mrb_define_class_method(mrb, klass, "_load", Klass##Load, MRB_ARGS_REQ(1)); \
|
mrb_define_class_method(mrb, klass, "_load", Klass##Load, MRB_ARGS_REQ(1)); \
|
||||||
serializableBindingInit<Klass>(mrb, klass); \
|
serializableBindingInit<Klass>(mrb, klass); \
|
||||||
mrb_define_method(mrb, klass, "initialize", Klass##Initialize, MRB_ARGS_REQ(3) | MRB_ARGS_OPT(1)); \
|
mrb_define_method(mrb, klass, "initialize", Klass##Initialize, MRB_ARGS_REQ(3) | MRB_ARGS_OPT(1)); \
|
||||||
|
|
|
@ -142,7 +142,7 @@ MRB_METHOD(FontSetDefaultColor)
|
||||||
void
|
void
|
||||||
fontBindingInit(mrb_state *mrb)
|
fontBindingInit(mrb_state *mrb)
|
||||||
{
|
{
|
||||||
RClass *klass = mrb_define_class(mrb, "Font", 0);
|
RClass *klass = defineClass(mrb, "Font");
|
||||||
|
|
||||||
Font::setDefaultColor(new Color(*Font::getDefaultColor()));
|
Font::setDefaultColor(new Color(*Font::getDefaultColor()));
|
||||||
wrapProperty(mrb, mrb_obj_value(klass), Font::getDefaultColor(), CSdefault_color, ColorType);
|
wrapProperty(mrb, mrb_obj_value(klass), Font::getDefaultColor(), CSdefault_color, ColorType);
|
||||||
|
|
|
@ -227,7 +227,7 @@ MRB_FUNCTION(fileExpandPath)
|
||||||
if (defDir)
|
if (defDir)
|
||||||
Debug() << "FIXME: File.expand_path: default_dir not implemented";
|
Debug() << "FIXME: File.expand_path: default_dir not implemented";
|
||||||
|
|
||||||
char buffer[512];
|
char buffer[PATH_MAX];
|
||||||
char *unused = realpath(path, buffer);
|
char *unused = realpath(path, buffer);
|
||||||
(void) unused;
|
(void) unused;
|
||||||
|
|
||||||
|
@ -568,7 +568,7 @@ fileBindingInit(mrb_state *mrb)
|
||||||
{
|
{
|
||||||
mrb_define_method(mrb, mrb->kernel_module, "open", fileOpen, MRB_ARGS_REQ(1) | MRB_ARGS_OPT(1) | MRB_ARGS_BLOCK());
|
mrb_define_method(mrb, mrb->kernel_module, "open", fileOpen, MRB_ARGS_REQ(1) | MRB_ARGS_OPT(1) | MRB_ARGS_BLOCK());
|
||||||
|
|
||||||
RClass *klass = mrb_define_class(mrb, "IO", 0);
|
RClass *klass = defineClass(mrb, "IO");
|
||||||
klass = mrb_define_class(mrb, "File", klass);
|
klass = mrb_define_class(mrb, "File", klass);
|
||||||
|
|
||||||
mrb_define_class_method(mrb, klass, "basename", fileBasename, MRB_ARGS_REQ(1) | MRB_ARGS_OPT(1));
|
mrb_define_class_method(mrb, klass, "basename", fileBasename, MRB_ARGS_REQ(1) | MRB_ARGS_OPT(1));
|
||||||
|
|
|
@ -259,21 +259,13 @@ read_string_value(MarshalContext *ctx)
|
||||||
mrb_state *mrb = ctx->mrb;
|
mrb_state *mrb = ctx->mrb;
|
||||||
int len = read_fixnum(ctx);
|
int len = read_fixnum(ctx);
|
||||||
|
|
||||||
struct RString *str =
|
mrb_value str = mrb_str_new(mrb, 0, len);
|
||||||
(struct RString*) mrb_obj_alloc
|
char *ptr = RSTR_PTR(RSTRING(str));
|
||||||
(mrb, MRB_TT_STRING, mrb->string_class);
|
|
||||||
|
|
||||||
str->c = mrb->string_class;
|
ctx->readData(ptr, len);
|
||||||
str->len = len;
|
ptr[len] = '\0';
|
||||||
str->aux.capa = len;
|
|
||||||
str->ptr = (char*) mrb_malloc(mrb, len+1);
|
|
||||||
|
|
||||||
ctx->readData(str->ptr, len);
|
return str;
|
||||||
str->ptr[len] = '\0';
|
|
||||||
|
|
||||||
mrb_value str_obj = mrb_obj_value(str);
|
|
||||||
|
|
||||||
return str_obj;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static mrb_value read_value(MarshalContext *ctx);
|
static mrb_value read_value(MarshalContext *ctx);
|
||||||
|
@ -724,7 +716,7 @@ write_symbol(MarshalContext *ctx, mrb_value symbol)
|
||||||
{
|
{
|
||||||
mrb_state *mrb = ctx->mrb;
|
mrb_state *mrb = ctx->mrb;
|
||||||
mrb_sym sym = mrb_symbol(symbol);
|
mrb_sym sym = mrb_symbol(symbol);
|
||||||
size_t len;
|
mrb_int len;
|
||||||
const char *p = mrb_sym2name_len(mrb, sym, &len);
|
const char *p = mrb_sym2name_len(mrb, sym, &len);
|
||||||
|
|
||||||
write_string(ctx, p);
|
write_string(ctx, p);
|
||||||
|
|
|
@ -197,8 +197,8 @@ TIME_ATTR(wday)
|
||||||
void
|
void
|
||||||
timeBindingInit(mrb_state *mrb)
|
timeBindingInit(mrb_state *mrb)
|
||||||
{
|
{
|
||||||
RClass *klass = mrb_define_class(mrb, "Time", 0);
|
RClass *klass = defineClass(mrb, "Time");
|
||||||
mrb_include_module(mrb, klass, mrb_class_get(mrb, "Comparable"));
|
mrb_include_module(mrb, klass, mrb_module_get(mrb, "Comparable"));
|
||||||
|
|
||||||
mrb_define_class_method(mrb, klass, "now", timeNow, MRB_ARGS_NONE());
|
mrb_define_class_method(mrb, klass, "now", timeNow, MRB_ARGS_NONE());
|
||||||
mrb_define_class_method(mrb, klass, "at", timeAt, MRB_ARGS_REQ(1));
|
mrb_define_class_method(mrb, klass, "at", timeAt, MRB_ARGS_REQ(1));
|
||||||
|
|
|
@ -61,7 +61,7 @@ DEF_PROP_F(Plane, ZoomY)
|
||||||
void
|
void
|
||||||
planeBindingInit(mrb_state *mrb)
|
planeBindingInit(mrb_state *mrb)
|
||||||
{
|
{
|
||||||
RClass *klass = mrb_define_class(mrb, "Plane", 0);
|
RClass *klass = defineClass(mrb, "Plane");
|
||||||
|
|
||||||
disposableBindingInit<Plane> (mrb, klass);
|
disposableBindingInit<Plane> (mrb, klass);
|
||||||
viewportElementBindingInit<Plane>(mrb, klass);
|
viewportElementBindingInit<Plane>(mrb, klass);
|
||||||
|
|
|
@ -100,7 +100,7 @@ DEF_PROP_F(Sprite, WavePhase)
|
||||||
void
|
void
|
||||||
spriteBindingInit(mrb_state *mrb)
|
spriteBindingInit(mrb_state *mrb)
|
||||||
{
|
{
|
||||||
RClass *klass = mrb_define_class(mrb, "Sprite", 0);
|
RClass *klass = defineClass(mrb, "Sprite");
|
||||||
|
|
||||||
disposableBindingInit <Sprite>(mrb, klass);
|
disposableBindingInit <Sprite>(mrb, klass);
|
||||||
flashableBindingInit <Sprite>(mrb, klass);
|
flashableBindingInit <Sprite>(mrb, klass);
|
||||||
|
|
|
@ -145,7 +145,7 @@ MARSH_LOAD_FUN(Table)
|
||||||
void
|
void
|
||||||
tableBindingInit(mrb_state *mrb)
|
tableBindingInit(mrb_state *mrb)
|
||||||
{
|
{
|
||||||
RClass *klass = mrb_define_class(mrb, "Table", 0);
|
RClass *klass = defineClass(mrb, "Table");
|
||||||
|
|
||||||
mrb_define_class_method(mrb, klass, "_load", TableLoad, MRB_ARGS_REQ(1));
|
mrb_define_class_method(mrb, klass, "_load", TableLoad, MRB_ARGS_REQ(1));
|
||||||
serializableBindingInit<Table>(mrb, klass);
|
serializableBindingInit<Table>(mrb, klass);
|
||||||
|
|
|
@ -142,13 +142,13 @@ DEF_PROP_I(Tilemap, OY)
|
||||||
void
|
void
|
||||||
tilemapBindingInit(mrb_state *mrb)
|
tilemapBindingInit(mrb_state *mrb)
|
||||||
{
|
{
|
||||||
RClass *klass = mrb_define_class(mrb, "TilemapAutotiles", 0);
|
RClass *klass = defineClass(mrb, "TilemapAutotiles");
|
||||||
|
|
||||||
mrb_define_method(mrb, klass, "[]=", tilemapAutotilesSet, MRB_ARGS_REQ(2));
|
mrb_define_method(mrb, klass, "[]=", tilemapAutotilesSet, MRB_ARGS_REQ(2));
|
||||||
mrb_define_method(mrb, klass, "[]", tilemapAutotilesGet, MRB_ARGS_REQ(1));
|
mrb_define_method(mrb, klass, "[]", tilemapAutotilesGet, MRB_ARGS_REQ(1));
|
||||||
mrb_define_method(mrb, klass, "inspect", inspectObject, MRB_ARGS_NONE());
|
mrb_define_method(mrb, klass, "inspect", inspectObject, MRB_ARGS_NONE());
|
||||||
|
|
||||||
klass = mrb_define_class(mrb, "Tilemap", 0);
|
klass = defineClass(mrb, "Tilemap");
|
||||||
|
|
||||||
disposableBindingInit<Tilemap>(mrb, klass);
|
disposableBindingInit<Tilemap>(mrb, klass);
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ DEF_PROP_I(Viewport, OY)
|
||||||
void
|
void
|
||||||
viewportBindingInit(mrb_state *mrb)
|
viewportBindingInit(mrb_state *mrb)
|
||||||
{
|
{
|
||||||
RClass *klass = mrb_define_class(mrb, "Viewport", 0);
|
RClass *klass = defineClass(mrb, "Viewport");
|
||||||
|
|
||||||
disposableBindingInit <Viewport>(mrb, klass);
|
disposableBindingInit <Viewport>(mrb, klass);
|
||||||
flashableBindingInit <Viewport>(mrb, klass);
|
flashableBindingInit <Viewport>(mrb, klass);
|
||||||
|
|
|
@ -73,7 +73,7 @@ DEF_PROP_I(Window, ContentsOpacity)
|
||||||
void
|
void
|
||||||
windowBindingInit(mrb_state *mrb)
|
windowBindingInit(mrb_state *mrb)
|
||||||
{
|
{
|
||||||
RClass *klass = mrb_define_class(mrb, "Window", 0);
|
RClass *klass = defineClass(mrb, "Window");
|
||||||
|
|
||||||
disposableBindingInit <Window>(mrb, klass);
|
disposableBindingInit <Window>(mrb, klass);
|
||||||
viewportElementBindingInit<Window>(mrb, klass);
|
viewportElementBindingInit<Window>(mrb, klass);
|
||||||
|
|
Loading…
Reference in New Issue