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 edited
1 moved

Legend:

Unmodified
Added
Removed
  • 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);
Note: See TracChangeset for help on using the changeset viewer.