This articles was published on 2013-04-04

[March 2013] mruby news

What happened on the mruby front in March 2013?

Improve stdlib

The Integer and String class was partly refactored and some bug fixes were applied to the RegExp API.

Random GEM

The mruby-random GEM was created and added to the mruby core. It is based on a C Random Number Generator Library from Takuji Nishimura and Makoto Matsumoto.

Gemification

mrbgems seems to have reached a definite breakthrough. The following core GEMs were created only in this month: mruby-print, mruby-sprintf, mruby-eval, mruby-enum-ext, mrb-array-ext, mruby-string-ext, mruby-numeric, mruby-struct and mruby-hash-ext. Some of these GEMs contain functionalities which were previously in the mruby core. As a GEM it is now possible to remove these features without patching the source.

Syntax Improvement

Several literals like %W, %w, %s, %I and %i were added to mruby by FUKUZAWA Tadashi. He also implemented the missing here documents.

API Improvements

Masaki Muranaka was working very hard this month. With around 100 commits only this month he improved the API quite dramatically by abstracting internal C structures and functions.

Commits

Here a list with all commits during this month.

Improve std lib

Integer.round have no arg.

Move Integer.{floor,ceil,round,truncate} to mrblib/. For maintainability.

Remove unused functions.

undef Integer#new; ref #1111

add Integer#chr test case: multibyte (raise RangeError)

add “strip” family to String.

Add String#dump method.

bugfix escape charactor for Regexp class

Random

Add test for Random::srand

Fix test for mruby-random

Add test for mruby-random

Activated mruby-random

Refactoring mruby-rand

Add Random#rand and Random#srand

Add Kernel#rand and Kernel#srand

Change Random module to class

add mt19937ar license (BSD) to LEGAL

Modified license information for mruby-random

Add mruby-random mrbgem (no activation though)

Gemification

Remove unused mrb_sprintf

mruby-sprintf should precede mruby-print

Add mruby-print

Remove __printstr__

add mruby-eval mrbgem (no activation though)

add mruby-hash-ext mrbgem, and method: Hash#merge!

Add double-quote

add Enumerable#group_by

add Enumerable#each_slice

add method(uniq, -, |, &, flatten, compact) and test of Array to mruby-array-ext

add Enumerable#each_cons

add Enumerable#take, Enumerable#take_while

add Enumerable#drop_while

add Enumerable#drop

add mruby-enum-ext

update build_config.rb

update build_config.rb

add mrbgem: mrb-array-ext

add mrbgems/ext/mruby-numeric, and method: Integer#chr

add mrbgems/mruby-string-ext, and method: String#getbyte

Separate Kernel#sprintf support from mruby core. It’s moved to mrbgems.

Move src/sprintf to mrbgems/mruby-sprintf/src/

Move mrblib for Struct

Gemify

Pluggable Struct

Pluggable Struct

Syntax Improvement

implement literal %W %w %s refactor string parsing

%I %i literal

refactor heredoc identifier

allow backtick as a symbol

Backtick operation

refactor heredoc identifier

implement literal %W %w %s refactor string parsing

implement heredoc

API Improvements

Add new API mrb_ptr_as_string().

Rename API mrb_str_cat2() to mrb_str_cat_cstr(). This is for naming orthogonality. mrb_str_cat2() is also left for backward compatibility.

Add new API mrb_intern_cstr(). This is for naming orthogonality. mrb_intern is also left for backward compatibility.

add new macro mrb_bool as a counterpart of mrb_bool_value

rename mrb_true_or_false_value() to mrb_bool_value()

Use mrb_true_or_false_value() / in sym_equal().

Use mrb_true_or_false_value() / in mrb_str_include().

Use mrb_true_or_false_value() / in mrb_str_eql().

Use mrb_true_or_false_value() / in mrb_str_empty_p().

Use mrb_true_or_false_value() / in mrb_str_equal_m().

Use mrb_true_or_false_value() / in range_eql().

Use mrb_true_or_false_value() / in mrb_range_include().

Use mrb_true_or_false_value() / in mrb_range_eq().

