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

C++ RB_TYPE_P函数代码示例

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

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



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

示例1: get_array

static VALUE
get_array(VALUE obj, int idx)
{
    VALUE ary = RSTRUCT_GET(obj, idx);
    if (!RB_TYPE_P(ary, T_ARRAY)) {
	rb_raise(rb_eTypeError, "%+"PRIsVALUE" not initialized", obj);
    }
    return ary;
}
开发者ID:hayaken8112,项目名称:.emacs.d,代码行数:9,代码来源:thread_sync.c


示例2: f_signbit

inline static VALUE
f_signbit(VALUE x)
{
    if (RB_TYPE_P(x, T_FLOAT)) {
	double f = RFLOAT_VALUE(x);
	return f_boolcast(!isnan(f) && signbit(f));
    }
    return f_negative_p(x);
}
开发者ID:0x00evil,项目名称:ruby,代码行数:9,代码来源:complex.c


示例3: rb_print_undef

void
rb_print_undef(VALUE klass, ID id, int scope)
{
    const char *v = method_scope_name(scope);
    rb_name_error(id, "undefined%s method `%"PRIsVALUE"' for %s `% "PRIsVALUE"'", v,
		  QUOTE_ID(id),
		  (RB_TYPE_P(klass, T_MODULE)) ? "module" : "class",
		  rb_class_name(klass));
}
开发者ID:DashYang,项目名称:sim,代码行数:9,代码来源:eval_error.c


示例4: get_strpath

static VALUE
get_strpath(VALUE obj)
{
    VALUE strpath;
    strpath = rb_ivar_get(obj, id_at_path);
    if (!RB_TYPE_P(strpath, T_STRING))
        rb_raise(rb_eTypeError, "unexpected @path");
    return strpath;
}
开发者ID:takuto-h,项目名称:ruby,代码行数:9,代码来源:pathname.c


示例5: rb_typeddata_is_kind_of

int
rb_typeddata_is_kind_of(VALUE obj, const rb_data_type_t *data_type)
{
    if (!RB_TYPE_P(obj, T_DATA) ||
	!RTYPEDDATA_P(obj) || !rb_typeddata_inherited_p(RTYPEDDATA_TYPE(obj), data_type)) {
	return 0;
    }
    return 1;
}
开发者ID:jasonrclark,项目名称:gdb_a_gentle_intro,代码行数:9,代码来源:error.c


示例6: f_one_p

inline static VALUE
f_one_p(VALUE x)
{
    if (RB_TYPE_P(x, T_FIXNUM)) {
	return f_boolcast(FIX2LONG(x) == 1);
    }
    else if (RB_TYPE_P(x, T_BIGNUM)) {
	return Qfalse;
    }
    else if (RB_TYPE_P(x, T_RATIONAL)) {
	VALUE num = RRATIONAL(x)->num;
	VALUE den = RRATIONAL(x)->den;

	return f_boolcast(FIXNUM_P(num) && FIX2LONG(num) == 1 &&
			  FIXNUM_P(den) && FIX2LONG(den) == 1);
    }
    return rb_funcall(x, id_eqeq_p, 1, ONE);
}
开发者ID:0x00evil,项目名称:ruby,代码行数:18,代码来源:complex.c


示例7: ruby__sfvextra

static const char *
ruby__sfvextra(rb_printf_buffer *fp, size_t valsize, void *valp, long *sz, int sign)
{
    VALUE value, result = (VALUE)fp->_bf._base;
    rb_encoding *enc;
    char *cp;

    if (valsize != sizeof(VALUE)) return 0;
    value = *(VALUE *)valp;
    if (RBASIC(result)->klass) {
	rb_raise(rb_eRuntimeError, "rb_vsprintf reentered");
    }
    if (sign == '+') {
	if (RB_TYPE_P(value, T_CLASS)) {
# define LITERAL(str) (*sz = rb_strlen_lit(str), str)

	    if (value == rb_cNilClass) {
		return LITERAL("nil");
	    }
	    else if (value == rb_cFixnum) {
		return LITERAL("Fixnum");
	    }
	    else if (value == rb_cSymbol) {
		return LITERAL("Symbol");
	    }
	    else if (value == rb_cTrueClass) {
		return LITERAL("true");
	    }
	    else if (value == rb_cFalseClass) {
		return LITERAL("false");
	    }
# undef LITERAL
	}
	value = rb_inspect(value);
    }
    else {
	value = rb_obj_as_string(value);
	if (sign == ' ') value = QUOTE(value);
    }
    enc = rb_enc_compatible(result, value);
    if (enc) {
	rb_enc_associate(result, enc);
    }
    else {
	enc = rb_enc_get(result);
	value = rb_str_conv_enc_opts(value, rb_enc_get(value), enc,
				     ECONV_UNDEF_REPLACE|ECONV_INVALID_REPLACE,
				     Qnil);
	*(volatile VALUE *)valp = value;
    }
    StringValueCStr(value);
    RSTRING_GETMEM(value, cp, *sz);
    ((rb_printf_buffer_extra *)fp)->value = value;
    OBJ_INFECT(result, value);
    return cp;
}
开发者ID:nhinze,项目名称:rhodes,代码行数:56,代码来源:sprintf.c


