Fix mruby bindings #197
No reviewers
Labels
No Label
RGSS accuracy
bug
compilation
discussion
documentation
duplicate
enhancement
invalid
performance issue
port request
question
ruby incompatibility
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: MapleShrine/mkxp#197
Loading…
Reference in New Issue
No description provided.
Delete Branch "pulsejet/mrb"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The bindings currently provided are really old and incompatible with API changes. mkxp compiles and runs against the latest mruby with these changes.
Good to see someone work on this! 👍
@Ancurio any reason why the RPG module is defined differently for mruby and MRI? The current mruby module gives me really cryptic errors; just adding the scripts from MRI to my
Scripts.rxdata
works pretty well. With only minor changes, the game seems to work (sorta), though for some reason no events are being triggered as I interact with them :(Looks good overall; sorry for the state the mruby binding has been in, I haven't used it in a long while and thus neglected maintenance. Would be great if there was an actual use for it besides just simple test scripts.
Thanks for working on it.
@ -119,3 +119,3 @@
mrb_value debug = rb_bool_new(shState->config().editor.debug);
mrb_value debug = mrb_bool_value(shState->config().editor.debug);
if (rgssVer == 1)
hm,
rb_
is from the MRI binding, so this probably slipped in with PR #191.@ -71,8 +71,7 @@ static const MrbExcData excData[] =
{ Shutdown, "SystemExit" },
Why the rename? Is
IOError
already defined by mruby?Return the saved IV here (see below).
Compare the MRI binding: We additionally save the passed argument as an IV, and return that in the getter.
@ -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)
Same as with get/SetName, except that the IV is stored in the Class object.
@ -598,3 +598,3 @@
/* 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));
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?
no spurious whitespace changes pls
whitespace change
@ -477,2 +476,3 @@
maxArena = mrb->arena_idx;
if (mrb->gc.arena_idx > maxArena)
maxArena = mrb->gc.arena_idx;
I don't remember the internals of mruby too well so I'll just trust that this does the right thing :)
@pulsejet
The mruby RPG module is the pre-compiled bytecode version; if there was a way to do this with MRI I would, but atm I can only feed it plain Ruby source code. You should be able to use your up-to-date version of mruby to update the precompiled bytecode.
@ -71,8 +71,7 @@ static const MrbExcData excData[] =
{ Shutdown, "SystemExit" },
Yeah. If I remember right, this throws up some error about
IOError
already existing.@ -598,3 +598,3 @@
/* 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));
Yup, it is in the
mruby-io
mrbgem that is included with the default build (check this, for some reason, the documentation doesn't list this). I'm a bit inclined towards keeping this code for a while since I haven't really tested much yet, so just renamed it toMKXPFileTest
. What do you think?Sorry about this. Perils of working late night =|
@ -71,8 +71,7 @@ static const MrbExcData excData[] =
{ Shutdown, "SystemExit" },
Should I rename this to something better?
Done
Needed to change this to
MRB_METHOD
forself
to be defined. Not sure what the change really means...@Ancurio
Would there be any realistic advantage of doing this?
Fixed up the requested changes and updated the RPG module. Decided to move the bytecode to a separate
xxd
file the way the mri bindings do; is there any argument against this?@ -598,3 +598,3 @@
/* 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));
Renaming the Module defeats the entire purpose of having it; code expecting
FileTest
functions will not work. Could you check whether themruby-io
gem covers all of the functions mentioned in the RGSS1 documentation? Either we require the gem to be disabled for mkxp, or drop the mkxp code in favor of the gem.It's what you said; only a method has an object to operate on (self), functions don't. The
FUNCTION
macro was to avoid having to(void)
the self argument every time in module functions.Maybe it just irks me to parse the same source code every time on startup; but you're right, it might be less of a headache to always just parse source instead having to compile against a possibly changing bytecode-specification (like with mruby); and I believe there might be far heavier tasks going on at startup.
Ideally though, the bytecode compilation would be integrated in mkxp's build process,
Could you please compile mruby without the
io
gem and only keep the fixes required to get that running? We can move eventual changes from replacing my custom code with the gem into a separate issue/PR.Sorry I didn't see this. Going out of town for now; I'll fix this when I get back. @Ancurio do we also want to make the change to to mruby-marshal? It seems to be much more complete and saving/loading works with minor changes (you can dump/load only once) unlike the current marshal class. One downside is that it depends on onig.
@ -598,3 +598,3 @@
/* 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));
@Ancurio just checked, it does implement everything we want (and much more) for
FileTest
and nothing forFile
(so no overlapping symbols). Actually I'm strongly against disablingmruby-io
, since being a core mrbgem, this will definitely break something else (mruby-marshal for a start)@ -71,8 +71,7 @@ static const MrbExcData excData[] =
{ Shutdown, "SystemExit" },
This is from the io-gem too, right. Just delete this entry in the array, and query the existing error class like done here: https://github.com/Ancurio/mkxp/blob/master/binding-mruby/binding-util.cpp#L120
@ -598,3 +598,3 @@
/* 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));
@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.
I'm still confused about
File
though; why did you not have to rename that toMKXPFile
?@pulsejet Wait, my marshal code can only dump / load once? That's not supposed to happen.. I think. The Marshal gem by @take-cheeze is not merged into mruby, is it? I would consider switching to it; the more code being shared, the better, especially if it's more complete.
Do you know the status of regular expressions in mruby? I also remember having quite a few problems with that in the past.
Noo @take-cheeze's mruby-marshal can load only once in the sense that you can't get variables by doing
variable_name = Marshal.load(file)
repeatedly, as it will set the entire contents of the file tovariable_name
and for dump any repeated calls are ignored. That part isn't merged yet. Sorry for the confusion.For Regex, I'm using mruby-onig-regexp, but I've also tried mruby-regexp-pcre and both seem to work fine, at least as far as I tested.
@ -598,3 +598,3 @@
/* 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));
Weirdly, the
File
class of themruby-io
is completely different, whileFileTest
is exactly the same, so we needFile
(though I've not tried removing it). Not really sure about anything here, but one thing I can confirm is thatthis code works
:PI wonder if @take-cheeze 's implementation can be configured for different RegExp implementations. Also on the dumping / loading only working once, that's a different behavior from MRI then, isn't it? I wonder if that is intentional or a bug.
@ -598,3 +598,3 @@
/* 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));
b724e06cf2/mrbgems/mruby-io/src/file.c (L395)
b724e06cf2/mrbgems/mruby-io/src/file_test.c (L365)
So it's
IO::File
in mruby whileFileTest
is defined in the global namespace? That's weird.Might be intentional, not sure. How is the behavior of MRI supposed to be implemented anyway? As for regex, I think using onig might be recommendable anyway, since the PCRE implementation says that you might want to use onig if you want better compatibility with MRI.
Sorry I completely forgot about this. Removed the
IOError2
thing (don't even remember much now) and right now this just works with mruby 1.4.1 compiled with the default gems (which includesio
, btw), and the default game seems to run fine (with the exception of save/load, of course). @Ancurio could you please go over this quickly one more time?@ -71,8 +71,7 @@ static const MrbExcData excData[] =
{ Shutdown, "SystemExit" },
Did this, but tbh I've no idea what's going on here
Step 1:
From your project repository, check out a new branch and test the changes.Step 2:
Merge the changes and update on Forgejo.