Merge remote-tracking branch 'pulsejet/mrb' into ems-mruby
This commit is contained in:
commit
ce7a19ae60
|
@ -121,7 +121,7 @@ static void mrbBindingInit(mrb_state *mrb)
|
||||||
/* Load global constants */
|
/* Load global constants */
|
||||||
mrb_define_global_const(mrb, "MKXP", mrb_true_value());
|
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)
|
if (rgssVer == 1)
|
||||||
mrb_define_global_const(mrb, "DEBUG", debug);
|
mrb_define_global_const(mrb, "DEBUG", debug);
|
||||||
else if (rgssVer >= 2)
|
else if (rgssVer >= 2)
|
||||||
|
@ -302,7 +302,7 @@ runRMXPScripts(mrb_state *mrb, mrbc_context *ctx)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int scriptCount = mrb_arY_len(scriptMrb, scriptArray);
|
int scriptCount = RARRAY_LEN(scriptArray);
|
||||||
|
|
||||||
std::string decodeBuffer;
|
std::string decodeBuffer;
|
||||||
decodeBuffer.resize(0x1000);
|
decodeBuffer.resize(0x1000);
|
||||||
|
|
|
@ -72,7 +72,7 @@ static const MrbExcData excData[] =
|
||||||
{ PHYSFS, "PHYSFSError" },
|
{ PHYSFS, "PHYSFSError" },
|
||||||
{ SDL, "SDLError" },
|
{ SDL, "SDLError" },
|
||||||
{ MKXP, "MKXPError" },
|
{ MKXP, "MKXPError" },
|
||||||
{ IO, "IOError" }
|
{ IO, "IOError2" }
|
||||||
};
|
};
|
||||||
|
|
||||||
static elementsN(excData);
|
static elementsN(excData);
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <mruby/data.h>
|
#include <mruby/data.h>
|
||||||
#include <mruby/variable.h>
|
#include <mruby/variable.h>
|
||||||
#include <mruby/class.h>
|
#include <mruby/class.h>
|
||||||
|
#include <mruby/string.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
@ -352,11 +353,13 @@ inline mrb_value
|
||||||
objectLoad(mrb_state *mrb, mrb_value self, const mrb_data_type &type)
|
objectLoad(mrb_state *mrb, mrb_value self, const mrb_data_type &type)
|
||||||
{
|
{
|
||||||
RClass *klass = mrb_class_ptr(self);
|
RClass *klass = mrb_class_ptr(self);
|
||||||
char *data;
|
|
||||||
int data_len;
|
|
||||||
mrb_get_args(mrb, "s", &data, &data_len);
|
|
||||||
|
|
||||||
C *c = C::deserialize(data, data_len);
|
mrb_value data;
|
||||||
|
mrb_get_args(mrb, "S", &data);
|
||||||
|
|
||||||
|
int data_len = mrb_string_value_len(mrb, data);
|
||||||
|
|
||||||
|
C *c = C::deserialize(RSTRING_PTR(data), data_len);
|
||||||
|
|
||||||
RData *obj = mrb_data_object_alloc(mrb, klass, c, &type);
|
RData *obj = mrb_data_object_alloc(mrb, klass, c, &type);
|
||||||
mrb_value obj_value = mrb_obj_value(obj);
|
mrb_value obj_value = mrb_obj_value(obj);
|
||||||
|
|
|
@ -49,7 +49,12 @@ MRB_METHOD(fontInitialize)
|
||||||
|
|
||||||
mrb_get_args(mrb, "|zi", &name, &size);
|
mrb_get_args(mrb, "|zi", &name, &size);
|
||||||
|
|
||||||
Font *f = new Font(name, size);
|
Font *f;
|
||||||
|
|
||||||
|
std::vector<std::string> names;
|
||||||
|
names.push_back(name);
|
||||||
|
|
||||||
|
f = new Font(&names, size);
|
||||||
|
|
||||||
setPrivateData(self, f, FontType);
|
setPrivateData(self, f, FontType);
|
||||||
|
|
||||||
|
@ -86,9 +91,7 @@ MRB_METHOD(fontInitializeCopy)
|
||||||
|
|
||||||
MRB_METHOD(FontGetName)
|
MRB_METHOD(FontGetName)
|
||||||
{
|
{
|
||||||
Font *f = getPrivateData<Font>(mrb, self);
|
return mrb_iv_get(mrb, self, mrb_intern_cstr(mrb, "name"));
|
||||||
|
|
||||||
return mrb_str_new_cstr(mrb, f->getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MRB_METHOD(FontSetName)
|
MRB_METHOD(FontSetName)
|
||||||
|
@ -98,7 +101,11 @@ MRB_METHOD(FontSetName)
|
||||||
mrb_value name;
|
mrb_value name;
|
||||||
mrb_get_args(mrb, "S", &name);
|
mrb_get_args(mrb, "S", &name);
|
||||||
|
|
||||||
f->setName(RSTRING_PTR(name));
|
std::vector<std::string> names;
|
||||||
|
names.push_back(RSTRING_PTR(name));
|
||||||
|
|
||||||
|
f->setName(names);
|
||||||
|
mrb_iv_set(mrb, self, mrb_intern_cstr(mrb, "name"), name);
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -135,17 +142,21 @@ DEF_KLASS_PROP(Font, mrb_bool, DefaultItalic, "b", bool)
|
||||||
DEF_KLASS_PROP(Font, mrb_bool, DefaultOutline, "b", bool)
|
DEF_KLASS_PROP(Font, mrb_bool, DefaultOutline, "b", bool)
|
||||||
DEF_KLASS_PROP(Font, mrb_bool, DefaultShadow, "b", bool)
|
DEF_KLASS_PROP(Font, mrb_bool, DefaultShadow, "b", bool)
|
||||||
|
|
||||||
MRB_FUNCTION(FontGetDefaultName)
|
MRB_METHOD(FontGetDefaultName)
|
||||||
{
|
{
|
||||||
return mrb_str_new_cstr(mrb, Font::getDefaultName());
|
return mrb_iv_get(mrb, self, mrb_intern_cstr(mrb, "default_name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
MRB_FUNCTION(FontSetDefaultName)
|
MRB_METHOD(FontSetDefaultName)
|
||||||
{
|
{
|
||||||
mrb_value nameObj;
|
mrb_value nameObj;
|
||||||
mrb_get_args(mrb, "S", &nameObj);
|
mrb_get_args(mrb, "S", &nameObj);
|
||||||
|
|
||||||
Font::setDefaultName(RSTRING_PTR(nameObj));
|
std::vector<std::string> names;
|
||||||
|
names.push_back(RSTRING_PTR(nameObj));
|
||||||
|
|
||||||
|
Font::setDefaultName(names, shState->fontState());
|
||||||
|
mrb_iv_set(mrb, self, mrb_intern_cstr(mrb, "default_name"), nameObj);
|
||||||
|
|
||||||
return nameObj;
|
return nameObj;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -596,7 +596,7 @@ fileBindingInit(mrb_state *mrb)
|
||||||
mrb_define_method(mrb, klass, "path", fileGetPath, MRB_ARGS_NONE());
|
mrb_define_method(mrb, klass, "path", fileGetPath, MRB_ARGS_NONE());
|
||||||
|
|
||||||
/* FileTest */
|
/* 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, "exist?", fileTestDoesExist, MRB_ARGS_REQ(1));
|
||||||
mrb_define_module_function(mrb, module, "directory?", fileTestIsDirectory, 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));
|
mrb_define_module_function(mrb, module, "file?", fileTestIsFile, MRB_ARGS_REQ(1));
|
||||||
|
|
|
@ -172,7 +172,7 @@ MRB_FUNCTION(kernelLoadData)
|
||||||
mrb_get_args(mrb, "z", &filename);
|
mrb_get_args(mrb, "z", &filename);
|
||||||
|
|
||||||
SDL_RWops ops;
|
SDL_RWops ops;
|
||||||
GUARD_EXC( shState->fileSystem().openRead(ops, filename); )
|
GUARD_EXC( shState->fileSystem().openReadRaw(ops, filename); )
|
||||||
|
|
||||||
mrb_value obj;
|
mrb_value obj;
|
||||||
try { obj = marshalLoadInt(mrb, &ops); }
|
try { obj = marshalLoadInt(mrb, &ops); }
|
||||||
|
|
|
@ -473,8 +473,8 @@ read_value(MarshalContext *ctx)
|
||||||
mrb_state *mrb = ctx->mrb;
|
mrb_state *mrb = ctx->mrb;
|
||||||
int8_t type = ctx->readByte();
|
int8_t type = ctx->readByte();
|
||||||
mrb_value value;
|
mrb_value value;
|
||||||
if (mrb->arena_idx > maxArena)
|
if (mrb->gc.arena_idx > maxArena)
|
||||||
maxArena = mrb->arena_idx;
|
maxArena = mrb->gc.arena_idx;
|
||||||
|
|
||||||
int arena = mrb_gc_arena_save(mrb);
|
int arena = mrb_gc_arena_save(mrb);
|
||||||
|
|
||||||
|
@ -676,7 +676,7 @@ static void
|
||||||
write_array(MarshalContext *ctx, mrb_value array)
|
write_array(MarshalContext *ctx, mrb_value array)
|
||||||
{
|
{
|
||||||
mrb_state *mrb = ctx->mrb;
|
mrb_state *mrb = ctx->mrb;
|
||||||
int len = mrb_ary_len(mrb, array);
|
int len = RARRAY_LEN(array);
|
||||||
write_fixnum(ctx, len);
|
write_fixnum(ctx, len);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
@ -687,8 +687,6 @@ write_array(MarshalContext *ctx, mrb_value array)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KHASH_DECLARE(ht, mrb_value, mrb_value, 1)
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
write_hash(MarshalContext *ctx, mrb_value hash)
|
write_hash(MarshalContext *ctx, mrb_value hash)
|
||||||
{
|
{
|
||||||
|
@ -707,7 +705,7 @@ write_hash(MarshalContext *ctx, mrb_value hash)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
write_value(ctx, kh_key(h, k));
|
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));
|
write_value(ctx, mrb_str_intern(mrb, path));
|
||||||
|
|
||||||
mrb_value iv_ary = mrb_obj_instance_variables(mrb, object);
|
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);
|
write_fixnum(ctx, iv_count);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
Loading…
Reference in New Issue