This articles was published on 2013-05-01

[April 2013] mruby news

What happened on the mruby front in April 2013?

mrbgems

The gemification is still proceeding. This month the following GEMs were created:

  • mruby-range-ext
  • mruby-proc-ext
  • mruby-bin-mruby
  • mruby-bin-mirb

The two last ones are interesting due to the reason that we can now also extract tools like mruby and mirb into an own GEM.

When I created the first version of mrbgems last year I didn’t expect that we will end up with so many GEMs inside of the core. I’m not totally convinced that these GEMs will evolve easily inside of the core but on the other side Ruby was always so powerful due to his powerful and rich standard library. So we have to accept this growing trend and have to deal with it. Maybe even finding a way to simplify it. I worked on a first simplification approach by introducing GemBox into the mruby core this month. With GemBoxes you can define a collection of GEMs and include them easily via the new method gembox inside of a MRuby::Build. A documentation about this new feature was created by Andrew Nordman.

The next step to simplify the usage of many GEMs is quite obviously a dependency system. Lets think about a lightweight way to interconnect GEMs.

Improve stdlib

Lots of improvements of the standard library are taking place now inside of the GEMs. For example String got some new methods by improving the mruby-string-ext GEM:

  • #swapcase
  • #swapcase!
  • #concat
  • #casecmp
  • #start_with
  • #end_with

Based on issue 1068, h2so5 took the initiative and implemented Proc#arity. Masaki Muranaka fixed NameError.new and implemented NameError.name at the same time. Matz on the other side implemented Module#constants.

Refactoring

A big portion of all commits this month and last month was consisting of refactoring the current code base. Mainly Matz and Masaki Muranaka renamed, removed and reduced existing code.

Commits

Here a list with all commits during this month.

mrbgems

Adds documentation for MRuby::GemBox usage

fix gembox rake tasks to support Ruby 1.8

IMPROVE: Move GemBox to more logical source location

FIX: Default build should use default GEMs and not all Core GEMs

Use gembox for travis build

Use gembox for default build

Add gembox which contains all default GEMs

Add gembox which contains all core GEMs

Add gembox feature

Move regression test as String#dump is not in ther core but the mrbgems.

Add tests to make sure. As we do not use standard library for formatting.

Add Symbol#to_proc, Symbol.all_symbols

Add mruby-proc-ext

Update doc/compile/README.md about mruby and mirb

Add mruby-range-ext

rename mruby,mirb gems to mruby-bin-{mruby,mirb}

Add verbose mode to mirb

Move mirb and mruby to mrbgems.

Change mruby-random License to MIT

Add comments: some methods is defined in mrbgems.

Add comments: eval method is defined in mrbgems.

Add a comment. Kernel#require is defined in the mrbgem.

Improve stdlib

Add implementation for respond_to_missing?

Add a test for respond_to_missing?

detect cyclic-include in Module#include

Add String#swapcase,swapcase!,concat,casecmp,start_with,end_with

Add Proc#arity

fix Module#ancestors and update test

Add NotImplementedError for Kernel.` and Kernel#`

fix test to check class variables in superclasses

Module#class_variables should check superclasses

Add one more test for NameError#initialize. As we support NameError#name.

Add test for NameError#name

Add `NameError#name`. Fix `NameError.new` and `NameError.initialize`. Enable 2nd argument for `NameError.new` in C API.

raise NotImplementedError from Module.constants (15.2.2.3.1); close #1125

Module#constants should include constants defined in superclass; close #1126

add Module#constants (15.2.2.4.24)

bugfix: Kernel#!=, and add #!= testcase.

Refactoring

rename mrb_to_id to mrb_obj_to_sym since symbol is nothing to do with identifier in mruby

use uint8_t for mrb_bool instead of unsigned int; close #1222

always use unsigned int as mrb_bool even in C++

change return value of mrb_free from void* to void

rename hash related gc functions

move mrb_shared_string definition to src/string.c

Add void to function parameters. This is for compatibility with C++

small cosmetic refactoring

rename mrb_interned API functions

remove unnecessary local variable

Remove redundant whitespaces. Just cosmetic.

rename every ARGS_XXX to MRB_ARGS_XXX; ref #1206

put MRB_ prefix before ARGS_XXX macros; ref #1206

rename MRB_ARGS_XXX to MRB_ASPEC_XXX; ref #1206

rename ARGS_GETXXX macros to avoid potential name conflict; close #1206

Simplify load.c. Remove code clones. Suppress return paths.

Use mrb_bool for the ‘b’ format specifier of mrb_get_args

Remove unused variable

Remove things that look done.

Use mrb_aspec instead of int32_t. As it will clarify what is doing.

Define mrb_code, mrb_aspec as uint32_t. They are always positive.

Clean up variable types and type casts.

Remove useless comments.

put spaces after if/while

small consmetic fix

