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
888ddf1c
Commit
888ddf1c
authored
Oct 30, 2013
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
type check class/module in mrb_get_args(); close #1477
parent
f8fea693
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
5 deletions
+29
-5
src/class.c
src/class.c
+27
-3
src/kernel.c
src/kernel.c
+2
-2
No files found.
src/class.c
View file @
888ddf1c
...
...
@@ -380,6 +380,7 @@ to_hash(mrb_state *mrb, mrb_value val)
string mruby type C type note
----------------------------------------------------------------------------------------------
o: Object [mrb_value]
C: class/module [mrb_value]
S: String [mrb_value]
A: Array [mrb_value]
H: Hash [mrb_value]
...
...
@@ -434,6 +435,29 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
}
}
break
;
case
'C'
:
{
mrb_value
*
p
;
p
=
va_arg
(
ap
,
mrb_value
*
);
if
(
i
<
argc
)
{
mrb_value
ss
;
ss
=
*
sp
++
;
switch
(
mrb_type
(
ss
))
{
case
MRB_TT_CLASS
:
case
MRB_TT_MODULE
:
case
MRB_TT_SCLASS
:
break
;
default:
mrb_raisef
(
mrb
,
E_TYPE_ERROR
,
"%S is not class/module"
,
ss
);
break
;
}
*
p
=
ss
;
i
++
;
}
}
break
;
case
'S'
:
{
mrb_value
*
p
;
...
...
@@ -732,7 +756,7 @@ mrb_mod_append_features(mrb_state *mrb, mrb_value mod)
mrb_value
klass
;
mrb_check_type
(
mrb
,
mod
,
MRB_TT_MODULE
);
mrb_get_args
(
mrb
,
"
o
"
,
&
klass
);
mrb_get_args
(
mrb
,
"
C
"
,
&
klass
);
mrb_include_module
(
mrb
,
mrb_class_ptr
(
klass
),
mrb_class_ptr
(
mod
));
return
mod
;
}
...
...
@@ -780,7 +804,7 @@ mrb_mod_include_p(mrb_state *mrb, mrb_value mod)
mrb_value
mod2
;
struct
RClass
*
c
=
mrb_class_ptr
(
mod
);
mrb_get_args
(
mrb
,
"
o
"
,
&
mod2
);
mrb_get_args
(
mrb
,
"
C
"
,
&
mod2
);
mrb_check_type
(
mrb
,
mod2
,
MRB_TT_MODULE
);
while
(
c
)
{
...
...
@@ -1059,7 +1083,7 @@ 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
)
{
if
(
mrb_get_args
(
mrb
,
"|
C
"
,
&
super
)
==
0
)
{
super
=
mrb_obj_value
(
mrb
->
object_class
);
}
new_class
=
mrb_class_new
(
mrb
,
mrb_class_ptr
(
super
));
...
...
src/kernel.c
View file @
888ddf1c
...
...
@@ -542,7 +542,7 @@ obj_is_instance_of(mrb_state *mrb, mrb_value self)
mrb_value
arg
;
mrb_bool
instance_of_p
;
mrb_get_args
(
mrb
,
"
o
"
,
&
arg
);
mrb_get_args
(
mrb
,
"
C
"
,
&
arg
);
instance_of_p
=
mrb_obj_is_instance_of
(
mrb
,
self
,
mrb_class_ptr
(
arg
));
return
mrb_bool_value
(
instance_of_p
);
...
...
@@ -715,7 +715,7 @@ mrb_obj_is_kind_of_m(mrb_state *mrb, mrb_value self)
mrb_value
arg
;
mrb_bool
kind_of_p
;
mrb_get_args
(
mrb
,
"
o
"
,
&
arg
);
mrb_get_args
(
mrb
,
"
C
"
,
&
arg
);
kind_of_p
=
mrb_obj_is_kind_of
(
mrb
,
self
,
mrb_class_ptr
(
arg
));
return
mrb_bool_value
(
kind_of_p
);
...
...
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