Use mrb_true_or_false_value() / in mrb_range_excl().

Use mrb_true_or_false_value() / in false_or().

Use mrb_true_or_false_value() / in false_xor().

Use mrb_true_or_false_value() / in true_xor().

Use mrb_true_or_false_value() / in true_and().

Use mrb_true_or_false_value() / in fix_equal().

Use mrb_true_or_false_value() / in flo_finite_p().

Use mrb_true_or_false_value() / in flo_eq().

Use mrb_true_or_false_value() / in num_eql().

Use mrb_true_or_false_value() / in obj_respond_to().

Use mrb_true_or_false_value() / in mrb_obj_is_kind_of_m().

Use mrb_true_or_false_value() / in mrb_obj_ivar_defined().

Use mrb_true_or_false_value() / in obj_is_instance_of().

Use mrb_true_or_false_value() / in mrb_f_block_given_p_m().

Use mrb_true_or_false_value() / in mrb_equal_m().

Use mrb_true_or_false_value() / in mrb_obj_not_equal_m().

Use mrb_true_or_false_value() / in mrb_obj_equal_m().

Use mrb_true_or_false_value() / in hash_equal().

Use mrb_true_or_false_value() / in mrb_hash_has_keyWithKey().

Use mrb_true_or_false_value() / in mrb_hash_empty_p().

Use mrb_true_or_false_value() / in gc_generational_mode_set().

Use mrb_true_or_false_value() / in change_gen_gc_mode().

Use mrb_true_or_false_value() / in gc_disable().

Use mrb_true_or_false_value() / in gc_enable().

Use mrb_true_or_false_value() / in exc_equal().

Use mrb_true_or_false_value() / in mrb_mod_eqq().

Use mrb_true_or_false_value() / in mrb_mod_const_defined().

Use mrb_true_or_false_value() / in mrb_mod_method_defined().

Use mrb_true_or_false_value() / in mrb_mod_cvar_defined().

Use mrb_true_or_false_value() / in mrb_bob_not().

Use mrb_true_or_false_value() / in mrb_ary_eql().

Use mrb_true_or_false_value() / in mrb_ary_equal().

Use mrb_true_or_false_value() / in mrb_ary_empty_p().

Use mrb_true_or_false_value() / in mrb_struct_eql().

Use mrb_true_or_false_value() / in mrb_struct_equal().

Remove the macro mrb_bool_value(). Use mrb_true_or_false() instead.

Add new API mrb_true_or_false_value().

Add a new function mrb_flo_to_str(). Use it instead of sprintf() as possible.

rename mrb_basic to mrb_basic_ptr; close #1011

obsolete mrb_object; opposite of bc870ce

mrb_str_new2 -> mrb_str_new_cstr

Modify API configuration. C API mrb_p() is always callable. – But it will do nothing when ENABLE_STDIO is not defined.

Change the second argument of mrb_flo_to_str(). Export mrb_flo_to_str() as API.

Remove mrb_flt2big() as there is no bignum in the core. Add new API mrb_flo_to_fixnum(). You can replace mrb_flt2big() to mrb_flo_to_fixnum() with few modifications.

Remove API mrb_string_value(). There have mrb_str_to_str() in the core. And mrb_string_value() is no merit to keep using.

Remove str_to_mrb_int(). There is some reasons. It is not used in the core. It does not have mrb_ prefix. strtol() is slightly heavy and we have similar API.

use new mrb_format API from mrb_raisef; its only format specifier is “%S” (stringify) and takes mrb_value; close #1062

Reduce using snprintf(). They can replace by mruby API.

use size_t for string length C API

Others

Fix the calc_crc_16_ccitt signature to match the source file

should have rewinded stack on exceptions; close #1113

revive #to_int

move to_i from fixnum to integer; remove reference of to_int which is not in ISO

cancel f4c27c6 since mruby.h is required for mrb_value etc. anyway

Add null char terminate to each symbol name.

Change to return the exception object when an exception occurred in mrb_funcall

Rename mrb_fix2str() to mrb_fixnum_to_str(). This is for naming consistency.

Include mrbconf.h as MRB_INT_MAX used here.

Fixed testrb load path

Display the command line when mrbc is kicked in the verbose mode.

Add CHAR_BIT check. There are uint8_t to char conversions.

Reduce temporary memory allocations. They are redundant.

Modify the type of line-number to uint16_t. Type short is not portable. And it cannot be more than UINT16_MAX because of the mrbc binary format.

Reduce temporary memory allocations. They are redundant.

Remove RiteFile as no used.

Allow globals that start with $_

Rearrange SIZE_MAX. It is supported also VC++ since its version10. And there seems SIZE_MAX is defined in stdint.h. And it possibly (depends on the version of VC++) conflicts with SIZE_MAX in limits.h. This patch is no need if I did not support VC++.

Move TRUE/FALSE existence checks.

Sort include files. Some redundant includes are removed.

Remove limits.h from numeric.h. Add limits.h to some C files.

Fixed wrong section size calculation

Fix a type mismatch.

return value from fread(3) just cannot be ignored

Fix format for new mrb_raisef().

Add arena guard. It will be exausted when the pool is huge.

Fix argunum_error() to use mrb_format().

Fix %s to %S.

Modify mrb_name_error() to use mrb_format().

Catch return values to silent compiler

Fix raisef formats in struct.c.

LEGAL file generator for binaries

Fix. In some cases, %S substitutions were failed.

Remove the escape backslash from the result string.

replace non formatting printf to (f)puts

implement mrb_format and mrb_vformat

Use mrb_check_datatype directly to avoid warning.

Remove empty line

Fix .travis.yml

Add travis_config.rb

Add simple usage message for mirb

Fix build error on VS2012 toolchain. A local variables define beginning of a scope block. VS2012 unacceptable “;;” in struct definition.

Added debug infomation section into .mrb file

Remove unused variable

bug in fread(3) error check

little cosmetic change (delete word Rite); bump dump file version number

Support mt instance valiables

Use C99 flexible array in pool.c

main.to_s should also return “main”

Changed to static functions

remove all MRB_TT_MAIN from source

use C99 flexible array member instead of [1]

zero length array is GCC extension

fixed build error on VS2012 toolchains.

Preprocessor # should be the top of line.

Remove unused macros.

Remove #if 0 … #endif code.

remove unused functions ‘mrb_strerrno’ and ‘mrb_bug_errno’.

Fix indentation in mirb.c

Make mrb_top_self return a real instance.

Make topenv() static inlined

Add stdio.h. This is just for now. We should discuss about remote tests later.

Separate FILE dependencies with ENABLE_STDIO.

Include stddef.h. It is required by size_t. In case you include stdio.h, stddef.h is included indirectly.

Adjusted indent, space and tab

Changed the RData type field to ‘const’

fixed NaN boxing compilation

Remove needless prototype

Use size_t instead of int. This is for portability.

For particular environments which has 25 < n < 32 bit int. There is no cost even if you use 16/32bit int targets.

Add brances to macro parameter. It may be refactored as GET_UNPACK_{b,c} are used only by GETARG_{b,c}.

Use ptrdiff_t instead of int. This is for portability.

Use mrb_bool instead of int. This is for portability; based on e767ebf but iv_foreach_func must return int

Remove unused marco CODEGEN_DUMP.

rename mrb_ptr_as_string() to mrb_ptr_to_str()

Remove _obj_classname() as unused.

Use mrb_obj_classname() instead of _obj_classname(). They are complietely same.

Remove *printf() that have “%p” format as possible. Use tomrb_ptr_as_string() instead.

Set MRB_TT_MODULE to Module.

Use mrb_str_cat() instead of mrb_str_cat2() as possible.

Add bitbucket git support.

Make array.c and vm.c share value_move().

Array bang methods should return nil if no change happen

Add configuration macro MRB_PARSER_BUF_SIZE.

Add an internal function intern_c(). It reduces function call parameter. For maintainability and performance.

Make intern_gen() inline. This is enough tiny to be inlined.

Use mrb_intern2() instead of mrb_intern(). This is for avoiding overhead by strlen().

Use mrb_intern2

