Ruby  2.1.3p242(2014-09-19revision47630)
method.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  method.h -
4 
5  $Author: tmm1 $
6  created at: Wed Jul 15 20:02:33 2009
7 
8  Copyright (C) 2009 Koichi Sasada
9 
10 **********************************************************************/
11 #ifndef METHOD_H
12 #define METHOD_H
13 
14 #include "internal.h"
15 
16 #ifndef END_OF_ENUMERATION
17 # if defined(__GNUC__) &&! defined(__STRICT_ANSI__)
18 # define END_OF_ENUMERATION(key)
19 # else
20 # define END_OF_ENUMERATION(key) END_OF_##key##_PLACEHOLDER = 0
21 # endif
22 #endif
23 
24 typedef enum {
25  NOEX_PUBLIC = 0x00,
26  NOEX_NOSUPER = 0x01,
27  NOEX_PRIVATE = 0x02,
29  NOEX_MASK = 0x06,
30  NOEX_BASIC = 0x08,
32  NOEX_MODFUNC = 0x12,
33  NOEX_SUPER = 0x20,
34  NOEX_VCALL = 0x40,
35  NOEX_RESPONDS = 0x80,
36 
38  NOEX_SAFE_SHIFT_OFFSET = ((NOEX_BIT_WIDTH+3)/4)*4 /* round up to nibble */
40 
41 #define NOEX_SAFE(n) ((int)((n) >> NOEX_SAFE_SHIFT_OFFSET) & 0x0F)
42 #define NOEX_WITH(n, s) (((s) << NOEX_SAFE_SHIFT_OFFSET) | (n) | (ruby_running ? 0 : NOEX_BASIC))
43 #define NOEX_WITH_SAFE(n) NOEX_WITH((n), rb_safe_level())
44 
45 /* method data type */
46 
47 typedef enum {
56  VM_METHOD_TYPE_OPTIMIZED, /* Kernel#send, Proc#call, etc */
57  VM_METHOD_TYPE_MISSING, /* wrapper for method_missing(id) */
59 
60  END_OF_ENUMERATION(VM_METHOD_TYPE)
62 
63 struct rb_call_info_struct;
64 
65 typedef struct rb_method_cfunc_struct {
67  VALUE (*invoker)(VALUE (*func)(ANYARGS), VALUE recv, int argc, const VALUE *argv);
68  int argc;
70 
71 typedef struct rb_method_attr_struct {
72  ID id;
73  const VALUE location;
75 
76 typedef struct rb_iseq_struct rb_iseq_t;
77 
79  rb_method_type_t type; /* method type */
81  union {
82  rb_iseq_t * const iseq; /* should be mark */
85  const VALUE proc; /* should be mark */
86  enum method_optimized_type {
89 
91  } optimize_type;
93  } body;
96 
97 typedef struct rb_method_entry_struct {
99  char mark;
102  VALUE klass; /* should be mark */
104 
108 };
109 
110 #define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)
111 
112 void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex);
114 rb_method_entry_t *rb_method_entry(VALUE klass, ID id, VALUE *define_class_ptr);
116 void rb_add_refined_method_entry(VALUE refined_class, ID mid);
118  const rb_method_entry_t *me,
119  VALUE *defined_class_ptr);
121  VALUE *defined_class_ptr);
123  VALUE *defined_class_ptr);
124 
125 rb_method_entry_t *rb_method_entry_get_without_cache(VALUE klass, ID id, VALUE *define_class_ptr);
127 
129 int rb_method_entry_eq(const rb_method_entry_t *m1, const rb_method_entry_t *m2);
131 
135 
138 void rb_sweep_method_entry(void *vm);
139 void rb_free_m_tbl(st_table *tbl);
140 void rb_free_m_tbl_wrapper(struct method_table_wrapper *wrapper);
141 
142 #endif /* METHOD_H */
143