当前位置: 首页>>代码示例>>C++>>正文


C++ rb_gv_get函数代码示例

本文整理汇总了C++中rb_gv_get函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_gv_get函数的具体用法?C++ rb_gv_get怎么用?C++ rb_gv_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rb_gv_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char **argv)
{
#ifndef __MINGW32__
	FILE *fileconf;
#endif
	char *tmp;
	char lichdir[256] = { '\0' };
	char datadir[512] = { '\0' };
	int nerr;

	sig_setup();

#ifndef __MINGW32__
	snprintf(lichdir, 256, "%s%s", getenv("HOME"), "/.lich.cfg");
	fileconf = fopen(lichdir, "rb");
	if (!fileconf) {
		perror("fopen");
		fprintf(stderr, "Your `$HOME/.lich.cfg' file cannot be opened: please create the file and put the full directory name Lich should use for settings/config files in it.\n\nFor example, to do that, you could type:    echo \"$HOME/lich\" > $HOME/.lich.cfg\n");
		exit(EXIT_FAILURE);
	}
	fgets(lichdir, 256, fileconf);
	fclose(fileconf);
	lichdir[strnlen(lichdir, 256) - 1] = '/';
	chdir(lichdir);
#else
	NtInitialize(&argc, &argv);
	strncpy(lichdir, argv[0], 255);
	tmp = &lichdir[strlen(lichdir)];
	while (tmp && (*tmp != '\\') && (*tmp != '/')) {
		tmp--;
	}
	*tmp = '\0';
	chdir(lichdir);
#endif
	
	init_ruby_interpreter(argc, argv);
	init_libs();
	prep_ruby_env();

	getcwd(lichdir, 255);
	lichdir[strlen(lichdir) + 1] = '\0';
	lichdir[strlen(lichdir)] = RSTRING(rb_const_get(rb_cFile, rb_intern("SEPARATOR")))->ptr[0];

	strcpy(datadir, lichdir);
	strcat(datadir, "data");
	datadir[strlen(datadir)] = lichdir[strlen(lichdir) - 1];

	rb_gv_set("$data_dir", rb_str_new(datadir, strlen(datadir)));
	rb_gv_set("$lich_dir", rb_str_new(lichdir, strlen(lichdir)));

	ruby_safe_level = 0;
	if (nerr = ruby_exec()) {
		tmp = RSTRING(rb_funcall(rb_gv_get("$!"), rb_intern("to_s"), 0))->ptr;
		if (!strncasecmp(tmp, "exit", 4)) ruby_stop(0);
		fprintf(stderr, "%s\n", tmp);
		fprintf(stderr, "%s\n", RSTRING(rb_funcall(rb_funcall(rb_gv_get("$!"), rb_intern("backtrace"), 0), rb_intern("join"), 1, rb_str_new2("\n")))->ptr);
		ruby_stop(nerr);
	}
	ruby_stop(0);
}
开发者ID:mtmiron,项目名称:lich,代码行数:60,代码来源:lich.c

示例2: prep_ruby_env

static inline void prep_ruby_env()
{
	ruby_script("Lich");

#ifdef __MINGW32__
	rb_ary_push(rb_gv_get("$\""), rb_str_new2("socket.dll"));
	reg32_setup();
#else
	rb_ary_push(rb_gv_get("$\""), rb_str_new2("socket.so"));
#endif
}
开发者ID:mtmiron,项目名称:lich,代码行数:11,代码来源:lich.c

示例3: makeProtectedCall

    VALUE makeProtectedCall(const std::string &t_functionName, std::vector<VALUE> &t_params)
    {
      // we go through all of this because we cannot rb_protect a call to
      // rb_funcall. At least not in any way I can find.
      std::stringstream params;

      for (size_t i = 0; i < t_params.size(); ++i)
      {
        std::stringstream ss;
        ss << "$embedded_ruby_param_" << i;

        rb_define_variable(ss.str().c_str(), &t_params[i]);

        params << ss.str();
        if (i < t_params.size() - 1)
        {
          params << ", ";
        }
      }

      std::string funcall = "$embedded_ruby_return = " + t_functionName + "(" + params.str() + ")";
      evalString(funcall);

      VALUE retval = rb_gv_get("$embedded_ruby_return");
      return retval;
    } 
