Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
16e38886
Commit
16e38886
authored
Nov 24, 2021
by
dearblue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed some methods where keyword arguments are not passed
parent
d6e1114f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
12 deletions
+42
-12
mrbgems/mruby-method/mrblib/method.rb
mrbgems/mruby-method/mrblib/method.rb
+4
-4
mrbgems/mruby-method/src/method.c
mrbgems/mruby-method/src/method.c
+11
-4
mrbgems/mruby-method/test/method.rb
mrbgems/mruby-method/test/method.rb
+23
-0
mrbgems/mruby-proc-ext/mrblib/proc.rb
mrbgems/mruby-proc-ext/mrblib/proc.rb
+2
-2
mrblib/symbol.rb
mrblib/symbol.rb
+2
-2
No files found.
mrbgems/mruby-method/mrblib/method.rb
View file @
16e38886
class
Method
def
to_proc
m
=
self
lambda
{
|*
args
,
&
b
|
m
.
call
(
*
args
,
&
b
)
lambda
{
|*
args
,
**
opts
,
&
b
|
m
.
call
(
*
args
,
**
opts
,
&
b
)
}
end
def
<<
(
other
)
->
(
*
args
,
&
block
)
{
call
(
other
.
call
(
*
arg
s
,
&
block
))
}
->
(
*
args
,
**
opts
,
&
block
)
{
call
(
other
.
call
(
*
args
,
**
opt
s
,
&
block
))
}
end
def
>>
(
other
)
->
(
*
args
,
&
block
)
{
other
.
call
(
call
(
*
arg
s
,
&
block
))
}
->
(
*
args
,
**
opts
,
&
block
)
{
other
.
call
(
call
(
*
args
,
**
opt
s
,
&
block
))
}
end
end
mrbgems/mruby-method/src/method.c
View file @
16e38886
...
...
@@ -20,15 +20,19 @@ args_shift(mrb_state *mrb)
mrb_value
*
argv
=
ci
->
stack
+
1
;
if
(
ci
->
n
<
15
)
{
if
(
ci
->
n
==
0
)
{
goto
argerr
;
}
mrb_assert
(
ci
->
nk
==
0
||
ci
->
nk
==
15
);
mrb_value
obj
=
argv
[
0
];
memmove
(
argv
,
argv
+
1
,
(
ci
->
n
+
1
/* block */
-
1
/* first value */
)
*
sizeof
(
mrb_value
));
int
count
=
ci
->
n
+
(
ci
->
nk
==
0
?
0
:
1
)
+
1
/* block */
-
1
/* first value */
;
memmove
(
argv
,
argv
+
1
,
count
*
sizeof
(
mrb_value
));
ci
->
n
--
;
return
obj
;
}
else
if
(
ci
->
n
==
15
&&
RARRAY_LEN
(
*
argv
)
>
0
)
{
else
if
(
RARRAY_LEN
(
*
argv
)
>
0
)
{
return
mrb_ary_shift
(
mrb
,
*
argv
);
}
else
{
argerr:
mrb_argnum_error
(
mrb
,
0
,
1
,
-
1
);
return
mrb_undef_value
();
/* not reached */
}
...
...
@@ -41,9 +45,12 @@ args_unshift(mrb_state *mrb, mrb_value obj)
mrb_value
*
argv
=
ci
->
stack
+
1
;
if
(
ci
->
n
<
15
)
{
mrb_
value
block
=
argv
[
ci
->
n
]
;
mrb_
assert
(
ci
->
nk
==
0
||
ci
->
nk
==
15
)
;
argv
[
0
]
=
mrb_ary_new_from_values
(
mrb
,
ci
->
n
,
argv
);
argv
[
1
]
=
block
;
argv
[
1
]
=
argv
[
ci
->
n
];
// keyword or block
if
(
ci
->
nk
==
15
)
{
argv
[
2
]
=
argv
[
ci
->
n
+
1
];
// block
}
ci
->
n
=
15
;
}
...
...
mrbgems/mruby-method/test/method.rb
View file @
16e38886
...
...
@@ -208,6 +208,16 @@ assert 'Method#to_proc' do
yield
39
end
assert_equal
42
,
o
.
bar
(
&
3
.
method
(:
+
))
def
o
.
baz
(
x
,
y
,
z
,
*
w
,
u
:,
v
:,
**
opts
,
&
blk
)
{
x
:,
y
:,
z
:,
w
:,
u
:,
v
:,
opts
:,
blk:
}
end
blk
=
->
{
}
values
=
{
x:
1
,
y:
2
,
z:
3
,
w:
[
4
,
5
,
6
],
u:
7
,
v:
8
,
opts:
{
s:
9
,
t:
10
},
blk:
blk
}
assert_equal
values
,
o
.
method
(
:baz
).
to_proc
.
call
(
1
,
2
,
3
,
4
,
5
,
6
,
u:
7
,
v:
8
,
s:
9
,
t:
10
,
&
blk
)
assert_equal
values
,
o
.
method
(
:baz
).
to_proc
.
call
(
1
,
2
,
3
,
4
,
5
,
6
,
**
{
u:
7
,
v:
8
,
s:
9
,
t:
10
},
&
blk
)
assert_equal
values
,
o
.
method
(
:baz
).
to_proc
.
call
(
*
[
1
,
2
,
3
,
4
,
5
,
6
],
u:
7
,
v:
8
,
s:
9
,
t:
10
,
&
blk
)
assert_equal
values
,
o
.
method
(
:baz
).
to_proc
.
call
(
*
[
1
,
2
,
3
,
4
,
5
,
6
],
**
{
u:
7
,
v:
8
,
s:
9
,
t:
10
},
&
blk
)
end
assert
'to_s'
do
...
...
@@ -449,4 +459,17 @@ assert 'UnboundMethod#bind_call' do
assert_equal
(
0
,
m
.
bind_call
([]))
assert_equal
(
1
,
m
.
bind_call
([
1
]))
assert_equal
(
2
,
m
.
bind_call
([
1
,
2
]))
o
=
Object
.
new
def
m
(
x
,
y
,
z
,
*
w
,
u
:,
v
:,
**
opts
,
&
blk
)
{
x
:,
y
:,
z
:,
w
:,
u
:,
v
:,
opts
:,
blk:
}
end
m
=
o
.
method
(
:m
).
unbind
blk
=
->
{
}
values
=
{
x:
1
,
y:
2
,
z:
3
,
w:
[
4
,
5
,
6
],
u:
7
,
v:
8
,
opts:
{
s:
9
,
t:
10
},
blk:
blk
}
assert_equal
values
,
m
.
bind_call
(
o
,
1
,
2
,
3
,
4
,
5
,
6
,
u:
7
,
v:
8
,
s:
9
,
t:
10
,
&
blk
)
assert_equal
values
,
m
.
bind_call
(
o
,
1
,
2
,
3
,
4
,
5
,
6
,
**
{
u:
7
,
v:
8
,
s:
9
,
t:
10
},
&
blk
)
assert_equal
values
,
m
.
bind_call
(
o
,
*
[
1
,
2
,
3
,
4
,
5
,
6
],
u:
7
,
v:
8
,
s:
9
,
t:
10
,
&
blk
)
assert_equal
values
,
m
.
bind_call
(
o
,
*
[
1
,
2
,
3
,
4
,
5
,
6
],
**
{
u:
7
,
v:
8
,
s:
9
,
t:
10
},
&
blk
)
assert_raise
(
ArgumentError
)
{
m
.
bind_call
}
end
mrbgems/mruby-proc-ext/mrblib/proc.rb
View file @
16e38886
...
...
@@ -40,11 +40,11 @@ class Proc
end
def
<<
(
other
)
->
(
*
args
,
&
block
)
{
call
(
other
.
call
(
*
arg
s
,
&
block
))
}
->
(
*
args
,
**
opts
,
&
block
)
{
call
(
other
.
call
(
*
args
,
**
opt
s
,
&
block
))
}
end
def
>>
(
other
)
->
(
*
args
,
&
block
)
{
other
.
call
(
call
(
*
arg
s
,
&
block
))
}
->
(
*
args
,
**
opts
,
&
block
)
{
other
.
call
(
call
(
*
args
,
**
opt
s
,
&
block
))
}
end
end
mrblib/symbol.rb
View file @
16e38886
class
Symbol
def
to_proc
->
(
obj
,
*
args
,
&
block
)
do
obj
.
__send__
(
self
,
*
args
,
&
block
)
->
(
obj
,
*
args
,
**
opts
,
&
block
)
do
obj
.
__send__
(
self
,
*
args
,
**
opts
,
&
block
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment