• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ rb_str_dup函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: full_name

static VALUE
full_name(VALUE klass, ID mid)
{
    VALUE result = rb_str_dup(klass_name(klass));
    rb_str_cat2(result, "#");
    rb_str_append(result, method_name(mid));

    return result;
}
开发者ID:Angeldude,项目名称:sonic-pi,代码行数:9,代码来源:rp_method.c


示例2: find_file

static VALUE find_file(VALUE fname)
{
    VALUE res = 0;
    int nOK = 0;

    //RAWLOG_INFO1("find_file: fname: %s", RSTRING_PTR(fname));

#ifdef RHODES_EMULATOR
    if ( strncmp(RSTRING_PTR(fname), rho_simconf_getRhodesPath(), strlen(rho_simconf_getRhodesPath())) == 0 )
        res = fname;
    else
#endif

#ifdef OS_WP8
	res = find_file_in_load_paths(fname);

	if (res)
		return res;
	else
#endif
    if ( strncmp(RSTRING_PTR(fname), rho_native_rhopath(), strlen(rho_native_rhopath())) == 0 ){
        res = rb_str_dup(fname);
        rb_str_cat(res,RHO_RB_EXT,strlen(RHO_RB_EXT));
        //RAWLOG_INFO1("find_file: res: %s", RSTRING_PTR(res));
    } else if ( strncmp(RSTRING_PTR(fname), rho_native_reruntimepath(), strlen(rho_native_reruntimepath())) == 0 ){
        res = rb_str_dup(fname);
        rb_str_cat(res,RHO_RB_EXT,strlen(RHO_RB_EXT));
        //RAWLOG_INFO1("find_file: res: %s", RSTRING_PTR(res));
    } else {
		res = find_file_in_load_paths(fname);

        if (res)
        {
			nOK = 1;
		}
    }

    //RAWLOG_INFO1("find_file: RhoPreparePath: %s", RSTRING_PTR(res));
    res = RhoPreparePath(res);
    if ( !nOK )
        nOK = 1;//eaccess(RSTRING_PTR(res), R_OK) == 0 ? 1 : 0;

    return nOK ? res : 0;
}
开发者ID:yura505,项目名称:rhodes,代码行数:44,代码来源:rhosupport.c


示例3: rb_mod_name

VALUE
rb_mod_name(VALUE mod, SEL sel)
{
    VALUE path = classname(mod);

    if (!NIL_P(path)) {
	return rb_str_dup(path);
    }
    return path;
}
开发者ID:kyab,项目名称:MacRuby,代码行数:10,代码来源:variable.c


示例4: Add_catchpoint

/*
 *  call-seq:
 *    Byebug.add_catchpoint(exception) -> exception
 *
 *  Adds a new exception to the catchpoints hash.
 */
static VALUE
Add_catchpoint(VALUE self, VALUE value)
{
  UNUSED(self);

  if (TYPE(value) != T_STRING)
    rb_raise(rb_eTypeError, "value of a catchpoint must be String");

  rb_hash_aset(catchpoints, rb_str_dup(value), INT2FIX(0));
  return value;
}
开发者ID:Alex-Aralis,项目名称:davey-rails-app,代码行数:17,代码来源:byebug.c


示例5: rhash_aset

VALUE
rhash_aset(VALUE hash, SEL sel, VALUE key, VALUE val)
{
    rhash_modify(hash);
    if (TYPE(key) == T_STRING && !OBJ_FROZEN(key)) {
        key = rb_str_dup(key);
        OBJ_FREEZE(key);
    }
    st_insert(RHASH(hash)->tbl, key, val);
    return val;
}
开发者ID:Jaharmi,项目名称:MacRuby,代码行数:11,代码来源:hash.c


示例6: RhoPreparePath

VALUE RhoPreparePath(VALUE path){
#ifdef __SYMBIAN32__

	VALUE fname2 = rb_str_dup(path);
	
	translate_char(RSTRING_PTR(fname2),'/', '\\');
	
	return fname2;
#endif //__SYMBIAN32__
	
	return path;
}
开发者ID:4nkh,项目名称:rhodes,代码行数:12,代码来源:rhosupport.c


