mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 57a56ddaa2 | |||
| a9e27933a9 | |||
| 4eb8fca140 | |||
| fa85f91e0e | |||
| 9540a8309c | |||
| 11184e9186 | |||
| 2f0bf1e110 | |||
| 41c43234a7 | |||
| 1aacde20fa | |||
| 941b99955a | |||
| 0701cc493c | |||
| 7047c52d7b | |||
| fddefeb7ee | |||
| 347729a7c0 | |||
| 7957f75bd8 | |||
| 4877dbf2a9 |
@@ -38,7 +38,7 @@ To confirm mrdb was installed properly, run mrdb with the `--version` option:
|
||||
|
||||
```bash
|
||||
$ mrdb --version
|
||||
mruby 2.1.0 (2019-10-18)
|
||||
mruby 2.1.0 (2019-11-19)
|
||||
```
|
||||
|
||||
## 2.2 Basic Operation
|
||||
|
||||
+9
-9
@@ -38,7 +38,7 @@ puts [1,2,3]
|
||||
3
|
||||
```
|
||||
|
||||
#### mruby [2.1.0 (2019-10-18)]
|
||||
#### mruby [2.1.0 (2019-11-19)]
|
||||
|
||||
```
|
||||
[1, 2, 3]
|
||||
@@ -61,7 +61,7 @@ end
|
||||
|
||||
`ZeroDivisionError` is raised.
|
||||
|
||||
#### mruby [2.1.0 (2019-10-18)]
|
||||
#### mruby [2.1.0 (2019-11-19)]
|
||||
|
||||
No exception is raised.
|
||||
|
||||
@@ -89,7 +89,7 @@ p Liste.new "foobar"
|
||||
|
||||
` [] `
|
||||
|
||||
#### mruby [2.1.0 (2019-10-18)]
|
||||
#### mruby [2.1.0 (2019-11-19)]
|
||||
|
||||
`ArgumentError` is raised.
|
||||
|
||||
@@ -119,7 +119,7 @@ false
|
||||
true
|
||||
```
|
||||
|
||||
#### mruby [2.1.0 (2019-10-18)]
|
||||
#### mruby [2.1.0 (2019-11-19)]
|
||||
|
||||
```
|
||||
true
|
||||
@@ -156,7 +156,7 @@ p 'ok'
|
||||
ok
|
||||
```
|
||||
|
||||
#### mruby [2.1.0 (2019-10-18)]
|
||||
#### mruby [2.1.0 (2019-11-19)]
|
||||
|
||||
```
|
||||
test.rb:8: undefined method 'test_func' (NoMethodError)
|
||||
@@ -178,7 +178,7 @@ defined?(Foo)
|
||||
nil
|
||||
```
|
||||
|
||||
#### mruby [2.1.0 (2019-10-18)]
|
||||
#### mruby [2.1.0 (2019-11-19)]
|
||||
|
||||
`NameError` is raised.
|
||||
|
||||
@@ -195,7 +195,7 @@ alias $a $__a__
|
||||
|
||||
` nil `
|
||||
|
||||
#### mruby [2.1.0 (2019-10-18)]
|
||||
#### mruby [2.1.0 (2019-11-19)]
|
||||
|
||||
Syntax error
|
||||
|
||||
@@ -217,7 +217,7 @@ end
|
||||
`ArgumentError` is raised.
|
||||
The re-defined `+` operator does not accept any arguments.
|
||||
|
||||
#### mruby [2.1.0 (2019-10-18)]
|
||||
#### mruby [2.1.0 (2019-11-19)]
|
||||
|
||||
` 'ab' `
|
||||
Behavior of the operator wasn't changed.
|
||||
@@ -233,7 +233,7 @@ $ ruby -e 'puts Proc.new {}.binding'
|
||||
#<Binding:0x00000e9deabb9950>
|
||||
```
|
||||
|
||||
#### mruby [2.1.0 (2019-10-18)]
|
||||
#### mruby [2.1.0 (2019-11-19)]
|
||||
|
||||
```
|
||||
$ ./bin/mruby -e 'puts Proc.new {}.binding'
|
||||
|
||||
@@ -52,7 +52,7 @@ mrb_break_value_get(struct RBreak *brk)
|
||||
{
|
||||
mrb_value val;
|
||||
val.value = brk->value;
|
||||
val.tt = brk->flags & RBREAK_VALUE_TT_MASK;
|
||||
val.tt = (enum mrb_vtype)(brk->flags & RBREAK_VALUE_TT_MASK);
|
||||
return val;
|
||||
}
|
||||
static inline void
|
||||
|
||||
@@ -67,12 +67,12 @@ MRB_BEGIN_DECL
|
||||
/*
|
||||
* Release month.
|
||||
*/
|
||||
#define MRUBY_RELEASE_MONTH 10
|
||||
#define MRUBY_RELEASE_MONTH 11
|
||||
|
||||
/*
|
||||
* Release day.
|
||||
*/
|
||||
#define MRUBY_RELEASE_DAY 18
|
||||
#define MRUBY_RELEASE_DAY 19
|
||||
|
||||
/*
|
||||
* Release date as a string.
|
||||
|
||||
@@ -24,6 +24,14 @@ module MRuby
|
||||
target
|
||||
end
|
||||
|
||||
def shellquote(s)
|
||||
if ENV['OS'] == 'Windows_NT'
|
||||
"\"#{s}\""
|
||||
else
|
||||
"#{s}"
|
||||
end
|
||||
end
|
||||
|
||||
NotFoundCommands = {}
|
||||
|
||||
private
|
||||
@@ -278,9 +286,9 @@ module MRuby
|
||||
@command = 'git'
|
||||
@flags = %w[]
|
||||
@clone_options = "clone %{flags} %{url} %{dir}"
|
||||
@pull_options = "--git-dir '%{repo_dir}/.git' --work-tree '%{repo_dir}' pull"
|
||||
@checkout_options = "--git-dir '%{repo_dir}/.git' --work-tree '%{repo_dir}' checkout %{checksum_hash}"
|
||||
@reset_options = "--git-dir '%{repo_dir}/.git' --work-tree '%{repo_dir}' reset %{checksum_hash}"
|
||||
@pull_options = "--git-dir #{shellquote("%{repo_dir}/.git")} --work-tree #{shellquote("%{repo_dir}")} pull"
|
||||
@checkout_options = "--git-dir #{shellquote("%{repo_dir}/.git")} --work-tree #{shellquote("%{repo_dir}")} checkout %{checksum_hash}"
|
||||
@reset_options = "--git-dir #{shellquote("%{repo_dir}/.git")} --work-tree #{shellquote("%{repo_dir}")} reset %{checksum_hash}"
|
||||
end
|
||||
|
||||
def run_clone(dir, url, _flags = [])
|
||||
@@ -304,11 +312,11 @@ module MRuby
|
||||
end
|
||||
|
||||
def commit_hash(dir)
|
||||
`#{@command} --git-dir '#{dir}/.git' --work-tree '#{dir}' rev-parse --verify HEAD`.strip
|
||||
`#{@command} --git-dir #{shellquote(dir +'/.git')} --work-tree #{shellquote(dir)} rev-parse --verify HEAD`.strip
|
||||
end
|
||||
|
||||
def current_branch(dir)
|
||||
`#{@command} --git-dir '#{dir}/.git' --work-tree '#{dir}' rev-parse --abbrev-ref HEAD`.strip
|
||||
`#{@command} --git-dir #{shellquote(dir + '/.git')} --work-tree #{shellquote(dir)} rev-parse --abbrev-ref HEAD`.strip
|
||||
end
|
||||
end
|
||||
|
||||
@@ -327,7 +335,9 @@ module MRuby
|
||||
infiles.each do |f|
|
||||
_pp "MRBC", f.relative_path, nil, :indent => 2
|
||||
end
|
||||
IO.popen("#{filename @command} #{@compile_options % {:funcname => funcname}} #{filename(infiles).join(' ')}", 'r+') do |io|
|
||||
cmd = "#{filename @command} #{@compile_options % {:funcname => funcname}} #{filename(infiles).join(' ')}"
|
||||
print("#{cmd}\n") if $verbose
|
||||
IO.popen(cmd, 'r+') do |io|
|
||||
out.puts io.read
|
||||
end
|
||||
# if mrbc execution fail, drop the file
|
||||
|
||||
@@ -54,6 +54,14 @@ module MRuby
|
||||
end
|
||||
end
|
||||
|
||||
def shellquote(s)
|
||||
if ENV['OS'] == 'Windows_NT'
|
||||
"\"#{s}\""
|
||||
else
|
||||
"'#{s}'"
|
||||
end
|
||||
end
|
||||
|
||||
def mruby
|
||||
mruby = {
|
||||
'version' => MRuby::Source::MRUBY_VERSION,
|
||||
@@ -62,7 +70,7 @@ module MRuby
|
||||
|
||||
git_dir = "#{MRUBY_ROOT}/.git"
|
||||
if File.directory?(git_dir)
|
||||
mruby['git_commit'] = `git --git-dir '#{git_dir}' --work-tree '#{MRUBY_ROOT}' rev-parse --verify HEAD`.strip
|
||||
mruby['git_commit'] = `git --git-dir #{shellquote(git_dir)} --work-tree #{shellquote(MRUBY_ROOT)} rev-parse --verify HEAD`.strip
|
||||
end
|
||||
|
||||
mruby
|
||||
|
||||
@@ -28,8 +28,4 @@ module Kernel
|
||||
def gets(*args)
|
||||
$stdin.gets(*args)
|
||||
end
|
||||
|
||||
def getc(*args)
|
||||
$stdin.getc(*args)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -284,12 +284,13 @@ mrb_io_alloc(mrb_state *mrb)
|
||||
#endif
|
||||
|
||||
static int
|
||||
option_to_fd(mrb_state *mrb, mrb_value obj, const char *key)
|
||||
option_to_fd(mrb_state *mrb, mrb_value hash, const char *key)
|
||||
{
|
||||
mrb_value opt = mrb_funcall(mrb, obj, "[]", 1, mrb_symbol_value(mrb_intern_static(mrb, key, strlen(key))));
|
||||
if (mrb_nil_p(opt)) {
|
||||
return -1;
|
||||
}
|
||||
mrb_value opt;
|
||||
|
||||
if (!mrb_hash_p(hash)) return -1;
|
||||
opt = mrb_hash_fetch(mrb, hash, mrb_symbol_value(mrb_intern_static(mrb, key, strlen(key))), mrb_nil_value());
|
||||
if (mrb_nil_p(opt)) return -1;
|
||||
|
||||
switch (mrb_type(opt)) {
|
||||
case MRB_TT_DATA: /* IO */
|
||||
@@ -907,11 +908,7 @@ mrb_io_syswrite(mrb_state *mrb, mrb_value io)
|
||||
}
|
||||
|
||||
mrb_get_args(mrb, "S", &str);
|
||||
if (!mrb_string_p(str)) {
|
||||
buf = mrb_funcall(mrb, str, "to_s", 0);
|
||||
} else {
|
||||
buf = str;
|
||||
}
|
||||
buf = str;
|
||||
|
||||
if (fptr->fd2 == -1) {
|
||||
fd = fptr->fd;
|
||||
|
||||
@@ -174,8 +174,8 @@ mrb_str_concat_m(mrb_state *mrb, mrb_value self)
|
||||
str = int_chr_binary(mrb, str);
|
||||
#endif
|
||||
else
|
||||
str = mrb_ensure_string_type(mrb, str);
|
||||
mrb_str_concat(mrb, self, str);
|
||||
mrb_ensure_string_type(mrb, str);
|
||||
mrb_str_cat_str(mrb, self, str);
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -145,7 +145,7 @@ class_name_str(mrb_state *mrb, struct RClass* c)
|
||||
if (mrb_nil_p(path)) {
|
||||
path = c->tt == MRB_TT_MODULE ? mrb_str_new_lit(mrb, "#<Module:") :
|
||||
mrb_str_new_lit(mrb, "#<Class:");
|
||||
mrb_str_concat(mrb, path, mrb_ptr_to_str(mrb, c));
|
||||
mrb_str_cat_str(mrb, path, mrb_ptr_to_str(mrb, c));
|
||||
mrb_str_cat_lit(mrb, path, ">");
|
||||
}
|
||||
return path;
|
||||
@@ -1885,7 +1885,8 @@ mrb_mod_to_s(mrb_state *mrb, mrb_value klass)
|
||||
return mrb_str_cat_lit(mrb, str, ">");
|
||||
}
|
||||
else {
|
||||
return class_name_str(mrb, mrb_class_ptr(klass));
|
||||
mrb_value str = class_name_str(mrb, mrb_class_ptr(klass));
|
||||
return mrb_frozen_p(mrb_basic_ptr(str)) ? mrb_str_dup(mrb, str) : str;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -423,7 +423,7 @@ mrb_any_to_s(mrb_state *mrb, mrb_value obj)
|
||||
mrb_str_cat_cstr(mrb, str, cname);
|
||||
if (!mrb_immediate_p(obj)) {
|
||||
mrb_str_cat_lit(mrb, str, ":");
|
||||
mrb_str_concat(mrb, str, mrb_ptr_to_str(mrb, mrb_ptr(obj)));
|
||||
mrb_str_cat_str(mrb, str, mrb_ptr_to_str(mrb, mrb_ptr(obj)));
|
||||
}
|
||||
mrb_str_cat_lit(mrb, str, ">");
|
||||
|
||||
|
||||
+7
-2
@@ -1388,8 +1388,13 @@ str_escape(mrb_state *mrb, mrb_value str, mrb_bool inspect)
|
||||
}
|
||||
mrb_str_cat_lit(mrb, result, "\"");
|
||||
#ifdef MRB_UTF8_STRING
|
||||
mrb_str_ptr(str)->flags |= ascii_flag;
|
||||
mrb_str_ptr(result)->flags |= ascii_flag;
|
||||
if (inspect) {
|
||||
mrb_str_ptr(str)->flags |= ascii_flag;
|
||||
mrb_str_ptr(result)->flags |= ascii_flag;
|
||||
}
|
||||
else {
|
||||
RSTR_SET_ASCII_FLAG(mrb_str_ptr(result));
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
|
||||
+1
-1
@@ -509,7 +509,7 @@ mrb_obj_iv_inspect(mrb_state *mrb, struct RObject *obj)
|
||||
mrb_str_cat_lit(mrb, str, "-<");
|
||||
mrb_str_cat_cstr(mrb, str, cn);
|
||||
mrb_str_cat_lit(mrb, str, ":");
|
||||
mrb_str_concat(mrb, str, mrb_ptr_to_str(mrb, obj));
|
||||
mrb_str_cat_str(mrb, str, mrb_ptr_to_str(mrb, obj));
|
||||
|
||||
iv_foreach(mrb, t, inspect_i, &str);
|
||||
mrb_str_cat_lit(mrb, str, ">");
|
||||
|
||||
Reference in New Issue
Block a user