开发者ID:kbenne,项目名称:EmbeddedScripting,代码行数:26,代码来源:RubyInterpreter.hpp

示例4: rg_print

static VALUE
rg_print(int argc, VALUE *argv, VALUE out)
{
    int i;
    VALUE line;
    VALUE output_field_separator;

    /* if no argument given, print `$_' */
    if (argc == 0) {
        argc = 1;
        line = rb_lastline_get();
        argv = &line;
    }

    output_field_separator = rb_gv_get("$,");
    for (i=0; i<argc; i++) {
        if (!NIL_P(output_field_separator) && i>0) {
            rg_write(out, output_field_separator);
        }
        switch (TYPE(argv[i])) {
          case T_NIL:
            rg_write(out, rb_str_new2("nil"));
            break;
          default:
            rg_write(out, argv[i]);
            break;
        }
    }
    if (!NIL_P(output_field_separator)) {
        rg_write(out, output_field_separator);
    }

    return Qnil;
}
开发者ID:htrb,项目名称:ruby-gnome2,代码行数:34,代码来源:rbglib_iochannel.c

示例5: rpmrubyRunFile

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;
}
开发者ID:hahnakane,项目名称:junkcode,代码行数:27,代码来源:rpmruby.c

示例6: Init_rubymsgque

RUBYMQ_EXTERN void Init_rubymsgque() {

  // Register system
#ifdef HAVE_FORK
//  MqInitSysAPI(NS(fork),NULL);
#endif

  // Initialize components
  NS(MqS_Init)();
  NS(MqSException_Init)();
  NS(MqBufferS_Init)();

  // get the script name
  VALUE a0 = rb_gv_get("$0");

  // init libmsgque global data
  if (MqInitBuf == NULL && !NIL_P(a0)) {
    struct MqBufferLS * initB = MqInitCreate();
    MqBufferLAppendC(initB, VAL2CST(rb_argv0));
    MqBufferLAppendC(initB, VAL2CST(a0));
  }

  // set global data
  id_receiver = rb_intern("receiver");
  id_clone = rb_intern("clone");
  id_unbind = rb_intern("unbind");
  id_bind = rb_intern("bind");
}
开发者ID:BackupTheBerlios,项目名称:nhi1-svn,代码行数:28,代码来源:context_ruby.c

示例7: ruby_coroutine_body_require

static VALUE ruby_coroutine_body_require(const char* file)
{
    int error;
    VALUE result = rb_protect((VALUE (*)(VALUE))rb_require,
                              (VALUE)file, &error);

    if (error)
    {
        printf("rb_require('%s') failed with status=%d\n",
               file, error);

        VALUE exception = rb_gv_get("$!");
        if (RTEST(exception))
        {
            printf("... because an exception was raised:\n");
            fflush(stdout);

            VALUE inspect = rb_inspect(exception);
            rb_io_puts(1, &inspect, rb_stderr);

            VALUE backtrace = rb_funcall(
                exception, rb_intern("backtrace"), 0);
            rb_io_puts(1, &backtrace, rb_stderr);
        }
    }

    return result;
}
开发者ID:sunaku,项目名称:ruby-coroutine-example,代码行数:28,代码来源:main.c

示例8: rpmrubyRunThreadFile

