예제 #1
0
rpmRC rpmrubyRunFile(rpmruby ruby, const char * fn, const char ** resultp)
{
    rpmRC rc = RPMRC_FAIL;

RUBYDBG((stderr, "--> %s(%p,%s,%p)\n", __FUNCTION__, ruby, fn, resultp));

    if (ruby == NULL) ruby = rpmrubyI();

    if (fn == NULL)
	goto exit;

#if defined(WITH_RUBYEMBED)
#if !defined(HAVE_RUBY_DEFINES_H)	/* XXX ruby-1.8.6 */
    rb_load_file(fn);
    ruby->state = ruby_exec();
#else
    ruby->state = ruby_exec_node(rb_load_file(fn));
#endif
    if (resultp != NULL)
	*resultp = RSTRING_PTR(rb_gv_get("$result"));
    rc = RPMRC_OK;
#endif	/* WITH_RUBYEMBED */

exit:
RUBYDBG((stderr, "<-- %s(%p,%s,%p) rc %d\n", __FUNCTION__, ruby, fn, resultp, rc));
    return rc;
}
예제 #2
0
파일: main.c 프로젝트: weimingtom/eriri_lua
int main(int argc, char *argv[])
{
	int ret;
	const char *script = argv[1];

	if (script == NULL) {
		script = 
			//"alphadraw.rb";
			"alpha.rb";
			//"aadraw.rb";
			//"test_fib.rb";
	}

	ruby_debug = Qtrue;
	ruby_verbose = Qtrue;

	ruby_init();
	ruby_init_loadpath();
	ruby_script(script);
	rb_load_file(script);
	ret = ruby_cleanup(ruby_exec());

	//exit(ret);
	return(ret);
}
예제 #3
0
파일: ruby.c 프로젝트: 0xroot/radare2
static int slurp_ruby(const char *file)
{
	if (r_file_exists(file)) {
		rb_load_file(file);
		ruby_exec();
		return R_TRUE;
	}
	eprintf("lang_ruby: Cannot open '%s'\n", file);
	return R_FALSE;
}
예제 #4
0
	Module* RubyModule::CreateModule(std::string& path)
	{
		path = UTF8ToSystem(path);
		rb_load_file(path.c_str());
		ruby_exec();
		// TODO: Do we need to call ruby_cleanup() here?

		Poco::Path p(path);
		std::string basename = p.getBaseName();
		std::string name = basename.substr(0,basename.length()-ruby_suffix.length()+3);
		std::string moduledir = path.substr(0,path.length()-basename.length()-3);

		return new RubyModuleInstance(host, path, moduledir, name);
	}
예제 #5
0
파일: ruby_module.cpp 프로젝트: mital/kroll
	Module* RubyModule::CreateModule(std::string& path)
	{
		rb_load_file(path.c_str());
		ruby_exec();

//		ruby_cleanup();  <-- at some point we need to call?


		Poco::Path p(path);
		std::string basename = p.getBaseName();
		std::string name = basename.substr(0,basename.length()-ruby_suffix.length()+3);
		std::string moduledir = path.substr(0,path.length()-basename.length()-3);

		Logger *logger = Logger::Get("Ruby");
		logger->Info("Loading Ruby path=%s", path.c_str());

		return new RubyModuleInstance(host, path, moduledir, name);
	}
예제 #6
0
/**
 * Load a ruby file
 *
 * @arg the file to load
 * @return Qnil
 */
VALUE LoadWrap(VALUE arg) {
  const char *filename = reinterpret_cast<const char*>(arg);
  rb_load_file(filename);
  return Qnil;
}
예제 #7
0
파일: load.c 프로젝트: Subv/Ruby-Impl
static void
rb_load_internal(VALUE fname, int wrap)
{
    int state;
    rb_thread_t *th = GET_THREAD();
    volatile VALUE wrapper = th->top_wrapper;
    volatile VALUE self = th->top_self;
    volatile int loaded = FALSE;
    volatile int mild_compile_error;
#ifndef __GNUC__
    rb_thread_t *volatile th0 = th;
#endif

    th->errinfo = Qnil; /* ensure */

    if (!wrap) {
	rb_secure(4);		/* should alter global state */
	th->top_wrapper = 0;
    }
    else {
	/* load in anonymous module as toplevel */
	th->top_self = rb_obj_clone(rb_vm_top_self());
	th->top_wrapper = rb_module_new();
	rb_extend_object(th->top_self, th->top_wrapper);
    }

    mild_compile_error = th->mild_compile_error;
    PUSH_TAG();
    state = EXEC_TAG();
    if (state == 0) {
	NODE *node;
	VALUE iseq;

	th->mild_compile_error++;
	node = (NODE *)rb_load_file(RSTRING_PTR(fname));
	loaded = TRUE;
	iseq = rb_iseq_new_top(node, rb_str_new2("<top (required)>"), fname, rb_realpath_internal(Qnil, fname, 1), Qfalse);
	th->mild_compile_error--;
	rb_iseq_eval(iseq);
    }
    POP_TAG();

#ifndef __GNUC__
    th = th0;
    fname = RB_GC_GUARD(fname);
#endif
    th->mild_compile_error = mild_compile_error;
    th->top_self = self;
    th->top_wrapper = wrapper;

    if (!loaded) {
	rb_exc_raise(GET_THREAD()->errinfo);
    }
    if (state) {
	rb_vm_jump_tag_but_local_jump(state, Qundef);
    }

    if (!NIL_P(GET_THREAD()->errinfo)) {
	/* exception during load */
	rb_exc_raise(th->errinfo);
    }
}