w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

class.h
Go to the documentation of this file.
1 /**
2 ** @file mruby/class.h - Class class
3 **
4 ** See Copyright Notice in mruby.h
5 */
6 
7 #ifndef MRUBY_CLASS_H
8 #define MRUBY_CLASS_H
9 
10 #include "common.h"
11 
12 /**
13  * Class class
14  */
16 
17 struct RClass {
19  struct iv_tbl *iv;
20  struct mt_tbl *mt;
21  struct RClass *super;
22 };
23 
24 #define mrb_class_ptr(v) ((struct RClass*)(mrb_ptr(v)))
25 
26 MRB_INLINE struct RClass*
28 {
29  switch (mrb_type(v)) {
30  case MRB_TT_FALSE:
31  if (mrb_fixnum(v))
32  return mrb->false_class;
33  return mrb->nil_class;
34  case MRB_TT_TRUE:
35  return mrb->true_class;
36  case MRB_TT_SYMBOL:
37  return mrb->symbol_class;
38  case MRB_TT_INTEGER:
39  return mrb->integer_class;
40 #ifndef MRB_NO_FLOAT
41  case MRB_TT_FLOAT:
42  return mrb->float_class;
43 #endif
44  case MRB_TT_CPTR:
45  return mrb->object_class;
46  case MRB_TT_ENV:
47  return NULL;
48  default:
49  return mrb_obj_ptr(v)->c;
50  }
51 }
52 
53 /* flags:
54  20: frozen
55  19: is_prepended
56  18: is_origin
57  17: is_inherited (used by method cache)
58  16: unused
59  0-15: instance type
60 */
61 #define MRB_FL_CLASS_IS_PREPENDED (1 << 19)
62 #define MRB_FL_CLASS_IS_ORIGIN (1 << 18)
63 #define MRB_CLASS_ORIGIN(c) do {\
64  if ((c)->flags & MRB_FL_CLASS_IS_PREPENDED) {\
65  (c) = (c)->super;\
66  while (!((c)->flags & MRB_FL_CLASS_IS_ORIGIN)) {\
67  (c) = (c)->super;\
68  }\
69  }\
70 } while (0)
71 #define MRB_FL_CLASS_IS_INHERITED (1 << 17)
72 #define MRB_INSTANCE_TT_MASK (0xFF)
73 #define MRB_SET_INSTANCE_TT(c, tt) ((c)->flags = (((c)->flags & ~MRB_INSTANCE_TT_MASK) | (char)(tt)))
74 #define MRB_INSTANCE_TT(c) (enum mrb_vtype)((c)->flags & MRB_INSTANCE_TT_MASK)
75 
81 
84 
85 MRB_API struct RClass* mrb_class_real(struct RClass* cl);
87 
88 void mrb_class_name_class(mrb_state*, struct RClass*, struct RClass*, mrb_sym);
92 void mrb_gc_mark_mt(mrb_state*, struct RClass*);
93 size_t mrb_gc_mark_mt_size(mrb_state*, struct RClass*);
94 void mrb_gc_free_mt(mrb_state*, struct RClass*);
95 
96 #ifndef MRB_NO_METHOD_CACHE
97 void mrb_mc_clear_by_class(mrb_state *mrb, struct RClass* c);
98 #else
99 #define mrb_mc_clear_by_class(mrb,c)
100 #endif
101 
102 /* return non zero to break the loop */
105 
107 
108 #endif /* MRUBY_CLASS_H */
#define mrb_fixnum(o)
Definition: boxing_nan.h:70
MRB_INLINE enum mrb_vtype mrb_type(mrb_value o)
Definition: boxing_word.h:195
void mrb_mc_clear_by_class(mrb_state *mrb, struct RClass *c)
Definition: class.c:1714
void mrb_define_method_raw(mrb_state *, struct RClass *, mrb_sym, mrb_method_t)
Definition: class.c:725
mrb_method_t mrb_method_search_vm(mrb_state *, struct RClass **, mrb_sym)
Definition: class.c:1730
struct RClass * mrb_vm_define_class(mrb_state *, mrb_value, mrb_value, mrb_sym)
Definition: class.c:556
void mrb_class_name_class(mrb_state *, struct RClass *, struct RClass *, mrb_sym)
Definition: class.c:294
void mrb_gc_free_mt(mrb_state *, struct RClass *)
Definition: class.c:288
mrb_method_t mrb_method_search(mrb_state *, struct RClass *, mrb_sym)
Definition: class.c:1778
mrb_bool mrb_const_name_p(mrb_state *, const char *, mrb_int)
Definition: class.c:324
void mrb_mt_foreach(mrb_state *, struct RClass *, mrb_mt_foreach_func *, void *)
Definition: class.c:225
mrb_value mrb_mod_to_s(mrb_state *, mrb_value)
Definition: class.c:2247
void mrb_remove_method(mrb_state *mrb, struct RClass *c, mrb_sym sym)
Definition: class.c:2314
mrb_value mrb_instance_new(mrb_state *mrb, mrb_value cv)
Definition: class.c:1923
void mrb_alias_method(mrb_state *, struct RClass *c, mrb_sym a, mrb_sym b)
Definition: class.c:2192
static struct RClass * mrb_class(mrb_state *mrb, mrb_value v)
Definition: class.h:27
struct RClass * mrb_vm_define_module(mrb_state *, mrb_value, mrb_sym)
Definition: class.c:454
size_t mrb_gc_mark_mt_size(mrb_state *, struct RClass *)
Definition: class.c:279
mrb_value mrb_class_find_path(mrb_state *, struct RClass *)
Definition: variable.c:1094
int() mrb_mt_foreach_func(mrb_state *, mrb_sym, mrb_method_t, void *)
Definition: class.h:103
void mrb_gc_mark_mt(mrb_state *, struct RClass *)
Definition: class.c:258
struct RClass * mrb_class_real(struct RClass *cl)
Definition: class.c:2091
#define b
Definition: jpegint.h:372
int v
Definition: dviconv.c:10
#define c(n)
Definition: gpos-common.c:150
#define a(n)
Definition: gpos-common.c:148
#define NULL
Definition: ftobjs.h:61
static const unsigned char cv[]
Definition: nkf.c:555
uintptr_t mrb_method_t
Definition: mruby.h:206
#define mrb_obj_ptr(v)
Definition: object.h:34
#define MRB_INLINE
Definition: common.h:62
#define MRB_END_DECL
Definition: common.h:28
#define MRB_BEGIN_DECL
Definition: common.h:26
#define MRB_API
Definition: common.h:73
Definition: class.h:17
struct RClass * super
Definition: class.h:21
struct mt_tbl * mt
Definition: class.h:20
MRB_OBJECT_HEADER
Definition: class.h:18
struct iv_tbl * iv
Definition: class.h:19
struct RClass * true_class
Definition: mruby.h:255
struct RClass * symbol_class
Definition: mruby.h:258
struct RClass * object_class
Definition: mruby.h:242
struct RClass * false_class
Definition: mruby.h:256
struct RClass * float_class
Definition: mruby.h:252
struct RClass * nil_class
Definition: mruby.h:257
struct RClass * integer_class
Definition: mruby.h:254
Definition: class.c:35
return() int(((double) *(font_tbl[cur_fnt].wtbl+(int)(*(font_tbl[cur_fnt].char_wi+(int)(ch - font_tbl[cur_fnt].char_f)% 256)))/(double)(1L<< 20)) *(double) font_tbl[cur_fnt].scale)
int32_t mrb_int
Definition: value.h:35
uint32_t mrb_sym
Definition: value.h:23
@ MRB_TT_TRUE
Definition: value.h:109
@ MRB_TT_FALSE
Definition: value.h:108
@ MRB_TT_SYMBOL
Definition: value.h:112
@ MRB_TT_CPTR
Definition: value.h:114
@ MRB_TT_FLOAT
Definition: value.h:110
@ MRB_TT_INTEGER
Definition: value.h:111
@ MRB_TT_ENV
Definition: value.h:127
#define sym(x)
Definition: y.tab.c:133