From a334cdc7afe285fbd0ed7f3c8ff6974528813552 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 1 Jun 2012 11:12:07 -0400 Subject: Update CMake to enable normal Xcode workflows Similar to the existing CMake Visual Studio IDE support, allow CMake to generate Xcode project files in mruby's root directory. This enables workflows normally expected by Xcode IDE users. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee97ad8b4..8e176c08a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,8 +33,8 @@ project(mruby C) # TODO stop polluting source tree with CMakeFiles/ and CMakeCache.txt # on build location check failure # Make sure we are not trying to generate in in-tree build unless building -# with a MSVC IDE where it's OK. -if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE) +# with an MSVC or Xcode IDE where it's OK. +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT (MSVC_IDE OR XCODE)) message(FATAL_ERROR "\nIn-source builds are not allowed as CMake would overwrite the " "Makefiles distributed with mruby. Please change to the 'build' " -- cgit v1.2.3 From 84207b2e0f14d2a8fd1ccc435b0c27f30b2ecce8 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 1 Jun 2012 11:20:28 -0400 Subject: Update in-source build error message --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e176c08a..c8b252d2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,8 +37,9 @@ project(mruby C) if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT (MSVC_IDE OR XCODE)) message(FATAL_ERROR "\nIn-source builds are not allowed as CMake would overwrite the " - "Makefiles distributed with mruby. Please change to the 'build' " - "subdirectory and run CMake from there.") + "Makefiles distributed with mruby. Delete any created 'CMakeFiles' " + "subdirectory and 'CMakeCache.txt' file from the current directory, " + "change to the 'build' subdirectory, and re-run CMake from there.") endif() if(COMMAND cmake_policy) -- cgit v1.2.3 From 49df2179578c34caefbe693a0eb74facb3ff9679 Mon Sep 17 00:00:00 2001 From: takahashim Date: Sat, 2 Jun 2012 01:14:45 +0900 Subject: use mrb_malloc instead of malloc --- src/struct.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/struct.c b/src/struct.c index d06124b50..fbe018930 100644 --- a/src/struct.c +++ b/src/struct.c @@ -416,7 +416,7 @@ mrb_struct_initialize_withArg(mrb_state *mrb, int argc, mrb_value *argv, mrb_val mrb_raise(mrb, E_ARGUMENT_ERROR, "struct size differs"); } st = RSTRUCT(self); - st->ptr = malloc(sizeof(mrb_value)*argc); + st->ptr = mrb_malloc(mrb, sizeof(mrb_value)*argc); st->len = n; memcpy(st->ptr, argv, sizeof(mrb_value)*argc); //if (n > argc) { -- cgit v1.2.3 From cb10b927836fcc56fc40e677497cc303e79625c5 Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Sat, 2 Jun 2012 01:33:04 +0800 Subject: Add Test Case for issue #210 --- test/t/module.rb | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/test/t/module.rb b/test/t/module.rb index 854be75a5..a5331e96d 100644 --- a/test/t/module.rb +++ b/test/t/module.rb @@ -5,6 +5,53 @@ assert('Module', '15.2.2') do Module.class == Class end +assert('Module#const_defined?', '15.2.2.4.20') do + module Test4ConstDefined + Const4Test4ConstDefined = true + end + + Test4ConstDefined.const_defined?(:Const4Test4ConstDefined) and + not Test4ConstDefined.const_defined?(:NotExisting) +end + +assert('Module#const_get', '15.2.2.4.21') do + module Test4ConstGet + Const4Test4ConstGet = 42 + end + + Test4ConstGet.const_get(:Const4Test4ConstGet) == 42 +end + +assert('Module.const_missing', '15.2.2.4.22') do + e1 = nil + + module Test4ConstMissing + def const_missing(sym) + # ATM this redirect doesn't work + puts "PLEASE GO TO TEST CASE Module.const_missing!" + puts "IT IS WORKING NOW!! PLEASE FINALIZE." + puts "Thanks :)" + end + end + + begin + Test4ConstMissing.const_get(:ConstDoesntExist) + rescue => e2 + e1 = e2 + end + + e1.class == NameError +end + +assert('Module#const_get', '15.2.2.4.23') do + module Test4ConstSet + Const4Test4ConstSet = 42 + end + + Test4ConstSet.const_set(:Const4Test4ConstSet, 23) + Test4ConstSet.const_get(:Const4Test4ConstSet) == 23 +end + # TODO not implemented ATM assert('Module.constants', '15.2.2') do # TODO not implemented ATM assert('Module.nesting', '15.2.2') do -- cgit v1.2.3 From 8804c7db6585d7cf3eda735f4758007704f237af Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Sat, 2 Jun 2012 01:39:53 +0800 Subject: Add Test Case for issue #211 --- test/t/kernel.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/t/kernel.rb b/test/t/kernel.rb index cd1f2d99e..847f1baeb 100644 --- a/test/t/kernel.rb +++ b/test/t/kernel.rb @@ -112,7 +112,17 @@ assert('Kernel#respond_to?', '15.3.1.2.43') do respond_to? :nil? end -# TODO at the moment doesn't comply to ISO assert('Kernel#send', '15.3.1.2.44') do +assert('Kernel#send', '15.3.1.2.44') do + # test with block + l = send(:lambda) do + true + end + l.call and l.class == Proc and + # test with argument + send(:respond_to?, :nil?) and + # test without argument and without block + send(:public_methods).class == Array +end assert('Kernel#singleton_methods', '15.3.1.2.45') do singleton_methods.class == Array -- cgit v1.2.3 From 703e97d5b35ab9ed5e7798729b9034924cd216b9 Mon Sep 17 00:00:00 2001 From: Masaki Muranaka Date: Fri, 1 Jun 2012 11:26:12 +0900 Subject: Use "if" instead "switch". --- src/codegen.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/codegen.c b/src/codegen.c index 505f0ad5b..20799f9ae 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -208,23 +208,19 @@ genop_peep(codegen_scope *s, mrb_code i, int val) case OP_SETCV: case OP_SETCONST: case OP_SETMCNST: - switch (c0) { - case OP_MOVE: + if (c0 == OP_MOVE) { if (GETARG_A(i) == GETARG_A(i0)) { s->iseq[s->pc-1] = MKOP_ABx(c1, GETARG_B(i0), GETARG_Bx(i)); return; } - break; } break; case OP_SETUPVAR: - switch (c0) { - case OP_MOVE: + if (c0 == OP_MOVE) { if (GETARG_A(i) == GETARG_A(i0)) { s->iseq[s->pc-1] = MKOP_ABC(c1, GETARG_B(i0), GETARG_B(i), GETARG_C(i)); return; } - break; } break; case OP_EPOP: -- cgit v1.2.3