Use `

fix comment.

fix the type of value that is returned by bit-shift expression.

“Ax” is larger than 16-bit.

fix the type of value that is returned by bit-shift expression.

fix the type of value that is returned by bit-shift expression.

remove gperf installation that is not needed if src/lex.def is properly updated; cancel #1037

update lex.def

Update Travis CI build to install gperf.

Fix indentation in keywords

Add gem version to build summary if it exists.

fix comment

fix spelling

remove unused local variable beg in parser_yylex

bugfix about escaping ‘n’

remove disused check code

Could you add me to AUTHORS?

Simplify conditional expressions. This is for speed tuning.

Lazy variable declarations. They are for speed tune.

Clean some redundant code up.

Make topenv() inlined.

Extract uvget/uvset to OP_GETUPVAR/OP_SETUPVAR. This is for speed tuning.

Make some tiny functions inlined. This is for supeed tuning.

Remove mrb_checkstack() as unused.

Optimize OP_SUBI.

Optimize OP_ADD instruction.

remove unused local variable beg in parser_yylex

personal style preference on function call in flo_to_s

fix the type of argument named ‘aspec’. ‘aspec’ should be large at least 24 bit.

applying C++ patch from @monaka to support C++ bool type; close #1019

Removed unused expr

fix the type of bit field variable. if ‘int’ type is 16bit integer, ‘unsigned int flags: 21′ is too large.

bugfix about escaping ‘n’

remove disused check code

Could you add me to AUTHORS?

remove bit-shift operation.

Remove memmove(). Use value_move() instead.

Fix a warning happens on MRB_INT64 enabled.

Add float.h. It exists even if the environment was freestanding. It has been supported since C89.

refine abf1b18 to remove nested if

Add Build Example for Arduino Due

Remove stdio.h as it is included in mrbconf.h.

Remove stdlib.h from mruby.h. It is for portability (care for freestanding environments). This is a first step. It will be reduced stdlib.h in each files later.

Remove unnecessory stdint.h.

Include mruby.h. As KHASH_DEFAULT_SIZE might be defined in mrbconf.h.

Remove unused string.h.

Remove strncmp(). It enables to process various options.

Remove string.h in khash.h

Avoid to call memset(). Use the new function kh_fill_flags() instead. This is for compatibility.

Change the place of the close parenthesis. Even though it probably cause no bugs for current code.

display BasicObject information in mirb

removed compatibility macros mrb_ary_new_elts() and mrb_ary_new4()

Remove bit-fields. They doesn’t reduce memory on major environments.

rename method

bug fix: fix wrong method name.

support ‘Cygwin’ as build platform.

Fix indentation in symbol.c

bug fix: fix “–sysroot” option and host platform detection.

Add break to default case in switch statement

add mrb_int overflow check for mrb_int

experimental MRB_INT16 added

use mrb_int as possible based on a patch from @monaka; close #994

symbol length make size_t from mrb_int; cancel #993 monaka/pr-cleanup-symbol.c-20130312

remove PARANOID from comments

Define type mrb_bool. It is typedef-ed to _Bool on C99, unsigned int on MSVC. It is safer than applying 1bit bit-fields to signed int.

Remove compiler warning

Cut off eval_test from main

Add null check

Extract stack zero filling to stack_clear(). Porting evelopers can optimize by replacing to memset() on their own risk.

Simplify. Temporary variable “i” is removed.

Add the type check in mrb_str_to_cstr().

set DATA_TYPE as soon as possible.

mrb_sys_fail raises SystemCallError if we have it.

Use mrb_int as possible.

Copy to *lenp just in case lenp != NULL.

Remove unused return value in mruby.c

Replace tabs with spaces

Add static declaration

Use suitable types for variables.

Use suitable types for variables.

Use int. They are no need to use unsigned/signed long. Think about 16bit architectures.

Add comments for paradnoid (a.k.a. mission critical) engineers.

Remove a meaningless type cast.

Remove str_alloc(). Use mrb_obj_alloc_string instead.

Remove mrb_str_sublen() as it is not used.

Remove mrb_str_new2(). Use mrb_str_new_cstr() instead. Make mrb_str_new_cstr() accept NULL pointer. It generates 0byte strings by NULL pointer.

Fix indents.

Rename STR_BUF_MIN_SIZE to MRB_STR_BUF_MIN_SIZE. Make it configurable.

fix inspect method

restore arena after mrb_define_method()

return value from mrb_gc_arena_save() is int

Fix typo

Fix indent in string.c

Change default gem path.

more CFLAGS and LDFLAGS are specified automatically.

add a new feature to select the target Android platform.

add a new feature to select the target architecture.

define and use print format macros for mrb_int

OP_ARRAY may overflow ARG_C

Fix warnings.

Don’t use int. It decreases portability. Use size_t as array index and length. It avoids overflow in the extreme situations.

Sanity check. As there are implicaton SIZE_MAX >= UINT32_MAX in this code. This assumption may break on some targets which have 16bit memory space.

Clean up code.

Store to *bin_size if bin_size != NULL.

Use type cast not void* but char*. Don’t substiture void pointers.

Remove unused substitutions and calculations.

Don’t initialize variables that store result as MRB_DUMP_OK. It possibly causes bugs on modifications in the future.

Fixed to uint8_t

Fixed #969

Change unsigned char to uint8_t

fix comment

unify mrb_ary_new{,_elts,_from_values}; mrb_ary_from_values() is a winner

mrbc: exit if outfile is specified multiple times

refactoring

bug fix: add new option ‘-mandroid’ into CFLAGS and same options are applied into LDFLAGS.

New mrb format. The detail is in https://github.com/mruby/mruby/issues/944

bug fix: the argument of ‘–sysroot’ option should be followed ‘=’ character.

fix handling of :branch option of gem.conf

Apply @masuidrive’s review point. @bins should be Array.

Add Support to build loadable modules defined in mrbgems.

Cut off mrb_irep_free from mrb_close; based on a patch from @matsumoto-r; close #951

Remove warning for regexp

Add null check after mrb_realloc for array

Add include guard in node.h

Replace tabs with spaces

skip empty OP_STRCAT

Remove RB_GC_GUARD(x) macro. See also mruby/mruby#948.

Skip end of loop in mrb_sym2name_len

Add accessor: version, description, summary, homepage.

use mrb_str_buf_new to create a buffer to be used by mrb_str_buf_cat

Make some printf enclose in #ifdef ENABLE_STDIO.

Include stdio.h in mrbconf.h instead of C extension sources.

Added a link to the contribution guidelines in the README

proper irep pool duplication check for strings

save/restore arena index for each codedump iteration

Replace tabs with spaces

allow reserved word for heredoc terminator

applied a patch from @cremo to support MSVC

use mrb_int for RString len

fix mrb_int for INT64 env

The variable len isn’t used anywhere.

delete trailing space

Reduce a snprintf() call in localjump_error().

Clean up range.c. Use mrb_int. Use mrb_vtype.

Define ARY_MAX_SIZE strictly. Use mrb_int instead of int.

Remove trailing whitespaces. This is just a cosmetic change.

cleanup: unused variable local_svar

Adjust some indents

cleanup: delete commented out match_op() from parse.y

bugfix: assert_raise

remove installing executable first to avoid text-file-busy when investigating on debugger

string interpolation in regex

mrb_open takes no arguments: (void) instead of ()

Remove unused var sv

use TT_ARRAY instead of TT_DATA

Fix two typos

replace instance_of check with structure check

remove struct RStruct, use RArray instead

fix indent in struct.c

internal array should be pudated using mrb_ary_set()

Set nil to uninitialized members

Fix copy values

Fixed GC guard

Should be MRB_DATA class. RStruct isn’t managed by mruby core. So it should be self-managed class instances.

format some source code (vm.c)

format some source code (class.c)

Add typedef to structures that have mrb_ prefix. Use typedef-ed type instead of struct directly.

Move the place of a curly bracket. This is just a cosmetic change.

Remove unused structures.

Fix styleguide based on @cremno’s input

Modification of CONTRIBUTING.md