Refactor kernel.c and class.c

use ISXDIGIT instead isxdigit on parser.y:3485

Replace malloc with mrb_malloc in mrbc

factor out redundant Regexp check into functions

Use mrb_name_error() as possible.

Move mrb_name_error() declaration to mruby.h As it is requred by struct mrbgem.

rename DATA API: mrb_get_datatype -> mrb_data_get_ptr; mrb_check_datatype -> mrb_data_check_and_get

Others

remove unnecessary intern; access to non-member cause IndexError

remove our own prototype for sprintf(); ref #1223

Revert file access mode to 0644.

use mrb_free to free random state

fix memory leaks in mruby-random

fix mrb_string_shared memory leaks

add extern funcs declaration and casts for cimpiling C++ compiler

mrb_str_new_static(): zero copy string creation

quote error message in mrbconf.h to stop warning

Add a descrption of MRB_INT16.

Avoid defining MRB_INT16 adn MRB_INT64 at the same time. This is a poka-yoke.

Remove macro ANYARGS. It is not used in the core and bundled mrbgems. And it is possible to conflict an application’s macro.

Add comments why there is no need to put the SIZE_ERROR check. It is for reviews in the future.

Add error checks for small environments which pointer is less than 32bit. These code will be removed by optimizer if the target runs on 32bit or above.

More strict NULL checks.

Fix underlying memory leaks. When realloc is failed, memories are leaked.

suppress intern inside of ‘respond_to?’.

Remove sprintf().

remove calling sprintf(); ref #1210

a string may have a lot of non-printable chars.

aspec bits should be packed in Ax; ref #1209

remove too many paren; ref #1209

add new macro MRB_ARGS_ARG(n1,n2) to specify required and optional arugments at once

modify functions to suppress symbol registration into intern pool.

modify the type of return value (mrb_bool => mrb_value).

add new functions to check if symbols are interned without registration.

Fix wrong comment

Set ENV before loading Rakefile in minirake

Fix segfault on loading binary RITE files.

Pass verbose flag to each gem test

fix unnecessary irep_free

ensure clause should be executed only once; close #1185

should call ensure before popping callinfo; cancel 8ce1ea84

Use memcmp instead of strcmp if it is possible.

Remove a comment.

wrong type cast

Make str_modify public

Fix typo.

Minor code format changes.

catching NameError here is not desirable.

rollback stack before executing ensure clause.

Add Visual Studio 2010 subsection to Toolchains section of README.md

Fix “implementaion” to “implementation”

Add closing double-quotes

move no block check to mrb_yield_internal

Add vs2010.rake

add no block check; based on patch from h2so5; close #1174

Fixed irep index overflows, when defining new closure.

Don’t ignore host when adding libmruby.a to deps.

string interpolation (#{foo}) does stringify implicitly; no need to call #to_s

Fix TypeError messages

Move apps in gems to #{MRUBY_ROOT}/bin/ when apps is built for “host”.

Use not tool/ but tools/. This is for naming consistency.

Cosmetic changes.

Refactor mrb_str_dump

Fix mirb to use readline

Add validation for C language symbol name

preparation for tail call optimization (still has bugs)

Show version only once with ‘-v’ option in mruby/mrbc

although I understand the intntion of 039679f1, consuming all memory in the test program is not a good idea

target_class should not be TT_ICLASS; close #1152

nregs size was too big (off by one); close #1137

Fix a memory leak in mirb

Fix checking for heredoc in mirb

Add ARGV constant. It is not required by ISO. Compatibility with CRuby.

Support $0 variable.

Add “test runner” support for cross builds. “test runner” means target simulator like QEmu, GDB sim, and so on. Also “test runner” might be debug agents for real targets. If you do not setup test_runner, Rake will work same as before.

stdint header seems required on osx for uint8_t

Define isascii for C99

Improve checking for unterminated string in mirb

Add some tests.

comment E_* macros to address concerns in #1143

parse_args should return either EXIT_SUCCESS or EXIT_FAILURE

use EXIT_SUCCESS and EXIT_FAILURE for exit status; close #1142

Fix exit

Improve CRuby rake compatible

Add syntax error for incomplete global variables

sort mrblib/*.rb files to compile (class.rb comes before error.rb); close #1132; close #1134

Add syntax error for incomplete instance/class variables

method function should return mrb_value

make Data_Make_Struct a statement to make it C99 compatible

Adjust ci->nregs to prevent heap corruption

Add “Comparable” to labels.

Add test cases.

revert 79ebdb5 for the time being #1110

mrb_any_to_s: add separator

Add fib39.rb to benchmark/

Use mrb_raise() as possible instead of mrb_raisef().

Fix typos.

Fix to fit new raisef format.

Add the care for malloc failed. At the first time, mrb_realloc raise RuntimeError. At the time fails twice in a row, it causes panic.

Add out_of_memory field to mrb_state.