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


C++ rb_id2name函数代码示例

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


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

示例1: mochilo_pack_symbol

void mochilo_pack_symbol(mochilo_buf *buf, VALUE rb_symbol)
{
	long size;
	const char *name;

	name = rb_id2name(SYM2ID(rb_symbol));
	size = strlen(name);

	if (size < 0x100) {
		uint8_t lead = size;
		mochilo_buf_putc(buf, MSGPACK_T_SYM);
		mochilo_buf_putc(buf, lead);
	} else {
		rb_raise(rb_eMochiloPackError,
			"Symbol too long: must be under %d bytes, %ld given", 0x100, size);
	}

	mochilo_buf_put(buf, name, size);
}
开发者ID:adelcambre,项目名称:mochilo,代码行数:19,代码来源:mochilo_pack.c

示例2: to_charptr

const char *
to_charptr(VALUE v)
{
  const char *str;
  if (SYMBOL_P(v)) {
    str = rb_id2name(SYM2ID(v));
  }
  else if (TYPE(v) == T_STRING) {
    str = StringValuePtr(v);
  }
  else if (v == Qnil) {
    str = NULL;
  }
  else {
    VALUE v_s = rb_funcall(v, rb_intern("to_s"), 0 );
    str = StringValuePtr(v_s);
  }
  return str;
}
开发者ID:steakknife,项目名称:ruby-sfcc,代码行数:19,代码来源:sfcc.c

示例3: recval_get_field

static VALUE
recval_get_field(VALUE self)
{
    VALUE obj;
    value_struct_data *data;
    ValueStruct *val;
    char *name = rb_id2name(ruby_frame->last_func);

    Data_Get_Struct(self, value_struct_data, data);

    if (!NIL_P(obj = rb_hash_aref(data->cache, rb_str_new2(name))))
        return obj;

    val = GetRecordItem(data->value, name);
    obj = get_value(val);
    if (CACHEABLE(val))
        rb_hash_aset(data->cache, rb_str_new2(name), obj);
    return obj;
}
开发者ID:ogochan,项目名称:libmondai,代码行数:19,代码来源:ruby.c

示例4: ins_methods_push

static int
ins_methods_push(ID name, long type, VALUE ary, long visi)
{
    if (type == -1) return ST_CONTINUE;
    switch (visi) {
      case NOEX_PRIVATE:
      case NOEX_PROTECTED:
      case NOEX_PUBLIC:
	visi = (type == visi);
	break;
      default:
	visi = (type != NOEX_PRIVATE);
	break;
    }
    if (visi) {
	rb_ary_push(ary, rb_str_new2(rb_id2name(name)));
    }
    return ST_CONTINUE;
}
开发者ID:asimoov,项目名称:emscripted-ruby,代码行数:19,代码来源:class.c

示例5: toolbutton_initialize

static VALUE
toolbutton_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE obj, label;
    GtkToolItem* item;

    rb_scan_args(argc, argv, "02", &obj, &label);

    if (TYPE(obj) == T_SYMBOL){
        item = gtk_tool_button_new_from_stock(rb_id2name(SYM2ID(obj)));
    } else if (TYPE(obj) == T_STRING){
        item = gtk_tool_button_new_from_stock(RVAL2CSTR(obj));
    } else {
        item = gtk_tool_button_new(GTK_WIDGET(RVAL2GOBJ(obj)), 
                                   NIL_P(label) ? NULL : RVAL2CSTR(label));
    }
    RBGTK_INITIALIZE(self, item);
    return Qnil;
}
开发者ID:benolee,项目名称:ruby-gnome2,代码行数:19,代码来源:rbgtktoolbutton.c

示例6: cb_unify_key

    VALUE
cb_unify_key(struct cb_bucket_st *bucket, VALUE key, int apply_prefix)
{
    VALUE ret = Qnil, tmp;

    if (RTEST(bucket->key_prefix_val) && apply_prefix) {
        ret = rb_str_dup(bucket->key_prefix_val);
    }
    switch (TYPE(key)) {
        case T_STRING:
            return NIL_P(ret) ? key : rb_str_concat(ret, key);
        case T_SYMBOL:
            tmp = STR_NEW_CSTR(rb_id2name(SYM2ID(key)));
            return NIL_P(ret) ? tmp : rb_str_concat(ret, tmp);
        default:    /* call #to_str or raise error */
            tmp = StringValue(key);
            return NIL_P(ret) ? tmp : rb_str_concat(ret, tmp);
    }
}
开发者ID:ijokarumawak,项目名称:couchbase-ruby-client,代码行数:19,代码来源:utils.c

示例7: rg_initialize

static VALUE
rg_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE name, label, tooltip, stock_id;
    const gchar *stock = NULL;

    rb_scan_args(argc, argv, "22", &name, &label, &tooltip, &stock_id);

    if (TYPE(stock_id) == T_SYMBOL) {
        stock = rb_id2name(SYM2ID(stock_id));
    } else if (TYPE(stock_id) == T_STRING){
        stock = RVAL2CSTR(stock_id);
    }

    G_INITIALIZE(self, gtk_action_new(RVAL2CSTR(name), RVAL2CSTR(label),
                                      NIL_P(tooltip) ? NULL : RVAL2CSTR(tooltip),
                                      stock));
    return Qnil;
}
开发者ID:Mazwak,项目名称:ruby-gnome2,代码行数:19,代码来源:rbgtkaction.c

示例8: rb_struct_aref_id

static VALUE
rb_struct_aref_id(VALUE s, ID id)
{
    VALUE *ptr, members, *ptr_members;
    long i, len;

    ptr = RSTRUCT_PTR(s);
    members = rb_struct_members(s);
    ptr_members = RARRAY_PTR(members);
    len = RARRAY_LEN(members);
    for (i=0; i<len; i++) {
	if (SYM2ID(ptr_members[i]) == id) {
	    return ptr[i];
	}
    }
    rb_name_error(id, "no member '%s' in struct", rb_id2name(id));

    UNREACHABLE;
}
开发者ID:Danylyuk,项目名称:first_app,代码行数:19,代码来源:struct.c

示例9: gobj_get_property

static VALUE
gobj_get_property(VALUE self, VALUE prop_name)
{
    GParamSpec* pspec;
    const char* name;

    if (SYMBOL_P(prop_name))
        name = rb_id2name(SYM2ID(prop_name));
    else
        name = StringValuePtr(prop_name);

    pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(RVAL2GOBJ(self)),
                                         name);

    if (!pspec)
        rb_raise(eNoPropertyError, "No such property: %s", name);
    else {
        // FIXME: use rb_ensure to call g_value_unset()
        GValueToRValueFunc getter = NULL;
        GValue gval = {0,};
        VALUE ret;

        {
            VALUE table = rb_hash_aref(type_to_prop_getter_table,
                                       INT2FIX(pspec->owner_type));
            if (!NIL_P(table)){
                VALUE obj = rb_hash_aref(table, CSTR2RVAL(g_param_spec_get_name(pspec)));
                if (!NIL_P(obj))
                    Data_Get_Struct(obj, void, getter);
            }
        }

        g_value_init(&gval, G_PARAM_SPEC_VALUE_TYPE(pspec));
        g_object_get_property(RVAL2GOBJ(self), name, &gval);

        ret = getter ? getter(&gval) : GVAL2RVAL(&gval);
        g_value_unset(&gval);

        G_CHILD_SET(self, rb_intern(name), ret);

        return ret;
    }
}
开发者ID:geoffyoungs,项目名称:ruby-gnome2,代码行数:43,代码来源:rbgobj_object.c

示例10: cr_select_font_face

/* Font/Text functions */
static   VALUE
cr_select_font_face (int argc, VALUE *argv, VALUE self)
{
  VALUE rb_family, rb_slant, rb_weight;
  const char *family;
  cairo_font_slant_t slant;
  cairo_font_weight_t weight;

  rb_scan_args(argc, argv, "03", &rb_family, &rb_slant, &rb_weight);

  if (NIL_P (rb_family))
    {
      family = "";
    }
  else if (rb_cairo__is_kind_of (rb_family, rb_cString))
    {
      family = RSTRING_PTR (rb_family);
    }
  else if (rb_cairo__is_kind_of (rb_family, rb_cSymbol))
    {
      family = rb_id2name (SYM2ID (rb_family));
    }
  else
    {
      rb_raise (rb_eArgError,
                "family name should be nil, String or Symbol: %s",
                rb_cairo__inspect (rb_family));
    }

  if (NIL_P (rb_slant))
    slant = CAIRO_FONT_SLANT_NORMAL;
  else
    slant = RVAL2CRFONTSLANT (rb_slant);

  if (NIL_P (rb_weight))
    weight = CAIRO_FONT_WEIGHT_NORMAL;
  else
    weight = RVAL2CRFONTWEIGHT (rb_weight);

  cairo_select_font_face (_SELF, family, slant, weight);
  cr_check_status (_SELF);
  return self;
}
开发者ID:joshuawatson,项目名称:rcairo,代码行数:44,代码来源:rb_cairo_context.c

示例11: error_pos

static void
error_pos(void)
{
    const char *sourcefile = rb_sourcefile();
    int sourceline = rb_sourceline();

    if (sourcefile) {
	if (sourceline == 0) {
	    warn_printf("%s", sourcefile);
	}
	else if (rb_frame_callee()) {
	    warn_printf("%s:%d:in `%s'", sourcefile, sourceline,
			rb_id2name(rb_frame_callee()));
	}
	else {
	    warn_printf("%s:%d", sourcefile, sourceline);
	}
    }
}
开发者ID:AdamDotCom,项目名称:my-rvm,代码行数:19,代码来源:eval_error.c

示例12: c_playback_volume_set

/*
 * call-seq:
 *  xc.playback_volume_set(channel, volume) -> result
 *
 * Sets playback volume for _channel_ to _volume_.
 */
static VALUE
c_playback_volume_set (VALUE self, VALUE channel, VALUE volume)
{
	RbXmmsClient *xmms = NULL;
	xmmsc_result_t *res;

	Data_Get_Struct (self, RbXmmsClient, xmms);

	CHECK_DELETED (xmms);

	Check_Type (channel, T_SYMBOL);
	Check_Type (volume, T_FIXNUM);

	res = xmmsc_playback_volume_set (xmms->real,
	                                 rb_id2name (SYM2ID (channel)),
	                                 NUM2UINT (volume));

	return TO_XMMS_CLIENT_RESULT (self, res);
}
开发者ID:dsheeler,项目名称:xmms2,代码行数:25,代码来源:rb_xmmsclient.c

示例13: specific_eval

static VALUE
specific_eval(int argc, VALUE *argv, VALUE klass, VALUE self)
{
    if (rb_block_given_p()) {
	if (argc > 0) {
	    rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
	}
	return yield_under(klass, self, Qundef);
    }
    else {
	const char *file = "(eval)";
	int line = 1;

//RHO
    rb_raise(rb_eNotImpError, "Not implemented: only eval of block is supported.");
//RHO

	if (argc == 0) {
	    rb_raise(rb_eArgError, "block not supplied");
	}
	else {
	    if (rb_safe_level() >= 4) {
		StringValue(argv[0]);
	    }
	    else {
		SafeStringValue(argv[0]);
	    }
	    if (argc > 3) {
		const char *name = rb_id2name(rb_frame_callee());
		rb_raise(rb_eArgError,
			 "wrong number of arguments: %s(src) or %s{..}",
			 name, name);
	    }
	    if (argc > 2)
		line = NUM2INT(argv[2]);
	    if (argc > 1) {
		file = StringValuePtr(argv[1]);
	    }
	}
	return eval_under(klass, self, argv[0], file, line);
    }
}
开发者ID:3runo5ouza,项目名称:rhodes,代码行数:42,代码来源:vm_eval.c

示例14: rg_initialize

static VALUE
rg_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE stock_id;
    GtkToolItem* item;

    rb_scan_args(argc, argv, "01", &stock_id);

    if (NIL_P(stock_id)){
        item = gtk_toggle_tool_button_new();
    } else {
        if (TYPE(stock_id) == T_SYMBOL){
            item = gtk_toggle_tool_button_new_from_stock(rb_id2name(SYM2ID(stock_id)));
        } else {
            item = gtk_toggle_tool_button_new_from_stock(RVAL2CSTR(stock_id));
        }
    }
    RBGTK_INITIALIZE(self, item);
    return Qnil;
}
开发者ID:msakai,项目名称:ruby-gnome2,代码行数:20,代码来源:rbgtktoggletoolbutton.c

示例15: rsock_revlookup_flag

int
rsock_revlookup_flag(VALUE revlookup, int *norevlookup)
{
#define return_norevlookup(x) {*norevlookup = (x); return 1;}
    ID id;

    switch (revlookup) {
      case Qtrue:  return_norevlookup(0);
      case Qfalse: return_norevlookup(1);
      case Qnil: break;
      default:
	Check_Type(revlookup, T_SYMBOL);
	id = SYM2ID(revlookup);
	if (id == id_numeric) return_norevlookup(1);
	if (id == id_hostname) return_norevlookup(0);
	rb_raise(rb_eArgError, "invalid reverse_lookup flag: :%s", rb_id2name(id));
    }
    return 0;
#undef return_norevlookup
}
开发者ID:SongJungHwan,项目名称:hwan,代码行数:20,代码来源:ipsocket.c


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