-
Notifications
You must be signed in to change notification settings - Fork 215
Fix mruby bindings #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix mruby bindings #197
Changes from all commits
39ac6ae
8b21699
a996d36
b90aa74
6fccac8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,7 +49,12 @@ MRB_METHOD(fontInitialize) | |
|
|
||
| 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); | ||
|
|
||
|
|
@@ -86,9 +91,7 @@ MRB_METHOD(fontInitializeCopy) | |
|
|
||
| MRB_METHOD(FontGetName) | ||
| { | ||
| Font *f = getPrivateData<Font>(mrb, self); | ||
|
|
||
| return mrb_str_new_cstr(mrb, f->getName()); | ||
| return mrb_iv_get(mrb, self, mrb_intern_cstr(mrb, "name")); | ||
| } | ||
|
|
||
| MRB_METHOD(FontSetName) | ||
|
|
@@ -98,7 +101,11 @@ MRB_METHOD(FontSetName) | |
| mrb_value 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); | ||
|
pulsejet marked this conversation as resolved.
|
||
| mrb_iv_set(mrb, self, mrb_intern_cstr(mrb, "name"), 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, DefaultShadow, "b", bool) | ||
|
|
||
| MRB_FUNCTION(FontGetDefaultName) | ||
| MRB_METHOD(FontGetDefaultName) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needed to change this to
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's what you said; only a method has an object to operate on (self), functions don't. The |
||
| { | ||
| 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_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; | ||
| } | ||
|
|
||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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"); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With this rename the class becomes pointless (scripts expect this standard name, which is also mentioned in the RGSS documentation); why was it necessary? Is there a native implementation now?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, it is in the
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Renaming the Module defeats the entire purpose of having it; code expecting
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Ancurio just checked, it does implement everything we want (and much more) for
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pulsejet Oh I'm sorry, I just finally understood why you renamed the module; my brain must have been lagging. The rename is fine (although I'd like to delete my code as soon as possible), with a comment about why the old classes exist.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Weirdly, the
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So it's |
||
| 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)); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't remember the internals of mruby too well so I'll just trust that this does the right thing :) |
||
|
|
||
| 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; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm,
rb_is from the MRI binding, so this probably slipped in with PR #191.