static rpmRC rpmrubyRunThreadFile(rpmruby ruby, const char * fn,
		const char **resultp)
{
    int error;
    VALUE result;
    rpmRC rc = RPMRC_FAIL;	/* assume failure */

    result = rb_protect((VALUE (*)(VALUE))rb_require, (VALUE)fn, &error);
    if (error) {
        fprintf(stderr, "rb_require('%s') failed with status=%d\n",
               fn, error);

        VALUE exception = rb_gv_get("$!");
        if (RTEST(exception)) {
            fprintf(stderr, "... because an exception was raised:\n");

            VALUE inspect = rb_inspect(exception);
            rb_io_puts(1, &inspect, rb_stderr);

            VALUE backtrace = rb_funcall(
                exception, rb_intern("backtrace"), 0);
            rb_io_puts(1, &backtrace, rb_stderr);
        }
    } else {
	/* XXX FIXME: check result */
	rc = RPMRC_OK;
    }

    return rc;
}
开发者ID:hahnakane,项目名称:junkcode,代码行数:30,代码来源:rpmruby.c

示例9: GetExceptionInfo

std::string GetExceptionInfo()
{
    VALUE exception = rb_gv_get("$!");
    if (NIL_P(exception))
        return std::string("No exception");

    VALUE klass = rb_funcall(rb_funcall(exception,
                                        rb_intern("class"),
                                        0),
                             rb_intern("to_s"),
                             0);
    VALUE to_s = rb_funcall(exception, rb_intern("to_s"), 0);
    VALUE backtrace = rb_funcall(rb_funcall(exception,
                                            rb_intern("backtrace"),
                                            0),
                                 rb_intern("join"),
                                 1,
                                 rb_str_new2("\n"));
    std::string info;
    info += StringValuePtr(klass);
    info += ": ";
    info += StringValuePtr(to_s);
    info += '\n';
    info += StringValuePtr(backtrace);
    return info;
}
开发者ID:KnIfER,项目名称:armagetron,代码行数:26,代码来源:tRuby.cpp

示例10: ss_rstring_assign_global_foobar

VALUE ss_rstring_assign_global_foobar(VALUE self) {
  VALUE var = rb_gv_get("$global_rstring_test");
  RSTRING(var)->len = 6;
  RSTRING(var)->ptr = ALLOC_N(char, 7);
  memcpy(RSTRING(var)->ptr, "foobar", 7);
  return Qnil;
}
开发者ID:Winstonwzl,项目名称:rubinius,代码行数:7,代码来源:subtend_string.c

示例11: iroffer_ruby_errro

static void iroffer_ruby_errro(int error)
{
  VALUE lasterr;
  VALUE inclass;
  VALUE message;
  VALUE ary;
  long c;

  if (error == 0)
    return;

  lasterr = rb_gv_get("$!"); /* NOTRANSLATE */
  inclass = rb_class_path(CLASS_OF(lasterr));
  message = rb_obj_as_string(lasterr);
  outerror(OUTERROR_TYPE_WARN_LOUD,
           "error ruby_script: class=%s, message=%s",
           RSTRING_PTR(inclass), RSTRING_PTR(message));

  if (!NIL_P(rb_errinfo())) {
    ary = rb_funcall(rb_errinfo(), rb_intern("backtrace"), 0);
    for (c=0; c<RARRAY_LEN(ary); ++c) {
      outerror(OUTERROR_TYPE_WARN_LOUD,
               "backtrace from %s",
               RSTRING_PTR(RARRAY_PTR(ary)[c]));
    }
  }
}
开发者ID:KayDat,项目名称:iroffer-dinoex,代码行数:27,代码来源:dinoex_ruby.c

示例12: InitializeInterpreter

void InitializeInterpreter()
{
    ruby_init();
    VALUE load_path = rb_gv_get("$LOAD_PATH");
    rb_ary_push(load_path, rb_str_new2("."));
    Init_armagetronad();
    ruby_script("Armagetron Advanced");
}
开发者ID:KnIfER,项目名称:armagetron,代码行数:8,代码来源:tRuby.cpp

示例13: LogError

 static void LogError(){
   VALUE lasterr = rb_gv_get("$!");
   VALUE message = rb_obj_as_string(lasterr);
   VALUE array   = rb_funcall(lasterr, rb_intern("backtrace"), 0);
   VALUE backtrace = rb_funcall(array, rb_intern("join"), 1, rb_str_new2("\n\t"));
   std::cout << "\t" << RSTRING_PTR(message) << std::endl;
   std::cout << RSTRING_PTR(backtrace) << std::endl;
 }
