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
9be81e74
Commit
9be81e74
authored
May 22, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
call Class#initialize from Class.new; ref ISO 15.2.3.3.1
parent
00f21446
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
5 deletions
+18
-5
src/class.c
src/class.c
+18
-5
No files found.
src/class.c
View file @
9be81e74
...
@@ -1094,19 +1094,31 @@ mrb_obj_new(mrb_state *mrb, struct RClass *c, mrb_int argc, const mrb_value *arg
...
@@ -1094,19 +1094,31 @@ mrb_obj_new(mrb_state *mrb, struct RClass *c, mrb_int argc, const mrb_value *arg
return
obj
;
return
obj
;
}
}
static
mrb_value
mrb_class_initialize
(
mrb_state
*
mrb
,
mrb_value
c
)
{
mrb_value
a
,
b
;
mrb_get_args
(
mrb
,
"|C&"
,
&
a
,
&
b
);
if
(
!
mrb_nil_p
(
b
))
{
mrb_yield_with_class
(
mrb
,
b
,
1
,
&
c
,
c
,
mrb_class_ptr
(
c
));
}
return
c
;
}
static
mrb_value
static
mrb_value
mrb_class_new_class
(
mrb_state
*
mrb
,
mrb_value
cv
)
mrb_class_new_class
(
mrb_state
*
mrb
,
mrb_value
cv
)
{
{
mrb_int
n
;
mrb_value
super
,
blk
;
mrb_value
super
,
blk
;
mrb_value
new_class
;
mrb_value
new_class
;
if
(
mrb_get_args
(
mrb
,
"|C&"
,
&
super
,
&
blk
)
==
0
)
{
n
=
mrb_get_args
(
mrb
,
"|C&"
,
&
super
,
&
blk
);
if
(
n
==
0
)
{
super
=
mrb_obj_value
(
mrb
->
object_class
);
super
=
mrb_obj_value
(
mrb
->
object_class
);
}
}
new_class
=
mrb_obj_value
(
mrb_class_new
(
mrb
,
mrb_class_ptr
(
super
)));
new_class
=
mrb_obj_value
(
mrb_class_new
(
mrb
,
mrb_class_ptr
(
super
)));
if
(
!
mrb_nil_p
(
blk
))
{
mrb_funcall_with_block
(
mrb
,
new_class
,
mrb_intern_lit
(
mrb
,
"initialize"
),
n
,
&
super
,
blk
);
mrb_yield_with_class
(
mrb
,
blk
,
1
,
&
new_class
,
new_class
,
mrb_class_ptr
(
new_class
));
}
mrb_funcall
(
mrb
,
super
,
"inherited"
,
1
,
new_class
);
mrb_funcall
(
mrb
,
super
,
"inherited"
,
1
,
new_class
);
return
new_class
;
return
new_class
;
}
}
...
@@ -1963,9 +1975,10 @@ mrb_init_class(mrb_state *mrb)
...
@@ -1963,9 +1975,10 @@ mrb_init_class(mrb_state *mrb)
mrb_define_method
(
mrb
,
bob
,
"!"
,
mrb_bob_not
,
MRB_ARGS_NONE
());
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
,
bob
,
"method_missing"
,
mrb_bob_missing
,
MRB_ARGS_ANY
());
/* 15.3.1.3.30 */
mrb_define_class_method
(
mrb
,
cls
,
"new"
,
mrb_class_new_class
,
MRB_ARGS_
ANY
(
));
mrb_define_class_method
(
mrb
,
cls
,
"new"
,
mrb_class_new_class
,
MRB_ARGS_
OPT
(
1
));
mrb_define_method
(
mrb
,
cls
,
"superclass"
,
mrb_class_superclass
,
MRB_ARGS_NONE
());
/* 15.2.3.3.4 */
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
,
"new"
,
mrb_instance_new
,
MRB_ARGS_ANY
());
/* 15.2.3.3.3 */
mrb_define_method
(
mrb
,
cls
,
"initialize"
,
mrb_class_initialize
,
MRB_ARGS_OPT
(
1
));
/* 15.2.3.3.1 */
mrb_define_method
(
mrb
,
cls
,
"inherited"
,
mrb_bob_init
,
MRB_ARGS_REQ
(
1
));
mrb_define_method
(
mrb
,
cls
,
"inherited"
,
mrb_bob_init
,
MRB_ARGS_REQ
(
1
));
MRB_SET_INSTANCE_TT
(
mod
,
MRB_TT_MODULE
);
MRB_SET_INSTANCE_TT
(
mod
,
MRB_TT_MODULE
);
...
...
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