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
f341957f
Commit
f341957f
authored
Dec 20, 2012
by
skandhas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mrb_mod_cvar_get
parent
a9f1c459
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
src/class.c
src/class.c
+28
-0
No files found.
src/class.c
View file @
f341957f
...
...
@@ -1444,6 +1444,33 @@ mrb_sym_value(mrb_state *mrb, mrb_value val)
return
mrb_symbol
(
val
);
}
/* 15.2.2.4.17 */
/*
* call-seq:
* mod.class_variable_get(symbol) -> obj
*
* Returns the value of the given class variable (or throws a
* <code>NameError</code> exception). The <code>@@</code> part of the
* variable name should be included for regular class variables
*
* class Fred
* @@foo = 99
* end
* Fred.class_variable_get(:@@foo) #=> 99
*/
static
mrb_value
mrb_mod_cvar_get
(
mrb_state
*
mrb
,
mrb_value
mod
)
{
mrb_value
sym
;
mrb_sym
id
;
mrb_get_args
(
mrb
,
"o"
,
&
sym
);
id
=
mrb_sym_value
(
mrb
,
sym
);
check_cvar_name
(
mrb
,
id
);
return
mrb_cv_get
(
mrb
,
mod
,
id
);
}
static
void
check_const_name
(
mrb_state
*
mrb
,
mrb_sym
id
)
{
...
...
@@ -1545,6 +1572,7 @@ mrb_init_class(mrb_state *mrb)
mrb_define_method
(
mrb
,
cls
,
"superclass"
,
mrb_class_superclass
,
ARGS_NONE
());
/* 15.2.3.3.4 */
mrb_define_method
(
mrb
,
cls
,
"new"
,
mrb_instance_new
,
ARGS_ANY
());
/* 15.2.3.3.3 */
mrb_define_method
(
mrb
,
cls
,
"inherited"
,
mrb_bob_init
,
ARGS_REQ
(
1
));
mrb_define_method
(
mrb
,
mod
,
"class_variable_get"
,
mrb_mod_cvar_get
,
ARGS_REQ
(
1
));
/* 15.2.2.4.17 */
mrb_define_method
(
mrb
,
mod
,
"extend_object"
,
mrb_mod_extend_object
,
ARGS_REQ
(
1
));
/* 15.2.2.4.25 */
mrb_define_method
(
mrb
,
mod
,
"extended"
,
mrb_bob_init
,
ARGS_REQ
(
1
));
/* 15.2.2.4.26 */
mrb_define_method
(
mrb
,
mod
,
"include"
,
mrb_mod_include
,
ARGS_ANY
());
/* 15.2.2.4.27 */
...
...
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