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
d9049c10
Unverified
Commit
d9049c10
authored
Dec 18, 2017
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Dec 18, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3904 from ksss/mruby-method
Add mruby-method
parents
bba6c9a1
c0914dbb
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
947 additions
and
0 deletions
+947
-0
mrbgems/mruby-method/README.md
mrbgems/mruby-method/README.md
+59
-0
mrbgems/mruby-method/mrbgem.rake
mrbgems/mruby-method/mrbgem.rake
+7
-0
mrbgems/mruby-method/mrblib/kernel.rb
mrbgems/mruby-method/mrblib/kernel.rb
+9
-0
mrbgems/mruby-method/mrblib/method.rb
mrbgems/mruby-method/mrblib/method.rb
+20
-0
mrbgems/mruby-method/mrblib/unbound_method.rb
mrbgems/mruby-method/mrblib/unbound_method.rb
+9
-0
mrbgems/mruby-method/src/method.c
mrbgems/mruby-method/src/method.c
+418
-0
mrbgems/mruby-method/test/method.rb
mrbgems/mruby-method/test/method.rb
+425
-0
No files found.
mrbgems/mruby-method/README.md
0 → 100644
View file @
d9049c10
mruby-method
===
A implementetion of class
**Method**
and
**UnboundMethod**
for mruby
```
ruby
p
Enumerable
.
instance_method
(
:find_all
).
source_location
#=> ["mruby/mruby/mrblib/enum.rb", 148]
```
# Note
`source_location`
method need this configuration in build_config.rb
```
ruby
MRuby
::
Build
.
new
do
|
conf
|
enable_debug
end
```
# Supported Methods
## Kernel
-
`Kernel#method`
-
`Kernel#singleton_method`
## Module
-
`Module#instance_method`
## Method class
-
`Method#name`
-
`Method#call`
-
`Method#super_method`
-
`Method#arity`
-
`Method#unbind`
-
`Method#[]`
-
`Method#owner`
-
`Method#receiver`
-
`Method#parameters`
-
`Method#source_location`
-
`Method#to_proc`
## UnboundMethod class
-
`UnboundMethod#name`
-
`UnboundMethod#bind`
-
`UnboundMethod#super_method`
-
`UnboundMethod#arity`
-
`UnboundMethod#owner`
-
`UnboundMethod#parameters`
-
`UnboundMethod#source_location`
# See also
-
https://ruby-doc.org/core-2.3.3/Method.html
-
https://ruby-doc.org/core-2.3.3/UnboundMethod.html
mrbgems/mruby-method/mrbgem.rake
0 → 100644
View file @
d9049c10
MRuby
::
Gem
::
Specification
.
new
(
'mruby-method'
)
do
|
spec
|
spec
.
license
=
'MIT'
spec
.
author
=
'mruby developers'
spec
.
summary
=
'Method and UnboundMethod class'
spec
.
add_dependency
(
'mruby-proc-ext'
,
:core
=>
'mruby-proc-ext'
)
end
mrbgems/mruby-method/mrblib/kernel.rb
0 → 100644
View file @
d9049c10
module
Kernel
def
singleton_method
(
name
)
m
=
method
(
name
)
if
m
.
owner
!=
singleton_class
raise
NameError
,
"undefined method `
#{
name
}
' for class `
#{
singleton_class
}
'"
end
m
end
end
mrbgems/mruby-method/mrblib/method.rb
0 → 100644
View file @
d9049c10
class
Method
def
to_proc
m
=
self
lambda
{
|*
args
,
&
b
|
m
.
call
(
*
args
,
&
b
)
}
end
def
owner
@owner
end
def
receiver
@recv
end
def
name
@name
end
end
mrbgems/mruby-method/mrblib/unbound_method.rb
0 → 100644
View file @
d9049c10
class
UnboundMethod
def
owner
@owner
end
def
name
@name
end
end
mrbgems/mruby-method/src/method.c
0 → 100644
View file @
d9049c10
This diff is collapsed.
Click to expand it.
mrbgems/mruby-method/test/method.rb
0 → 100644
View file @
d9049c10
This diff is collapsed.
Click to expand it.
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