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


C++ rb_str_new_cstr函数代码示例

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


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

示例1: string_spec_rb_str_new_cstr

VALUE string_spec_rb_str_new_cstr(VALUE self, VALUE str) {
  if(NIL_P(str)) {
    return rb_str_new_cstr(NULL);
  } else {
    return rb_str_new_cstr(RSTRING_PTR(str));
  }
}
开发者ID:jeremyz,项目名称:rubinius,代码行数:7,代码来源:string_spec.c

示例2: symbol_new

static VALUE symbol_new(bfd * abfd, asymbol *s, char is_dynamic) {
	symbol_info info;
	VALUE class, instance;
	VALUE argv[1] = { Qnil };

	class = rb_class_new(clsSymbol);
	instance = Data_Wrap_Struct(class, NULL, NULL, s);
	rb_obj_call_init(instance, 0, argv);

	bfd_symbol_info(s, &info);

	/* set instance variables */
	rb_iv_set(instance, IVAR(SYM_ATTR_NAME), rb_str_new_cstr(info.name) );
	rb_iv_set(instance, IVAR(SYM_ATTR_TYPE), INT2NUM((int) info.type) );
	rb_iv_set(instance, IVAR(SYM_ATTR_VALUE), SIZET2NUM(info.value) );
	rb_iv_set(instance, IVAR(SYM_ATTR_FLAGS), INT2NUM(s->flags) );
	rb_iv_set(instance, IVAR(SYM_ATTR_BIND), 
		  rb_str_new_cstr( (is_dynamic ? SYM_BIND_DYNAMIC : 
				  		 SYM_BIND_STATIC) ) );
	if ( s->section ) {
		rb_iv_set(instance, IVAR(SYM_ATTR_SECTION), 
			  rb_str_new_cstr(s->section->name)); 
	}

	return instance;
}
开发者ID:hexgolems,项目名称:opdis-ruby,代码行数:26,代码来源:BFD.c

示例3: arg_string_literal_serialize

static VALUE
arg_string_literal_serialize(void* data)
{
    rb_tracelog_arg_string_literal_t *arg = (rb_tracelog_arg_string_literal_t*)data;
    VALUE key = rb_str_new_cstr(arg->key);
    VALUE val = rb_str_new_cstr(arg->val);

    VALUE args = rb_hash_new();
    rb_hash_aset(args, key, val);
    return args;
}
开发者ID:nyaxt,项目名称:tracejson,代码行数:11,代码来源:tracelog.c

示例4: showExc

static void showExc(VALUE exc)
{
	VALUE bt = rb_funcall2(exc, rb_intern("backtrace"), 0, NULL);
	VALUE bt0 = rb_ary_entry(bt, 0);
	VALUE name = rb_class_path(rb_obj_class(exc));

	VALUE ds = rb_sprintf("%" PRIsVALUE ": %" PRIsVALUE " (%" PRIsVALUE ")",
	                      bt0, exc, name);
	/* omit "useless" last entry (from ruby:1:in `eval') */
	for (long i = 1, btlen = RARRAY_LEN(bt) - 1; i < btlen; ++i)
		rb_str_catf(ds, "\n\tfrom %" PRIsVALUE, rb_ary_entry(bt, i));
	Debug() << StringValueCStr(ds);

	ID id_index = rb_intern("index");
	/* an "offset" argument is not needed for the first time */
	VALUE argv[2] = { rb_str_new_cstr(":") };
	long filelen = NUM2LONG(rb_funcall2(bt0, id_index, 1, argv));
	argv[1] = LONG2NUM(filelen + 1);
	VALUE tmp = rb_funcall2(bt0, id_index, ARRAY_SIZE(argv), argv);
	long linelen = NUM2LONG(tmp) - filelen - 1;
	VALUE file = rb_str_subseq(bt0, 0, filelen);
	VALUE line = rb_str_subseq(bt0, filelen + 1, linelen);
	VALUE ms = rb_sprintf("Script '%" PRIsVALUE "' line %" PRIsVALUE
	                      ": %" PRIsVALUE " occured.\n\n%" PRIsVALUE,
	                      file, line, name, exc);
	showMsg(StringValueCStr(ms));
}
开发者ID:BlackLotus,项目名称:mkxp,代码行数:27,代码来源:binding-mri.cpp

