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);
|
||||
fflush(stdout);
|
||||
|
||||
return mrb__float_value(ms);
|
||||
return mrb_float_value(mrb, ms);
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
|
|
@ -112,6 +112,12 @@ getMrbData(mrb_state *mrb)
|
|||
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) \
|
||||
{ try { exp } catch (Exception &exc) { raiseMrbExc(mrb, exc); } }
|
||||
|
||||
|
@ -237,7 +243,7 @@ mrb__float_value(mrb_float f)
|
|||
{
|
||||
mrb_value v;
|
||||
|
||||
MRB_SET_VALUE(v, MRB_TT_FLOAT, value.f, f);
|
||||
SET_FLOAT_VALUE(0, v, f);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
|
@ -306,7 +306,7 @@ CLONE_FUN(Bitmap)
|
|||
void
|
||||
bitmapBindingInit(mrb_state *mrb)
|
||||
{
|
||||
RClass *klass = mrb_define_class(mrb, "Bitmap", 0);
|
||||
RClass *klass = defineClass(mrb, "Bitmap");
|
||||
|
||||
disposableBindingInit<Bitmap>(mrb, klass);
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ CLONE_FUN(Rect)
|
|||
|
||||
#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)); \
|
||||
serializableBindingInit<Klass>(mrb, klass); \
|
||||
mrb_define_method(mrb, klass, "initialize", Klass##Initialize, MRB_ARGS_REQ(3) | MRB_ARGS_OPT(1)); \
|
||||
|
|
|
@ -142,7 +142,7 @@ MRB_METHOD(FontSetDefaultColor)
|
|||
void
|
||||
fontBindingInit(mrb_state *mrb)
|
||||
{
|
||||
RClass *klass = mrb_define_class(mrb, "Font", 0);
|
||||
RClass *klass = defineClass(mrb, "Font");
|
||||
|
||||
Font::setDefaultColor(new Color(*Font::getDefaultColor()));
|
||||
wrapProperty(mrb, mrb_obj_value(klass), Font::getDefaultColor(), CSdefault_color, ColorType);
|
||||
|
|
|
@ -227,7 +227,7 @@ MRB_FUNCTION(fileExpandPath)
|
|||
if (defDir)
|
||||
Debug() << "FIXME: File.expand_path: default_dir not implemented";
|
||||
|
||||
char buffer[512];
|
||||
char buffer[PATH_MAX];
|
||||
char *unused = realpath(path, buffer);
|
||||
(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());
|
||||
|
||||
RClass *klass = mrb_define_class(mrb, "IO", 0);
|
||||
RClass *klass = defineClass(mrb, "IO");
|
||||
klass = mrb_define_class(mrb, "File", klass);
|
||||
|
||||
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;
|
||||
int len = read_fixnum(ctx);
|
||||
|
||||
struct RString *str =
|
||||
(struct RString*) mrb_obj_alloc
|
||||
(mrb, MRB_TT_STRING, mrb->string_class);
|
||||
mrb_value str = mrb_str_new(mrb, 0, len);
|
||||
char *ptr = RSTR_PTR(RSTRING(str));
|
||||
|
||||
str->c = mrb->string_class;
|
||||
str->len = len;
|
||||
str->aux.capa = len;
|
||||
str->ptr = (char*) mrb_malloc(mrb, len+1);
|
||||
ctx->readData(ptr, len);
|
||||
ptr[len] = '\0';
|
||||
|
||||
ctx->readData(str->ptr, len);
|
||||
str->ptr[len] = '\0';
|
||||
|
||||
mrb_value str_obj = mrb_obj_value(str);
|
||||
|
||||
return str_obj;
|
||||
return str;
|
||||
}
|
||||
|
||||
static mrb_value read_value(MarshalContext *ctx);
|
||||
|
@ -724,7 +716,7 @@ write_symbol(MarshalContext *ctx, mrb_value symbol)
|
|||
{
|
||||
mrb_state *mrb = ctx->mrb;
|
||||
mrb_sym sym = mrb_symbol(symbol);
|
||||
size_t len;
|
||||
mrb_int len;
|
||||
const char *p = mrb_sym2name_len(mrb, sym, &len);
|
||||
|
||||
write_string(ctx, p);
|
||||
|
|
|
@ -197,8 +197,8 @@ TIME_ATTR(wday)
|
|||
void
|
||||
timeBindingInit(mrb_state *mrb)
|
||||
{
|
||||
RClass *klass = mrb_define_class(mrb, "Time", 0);
|
||||
mrb_include_module(mrb, klass, mrb_class_get(mrb, "Comparable"));
|
||||
RClass *klass = defineClass(mrb, "Time");
|
||||
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, "at", timeAt, MRB_ARGS_REQ(1));
|
||||
|
|
|
@ -61,7 +61,7 @@ DEF_PROP_F(Plane, ZoomY)
|
|||
void
|
||||
planeBindingInit(mrb_state *mrb)
|
||||
{
|
||||
RClass *klass = mrb_define_class(mrb, "Plane", 0);
|
||||
RClass *klass = defineClass(mrb, "Plane");
|
||||
|
||||
disposableBindingInit<Plane> (mrb, klass);
|
||||
viewportElementBindingInit<Plane>(mrb, klass);
|
||||
|
|
|
@ -100,7 +100,7 @@ DEF_PROP_F(Sprite, WavePhase)
|
|||
void
|
||||
spriteBindingInit(mrb_state *mrb)
|
||||
{
|
||||
RClass *klass = mrb_define_class(mrb, "Sprite", 0);
|
||||
RClass *klass = defineClass(mrb, "Sprite");
|
||||
|
||||
disposableBindingInit <Sprite>(mrb, klass);
|
||||
flashableBindingInit <Sprite>(mrb, klass);
|
||||
|
|
|
@ -145,7 +145,7 @@ MARSH_LOAD_FUN(Table)
|
|||
void
|
||||
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));
|
||||
serializableBindingInit<Table>(mrb, klass);
|
||||
|
|
|
@ -142,13 +142,13 @@ DEF_PROP_I(Tilemap, OY)
|
|||
void
|
||||
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, "[]", tilemapAutotilesGet, MRB_ARGS_REQ(1));
|
||||
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);
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ DEF_PROP_I(Viewport, OY)
|
|||
void
|
||||
viewportBindingInit(mrb_state *mrb)
|
||||
{
|
||||
RClass *klass = mrb_define_class(mrb, "Viewport", 0);
|
||||
RClass *klass = defineClass(mrb, "Viewport");
|
||||
|
||||
disposableBindingInit <Viewport>(mrb, klass);
|
||||
flashableBindingInit <Viewport>(mrb, klass);
|
||||
|
|
|
@ -73,7 +73,7 @@ DEF_PROP_I(Window, ContentsOpacity)
|
|||
void
|
||||
windowBindingInit(mrb_state *mrb)
|
||||
{
|
||||
RClass *klass = mrb_define_class(mrb, "Window", 0);
|
||||
RClass *klass = defineClass(mrb, "Window");
|
||||
|
||||
disposableBindingInit <Window>(mrb, klass);
|
||||
viewportElementBindingInit<Window>(mrb, klass);
|
||||
|
|
Loading…
Reference in New Issue