本文整理汇总了C++中FL_TEST函数的典型用法代码示例。如果您正苦于以下问题:C++ FL_TEST函数的具体用法?C++ FL_TEST怎么用?C++ FL_TEST使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FL_TEST函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: rb_obj_singleton_methods
VALUE
rb_obj_singleton_methods(int argc, VALUE *argv, VALUE obj)
{
VALUE recur, ary, klass;
st_table *list;
if (argc == 0) {
recur = Qtrue;
}
else {
rb_scan_args(argc, argv, "01", &recur);
}
klass = CLASS_OF(obj);
list = st_init_numtable();
if (klass && FL_TEST(klass, FL_SINGLETON)) {
st_foreach(RCLASS_M_TBL(klass), method_entry, (st_data_t)list);
klass = RCLASS_SUPER(klass);
}
if (RTEST(recur)) {
while (klass && (FL_TEST(klass, FL_SINGLETON) || TYPE(klass) == T_ICLASS)) {
st_foreach(RCLASS_M_TBL(klass), method_entry, (st_data_t)list);
klass = RCLASS_SUPER(klass);
}
}
ary = rb_ary_new();
st_foreach(list, ins_methods_i, ary);
st_free_table(list);
return ary;
}
开发者ID:technohippy,项目名称:oruby,代码行数:30,代码来源:class.c
示例2: rb_obj_singleton_methods
VALUE
rb_obj_singleton_methods(int argc, VALUE *argv, VALUE obj)
{
VALUE recur, ary, klass, origin;
st_table *list, *mtbl;
if (argc == 0) {
recur = Qtrue;
}
else {
rb_scan_args(argc, argv, "01", &recur);
}
klass = CLASS_OF(obj);
origin = RCLASS_ORIGIN(klass);
list = st_init_numtable();
if (klass && FL_TEST(klass, FL_SINGLETON)) {
if ((mtbl = RCLASS_M_TBL(origin)) != 0)
st_foreach(mtbl, method_entry_i, (st_data_t)list);
klass = RCLASS_SUPER(klass);
}
if (RTEST(recur)) {
while (klass && (FL_TEST(klass, FL_SINGLETON) || RB_TYPE_P(klass, T_ICLASS))) {
if (klass != origin && (mtbl = RCLASS_M_TBL(klass)) != 0)
st_foreach(mtbl, method_entry_i, (st_data_t)list);
klass = RCLASS_SUPER(klass);
}
}
ary = rb_ary_new();
st_foreach(list, ins_methods_i, ary);
st_free_table(list);
return ary;
}
开发者ID:Danylyuk,项目名称:first_app,代码行数:33,代码来源:class.c
示例3: rb_undef
void
rb_undef(VALUE klass, ID id)
{
VALUE origin;
NODE *body;
if (rb_vm_cbase() == rb_cObject && klass == rb_cObject) {
rb_secure(4);
}
if (rb_safe_level() >= 4 && !OBJ_TAINTED(klass)) {
rb_raise(rb_eSecurityError, "Insecure: can't undef `%s'",
rb_id2name(id));
}
rb_frozen_class_p(klass);
if (id == object_id || id == __send__ || id == idInitialize) {
rb_warn("undefining `%s' may cause serious problem", rb_id2name(id));
}
body = search_method(klass, id, &origin);
if (!body || !body->nd_body) {
const char *s0 = " class";
VALUE c = klass;
if (FL_TEST(c, FL_SINGLETON)) {
VALUE obj = rb_iv_get(klass, "__attached__");
switch (TYPE(obj)) {
case T_MODULE:
case T_CLASS:
c = obj;
s0 = "";
}
}
else if (TYPE(c) == T_MODULE) {
s0 = " module";
}
rb_name_error(id, "undefined method `%s' for%s `%s'",
rb_id2name(id), s0, rb_class2name(c));
}
rb_add_method(klass, id, 0, NOEX_PUBLIC);
if (FL_TEST(klass, FL_SINGLETON)) {
rb_funcall(rb_iv_get(klass, "__attached__"),
singleton_undefined, 1, ID2SYM(id));
}
else {
rb_funcall(klass, undefined, 1, ID2SYM(id));
}
}
开发者ID:genki,项目名称:ruby,代码行数:49,代码来源:vm_method.c
示例4: singleton_class_clone_int
static VALUE
singleton_class_clone_int(VALUE obj, VALUE nklass)
{
VALUE klass = RBASIC(obj)->klass;
if (!FL_TEST(klass, FL_SINGLETON))
return klass;
else {
/* copy singleton(unnamed) class */
NEWOBJ(clone, struct RClass);
OBJSETUP(clone, 0, RBASIC(klass)->flags);
if (BUILTIN_TYPE(obj) == T_CLASS) {
RBASIC(clone)->klass = (VALUE)clone;
}
else {
RBASIC(clone)->klass = rb_singleton_class_clone(klass);
}
clone->super = RCLASS(klass)->super;
clone->iv_tbl = 0;
clone->m_tbl = 0;
if (RCLASS(klass)->iv_tbl) {
clone->iv_tbl = st_copy(RCLASS(klass)->iv_tbl);
}
clone->m_tbl = st_init_numtable();
st_foreach(RCLASS(klass)->m_tbl, (int (*)(...))clone_method, NIL_P(nklass) ? (VALUE)clone : nklass);
rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone);
FL_SET(clone, FL_SINGLETON);
return (VALUE)clone;
}
}
开发者ID:asimoov,项目名称:emscripted-ruby,代码行数:32,代码来源:class.c
示例5: total_i
static int
total_i(void *vstart, void *vend, size_t stride, void *ptr)
{
VALUE v;
struct total_data *data = (struct total_data *)ptr;
for (v = (VALUE)vstart; v != (VALUE)vend; v += stride) {
if (RBASIC(v)->flags) {
switch (BUILTIN_TYPE(v)) {
case T_NONE:
case T_ICLASS:
case T_NODE:
case T_ZOMBIE:
continue;
case T_CLASS:
if (FL_TEST(v, FL_SINGLETON))
continue;
default:
if (data->klass == 0 || rb_obj_is_kind_of(v, data->klass)) {
data->total += memsize_of(v);
}
}
}
}
return 0;
}
开发者ID:Chatto,项目名称:VGdesk,代码行数:27,代码来源:objspace.c
示例6: superclass_name
static VALUE superclass_name(VALUE module)
{
if(TYPE(module) == T_MODULE)
{
return Qnil;
}
else
{
VALUE super = RCLASS_SUPER(module);
while(TYPE(super) == T_ICLASS)
{
super = RCLASS_SUPER(super);
}
if(!super)
{
return Qnil;
}
if(FL_TEST(super, FL_SINGLETON))
{
VALUE v = rb_iv_get(super, "__attached__");
VALUE name = rb_mod_name(v);
rb_str_cat2(name, "::<Singleton>");
return name;
}
else
{
return rb_mod_name(super);
}
}
}
开发者ID:shmulim,项目名称:ruby-internal,代码行数:33,代码来源:module.c
示例7: call_trace_func
static void
call_trace_func(rb_event_flag_t event, VALUE proc, VALUE self, ID id, VALUE klass)
{
const char *srcfile = rb_sourcefile();
VALUE eventname = rb_str_new2(get_event_name(event));
VALUE filename = srcfile ? rb_str_new2(srcfile) : Qnil;
VALUE argv[6];
int line = rb_sourceline();
rb_thread_t *th = GET_THREAD();
if (!klass) {
rb_thread_method_id_and_class(th, &id, &klass);
}
if (klass) {
if (RB_TYPE_P(klass, T_ICLASS)) {
klass = RBASIC(klass)->klass;
}
else if (FL_TEST(klass, FL_SINGLETON)) {
klass = rb_iv_get(klass, "__attached__");
}
}
argv[0] = eventname;
argv[1] = filename;
argv[2] = INT2FIX(line);
argv[3] = id ? ID2SYM(id) : Qnil;
argv[4] = (self && srcfile) ? rb_binding_new() : Qnil;
argv[5] = klass ? klass : Qnil;
rb_proc_call_with_block(proc, 6, argv, Qnil);
}
开发者ID:Chatto,项目名称:VGdesk,代码行数:32,代码来源:vm_trace.c
示例8: rb_mod_init_copy
/* :nodoc: */
VALUE
rb_mod_init_copy(VALUE clone, VALUE orig)
{
rb_obj_init_copy(clone, orig);
if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) {
RBASIC(clone)->klass = rb_singleton_class_clone(orig);
}
RCLASS_SUPER(clone) = RCLASS_SUPER(orig);
if (RCLASS_IV_TBL(orig)) {
ID id;
RCLASS_IV_TBL(clone) = st_copy(RCLASS_IV_TBL(orig));
CONST_ID(id, "__classpath__");
st_delete(RCLASS_IV_TBL(clone), (st_data_t*)&id, 0);
CONST_ID(id, "__classid__");
st_delete(RCLASS_IV_TBL(clone), (st_data_t*)&id, 0);
}
if (RCLASS_M_TBL(orig)) {
struct clone_method_data data;
data.tbl = RCLASS_M_TBL(clone) = st_init_numtable();
data.klass = clone;
st_foreach(RCLASS_M_TBL(orig), clone_method,
(st_data_t)&data);
}
return clone;
}
开发者ID:technohippy,项目名称:oruby,代码行数:28,代码来源:class.c
示例9: rb_gc_copy_finalizer
void
rb_gc_copy_finalizer(VALUE dest, VALUE obj)
{
VALUE table;
if (__os_finalizers == NULL)
return;
if (NATIVE(obj)) {
if (!rb_objc_flag_check((void *)obj, FL_FINALIZE))
return;
}
else {
if (!FL_TEST(obj, FL_FINALIZE))
return;
}
table = (VALUE)CFDictionaryGetValue((CFDictionaryRef)__os_finalizers,
(const void *)obj);
if (table == 0) {
CFDictionaryRemoveValue(__os_finalizers, (const void *)dest);
}
else {
CFDictionarySetValue(__os_finalizers, (const void *)dest,
(const void *)table);
}
}
开发者ID:prototype,项目名称:MacRuby,代码行数:28,代码来源:gc.c
示例10: klass_name
static VALUE
klass_name(VALUE klass)
{
VALUE result = Qnil;
if (klass == 0 || klass == Qnil)
{
result = rb_str_new2("Global");
}
else if (BUILTIN_TYPE(klass) == T_MODULE)
{
result = rb_inspect(klass);
}
else if (BUILTIN_TYPE(klass) == T_CLASS && FL_TEST(klass, FL_SINGLETON))
{
result = figure_singleton_name(klass);
}
else if (BUILTIN_TYPE(klass) == T_CLASS)
{
result = rb_inspect(klass);
}
else
{
/* Should never happen. */
result = rb_str_new2("Unknown");
}
return result;
}
开发者ID:FesterCluck,项目名称:PMOG-OS,代码行数:29,代码来源:ruby_prof.c
示例11: rb_singleton_class
VALUE
rb_singleton_class(VALUE obj)
{
VALUE klass;
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);
}
DEFER_INTS;
if (FL_TEST(RBASIC(obj)->klass, FL_SINGLETON) &&
rb_iv_get(RBASIC(obj)->klass, "__attached__") == obj) {
klass = RBASIC(obj)->klass;
}
else {
klass = rb_make_metaclass(obj, RBASIC(obj)->klass);
}
if (OBJ_TAINTED(obj)) {
OBJ_TAINT(klass);
}
else {
FL_UNSET(klass, FL_TAINT);
}
if (OBJ_FROZEN(obj)) OBJ_FREEZE(klass);
ALLOW_INTS;
return klass;
}
开发者ID:genki,项目名称:ruby,代码行数:34,代码来源:class.c
示例12: rb_singleton_class_clone
VALUE
rb_singleton_class_clone(VALUE obj)
{
VALUE klass = RBASIC(obj)->klass;
if (!FL_TEST(klass, FL_SINGLETON))
return klass;
else {
struct clone_method_data data;
/* copy singleton(unnamed) class */
VALUE clone = class_alloc(RBASIC(klass)->flags, 0);
if (BUILTIN_TYPE(obj) == T_CLASS) {
RBASIC(clone)->klass = (VALUE)clone;
}
else {
RBASIC(clone)->klass = rb_singleton_class_clone(klass);
}
RCLASS_SUPER(clone) = RCLASS_SUPER(klass);
if (RCLASS_IV_TBL(klass)) {
RCLASS_IV_TBL(clone) = st_copy(RCLASS_IV_TBL(klass));
}
RCLASS_M_TBL(clone) = st_init_numtable();
data.tbl = RCLASS_M_TBL(clone);
data.klass = (VALUE)clone;
st_foreach(RCLASS_M_TBL(klass), clone_method,
(st_data_t)&data);
rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone);
FL_SET(clone, FL_SINGLETON);
return (VALUE)clone;
}
}
开发者ID:technohippy,项目名称:oruby,代码行数:33,代码来源:class.c
示例13: class_instance_method_list
static VALUE
class_instance_method_list(int argc, VALUE *argv, VALUE mod, int obj, int (*func) (st_data_t, st_data_t, st_data_t))
{
VALUE ary;
int recur, prepended = 0;
st_table *list;
if (argc == 0) {
recur = TRUE;
}
else {
VALUE r;
rb_scan_args(argc, argv, "01", &r);
recur = RTEST(r);
}
if (!recur && RCLASS_ORIGIN(mod) != mod) {
mod = RCLASS_ORIGIN(mod);
prepended = 1;
}
list = st_init_numtable();
for (; mod; mod = RCLASS_SUPER(mod)) {
if (RCLASS_M_TBL(mod)) st_foreach(RCLASS_M_TBL(mod), method_entry_i, (st_data_t)list);
if (BUILTIN_TYPE(mod) == T_ICLASS && !prepended) continue;
if (obj && FL_TEST(mod, FL_SINGLETON)) continue;
if (!recur) break;
}
ary = rb_ary_new();
st_foreach(list, func, ary);
st_free_table(list);
return ary;
}
开发者ID:Danylyuk,项目名称:first_app,代码行数:34,代码来源:class.c
示例14: make_metametaclass
/*!
* Creates a meta^(n+1)-class for a meta^(n)-class.
* \param metaclass a class of a class
* \return the created meta^(n+1)-class.
* \pre \a metaclass is a metaclass
* \post the class of \a metaclass is the returned class.
*/
static VALUE
make_metametaclass(VALUE metaclass)
{
VALUE metametaclass, super_of_metaclass;
if (RBASIC(metaclass)->klass == metaclass) { /* for meta^(n)-class of Class */
metametaclass = rb_class_boot(Qnil);
RBASIC(metametaclass)->klass = metametaclass;
}
else {
metametaclass = rb_class_boot(Qnil);
RBASIC(metametaclass)->klass =
(RBASIC(RBASIC(metaclass)->klass)->klass == RBASIC(metaclass)->klass)
? make_metametaclass(RBASIC(metaclass)->klass)
: RBASIC(RBASIC(metaclass)->klass)->klass;
}
FL_SET(metametaclass, FL_SINGLETON);
rb_singleton_class_attached(metametaclass, metaclass);
RBASIC(metaclass)->klass = metametaclass;
super_of_metaclass = RCLASS_SUPER(metaclass);
while (FL_TEST(super_of_metaclass, T_ICLASS)) {
super_of_metaclass = RCLASS_SUPER(super_of_metaclass);
}
RCLASS_SUPER(metametaclass) =
rb_iv_get(RBASIC(super_of_metaclass)->klass, "__attached__") == super_of_metaclass
? RBASIC(super_of_metaclass)->klass
: make_metametaclass(super_of_metaclass);
OBJ_INFECT(metametaclass, RCLASS_SUPER(metametaclass));
return metametaclass;
}
开发者ID:technohippy,项目名称:oruby,代码行数:40,代码来源:class.c
示例15: class_instance_method_list
static VALUE
class_instance_method_list(int argc, VALUE *argv, VALUE mod, int (*func) (ID, long, VALUE))
{
VALUE ary;
int recur;
st_table *list;
if (argc == 0) {
recur = TRUE;
}
else {
VALUE r;
rb_scan_args(argc, argv, "01", &r);
recur = RTEST(r);
}
list = st_init_numtable();
for (; mod; mod = RCLASS_SUPER(mod)) {
st_foreach(RCLASS_M_TBL(mod), method_entry, (st_data_t)list);
if (BUILTIN_TYPE(mod) == T_ICLASS) continue;
if (FL_TEST(mod, FL_SINGLETON)) continue;
if (!recur) break;
}
ary = rb_ary_new();
st_foreach(list, func, ary);
st_free_table(list);
return ary;
}
开发者ID:technohippy,项目名称:oruby,代码行数:29,代码来源:class.c
示例16: include_modules_at
static int
include_modules_at(const VALUE klass, VALUE c, VALUE module)
{
VALUE p, iclass;
int method_changed = 0, constant_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_WRAPPER(p) == RCLASS_M_TBL_WRAPPER(module)) {
if (!superclass_seen) {
c = p; /* move insertion point */
}
goto skip;
}
break;
case T_CLASS:
superclass_seen = TRUE;
break;
}
}
iclass = rb_include_class_new(module, RCLASS_SUPER(c));
c = RCLASS_SET_SUPER(c, iclass);
if (BUILTIN_TYPE(module) == T_ICLASS) {
rb_module_add_to_subclasses_list(RBASIC(module)->klass, iclass);
} else {
rb_module_add_to_subclasses_list(module, iclass);
}
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)
method_changed = 1;
if (RMODULE_CONST_TBL(module) && RMODULE_CONST_TBL(module)->num_entries)
constant_changed = 1;
skip:
module = RCLASS_SUPER(module);
}
if (method_changed) rb_clear_method_cache_by_class(klass);
if (constant_changed) rb_clear_constant_cache();
return method_changed;
}
开发者ID:Danylyuk,项目名称:first_app,代码行数:60,代码来源:class.c
示例17: rb_alias
void
rb_alias(VALUE klass, ID name, ID def)
{
NODE *orig_fbody, *node, *method;
VALUE singleton = 0;
st_data_t data;
rb_frozen_class_p(klass);
if (klass == rb_cObject) {
rb_secure(4);
}
orig_fbody = search_method(klass, def, 0);
if (!orig_fbody || !orig_fbody->nd_body) {
if (TYPE(klass) == T_MODULE) {
orig_fbody = search_method(rb_cObject, def, 0);
}
}
if (!orig_fbody || !orig_fbody->nd_body) {
rb_print_undef(klass, def, 0);
}
if (FL_TEST(klass, FL_SINGLETON)) {
singleton = rb_iv_get(klass, "__attached__");
}
orig_fbody->nd_cnt++;
if (st_lookup(RCLASS_M_TBL(klass), name, &data)) {
node = (NODE *)data;
if (node) {
if (RTEST(ruby_verbose) && node->nd_cnt == 0 && node->nd_body) {
rb_warning("discarding old %s", rb_id2name(name));
}
if (nd_type(node->nd_body->nd_body) == NODE_CFUNC) {
rb_vm_check_redefinition_opt_method(node);
}
}
}
st_insert(RCLASS_M_TBL(klass), name,
(st_data_t) NEW_FBODY(
method = NEW_METHOD(orig_fbody->nd_body->nd_body,
orig_fbody->nd_body->nd_clss,
NOEX_WITH_SAFE(orig_fbody->nd_body->nd_noex)), def));
method->nd_file = (void *)def;
rb_clear_cache_by_id(name);
if (!ruby_running) return;
if (singleton) {
rb_funcall(singleton, singleton_added, 1, ID2SYM(name));
}
else {
rb_funcall(klass, added, 1, ID2SYM(name));
}
}
开发者ID:iriscouch,项目名称:ruby-inabox,代码行数:56,代码来源:vm_method.c
示例18: Looksee_singleton_instance
VALUE Looksee_singleton_instance(VALUE self, VALUE klass) {
if (!SPECIAL_CONST_P(klass) && BUILTIN_TYPE(klass) == T_CLASS && FL_TEST(klass, FL_SINGLETON)) {
VALUE object;
if (!Looksee_method_table_lookup(RCLASS_IV_TBL(klass), rb_intern("__attached__"), (st_data_t *)&object))
rb_raise(rb_eRuntimeError, "[looksee bug] can't find singleton object");
return object;
} else {
return Qnil;
}
}
开发者ID:mathieujobin,项目名称:looksee,代码行数:10,代码来源:mri.c
示例19: Looksee_singleton_instance
VALUE Looksee_singleton_instance(VALUE self, VALUE singleton_class) {
if (BUILTIN_TYPE(singleton_class) == T_CLASS && FL_TEST(singleton_class, FL_SINGLETON)) {
VALUE object;
if (!Looksee_method_table_lookup(RCLASS_IV_TBL(singleton_class), rb_intern("__attached__"), (st_data_t *)&object))
rb_raise(rb_eRuntimeError, "[looksee bug] can't find singleton object");
return object;
} else {
rb_raise(rb_eTypeError, "expected singleton class, got %s", rb_obj_classname(singleton_class));
}
}
开发者ID:hkraji,项目名称:looksee,代码行数:10,代码来源:mri.c
示例20: rb_singleton_class_attached
/*!
* Attach a object to a singleton class.
* @pre \a klass is the singleton class of \a obj.
*/
void
rb_singleton_class_attached(VALUE klass, VALUE obj)
{
if (FL_TEST(klass, FL_SINGLETON)) {
if (!RCLASS_IV_TBL(klass)) {
RCLASS_IV_TBL(klass) = st_init_numtable();
}
st_insert(RCLASS_IV_TBL(klass), id_attached, obj);
}
}
开发者ID:fi8on,项目名称:ruby,代码行数:14,代码来源:class.c
注:本文中的FL_TEST函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论