Commit Graph

1177 Commits

Author SHA1 Message Date
KOBAYASHI Shuji f9bf2d9d8e Read/write MRB_STR_ASCII flag only when MRB_UTF8_STRING is defined 2019-07-05 22:19:31 +09:00
Yukihiro "Matz" Matsumoto 991bdd4ed7 Rename MRB_STR_NO_UTF to 'MRB_STR_ASCII`; close #4550
In #4550, @shuuji proposed the name name `MRB_STR_NO_MULTI_BYTE` for
more precise description. Although I agree that the name name is
correct, but the flag means the string does not contain multi byte UTF-8
characters, i.e. all characters fit in the range of ASCII.
2019-07-04 23:07:18 +09:00
KOBAYASHI Shuji d915261590 Refine document to mrb_get_args()` [ci skip] 2019-07-03 20:41:30 +09:00
Yukihiro "Matz" Matsumoto 84779f0170 Merge pull request #4532 from shuujii/fix-String-byteslice-with-MRB_UTF8_STRING-and-some-edge-cases
Fix `String#byteslice` with `MRB_UTF8_STRING` and some edge cases
2019-06-26 12:41:56 +09:00
KOBAYASHI Shuji 75df13a973 Fix String#byteslice with MRB_UTF8_STRING and some edge cases
Example:

  $ bin/mruby -e '
    p "あa".byteslice(1)
    p "bar".byteslice(3)
    p "bar".byteslice(4..0)
  '

  Before this patch:

    "a"
    ""
    RangeError (4..0 out of range)

  After this patch (same as Ruby):

    "\x81"
    nil
    nil
2019-06-25 23:09:23 +09:00
Yukihiro "Matz" Matsumoto f268ecaf0d Merge pull request #4516 from shuujii/fix-struct-RRange-overflow-on-32-bit-CPU-with-MRB_NAN_BOXING
Fix `struct RRange` overflow on 32-bit CPU with `MRB_NAN_BOXING`
2019-06-25 22:44:31 +09:00
KOBAYASHI Shuji 4d9d6faf0d Remove unneeded statement in SET_OBJ_VALUE with boxing_word.h
`(r).value.bp` and `v` have the same value due to assignment of the line
preceding the removed line.
2019-06-19 17:50:20 +09:00
KOBAYASHI Shuji 81828f8b08 Fix struct RRange overflow on 32-bit CPU with MRB_NAN_BOXING 2019-06-18 18:17:03 +09:00
KOBAYASHI Shuji 9bd692bc67 Fix class name validation in Struct.new
Before this patch:

  $ bin/mruby -e 'p Struct.new("A-")'
  #=> Struct::"A-"

After this patch:

  $ bin/mruby -e 'p Struct.new("A-")'
  #=> NameError: identifier A- needs to be constant
2019-06-13 21:24:48 +09:00
dearblue 81ea89f10e Need explicit cast for C++ 2019-06-04 21:41:40 +09:00
Yukihiro "Matz" Matsumoto 2b81ea7ec1 Add mrb_alloca again; ref #4470
This time, the allocated memory comes from the string object, which is
referenced from GC arena. The memory region will be reclaimed when the C
function called from VM is terminated, or the GC arena is restored.
2019-05-29 11:47:12 +09:00
dearblue d1e1bb0d5b Remove mrb_alloca() function
When I found this function, I expected it to behave the same as the
`alloca(3)` function, but it is accually the `mrb_alloca()` function
does not free the heap until the `mrb_close()` function is called.

Also, even if it is deleted, it can be replaced with the combination
of the `MRB_TT_DATA` object and the `mrb_gv_set()` function if it is
sure necessary.
2019-05-25 23:59:43 +09:00
dearblue 56e0e1934d Name the return value of mrb_range_beg_len() 2019-05-25 12:12:21 +09:00
Yukihiro "Matz" Matsumoto 85a2dfc841 Merge pull request #4403 from dearblue/read-irep-from-buf
Read irep from buffers
2019-05-22 08:58:50 +09:00
Yukihiro "Matz" Matsumoto e941cf06a3 Export mrb_int_value that converts mrb_float to Fixnum.
Or `Float` if `mrb_float` value is too big (or too small) to fit in
`mrb_int`. The `_int_` in `mrb_int_value` means `Integral` module, which
represents integer-like values in mruby.
2019-05-21 21:08:26 +09:00
Yukihiro "Matz" Matsumoto 8b8bf9f3f6 Add new functions for numerical operation; ref 237a57b
New functions:
* mrb_num_plus(mrb, x, y)
* mrb_num_minus(mrb, x, y)
* num_num_mul(mrb, x, y)
2019-05-20 14:59:25 +09:00
dearblue 67fc3428cb Remove "LINE" section reader
Because it is not currently output by `mrbc`.
2019-05-19 11:09:25 +09:00
Yukihiro "Matz" Matsumoto e41f15747e Rename struct RIstruct to struct RIStruct. 2019-05-18 11:10:20 +09:00
dearblue a14ae80102 (Proof of Concept) mruby tuning profiles [ci skip]
Not only mruby, it is one of the difficult things to adjust the performance vs. memory efficiency of the software.
If the approximate target device is divided and the adjustment value for it is prepared by default, it is a good indicator to do fine adjustment.