示例5: grpc_rb_call_credentials_callback_with_gil

static void grpc_rb_call_credentials_callback_with_gil(void* param) {
  callback_params* const params = (callback_params*)param;
  VALUE auth_uri = rb_str_new_cstr(params->context.service_url);
  /* Pass the arguments to the proc in a hash, which currently only has they key
     'auth_uri' */
  VALUE callback_args = rb_ary_new();
  VALUE args = rb_hash_new();
  VALUE result;
  grpc_metadata_array md_ary;
  grpc_status_code status;
  VALUE details;
  char* error_details;
  grpc_metadata_array_init(&md_ary);
  rb_hash_aset(args, ID2SYM(rb_intern("jwt_aud_uri")), auth_uri);
  rb_ary_push(callback_args, params->get_metadata);
  rb_ary_push(callback_args, args);
  result = rb_rescue(grpc_rb_call_credentials_callback, callback_args,
                     grpc_rb_call_credentials_callback_rescue, Qnil);
  // Both callbacks return a hash, so result should be a hash
  grpc_rb_md_ary_convert(rb_hash_aref(result, rb_str_new2("metadata")),
                         &md_ary);
  status = NUM2INT(rb_hash_aref(result, rb_str_new2("status")));
  details = rb_hash_aref(result, rb_str_new2("details"));
  error_details = StringValueCStr(details);
  params->callback(params->user_data, md_ary.metadata, md_ary.count, status,
                   error_details);
  grpc_rb_metadata_array_destroy_including_entries(&md_ary);
  gpr_free(params);
}
开发者ID:CCNITSilchar,项目名称:grpc,代码行数:29,代码来源:rb_call_credentials.c

示例6: zval_to_hash

VALUE zval_to_hash(zval *zv) {
  HashTable *ht;
  HashPosition pos;
  zval **data;
  VALUE ret;

  convert_to_array(zv);
  ht = Z_ARRVAL_P(zv);

  ret = rb_hash_new();

    zend_hash_internal_pointer_reset_ex(ht, &pos);
    while (zend_hash_get_current_data_ex(ht, (void **)&data, &pos) == SUCCESS) {
        char* key_str;
        uint key_len;
        ulong num_index;
        VALUE key = Qnil;
        VALUE val = new_php_embed_value(*data);

        switch(zend_hash_get_current_key_ex(ht, &key_str, &key_len, &num_index, 0, &pos)) {
            case HASH_KEY_IS_STRING:
                //key = rb_str_new(key_str, key_len);
                key = rb_str_new_cstr(key_str);
                break;
            case HASH_KEY_IS_LONG:
                key = LONG2NUM(num_index);
                break;
        }

        rb_hash_aset(ret, key, val);
        zend_hash_move_forward_ex(ht, &pos);
    }
    return ret;
}
开发者ID:Epictetus,项目名称:php_embed,代码行数:34,代码来源:convert.c

示例7: test_num2ull

static VALUE
test_num2ull(VALUE obj, VALUE num)
{
    char buf[128];
    sprintf(buf, "%"PRI_LL_PREFIX"u", NUM2ULL(num));
    return rb_str_new_cstr(buf);
}
开发者ID:0x00evil,项目名称:ruby,代码行数:7,代码来源:num2int.c

示例8: test_num2int

static VALUE
test_num2int(VALUE obj, VALUE num)
{
    char buf[128];
    sprintf(buf, "%d", NUM2INT(num));
    return rb_str_new_cstr(buf);
}
开发者ID:0x00evil,项目名称:ruby,代码行数:7,代码来源:num2int.c

示例9: test_num2ulong

static VALUE
test_num2ulong(VALUE obj, VALUE num)
{
    char buf[128];
    sprintf(buf, "%lu", NUM2ULONG(num));
    return rb_str_new_cstr(buf);
}
开发者ID:0x00evil,项目名称:ruby,代码行数:7,代码来源:num2int.c

示例10: ossl_make_error

/*
 * Errors
 */