示例8: num_members

static long
num_members(VALUE klass)
{
    VALUE members;
    members = struct_ivar_get(klass, id_members);
    if (!RB_TYPE_P(members, T_ARRAY)) {
	rb_raise(rb_eTypeError, "broken members");
    }
    return RARRAY_LEN(members);
}
开发者ID:Chatto,项目名称:VGdesk,代码行数:10,代码来源:struct.c


示例9: rb_print_inaccessible

void
rb_print_inaccessible(VALUE klass, ID id, int scope)
{
    const char *v = method_scope_name(scope);
    rb_name_error(id, "method `%"PRIsVALUE"' for %s `% "PRIsVALUE"' is %s",
		  QUOTE_ID(id),
		  (RB_TYPE_P(klass, T_MODULE)) ? "module" : "class",
		  rb_class_name(klass),
		  v);
}
开发者ID:DashYang,项目名称:sim,代码行数:10,代码来源:eval_error.c


示例10: big

static VALUE
big(VALUE x)
{
    if (FIXNUM_P(x))
        return rb_int2big(FIX2LONG(x));
    if (RB_TYPE_P(x, T_BIGNUM))
        return x;
    rb_raise(rb_eTypeError, "can't convert %s to Bignum",
            rb_obj_classname(x));
}
开发者ID:Danylyuk,项目名称:first_app,代码行数:10,代码来源:rat.c


示例11: rb_singleton_class

/*!
 * Returns the singleton class of \a obj. Creates it if necessary.
 *
 * \param obj an arbitrary object.
 * \throw TypeError if \a obj is a Fixnum or a Symbol.
 * \return the singleton class.
 *
 * \post \a obj has its own singleton class.
 * \post if \a obj is a class,
 *       the returned singleton class also has its own
 *       singleton class in order to keep consistency of the
 *       inheritance structure of metaclasses.
 * \note a new singleton class will be created
 *       if \a obj does not have it.
 * \note the singleton classes for nil, true and false are:
 *       NilClass, TrueClass and FalseClass.
 */
VALUE
rb_singleton_class(VALUE obj)
{
    VALUE klass = singleton_class_of(obj);

    /* ensures an exposed class belongs to its own eigenclass */
    if (RB_TYPE_P(obj, T_CLASS)) (void)ENSURE_EIGENCLASS(klass);

    return klass;
}
开发者ID:Danylyuk,项目名称:first_app,代码行数:27,代码来源:class.c


示例12: enc_find

/*
 * call-seq:
 *   Encoding.find(string) -> enc
 *
 * Search the encoding with specified <i>name</i>.
 * <i>name</i> should be a string.
 *
 *   Encoding.find("US-ASCII")  #=> #<Encoding:US-ASCII>
 *
 * Names which this method accept are encoding names and aliases
 * including following special aliases
 *
 * "external"::   default external encoding
 * "internal"::   default internal encoding
 * "locale"::     locale encoding
 * "filesystem":: filesystem encoding
 *
 * An ArgumentError is raised when no encoding with <i>name</i>.
 * Only <code>Encoding.find("internal")</code> however returns nil
 * when no encoding named "internal", in other words, when Ruby has no
 * default internal encoding.
 */
