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
147fbf1c
Commit
147fbf1c
authored
Sep 19, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
`Module#const_defined?` to take second optional argument as CRuby; fix #2593
parent
95c7f570
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
17 deletions
+14
-17
src/class.c
src/class.c
+14
-17
No files found.
src/class.c
View file @
147fbf1c
...
...
@@ -1919,27 +1919,24 @@ check_const_name_sym(mrb_state *mrb, mrb_sym id)
check_const_name_str
(
mrb
,
mrb_sym2str
(
mrb
,
id
));
}
static
mrb_value
const_defined
(
mrb_state
*
mrb
,
mrb_value
mod
,
mrb_sym
id
,
mrb_bool
inherit
)
{
if
(
inherit
)
{
return
mrb_bool_value
(
mrb_const_defined
(
mrb
,
mod
,
id
));
}
return
mrb_bool_value
(
mrb_const_defined_at
(
mrb
,
mod
,
id
));
}
static
mrb_value
mrb_mod_const_defined
(
mrb_state
*
mrb
,
mrb_value
mod
)
{
mrb_value
id
;
mrb_bool
inherit
=
TRUE
;
id
=
get_sym_or_str_arg
(
mrb
);
if
(
mrb_type
(
id
)
==
MRB_TT_SYMBOL
)
{
check_const_name_sym
(
mrb
,
mrb_symbol
(
id
));
return
mrb_bool_value
(
mrb_const_defined
(
mrb
,
mod
,
mrb_symbol
(
id
)));
}
else
{
mrb_value
sym
;
check_const_name_str
(
mrb
,
id
);
sym
=
mrb_check_intern_str
(
mrb
,
id
);
if
(
mrb_nil_p
(
sym
))
{
return
mrb_false_value
();
}
else
{
return
mrb_bool_value
(
mrb_const_defined
(
mrb
,
mod
,
mrb_symbol
(
sym
)));
}
}
mrb_get_args
(
mrb
,
"n|b"
,
&
id
,
&
inherit
);
check_const_name_sym
(
mrb
,
mrb_symbol
(
id
));
return
const_defined
(
mrb
,
mod
,
mrb_symbol
(
id
),
inherit
);
}
static
mrb_value
...
...
@@ -2131,7 +2128,7 @@ mrb_init_class(mrb_state *mrb)
mrb_define_method
(
mrb
,
mod
,
"alias_method"
,
mrb_mod_alias
,
MRB_ARGS_ANY
());
/* 15.2.2.4.8 */
mrb_define_method
(
mrb
,
mod
,
"ancestors"
,
mrb_mod_ancestors
,
MRB_ARGS_NONE
());
/* 15.2.2.4.9 */
mrb_define_method
(
mrb
,
mod
,
"undef_method"
,
mrb_mod_undef
,
MRB_ARGS_ANY
());
/* 15.2.2.4.41 */
mrb_define_method
(
mrb
,
mod
,
"const_defined?"
,
mrb_mod_const_defined
,
MRB_ARGS_
REQ
(
1
));
/* 15.2.2.4.20 */
mrb_define_method
(
mrb
,
mod
,
"const_defined?"
,
mrb_mod_const_defined
,
MRB_ARGS_
ARG
(
1
,
1
));
/* 15.2.2.4.20 */
mrb_define_method
(
mrb
,
mod
,
"const_get"
,
mrb_mod_const_get
,
MRB_ARGS_REQ
(
1
));
/* 15.2.2.4.21 */
mrb_define_method
(
mrb
,
mod
,
"const_set"
,
mrb_mod_const_set
,
MRB_ARGS_REQ
(
2
));
/* 15.2.2.4.23 */
mrb_define_method
(
mrb
,
mod
,
"constants"
,
mrb_mod_constants
,
MRB_ARGS_OPT
(
1
));
/* 15.2.2.4.24 */
...
...
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