Commit Graph

115 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 14206a75a3 Remove potential path to avoid uninitialized variable access. 2018-08-13 23:15:52 +09:00
Yukihiro "Matz" Matsumoto afbbc0a2cb Small refactoring.
The macro `RCLASS_SUPER`, `RCLASS_IV_TBL` and `RCLASS_M_TBL` are
removed from `include/mruby/class.h`.
2018-08-06 10:15:55 +09:00
Yukihiro "Matz" Matsumoto bbb0882343 Modifying frozen objects will raise FrozenError.
`FrozenError` is a subclass of `RuntimeError` which used to be
raised.  [Ruby2.5]
2017-12-12 18:41:18 +09:00
Yukihiro "Matz" Matsumoto 8f2c62407c Add MRB_METHOD_TABLE_INLINE option.
Now the method tables (in classes/modules and caches) keeps C function
pointers without wrapping in `struct RProc` objects. For the sake of
portability, `mrb_method_t` is represented by the struct and union, but
if the most significant bit of the pointer is not used by the platform,
`mrb_method_t` should be packed in `uintptr_t` to reduce memory usage.

`MRB_METHOD_TABLE_INLINE` is turned on by default for linux.
2017-11-20 18:33:41 +09:00
Yukihiro "Matz" Matsumoto 12e38597c8 Always check division-by-zero to avoid undefined behavior; fix #3816
Also removed the code to normalize NaN value for `MRB_NAN_BOXING`.
Tha code was added to fix #1712 but no longer required after 249f05e7d.
2017-11-03 09:35:55 +09:00
Yukihiro "Matz" Matsumoto 77edafb04c Need to check number of argument of Struct#new; fix #3823 2017-10-29 00:25:45 +09:00
Yukihiro "Matz" Matsumoto fb85855fa1 Add more checks before accessing struct pointer; ref #3831 2017-10-17 07:43:35 +09:00
Yukihiro "Matz" Matsumoto be2c1592ed Check struct-array pointer before accessing; fix #3831 2017-10-16 22:53:36 +09:00
dearblue 44e2c97152 fix alias for Struct accessors 2017-10-15 23:43:55 +09:00
Yukihiro "Matz" Matsumoto f26d00d9e8 Embed small size array elements in the heap.
It reduces the memory consumption and sometimes improve the
performance as well.  For example, the consumed memory size
of `bench/bm_ao_render.rb` is reduced from 1.2GB to 1GB, and
its total execution time become 18.795 sec from 22.229 sec.
2017-07-27 16:13:06 +09:00
Yukihiro "Matz" Matsumoto a18904a4c2 Use "$!" specifier of mrb_get_args. 2017-07-12 14:49:55 +09:00
Yukihiro "Matz" Matsumoto 3554a41a54 Remove unnecessary initialization of a local variable. 2017-06-27 22:48:06 +09:00
take_cheeze da5b7fa769 Support freeze in Struct. 2017-04-21 17:23:54 +09:00
Yukihiro "Matz" Matsumoto 17377af984 Struct may not be initialized in #to_h; fix #3607 2017-04-13 10:51:16 +09:00
Yukihiro "Matz" Matsumoto bd7bf260e8 Should specify instance type of Structs; fix #3591 2017-04-05 17:52:26 +09:00
Yukihiro "Matz" Matsumoto 74712c73ac Need to insert write barriers in struct updates; fix #3547 2017-04-05 11:53:20 +09:00
Yukihiro "Matz" Matsumoto 5771c9778e add a test for #3296 2016-11-30 03:51:23 +09:00
Yukihiro "Matz" Matsumoto 37743111d9 should not refer Struct class by name; fix #3296 2016-11-30 03:49:56 +09:00
Yukihiro "Matz" Matsumoto 743c1e7be1 stop warnings in the test; ref #3280 2016-11-25 09:44:22 +09:00
Yukihiro "Matz" Matsumoto 79e3980a7f resolve conflict; ref #3281 2016-11-25 09:31:51 +09:00
Clayton Smith b60d6c42aa Don't allow array parameter in Struct.new 2016-11-24 10:05:05 -05:00
Clayton Smith 82731d9ee0 Remove constant when a struct is redefined. 2016-11-24 10:04:09 -05:00
Tomasz Dąbrowski 8e0dc6fa8d Correct argument specifications for few methods:
- Struct#values_at
 - Module#define_method
 - String#chop
 - String#chop!
