本文整理汇总了C++中rb_attr_get函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_attr_get函数的具体用法?C++ rb_attr_get怎么用?C++ rb_attr_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_attr_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exc_to_s
static VALUE
exc_to_s(VALUE exc)
{
VALUE mesg = rb_attr_get(exc, rb_intern("mesg"));
if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc));
return rb_String(mesg);
}
示例2: exit_success_p
static VALUE
exit_success_p(VALUE exc)
{
VALUE status = rb_attr_get(exc, rb_intern("status"));
if (NIL_P(status)) return Qtrue;
if (status == INT2FIX(EXIT_SUCCESS)) return Qtrue;
return Qfalse;
}
示例3: exc_backtrace
static VALUE
exc_backtrace(VALUE exc)
{
ID bt;
CONST_ID(bt, "bt");
return rb_attr_get(exc, bt);
}
示例4: exc_backtrace
static VALUE
exc_backtrace(VALUE exc, SEL sel)
{
static ID bt;
if (!bt) bt = rb_intern("bt");
return rb_attr_get(exc, bt);
}
示例5: exc_to_s
static VALUE
exc_to_s(VALUE exc)
{
VALUE mesg = rb_attr_get(exc, rb_intern("mesg"));
if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc));
if (OBJ_TAINTED(exc)) OBJ_TAINT(mesg);
return mesg;
}
示例6: name_err_to_s
static VALUE
name_err_to_s(VALUE exc)
{
VALUE mesg = rb_attr_get(exc, rb_intern("mesg"));
VALUE str = mesg;
if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc));
StringValue(str);
return str;
}
示例7: exc_to_s
static VALUE
exc_to_s(VALUE exc)
{
VALUE mesg = rb_attr_get(exc, rb_intern("mesg"));
VALUE r = Qnil;
if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc));
r = rb_String(mesg);
OBJ_INFECT(r, exc);
return r;
}
示例8: exc_backtrace_locations
/*
* call-seq:
* exception.backtrace_locations -> array
*
* Returns any backtrace associated with the exception. This method is
* similar to Exception#backtrace, but the backtrace is an array of
* Thread::Backtrace::Location.
*
* Now, this method is not affected by Exception#set_backtrace().
*/
static VALUE
exc_backtrace_locations(VALUE exc)
{
VALUE obj;
obj = rb_attr_get(exc, id_bt_locations);
if (!NIL_P(obj)) {
obj = rb_backtrace_to_location_ary(obj);
}
return obj;
}
示例9: rb_mod_included_modules_nosuper
static void
rb_mod_included_modules_nosuper(VALUE mod, VALUE ary)
{
VALUE inc_mods = rb_attr_get(mod, idIncludedModules);
if (inc_mods != Qnil) {
int i, count = RARRAY_LEN(inc_mods);
for (i = 0; i < count; i++) {
VALUE imod = RARRAY_AT(inc_mods, i);
rb_ary_push(ary, imod);
}
}
}
示例10: lazy_drop_while_func
static VALUE
lazy_drop_while_func(VALUE val, VALUE args, int argc, VALUE *argv)
{
VALUE memo = rb_attr_get(argv[0], id_memo);
if (NIL_P(memo) && !RTEST(rb_yield_values2(argc - 1, &argv[1]))) {
rb_ivar_set(argv[0], id_memo, memo = Qtrue);
}
if (memo == Qtrue) {
rb_funcall2(argv[0], id_yield, argc - 1, argv + 1);
}
return Qnil;
}
示例11: append_method
static VALUE
append_method(VALUE obj, VALUE str, ID default_method, VALUE default_args)
{
VALUE method, eargs;
method = rb_attr_get(obj, id_method);
if (method != Qfalse) {
ID mid = default_method;
if (!NIL_P(method)) {
Check_Type(method, T_SYMBOL);
mid = SYM2ID(method);
}
rb_str_buf_cat2(str, ":");
rb_str_buf_append(str, rb_id2str(mid));
}
eargs = rb_attr_get(obj, id_arguments);
if (NIL_P(eargs)) {
eargs = default_args;
}
if (eargs != Qfalse) {
long argc = RARRAY_LEN(eargs);
VALUE *argv = RARRAY_PTR(eargs);
if (argc > 0) {
rb_str_buf_cat2(str, "(");
while (argc--) {
VALUE arg = *argv++;
rb_str_append(str, rb_inspect(arg));
rb_str_buf_cat2(str, argc > 0 ? ", " : ")");
OBJ_INFECT(str, arg);
}
}
}
return str;
}
示例12: name_err_to_s
static VALUE
name_err_to_s(VALUE exc)
{
VALUE mesg = rb_attr_get(exc, rb_intern("mesg")), str = mesg;
if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc));
StringValue(str);
if (str != mesg) {
rb_iv_set(exc, "mesg", mesg = str);
}
if (OBJ_TAINTED(exc)) OBJ_TAINT(mesg);
return mesg;
}
示例13: exc_backtrace_locations
/*
* call-seq:
* exception.backtrace_locations -> array
*
* Returns any backtrace associated with the exception. This method is
* similar to Exception#backtrace, but the backtrace is an array of
* Thread::Backtrace::Location.
*
* Now, this method is not affected by Exception#set_backtrace().
*/
static VALUE
exc_backtrace_locations(VALUE exc)
{
ID bt_locations;
VALUE obj;
CONST_ID(bt_locations, "bt_locations");
obj = rb_attr_get(exc, bt_locations);
if (!NIL_P(obj)) {
obj = rb_backtrace_to_location_ary(obj);
}
return obj;
}
示例14: rb_mod_ancestors_nocopy
VALUE
rb_mod_ancestors_nocopy(VALUE mod)
{
VALUE ary = rb_attr_get(mod, idAncestors);
if (NIL_P(ary)) {
ary = rb_ary_new();
for (VALUE p = mod; p != 0; p = RCLASS_SUPER(p)) {
rb_ary_push(ary, p);
rb_mod_included_modules_nosuper(p, ary);
}
rb_ivar_set(mod, idAncestors, ary);
}
return ary;
}
示例15: exit_success_p
static VALUE
exit_success_p(VALUE exc)
{
VALUE status_val = rb_attr_get(exc, rb_intern("status"));
int status;
if (NIL_P(status_val))
return Qtrue;
status = NUM2INT(status_val);
if (WIFEXITED(status) && WEXITSTATUS(status) == EXIT_SUCCESS)
return Qtrue;
return Qfalse;
}