本文整理汇总了C++中rb_str_dup函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_str_dup函数的具体用法?C++ rb_str_dup怎么用?C++ rb_str_dup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_str_dup函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
示例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);
}
示例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 );
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}