2016-11-16 15:46:28 +01:00
Yukihiro "Matz" Matsumoto a66a1e92e7 Merge pull request #3179 from ksss/struct
Should not define to `Struct` class
2016-07-25 14:19:10 +09:00
Yukihiro "Matz" Matsumoto 417092360d Fixed crash error when #initialize is redefined for Struct; fix #3177
refactored redundant functions; removed optimized accessors for safety
this fix also close #3178
2016-07-25 10:32:10 +09:00
ksss bf21063a72 Add regression test 2016-07-22 15:26:17 +09:00
ksss 1a8074accf Should not define to Struct class 2016-07-22 15:26:11 +09:00
Yukihiro "Matz" Matsumoto 817b884343 add #dig tests 2016-03-23 12:34:32 +09:00
Yukihiro "Matz" Matsumoto daf83946bb add #dig to Array,Hash and Struct 2016-03-23 11:49:28 +09:00
Yukihiro "Matz" Matsumoto cf5ca03676 mruby-struct: copied Struct length is not initialized; fix #3114 2016-02-19 11:46:18 +09:00
Yukihiro "Matz" Matsumoto d3c6fafaf3 Merge pull request #2331 from take-cheeze/struct_test
Improve `Struct` test.
2015-12-26 15:46:49 +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 101ec5eb0a don't print anonymous struct class name 2015-09-23 12:51:12 +09:00
Yukihiro "Matz" Matsumoto 20a4e9ade6 mruby-struct gem refactoring 2015-09-23 12:13:01 +09:00
Franck Verrot 2588507285 Remove unnecessary backticks.
Dr Markus Kuhn published in 1999 an article [1] explaining in details
why we shouldn't use the ASCII grave accent (0x60) as a left quotation.

Backticks have been used most notably to produce nice-looking LaTeX
documents but it doesn't seem to be an issue on modern platforms and
for the oldest ones, there are workarounds as mentioned by Dr Kuhn.

[1]: https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html
2015-06-24 13:07:07 +02:00
cremno 2ee84eb3df remove unnecessary including of <ctype.h>
Not needed anymore since 85075bef75
2015-05-28 10:44:20 +02:00
Jun Hiroe ac131c9052 Remove eql_p variable in mrb_struct_eql func 2015-02-07 01:46:56 +09:00
Jun Hiroe 7dff6ab75a Remove eql_p variable in mrb_struct_equal func 2015-02-07 01:46:45 +09:00
takahashim 9dff0aedb1 fix Segmentation fault on Struct#inspect due to recursive Struct object 2015-01-12 20:08:53 +09:00
Yukihiro "Matz" Matsumoto 95c7f570e1 change class argument of mrb_const_defined_at from struct RClass* to mrb_value to make it consistent with mrb_const_defined; ref #2593 2014-09-19 02:51:52 +09:00
Yukihiro "Matz" Matsumoto 48c5321dca constify pointer from RARRAY_PTR to detect potential write barrier bugs.
if you see compiler errors due to this commit, you'd better to use array-modifying
functions, e.g. mrb_ary_set() or mrb_ary_push(), otherwise you might see nasty
GC bugs in the future.  if you are sure what you are doing, replace `RARRAY_PTR(ary)`
by `mrb_ary_ptr(ary)->ptr`. but be warned.
2014-09-12 12:42:39 +09:00
cremno fec2c66ea8 get rid of shadowing variables (mrbgems)
Mostly renaming, except that the definition of struct accessor methods
is now done in a new function.
2014-09-04 12:31:52 +02:00
take_cheeze e6a263a162 Raise NameError as defined in specification when Struct member isn't found. 2014-06-19 22:06:07 +09:00
take_cheeze a2f5840b60 Add tests to Struct#[] and Struct#[]=. 2014-06-19 22:06:07 +09:00
take_cheeze 3d94022b54 Replace return value result passing with assert_* in Struct test. 2014-06-19 22:06:07 +09:00
take_cheeze 77047b5ed4 Test all ISO defined classes direct superclass except Object class.
Move mrbgems ISO direct superclass test to `superclass.rb`.
Skips test if class isn't defined.
Close #2332.
2014-06-15 17:07:01 +09:00
Yukihiro "Matz" Matsumoto ccd871bcca reduce calling mrb_sym2name_len() from struct.c; ref #2365 2014-06-06 09:25:29 +09:00
cremno 025b8f7644 mruby-struct: implement mrb_is_(local|const)_id 2014-06-05 18:48:17 +02:00
cremno 65a7eac1a9 mruby-struct: remove unused functions 2014-06-05 01:31:15 +02:00
cremno 64b0e48dcb mruby-struct: use correct data types 2014-06-05 01:27:39 +02:00