Commit Graph

127 Commits

Author SHA1 Message Date
KOBAYASHI Shuji 375c1ebc41 Rename BITSIZE to BIT and BIT to BIT_POS for consistency
The bit width terminology is unified to `BIT` according to `MRB_INT_BIT`
and `CHAR_BIT`. Also the bit position terminology is unified to `BIT_POS`.
2019-11-23 20:40:23 +09:00
KOBAYASHI Shuji a2df247063 Introduce mrb_ssize type for buffer size on memory; ref #4483
Previously, `mrb_int` was used as the type that represents the buffer size
on memory, but the sizes of `RString` and `RArray` exceed 6 words when
`MRB_INT64` is enabled on 32-bit CPU.

I don't think it is necessary to be able to represent the buffer size on
memory that exceeds the virtual address space. Therefore, for this purpose,
introduce `mrb_ssize` which doesn't exceed the sizes of `mrb_int` and
pointer.

I think all `mrb_int` used for this purpose should be changed to
`mrb_ssize`, but currently only the members of the structures (`RString`,
`mrb_shared_string`, `RArray` and `mrb_shared_array`) are changed.
2019-11-21 19:34:02 +09:00
Yukihiro "Matz" Matsumoto 28bbd3e7d9 Add argument names to C function prototypes. 2019-09-14 23:21:44 +09:00
David Siaw 6375639917 fix lots of warnings and make logo not so big 2019-08-26 02:08:33 +09:00
KOBAYASHI Shuji 8157672a29 Use RBasic padding for embedded string on 64-bit CPU
On 64-bit CPU, there is padding in `RBasic`, so reorder the fields and use
it as buffer of embedded string. This change allows 4 more bytes to be
embedded on 64-bit CPU.

However, an incompatibility will occur if `RString::as::ary` is accessed
directly because `RString` structure has changed.
2019-08-20 18:49:55 +09:00
Yukihiro "Matz" Matsumoto b5e2d208b9 Merge pull request #4636 from davidsiaw/doxygen
Generate doxygen docs for mruby
2019-08-19 07:29:46 +09:00
David Siaw b5299b1c58 fix up documentation for values 2019-08-18 20:12:44 +09:00
KOBAYASHI Shuji caba5fef27 Refactor set/unset string type flags
Introduce `RSTR_SET_TYPE_FLAG` macro to set the specified string type flag and
clear the others.
2019-08-17 21:24:08 +09:00
KOBAYASHI Shuji 450684ab33 mrb_str_modify_keep_ascii can embed one more byte
The condition to make an embedded string was incorrect. Because there were
several similar codes, extracted into `RSTR_EMBEDDABLE_P` macro.
2019-08-11 20:48:37 +09:00
Yukihiro "Matz" Matsumoto 98fc887cb3 Reorganize mrb_string_value_cstr and related functions.
`mrb_string_value_cstr` and `mrb_string_value_len`: obsolete
`mrb_string_cstr`: new function to retrieve NULL terminated C string
`RSTRING_CSTR`: wrapper macro of `mrb_string_cstr`
2019-08-07 15:52:10 +09:00
Yukihiro "Matz" Matsumoto b22bde6596 Avoid MRB_INLINE for mrb_str_modify(); ref #4579
Functions that are called infrequently need not to be inline.
2019-07-17 10:36:10 +09:00
KOBAYASHI Shuji 9093f3403f Add MRB_API to mrb_str_modify_keep_ascii() 2019-07-15 07:43:46 +09:00
KOBAYASHI Shuji 380805ece2 Keep MRB_STR_ASCII flag in some methods of String 2019-07-14 19:13:19 +09:00
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 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 0c5f26e0ff Remove unnecessary mrb_regexp_check() and related functions. 2019-04-24 11:43:05 +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 69fd1a5925 Fix Symbol#size for multi-byte characters with MRB_UTF8_STRING
Before:

  p :あ.size  #=> 3

After:

  p :あ.size  #=> 1
2019-02-04 18:11:22 +09:00
dearblue 14133f4057 Fix macro arguments with paren 2018-12-18 23:05:36 +09:00
Yukihiro "Matz" Matsumoto 53e2df3e93 Restore mrb_string_type function for compatibility. 2018-11-19 16:13:26 +09:00
Yukihiro "Matz" Matsumoto 9516731329 Use type checking mrb_to_str instead of converting mrb_str_to_str. 2018-11-19 12:08:28 +09:00
Yukihiro "Matz" Matsumoto ff08856fe3 Remove implicit conversion using to_str method; fix #3854
We have added internal convenience method `__to_str` which
does string type check.

