MRI: rewrite script eval (was: Question about $0) #24
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#24
Loading…
Reference in New Issue
No description provided.
Delete Branch "mri-rewrite-script-eval"
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?
Maybe there is a reason for setting
$0
. Could you tell me? I can only speculate:It's far easier and more intuitive than this which doesn't work with mkxp:
So if that's a mkxp-specific extension, then it should be mentioned in the README.
Relevant code line: https://github.com/Ancurio/mkxp/blob/f06769b434/binding-mri/binding-mri.cpp#L269
The reason as far as I remember was me desperately trying to get ruby to output script names inside exception backtraces. Alas, I failed; I don't think there's a need to call this function.
This is one part that really frustrated me too because I was able to almost perfectly replicate exception messages in the mruby binding ^^"
I closed #23. I wanted to send two separate PRs, but I think
$RGSS_SCRIPTS
,$0
and__FILE__
are related enough. The code above should work now!As I've already said I'm trying to get the Hermes 0.4 demo (among other things) to run under mkxp and now it's (hopefully) only Ruby 1.9+ issues I have to deal with. Other scripts that are using those things aren't important (to me). They're mainly used for debugging or better error printing which might be helpful when porting games.
I also don't know why the RGSS isn't setting
__FILE__
to the script's name. That can be done and would fix useless filenames in warnings and error messages. At least in the last case that can be fixed, but even that is kinda messy.Yeah, that seems pretty backward. It would be nice to add a config bool sometime later to override this behavior and set FILE to the actual script name, for debugging purposes.
I really really like that you found a way to force the script encoding into UTF8 without using the ugly header solution; that was seriously giving me headaches when I had to implement it! (It also screwed up the line numbers in backtraces)
Alright, this looks good so far. I'll test it a bit more when I get time and then do the merge.
Added! Feel free to change the name or default setting. I'm not good at naming things and the default (
Section042
) isn't helpful at the moment. I may look into better backtraces in the future, but this will definitely be another PR.Hey, that's awesome! I just tried this with a game I've been debugging a week ago, and the new backtraces make things a million times easier to trace down. Also, warnings during runtime finally have proper locations attached to them which makes them a lot less cryptic. All in all this is a big win.
As always, thanks a lot for your contribution!