32 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto b716bf005e mruby-range-ext/range.c: use the reference from mrb structure.
Avoid `mrb_class_get()` if possible.
2022-09-12 10:29:45 +09:00
Yukihiro "Matz" Matsumoto 2bea39f339 mruby-range-ext/range.c: Range#cover?() takes a range too. 2022-04-24 14:02:00 +09:00
Yukihiro "Matz" Matsumoto d912b864df mruby-range-ext/range.c: cover? should work with begin-less ranges. 2022-02-09 13:32:20 +09:00
dearblue 5a57602860 Organize the include of header files
- `#include <math.h>` is done in `mruby.h`.
  Eliminate the need to worry about the `MRB_NO_FLOAT` macro.

- Include mruby header files before standard header files.
  If the standard header file is already placed before `mruby.h`, the standard header file added in the future tends to be placed before `mruby.h`.

This change should some reduce the chances of macros that must be defined becoming undefined in C++ or including problematic header files in a particular mruby build configuration.
2021-08-21 15:42:57 +09:00
Yukihiro "Matz" Matsumoto 2bed750eb0 range.c: avoid use of mrb_fixnum_p.
`mrb_int` may not fit in `fixnum` (inline integer).
2021-05-13 15:35:34 +09:00
Yukihiro "Matz" Matsumoto d35677f213 Implement Range#last in mruby-range-ext in Ruby.
This reduce unnecessary calls of `mrb_funcall()`.
2020-10-29 10:43:08 +09:00
Yukihiro "Matz" Matsumoto 6b457d2c00 Merge branch 'work_for_merge' of https://github.com/zubycz/mruby into zubycz-work_for_merge 2020-10-15 18:35:13 +09:00
taiyoslime bec4d05340 Introduce endless range (a part of #5085)
Co-Authored-By: n4o847 <22975590+n4o847@users.noreply.github.com>
Co-Authored-By: smallkirby <ssmallkirby@gmail.com>
2020-10-13 14:09:36 +09:00
Yukihiro "Matz" Matsumoto 2b188ed8a1 Reorganize Integer system.
- Integrate `Fixnum` and `Integer`
- Remove `Integral`
- `int / int -> int`
- Replace `mrb_fixnum()` to `mrb_int()`
- Replace `mrb_fixnum_value()` to `mrb_int_value()`.
- Use `mrb_integer_p()` instead of `mrb_fixnum_p()`
2020-10-12 18:19:54 +09:00
Yukihiro "Matz" Matsumoto 8a87549315 Rename float configuration option names.
- `MRB_WITHOUT_FLOAT` => `MRB_NO_FLOAT`
- `MRB_USE_FLOAT` => `MRB_USE_FLOAT32`

The former is to use `USE_XXX` naming convention. The latter is to make
sure `float` is 32bit float and not floating point number in general.
2020-10-12 16:21:40 +09:00
Yukihiro "Matz" Matsumoto 00f5ddc9ae Use mrb_funcall_id() extensively.
Except for support files e.g. `mruby-test/driver.c`, which are not
target of symbol collection via `rake gensym`.
2020-10-12 16:20:58 +09:00
Yukihiro "Matz" Matsumoto 49ae2a69f2 Add mrb_get_arg1() that retrieves single (and only) argument.
`mrb_get_arg1()` raises `ArgumentError` if the method does not receive one
argument.

And replaces all `mrb_get_args(mrb, "o", &arg)` by the new function.
2020-06-20 12:49:46 +09:00
Yukihiro "Matz" Matsumoto 76f1aa7de5 Remove mrb_funcall from <=> operations. 2019-09-14 09:05:32 +09:00
Yukihiro "Matz" Matsumoto 2add864164 Allow mruby-range-ext to work with MRB_WITHOUT_FLOAT; ref #4576 2019-07-17 10:36:10 +09:00
dearblue c96b517ea2 Error needed/conflicts configuration
The purpose is to clarify the error if there is a needed/conflicts
configuration at compile time.
2019-07-14 00:29:17 +09:00
Yukihiro "Matz" Matsumoto 1c574b065d Remove mrb_ prefix from static functions in mruby-range-ext; #4213 2019-01-04 14:46:17 +09:00
KOBAYASHI Shuji 648b57620a range: Embed edges in RRange on boxing environment.
[Breaking changes]

Developers must use following APIs for accessing attributes of RRange
because RRange structure depends on boxing setting.

- mrb_range_beg
- mrb_range_end
- mrb_range_excl_p
2019-01-01 15:35:56 +09:00
Yukihiro "Matz" Matsumoto 1d781da8a6 Should not include float.h here. 2017-08-11 13:52:01 +09:00
Yukihiro "Matz" Matsumoto bc1259de3b add explicit casts 2017-01-02 17:48:44 +09:00
Yukihiro "Matz" Matsumoto 79a621dd73 Check before retrieving struct RRange pointer; fix #3320
range->edges may be NULL for example when #initialize_copy removed.
2016-12-03 12:30:01 +09:00
Tomasz Dąbrowski 72ed7eebc3 Fixed Range.size to use proper floating point tolerance 2016-11-24 12:50:49 +01:00
ksss 682237be6e Reimplements Range#first
Range#first shouldn't call `Range#to_a` on infinity range.
2016-11-21 16:55:49 +09:00
ksss 22390aa1c8 Use mrb_float instead of double 2016-11-19 23:25:08 +09:00
ksss a2fbd80a47 Fix Range#size results 2016-11-19 23:25:07 +09:00
Yukihiro "Matz" Matsumoto 5c405dea3d include changed from by quotes ("") to by brackets (<>); close #3032 2015-11-27 17:48:23 +09:00
Yukihiro "Matz" Matsumoto 91a025b1e6 reimplement Range#size using double with fixing corner cases; ref #2293 2014-05-19 18:04:27 +09:00
Jun Hiroe 4b3ff090ab Add Range#size 2014-05-19 16:17:10 +09:00
Yukihiro "Matz" Matsumoto 7c82b9e1bf use mrb_get_args("i") 2014-03-21 23:36:03 +09:00
cremno 09bb30870b tiny word boxing optimization 2014-01-02 06:36:29 +01:00
Jun Hiroe 8e42868600 Repalace int with mrb_bool because a return value is boolean. 2013-07-15 23:17:12 +09:00
Yukihiro "Matz" Matsumoto 30d580ecbc rename every ARGS_XXX to MRB_ARGS_XXX; ref #1206 2013-04-25 09:47:36 +09:00
h2so5 1d10912076 Add mruby-range-ext 2013-04-14 13:59:46 +09:00