MRI: rewrite script eval (was: Question about $0) #24

Merged
cremno merged 7 commits from mri-rewrite-script-eval into master 2014-04-12 09:54:13 +00:00
1 changed files with 13 additions and 3 deletions
Showing only changes of commit 4e0262d2a7 - Show all commits

View File

@ -262,15 +262,24 @@ static void runRMXPScripts()
} }
rb_ary_store(script, 3, rb_str_new_cstr(decodeBuffer.c_str())); rb_ary_store(script, 3, rb_str_new_cstr(decodeBuffer.c_str()));
}
for (long i = 0; i < scriptCount; ++i)
{
VALUE script = rb_ary_entry(scriptArray, i);
VALUE scriptDecoded = rb_ary_entry(script, 3);
/* Store encoding header + the decoded script /* Store encoding header + the decoded script
* in 'sc.decData' */ * in 'sc.decData' */
std::string decData = "#encoding:utf-8\n"; std::string decData = "#encoding:utf-8\n";
size_t hdSize = decData.size(); size_t hdSize = decData.size();
decData.resize(hdSize + bufferLen); const char *scriptDecPtr;
memcpy(&decData[hdSize], decodeBuffer.c_str(), bufferLen); long scriptDecLen;
RSTRING_GETMEM(scriptDecoded, scriptDecPtr, scriptDecLen);
decData.resize(hdSize + scriptDecLen);
memcpy(&decData[hdSize], scriptDecPtr, scriptDecLen);
ruby_script(RSTRING_PTR(scriptName)); ruby_script(RSTRING_PTR(rb_ary_entry(script, 1)));
/* Execute code */ /* Execute code */
rb_eval_string_protect(decData.c_str(), 0); rb_eval_string_protect(decData.c_str(), 0);
@ -281,6 +290,7 @@ static void runRMXPScripts()
} }
} }
static void mriBindingExecute() static void mriBindingExecute()
{ {
ruby_setup(); ruby_setup();