示例7: Game_title_eq

static VALUE
Game_title_eq(VALUE self, VALUE rbTitle)
{
  Game* game;
  Data_Get_Struct(self, Game, game);
  CheckDisposed(game);
  Check_Type(rbTitle, T_STRING);
  if (SDL_WasInit(SDL_INIT_VIDEO)) {
    SDL_WM_SetCaption(StringValueCStr(rbTitle), NULL);
  }
  return rb_iv_set(self, "title", rb_str_dup(rbTitle));
}
开发者ID:CaptainJet,项目名称:RM-StarRuby,代码行数:12,代码来源:game.c


示例8: _msgpack_buffer_chunk_as_string

static inline VALUE _msgpack_buffer_chunk_as_string(msgpack_buffer_chunk_t* c)
{
    size_t chunk_size = c->last - c->first;
    if(chunk_size == 0) {
        return rb_str_buf_new(0);
    }

    if(c->mapped_string != NO_MAPPED_STRING) {
        return rb_str_dup(c->mapped_string);
    }

    return rb_str_new(c->first, chunk_size);
}
开发者ID:CodeMonkeySteve,项目名称:msgpack-ruby,代码行数:13,代码来源:buffer.c


示例9: pg_tmir_copy_get

static VALUE
pg_tmir_copy_get( t_typemap *p_typemap, VALUE field_str, int fieldno, int format, int enc_idx )
{
	t_tmir *this = (t_tmir *) p_typemap;
	rb_encoding *p_encoding = rb_enc_from_index(enc_idx);
	VALUE enc = rb_enc_from_encoding(p_encoding);
	/* field_str is reused in-place by pg_text_dec_copy_row(), so we need to make
	 * a copy of the string buffer for use in ruby space. */
	VALUE field_str_copy = rb_str_dup(field_str);
	rb_str_modify(field_str_copy);

	return rb_funcall( this->self, s_id_typecast_copy_get, 4, field_str_copy, INT2NUM(fieldno), INT2NUM(format), enc );
}
开发者ID:13l1236,项目名称:rails-app-for-lesson,代码行数:13,代码来源:pg_type_map_in_ruby.c


示例10: cState_aset

/*
* call-seq: []=(name, value)
*
* Set the attribute name to value.
*/
static VALUE cState_aset(VALUE self, VALUE name, VALUE value)
{
    VALUE name_writer;

    name = rb_funcall(name, i_to_s, 0);
    name_writer = rb_str_cat2(rb_str_dup(name), "=");
    if (RTEST(rb_funcall(self, i_respond_to_p, 1, name_writer))) {
        return rb_funcall(self, i_send, 2, name_writer, value);
    } else {
        rb_ivar_set(self, rb_intern_str(rb_str_concat(rb_str_new2("@"), name)), value);
    }
    return Qnil;
}
开发者ID:Danylyuk,项目名称:first_app,代码行数:18,代码来源:generator.c


示例11: pg_define_coder

void
pg_define_coder( const char *name, void *func, VALUE klass, VALUE nsp )
{
  VALUE type_obj = Data_Wrap_Struct( klass, NULL, NULL, func );
	VALUE objname = rb_str_dup(rb_mod_name(nsp));
	rb_str_cat2( objname, "::");
	rb_str_cat2( objname, name);

  rb_iv_set( type_obj, "@name", rb_obj_freeze(objname) );
  rb_define_const( nsp, name, rb_obj_freeze(type_obj) );

  RB_GC_GUARD(type_obj);
}
开发者ID:willbryant,项目名称:ruby-pg,代码行数:13,代码来源:pg_coder.c


示例12: range_to_s

static VALUE
range_to_s(VALUE range, SEL sel)
{
    VALUE str, str2;

    str = rb_obj_as_string(RANGE_BEG(range));
    str2 = rb_obj_as_string(RANGE_END(range));
    str = rb_str_dup(str);
    rb_str_cat(str, "...", EXCL(range) ? 3 : 2);
    rb_str_append(str, str2);
    OBJ_INFECT(str, str2);

    return str;
}
开发者ID:HumbleRepose,项目名称:MacRuby,代码行数:14,代码来源:range.c


示例13: unix_path

