|
| 1 | +/** |
| 2 | +** @file mruby/internal.h - Functions only called from within the library |
| 3 | +** |
| 4 | +** See Copyright Notice in mruby.h |
| 5 | +*/ |
| 6 | + |
| 7 | +#ifndef MRUBY_INTERNAL_H |
| 8 | +#define MRUBY_INTERNAL_H |
| 9 | + |
| 10 | +#ifdef MRUBY_ARRAY_H |
| 11 | +void mrb_ary_decref(mrb_state*, mrb_shared_array*); |
| 12 | +mrb_value mrb_ary_subseq(mrb_state *mrb, mrb_value ary, mrb_int beg, mrb_int len); |
| 13 | +#endif |
| 14 | + |
| 15 | +#ifdef MRUBY_CLASS_H |
| 16 | +struct RClass *mrb_vm_define_class(mrb_state*, mrb_value, mrb_value, mrb_sym); |
| 17 | +struct RClass *mrb_vm_define_module(mrb_state*, mrb_value, mrb_sym); |
| 18 | +mrb_value mrb_instance_new(mrb_state *mrb, mrb_value cv); |
| 19 | +void mrb_class_name_class(mrb_state*, struct RClass*, struct RClass*, mrb_sym); |
| 20 | +mrb_bool mrb_const_name_p(mrb_state*, const char*, mrb_int); |
| 21 | +mrb_value mrb_class_find_path(mrb_state*, struct RClass*); |
| 22 | +mrb_value mrb_mod_to_s(mrb_state *, mrb_value); |
| 23 | +void mrb_method_added(mrb_state *mrb, struct RClass *c, mrb_sym mid); |
| 24 | +#endif |
| 25 | + |
| 26 | +/* debug */ |
| 27 | +size_t mrb_packed_int_len(uint32_t num); |
| 28 | +size_t mrb_packed_int_encode(uint32_t num, uint8_t *p, uint8_t *pend); |
| 29 | +uint32_t mrb_packed_int_decode(const uint8_t *p, const uint8_t **newpos); |
| 30 | + |
| 31 | +/* dump */ |
| 32 | +#ifdef MRUBY_IREP_H |
| 33 | +int mrb_dump_irep(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, uint8_t **bin, size_t *bin_size); |
| 34 | +#ifndef MRB_NO_STDIO |
| 35 | +int mrb_dump_irep_binary(mrb_state*, const mrb_irep*, uint8_t, FILE*); |
| 36 | +int mrb_dump_irep_cfunc(mrb_state *mrb, const mrb_irep*, uint8_t flags, FILE *f, const char *initname); |
| 37 | +int mrb_dump_irep_cstruct(mrb_state *mrb, const mrb_irep*, uint8_t flags, FILE *f, const char *initname); |
| 38 | +mrb_irep *mrb_read_irep_file(mrb_state*, FILE*); |
| 39 | +#endif |
| 40 | +#endif |
| 41 | + |
| 42 | +/* error */ |
| 43 | +mrb_value mrb_exc_inspect(mrb_state *mrb, mrb_value exc); |
| 44 | +mrb_value mrb_exc_backtrace(mrb_state *mrb, mrb_value exc); |
| 45 | +mrb_value mrb_get_backtrace(mrb_state *mrb); |
| 46 | +void mrb_exc_mesg_set(mrb_state *mrb, struct RException *exc, mrb_value mesg); |
| 47 | +mrb_value mrb_exc_mesg_get(mrb_state *mrb, struct RException *exc); |
| 48 | + |
| 49 | +/* gc */ |
| 50 | +void mrb_gc_mark_mt(mrb_state*, struct RClass*); |
| 51 | +size_t mrb_gc_mark_mt_size(mrb_state*, struct RClass*); |
| 52 | +void mrb_gc_free_mt(mrb_state*, struct RClass*); |
| 53 | + |
| 54 | +/* hash */ |
| 55 | +size_t mrb_hash_memsize(mrb_value obj); |
| 56 | +void mrb_gc_mark_hash(mrb_state*, struct RHash*); |
| 57 | +size_t mrb_gc_mark_hash_size(mrb_state*, struct RHash*); |
| 58 | +void mrb_gc_free_hash(mrb_state*, struct RHash*); |
| 59 | + |
| 60 | +/* irep */ |
| 61 | +struct mrb_insn_data mrb_decode_insn(const mrb_code *pc); |
| 62 | +#ifdef MRUBY_IREP_H |
| 63 | +void mrb_irep_free(mrb_state*, struct mrb_irep*); |
| 64 | +void mrb_irep_incref(mrb_state*, struct mrb_irep*); |
| 65 | +void mrb_irep_decref(mrb_state*, struct mrb_irep*); |
| 66 | +void mrb_irep_cutref(mrb_state*, struct mrb_irep*); |
| 67 | +void mrb_irep_remove_lv(mrb_state *mrb, mrb_irep *irep); |
| 68 | + |
| 69 | +static inline const struct mrb_irep_catch_handler * |
| 70 | +mrb_irep_catch_handler_table(const struct mrb_irep *irep) |
| 71 | +{ |
| 72 | + if (irep->clen > 0) { |
| 73 | + return (const struct mrb_irep_catch_handler*)(irep->iseq + irep->ilen); |
| 74 | + } |
| 75 | + else { |
| 76 | + return (const struct mrb_irep_catch_handler*)NULL; |
| 77 | + } |
| 78 | +} |
| 79 | +#endif |
| 80 | + |
| 81 | +/* numeric */ |
| 82 | +mrb_int mrb_div_int(mrb_state *mrb, mrb_int x, mrb_int y); |
| 83 | +mrb_value mrb_int_add(mrb_state *mrb, mrb_value x, mrb_value y); |
| 84 | +mrb_value mrb_int_sub(mrb_state *mrb, mrb_value x, mrb_value y); |
| 85 | +mrb_value mrb_int_mul(mrb_state *mrb, mrb_value x, mrb_value y); |
| 86 | + |
| 87 | +#ifdef MRB_USE_COMPLEX |
| 88 | +mrb_value mrb_complex_new(mrb_state *mrb, mrb_float x, mrb_float y); |
| 89 | +mrb_value mrb_complex_add(mrb_state *mrb, mrb_value x, mrb_value y); |
| 90 | +mrb_value mrb_complex_sub(mrb_state *mrb, mrb_value x, mrb_value y); |
| 91 | +mrb_value mrb_complex_mul(mrb_state *mrb, mrb_value x, mrb_value y); |
| 92 | +mrb_value mrb_complex_div(mrb_state *mrb, mrb_value x, mrb_value y); |
| 93 | +#endif |
| 94 | +#ifdef MRB_USE_RATIONAL |
| 95 | +mrb_value mrb_rational_new(mrb_state *mrb, mrb_int x, mrb_int y); |
| 96 | +mrb_value mrb_rational_add(mrb_state *mrb, mrb_value x, mrb_value y); |
| 97 | +mrb_value mrb_rational_sub(mrb_state *mrb, mrb_value x, mrb_value y); |
| 98 | +mrb_value mrb_rational_mul(mrb_state *mrb, mrb_value x, mrb_value y); |
| 99 | +mrb_value mrb_rational_div(mrb_state *mrb, mrb_value x, mrb_value y); |
| 100 | +#endif |
| 101 | + |
| 102 | +#ifdef MRUBY_PROC_H |
| 103 | +struct RProc *mrb_proc_new(mrb_state*, const mrb_irep*); |
| 104 | +struct RProc *mrb_closure_new(mrb_state*, const mrb_irep*); |
| 105 | +void mrb_proc_copy(mrb_state *mrb, struct RProc *a, struct RProc *b); |
| 106 | +mrb_int mrb_proc_arity(const struct RProc *p); |
| 107 | +#endif |
| 108 | + |
| 109 | +/* range */ |
| 110 | +#ifdef MRUBY_RANGE_H |
| 111 | +mrb_value mrb_get_values_at(mrb_state *mrb, mrb_value obj, mrb_int olen, mrb_int argc, const mrb_value *argv, mrb_value (*func)(mrb_state*, mrb_value, mrb_int)); |
| 112 | +void mrb_gc_mark_range(mrb_state *mrb, struct RRange *r); |
| 113 | +#endif |
| 114 | + |
| 115 | +/* string */ |
| 116 | +void mrb_gc_free_str(mrb_state*, struct RString*); |
| 117 | +uint32_t mrb_str_hash(mrb_state *mrb, mrb_value str); |
| 118 | +mrb_value mrb_str_dump(mrb_state *mrb, mrb_value str); |
| 119 | +mrb_value mrb_str_inspect(mrb_state *mrb, mrb_value str); |
| 120 | +mrb_bool mrb_str_beg_len(mrb_int str_len, mrb_int *begp, mrb_int *lenp); |
| 121 | +mrb_value mrb_str_byte_subseq(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len); |
| 122 | +mrb_value mrb_str_aref(mrb_state *mrb, mrb_value str, mrb_value idx, mrb_value len); |
| 123 | + |
| 124 | +#ifdef MRB_UTF8_STRING |
| 125 | +mrb_int mrb_utf8len(const char *str, const char *end); |
| 126 | +mrb_int mrb_utf8_strlen(const char *str, mrb_int byte_len); |
| 127 | +#endif |
| 128 | + |
| 129 | +/* variable */ |
| 130 | +mrb_value mrb_vm_special_get(mrb_state*, mrb_sym); |
| 131 | +void mrb_vm_special_set(mrb_state*, mrb_sym, mrb_value); |
| 132 | +mrb_value mrb_vm_cv_get(mrb_state*, mrb_sym); |
| 133 | +void mrb_vm_cv_set(mrb_state*, mrb_sym, mrb_value); |
| 134 | +mrb_value mrb_vm_const_get(mrb_state*, mrb_sym); |
| 135 | +void mrb_vm_const_set(mrb_state*, mrb_sym, mrb_value); |
| 136 | +size_t mrb_obj_iv_tbl_memsize(mrb_value); |
| 137 | +mrb_value mrb_obj_iv_inspect(mrb_state*, struct RObject*); |
| 138 | +void mrb_obj_iv_set_force(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v); |
| 139 | +mrb_value mrb_mod_constants(mrb_state *mrb, mrb_value mod); |
| 140 | +mrb_value mrb_f_global_variables(mrb_state *mrb, mrb_value self); |
| 141 | +mrb_value mrb_obj_instance_variables(mrb_state*, mrb_value); |
| 142 | +mrb_value mrb_mod_class_variables(mrb_state*, mrb_value); |
| 143 | +mrb_value mrb_mod_cv_get(mrb_state *mrb, struct RClass * c, mrb_sym sym); |
| 144 | +mrb_bool mrb_mod_cv_defined(mrb_state *mrb, struct RClass * c, mrb_sym sym); |
| 145 | +mrb_bool mrb_ident_p(const char *s, mrb_int len); |
| 146 | + |
| 147 | +/* GC functions */ |
| 148 | +void mrb_gc_mark_gv(mrb_state*); |
| 149 | +void mrb_gc_free_gv(mrb_state*); |
| 150 | +void mrb_gc_mark_iv(mrb_state*, struct RObject*); |
| 151 | +size_t mrb_gc_mark_iv_size(mrb_state*, struct RObject*); |
| 152 | +void mrb_gc_free_iv(mrb_state*, struct RObject*); |
| 153 | + |
| 154 | +/* VM */ |
| 155 | +mrb_int mrb_ci_bidx(mrb_callinfo *ci); |
| 156 | + |
| 157 | +#endif /* MRUBY_INTERNAL_H */ |
0 commit comments