static VALUE
enc_find(VALUE klass, VALUE enc)
{
    int idx;
    if (RB_TYPE_P(enc, T_DATA) && is_data_encoding(enc))
	return enc;
    idx = str_to_encindex(enc);
    if (idx == UNSPECIFIED_ENCODING) return Qnil;
    return rb_enc_from_encoding_index(idx);
}
开发者ID:SongJungHwan,项目名称:hwan,代码行数:32,代码来源:encoding.c


示例13: rb_struct_aref

VALUE
rb_struct_aref(VALUE s, VALUE idx)
{
    long i;

    if (RB_TYPE_P(idx, T_STRING) || RB_TYPE_P(idx, T_SYMBOL)) {
	return rb_struct_aref_id(s, rb_to_id(idx));
    }

    i = NUM2LONG(idx);
    if (i < 0) i = RSTRUCT_LEN(s) + i;
    if (i < 0)
        rb_raise(rb_eIndexError, "offset %ld too small for struct(size:%ld)",
		 i, RSTRUCT_LEN(s));
    if (RSTRUCT_LEN(s) <= i)
        rb_raise(rb_eIndexError, "offset %ld too large for struct(size:%ld)",
		 i, RSTRUCT_LEN(s));
    return RSTRUCT_PTR(s)[i];
}
开发者ID:Chatto,项目名称:VGdesk,代码行数:19,代码来源:struct.c


示例14: rb_profile_frame_classpath

VALUE
rb_profile_frame_classpath(VALUE frame)
{
    VALUE klass = rb_iseq_klass(frame2iseq(frame));

    if (klass && !NIL_P(klass)) {
	if (RB_TYPE_P(klass, T_ICLASS)) {
	    klass = RBASIC(klass)->klass;
	}
	else if (FL_TEST(klass, FL_SINGLETON)) {
	    klass = rb_ivar_get(klass, id__attached__);
	    if (!RB_TYPE_P(klass, T_CLASS))
		return rb_sprintf("#<%s:%p>", rb_class2name(rb_obj_class(klass)), (void*)klass);
	}
	return rb_class_path(klass);
    }
    else {
	return Qnil;
    }
}
开发者ID:sho-h,项目名称:ruby,代码行数:20,代码来源:vm_backtrace.c


示例15: add_event_call_back

static void
add_event_call_back(VALUE obj, VALUE event, VALUE data)
{
    VALUE events = rb_ivar_get(obj, id_events);
    if (NIL_P(events) || !RB_TYPE_P(events, T_ARRAY)) {
        events = rb_ary_new();
        rb_ivar_set(obj, id_events, events);
    }
    ole_delete_event(events, event);
    rb_ary_push(events, data);
}
开发者ID:yugui,项目名称:ruby,代码行数:11,代码来源:win32ole_event.c


示例16: rb_check_backtrace

VALUE
rb_check_backtrace(VALUE bt)
{
    long i;
    static const char err[] = "backtrace must be Array of String";

    if (!NIL_P(bt)) {
	if (RB_TYPE_P(bt, T_STRING)) return rb_ary_new3(1, bt);
	if (rb_backtrace_p(bt)) return bt;
	if (!RB_TYPE_P(bt, T_ARRAY)) {
	    rb_raise(rb_eTypeError, err);
	}
	for (i=0;i<RARRAY_LEN(bt);i++) {
	    if (!RB_TYPE_P(RARRAY_PTR(bt)[i], T_STRING)) {
		rb_raise(rb_eTypeError, err);
	    }
	}
    }
    return bt;
}
开发者ID:Chatto,项目名称:VGdesk,代码行数:20,代码来源:error.c


示例17: syserr_initialize

