本文整理汇总了C++中RCLASS_SUPER函数的典型用法代码示例。如果您正苦于以下问题:C++ RCLASS_SUPER函数的具体用法?C++ RCLASS_SUPER怎么用?C++ RCLASS_SUPER使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RCLASS_SUPER函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: add_module
static void add_module(VALUE self, VALUE module)
{
VALUE super = RCLASS_SUPER(rb_singleton_class(self));
#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) = (void*)st_init_numtable();
}
RCLASS_IV_TBL(klass) = RCLASS_IV_TBL(module);
RCLASS_M_TBL(klass) = RCLASS_M_TBL(module);
RCLASS_SUPER(klass) = super;
if (TYPE(module) == T_ICLASS) {
KLASS_OF(klass) = KLASS_OF(module);
} else {
KLASS_OF(klass) = module;
}
OBJ_INFECT(klass, module);
OBJ_INFECT(klass, super);
RCLASS_SUPER(rb_singleton_class(self)) = (VALUE)klass;
}
开发者ID:kristianmandrup,项目名称:mixology,代码行数:32,代码来源:mixology.c
示例2: 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
示例3: rb_to_module
VALUE
rb_to_module(VALUE self)
{
VALUE rclass, chain_start, jcur, klass;
switch(BUILTIN_TYPE(self)) {
case T_MODULE:
return self;
case T_CLASS:
klass = self;
break;
case T_OBJECT:
default:
klass = rb_singleton_class(self);
}
chain_start = j_class_new(klass, rb_cObject);
KLASS_OF(chain_start) = rb_cModule;
RBASIC(chain_start)->flags = T_MODULE;
jcur = chain_start;
for(rclass = RCLASS_SUPER(klass); rclass != rb_cObject;
rclass = RCLASS_SUPER(rclass)) {
RCLASS_SUPER(jcur) = j_class_new(rclass, rb_cObject);
jcur = RCLASS_SUPER(jcur);
}
RCLASS_SUPER(jcur) = (VALUE)NULL;
return chain_start;
}
开发者ID:RavensKrag,项目名称:texplay,代码行数:33,代码来源:object2module.c
示例4: 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
示例5: rb_extend_object
void
rb_extend_object(VALUE obj, VALUE module)
{
VALUE klass;
if (TYPE(obj) == T_CLASS && RCLASS_RUBY(obj)) {
VALUE sklass = rb_make_singleton_class(RCLASS_SUPER(obj));
RCLASS_SET_SUPER(obj, sklass);
klass = *(VALUE *)sklass;
}
else {
klass = rb_singleton_class(obj);
}
rb_include_module(klass, module);
VALUE m = module;
do {
VALUE ary = rb_attr_get(m, idIncludedModules);
if (ary != Qnil) {
for (int i = 0, count = RARRAY_LEN(ary); i < count; i++) {
VALUE mod = RARRAY_AT(ary, i);
rb_extend_object(obj, mod);
}
}
m = RCLASS_SUPER(m);
}
while (m == 0 || RCLASS_SINGLETON(m));
}
开发者ID:JosephKu,项目名称:MacRuby,代码行数:28,代码来源:eval.c
示例6: 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
示例7: 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
示例8: make_metaclass
/*!
* Creates a metaclass of \a klass
* \param klass a class
* \return created metaclass for the class
* \pre \a klass is a Class object
* \pre \a klass has no singleton class.
* \post the class of \a klass is the returned class.
* \post the returned class is meta^(n+1)-class when \a klass is a meta^(n)-klass for n >= 0
*/
static inline VALUE
make_metaclass(VALUE klass)
{
VALUE super;
VALUE metaclass = rb_class_boot(Qundef);
FL_SET(metaclass, FL_SINGLETON);
rb_singleton_class_attached(metaclass, klass);
if (META_CLASS_OF_CLASS_CLASS_P(klass)) {
METACLASS_OF(klass) = METACLASS_OF(metaclass) = metaclass;
}
else {
VALUE tmp = METACLASS_OF(klass); /* for a meta^(n)-class klass, tmp is meta^(n)-class of Class class */
METACLASS_OF(klass) = metaclass;
METACLASS_OF(metaclass) = ENSURE_EIGENCLASS(tmp);
}
super = RCLASS_SUPER(klass);
while (RB_TYPE_P(super, T_ICLASS)) super = RCLASS_SUPER(super);
RCLASS_SUPER(metaclass) = super ? ENSURE_EIGENCLASS(super) : rb_cClass;
OBJ_INFECT(metaclass, RCLASS_SUPER(metaclass));
return metaclass;
}
开发者ID:fi8on,项目名称:ruby,代码行数:35,代码来源:class.c
示例9: 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
示例10: 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
示例11: 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
示例12: rb_singleton_class_clone
VALUE
rb_singleton_class_clone(VALUE obj)
{
VALUE klass = RBASIC(obj)->klass;
if (!RCLASS_SINGLETON(klass)) {
return klass;
}
// Create new singleton class.
VALUE clone = rb_objc_create_class(NULL, RCLASS_SUPER(klass));
// Copy ivars.
CFMutableDictionaryRef ivar_dict = rb_class_ivar_dict(klass);
if (ivar_dict != NULL) {
CFMutableDictionaryRef cloned_ivar_dict =
CFDictionaryCreateMutableCopy(NULL, 0, (CFDictionaryRef)ivar_dict);
rb_class_ivar_set_dict(clone, cloned_ivar_dict);
CFMakeCollectable(cloned_ivar_dict);
}
// Copy methods.
rb_vm_copy_methods((Class)klass, (Class)clone);
rb_singleton_class_attached(clone, obj);
if (RCLASS_SUPER(clone) == rb_cRubyObject) {
long v = RCLASS_VERSION(clone) ^ RCLASS_IS_OBJECT_SUBCLASS;
RCLASS_SET_VERSION(clone, v);
}
RCLASS_SET_VERSION_FLAG(clone, RCLASS_IS_SINGLETON);
return clone;
}
开发者ID:MSch,项目名称:MacRuby,代码行数:31,代码来源:class.c
示例13: rb_mod_append_features
static VALUE
rb_mod_append_features(VALUE module, SEL sel, VALUE include)
{
VALUE orig = include;
switch (TYPE(include)) {
case T_CLASS:
case T_MODULE:
break;
default:
Check_Type(include, T_CLASS);
break;
}
if (RCLASS_RUBY(include)) {
VALUE sinclude = rb_make_singleton_class(RCLASS_SUPER(include));
RCLASS_SET_SUPER(include, sinclude);
include = sinclude;
}
rb_include_module2(include, orig, module, true, true);
VALUE m = module;
do {
VALUE ary = rb_attr_get(m, idIncludedModules);
if (ary != Qnil) {
for (int i = 0, count = RARRAY_LEN(ary); i < count; i++) {
VALUE mod = RARRAY_AT(ary, i);
rb_mod_append_features(mod, sel, include);
}
}
m = RCLASS_SUPER(m);
}
while (m == 0 || RCLASS_SINGLETON(m));
return module;
}
开发者ID:JosephKu,项目名称:MacRuby,代码行数:34,代码来源:eval.c
示例14: remove_nested_module
static void remove_nested_module(VALUE klass, VALUE module) {
if (CLASS_OF(RCLASS_SUPER(klass)) == CLASS_OF(RCLASS_SUPER(module))) {
if (RCLASS_SUPER(RCLASS_SUPER(module)) && BUILTIN_TYPE(RCLASS_SUPER(module)) == T_ICLASS) {
remove_nested_module(RCLASS_SUPER(klass), RCLASS_SUPER(module));
}
RCLASS_SUPER(klass) = RCLASS_SUPER(RCLASS_SUPER(klass));
}
}
开发者ID:meh,项目名称:blockenspiel,代码行数:8,代码来源:unmixer_mri.c
示例15: evilr__iclass_matching_before
/* Walk the super chain from klass until either before or an iclass for mod is encountered. If
* before is encountered first, return NULL. If an iclass for mod is encountered first, return
* the iclass. */
static VALUE evilr__iclass_matching_before(VALUE klass, VALUE mod, VALUE before) {
VALUE c;
for (c = RCLASS_SUPER(klass); c && c != before; c = RCLASS_SUPER(c)) {
if (BUILTIN_TYPE(c) == T_ICLASS && RBASIC_KLASS(c) == mod) {
return c;
}
}
return NULL;
}
开发者ID:jeremyevans,项目名称:evilr,代码行数:12,代码来源:evilr.c
示例16: rb_obj_superclass
static VALUE
rb_obj_superclass(VALUE klass, SEL sel)
{
VALUE cl = RCLASS_SUPER(klass);
while (rb_class_hidden(cl)) {
cl = RCLASS_SUPER(cl);
}
return rb_class_real(cl, true);
}
开发者ID:MSch,项目名称:MacRuby,代码行数:9,代码来源:class.c
示例17: remove_nested_module
static void remove_nested_module(VALUE klass, VALUE include_class)
{
if (KLASS_OF(RCLASS_SUPER(klass)) != KLASS_OF(RCLASS_SUPER(include_class))) {
return;
}
if (RCLASS_SUPER(RCLASS_SUPER(include_class)) && BUILTIN_TYPE(RCLASS_SUPER(include_class)) == T_ICLASS) {
remove_nested_module(RCLASS_SUPER(klass), RCLASS_SUPER(include_class));
}
RCLASS_SUPER(klass) = RCLASS_SUPER(RCLASS_SUPER(klass));
}
开发者ID:kristianmandrup,项目名称:mixology,代码行数:10,代码来源:mixology.c
示例18: rb_gsl_spline_info
static VALUE rb_gsl_spline_info(VALUE obj)
{
rb_gsl_spline *p = NULL;
char buf[256];
Data_Get_Struct(obj, rb_gsl_spline, p);
sprintf(buf, "Class: %s\n", rb_class2name(CLASS_OF(obj)));
sprintf(buf, "%sSuperClass: %s\n", buf, rb_class2name(RCLASS_SUPER(RCLASS_SUPER(obj))));
sprintf(buf, "%sType: %s\n", buf, gsl_interp_name(p->s->interp));
sprintf(buf, "%sxmin: %f\n", buf, p->s->interp->xmin);
sprintf(buf, "%sxmax: %f\n", buf, p->s->interp->xmax);
sprintf(buf, "%sSize: %d\n", buf, (int) p->s->size);
return rb_str_new2(buf);
}
开发者ID:Fudge,项目名称:rb-gsl,代码行数:13,代码来源:spline.c
示例19: 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:technohippy,项目名称:oruby,代码行数:13,代码来源:class.c
示例20: 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:technohippy,项目名称:oruby,代码行数:13,代码来源:class.c
注:本文中的RCLASS_SUPER函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论