This PR divides into four profiles.

***Caution: There is no basis for the definitions in the patch.***

- `MRB_CONSTRAINED_BASELINE_PROFILE` - for microprocessors. Reduce memory consumption.
- `MRB_BASELINE_PROFILE` - Default value of mruby.
- `MRB_MAIN_PROFILE` - For desktop computers. Assume that a huge amount of RAM, 10 MiB or more, is on board.
- `MRB_HIGH_PROFILE` - for servers. Assume that mruby VM has a long life.

As you can see the profile name has been ~~stolen~~ imitated from H.264.
2019-05-17 22:32:01 +09:00
Yukihiro "Matz" Matsumoto 237a57bbe8 Make unused functions private.
* mrb_fixnum_plus()
* mrb_fixnum_minus()
* mrb_fixnum_mul()
2019-05-17 11:30:38 +09:00
Yukihiro "Matz" Matsumoto 0c91da257b Remove unused mrb_num_div() function. 2019-05-17 11:27:21 +09:00
Yukihiro "Matz" Matsumoto 283530b19b Use mrb_float instead of double in FIXABLE_FLOAT. 2019-05-17 10:37:49 +09:00
Yukihiro "Matz" Matsumoto 304b52fabe Set maximum string (and symbol) size to 65534 (UINT16_MAX-1).
The previous value (`UINT16_MAX`) was too long for symbols, so it raises
an exception after the length check.
2019-05-16 11:44:51 +09:00
Ukrainskiy Sergey 8808219e6d Initial suffix support 2019-05-15 16:57:21 +09:00
Yukihiro "Matz" Matsumoto 7f1f499b22 Merge pull request #4400 from shuujii/fix-name-assignment-to-frozen-anonymous-class-module
Fix name assignment to frozen anonymous class/module
2019-05-15 15:47:02 +09:00
Yukihiro "Matz" Matsumoto f83112cea2 Fixed include specifier format for mruby/common.h. 2019-05-02 22:55:19 +09:00
dearblue 828a998941 Update document for MRB_USE_CUSTOM_RO_DATA_P 2019-04-27 22:29:20 +09:00
dearblue b57f61ac95 Update document for any configurations
- (Modify) `MRB_INT16`
- (Add)    `MRB_INT32`
- (Modify) `MRB_INT64`
- (Add)    `MRB_USE_ETEXT_EDATA`
- (Add)    `MRB_NO_INIT_ARRAY_START
- (Add)    `MRB_WITHOUT_FLOAT`
- (Add)    `MRB_METHOD_CACHE`
- (Add)    `MRB_METHOD_CACHE_SIZE`
- (Add)    `MRB_METHOD_TABLE_INLINE
- (Add)    `MRB_ENABLE_ALL_SYMBOLS`
2019-04-27 22:28:54 +09:00
dearblue 302ad847a3 Add customized mrb_ro_data_p()
User definable `mrb_ro_data_p()` functions are available
by defining `MRB_USE_CUSTOM_RO_DATA_P`.

(Limitation) It can not be defined as an inline function.
2019-04-26 21:28:57 +09:00
dearblue 8f6f36f654 Add mruby binary loader functions from buffer memory
Add new functions (with `MRB_API`):
- `mrb_read_irep_buf()`
- `mrb_load_irep_buf()`
- `mrb_load_irep_buf_cxt()`
2019-04-24 22:56:39 +09:00
Yukihiro "Matz" Matsumoto 163a6d01e0 Reorganize defines related to MRB_INLINE; ref #4391 2019-04-24 12:09:16 +09:00
Yukihiro "Matz" Matsumoto 0c5f26e0ff Remove unnecessary mrb_regexp_check() and related functions. 2019-04-24 11:43:05 +09:00
KOBAYASHI Shuji cc7f9190ba Fix name assignment to frozen anonymous class/module
Fix the following issues:

  A = Class.new.freeze              #=> FrozenError
  Module.new::B = Class.new.freeze  #=> FrozenError
  String::B = Module.new.freeze     #=> FrozenError
