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
babc8d00
Commit
babc8d00
authored
Aug 15, 2013
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement Class.new in C again
parent
6e978d55
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
6 deletions
+16
-6
mrblib/class.rb
mrblib/class.rb
+0
-5
src/class.c
src/class.c
+16
-1
No files found.
mrblib/class.rb
View file @
babc8d00
...
...
@@ -4,11 +4,6 @@ class Class
obj
.
initialize
(
*
args
,
&
b
)
obj
end
def
self
.
new
(
*
args
)
obj
=
super
obj
.
inherited
obj
end
end
class
Module
...
...
src/class.c
View file @
babc8d00
...
...
@@ -1055,6 +1055,20 @@ mrb_obj_new(mrb_state *mrb, struct RClass *c, int argc, mrb_value *argv)
return
obj
;
}
static
mrb_value
mrb_class_new_class
(
mrb_state
*
mrb
,
mrb_value
cv
)
{
mrb_value
super
;
struct
RClass
*
new_class
;
if
(
mrb_get_args
(
mrb
,
"|o"
,
&
super
)
==
0
)
{
super
=
mrb_obj_value
(
mrb
->
object_class
);
}
new_class
=
mrb_class_new
(
mrb
,
mrb_class_ptr
(
super
));
mrb_funcall
(
mrb
,
super
,
"inherited"
,
1
,
mrb_obj_value
(
new_class
));
return
mrb_obj_value
(
new_class
);
}
mrb_value
mrb_class_superclass
(
mrb_state
*
mrb
,
mrb_value
klass
)
{
...
...
@@ -1871,8 +1885,9 @@ mrb_init_class(mrb_state *mrb)
mrb_define_method
(
mrb
,
bob
,
"!"
,
mrb_bob_not
,
MRB_ARGS_NONE
());
mrb_define_method
(
mrb
,
bob
,
"method_missing"
,
mrb_bob_missing
,
MRB_ARGS_ANY
());
/* 15.3.1.3.30 */
mrb_define_
method
(
mrb
,
cls
,
"superclass"
,
mrb_class_superclass
,
MRB_ARGS_NONE
());
/* 15.2.3.3.4 */
mrb_define_
class_method
(
mrb
,
cls
,
"new"
,
mrb_class_new_class
,
MRB_ARGS_ANY
());
mrb_define_method
(
mrb
,
cls
,
"alloc"
,
mrb_instance_alloc
,
MRB_ARGS_NONE
());
mrb_define_method
(
mrb
,
cls
,
"superclass"
,
mrb_class_superclass
,
MRB_ARGS_NONE
());
/* 15.2.3.3.4 */
mrb_define_method
(
mrb
,
cls
,
"new"
,
mrb_instance_new
,
MRB_ARGS_ANY
());
/* 15.2.3.3.3 */
mrb_define_method
(
mrb
,
cls
,
"inherited"
,
mrb_bob_init
,
MRB_ARGS_REQ
(
1
));
...
...
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