/*
 * call-seq:
 *   unixsocket.path => path
 *
 * Returns the path of the local address of unixsocket.
 *
 *   s = UNIXServer.new("/tmp/sock")
 *   p s.path #=> "/tmp/sock"
 *
 */
static VALUE
unix_path(VALUE sock)
{
    rb_io_t *fptr;

    GetOpenFile(sock, fptr);
    if (NIL_P(fptr->pathv)) {
	struct sockaddr_un addr;
	socklen_t len = (socklen_t)sizeof(addr);
	if (getsockname(fptr->fd, (struct sockaddr*)&addr, &len) < 0)
	    rb_sys_fail(0);
	fptr->pathv = rb_obj_freeze(rb_str_new_cstr(rsock_unixpath(&addr, len)));
    }
    return rb_str_dup(fptr->pathv);
}
开发者ID:AsherBond,项目名称:MondocosmOS-Dependencies,代码行数:25,代码来源:unixsocket.c


示例14: fc_path

static VALUE
fc_path(struct fc_result *fc, ID name)
{
    VALUE path, tmp;

    path = rb_str_dup(rb_id2str(name));
    while (fc) {
	if (fc->track == rb_cObject) break;
	if ((tmp = rb_attr_get(fc->track, id_classpath)) != Qnil) {
	    tmp = rb_str_dup(tmp);
	    rb_str_cat2(tmp, "::");
	    rb_str_append(tmp, path);
	    path = tmp;
	    break;
	}
	tmp = rb_str_dup(rb_id2str(fc->name));
	rb_str_cat2(tmp, "::");
	rb_str_append(tmp, path);
	path = tmp;
	fc = fc->prev;
    }
    OBJ_FREEZE(path);
    return path;
}
开发者ID:kyab,项目名称:MacRuby,代码行数:24,代码来源:variable.c


示例15: rb_trie_read

/*
 * call-seq:
 *   read(filename_base) -> Trie
 *
 * Returns a new trie with data as read from disk.
 */
static VALUE rb_trie_read(VALUE self, VALUE filename_base) {
  VALUE da_filename = rb_str_dup(filename_base);
  rb_str_concat(da_filename, rb_str_new2(".da"));
  StringValue(da_filename);
    
  VALUE tail_filename = rb_str_dup(filename_base);
  rb_str_concat(tail_filename, rb_str_new2(".tail"));
  StringValue(tail_filename);

  Trie *trie = trie_new();

  VALUE obj;
  obj = Data_Wrap_Struct(self, 0, trie_free, trie);

  DArray *old_da = trie->da;
  Tail *old_tail = trie->tail;

  FILE *da_file = fopen(RSTRING_PTR(da_filename), "r");
  if (da_file == NULL)
    raise_ioerror("Error reading .da file.");

  trie->da = da_read(da_file);
  fclose(da_file);

  FILE *tail_file = fopen(RSTRING_PTR(tail_filename), "r");
  if (tail_file == NULL)
    raise_ioerror("Error reading .tail file.");

  trie->tail = tail_read(tail_file);
  fclose(tail_file);

  da_free(old_da);
  tail_free(old_tail);

  return obj;
}
开发者ID:kritik,项目名称:trie,代码行数:42,代码来源:trie.c


示例16: name_err_mesg_to_str

/* :nodoc: */
static VALUE
name_err_mesg_to_str(VALUE obj, SEL sel)
{
    VALUE *ptr, mesg;
    Data_Get_Struct(obj, VALUE, ptr);

    mesg = ptr[0];
    if (NIL_P(mesg)) {
	return Qnil;
    }
    else {
	const char *desc = 0;
	VALUE d = 0, args[3];

	obj = ptr[1];
	switch (TYPE(obj)) {
	  case T_NIL:
	    desc = "nil";
	    break;
	  case T_TRUE:
	    desc = "true";
	    break;
	  case T_FALSE:
	    desc = "false";
	    break;
	  default:
	    d = rb_protect(safe_inspect, obj, NULL);
	    if (NIL_P(d) || RSTRING_LEN(d) > 65) {
		d = rb_any_to_s(obj);
	    }
	    desc = RSTRING_PTR(d);
	    break;
	}
	if (desc && desc[0] != '#') {
	    d = d ? rb_str_dup(d) : rb_str_new2(desc);
	    rb_str_cat2(d, ":");
	    rb_str_cat2(d, rb_obj_classname(obj));
	}
	args[0] = mesg;
	args[1] = ptr[2];
	args[2] = d;
	mesg = rb_f_sprintf(3, args);
    }
    if (OBJ_TAINTED(obj)) {
	OBJ_TAINT(mesg);
    }
    return mesg;
}
开发者ID:1nueve,项目名称:MacRuby,代码行数:49,代码来源:error.c


