From 39ac6aecf06add5aaf453e160a6ccd645d829c91 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Sat, 28 Apr 2018 12:39:21 +0530 Subject: [PATCH] Fix up build with mruby binding --- binding-mruby/binding-mruby.cpp | 4 ++-- binding-mruby/binding-util.cpp | 2 +- binding-mruby/font-binding.cpp | 25 ++++++++++++++++++------- binding-mruby/mrb-ext/file.cpp | 2 +- binding-mruby/mrb-ext/kernel.cpp | 2 +- binding-mruby/mrb-ext/marshal.cpp | 12 +++++------- 6 files changed, 28 insertions(+), 19 deletions(-) diff --git a/binding-mruby/binding-mruby.cpp b/binding-mruby/binding-mruby.cpp index a713d73..458d0b0 100644 --- a/binding-mruby/binding-mruby.cpp +++ b/binding-mruby/binding-mruby.cpp @@ -117,7 +117,7 @@ static void mrbBindingInit(mrb_state *mrb) /* Load global constants */ mrb_define_global_const(mrb, "MKXP", mrb_true_value()); - mrb_value debug = rb_bool_new(shState->config().editor.debug); + mrb_value debug = mrb_bool_value(shState->config().editor.debug); if (rgssVer == 1) mrb_define_global_const(mrb, "DEBUG", debug); else if (rgssVer >= 2) @@ -298,7 +298,7 @@ runRMXPScripts(mrb_state *mrb, mrbc_context *ctx) return; } - int scriptCount = mrb_ary_len(scriptMrb, scriptArray); + int scriptCount = RARRAY_LEN(scriptArray); std::string decodeBuffer; decodeBuffer.resize(0x1000); diff --git a/binding-mruby/binding-util.cpp b/binding-mruby/binding-util.cpp index c062eec..efb38c9 100644 --- a/binding-mruby/binding-util.cpp +++ b/binding-mruby/binding-util.cpp @@ -72,7 +72,7 @@ static const MrbExcData excData[] = { PHYSFS, "PHYSFSError" }, { SDL, "SDLError" }, { MKXP, "MKXPError" }, - { IO, "IOError" } + { IO, "IOError2" } }; static elementsN(excData); diff --git a/binding-mruby/font-binding.cpp b/binding-mruby/font-binding.cpp index 31cfd01..e76a1cd 100644 --- a/binding-mruby/font-binding.cpp +++ b/binding-mruby/font-binding.cpp @@ -49,7 +49,12 @@ MRB_METHOD(fontInitialize) mrb_get_args(mrb, "|zi", &name, &size); - Font *f = new Font(name, size); + Font *f; + + std::vector names; + names.push_back(name); + + f = new Font(&names, size); setPrivateData(self, f, FontType); @@ -86,9 +91,8 @@ MRB_METHOD(fontInitializeCopy) MRB_METHOD(FontGetName) { - Font *f = getPrivateData(mrb, self); - - return mrb_str_new_cstr(mrb, f->getName()); + /* FIXME: getName method is missing from Font */ + return mrb_str_new_cstr(mrb, "name"); } MRB_METHOD(FontSetName) @@ -98,7 +102,10 @@ MRB_METHOD(FontSetName) mrb_value name; mrb_get_args(mrb, "S", &name); - f->setName(RSTRING_PTR(name)); + std::vector names; + names.push_back(RSTRING_PTR(name)); + + f->setName(names); return name; } @@ -137,7 +144,8 @@ DEF_KLASS_PROP(Font, mrb_bool, DefaultShadow, "b", bool) MRB_FUNCTION(FontGetDefaultName) { - return mrb_str_new_cstr(mrb, Font::getDefaultName()); + /* FIXME: getDefaultName method is missing from Font */ + return mrb_str_new_cstr(mrb, "default_name"); } MRB_FUNCTION(FontSetDefaultName) @@ -145,7 +153,10 @@ MRB_FUNCTION(FontSetDefaultName) mrb_value nameObj; mrb_get_args(mrb, "S", &nameObj); - Font::setDefaultName(RSTRING_PTR(nameObj)); + std::vector names; + names.push_back(RSTRING_PTR(nameObj)); + + Font::setDefaultName(names, shState->fontState()); return nameObj; } diff --git a/binding-mruby/mrb-ext/file.cpp b/binding-mruby/mrb-ext/file.cpp index e68a38d..199c924 100644 --- a/binding-mruby/mrb-ext/file.cpp +++ b/binding-mruby/mrb-ext/file.cpp @@ -596,7 +596,7 @@ fileBindingInit(mrb_state *mrb) mrb_define_method(mrb, klass, "path", fileGetPath, MRB_ARGS_NONE()); /* FileTest */ - RClass *module = mrb_define_module(mrb, "FileTest"); + RClass *module = mrb_define_module(mrb, "MKXPFileTest"); mrb_define_module_function(mrb, module, "exist?", fileTestDoesExist, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, module, "directory?", fileTestIsDirectory, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, module, "file?", fileTestIsFile, MRB_ARGS_REQ(1)); diff --git a/binding-mruby/mrb-ext/kernel.cpp b/binding-mruby/mrb-ext/kernel.cpp index 0046869..e82b7fb 100644 --- a/binding-mruby/mrb-ext/kernel.cpp +++ b/binding-mruby/mrb-ext/kernel.cpp @@ -172,7 +172,7 @@ MRB_FUNCTION(kernelLoadData) mrb_get_args(mrb, "z", &filename); SDL_RWops ops; - GUARD_EXC( shState->fileSystem().openRead(ops, filename); ) + GUARD_EXC( shState->fileSystem().openReadRaw(ops, filename); ) mrb_value obj; try { obj = marshalLoadInt(mrb, &ops); } diff --git a/binding-mruby/mrb-ext/marshal.cpp b/binding-mruby/mrb-ext/marshal.cpp index 78baddb..d6a5558 100644 --- a/binding-mruby/mrb-ext/marshal.cpp +++ b/binding-mruby/mrb-ext/marshal.cpp @@ -473,8 +473,8 @@ read_value(MarshalContext *ctx) mrb_state *mrb = ctx->mrb; int8_t type = ctx->readByte(); mrb_value value; - if (mrb->arena_idx > maxArena) - maxArena = mrb->arena_idx; + if (mrb->gc.arena_idx > maxArena) + maxArena = mrb->gc.arena_idx; int arena = mrb_gc_arena_save(mrb); @@ -676,7 +676,7 @@ static void write_array(MarshalContext *ctx, mrb_value array) { mrb_state *mrb = ctx->mrb; - int len = mrb_ary_len(mrb, array); + int len = RARRAY_LEN(array); write_fixnum(ctx, len); int i; @@ -687,8 +687,6 @@ write_array(MarshalContext *ctx, mrb_value array) } } -KHASH_DECLARE(ht, mrb_value, mrb_value, 1) - static void write_hash(MarshalContext *ctx, mrb_value hash) { @@ -707,7 +705,7 @@ write_hash(MarshalContext *ctx, mrb_value hash) continue; write_value(ctx, kh_key(h, k)); - write_value(ctx, kh_val(h, k)); + write_value(ctx, kh_val(h, k).v); } } @@ -732,7 +730,7 @@ write_object(MarshalContext *ctx, mrb_value object) write_value(ctx, mrb_str_intern(mrb, path)); mrb_value iv_ary = mrb_obj_instance_variables(mrb, object); - int iv_count = mrb_ary_len(mrb, iv_ary); + int iv_count = RARRAY_LEN(iv_ary); write_fixnum(ctx, iv_count); int i;