开发者ID:hackur,项目名称:bowline-desktop,代码行数:8,代码来源:ruby_utils.cpp

示例14: coverage_event_coverage_hook

static void coverage_event_coverage_hook(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass) {
  char *sourcefile;
  unsigned int sourceline;
  static unsigned int in_hook = 0;
 
  if(in_hook) {
    return;
  }

  in_hook++;

  #if COVERAGE_DEBUG_EVENTS
    do {
      int status;
      VALUE old_exception;
      old_exception = rb_gv_get("$!");
      rb_protect(rb_inspect, klass, &status);
      if(!status) {
        printf("EVENT: %d %s %s %s %d\n", event,
               klass ? RSTRING(rb_inspect(klass))->ptr : "", 
               mid ? (mid == ID_ALLOCATOR ? "ID_ALLOCATOR" : rb_id2name(mid))
               : "unknown",
               node ? node->nd_file : "", node ? nd_line(node) : 0);
      } 
      else {
        printf("EVENT: %d %s %s %d\n", event,
               mid ? (mid == ID_ALLOCATOR ? "ID_ALLOCATOR" : rb_id2name(mid)) 
               : "unknown",
               node ? node->nd_file : "", node ? nd_line(node) : 0);
      }
      
      rb_gv_set("$!", old_exception);
    } while (0); 
  #endif

  if(event & RUBY_EVENT_C_CALL) {
    coverage_mark_caller();
  }
  
  if(event & (RUBY_EVENT_C_CALL | RUBY_EVENT_C_RETURN | RUBY_EVENT_CLASS)) {
    in_hook--;
    return;
  }
  
  if(node == NULL) {
    in_hook--;
      return;
  }
  
  sourcefile = node->nd_file;
  sourceline = nd_line(node) - 1;
  
  coverage_increase_counter_cached(sourcefile, sourceline);
  
  if(event & RUBY_EVENT_CALL)
    coverage_mark_caller();
  in_hook--;
}
开发者ID:CoralineAda,项目名称:rcov,代码行数:58,代码来源:rcovrt.c

示例15: mriBindingExecute

static void mriBindingExecute()
{
	/* Normally only a ruby executable would do a sysinit,
	 * but not doing it will lead to crashes due to closed
	 * stdio streams on some platforms (eg. Windows) */
	int argc = 0;
	char **argv = 0;
	ruby_sysinit(&argc, &argv);

	ruby_setup();
	rb_enc_set_default_external(rb_enc_from_encoding(rb_utf8_encoding()));

	Config &conf = shState->rtData().config;

	if (!conf.rubyLoadpaths.empty())
	{
		/* Setup custom load paths */
		VALUE lpaths = rb_gv_get(":");

		for (size_t i = 0; i < conf.rubyLoadpaths.size(); ++i)
		{
			std::string &path = conf.rubyLoadpaths[i];

			VALUE pathv = rb_str_new(path.c_str(), path.size());
			rb_ary_push(lpaths, pathv);
		}
	}

	RbData rbData;
	shState->setBindingData(&rbData);
	BacktraceData btData;

	mriBindingInit();


	STEAMSHIM_init();
	_rb_define_module_function(rb_mKernel, "_steam_achievement_unlock",
	                           _steamAchievementUnlock);


	std::string &customScript = conf.customScript;
	if (!customScript.empty())
		runCustomScript(customScript);
	else
		runRMXPScripts(btData);

	VALUE exc = rb_errinfo();
	if (!NIL_P(exc) && !rb_obj_is_kind_of(exc, rb_eSystemExit))
		showExc(exc, btData);

	ruby_cleanup(0);


	STEAMSHIM_deinit();


	shState->rtData().rqTermAck.set();
}
开发者ID:Ancurio,项目名称:mkxp-abs,代码行数:58,代码来源:binding-mri.cpp


注:本文中的rb_gv_get函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。