示例17: rb_set_class_path2

void
rb_set_class_path2(VALUE klass, VALUE under, const char *name, VALUE outer)
{
    VALUE str;

    if (under == rb_cObject) {
	str = rb_str_new2(name);
    }
    else {
	str = rb_str_dup(rb_class_path(under));
	rb_str_cat2(str, "::");
	rb_str_cat2(str, name);
    }
    OBJ_FREEZE(str);
    rb_ivar_set(klass, id_classpath, str);
}
开发者ID:kyab,项目名称:MacRuby,代码行数:16,代码来源:variable.c


示例18: rb_set_class_path_string

void
rb_set_class_path_string(VALUE klass, VALUE under, VALUE name)
{
    VALUE str;

    if (under == rb_cObject) {
	str = rb_str_new_frozen(name);
    }
    else {
	str = rb_str_dup(rb_class_path(under));
	rb_str_cat2(str, "::");
	rb_str_append(str, name);
	OBJ_FREEZE(str);
    }
    rb_ivar_set(klass, classpath, str);
}
开发者ID:alexanderblair,项目名称:Gemdata,代码行数:16,代码来源:variable.c


示例19: name_err_mesg_to_str

/* :nodoc: */
static VALUE
name_err_mesg_to_str(VALUE obj)
{
    VALUE *ptr, mesg;
    TypedData_Get_Struct(obj, VALUE, &name_err_mesg_data_type, ptr);

    mesg = ptr[0];
    if (NIL_P(mesg)) return Qnil;
    else {
	const char *desc = 0;
	VALUE d = 0, args[NAME_ERR_MESG_COUNT];
	int state = 0;

	obj = ptr[1];
	switch (obj) {
	  case Qnil:
	    desc = "nil";
	    break;
	  case Qtrue:
	    desc = "true";
	    break;
	  case Qfalse:
	    desc = "false";
	    break;
	  default:
	    d = rb_protect(rb_inspect, obj, &state);
	    if (state)
		rb_set_errinfo(Qnil);
	    if (NIL_P(d) || RSTRING_LEN(d) > 65) {
		d = rb_any_to_s(obj);
	    }
	    desc = RSTRING_PTR(d);
	    break;
	}
	if (desc && desc[0] != '#') {
	    d = d ? rb_str_dup(d) : rb_str_new2(desc);
	    rb_str_cat2(d, ":");
	    rb_str_append(d, rb_class_name(CLASS_OF(obj)));
	}
	args[0] = mesg;
	args[1] = ptr[2];
	args[2] = d;
	mesg = rb_f_sprintf(NAME_ERR_MESG_COUNT, args);
    }
    return mesg;
}
开发者ID:knugie,项目名称:ruby,代码行数:47,代码来源:error.c


示例20: inspect_range

static VALUE
inspect_range(VALUE range, VALUE dummy, int recur)
{
    VALUE str, str2;

    if (recur) {
	return rb_str_new2(EXCL(range) ? "(... ... ...)" : "(... .. ...)");
    }
    str = rb_inspect(RANGE_BEG(range));
    str2 = rb_inspect(RANGE_END(range));
    str = rb_str_dup(str);
    rb_str_cat(str, "...", EXCL(range) ? 3 : 2);
    rb_str_append(str, str2);
    OBJ_INFECT(str, str2);

    return str;
}
开发者ID:HumbleRepose,项目名称:MacRuby,代码行数:17,代码来源:range.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ rb_str_export_to_enc函数代码示例发布时间:2022-05-30
下一篇:
C++ rb_str_concat函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap