本文整理汇总了C++中rb_id2name函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_id2name函数的具体用法?C++ rb_id2name怎么用?C++ rb_id2name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_id2name函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: rb_struct_set
static VALUE
rb_struct_set(VALUE obj, VALUE val)
{
VALUE members, slot;
ID id;
long i;
members = rb_struct_members(obj);
rb_struct_modify(obj);
id = ruby_frame->orig_func;
for (i=0; i<RARRAY(members)->len; i++) {
slot = RARRAY(members)->ptr[i];
if (rb_id_attrset(SYM2ID(slot)) == id) {
return RSTRUCT(obj)->ptr[i] = val;
}
}
rb_name_error(ruby_frame->last_func, "`%s' is not a struct member",
rb_id2name(id));
return Qnil; /* not reached */
}
开发者ID:asimoov,项目名称:emscripted-ruby,代码行数:20,代码来源:struct.c
示例17: extract_change_type_from_notification
static VALUE
extract_change_type_from_notification(const PFILE_NOTIFY_INFORMATION info) {
ID type;
switch(info->Action) {
case FILE_ACTION_ADDED: type = wdm_rb_sym_added; break;
case FILE_ACTION_REMOVED: type = wdm_rb_sym_removed; break;
case FILE_ACTION_MODIFIED: type = wdm_rb_sym_modified; break;
case FILE_ACTION_RENAMED_OLD_NAME: type = wdm_rb_sym_renamed_old_file; break;
case FILE_ACTION_RENAMED_NEW_NAME: type = wdm_rb_sym_renamed_new_file; break;
default:
rb_raise(eWDM_Error, "Unknown change happened to a file in a watched directory!");
}
#if WDM_DEBUG_ENABLED // Used to avoid the func call when in release mode
WDM_DEBUG("change type: '%s'", rb_id2name(type));
#endif
return ID2SYM(type);
}
开发者ID:jarmo,项目名称:wdm,代码行数:20,代码来源:rb_change.c
示例18: rb_mouse_rotate
/*
* Perform a rotation gesture in the given `direction` the given `angle` degrees
*
* Possible directions are:
*
* - `:cw`, ':clockwise`, ':clock_wise` to rotate in the clockwise
* direction
* - `:ccw`, ':counter_clockwise`, `:counter_clock_wise` to rotate in
* the the counter clockwise direction
*
* The `angle` parameter is a number of degrees to rotate. There are 360
* degrees in a full rotation, as you would expect in Euclidian geometry.
*
* You can also optionally specify a point on screen for the mouse
* pointer to be moved to before the gesture begins. The movement will
* be instantaneous. Default `point` is {#current_position}.
*
* An animation duration can also be specified. The default is 0.2 seconds.
*
* @overload rotate(direction, angle)
* @param direction [Symbol]
* @param angle [Float]
* @return [CGPoint]
* @overload rotate(direction, angle, point)
* @param direction [Symbol]
* @param angle [Float]
* @param point [CGPoint]
* @return [CGPoint]
* @overload rotate(direction, angle, point, duration)
* @param direction [Symbol]
* @param angle [Float]
* @param point [CGPoint]
* @param duration [Float]
* @return [CGPoint]
*/
static
VALUE
rb_mouse_rotate(const int argc, VALUE* const argv, UNUSED const VALUE self)
{
if (argc < 2)
rb_raise(rb_eArgError, "wrong number of arguments (%d for 2+)", argc);
const VALUE input_dir = argv[0];
CGRotateDirection direction = kCGRotateNone;
if (input_dir == sym_cw ||
input_dir == sym_clockwise ||
input_dir == sym_clock_wise)
direction = kCGRotateClockwise;
else if (input_dir == sym_ccw ||
input_dir == sym_counter_clockwise ||
input_dir == sym_counter_clock_wise)
direction = kCGRotateCounterClockwise;
else
rb_raise(rb_eArgError,
"invalid rotation direction `%s'",
rb_id2name(SYM2ID(input_dir)));
const double angle = NUM2DBL(argv[1]);
if (argc == 2) {
mouse_rotate(direction, angle);
return CURRENT_POSITION;
}
const CGPoint point = rb_mouse_unwrap_point(argv[2]);
if (argc == 3) {
mouse_rotate2(direction, angle, point);
return CURRENT_POSITION;
}
mouse_rotate3(direction, angle, point, NUM2DBL(argv[3]));
return CURRENT_POSITION;
}
开发者ID:AXElements,项目名称:mouse,代码行数:76,代码来源:mouse.c
示例19: rb_f_local_variables
static VALUE
rb_f_local_variables(void)
{
VALUE ary = rb_ary_new();
rb_thread_t *th = GET_THREAD();
rb_control_frame_t *cfp =
vm_get_ruby_level_caller_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp));
int i;
while (cfp) {
if (cfp->iseq) {
for (i = 0; i < cfp->iseq->local_table_size; i++) {
ID lid = cfp->iseq->local_table[i];
if (lid) {
const char *vname = rb_id2name(lid);
/* should skip temporary variable */
if (vname) {
rb_ary_push(ary, ID2SYM(lid));
}
}
}
}
if (cfp->lfp != cfp->dfp) {
/* block */
VALUE *dfp = GC_GUARDED_PTR_REF(cfp->dfp[0]);
if (vm_collect_local_variables_in_heap(th, dfp, ary)) {
break;
}
else {
while (cfp->dfp != dfp) {
cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
}
}
}
else {
break;
}
}
return ary;
}
开发者ID:3runo5ouza,项目名称:rhodes,代码行数:41,代码来源:vm_eval.c
示例20: rg_m_source_set_icon
static VALUE
rg_m_source_set_icon(int argc, VALUE *argv, VALUE self)
{
VALUE widget, obj, pixmap = Qnil, mask = Qnil;
rb_scan_args(argc, argv, "22", &widget, &obj, &pixmap, &mask);
if (argc == 4){
gtk_drag_source_set_icon(RVAL2WIDGET(widget), GDK_COLORMAP(RVAL2GOBJ(obj)),
GDK_PIXMAP(RVAL2GOBJ(pixmap)),
GDK_BITMAP(RVAL2GOBJ(mask)));
} else if (argc == 2){
if (TYPE(obj) == T_SYMBOL){
gtk_drag_source_set_icon_stock(RVAL2WIDGET(widget), rb_id2name(SYM2ID(obj)));
} else {
gtk_drag_source_set_icon_pixbuf(RVAL2WIDGET(widget), GDK_PIXBUF(RVAL2GOBJ(obj)));
}
} else {
rb_raise(rb_eArgError, "need 2 or 4 arguments");
}
return self;
}
开发者ID:Vasfed,项目名称:ruby-gnome2,代码行数:21,代码来源:rbgtkdrag.c
注:本文中的rb_id2name函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论