static VALUE
syserr_initialize(int argc, VALUE *argv, VALUE self)
{
#if !defined(_WIN32)
    char *strerror();
#endif
    const char *err;
    VALUE mesg, error, func;
    VALUE klass = rb_obj_class(self);

    if (klass == rb_eSystemCallError) {
	st_data_t data = (st_data_t)klass;
	rb_scan_args(argc, argv, "12", &mesg, &error, &func);
	if (argc == 1 && FIXNUM_P(mesg)) {
	    error = mesg; mesg = Qnil;
	}
	if (!NIL_P(error) && st_lookup(syserr_tbl, NUM2LONG(error), &data)) {
	    klass = (VALUE)data;
	    /* change class */
	    if (!RB_TYPE_P(self, T_OBJECT)) { /* insurance to avoid type crash */
		rb_raise(rb_eTypeError, "invalid instance type");
	    }
	    RBASIC_SET_CLASS(self, klass);
	}
    }
    else {
	rb_scan_args(argc, argv, "02", &mesg, &func);
	error = rb_const_get(klass, rb_intern("Errno"));
    }
    if (!NIL_P(error)) err = strerror(NUM2INT(error));
    else err = "unknown error";
    if (!NIL_P(mesg)) {
	rb_encoding *le = rb_locale_encoding();
	VALUE str = StringValue(mesg);
	rb_encoding *me = rb_enc_get(mesg);

	if (NIL_P(func))
	    mesg = rb_sprintf("%s - %"PRIsVALUE, err, mesg);
	else
	    mesg = rb_sprintf("%s @ %"PRIsVALUE" - %"PRIsVALUE, err, func, mesg);
	if (le != me && rb_enc_asciicompat(me)) {
	    le = me;
	}/* else assume err is non ASCII string. */
	OBJ_INFECT(mesg, str);
	rb_enc_associate(mesg, le);
    }
    else {
	mesg = rb_str_new2(err);
	rb_enc_associate(mesg, rb_locale_encoding());
    }
    rb_call_super(1, &mesg);
    rb_iv_set(self, "errno", error);
    return self;
}
开发者ID:knugie,项目名称:ruby,代码行数:54,代码来源:error.c


示例18: fontSetNameHelper

static void
fontSetNameHelper(VALUE self, int argc, VALUE *argv,
                  const char *nameIv, char *outBuf, size_t outLen)
{
	rb_check_argc(argc, 1);

	VALUE arg = argv[0];

	// Fixme: in RGSS3, specifying "" (and only that) as font name results in
	// no text being drawn (everything else is substituted with Arial I think)
	strncpy(outBuf, "", outLen);

	if (RB_TYPE_P(arg, RUBY_T_STRING))
	{
		strncpy(outBuf, RSTRING_PTR(arg), outLen);
	}
	else if (RB_TYPE_P(arg, RUBY_T_ARRAY))
	{
		for (long i = 0; i < RARRAY_LEN(arg); ++i)
		{
			VALUE str = rb_ary_entry(arg, i);

			/* Non-string objects are tolerated (ignored) */
			if (!RB_TYPE_P(str, RUBY_T_STRING))
				continue;

			const char *family = RSTRING_PTR(str);

			/* We only set the core Font object's name attribute
			 * to the actually existing font name */
			if (!shState->fontState().fontPresent(family))
				continue;

			strncpy(outBuf, family, outLen);
		}
	}

	/* RMXP doesn't even care if the argument type is
	 * something other than string/array. Whatever... */
	rb_iv_set(self, nameIv, arg);
}
开发者ID:AlexandreSousa,项目名称:mkxp,代码行数:41,代码来源:font-binding.cpp


示例19: rb_struct_eql

static VALUE
rb_struct_eql(VALUE s, VALUE s2)
{
    if (s == s2) return Qtrue;
    if (!RB_TYPE_P(s2, T_STRUCT)) return Qfalse;
    if (rb_obj_class(s) != rb_obj_class(s2)) return Qfalse;
    if (RSTRUCT_LEN(s) != RSTRUCT_LEN(s2)) {
	rb_bug("inconsistent struct"); /* should never happen */
    }

    return rb_exec_recursive_paired(recursive_eql, s, s2, s2);
}
开发者ID:Chatto,项目名称:VGdesk,代码行数:12,代码来源:struct.c


示例20: nucomp_coerce

/* :nodoc: */
static VALUE
nucomp_coerce(VALUE self, VALUE other)
{
    if (k_numeric_p(other) && f_real_p(other))
	return rb_assoc_new(f_complex_new_bang1(CLASS_OF(self), other), self);
    if (RB_TYPE_P(other, T_COMPLEX))
	return rb_assoc_new(other, self);

    rb_raise(rb_eTypeError, "%s can't be coerced into %s",
	     rb_obj_classname(other), rb_obj_classname(self));
    return Qnil;
}
开发者ID:gogotanaka,项目名称:ruby_svn,代码行数:13,代码来源:complex.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ RC函数代码示例发布时间:2022-05-30
下一篇:
C++ RB_SOURCE_GET_CLASS函数代码示例发布时间: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