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
ef4f29be
Commit
ef4f29be
authored
May 18, 2014
by
ksss
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support class define in singleton class
parent
4a6650b1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
+14
-3
src/class.c
src/class.c
+14
-3
No files found.
src/class.c
View file @
ef4f29be
...
@@ -227,6 +227,7 @@ mrb_vm_define_class(mrb_state *mrb, mrb_value outer, mrb_value super, mrb_sym id
...
@@ -227,6 +227,7 @@ mrb_vm_define_class(mrb_state *mrb, mrb_value outer, mrb_value super, mrb_sym id
}
}
switch
(
mrb_type
(
outer
))
{
switch
(
mrb_type
(
outer
))
{
case
MRB_TT_CLASS
:
case
MRB_TT_CLASS
:
case
MRB_TT_SCLASS
:
case
MRB_TT_MODULE
:
case
MRB_TT_MODULE
:
break
;
break
;
default:
default:
...
@@ -1245,21 +1246,31 @@ mrb_class_path(mrb_state *mrb, struct RClass *c)
...
@@ -1245,21 +1246,31 @@ mrb_class_path(mrb_state *mrb, struct RClass *c)
{
{
mrb_value
path
;
mrb_value
path
;
const
char
*
name
;
const
char
*
name
;
mrb_int
len
;
mrb_sym
classpath
=
mrb_intern_lit
(
mrb
,
"__classpath__"
);
mrb_sym
classpath
=
mrb_intern_lit
(
mrb
,
"__classpath__"
);
path
=
mrb_obj_iv_get
(
mrb
,
(
struct
RObject
*
)
c
,
classpath
);
path
=
mrb_obj_iv_get
(
mrb
,
(
struct
RObject
*
)
c
,
classpath
);
if
(
mrb_nil_p
(
path
))
{
if
(
mrb_nil_p
(
path
))
{
struct
RClass
*
outer
=
mrb_class_outer_module
(
mrb
,
c
);
struct
RClass
*
outer
=
mrb_class_outer_module
(
mrb
,
c
);
mrb_sym
sym
=
mrb_class_sym
(
mrb
,
c
,
outer
);
mrb_sym
sym
=
mrb_class_sym
(
mrb
,
c
,
outer
);
mrb_int
len
;
if
(
sym
==
0
)
{
if
(
sym
==
0
)
{
return
mrb_nil_value
();
return
mrb_nil_value
();
}
}
else
if
(
outer
&&
outer
!=
mrb
->
object_class
)
{
else
if
(
outer
&&
outer
!=
mrb
->
object_class
)
{
mrb_value
base
=
mrb_class_path
(
mrb
,
outer
);
mrb_value
base
=
mrb_class_path
(
mrb
,
outer
);
path
=
mrb_str_plus
(
mrb
,
base
,
mrb_str_new_lit
(
mrb
,
"::"
));
path
=
mrb_str_buf_new
(
mrb
,
0
);
if
(
mrb_nil_p
(
base
))
{
mrb_str_cat_lit
(
mrb
,
path
,
"#<Class:"
);
mrb_str_concat
(
mrb
,
path
,
mrb_ptr_to_str
(
mrb
,
outer
));
mrb_str_cat_lit
(
mrb
,
path
,
">"
);
}
else
{
mrb_str_concat
(
mrb
,
path
,
base
);
}
mrb_str_cat_lit
(
mrb
,
path
,
"::"
);
name
=
mrb_sym2name_len
(
mrb
,
sym
,
&
len
);
name
=
mrb_sym2name_len
(
mrb
,
sym
,
&
len
);
mrb_str_c
oncat
(
mrb
,
path
,
mrb_str_new
(
mrb
,
name
,
len
)
);
mrb_str_c
at
(
mrb
,
path
,
name
,
len
);
}
}
else
{
else
{
name
=
mrb_sym2name_len
(
mrb
,
sym
,
&
len
);
name
=
mrb_sym2name_len
(
mrb
,
sym
,
&
len
);
...
...
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