Ignore:
Timestamp:
Jan 21, 2018, 12:10:09 AM (6 years ago)
Author:
coas-nagasima
Message:

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

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  
    88#define MRUBY_ARRAY_H
    99
    10 #include "mruby/common.h"
     10#include "common.h"
    1111
    1212/*
     
    5555 *
    5656 * @param mrb The mruby state reference.
    57  * @return The initialized array
     57 * @return The initialized array.
    5858 */
    5959MRB_API mrb_value mrb_ary_new(mrb_state *mrb);
    6060
     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 */
    6173MRB_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 */
    6287MRB_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 */
     99MRB_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 */
     110MRB_API mrb_value mrb_ary_splat(mrb_state *mrb, mrb_value value);
    65111
    66112/*
     
    85131 *
    86132 * @param mrb The mruby state reference.
    87  * @param ary The array from which the value will be poped.
    88  * @return The poped value.
     133 * @param ary The array from which the value will be popped.
     134 * @return The popped value.
    89135 */
    90136MRB_API mrb_value mrb_ary_pop(mrb_state *mrb, mrb_value ary);
     
    118164MRB_API void mrb_ary_set(mrb_state *mrb, mrb_value ary, mrb_int n, mrb_value val);
    119165
    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 */
     177MRB_API void mrb_ary_replace(mrb_state *mrb, mrb_value self, mrb_value other);
    121178MRB_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 */
    122191MRB_API mrb_value mrb_ary_unshift(mrb_state *mrb, mrb_value self, mrb_value item);
    123192MRB_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 */
    124205MRB_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 */
    125218MRB_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 */
    126231MRB_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 */
     240MRB_API mrb_value mrb_ary_resize(mrb_state *mrb, mrb_value ary, mrb_int new_len);
    128241
    129242static inline mrb_int
     
    135248}
    136249
     250static inline mrb_value
     251ary_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
    137259MRB_END_DECL
    138260
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/boxing_nan.h

    r321 r331  
    5454
    5555#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)
    5757#define mrb_ptr(o)      ((void*)((((uintptr_t)0x3fffffffffff)&((uintptr_t)((o).value.p)))<<2))
    5858#define mrb_float(o)    (o).f
     
    6161#define mrb_symbol(o)   (o).value.sym
    6262
     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
    6369#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));\
    7377} while (0)
    7478
     
    7781    (r).value.ttt = 0x7ff80000; \
    7882    (r).value.i = 0; \
    79   } else { \
     83  } \
     84  else { \
    8085    (r).f = v; \
    8186  }} while(0)
     
    8792#define SET_INT_VALUE(r,n) BOXNAN_SET_VALUE(r, MRB_TT_FIXNUM, value.i, (n))
    8893#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)
    9196#define SET_UNDEF_VALUE(r) BOXNAN_SET_VALUE(r, MRB_TT_UNDEF, value.i, 0)
    9297
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/boxing_word.h

    r321 r331  
    1010#if defined(MRB_INT16)
    1111# 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.
    1216#endif
    1317
     
    6367#define mrb_cptr(o)    (o).value.vp->p
    6468#define mrb_float(o)   (o).value.fp->f
    65 #define mrb_fixnum(o)  (o).value.i
     69#define mrb_fixnum(o)  ((mrb_int)(o).value.i)
    6670#define mrb_symbol(o)  (o).value.sym
    6771
     
    9296#define mrb_nil_p(o)  ((o).w == MRB_Qnil)
    9397
    94 #define BOXWORD_SET_VALUE(o, ttt, attr, v) do {\
     98#define BOXWORD_SET_VALUE(o, ttt, attr, v) do { \
    9599  switch (ttt) {\
    96100  case MRB_TT_FALSE:  (o).w = (v) ? MRB_Qfalse : MRB_Qnil; break;\
    97101  case MRB_TT_TRUE:   (o).w = MRB_Qtrue; break;\
    98102  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;\
    101105  default:            (o).w = 0; (o).attr = (v); if ((o).value.bp) (o).value.bp->tt = ttt; break;\
    102106  }\
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/class.h

    r321 r331  
    88#define MRUBY_CLASS_H
    99
    10 #include "mruby/common.h"
     10#include "common.h"
    1111
    1212/**
     
    5252}
    5353
    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)
    5556#define MRB_FLAG_IS_PREPENDED (1 << 19)
    5657#define MRB_FLAG_IS_ORIGIN (1 << 20)
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/common.h

    r321 r331  
    11/*
    2 ** mruby/common.h - mruby common platform definitions
     2**"common.h - mruby common platform definition"
    33**
    44** See Copyright Notice in mruby.h
     
    1010
    1111#ifdef __cplusplus
     12#ifdef MRB_ENABLE_CXX_ABI
     13#define MRB_BEGIN_DECL
     14#define MRB_END_DECL
     15#else
    1216# define MRB_BEGIN_DECL extern "C" {
    1317# define MRB_END_DECL   }
     18#endif
    1419#else
    1520/** Start declarations in C mode */
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/compile.h

    r321 r331  
    88#define MRUBY_COMPILE_H
    99
    10 #include "mruby/common.h"
     10#include "common.h"
    1111
    1212/**
     
    1515MRB_BEGIN_DECL
    1616
    17 #include "mruby.h"
     17#include <mruby.h>
    1818
    1919struct mrb_jmpbuf;
     
    4040MRB_API const char *mrbc_filename(mrb_state *mrb, mrbc_context *c, const char *s);
    4141MRB_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);
    4442
    4543/* AST node structure */
     
    105103};
    106104
    107 #define MRB_PARSER_BUF_SIZE 1024
     105#define MRB_PARSER_TOKBUF_MAX 65536
     106#define MRB_PARSER_TOKBUF_SIZE 256
    108107
    109108/* parser structure */
     
    133132
    134133  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;
    137138
    138139  mrb_ast_node *all_heredocs;   /* list of mrb_parser_heredoc_info* */
     
    163164MRB_API void mrb_parser_free(struct mrb_parser_state*);
    164165MRB_API void mrb_parser_parse(struct mrb_parser_state*,mrbc_context*);
     166MRB_API double mrb_float_read(const char*, char**);
    165167
    166168MRB_API void mrb_parser_set_filename(struct mrb_parser_state*, char const*);
     
    174176MRB_API struct mrb_parser_state* mrb_parse_nstring(mrb_state*,const char*,int,mrbc_context*);
    175177MRB_API struct RProc* mrb_generate_code(mrb_state*, struct mrb_parser_state*);
     178MRB_API mrb_value mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c);
    176179
    177180/* program load functions */
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/data.h

    r321 r331  
    88#define MRUBY_DATA_H
    99
    10 #include "mruby/common.h"
     10#include "common.h"
    1111
    1212/**
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/debug.h

    r321 r331  
    88#define MRUBY_DEBUG_H
    99
    10 #include "mruby/common.h"
     10#include "common.h"
    1111
    1212/**
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/dump.h

    r321 r331  
    88#define MRUBY_DUMP_H
    99
    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"
    1313
    1414/**
     
    5353#define RITE_BINARY_IDENT              "RITE"
    5454#define RITE_BINARY_IDENT_LIL          "ETIR"
    55 #define RITE_BINARY_FORMAT_VER         "0003"
     55#define RITE_BINARY_FORMAT_VER         "0004"
    5656#define RITE_COMPILER_NAME             "MATZ"
    5757#define RITE_COMPILER_VERSION          "0000"
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/error.h

    r321 r331  
    88#define MRUBY_ERROR_H
    99
    10 #include "mruby/common.h"
     10#include "common.h"
    1111
    1212/**
     
    3232/* declaration for fail method */
    3333MRB_API mrb_value mrb_f_raise(mrb_state*, mrb_value);
     34
     35struct RBreak {
     36  MRB_OBJECT_HEADER;
     37  struct iv_tbl *iv;
     38  struct RProc *proc;
     39  mrb_value val;
     40};
    3441
    3542/**
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/gc.h

    r321 r331  
    88#define MRUBY_GC_H
    99
    10 #include "mruby/common.h"
     10#include "common.h"
    1111
    1212/**
     
    1818struct mrb_state;
    1919
    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
     22typedef int (mrb_each_object_callback)(struct mrb_state *mrb, struct RBasic *obj, void *data);
    2123void mrb_objspace_each_objects(struct mrb_state *mrb, mrb_each_object_callback *callback, void *data);
    2224MRB_API void mrb_free_context(struct mrb_state *mrb, struct mrb_context *c);
     
    6365  int interval_ratio;
    6466  int step_ratio;
     67  mrb_bool iterating     :1;
    6568  mrb_bool disabled      :1;
    6669  mrb_bool full          :1;
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/hash.h

    r321 r331  
    88#define MRUBY_HASH_H
    99
    10 #include "mruby/common.h"
     10#include "common.h"
     11#include <mruby/khash.h>
    1112
    1213/**
     
    2425#define mrb_hash_value(p)  mrb_obj_value((void*)(p))
    2526
    26 MRB_API mrb_value mrb_hash_new_capa(mrb_state*, int);
     27MRB_API mrb_value mrb_hash_new_capa(mrb_state*, mrb_int);
    2728
    2829/*
    2930 * 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.
    3038 */
    3139MRB_API mrb_value mrb_hash_new(mrb_state *mrb);
     
    3341/*
    3442 * 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.
    3553 */
    3654MRB_API void mrb_hash_set(mrb_state *mrb, mrb_value hash, mrb_value key, mrb_value val);
    3755
    3856/*
    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.
    4068 */
    4169MRB_API mrb_value mrb_hash_get(mrb_state *mrb, mrb_value hash, mrb_value key);
    4270
     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 */
    4385MRB_API mrb_value mrb_hash_fetch(mrb_state *mrb, mrb_value hash, mrb_value key, mrb_value def);
    4486
    4587/*
    4688 * 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.
    4798 */
    4899MRB_API mrb_value mrb_hash_delete_key(mrb_state *mrb, mrb_value hash, mrb_value key);
     
    50101/*
    51102 * 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.
    52111 */
    53112MRB_API mrb_value mrb_hash_keys(mrb_state *mrb, mrb_value hash);
    54113MRB_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 */
    55126MRB_API mrb_value mrb_hash_empty_p(mrb_state *mrb, mrb_value self);
    56127
    57128/*
     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 */
     139MRB_API mrb_value mrb_hash_values(mrb_state *mrb, mrb_value hash);
     140
     141/*
    58142 * 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
    59151 */
    60152MRB_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 */
     156typedef struct {
     157  mrb_value v;
     158  mrb_int n;
     159} mrb_hash_value;
     160
     161KHASH_DECLARE(ht, mrb_value, mrb_hash_value, TRUE)
    61162
    62163/* RHASH_TBL allocates st_table if not available. */
     
    67168MRB_API struct kh_ht * mrb_hash_tbl(mrb_state *mrb, mrb_value hash);
    68169
    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)
    70173#define MRB_RHASH_PROCDEFAULT_P(h) (RHASH(h)->flags & MRB_HASH_PROC_DEFAULT)
    71174
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/irep.h

    r321 r331  
    88#define MRUBY_IREP_H
    99
    10 #include "mruby/common.h"
    11 #include "mruby/compile.h"
     10#include "common.h"
     11#include <mruby/compile.h>
    1212
    1313/**
     
    4040  struct mrb_locals *lv;
    4141  /* debug info */
     42  mrb_bool own_filename;
    4243  const char *filename;
    4344  uint16_t *lines;
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/khash.h

    r321 r331  
    1010#include <string.h>
    1111
    12 #include "mruby.h"
    13 #include "mruby/common.h"
     12#include <mruby.h>
     13#include "common.h"
    1414
    1515/**
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/numeric.h

    r321 r331  
    88#define MRUBY_NUMERIC_H
    99
    10 #include "mruby/common.h"
     10#include "common.h"
    1111
    1212/**
     
    2121#define FIXABLE(f) (POSFIXABLE(f) && NEGFIXABLE(f))
    2222
     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
    2329MRB_API mrb_value mrb_flo_to_fixnum(mrb_state *mrb, mrb_value val);
    2430MRB_API mrb_value mrb_fixnum_to_str(mrb_state *mrb, mrb_value x, int base);
     
    3238mrb_value mrb_num_div(mrb_state *mrb, mrb_value x, mrb_value y);
    3339
     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
     71static inline mrb_bool
     72mrb_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
     77static inline mrb_bool
     78mrb_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
     83static inline mrb_bool
     84mrb_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
    3493#define MRB_UINT_MAKE2(n) uint ## n ## _t
    3594#define MRB_UINT_MAKE(n) MRB_UINT_MAKE2(n)
     
    3796
    3897#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_bool
    45 mrb_int_add_overflow(mrb_int augend, mrb_int addend, mrb_int *sum)
    46 {
    47   mrb_bool of;
    48 
    49 #ifdef MRB_INT64
    50   long long val;
    51   of = __builtin_saddll_overflow(augend, addend, &val) ||
    52 #else
    53   int val;
    54   of = __builtin_sadd_overflow(augend, addend, &val) ||
    55 #endif
    56   (val > MRB_INT_MAX) || (val < MRB_INT_MIN);
    57 
    58   *sum = (mrb_int) val;
    59   return of;
    60 }
    61 
    62 static inline mrb_bool
    63 mrb_int_sub_overflow(mrb_int minuend, mrb_int subtrahend, mrb_int *difference)
    64 {
    65   mrb_bool of;
    66 
    67 #ifdef MRB_INT64
    68   long long val;
    69   of = __builtin_ssubll_overflow(minuend, subtrahend, &val) ||
    70 #else
    71   int val;
    72   of = __builtin_ssub_overflow(minuend, subtrahend, &val) ||
    73 #endif
    74   (val > MRB_INT_MAX) || (val < MRB_INT_MIN);
    75 
    76   *difference = (mrb_int) val;
    77   return of;
    78 }
    79 #else
    8098
    8199static inline mrb_bool
     
    99117}
    100118
     119static inline mrb_bool
     120mrb_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;
    101145#endif
     146}
    102147
    103148#undef MRB_INT_OVERFLOW_MASK
     
    106151#undef MRB_UINT_MAKE2
    107152
     153#endif
     154
    108155MRB_END_DECL
    109156
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/object.h

    r321 r331  
    2323#define mrb_basic_ptr(v) ((struct RBasic*)(mrb_ptr(v)))
    2424
     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
    2529struct RObject {
    2630  MRB_OBJECT_HEADER;
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/opcode.h

    r321 r331  
    8383  OP_JMPNOT,/*    A sBx   if !R(A) pc+=sBx                                */
    8484  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)         */
    8687  OP_POPERR,/*    A       A.times{rescue_pop()}                           */
    8788  OP_RAISE,/*     A       raise(R(A))                                     */
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/proc.h

    r321 r331  
    88#define MRUBY_PROC_H
    99
    10 #include "mruby/common.h"
    11 #include "mruby/irep.h"
     10#include "common.h"
     11#include <mruby/irep.h>
    1212
    1313/**
     
    1919  MRB_OBJECT_HEADER;
    2020  mrb_value *stack;
    21   mrb_sym mid;
    2221  ptrdiff_t cioff;
     22  union {
     23    mrb_sym mid;
     24    struct mrb_context *c;
     25  } cxt;
    2326};
    2427
     
    2730#define MRB_ENV_UNSHARE_STACK(e) ((e)->cioff = -1)
    2831#define MRB_ENV_STACK_SHARED_P(e) ((e)->cioff >= 0)
     32
     33MRB_API void mrb_env_unshare(mrb_state*, struct REnv*);
    2934
    3035struct RProc {
     
    5156#define MRB_PROC_STRICT 256
    5257#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)
    5360
    5461#define mrb_proc_ptr(v)    ((struct RProc*)(mrb_ptr(v)))
     
    6976#define mrb_cfunc_env_get(mrb, idx) mrb_proc_cfunc_env_get(mrb, idx)
    7077
    71 #include "mruby/khash.h"
     78#include <mruby/khash.h>
    7279KHASH_DECLARE(mt, mrb_sym, struct RProc*, TRUE)
    7380
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/range.h

    r321 r331  
    88#define MRUBY_RANGE_H
    99
    10 #include "mruby/common.h"
     10#include "common.h"
    1111
    1212/**
     
    2626};
    2727
    28 #define mrb_range_ptr(v)    ((struct RRange*)(mrb_ptr(v)))
     28MRB_API struct RRange* mrb_range_ptr(mrb_state *mrb, mrb_value v);
     29#define mrb_range_raw_ptr(v) ((struct RRange*)mrb_ptr(v))
    2930#define mrb_range_value(p)  mrb_obj_value((void*)(p))
    3031
     
    4142MRB_API mrb_value mrb_range_new(mrb_state *mrb, mrb_value start, mrb_value end, mrb_bool exclude);
    4243
    43 MRB_API mrb_bool mrb_range_beg_len(mrb_state *mrb, mrb_value range, mrb_int *begp, mrb_int *lenp, mrb_int len);
     44MRB_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);
    4445mrb_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));
    4546
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/re.h

    r321 r331  
    88#define MRUBY_RE_H
    99
    10 #ifdef __cplusplus
    11 extern "C" {
    12 #endif
     10MRB_BEGIN_DECL
    1311
    1412#define REGEXP_CLASS          "Regexp"
    1513
    16 #ifdef __cplusplus
    17 }
    18 #endif
     14MRB_END_DECL
    1915
    2016#endif  /* RE_H */
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/string.h

    r321 r331  
    88#define MRUBY_STRING_H
    99
    10 #include "mruby/common.h"
     10#include "common.h"
    1111
    1212/**
     
    4545  if (RSTR_EMBED_P(s)) {\
    4646    RSTR_SET_EMBED_LEN((s),(n));\
    47   } else {\
     47  }\
     48  else {\
    4849    s->as.heap.len = (mrb_int)(n);\
    4950  }\
     
    6364#define RSTR_UNSET_NOFREE_FLAG(s) ((s)->flags &= ~MRB_STR_NOFREE)
    6465
    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 
    6966/*
    7067 * Returns a pointer from a Ruby string
     
    7370#define RSTRING(s)           mrb_str_ptr(s)
    7471#define RSTRING_PTR(s)       RSTR_PTR(RSTRING(s))
    75 #define RSTRING_EMBED_LEN(s) RSTR_ENBED_LEN(RSTRING(s))
     72#define RSTRING_EMBED_LEN(s) RSTR_EMBED_LEN(RSTRING(s))
    7673#define RSTRING_LEN(s)       RSTR_LEN(RSTRING(s))
    7774#define RSTRING_CAPA(s)      RSTR_CAPA(RSTRING(s))
    7875#define RSTRING_END(s)       (RSTRING_PTR(s) + RSTRING_LEN(s))
    79 mrb_int mrb_str_strlen(mrb_state*, struct RString*);
     76MRB_API mrb_int mrb_str_strlen(mrb_state*, struct RString*);
    8077
    8178#define MRB_STR_SHARED    1
    8279#define MRB_STR_NOFREE    2
    83 #define MRB_STR_FROZEN    4
    84 #define MRB_STR_EMBED     8
    85 #define MRB_STR_EMBED_LEN_MASK 0x1f0
    86 #define MRB_STR_EMBED_LEN_SHIFT 4
     80#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
    8784
    8885void mrb_gc_free_str(mrb_state*, struct RString*);
    8986MRB_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 */
    90132MRB_API void mrb_str_concat(mrb_state*, mrb_value, mrb_value);
    91133
    92134/*
    93135 * 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.
    94185 */
    95186MRB_API mrb_value mrb_str_plus(mrb_state*, mrb_value, mrb_value);
     
    97188/*
    98189 * 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.
    99194 */
    100195MRB_API mrb_value mrb_ptr_to_str(mrb_state *, void*);
     
    102197/*
    103198 * 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.
    104203 */
    105204MRB_API mrb_value mrb_obj_as_string(mrb_state *mrb, mrb_value obj);
    106205
    107206/*
    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.
    109243 */
    110244MRB_API mrb_value mrb_str_resize(mrb_state *mrb, mrb_value str, mrb_int len);
     
    112246/*
    113247 * 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.
    114286 */
    115287MRB_API mrb_value mrb_str_substr(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len);
     
    117289/*
    118290 * 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.
    119296 */
    120297MRB_API mrb_value mrb_string_type(mrb_state *mrb, mrb_value str);
     
    124301
    125302MRB_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);
     303MRB_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 */
     312MRB_API mrb_int mrb_string_value_len(mrb_state *mrb, mrb_value str);
    127313
    128314/*
    129315 * 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.
    130321 */
    131322MRB_API mrb_value mrb_str_dup(mrb_state *mrb, mrb_value str);
    132323
    133324/*
    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.
    135330 */
    136331MRB_API mrb_value mrb_str_intern(mrb_state *mrb, mrb_value self);
     
    146341/*
    147342 * 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.
    148348 */
    149349MRB_API mrb_bool mrb_str_equal(mrb_state *mrb, mrb_value str1, mrb_value str2);
     
    152352 * Returns a concated string comprised of a Ruby string and a C string.
    153353 *
     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.
    154359 * @see mrb_str_cat_cstr
    155360 */
     
    159364 * Returns a concated string comprised of a Ruby string and a C string.
    160365 *
     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.
    161370 * @see mrb_str_cat
    162371 */
     
    176385
    177386/*
    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.
    179400 */
    180401MRB_API char *mrb_str_to_cstr(mrb_state *mrb, mrb_value str);
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/throw.h

    r321 r331  
    88#define MRB_THROW_H
    99
    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)
    1117
    1218#define MRB_TRY(buf) do { try {
     
    2127#include <setjmp.h>
    2228
    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) {
    2438#define MRB_CATCH(buf) } else {
    2539#define MRB_END_EXC(buf) } } while(0)
    2640
    27 #define MRB_THROW(buf) longjmp((buf)->impl, 1);
     41#define MRB_THROW(buf) MRB_LONGJMP((buf)->impl, 1);
    2842#define mrb_jmpbuf_impl jmp_buf
    2943
     
    3347  mrb_jmpbuf_impl impl;
    3448
    35 #ifdef MRB_ENABLE_CXX_EXCEPTION
     49#if defined(MRB_ENABLE_CXX_EXCEPTION) && defined(__cplusplus)
    3650  static mrb_int jmpbuf_id;
    3751  mrb_jmpbuf() : impl(jmpbuf_id++) {}
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/value.h

    r321 r331  
    88#define MRUBY_VALUE_H
    99
    10 #include "mruby/common.h"
     10#include "common.h"
    1111
    1212/**
     
    2121#if defined(MRB_INT16) && defined(MRB_INT64)
    2222# 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>
    2337#endif
    2438
     
    2842# define MRB_INT_MIN (INT64_MIN>>MRB_FIXNUM_SHIFT)
    2943# define MRB_INT_MAX (INT64_MAX>>MRB_FIXNUM_SHIFT)
     44# define MRB_PRIo PRIo64
     45# define MRB_PRId PRId64
     46# define MRB_PRIx PRIx64
    3047#elif defined(MRB_INT16)
    3148  typedef int16_t mrb_int;
     
    3350# define MRB_INT_MIN (INT16_MIN>>MRB_FIXNUM_SHIFT)
    3451# define MRB_INT_MAX (INT16_MAX>>MRB_FIXNUM_SHIFT)
     52# define MRB_PRIo PRIo16
     53# define MRB_PRId PRId16
     54# define MRB_PRIx PRIx16
    3555#else
    3656  typedef int32_t mrb_int;
     
    3858# define MRB_INT_MIN (INT32_MIN>>MRB_FIXNUM_SHIFT)
    3959# 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
     66MRB_API double mrb_float_read(const char*, char**);
    4267#ifdef MRB_USE_FLOAT
    4368  typedef float mrb_float;
    44 # define str_to_mrb_float(buf) strtof(buf, NULL)
    4569#else
    4670  typedef double mrb_float;
    47 # define str_to_mrb_float(buf) strtod(buf, NULL)
    4871#endif
    4972
     
    6386#  define isinf(n) (!_finite(n) && !_isnan(n))
    6487#  define signbit(n) (_copysign(1.0, (n)) < 0.0)
    65 #  define strtof (float)strtod
    6688static const unsigned int IEEE754_INFINITY_BITS_SINGLE = 0x7F800000;
    6789#  define INFINITY (*(float *)&IEEE754_INFINITY_BITS_SINGLE)
     
    94116  MRB_TT_DATA,        /*  21 */
    95117  MRB_TT_FIBER,       /*  22 */
    96   MRB_TT_MAXDEFINE    /*  23 */
     118  MRB_TT_ISTRUCT,     /*  23 */
     119  MRB_TT_BREAK,       /*  24 */
     120  MRB_TT_MAXDEFINE    /*  25 */
    97121};
    98122
    99 #include "mruby/object.h"
     123#include <mruby/object.h>
    100124
    101125#ifdef MRB_DOCUMENTATION_BLOCK
     
    188212  mrb_value v;
    189213  SET_OBJ_VALUE(v, (struct RBasic*)p);
     214  mrb_assert(p == mrb_ptr(v));
     215  mrb_assert(((struct RBasic*)p)->tt == mrb_type(v));
    190216  return v;
    191217}
     
    242268
    243269#ifdef MRB_USE_ETEXT_EDATA
     270#if (defined(__APPLE__) && defined(__MACH__))
     271#include <mach-o/getsect.h>
     272static inline mrb_bool
     273mrb_ro_data_p(const char *p)
     274{
     275  return (const char*)get_etext() < p && p < (const char*)get_edata();
     276}
     277#else
    244278extern char _etext[];
    245279#ifdef MRB_NO_INIT_ARRAY_START
     
    260294}
    261295#endif
     296#endif
    262297#else
    263298# define mrb_ro_data_p(p) FALSE
  • EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/variable.h

    r321 r331  
    88#define MRUBY_VARIABLE_H
    99
    10 #include "mruby/common.h"
     10#include "common.h"
    1111
    1212/**
     
    5555MRB_API void mrb_iv_copy(mrb_state *mrb, mrb_value dst, mrb_value src);
    5656MRB_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 */
    5776MRB_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 */
    5896MRB_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 */
    59116MRB_API void mrb_gv_remove(mrb_state *mrb, mrb_sym sym);
     117
    60118MRB_API mrb_value mrb_cv_get(mrb_state *mrb, mrb_value mod, mrb_sym sym);
    61119MRB_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  
    88#define MRUBY_VERSION_H
    99
    10 #include "mruby/common.h"
     10#include "common.h"
    1111
    1212/**
     
    4343 * Minor release version number.
    4444 */
    45 #define MRUBY_RELEASE_MINOR 2
     45#define MRUBY_RELEASE_MINOR 3
    4646
    4747/*
     
    6363 * Release year.
    6464 */
    65 #define MRUBY_RELEASE_YEAR 2015
     65#define MRUBY_RELEASE_YEAR 2017
    6666
    6767/*
    6868 * Release month.
    6969 */
    70 #define MRUBY_RELEASE_MONTH 11
     70#define MRUBY_RELEASE_MONTH 7
    7171
    7272/*
    7373 * Release day.
    7474 */
    75 #define MRUBY_RELEASE_DAY 17
     75#define MRUBY_RELEASE_DAY 4
    7676
    7777/*
Note: See TracChangeset for help on using the changeset viewer.