2019-04-23 20:45:38 +09:00
Yukihiro "Matz" Matsumoto 49cb149033 Merge pull request #4391 from dearblue/inlines
Change modifier to `MRB_INLINE` from `static inline`
2019-04-22 21:17:27 +09:00
KOBAYASHI Shuji b212050026 Expand BOXWORD_SET_VALUE() macro in include/mruby/boxing_word.h
In `SET_OBJ_VALUE()`, branch isn't removed because `switch` condition isn't
constant expression.
2019-04-20 21:23:58 +09:00
dearblue 125c3bef19 Add mrb_true_p() and mrb_false_p() macro functions 2019-04-19 22:50:05 +09:00
dearblue 6907e97fa1 Change modifier to MRB_INLINE from static inline 2019-04-19 22:24:22 +09:00
KOBAYASHI Shuji 79a7f18150 Avoid potential zero size array declaration; fix #4382 2019-04-16 19:56:11 +09:00
Yukihiro "Matz" Matsumoto 88ac7549c0 Remove MRB_API from mrb_instance_new. 2019-04-10 19:11:35 +09:00
Yukihiro "Matz" Matsumoto d0b30f4ce2 Merge pull request #4367 from shuujii/extract-frozen-checking-to-function
Extract frozen checking to function
2019-04-10 06:03:32 +09:00
KOBAYASHI Shuji e3beef065c Extract frozen checking to function 2019-04-09 18:23:11 +09:00
KOBAYASHI Shuji f89fe04d54 Remove unneeded function prototypes 2019-04-08 22:34:49 +09:00
Yukihiro "Matz" Matsumoto f882b6908e Merge pull request #4357 from mruby/stable
Update version and release date. `mruby 2.0.1 (2019-4-4)`
2019-04-05 17:06:21 +09:00
KOBAYASHI Shuji ed41bbb199 Use mrb_proc_arity instead of Proc#arity call in Method#arity 2019-04-04 22:17:26 +09:00
Hiroshi Mimaki 7c91efc1ff Update version and release date.
`mruby 2.0.1 (2019-4-4)`
2019-04-04 09:26:40 +09:00
KOBAYASHI Shuji 9b7e9addcd Pad leading zero to month and day in MRUBY_RELEASE_DATE
For Ruby compatibility.
2019-04-02 16:24:07 +09:00
Yukihiro "Matz" Matsumoto 2871d0cdc5 Avoid keeping pointers from mrb_sym2name_len(); fix #4342
The addresses for packed inline symbols reference `mrb->symbuf` that
could be overridden by the later call of `mrb_sym2name_len`. Since
file names in call stack information are kept as symbols, keeping the
address in the C structures could cause problems like #4342.

This changes small incompatible changes in function prototypes:
* `mrb_parser_get_filename`: return value changed to `mrb_sym`.
* `mrb_debug_get_filename`: add `mrb_state*` as a first argument.
* `mrb_debug_get_line`: ditto.

I believe above functions are almost internal, and no third-party
mrbgem use them.
2019-04-01 14:13:06 +09:00
Tomoyuki Sahara d8d59f70c1 va_list is defined in stdarg.h.
fixes build on OpenBSD.
2019-03-29 11:55:04 +09:00
Yukihiro "Matz" Matsumoto c2660b8111 Fix missing MRB_API prefix for functions below; clse #4267
Functions to add prototypes to headers:
* mrb_ary_splice()
* mrb_notimplement()
* mrb_vformat()
* mrb_cstr_to_dbl()
* mrb_cstr_to_inum()

Functions to be made `static` (`MRB_API` was not needed):
* mrb_mod_module_function()
* mrb_obj_hash()
* mrb_str_len_to_inum()

Functions to remove `MRB_API` from definitions (referenced from within `libmruby`):
* mrb_mod_cv_defined()
* mrb_mod_cv_get()
* mrb_f_send()
2019-03-26 10:23:52 +09:00
KOBAYASHI Shuji 16b1b2978e Fix constant name validation
`X!` etc are invalid constant name.
2019-03-14 23:09:05 +09:00