本文整理汇总了C++中BUILTIN_TYPE函数的典型用法代码示例。如果您正苦于以下问题:C++ BUILTIN_TYPE函数的具体用法?C++ BUILTIN_TYPE怎么用?C++ BUILTIN_TYPE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BUILTIN_TYPE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: method_key
void
method_key(prof_method_key_t* key, VALUE klass, ID mid)
{
/* Is this an include for a module? If so get the actual
module class since we want to combine all profiling
results for that module. */
if (klass != 0)
klass = (BUILTIN_TYPE(klass) == T_ICLASS ? RBASIC(klass)->klass : klass);
key->klass = klass;
key->mid = mid;
key->key = (klass << 4) + (mid << 2);
}
开发者ID:Angeldude,项目名称:sonic-pi,代码行数:13,代码来源:rp_method.c
示例2: rb_mod_included_modules
VALUE
rb_mod_included_modules(VALUE mod)
{
VALUE ary = rb_ary_new();
VALUE p;
for (p = RCLASS_SUPER(mod); p; p = RCLASS_SUPER(p)) {
if (BUILTIN_TYPE(p) == T_ICLASS) {
rb_ary_push(ary, RBASIC(p)->klass);
}
}
return ary;
}
开发者ID:Benabik,项目名称:ruby-concurrent-gc,代码行数:13,代码来源:class.c
示例3: rb_mod_include_p
VALUE
rb_mod_include_p(VALUE mod, VALUE mod2)
{
VALUE p;
Check_Type(mod2, T_MODULE);
for (p = RCLASS_SUPER(mod); p; p = RCLASS_SUPER(p)) {
if (BUILTIN_TYPE(p) == T_ICLASS) {
if (RBASIC(p)->klass == mod2) return Qtrue;
}
}
return Qfalse;
}
开发者ID:Benabik,项目名称:ruby-concurrent-gc,代码行数:13,代码来源:class.c
示例4: cos_i
static int
cos_i(void *vstart, void *vend, size_t stride, void *data)
{
size_t *counts = (size_t *)data;
VALUE v = (VALUE)vstart;
for (;v != (VALUE)vend; v += stride) {
if (RBASIC(v)->flags) {
counts[BUILTIN_TYPE(v)] += rb_obj_memsize_of(v);
}
}
return 0;
}
开发者ID:DashYang,项目名称:sim,代码行数:13,代码来源:objspace.c
示例5: linear_object_p
static int
linear_object_p(VALUE obj)
{
if (FIXNUM_P(obj) || FLONUM_P(obj)) return TRUE;
if (SPECIAL_CONST_P(obj)) return FALSE;
switch (BUILTIN_TYPE(obj)) {
case T_FLOAT:
case T_BIGNUM:
return TRUE;
}
if (rb_obj_is_kind_of(obj, rb_cNumeric)) return TRUE;
if (rb_obj_is_kind_of(obj, rb_cTime)) return TRUE;
return FALSE;
}
开发者ID:DashYang,项目名称:sim,代码行数:14,代码来源:range.c
示例6: rb_cmperr
void
rb_cmperr(VALUE x, VALUE y)
{
VALUE classname;
if (SPECIAL_CONST_P(y) || BUILTIN_TYPE(y) == T_FLOAT) {
classname = rb_inspect(y);
}
else {
classname = rb_obj_class(y);
}
rb_raise(rb_eArgError, "comparison of %"PRIsVALUE" with %"PRIsVALUE" failed",
rb_obj_class(x), classname);
}
开发者ID:DashYang,项目名称:sim,代码行数:14,代码来源:compar.c
示例7: include_modules_at
static int
include_modules_at(const VALUE klass, VALUE c, VALUE module)
{
VALUE p;
int changed = 0;
const st_table *const klass_m_tbl = RCLASS_M_TBL(RCLASS_ORIGIN(klass));
while (module) {
int superclass_seen = FALSE;
if (RCLASS_ORIGIN(module) != module)
goto skip;
if (klass_m_tbl && klass_m_tbl == RCLASS_M_TBL(module))
return -1;
/* ignore if the module included already in superclasses */
for (p = RCLASS_SUPER(klass); p; p = RCLASS_SUPER(p)) {
switch (BUILTIN_TYPE(p)) {
case T_ICLASS:
if (RCLASS_M_TBL(p) == RCLASS_M_TBL(module)) {
if (!superclass_seen) {
c = p; /* move insertion point */
}
goto skip;
}
break;
case T_CLASS:
superclass_seen = TRUE;
break;
}
}
c = RCLASS_SET_SUPER(c, rb_include_class_new(module, RCLASS_SUPER(c)));
if (FL_TEST(klass, RMODULE_IS_REFINEMENT)) {
VALUE refined_class =
rb_refinement_module_get_refined_class(klass);
st_foreach(RMODULE_M_TBL(module), add_refined_method_entry_i,
(st_data_t) refined_class);
FL_SET(c, RMODULE_INCLUDED_INTO_REFINEMENT);
}
if (RMODULE_M_TBL(module) && RMODULE_M_TBL(module)->num_entries)
changed = 1;
if (RMODULE_CONST_TBL(module) && RMODULE_CONST_TBL(module)->num_entries)
changed = 1;
skip:
module = RCLASS_SUPER(module);
}
return changed;
}
开发者ID:takuto-h,项目名称:ruby,代码行数:49,代码来源:class.c
示例8: enc_capable
static inline int
enc_capable(VALUE obj)
{
if (SPECIAL_CONST_P(obj)) return SYMBOL_P(obj);
switch (BUILTIN_TYPE(obj)) {
case T_STRING:
case T_REGEXP:
case T_FILE:
return TRUE;
case T_DATA:
if (is_data_encoding(obj)) return TRUE;
default:
return FALSE;
}
}
开发者ID:217,项目名称:ruby,代码行数:15,代码来源:encoding.c
示例9: rb_cmperr
void
rb_cmperr(VALUE x, VALUE y)
{
const char *classname;
if (SPECIAL_CONST_P(y) || BUILTIN_TYPE(y) == T_FLOAT) {
y = rb_inspect(y);
classname = StringValuePtr(y);
}
else {
classname = rb_obj_classname(y);
}
rb_raise(rb_eArgError, "comparison of %s with %s failed",
rb_obj_classname(x), classname);
}
开发者ID:brightbox,项目名称:deb-ruby2.0,代码行数:15,代码来源:compar.c
示例10: cn_i
static int
cn_i(void *vstart, void *vend, size_t stride, void *n)
{
size_t *nodes = (size_t *)n;
VALUE v = (VALUE)vstart;
for (; v != (VALUE)vend; v += stride) {
if (RBASIC(v)->flags && BUILTIN_TYPE(v) == T_NODE) {
size_t s = nd_type((NODE *)v);
nodes[s]++;
}
}
return 0;
}
开发者ID:GunioRobot,项目名称:ruby,代码行数:15,代码来源:objspace.c
示例11: rb_mod_ancestors
VALUE
rb_mod_ancestors(VALUE mod)
{
VALUE p, ary = rb_ary_new();
for (p = mod; p; p = RCLASS_SUPER(p)) {
if (BUILTIN_TYPE(p) == T_ICLASS) {
rb_ary_push(ary, RBASIC(p)->klass);
}
else if (p == RCLASS_ORIGIN(p)) {
rb_ary_push(ary, p);
}
}
return ary;
}
开发者ID:Danylyuk,项目名称:first_app,代码行数:15,代码来源:class.c
示例12: rb_mod_included_modules
VALUE
rb_mod_included_modules(VALUE mod)
{
VALUE ary = rb_ary_new();
VALUE p;
VALUE origin = RCLASS_ORIGIN(mod);
for (p = RCLASS_SUPER(mod); p; p = RCLASS_SUPER(p)) {
if (p != origin && BUILTIN_TYPE(p) == T_ICLASS) {
VALUE m = RBASIC(p)->klass;
if (RB_TYPE_P(m, T_MODULE))
rb_ary_push(ary, m);
}
}
return ary;
}
开发者ID:Danylyuk,项目名称:first_app,代码行数:16,代码来源:class.c
示例13: putstr
static void putstr(VALUE str, const upb_fielddef *f, upb_sink *sink) {
if (str == Qnil) return;
assert(BUILTIN_TYPE(str) == RUBY_T_STRING);
upb_sink subsink;
// Ensure that the string has the correct encoding. We also check at field-set
// time, but the user may have mutated the string object since then.
native_slot_validate_string_encoding(upb_fielddef_type(f), str);
upb_sink_startstr(sink, getsel(f, UPB_HANDLER_STARTSTR), RSTRING_LEN(str),
&subsink);
upb_sink_putstring(&subsink, getsel(f, UPB_HANDLER_STRING), RSTRING_PTR(str),
RSTRING_LEN(str), NULL);
upb_sink_endstr(sink, getsel(f, UPB_HANDLER_ENDSTR));
}
开发者ID:6116353,项目名称:protobuf,代码行数:16,代码来源:encode_decode.c
示例14: rb_mod_ancestors
VALUE
rb_mod_ancestors(VALUE mod)
{
VALUE p, ary = rb_ary_new();
for (p = mod; p; p = RCLASS_SUPER(p)) {
if (FL_TEST(p, FL_SINGLETON))
continue;
if (BUILTIN_TYPE(p) == T_ICLASS) {
rb_ary_push(ary, RBASIC(p)->klass);
}
else {
rb_ary_push(ary, p);
}
}
return ary;
}
开发者ID:technohippy,项目名称:oruby,代码行数:17,代码来源:class.c
示例15: rb_include_module
void
rb_include_module(VALUE klass, VALUE module)
{
VALUE p, c;
int changed = 0;
rb_frozen_class_p(klass);
if (!OBJ_UNTRUSTED(klass)) {
rb_secure(4);
}
if (TYPE(module) != T_MODULE) {
Check_Type(module, T_MODULE);
}
OBJ_INFECT(klass, module);
c = klass;
while (module) {
int superclass_seen = FALSE;
if (RCLASS_M_TBL(klass) == RCLASS_M_TBL(module))
rb_raise(rb_eArgError, "cyclic include detected");
/* ignore if the module included already in superclasses */
for (p = RCLASS_SUPER(klass); p; p = RCLASS_SUPER(p)) {
switch (BUILTIN_TYPE(p)) {
case T_ICLASS:
if (RCLASS_M_TBL(p) == RCLASS_M_TBL(module)) {
if (!superclass_seen) {
c = p; /* move insertion point */
}
goto skip;
}
break;
case T_CLASS:
superclass_seen = TRUE;
break;
}
}
c = RCLASS_SUPER(c) = include_class_new(module, RCLASS_SUPER(c));
if (RMODULE_M_TBL(module) && RMODULE_M_TBL(module)->num_entries)
changed = 1;
skip:
module = RCLASS_SUPER(module);
}
if (changed) rb_clear_cache();
}
开发者ID:fi8on,项目名称:ruby,代码行数:46,代码来源:class.c
示例16: module_remove_features
/*
* call-seq:
* remove_features(mod) => mod
*
* When this module is unincluded from another, Ruby Internal calls
* remove_features in this module. The default behavior is to remove
* the constants, methods, and module variables of this module from
* _mod_. If this module has not been included by _mod_, an exception
* will be raised.
*/
static VALUE module_remove_features(VALUE module, VALUE uninclude)
{
VALUE prev, mod;
if(TYPE(uninclude) != T_CLASS && TYPE(uninclude) != T_MODULE)
{
Check_Type(uninclude, T_CLASS);
}
rb_frozen_class_p(uninclude);
if(!OBJ_TAINTED(uninclude))
{
rb_secure(4);
}
OBJ_INFECT(uninclude, module);
if(RCLASS(uninclude)->m_tbl == RCLASS(module)->m_tbl)
{
rb_raise(rb_eArgError, "Cannot remove module from itself");
}
prev = uninclude;
mod = RCLASS_SUPER(uninclude);
while(mod)
{
if(RCLASS(module)->m_tbl == RCLASS(mod)->m_tbl)
{
RCLASS_SUPER(prev) = RCLASS_SUPER(mod);
rb_clear_cache();
return module;
}
if(BUILTIN_TYPE(mod) == T_CLASS)
{
break;
}
prev = mod;
mod = RCLASS_SUPER(mod);
}
rb_raise(rb_eArgError, "Could not find included module");
return module;
}
开发者ID:shmulim,项目名称:ruby-internal,代码行数:56,代码来源:module.c
示例17: j_class_new
/* a modified version of include_class_new from class.c */
static VALUE
j_class_new(VALUE module, VALUE sup)
{
#ifdef RUBY_19
VALUE klass = class_alloc(T_ICLASS, rb_cClass);
#else
NEWOBJ(klass, struct RClass);
OBJSETUP(klass, rb_cClass, T_ICLASS);
#endif
if (BUILTIN_TYPE(module) == T_ICLASS) {
module = KLASS_OF(module);
}
if (!RCLASS_IV_TBL(module)) {
RCLASS_IV_TBL(module) = (struct st_table *)st_init_numtable();
}
/* assign iv_tbl, m_tbl and super */
RCLASS_IV_TBL(klass) = RCLASS_IV_TBL(module);
RCLASS_SUPER(klass) = sup;
if(TYPE(module) != T_OBJECT) {
RCLASS_M_TBL(klass) = RCLASS_M_TBL(module);
}
else {
RCLASS_M_TBL(klass) = RCLASS_M_TBL(CLASS_OF(module));
}
/* */
if (TYPE(module) == T_ICLASS) {
KLASS_OF(klass) = KLASS_OF(module);
}
else {
KLASS_OF(klass) = module;
}
if(TYPE(module) != T_OBJECT) {
OBJ_INFECT(klass, module);
OBJ_INFECT(klass, sup);
}
return (VALUE)klass;
}
开发者ID:RavensKrag,项目名称:texplay,代码行数:47,代码来源:object2module.c
示例18: rb_include_module
void
rb_include_module(VALUE klass, VALUE module)
{
VALUE p, c;
int changed = 0;
rb_frozen_class_p(klass);
if (!OBJ_TAINTED(klass)) {
rb_secure(4);
}
if (TYPE(module) != T_MODULE) {
Check_Type(module, T_MODULE);
}
OBJ_INFECT(klass, module);
c = klass;
while (module) {
int superclass_seen = Qfalse;
if (RCLASS(klass)->m_tbl == RCLASS(module)->m_tbl)
rb_raise(rb_eArgError, "cyclic include detected");
/* ignore if the module included already in superclasses */
for (p = RCLASS(klass)->super; p; p = RCLASS(p)->super) {
switch (BUILTIN_TYPE(p)) {
case T_ICLASS:
if (RCLASS(p)->m_tbl == RCLASS(module)->m_tbl) {
if (!superclass_seen) {
c = p; /* move insertion point */
}
goto skip;
}
break;
case T_CLASS:
superclass_seen = Qtrue;
break;
}
}
c = RCLASS(c)->super = include_class_new(module, RCLASS(c)->super);
changed = 1;
skip:
module = RCLASS(module)->super;
}
if (changed) rb_clear_cache();
}
开发者ID:asimoov,项目名称:emscripted-ruby,代码行数:45,代码来源:class.c
示例19: rb_singleton_class
VALUE
rb_singleton_class(VALUE obj)
{
VALUE klass;
ID attached;
if (FIXNUM_P(obj) || SYMBOL_P(obj)) {
rb_raise(rb_eTypeError, "can't define singleton");
}
if (rb_special_const_p(obj)) {
SPECIAL_SINGLETON(Qnil, rb_cNilClass);
SPECIAL_SINGLETON(Qfalse, rb_cFalseClass);
SPECIAL_SINGLETON(Qtrue, rb_cTrueClass);
rb_bug("unknown immediate %ld", obj);
}
CONST_ID(attached, "__attached__");
if (FL_TEST(RBASIC(obj)->klass, FL_SINGLETON) &&
rb_ivar_get(RBASIC(obj)->klass, attached) == obj) {
klass = RBASIC(obj)->klass;
}
else {
klass = rb_make_metaclass(obj, RBASIC(obj)->klass);
}
if (BUILTIN_TYPE(obj) == T_CLASS) {
if (rb_iv_get(RBASIC(klass)->klass, "__attached__") != klass)
make_metametaclass(klass);
}
if (OBJ_TAINTED(obj)) {
OBJ_TAINT(klass);
}
else {
FL_UNSET(klass, FL_TAINT);
}
if (OBJ_UNTRUSTED(obj)) {
OBJ_UNTRUST(klass);
}
else {
FL_UNSET(klass, FL_UNTRUSTED);
}
if (OBJ_FROZEN(obj)) OBJ_FREEZE(klass);
return klass;
}
开发者ID:technohippy,项目名称:oruby,代码行数:45,代码来源:class.c
示例20: evilr_swap
/* call-seq:
* swap(other) -> self
*
* Swap the contents of the receiver with +other+:
*
* a = []
* b = {}
* a.swap(b) # => {}
* a # => {}
* b # => []
*
* You cannot swap a Class or Module except with another
* Class or Module, and you can only swap a Class with a Class and
* a Module with a Module (no swapping a Class with Module), and you
* cannot swap immediate values. If an invalid swap attempt is
* detected, a +TypeError+ is raised.*/
static VALUE evilr_swap(VALUE self, VALUE other) {
char tmp[OBJECT_SIZE];
evilr__check_immediates(self, other);
if ((BUILTIN_TYPE(self) == T_MODULE || BUILTIN_TYPE(self) == T_CLASS ||
BUILTIN_TYPE(other) == T_MODULE || BUILTIN_TYPE(other) == T_CLASS) &&
BUILTIN_TYPE(self) != BUILTIN_TYPE(other)) {
rb_raise(rb_eTypeError, "incompatible types used");
}
memcpy(tmp, ROBJECT(self), OBJECT_SIZE);
memcpy(ROBJECT(self), ROBJECT(other), OBJECT_SIZE);
memcpy(ROBJECT(other), tmp, OBJECT_SIZE);
return self;
}
开发者ID:jeremyevans,项目名称:evilr,代码行数:29,代码来源:evilr.c
注:本文中的BUILTIN_TYPE函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论