static VALUE
ossl_make_error(VALUE exc, const char *fmt, va_list args)
{
    VALUE str = Qnil;
    unsigned long e;

    if (fmt) {
	str = rb_vsprintf(fmt, args);
    }
    e = ERR_peek_last_error();
    if (e) {
	const char *msg = ERR_reason_error_string(e);

	if (NIL_P(str)) {
	    if (msg) str = rb_str_new_cstr(msg);
	}
	else {
	    if (RSTRING_LEN(str)) rb_str_cat2(str, ": ");
	    rb_str_cat2(str, msg ? msg : "(null)");
	}
	ossl_clear_error();
    }

    if (NIL_P(str)) str = rb_str_new(0, 0);
    return rb_exc_new3(exc, str);
}
开发者ID:dennyc,项目名称:openssl,代码行数:29,代码来源:ossl.c

示例11: xopenssl_md5

VALUE xopenssl_md5(VALUE self, VALUE str) {
  // We need to copy to a native string as we can't pass Ruby strings into native at the moment

  size_t str_len = RSTRING_LEN(str);
  char *str_ptr = RSTRING_PTR(str);

  unsigned char *native_str = alloca(str_len + 1);

  for (int n = 0; n < str_len; n++) {
    native_str[n] = str_ptr[n];
  }

  native_str[str_len] = '\0';

  unsigned char digest[MD5_DIGEST_LENGTH];

  MD5(native_str, str_len, digest);

  char *hex = alloca(MD5_DIGEST_LENGTH * 2 + 1);

  char *hex_ptr = hex;

  for (int n = 0; n < MD5_DIGEST_LENGTH; n++){
    hex_ptr += sprintf(hex_ptr, "%02x", digest[n]);
  }

  *hex_ptr = '\0';

  return rb_str_new_cstr(hex);
}
开发者ID:coderhs,项目名称:jruby,代码行数:30,代码来源:xopenssl.c

示例12: proxenet_ruby_load_file

int proxenet_ruby_load_file(plugin_t* plugin)
{
	char* filename;
	char* pathname;
	int res = 0;

        if(plugin->state != INACTIVE){
#ifdef DEBUG
                if(cfg->verbose > 2)
                        xlog(LOG_DEBUG, "Plugin '%s' is already loaded. Skipping...\n", plugin->name);
#endif
                return 0;
        }

	filename = plugin->filename;
        pathname = plugin->fullpath;

	rb_load_protect(rb_str_new_cstr(pathname), 0, &res);
	if (res != 0) {
		xlog(LOG_ERROR, "[Ruby] Error %d when load file '%s'\n", res, pathname);
		return -1;
	}

#ifdef DEBUG
	xlog(LOG_DEBUG, "%s\n", pathname);
#endif
	return 0;
}
开发者ID:thorgul,项目名称:proxenet,代码行数:28,代码来源:plugin-ruby.c

示例13: test_fix2short

static VALUE
test_fix2short(VALUE obj, VALUE num)
{
    char buf[128];
    sprintf(buf, "%d", FIX2SHORT(num));
    return rb_str_new_cstr(buf);
}
开发者ID:0x00evil,项目名称:ruby,代码行数:7,代码来源:num2int.c

示例14: test_fix2uint

static VALUE
test_fix2uint(VALUE obj, VALUE num)
{
    char buf[128];
    sprintf(buf, "%u", FIX2UINT(num));
    return rb_str_new_cstr(buf);
}
开发者ID:0x00evil,项目名称:ruby,代码行数:7,代码来源:num2int.c

示例15: rd_die_source_files

static VALUE rd_die_source_files(VALUE self)
{
    rd_die_t *die = GetDie(self);
    Dwarf_Signed cnt = 0;
    char **srcfiles = 0;
    Dwarf_Error err;
    VALUE files = Qnil;

    if (die->srcfiles != Qfalse) {
        return die->srcfiles;
    }

    if (chkerr2(dwarf_srcfiles(die->die, &srcfiles, &cnt, &err), &err)) {
        int i;

        files = rb_ary_new_capa(cnt);
        for (i = 0; i < cnt; i++) {
            VALUE file = rb_str_new_cstr(srcfiles[i]);
            OBJ_FREEZE(file);
            rb_ary_store(files, i, file);
            dwarf_dealloc(die->shared_data->dbg, srcfiles[i], DW_DLA_STRING);
        }
        dwarf_dealloc(die->shared_data->dbg, srcfiles, DW_DLA_LIST);
    }
    die->srcfiles = files;
    return files;
}
开发者ID:kubo,项目名称:rdwarf,代码行数:27,代码来源:rdwarf.c


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