Changeset 331 for EcnlProtoTool/trunk/mruby-1.3.0/include/mruby
- Timestamp:
- Jan 21, 2018, 12:10:09 AM (6 years ago)
- Location:
- EcnlProtoTool/trunk/mruby-1.3.0
- Files:
-
- 1 added
- 25 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/array.h
r321 r331 8 8 #define MRUBY_ARRAY_H 9 9 10 #include " mruby/common.h"10 #include "common.h" 11 11 12 12 /* … … 55 55 * 56 56 * @param mrb The mruby state reference. 57 * @return The initialized array 57 * @return The initialized array. 58 58 */ 59 59 MRB_API mrb_value mrb_ary_new(mrb_state *mrb); 60 60 61 /* 62 * Initializes a new array with initial values 63 * 64 * Equivalent to: 65 * 66 * Array[value1, value2, ...] 67 * 68 * @param mrb The mruby state reference. 69 * @param size The numer of values. 70 * @param vals The actual values. 71 * @return The initialized array. 72 */ 61 73 MRB_API mrb_value mrb_ary_new_from_values(mrb_state *mrb, mrb_int size, const mrb_value *vals); 74 75 /* 76 * Initializes a new array with two initial values 77 * 78 * Equivalent to: 79 * 80 * Array[car, cdr] 81 * 82 * @param mrb The mruby state reference. 83 * @param car The first value. 84 * @param cdr The second value. 85 * @return The initialized array. 86 */ 62 87 MRB_API mrb_value mrb_assoc_new(mrb_state *mrb, mrb_value car, mrb_value cdr); 63 MRB_API void mrb_ary_concat(mrb_state*, mrb_value, mrb_value); 64 MRB_API mrb_value mrb_ary_splat(mrb_state*, mrb_value); 88 89 /* 90 * Concatenate two arrays. The target array will be modified 91 * 92 * Equivalent to: 93 * ary.concat(other) 94 * 95 * @param mrb The mruby state reference. 96 * @param self The target array. 97 * @param other The array that will be concatenated to self. 98 */ 99 MRB_API void mrb_ary_concat(mrb_state *mrb, mrb_value self, mrb_value other); 100 101 /* 102 * Create an array from the input. It tries calling to_a on the 103 * value. If value does not respond to that, it creates a new 104 * array with just this value. 105 * 106 * @param mrb The mruby state reference. 107 * @param value The value to change into an array. 108 * @return An array representation of value. 109 */ 110 MRB_API mrb_value mrb_ary_splat(mrb_state *mrb, mrb_value value); 65 111 66 112 /* … … 85 131 * 86 132 * @param mrb The mruby state reference. 87 * @param ary The array from which the value will be pop ed.88 * @return The pop ed value.133 * @param ary The array from which the value will be popped. 134 * @return The popped value. 89 135 */ 90 136 MRB_API mrb_value mrb_ary_pop(mrb_state *mrb, mrb_value ary); … … 118 164 MRB_API void mrb_ary_set(mrb_state *mrb, mrb_value ary, mrb_int n, mrb_value val); 119 165 120 MRB_API void mrb_ary_replace(mrb_state *mrb, mrb_value a, mrb_value b); 166 /* 167 * Replace the array with another array 168 * 169 * Equivalent to: 170 * 171 * ary.replace(other) 172 * 173 * @param mrb The mruby state reference 174 * @param self The target array. 175 * @param other The array to replace it with. 176 */ 177 MRB_API void mrb_ary_replace(mrb_state *mrb, mrb_value self, mrb_value other); 121 178 MRB_API mrb_value mrb_check_array_type(mrb_state *mrb, mrb_value self); 179 180 /* 181 * Unshift an element into an array 182 * 183 * Equivalent to: 184 * 185 * ary.unshift(item) 186 * 187 * @param mrb The mruby state reference. 188 * @param self The target array. 189 * @param item The item to unshift. 190 */ 122 191 MRB_API mrb_value mrb_ary_unshift(mrb_state *mrb, mrb_value self, mrb_value item); 123 192 MRB_API mrb_value mrb_ary_entry(mrb_value ary, mrb_int offset); 193 194 /* 195 * Shifts the first element from the array. 196 * 197 * Equivalent to: 198 * 199 * ary.shift 200 * 201 * @param mrb The mruby state reference. 202 * @param self The array from which the value will be shifted. 203 * @return The shifted value. 204 */ 124 205 MRB_API mrb_value mrb_ary_shift(mrb_state *mrb, mrb_value self); 206 207 /* 208 * Removes all elements from this array 209 * 210 * Equivalent to: 211 * 212 * ary.clear 213 * 214 * @param mrb The mruby state reference. 215 * @param self The target array. 216 * @return self 217 */ 125 218 MRB_API mrb_value mrb_ary_clear(mrb_state *mrb, mrb_value self); 219 220 /* 221 * Join the array elements together in a string 222 * 223 * Equivalent to: 224 * 225 * ary.join(sep="") 226 * 227 * @param mrb The mruby state reference. 228 * @param ary The target array 229 * @param sep The separater, can be NULL 230 */ 126 231 MRB_API mrb_value mrb_ary_join(mrb_state *mrb, mrb_value ary, mrb_value sep); 127 MRB_API mrb_value mrb_ary_resize(mrb_state *mrb, mrb_value ary, mrb_int len); 232 233 /* 234 * Update the capacity of the array 235 * 236 * @param mrb The mruby state reference. 237 * @param ary The target array. 238 * @param new_len The new capacity of the array 239 */ 240 MRB_API mrb_value mrb_ary_resize(mrb_state *mrb, mrb_value ary, mrb_int new_len); 128 241 129 242 static inline mrb_int … … 135 248 } 136 249 250 static inline mrb_value 251 ary_elt(mrb_value ary, mrb_int offset) 252 { 253 if (offset < 0 || RARRAY_LEN(ary) <= offset) { 254 return mrb_nil_value(); 255 } 256 return RARRAY_PTR(ary)[offset]; 257 } 258 137 259 MRB_END_DECL 138 260 -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/boxing_nan.h
r321 r331 54 54 55 55 #define mrb_tt(o) ((enum mrb_vtype)(((o).value.ttt & 0xfc000)>>14)-1) 56 #define mrb_type(o) ( (uint32_t)0xfff00000 < (o).value.ttt ? mrb_tt(o) : MRB_TT_FLOAT)56 #define mrb_type(o) (enum mrb_vtype)((uint32_t)0xfff00000 < (o).value.ttt ? mrb_tt(o) : MRB_TT_FLOAT) 57 57 #define mrb_ptr(o) ((void*)((((uintptr_t)0x3fffffffffff)&((uintptr_t)((o).value.p)))<<2)) 58 58 #define mrb_float(o) (o).f … … 61 61 #define mrb_symbol(o) (o).value.sym 62 62 63 #ifdef MRB_64BIT 64 #define BOXNAN_SHIFT_LONG_POINTER(v) (((uintptr_t)(v)>>34)&0x3fff) 65 #else 66 #define BOXNAN_SHIFT_LONG_POINTER(v) 0 67 #endif 68 63 69 #define BOXNAN_SET_VALUE(o, tt, attr, v) do {\ 64 switch (tt) {\ 65 case MRB_TT_FALSE:\ 66 case MRB_TT_TRUE:\ 67 case MRB_TT_UNDEF:\ 68 case MRB_TT_FIXNUM:\ 69 case MRB_TT_SYMBOL: (o).attr = (v); break;\ 70 default: (o).value.i = 0; (o).value.p = (void*)((uintptr_t)(o).value.p | (((uintptr_t)(v))>>2)); break;\ 71 }\ 72 (o).value.ttt = (0xfff00000|(((tt)+1)<<14));\ 70 (o).attr = (v);\ 71 (o).value.ttt = 0xfff00000 | (((tt)+1)<<14);\ 72 } while (0) 73 74 #define BOXNAN_SET_OBJ_VALUE(o, tt, v) do {\ 75 (o).value.p = (void*)((uintptr_t)(v)>>2);\ 76 (o).value.ttt = (0xfff00000|(((tt)+1)<<14)|BOXNAN_SHIFT_LONG_POINTER(v));\ 73 77 } while (0) 74 78 … … 77 81 (r).value.ttt = 0x7ff80000; \ 78 82 (r).value.i = 0; \ 79 } else { \ 83 } \ 84 else { \ 80 85 (r).f = v; \ 81 86 }} while(0) … … 87 92 #define SET_INT_VALUE(r,n) BOXNAN_SET_VALUE(r, MRB_TT_FIXNUM, value.i, (n)) 88 93 #define SET_SYM_VALUE(r,v) BOXNAN_SET_VALUE(r, MRB_TT_SYMBOL, value.sym, (v)) 89 #define SET_OBJ_VALUE(r,v) BOXNAN_SET_ VALUE(r, (((struct RObject*)(v))->tt), value.p, (v))90 #define SET_CPTR_VALUE(mrb,r,v) BOXNAN_SET_ VALUE(r, MRB_TT_CPTR, value.p, v)94 #define SET_OBJ_VALUE(r,v) BOXNAN_SET_OBJ_VALUE(r, (((struct RObject*)(v))->tt), (v)) 95 #define SET_CPTR_VALUE(mrb,r,v) BOXNAN_SET_OBJ_VALUE(r, MRB_TT_CPTR, v) 91 96 #define SET_UNDEF_VALUE(r) BOXNAN_SET_VALUE(r, MRB_TT_UNDEF, value.i, 0) 92 97 -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/boxing_word.h
r321 r331 10 10 #if defined(MRB_INT16) 11 11 # error MRB_INT16 is too small for MRB_WORD_BOXING. 12 #endif 13 14 #if defined(MRB_INT64) && !defined(MRB_64BIT) 15 #error MRB_INT64 cannot be used with MRB_WORD_BOXING in 32-bit mode. 12 16 #endif 13 17 … … 63 67 #define mrb_cptr(o) (o).value.vp->p 64 68 #define mrb_float(o) (o).value.fp->f 65 #define mrb_fixnum(o) ( o).value.i69 #define mrb_fixnum(o) ((mrb_int)(o).value.i) 66 70 #define mrb_symbol(o) (o).value.sym 67 71 … … 92 96 #define mrb_nil_p(o) ((o).w == MRB_Qnil) 93 97 94 #define BOXWORD_SET_VALUE(o, ttt, attr, v) do { \98 #define BOXWORD_SET_VALUE(o, ttt, attr, v) do { \ 95 99 switch (ttt) {\ 96 100 case MRB_TT_FALSE: (o).w = (v) ? MRB_Qfalse : MRB_Qnil; break;\ 97 101 case MRB_TT_TRUE: (o).w = MRB_Qtrue; break;\ 98 102 case MRB_TT_UNDEF: (o).w = MRB_Qundef; break;\ 99 case MRB_TT_FIXNUM: (o). value.i_flag = MRB_FIXNUM_FLAG; (o).attr = (v); break;\100 case MRB_TT_SYMBOL: (o). value.sym_flag = MRB_SYMBOL_FLAG; (o).attr = (v); break;\103 case MRB_TT_FIXNUM: (o).w = 0;(o).value.i_flag = MRB_FIXNUM_FLAG; (o).attr = (v); break;\ 104 case MRB_TT_SYMBOL: (o).w = 0;(o).value.sym_flag = MRB_SYMBOL_FLAG; (o).attr = (v); break;\ 101 105 default: (o).w = 0; (o).attr = (v); if ((o).value.bp) (o).value.bp->tt = ttt; break;\ 102 106 }\ -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/class.h
r321 r331 8 8 #define MRUBY_CLASS_H 9 9 10 #include " mruby/common.h"10 #include "common.h" 11 11 12 12 /** … … 52 52 } 53 53 54 // TODO: figure out where to put user flags 54 /* TODO: figure out where to put user flags */ 55 #define MRB_FLAG_IS_FROZEN (1 << 18) 55 56 #define MRB_FLAG_IS_PREPENDED (1 << 19) 56 57 #define MRB_FLAG_IS_ORIGIN (1 << 20) -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/common.h
r321 r331 1 1 /* 2 ** mruby/common.h - mruby common platform definitions2 **"common.h - mruby common platform definition" 3 3 ** 4 4 ** See Copyright Notice in mruby.h … … 10 10 11 11 #ifdef __cplusplus 12 #ifdef MRB_ENABLE_CXX_ABI 13 #define MRB_BEGIN_DECL 14 #define MRB_END_DECL 15 #else 12 16 # define MRB_BEGIN_DECL extern "C" { 13 17 # define MRB_END_DECL } 18 #endif 14 19 #else 15 20 /** Start declarations in C mode */ -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/compile.h
r321 r331 8 8 #define MRUBY_COMPILE_H 9 9 10 #include " mruby/common.h"10 #include "common.h" 11 11 12 12 /** … … 15 15 MRB_BEGIN_DECL 16 16 17 #include "mruby.h"17 #include <mruby.h> 18 18 19 19 struct mrb_jmpbuf; … … 40 40 MRB_API const char *mrbc_filename(mrb_state *mrb, mrbc_context *c, const char *s); 41 41 MRB_API void mrbc_partial_hook(mrb_state *mrb, mrbc_context *c, int (*partial_hook)(struct mrb_parser_state*), void*data); 42 43 MRB_API mrb_value mrb_toplevel_run_keep(mrb_state*, struct RProc*, unsigned int);44 42 45 43 /* AST node structure */ … … 105 103 }; 106 104 107 #define MRB_PARSER_BUF_SIZE 1024 105 #define MRB_PARSER_TOKBUF_MAX 65536 106 #define MRB_PARSER_TOKBUF_SIZE 256 108 107 109 108 /* parser structure */ … … 133 132 134 133 mrb_ast_node *pb; 135 char buf[MRB_PARSER_BUF_SIZE]; 136 int bidx; 134 char *tokbuf; 135 char buf[MRB_PARSER_TOKBUF_SIZE]; 136 int tidx; 137 int tsiz; 137 138 138 139 mrb_ast_node *all_heredocs; /* list of mrb_parser_heredoc_info* */ … … 163 164 MRB_API void mrb_parser_free(struct mrb_parser_state*); 164 165 MRB_API void mrb_parser_parse(struct mrb_parser_state*,mrbc_context*); 166 MRB_API double mrb_float_read(const char*, char**); 165 167 166 168 MRB_API void mrb_parser_set_filename(struct mrb_parser_state*, char const*); … … 174 176 MRB_API struct mrb_parser_state* mrb_parse_nstring(mrb_state*,const char*,int,mrbc_context*); 175 177 MRB_API struct RProc* mrb_generate_code(mrb_state*, struct mrb_parser_state*); 178 MRB_API mrb_value mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c); 176 179 177 180 /* program load functions */ -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/data.h
r321 r331 8 8 #define MRUBY_DATA_H 9 9 10 #include " mruby/common.h"10 #include "common.h" 11 11 12 12 /** -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/debug.h
r321 r331 8 8 #define MRUBY_DEBUG_H 9 9 10 #include " mruby/common.h"10 #include "common.h" 11 11 12 12 /** -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/dump.h
r321 r331 8 8 #define MRUBY_DUMP_H 9 9 10 #include "mruby.h"11 #include "mruby/irep.h"12 #include " mruby/common.h"10 #include <mruby.h> 11 #include <mruby/irep.h> 12 #include "common.h" 13 13 14 14 /** … … 53 53 #define RITE_BINARY_IDENT "RITE" 54 54 #define RITE_BINARY_IDENT_LIL "ETIR" 55 #define RITE_BINARY_FORMAT_VER "000 3"55 #define RITE_BINARY_FORMAT_VER "0004" 56 56 #define RITE_COMPILER_NAME "MATZ" 57 57 #define RITE_COMPILER_VERSION "0000" -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/error.h
r321 r331 8 8 #define MRUBY_ERROR_H 9 9 10 #include " mruby/common.h"10 #include "common.h" 11 11 12 12 /** … … 32 32 /* declaration for fail method */ 33 33 MRB_API mrb_value mrb_f_raise(mrb_state*, mrb_value); 34 35 struct RBreak { 36 MRB_OBJECT_HEADER; 37 struct iv_tbl *iv; 38 struct RProc *proc; 39 mrb_value val; 40 }; 34 41 35 42 /** -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/gc.h
r321 r331 8 8 #define MRUBY_GC_H 9 9 10 #include " mruby/common.h"10 #include "common.h" 11 11 12 12 /** … … 18 18 struct mrb_state; 19 19 20 typedef void (mrb_each_object_callback)(struct mrb_state *mrb, struct RBasic *obj, void *data); 20 #define MRB_EACH_OBJ_OK 0 21 #define MRB_EACH_OBJ_BREAK 1 22 typedef int (mrb_each_object_callback)(struct mrb_state *mrb, struct RBasic *obj, void *data); 21 23 void mrb_objspace_each_objects(struct mrb_state *mrb, mrb_each_object_callback *callback, void *data); 22 24 MRB_API void mrb_free_context(struct mrb_state *mrb, struct mrb_context *c); … … 63 65 int interval_ratio; 64 66 int step_ratio; 67 mrb_bool iterating :1; 65 68 mrb_bool disabled :1; 66 69 mrb_bool full :1; -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/hash.h
r321 r331 8 8 #define MRUBY_HASH_H 9 9 10 #include "mruby/common.h" 10 #include "common.h" 11 #include <mruby/khash.h> 11 12 12 13 /** … … 24 25 #define mrb_hash_value(p) mrb_obj_value((void*)(p)) 25 26 26 MRB_API mrb_value mrb_hash_new_capa(mrb_state*, int);27 MRB_API mrb_value mrb_hash_new_capa(mrb_state*, mrb_int); 27 28 28 29 /* 29 30 * Initializes a new hash. 31 * 32 * Equivalent to: 33 * 34 * Hash.new 35 * 36 * @param mrb The mruby state reference. 37 * @return The initialized hash. 30 38 */ 31 39 MRB_API mrb_value mrb_hash_new(mrb_state *mrb); … … 33 41 /* 34 42 * Sets a keys and values to hashes. 43 * 44 * Equivalent to: 45 * 46 * hash[key] = val 47 * 48 * @param mrb The mruby state reference. 49 * @param hash The target hash. 50 * @param key The key to set. 51 * @param val The value to set. 52 * @return The value. 35 53 */ 36 54 MRB_API void mrb_hash_set(mrb_state *mrb, mrb_value hash, mrb_value key, mrb_value val); 37 55 38 56 /* 39 * Gets a value from a key. 57 * Gets a value from a key. If the key is not found, the default of the 58 * hash is used. 59 * 60 * Equivalent to: 61 * 62 * hash[key] 63 * 64 * @param mrb The mruby state reference. 65 * @param hash The target hash. 66 * @param key The key to get. 67 * @return The found value. 40 68 */ 41 69 MRB_API mrb_value mrb_hash_get(mrb_state *mrb, mrb_value hash, mrb_value key); 42 70 71 /* 72 * Gets a value from a key. If the key is not found, the default parameter is 73 * used. 74 * 75 * Equivalent to: 76 * 77 * hash.hash_key?(key) ? hash[key] : def 78 * 79 * @param mrb The mruby state reference. 80 * @param hash The target hash. 81 * @param key The key to get. 82 * @param def The default value. 83 * @return The found value. 84 */ 43 85 MRB_API mrb_value mrb_hash_fetch(mrb_state *mrb, mrb_value hash, mrb_value key, mrb_value def); 44 86 45 87 /* 46 88 * Deletes hash key and value pair. 89 * 90 * Equivalent to: 91 * 92 * hash.delete(key) 93 * 94 * @param mrb The mruby state reference. 95 * @param hash The target hash. 96 * @param key The key to delete. 97 * @return The deleted value. 47 98 */ 48 99 MRB_API mrb_value mrb_hash_delete_key(mrb_state *mrb, mrb_value hash, mrb_value key); … … 50 101 /* 51 102 * Gets an array of keys. 103 * 104 * Equivalent to: 105 * 106 * hash.keys 107 * 108 * @param mrb The mruby state reference. 109 * @param hash The target hash. 110 * @return An array with the keys of the hash. 52 111 */ 53 112 MRB_API mrb_value mrb_hash_keys(mrb_state *mrb, mrb_value hash); 54 113 MRB_API mrb_value mrb_check_hash_type(mrb_state *mrb, mrb_value hash); 114 115 /* 116 * Check if the hash is empty 117 * 118 * Equivalent to: 119 * 120 * hash.empty? 121 * 122 * @param mrb The mruby state reference. 123 * @param self The target hash. 124 * @return True if the hash is empty, false otherwise. 125 */ 55 126 MRB_API mrb_value mrb_hash_empty_p(mrb_state *mrb, mrb_value self); 56 127 57 128 /* 129 * Gets an array of values. 130 * 131 * Equivalent to: 132 * 133 * hash.values 134 * 135 * @param mrb The mruby state reference. 136 * @param hash The target hash. 137 * @return An array with the values of the hash. 138 */ 139 MRB_API mrb_value mrb_hash_values(mrb_state *mrb, mrb_value hash); 140 141 /* 58 142 * Clears the hash. 143 * 144 * Equivalent to: 145 * 146 * hash.clear 147 * 148 * @param mrb The mruby state reference. 149 * @param hash The target hash. 150 * @return The hash 59 151 */ 60 152 MRB_API mrb_value mrb_hash_clear(mrb_state *mrb, mrb_value hash); 153 154 /* declaration of struct kh_ht */ 155 /* be careful when you touch the internal */ 156 typedef struct { 157 mrb_value v; 158 mrb_int n; 159 } mrb_hash_value; 160 161 KHASH_DECLARE(ht, mrb_value, mrb_hash_value, TRUE) 61 162 62 163 /* RHASH_TBL allocates st_table if not available. */ … … 67 168 MRB_API struct kh_ht * mrb_hash_tbl(mrb_state *mrb, mrb_value hash); 68 169 69 #define MRB_HASH_PROC_DEFAULT 256 170 #define MRB_HASH_DEFAULT 1 171 #define MRB_HASH_PROC_DEFAULT 2 172 #define MRB_RHASH_DEFAULT_P(h) (RHASH(h)->flags & MRB_HASH_DEFAULT) 70 173 #define MRB_RHASH_PROCDEFAULT_P(h) (RHASH(h)->flags & MRB_HASH_PROC_DEFAULT) 71 174 -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/irep.h
r321 r331 8 8 #define MRUBY_IREP_H 9 9 10 #include " mruby/common.h"11 #include "mruby/compile.h"10 #include "common.h" 11 #include <mruby/compile.h> 12 12 13 13 /** … … 40 40 struct mrb_locals *lv; 41 41 /* debug info */ 42 mrb_bool own_filename; 42 43 const char *filename; 43 44 uint16_t *lines; -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/khash.h
r321 r331 10 10 #include <string.h> 11 11 12 #include "mruby.h"13 #include " mruby/common.h"12 #include <mruby.h> 13 #include "common.h" 14 14 15 15 /** -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/numeric.h
r321 r331 8 8 #define MRUBY_NUMERIC_H 9 9 10 #include " mruby/common.h"10 #include "common.h" 11 11 12 12 /** … … 21 21 #define FIXABLE(f) (POSFIXABLE(f) && NEGFIXABLE(f)) 22 22 23 #ifdef MRB_INT64 24 #define FIXABLE_FLOAT(f) FIXABLE((mrb_int)(f)) 25 #else 26 #define FIXABLE_FLOAT(f) FIXABLE(f) 27 #endif 28 23 29 MRB_API mrb_value mrb_flo_to_fixnum(mrb_state *mrb, mrb_value val); 24 30 MRB_API mrb_value mrb_fixnum_to_str(mrb_state *mrb, mrb_value x, int base); … … 32 38 mrb_value mrb_num_div(mrb_state *mrb, mrb_value x, mrb_value y); 33 39 40 #ifndef __has_builtin 41 #define __has_builtin(x) 0 42 #endif 43 44 #if (defined(__GNUC__) && __GNUC__ >= 5) || \ 45 (__has_builtin(__builtin_add_overflow) && \ 46 __has_builtin(__builtin_sub_overflow) && \ 47 __has_builtin(__builtin_mul_overflow)) 48 # define MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS 49 #endif 50 51 /* 52 // Clang 3.8 and 3.9 have problem compiling mruby in 32-bit mode, when MRB_INT64 is set 53 // because of missing __mulodi4 and similar functions in its runtime. We need to use custom 54 // implementation for them. 55 */ 56 #ifdef MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS 57 #if defined(__clang__) && (__clang_major__ == 3) && (__clang_minor__ >= 8) && \ 58 defined(MRB_32BIT) && defined(MRB_INT64) 59 #undef MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS 60 #endif 61 #endif 62 63 #ifdef MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS 64 65 #ifndef MRB_WORD_BOXING 66 # define WBCHK(x) 0 67 #else 68 # define WBCHK(x) !FIXABLE(x) 69 #endif 70 71 static inline mrb_bool 72 mrb_int_add_overflow(mrb_int augend, mrb_int addend, mrb_int *sum) 73 { 74 return __builtin_add_overflow(augend, addend, sum) || WBCHK(*sum); 75 } 76 77 static inline mrb_bool 78 mrb_int_sub_overflow(mrb_int minuend, mrb_int subtrahend, mrb_int *difference) 79 { 80 return __builtin_sub_overflow(minuend, subtrahend, difference) || WBCHK(*difference); 81 } 82 83 static inline mrb_bool 84 mrb_int_mul_overflow(mrb_int multiplier, mrb_int multiplicand, mrb_int *product) 85 { 86 return __builtin_mul_overflow(multiplier, multiplicand, product) || WBCHK(*product); 87 } 88 89 #undef WBCHK 90 91 #else 92 34 93 #define MRB_UINT_MAKE2(n) uint ## n ## _t 35 94 #define MRB_UINT_MAKE(n) MRB_UINT_MAKE2(n) … … 37 96 38 97 #define MRB_INT_OVERFLOW_MASK ((mrb_uint)1 << (MRB_INT_BIT - 1 - MRB_FIXNUM_SHIFT)) 39 40 /* Idea from Potion: https://github.com/perl11/potion (MIT) */41 #if (defined(__clang__) && ((__clang_major__ > 3) || (__clang_major__ == 3 && __clang_minor__ >= 4))) \42 || (defined(__GNUC__) && __GNUC__ >= 5)43 44 static inline mrb_bool45 mrb_int_add_overflow(mrb_int augend, mrb_int addend, mrb_int *sum)46 {47 mrb_bool of;48 49 #ifdef MRB_INT6450 long long val;51 of = __builtin_saddll_overflow(augend, addend, &val) ||52 #else53 int val;54 of = __builtin_sadd_overflow(augend, addend, &val) ||55 #endif56 (val > MRB_INT_MAX) || (val < MRB_INT_MIN);57 58 *sum = (mrb_int) val;59 return of;60 }61 62 static inline mrb_bool63 mrb_int_sub_overflow(mrb_int minuend, mrb_int subtrahend, mrb_int *difference)64 {65 mrb_bool of;66 67 #ifdef MRB_INT6468 long long val;69 of = __builtin_ssubll_overflow(minuend, subtrahend, &val) ||70 #else71 int val;72 of = __builtin_ssub_overflow(minuend, subtrahend, &val) ||73 #endif74 (val > MRB_INT_MAX) || (val < MRB_INT_MIN);75 76 *difference = (mrb_int) val;77 return of;78 }79 #else80 98 81 99 static inline mrb_bool … … 99 117 } 100 118 119 static inline mrb_bool 120 mrb_int_mul_overflow(mrb_int multiplier, mrb_int multiplicand, mrb_int *product) 121 { 122 #if MRB_INT_BIT == 32 123 int64_t n = (int64_t)multiplier * multiplicand; 124 *product = (mrb_int)n; 125 return !FIXABLE(n); 126 #else 127 if (multiplier > 0) { 128 if (multiplicand > 0) { 129 if (multiplier > MRB_INT_MAX / multiplicand) return TRUE; 130 } 131 else { 132 if (multiplicand < MRB_INT_MAX / multiplier) return TRUE; 133 } 134 } 135 else { 136 if (multiplicand > 0) { 137 if (multiplier < MRB_INT_MAX / multiplicand) return TRUE; 138 } 139 else { 140 if (multiplier != 0 && multiplicand < MRB_INT_MAX / multiplier) return TRUE; 141 } 142 } 143 *product = multiplier * multiplicand; 144 return FALSE; 101 145 #endif 146 } 102 147 103 148 #undef MRB_INT_OVERFLOW_MASK … … 106 151 #undef MRB_UINT_MAKE2 107 152 153 #endif 154 108 155 MRB_END_DECL 109 156 -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/object.h
r321 r331 23 23 #define mrb_basic_ptr(v) ((struct RBasic*)(mrb_ptr(v))) 24 24 25 #define MRB_FROZEN_P(o) ((o)->flags & MRB_FLAG_IS_FROZEN) 26 #define MRB_SET_FROZEN_FLAG(o) ((o)->flags |= MRB_FLAG_IS_FROZEN) 27 #define MRB_UNSET_FROZEN_FLAG(o) ((o)->flags &= ~MRB_FLAG_IS_FROZEN) 28 25 29 struct RObject { 26 30 MRB_OBJECT_HEADER; -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/opcode.h
r321 r331 83 83 OP_JMPNOT,/* A sBx if !R(A) pc+=sBx */ 84 84 OP_ONERR,/* sBx rescue_push(pc+sBx) */ 85 OP_RESCUE,/* A clear(exc); R(A) := exception (ignore when A=0) */ 85 OP_RESCUE,/* A B C if A (if C exc=R(A) else R(A) := exc); 86 if B R(B) := exc.isa?(R(B)); clear(exc) */ 86 87 OP_POPERR,/* A A.times{rescue_pop()} */ 87 88 OP_RAISE,/* A raise(R(A)) */ -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/proc.h
r321 r331 8 8 #define MRUBY_PROC_H 9 9 10 #include " mruby/common.h"11 #include "mruby/irep.h"10 #include "common.h" 11 #include <mruby/irep.h> 12 12 13 13 /** … … 19 19 MRB_OBJECT_HEADER; 20 20 mrb_value *stack; 21 mrb_sym mid;22 21 ptrdiff_t cioff; 22 union { 23 mrb_sym mid; 24 struct mrb_context *c; 25 } cxt; 23 26 }; 24 27 … … 27 30 #define MRB_ENV_UNSHARE_STACK(e) ((e)->cioff = -1) 28 31 #define MRB_ENV_STACK_SHARED_P(e) ((e)->cioff >= 0) 32 33 MRB_API void mrb_env_unshare(mrb_state*, struct REnv*); 29 34 30 35 struct RProc { … … 51 56 #define MRB_PROC_STRICT 256 52 57 #define MRB_PROC_STRICT_P(p) (((p)->flags & MRB_PROC_STRICT) != 0) 58 #define MRB_PROC_ORPHAN 512 59 #define MRB_PROC_ORPHAN_P(p) (((p)->flags & MRB_PROC_ORPHAN) != 0) 53 60 54 61 #define mrb_proc_ptr(v) ((struct RProc*)(mrb_ptr(v))) … … 69 76 #define mrb_cfunc_env_get(mrb, idx) mrb_proc_cfunc_env_get(mrb, idx) 70 77 71 #include "mruby/khash.h"78 #include <mruby/khash.h> 72 79 KHASH_DECLARE(mt, mrb_sym, struct RProc*, TRUE) 73 80 -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/range.h
r321 r331 8 8 #define MRUBY_RANGE_H 9 9 10 #include " mruby/common.h"10 #include "common.h" 11 11 12 12 /** … … 26 26 }; 27 27 28 #define mrb_range_ptr(v) ((struct RRange*)(mrb_ptr(v))) 28 MRB_API struct RRange* mrb_range_ptr(mrb_state *mrb, mrb_value v); 29 #define mrb_range_raw_ptr(v) ((struct RRange*)mrb_ptr(v)) 29 30 #define mrb_range_value(p) mrb_obj_value((void*)(p)) 30 31 … … 41 42 MRB_API mrb_value mrb_range_new(mrb_state *mrb, mrb_value start, mrb_value end, mrb_bool exclude); 42 43 43 MRB_API mrb_ bool mrb_range_beg_len(mrb_state *mrb, mrb_value range, mrb_int *begp, mrb_int *lenp, mrb_int len);44 MRB_API mrb_int mrb_range_beg_len(mrb_state *mrb, mrb_value range, mrb_int *begp, mrb_int *lenp, mrb_int len, mrb_bool trunc); 44 45 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)); 45 46 -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/re.h
r321 r331 8 8 #define MRUBY_RE_H 9 9 10 #ifdef __cplusplus 11 extern "C" { 12 #endif 10 MRB_BEGIN_DECL 13 11 14 12 #define REGEXP_CLASS "Regexp" 15 13 16 #ifdef __cplusplus 17 } 18 #endif 14 MRB_END_DECL 19 15 20 16 #endif /* RE_H */ -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/string.h
r321 r331 8 8 #define MRUBY_STRING_H 9 9 10 #include " mruby/common.h"10 #include "common.h" 11 11 12 12 /** … … 45 45 if (RSTR_EMBED_P(s)) {\ 46 46 RSTR_SET_EMBED_LEN((s),(n));\ 47 } else {\ 47 }\ 48 else {\ 48 49 s->as.heap.len = (mrb_int)(n);\ 49 50 }\ … … 63 64 #define RSTR_UNSET_NOFREE_FLAG(s) ((s)->flags &= ~MRB_STR_NOFREE) 64 65 65 #define RSTR_FROZEN_P(s) ((s)->flags & MRB_STR_FROZEN)66 #define RSTR_SET_FROZEN_FLAG(s) ((s)->flags |= MRB_STR_FROZEN)67 #define RSTR_UNSET_FROZEN_FLAG(s) ((s)->flags &= ~MRB_STR_FROZEN)68 69 66 /* 70 67 * Returns a pointer from a Ruby string … … 73 70 #define RSTRING(s) mrb_str_ptr(s) 74 71 #define RSTRING_PTR(s) RSTR_PTR(RSTRING(s)) 75 #define RSTRING_EMBED_LEN(s) RSTR_E NBED_LEN(RSTRING(s))72 #define RSTRING_EMBED_LEN(s) RSTR_EMBED_LEN(RSTRING(s)) 76 73 #define RSTRING_LEN(s) RSTR_LEN(RSTRING(s)) 77 74 #define RSTRING_CAPA(s) RSTR_CAPA(RSTRING(s)) 78 75 #define RSTRING_END(s) (RSTRING_PTR(s) + RSTRING_LEN(s)) 79 mrb_int mrb_str_strlen(mrb_state*, struct RString*);76 MRB_API mrb_int mrb_str_strlen(mrb_state*, struct RString*); 80 77 81 78 #define MRB_STR_SHARED 1 82 79 #define MRB_STR_NOFREE 2 83 #define MRB_STR_ FROZEN 484 #define MRB_STR_EMBED 885 #define MRB_STR_EMBED_LEN_MASK 0x 1f086 #define MRB_STR_EMBED_LEN_SHIFT 480 #define MRB_STR_NO_UTF 8 81 #define MRB_STR_EMBED 16 82 #define MRB_STR_EMBED_LEN_MASK 0x3e0 83 #define MRB_STR_EMBED_LEN_SHIFT 5 87 84 88 85 void mrb_gc_free_str(mrb_state*, struct RString*); 89 86 MRB_API void mrb_str_modify(mrb_state*, struct RString*); 87 /* 88 * Appends self to other. Returns self as a concatnated string. 89 * 90 * 91 * Example: 92 * 93 * !!!c 94 * int 95 * main(int argc, 96 * char **argv) 97 * { 98 * // Variable declarations. 99 * mrb_value str1; 100 * mrb_value str2; 101 * 102 * mrb_state *mrb = mrb_open(); 103 * if (!mrb) 104 * { 105 * // handle error 106 * } 107 * 108 * // Creates new Ruby strings. 109 * str1 = mrb_str_new_lit(mrb, "abc"); 110 * str2 = mrb_str_new_lit(mrb, "def"); 111 * 112 * // Concatnates str2 to str1. 113 * mrb_str_concat(mrb, str1, str2); 114 * 115 * // Prints new Concatnated Ruby string. 116 * mrb_p(mrb, str1); 117 * 118 * mrb_close(mrb); 119 * return 0; 120 * } 121 * 122 * 123 * Result: 124 * 125 * => "abcdef" 126 * 127 * @param [mrb_state] mrb The current mruby state. 128 * @param [mrb_value] self String to concatenate. 129 * @param [mrb_value] other String to append to self. 130 * @return [mrb_value] Returns a new String appending other to self. 131 */ 90 132 MRB_API void mrb_str_concat(mrb_state*, mrb_value, mrb_value); 91 133 92 134 /* 93 135 * Adds two strings together. 136 * 137 * 138 * Example: 139 * 140 * !!!c 141 * int 142 * main(int argc, 143 * char **argv) 144 * { 145 * // Variable declarations. 146 * mrb_value a; 147 * mrb_value b; 148 * mrb_value c; 149 * 150 * mrb_state *mrb = mrb_open(); 151 * if (!mrb) 152 * { 153 * // handle error 154 * } 155 * 156 * // Creates two Ruby strings from the passed in C strings. 157 * a = mrb_str_new_lit(mrb, "abc"); 158 * b = mrb_str_new_lit(mrb, "def"); 159 * 160 * // Prints both C strings. 161 * mrb_p(mrb, a); 162 * mrb_p(mrb, b); 163 * 164 * // Concatnates both Ruby strings. 165 * c = mrb_str_plus(mrb, a, b); 166 * 167 * // Prints new Concatnated Ruby string. 168 * mrb_p(mrb, c); 169 * 170 * mrb_close(mrb); 171 * return 0; 172 * } 173 * 174 * 175 * Result: 176 * 177 * => "abc" # First string 178 * => "def" # Second string 179 * => "abcdef" # First & Second concatnated. 180 * 181 * @param [mrb_state] mrb The current mruby state. 182 * @param [mrb_value] a First string to concatenate. 183 * @param [mrb_value] b Second string to concatenate. 184 * @return [mrb_value] Returns a new String containing a concatenated to b. 94 185 */ 95 186 MRB_API mrb_value mrb_str_plus(mrb_state*, mrb_value, mrb_value); … … 97 188 /* 98 189 * Converts pointer into a Ruby string. 190 * 191 * @param [mrb_state] mrb The current mruby state. 192 * @param [void*] p The pointer to convert to Ruby string. 193 * @return [mrb_value] Returns a new Ruby String. 99 194 */ 100 195 MRB_API mrb_value mrb_ptr_to_str(mrb_state *, void*); … … 102 197 /* 103 198 * Returns an object as a Ruby string. 199 * 200 * @param [mrb_state] mrb The current mruby state. 201 * @param [mrb_value] obj An object to return as a Ruby string. 202 * @return [mrb_value] An object as a Ruby string. 104 203 */ 105 204 MRB_API mrb_value mrb_obj_as_string(mrb_state *mrb, mrb_value obj); 106 205 107 206 /* 108 * Resizes the string's length. 207 * Resizes the string's length. Returns the amount of characters 208 * in the specified by len. 209 * 210 * Example: 211 * 212 * !!!c 213 * int 214 * main(int argc, 215 * char **argv) 216 * { 217 * // Variable declaration. 218 * mrb_value str; 219 * 220 * mrb_state *mrb = mrb_open(); 221 * if (!mrb) 222 * { 223 * // handle error 224 * } 225 * // Creates a new string. 226 * str = mrb_str_new_lit(mrb, "Hello, world!"); 227 * // Returns 5 characters of 228 * mrb_str_resize(mrb, str, 5); 229 * mrb_p(mrb, str); 230 * 231 * mrb_close(mrb); 232 * return 0; 233 * } 234 * 235 * Result: 236 * 237 * => "Hello" 238 * 239 * @param [mrb_state] mrb The current mruby state. 240 * @param [mrb_value] str The Ruby string to resize. 241 * @param [mrb_value] len The length. 242 * @return [mrb_value] An object as a Ruby string. 109 243 */ 110 244 MRB_API mrb_value mrb_str_resize(mrb_state *mrb, mrb_value str, mrb_int len); … … 112 246 /* 113 247 * Returns a sub string. 248 * 249 * Example: 250 * 251 * !!!c 252 * int 253 * main(int argc, 254 * char const **argv) 255 * { 256 * // Variable declarations. 257 * mrb_value str1; 258 * mrb_value str2; 259 * 260 * mrb_state *mrb = mrb_open(); 261 * if (!mrb) 262 * { 263 * // handle error 264 * } 265 * // Creates new string. 266 * str1 = mrb_str_new_lit(mrb, "Hello, world!"); 267 * // Returns a sub-string within the range of 0..2 268 * str2 = mrb_str_substr(mrb, str1, 0, 2); 269 * 270 * // Prints sub-string. 271 * mrb_p(mrb, str2); 272 * 273 * mrb_close(mrb); 274 * return 0; 275 * } 276 * 277 * Result: 278 * 279 * => "He" 280 * 281 * @param [mrb_state] mrb The current mruby state. 282 * @param [mrb_value] str Ruby string. 283 * @param [mrb_int] beg The beginning point of the sub-string. 284 * @param [mrb_int] len The end point of the sub-string. 285 * @return [mrb_value] An object as a Ruby sub-string. 114 286 */ 115 287 MRB_API mrb_value mrb_str_substr(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len); … … 117 289 /* 118 290 * Returns a Ruby string type. 291 * 292 * 293 * @param [mrb_state] mrb The current mruby state. 294 * @param [mrb_value] str Ruby string. 295 * @return [mrb_value] A Ruby string. 119 296 */ 120 297 MRB_API mrb_value mrb_string_type(mrb_state *mrb, mrb_value str); … … 124 301 125 302 MRB_API const char *mrb_string_value_cstr(mrb_state *mrb, mrb_value *ptr); 126 MRB_API const char *mrb_string_value_ptr(mrb_state *mrb, mrb_value ptr); 303 MRB_API const char *mrb_string_value_ptr(mrb_state *mrb, mrb_value str); 304 /* 305 * Returns the length of the Ruby string. 306 * 307 * 308 * @param [mrb_state] mrb The current mruby state. 309 * @param [mrb_value] str Ruby string. 310 * @return [mrb_int] The length of the passed in Ruby string. 311 */ 312 MRB_API mrb_int mrb_string_value_len(mrb_state *mrb, mrb_value str); 127 313 128 314 /* 129 315 * Duplicates a string object. 316 * 317 * 318 * @param [mrb_state] mrb The current mruby state. 319 * @param [mrb_value] str Ruby string. 320 * @return [mrb_value] Duplicated Ruby string. 130 321 */ 131 322 MRB_API mrb_value mrb_str_dup(mrb_state *mrb, mrb_value str); 132 323 133 324 /* 134 * Returns a symbol from a passed in string. 325 * Returns a symbol from a passed in Ruby string. 326 * 327 * @param [mrb_state] mrb The current mruby state. 328 * @param [mrb_value] self Ruby string. 329 * @return [mrb_value] A symbol. 135 330 */ 136 331 MRB_API mrb_value mrb_str_intern(mrb_state *mrb, mrb_value self); … … 146 341 /* 147 342 * Returns true if the strings match and false if the strings don't match. 343 * 344 * @param [mrb_state] mrb The current mruby state. 345 * @param [mrb_value] str1 Ruby string to compare. 346 * @param [mrb_value] str2 Ruby string to compare. 347 * @return [mrb_value] boolean value. 148 348 */ 149 349 MRB_API mrb_bool mrb_str_equal(mrb_state *mrb, mrb_value str1, mrb_value str2); … … 152 352 * Returns a concated string comprised of a Ruby string and a C string. 153 353 * 354 * @param [mrb_state] mrb The current mruby state. 355 * @param [mrb_value] str Ruby string. 356 * @param [const char *] ptr A C string. 357 * @param [size_t] len length of C string. 358 * @return [mrb_value] A Ruby string. 154 359 * @see mrb_str_cat_cstr 155 360 */ … … 159 364 * Returns a concated string comprised of a Ruby string and a C string. 160 365 * 366 * @param [mrb_state] mrb The current mruby state. 367 * @param [mrb_value] str Ruby string. 368 * @param [const char *] ptr A C string. 369 * @return [mrb_value] A Ruby string. 161 370 * @see mrb_str_cat 162 371 */ … … 176 385 177 386 /* 178 * Returns a C string from a Ruby string. 387 * Returns a newly allocated C string from a Ruby string. 388 * This is an utility function to pass a Ruby string to C library functions. 389 * 390 * - Returned string does not contain any NUL characters (but terminator). 391 * - It raises an ArgumentError exception if Ruby string contains 392 * NUL characters. 393 * - Retured string will be freed automatically on next GC. 394 * - Caller can modify returned string without affecting Ruby string 395 * (e.g. it can be used for mkstemp(3)). 396 * 397 * @param [mrb_state *] mrb The current mruby state. 398 * @param [mrb_value] str Ruby string. Must be an instance of String. 399 * @return [char *] A newly allocated C string. 179 400 */ 180 401 MRB_API char *mrb_str_to_cstr(mrb_state *mrb, mrb_value str); -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/throw.h
r321 r331 8 8 #define MRB_THROW_H 9 9 10 #ifdef MRB_ENABLE_CXX_EXCEPTION 10 #if defined(MRB_ENABLE_CXX_ABI) 11 # if !defined(__cplusplus) 12 # error Trying to use C++ exception handling in C code 13 # endif 14 #endif 15 16 #if defined(MRB_ENABLE_CXX_EXCEPTION) && defined(__cplusplus) 11 17 12 18 #define MRB_TRY(buf) do { try { … … 21 27 #include <setjmp.h> 22 28 23 #define MRB_TRY(buf) do { if (setjmp((buf)->impl) == 0) { 29 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) 30 #define MRB_SETJMP _setjmp 31 #define MRB_LONGJMP _longjmp 32 #else 33 #define MRB_SETJMP setjmp 34 #define MRB_LONGJMP longjmp 35 #endif 36 37 #define MRB_TRY(buf) do { if (MRB_SETJMP((buf)->impl) == 0) { 24 38 #define MRB_CATCH(buf) } else { 25 39 #define MRB_END_EXC(buf) } } while(0) 26 40 27 #define MRB_THROW(buf) longjmp((buf)->impl, 1);41 #define MRB_THROW(buf) MRB_LONGJMP((buf)->impl, 1); 28 42 #define mrb_jmpbuf_impl jmp_buf 29 43 … … 33 47 mrb_jmpbuf_impl impl; 34 48 35 #if def MRB_ENABLE_CXX_EXCEPTION49 #if defined(MRB_ENABLE_CXX_EXCEPTION) && defined(__cplusplus) 36 50 static mrb_int jmpbuf_id; 37 51 mrb_jmpbuf() : impl(jmpbuf_id++) {} -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/value.h
r321 r331 8 8 #define MRUBY_VALUE_H 9 9 10 #include " mruby/common.h"10 #include "common.h" 11 11 12 12 /** … … 21 21 #if defined(MRB_INT16) && defined(MRB_INT64) 22 22 # error "You can't define MRB_INT16 and MRB_INT64 at the same time." 23 #endif 24 25 #if defined _MSC_VER && _MSC_VER < 1800 26 # define PRIo64 "llo" 27 # define PRId64 "lld" 28 # define PRIx64 "llx" 29 # define PRIo16 "ho" 30 # define PRId16 "hd" 31 # define PRIx16 "hx" 32 # define PRIo32 "o" 33 # define PRId32 "d" 34 # define PRIx32 "x" 35 #else 36 # include <inttypes.h> 23 37 #endif 24 38 … … 28 42 # define MRB_INT_MIN (INT64_MIN>>MRB_FIXNUM_SHIFT) 29 43 # define MRB_INT_MAX (INT64_MAX>>MRB_FIXNUM_SHIFT) 44 # define MRB_PRIo PRIo64 45 # define MRB_PRId PRId64 46 # define MRB_PRIx PRIx64 30 47 #elif defined(MRB_INT16) 31 48 typedef int16_t mrb_int; … … 33 50 # define MRB_INT_MIN (INT16_MIN>>MRB_FIXNUM_SHIFT) 34 51 # define MRB_INT_MAX (INT16_MAX>>MRB_FIXNUM_SHIFT) 52 # define MRB_PRIo PRIo16 53 # define MRB_PRId PRId16 54 # define MRB_PRIx PRIx16 35 55 #else 36 56 typedef int32_t mrb_int; … … 38 58 # define MRB_INT_MIN (INT32_MIN>>MRB_FIXNUM_SHIFT) 39 59 # define MRB_INT_MAX (INT32_MAX>>MRB_FIXNUM_SHIFT) 40 #endif 41 60 # define MRB_PRIo PRIo32 61 # define MRB_PRId PRId32 62 # define MRB_PRIx PRIx32 63 #endif 64 65 66 MRB_API double mrb_float_read(const char*, char**); 42 67 #ifdef MRB_USE_FLOAT 43 68 typedef float mrb_float; 44 # define str_to_mrb_float(buf) strtof(buf, NULL)45 69 #else 46 70 typedef double mrb_float; 47 # define str_to_mrb_float(buf) strtod(buf, NULL)48 71 #endif 49 72 … … 63 86 # define isinf(n) (!_finite(n) && !_isnan(n)) 64 87 # define signbit(n) (_copysign(1.0, (n)) < 0.0) 65 # define strtof (float)strtod66 88 static const unsigned int IEEE754_INFINITY_BITS_SINGLE = 0x7F800000; 67 89 # define INFINITY (*(float *)&IEEE754_INFINITY_BITS_SINGLE) … … 94 116 MRB_TT_DATA, /* 21 */ 95 117 MRB_TT_FIBER, /* 22 */ 96 MRB_TT_MAXDEFINE /* 23 */ 118 MRB_TT_ISTRUCT, /* 23 */ 119 MRB_TT_BREAK, /* 24 */ 120 MRB_TT_MAXDEFINE /* 25 */ 97 121 }; 98 122 99 #include "mruby/object.h"123 #include <mruby/object.h> 100 124 101 125 #ifdef MRB_DOCUMENTATION_BLOCK … … 188 212 mrb_value v; 189 213 SET_OBJ_VALUE(v, (struct RBasic*)p); 214 mrb_assert(p == mrb_ptr(v)); 215 mrb_assert(((struct RBasic*)p)->tt == mrb_type(v)); 190 216 return v; 191 217 } … … 242 268 243 269 #ifdef MRB_USE_ETEXT_EDATA 270 #if (defined(__APPLE__) && defined(__MACH__)) 271 #include <mach-o/getsect.h> 272 static inline mrb_bool 273 mrb_ro_data_p(const char *p) 274 { 275 return (const char*)get_etext() < p && p < (const char*)get_edata(); 276 } 277 #else 244 278 extern char _etext[]; 245 279 #ifdef MRB_NO_INIT_ARRAY_START … … 260 294 } 261 295 #endif 296 #endif 262 297 #else 263 298 # define mrb_ro_data_p(p) FALSE -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/variable.h
r321 r331 8 8 #define MRUBY_VARIABLE_H 9 9 10 #include " mruby/common.h"10 #include "common.h" 11 11 12 12 /** … … 55 55 MRB_API void mrb_iv_copy(mrb_state *mrb, mrb_value dst, mrb_value src); 56 56 MRB_API mrb_bool mrb_const_defined_at(mrb_state *mrb, mrb_value mod, mrb_sym id); 57 58 /** 59 * Get a global variable. Will return nil if the var does not exist 60 * 61 * Example: 62 * 63 * !!!ruby 64 * # Ruby style 65 * var = $value 66 * 67 * !!!c 68 * // C style 69 * mrb_sym sym = mrb_intern_lit(mrb, "$value"); 70 * mrb_value var = mrb_gv_get(mrb, sym); 71 * 72 * @param mrb The mruby state reference 73 * @param sym The name of the global variable 74 * @return The value of that global variable. May be nil 75 */ 57 76 MRB_API mrb_value mrb_gv_get(mrb_state *mrb, mrb_sym sym); 77 78 /** 79 * Set a global variable 80 * 81 * Example: 82 * 83 * !!!ruby 84 * # Ruby style 85 * $value = "foo" 86 * 87 * !!!c 88 * // C style 89 * mrb_sym sym = mrb_intern_lit(mrb, "$value"); 90 * mrb_gv_set(mrb, sym, mrb_str_new_lit("foo")); 91 * 92 * @param mrb The mruby state reference 93 * @param sym The name of the global variable 94 * @param val The value of the global variable 95 */ 58 96 MRB_API void mrb_gv_set(mrb_state *mrb, mrb_sym sym, mrb_value val); 97 98 /** 99 * Remove a global variable. 100 * 101 * Example: 102 * 103 * !!!ruby 104 * # Ruby style 105 * $value = nil 106 * 107 * !!!c 108 * // C style 109 * mrb_sym sym = mrb_intern_lit(mrb, "$value"); 110 * mrb_gv_remove(mrb, sym); 111 * 112 * @param mrb The mruby state reference 113 * @param sym The name of the global variable 114 * @param val The value of the global variable 115 */ 59 116 MRB_API void mrb_gv_remove(mrb_state *mrb, mrb_sym sym); 117 60 118 MRB_API mrb_value mrb_cv_get(mrb_state *mrb, mrb_value mod, mrb_sym sym); 61 119 MRB_API void mrb_mod_cv_set(mrb_state *mrb, struct RClass * c, mrb_sym sym, mrb_value v); -
EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/version.h
r321 r331 8 8 #define MRUBY_VERSION_H 9 9 10 #include " mruby/common.h"10 #include "common.h" 11 11 12 12 /** … … 43 43 * Minor release version number. 44 44 */ 45 #define MRUBY_RELEASE_MINOR 245 #define MRUBY_RELEASE_MINOR 3 46 46 47 47 /* … … 63 63 * Release year. 64 64 */ 65 #define MRUBY_RELEASE_YEAR 201 565 #define MRUBY_RELEASE_YEAR 2017 66 66 67 67 /* 68 68 * Release month. 69 69 */ 70 #define MRUBY_RELEASE_MONTH 1170 #define MRUBY_RELEASE_MONTH 7 71 71 72 72 /* 73 73 * Release day. 74 74 */ 75 #define MRUBY_RELEASE_DAY 1775 #define MRUBY_RELEASE_DAY 4 76 76 77 77 /*
Note:
See TracChangeset
for help on using the changeset viewer.