The issue #3854 was fixed but fundamental flaw of lack of stack
depth check along with fibers still remains. Use `MRB_GC_FIXED_ARENA`
for workaround.
2018-11-19 12:05:46 +09:00
dearblue 9da9e5eb4e Fix typo for concatenate 2018-09-07 22:32:34 +09:00
Yukihiro "Matz" Matsumoto e4662d77e7 Should not use FSHARED state for string from irep pools; fix #3829
This strings in `irep` pools may be freed forcefully in `mrb_irep_free`.
This commit probably fixes #3817 as well.
2017-11-03 08:24:47 +09:00
Yukihiro "Matz" Matsumoto 7edbe428ca Add new type of shared string: RSTR_FSHARED.
`RSTR_FSHARED` use frozen strings as shared body instead of
`struct mrb_shared_string`. This reduces allocation from
literal strings.
2017-10-01 16:24:43 +09:00
Tomasz Dąbrowski 3e1d60ae0b fix: src\hash.c(27): warning C4244: '=': conversion from 'mrb_int' to 'khint_t', possible loss of data 2017-09-27 22:22:05 +02:00
Yukihiro "Matz" Matsumoto f1767fd079 Separate mrb_str_buf_new and mrb_str_new_capa.
`mrb_str_buf_new` is an old function that ensures capacity size of
`MRB_STR_BUF_MIN_SIZE` minimum. Usually one need to use
`mrb_str_new_capa` instead.
2017-08-18 22:17:48 +09:00
Christopher Aue f937af5745 Extended Module#const_get to support class paths 2017-07-28 23:19:49 +02:00
Christopher Aue c7018ea962 Added mrb_str_index to the mrb API 2017-07-28 21:07:20 +02:00
Yukihiro "Matz" Matsumoto 77331d127b Unify else clause style 2017-04-03 16:56:27 +09:00
hhc0null af4f6e8dc6 Fix a typo. 2017-01-12 00:02:17 +09:00
Takashi Kokubun 10bb7ad693 Implement Object#freeze 2016-12-11 03:44:15 +09:00
Yukihiro "Matz" Matsumoto f9f19f34dd replace _cstr by _lit for litral C strings; ref #3300 2016-11-27 20:53:25 +09:00
Nobuyoshi Nakada 6511bfd79a Removed trailing spaces 2016-09-28 12:29:41 +09:00
Yukihiro "Matz" Matsumoto afbe211c60 mrb_str_strlen() should be MRB_API; ref #3216 2016-09-27 10:29:56 +09:00
Ralph Desir(Mav7) 189ad47346 yard docs for string.h 2016-07-23 02:47:32 -04:00
Yukihiro "Matz" Matsumoto 25e4ec3f37 cache UTF8 status for utf8_strlen(); ref #980 2016-02-04 23:33:16 +09:00
Yukihiro "Matz" Matsumoto 36fabe104b new API function mrb_string_value_len() 2015-12-01 16:18:01 +09:00
Yukihiro "Matz" Matsumoto 065966dae4 common.h are supposed to be included from other header, so call it with quotes; ref #3032 2015-11-28 00:10:38 +09:00
Yukihiro "Matz" Matsumoto 5c405dea3d include changed from by quotes ("") to by brackets (<>); close #3032 2015-11-27 17:48:23 +09:00
Tomoyuki Sahara 90b7ec88dc YARD doc for mrb_str_to_cstr. 2015-11-24 16:03:58 +09:00
Seba Gamboa 649901b75c Merge doc/api/mruby/string.h.md contents 2015-10-08 12:55:28 -03:00
Seba Gamboa a0fe0c40b1 Remove old doxygen tags 2015-10-08 12:29:10 -03:00
Seba Gamboa 40bf7bde78 Sorting documentation grouping 2015-09-21 01:48:42 -03:00
Seba Gamboa c127614638 Setting up doxygen groups 2015-09-20 21:14:07 -03:00
Seba Gamboa 7505bad677 Playing around with some documentations schemes 2015-09-18 23:59:29 -03:00
Yukihiro "Matz" Matsumoto 1a45447b8b add String#freeze to the core 2015-08-27 17:54:30 +09:00
Yukihiro "Matz" Matsumoto 9e4b012478 Merge pull request #2570 from cubicdaiya/issues/unify_duplicated_functions
Unify and rename duplicated functions (noregexp() and regexp_check()).
2014-08-29 01:09:33 +09:00
Tatsuhiko Kubo 5fa30aeaea Fix mismatches for MRB_API declarations. 2014-08-29 01:06:22 +09:00