Merge remote-tracking branch 'upstream/master' into lang-doc

This commit is contained in:
Daniel Bovensiepen
2013-08-01 15:17:34 +08:00
12 changed files with 62 additions and 16 deletions
+6 -6
View File
@@ -42,25 +42,25 @@ MRuby::Build.new do |conf|
# linker.option_library_path = '-L%s'
# linker.link_options = "%{flags} -o %{outfile} %{objs} %{libs}"
# end
# Archiver settings
# conf.archiver do |archiver|
# archiver.command = ENV['AR'] || 'ar'
# archiver.archive_options = 'rs %{outfile} %{objs}'
# end
# Parser generator settings
# conf.yacc do |yacc|
# yacc.command = ENV['YACC'] || 'bison'
# yacc.compile_options = '-o %{outfile} %{infile}'
# end
# gperf settings
# conf.gperf do |gperf|
# gperf.command = 'gperf'
# gperf.compile_options = '-L ANSI-C -C -p -j1 -i 1 -g -o -t -N mrb_reserved_word -k"1,3,$" %{infile} > %{outfile}'
# end
# file extensions
# conf.exts do |exts|
# exts.object = '.o'
@@ -75,12 +75,12 @@ end
# Define cross build settings
# MRuby::CrossBuild.new('32bit') do |conf|
# toolchain :gcc
#
#
# conf.cc.flags << "-m32"
# conf.linker.flags << "-m32"
#
# conf.build_mrbtest_lib_only
#
#
# conf.gem 'examples/mrbgems/c_and_ruby_extension_example'
#
# conf.test_runner.command = 'env'
+1 -1
View File
@@ -156,7 +156,7 @@ the following options additionally inside of your GEM specification:
mruby can be extended with C. This is possible by using the C API to
integrate C libraries into mruby.
### Pre-Conditions
### Preconditions
mrbgems expects that you have implemented a C method called
`mrb_YOURGEMNAME_gem_init(mrb_state)`. `YOURGEMNAME` will be replaced
+1
View File
@@ -23,6 +23,7 @@ typedef struct mrbc_context {
short lineno;
int (*partial_hook)(struct mrb_parser_state*);
void *partial_data;
struct RClass *target_class;
mrb_bool capture_errors:1;
mrb_bool dump_result:1;
mrb_bool no_exec:1;
+4
View File
@@ -0,0 +1,4 @@
MRuby::Gem::Specification.new('mruby-exit') do |spec|
spec.license = 'MIT'
spec.author = 'mruby developers'
end
+24
View File
@@ -0,0 +1,24 @@
#include <stdlib.h>
#include "mruby.h"
static mrb_value
f_exit(mrb_state *mrb, mrb_value self)
{
mrb_int i = EXIT_SUCCESS;
mrb_get_args(mrb, "|i", &i);
exit(i);
/* not reached */
return mrb_nil_value();
}
void
mrb_mruby_exit_gem_init(mrb_state* mrb)
{
mrb_define_method(mrb, mrb->kernel_module, "exit", f_exit, MRB_ARGS_REQ(1));
}
void
mrb_mruby_exit_gem_final(mrb_state* mrb)
{
}
+3 -3
View File
@@ -59,7 +59,7 @@ nil_to_i(mrb_state *mrb, mrb_value obj)
* k.instance_exec(5) {|x| @secret+x } #=> 104
*/
mrb_value
mrb_value
mrb_yield_internal(mrb_state *mrb, mrb_value b, int argc, mrb_value *argv, mrb_value self, struct RClass *c);
static mrb_value
@@ -69,7 +69,7 @@ mrb_obj_instance_exec(mrb_state *mrb, mrb_value self)
int argc;
mrb_value blk;
struct RClass *c;
mrb_get_args(mrb, "*&", &argv, &argc, &blk);
if (mrb_nil_p(blk)) {
@@ -80,7 +80,7 @@ mrb_obj_instance_exec(mrb_state *mrb, mrb_value self)
case MRB_TT_SYMBOL:
case MRB_TT_FIXNUM:
case MRB_TT_FLOAT:
c = 0;
c = NULL;
break;
default:
c = mrb_class_ptr(mrb_singleton_class(mrb, self));
-1
View File
@@ -311,7 +311,6 @@ mrb_define_method_id(mrb_state *mrb, struct RClass *c, mrb_sym mid, mrb_func_t f
int ai = mrb_gc_arena_save(mrb);
p = mrb_proc_new_cfunc(mrb, func);
p->target_class = c;
mrb_define_method_raw(mrb, c, mid, p);
mrb_gc_arena_restore(mrb, ai);
}
-1
View File
@@ -1551,7 +1551,6 @@ codegen(codegen_scope *s, node *tree, int val)
// variable rhs
codegen(s, t, VAL);
gen_vmassignment(s, tree->car, rhs, val);
if (!val) pop();
}
}
break;
+11 -1
View File
@@ -5210,6 +5210,8 @@ mrb_parse_string(mrb_state *mrb, const char *s, mrbc_context *c)
static mrb_value
load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
{
struct RClass *target = mrb->object_class;
struct RProc *proc;
int n;
mrb_value v;
@@ -5243,8 +5245,16 @@ load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
if (c) {
if (c->dump_result) codedump_all(mrb, n);
if (c->no_exec) return mrb_fixnum_value(n);
if (c->target_class) {
target = c->target_class;
}
}
v = mrb_run(mrb, mrb_proc_new(mrb, mrb->irep[n]), mrb_top_self(mrb));
proc = mrb_proc_new(mrb, mrb->irep[n]);
proc->target_class = target;
if (mrb->c->ci) {
mrb->c->ci->target_class = target;
}
v = mrb_run(mrb, proc, mrb_top_self(mrb));
if (mrb->exc) return mrb_nil_value();
return v;
}
+1 -1
View File
@@ -386,9 +386,9 @@ mrb_funcall_with_block(mrb_state *mrb, mrb_value self, mrb_sym mid, int argc, mr
if (MRB_PROC_CFUNC_P(p)) {
int ai = mrb_gc_arena_save(mrb);
val = p->body.func(mrb, self);
mrb_gc_arena_restore(mrb, ai);
mrb->c->stack = mrb->c->stbase + mrb->c->ci->stackidx;
cipop(mrb);
mrb_gc_arena_restore(mrb, ai);
}
else {
val = mrb_run(mrb, p, self);
+2 -2
View File
@@ -101,7 +101,7 @@ end
def assert_equal(arg1, arg2 = nil, arg3 = nil)
if block_given?
exp, act, msg = yield, arg1, arg2
exp, act, msg = arg1, yield, arg2
else
exp, act, msg = arg1, arg2, arg3
end
@@ -113,7 +113,7 @@ end
def assert_not_equal(arg1, arg2 = nil, arg3 = nil)
if block_given?
exp, act, msg = yield, arg1, arg2
exp, act, msg = arg1, yield, arg2
else
exp, act, msg = arg1, arg2, arg3
end
+9
View File
@@ -65,3 +65,12 @@ assert('Abbreviated variable assignment as returns') do
end
assert_equal Syntax4AbbrVarAsgnAsReturns::A.new.b, 1
end
assert('Splat and mass assignment') do
*a = *[1,2,3]
b, *c = *[7,8,9]
assert_equal [1,2,3], a
assert_equal 7, b
assert_equal [8,9], c
end