зеркало из https://github.com/github/ruby.git
internal/class.h rework
This file has almost nothing to do. Added some #ifdef lines and rearranged file contents. Those macros are unable to translate into inline functions, because they are used as lvalues of assignments.
This commit is contained in:
Родитель
7d71d916a2
Коммит
63c9f620cf
|
@ -9,17 +9,23 @@
|
|||
* modify this file, provided that the conditions mentioned in the
|
||||
* file COPYING are met. Consult the file for details.
|
||||
*/
|
||||
#include "id_table.h" /* for struct rb_id_table */
|
||||
#include "internal/gc.h" /* for RB_OBJ_WRITE */
|
||||
#include "internal/serial.h" /* for rb_serial_t */
|
||||
#include "internal/stdbool.h" /* for bool */
|
||||
#include "ruby/intern.h" /* for rb_alloc_func_t */
|
||||
#include "ruby/ruby.h" /* for struct RBasic */
|
||||
|
||||
#undef RClass /* See also include/ruby/backward.h */
|
||||
#undef RCLASS_SUPER
|
||||
|
||||
struct rb_deprecated_classext_struct {
|
||||
char conflict[sizeof(VALUE) * 3];
|
||||
};
|
||||
|
||||
struct rb_subclass_entry;
|
||||
typedef struct rb_subclass_entry rb_subclass_entry_t;
|
||||
|
||||
struct rb_subclass_entry {
|
||||
VALUE klass;
|
||||
rb_subclass_entry_t *next;
|
||||
struct rb_subclass_entry *next;
|
||||
};
|
||||
|
||||
struct rb_classext_struct {
|
||||
|
@ -30,14 +36,14 @@ struct rb_classext_struct {
|
|||
#endif
|
||||
struct rb_id_table *const_tbl;
|
||||
struct rb_id_table *callable_m_tbl;
|
||||
rb_subclass_entry_t *subclasses;
|
||||
rb_subclass_entry_t **parent_subclasses;
|
||||
struct rb_subclass_entry *subclasses;
|
||||
struct rb_subclass_entry **parent_subclasses;
|
||||
/**
|
||||
* In the case that this is an `ICLASS`, `module_subclasses` points to the link
|
||||
* in the module's `subclasses` list that indicates that the klass has been
|
||||
* included. Hopefully that makes sense.
|
||||
*/
|
||||
rb_subclass_entry_t **module_subclasses;
|
||||
struct rb_subclass_entry **module_subclasses;
|
||||
#if SIZEOF_SERIAL_T != SIZEOF_VALUE /* otherwise class_serial is in struct RClass */
|
||||
rb_serial_t class_serial;
|
||||
#endif
|
||||
|
@ -47,13 +53,10 @@ struct rb_classext_struct {
|
|||
const VALUE includer;
|
||||
};
|
||||
|
||||
typedef struct rb_classext_struct rb_classext_t;
|
||||
|
||||
#undef RClass
|
||||
struct RClass {
|
||||
struct RBasic basic;
|
||||
VALUE super;
|
||||
rb_classext_t *ptr;
|
||||
struct rb_classext_struct *ptr;
|
||||
#if SIZEOF_SERIAL_T == SIZEOF_VALUE
|
||||
/* Class serial is as wide as VALUE. Place it here. */
|
||||
rb_serial_t class_serial;
|
||||
|
@ -63,28 +66,8 @@ struct RClass {
|
|||
#endif
|
||||
};
|
||||
|
||||
void rb_class_subclass_add(VALUE super, VALUE klass);
|
||||
void rb_class_remove_from_super_subclasses(VALUE);
|
||||
int rb_singleton_class_internal_p(VALUE sklass);
|
||||
/* class.c */
|
||||
VALUE rb_class_boot(VALUE);
|
||||
VALUE rb_class_inherited(VALUE, VALUE);
|
||||
VALUE rb_make_metaclass(VALUE, VALUE);
|
||||
VALUE rb_include_class_new(VALUE, VALUE);
|
||||
void rb_class_foreach_subclass(VALUE klass, void (*f)(VALUE, VALUE), VALUE);
|
||||
void rb_class_detach_subclasses(VALUE);
|
||||
void rb_class_detach_module_subclasses(VALUE);
|
||||
void rb_class_remove_from_module_subclasses(VALUE);
|
||||
VALUE rb_obj_methods(int argc, const VALUE *argv, VALUE obj);
|
||||
VALUE rb_obj_protected_methods(int argc, const VALUE *argv, VALUE obj);
|
||||
VALUE rb_obj_private_methods(int argc, const VALUE *argv, VALUE obj);
|
||||
VALUE rb_obj_public_methods(int argc, const VALUE *argv, VALUE obj);
|
||||
VALUE rb_special_singleton_class(VALUE);
|
||||
VALUE rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach);
|
||||
VALUE rb_singleton_class_get(VALUE obj);
|
||||
|
||||
int rb_class_has_methods(VALUE c);
|
||||
void rb_undef_methods_from(VALUE klass, VALUE super);
|
||||
typedef struct rb_subclass_entry rb_subclass_entry_t;
|
||||
typedef struct rb_classext_struct rb_classext_t;
|
||||
|
||||
#define RCLASS_EXT(c) (RCLASS(c)->ptr)
|
||||
#define RCLASS_IV_TBL(c) (RCLASS_EXT(c)->iv_tbl)
|
||||
|
@ -109,6 +92,36 @@ void rb_undef_methods_from(VALUE klass, VALUE super);
|
|||
#define RICLASS_IS_ORIGIN FL_USER5
|
||||
#define RCLASS_REFINED_BY_ANY FL_USER7
|
||||
|
||||
/* class.c */
|
||||
void rb_class_subclass_add(VALUE super, VALUE klass);
|
||||
void rb_class_remove_from_super_subclasses(VALUE);
|
||||
int rb_singleton_class_internal_p(VALUE sklass);
|
||||
VALUE rb_class_boot(VALUE);
|
||||
VALUE rb_make_metaclass(VALUE, VALUE);
|
||||
VALUE rb_include_class_new(VALUE, VALUE);
|
||||
void rb_class_foreach_subclass(VALUE klass, void (*f)(VALUE, VALUE), VALUE);
|
||||
void rb_class_detach_subclasses(VALUE);
|
||||
void rb_class_detach_module_subclasses(VALUE);
|
||||
void rb_class_remove_from_module_subclasses(VALUE);
|
||||
VALUE rb_obj_methods(int argc, const VALUE *argv, VALUE obj);
|
||||
VALUE rb_obj_protected_methods(int argc, const VALUE *argv, VALUE obj);
|
||||
VALUE rb_obj_private_methods(int argc, const VALUE *argv, VALUE obj);
|
||||
VALUE rb_obj_public_methods(int argc, const VALUE *argv, VALUE obj);
|
||||
VALUE rb_special_singleton_class(VALUE);
|
||||
VALUE rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach);
|
||||
VALUE rb_singleton_class_get(VALUE obj);
|
||||
int rb_class_has_methods(VALUE c);
|
||||
void rb_undef_methods_from(VALUE klass, VALUE super);
|
||||
static inline void RCLASS_SET_ORIGIN(VALUE klass, VALUE origin);
|
||||
static inline VALUE RCLASS_SUPER(VALUE klass);
|
||||
static inline VALUE RCLASS_SET_SUPER(VALUE klass, VALUE super);
|
||||
static inline void RCLASS_SET_INCLUDER(VALUE iclass, VALUE klass);
|
||||
|
||||
MJIT_SYMBOL_EXPORT_BEGIN
|
||||
VALUE rb_class_inherited(VALUE, VALUE);
|
||||
VALUE rb_keyword_error_new(const char *, VALUE);
|
||||
MJIT_SYMBOL_EXPORT_END
|
||||
|
||||
static inline void
|
||||
RCLASS_SET_ORIGIN(VALUE klass, VALUE origin)
|
||||
{
|
||||
|
@ -122,7 +135,6 @@ RCLASS_SET_INCLUDER(VALUE iclass, VALUE klass)
|
|||
RB_OBJ_WRITE(iclass, &RCLASS_INCLUDER(iclass), klass);
|
||||
}
|
||||
|
||||
#undef RCLASS_SUPER
|
||||
static inline VALUE
|
||||
RCLASS_SUPER(VALUE klass)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче