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
a367373f
Commit
a367373f
authored
Nov 16, 2019
by
KOBAYASHI Shuji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Implement Ruby2.7's frozen strings from `Symbol#to_s`"
This feature was reverted from Ruby 2.7.
parent
c9f156ef
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
27 deletions
+24
-27
mrbgems/mruby-class-ext/src/class.c
mrbgems/mruby-class-ext/src/class.c
+5
-1
mrbgems/mruby-symbol-ext/mrblib/symbol.rb
mrbgems/mruby-symbol-ext/mrblib/symbol.rb
+4
-4
src/class.c
src/class.c
+11
-14
src/symbol.c
src/symbol.c
+3
-7
src/variable.c
src/variable.c
+1
-1
No files found.
mrbgems/mruby-class-ext/src/class.c
View file @
a367373f
...
...
@@ -5,7 +5,11 @@
static
mrb_value
mrb_mod_name
(
mrb_state
*
mrb
,
mrb_value
self
)
{
return
mrb_class_path
(
mrb
,
mrb_class_ptr
(
self
));
mrb_value
name
=
mrb_class_path
(
mrb
,
mrb_class_ptr
(
self
));
if
(
mrb_string_p
(
name
))
{
MRB_SET_FROZEN_FLAG
(
mrb_basic_ptr
(
name
));
}
return
name
;
}
static
mrb_value
...
...
mrbgems/mruby-symbol-ext/mrblib/symbol.rb
View file @
a367373f
...
...
@@ -10,7 +10,7 @@ class Symbol
# Same as <code>sym.to_s.capitalize.intern</code>.
def
capitalize
self
.
to_s
.
capitalize
.
to_sym
(
self
.
to_s
.
capitalize!
||
self
)
.
to_sym
end
##
...
...
@@ -20,7 +20,7 @@ class Symbol
# Same as <code>sym.to_s.downcase.intern</code>.
def
downcase
self
.
to_s
.
downcase
.
to_sym
(
self
.
to_s
.
downcase!
||
self
)
.
to_sym
end
##
...
...
@@ -30,7 +30,7 @@ class Symbol
# Same as <code>sym.to_s.upcase.intern</code>.
def
upcase
self
.
to_s
.
upcase
.
to_sym
(
self
.
to_s
.
upcase!
||
self
)
.
to_sym
end
##
...
...
@@ -41,7 +41,7 @@ class Symbol
def
casecmp
(
other
)
return
nil
unless
other
.
kind_of?
(
Symbol
)
lhs
=
self
.
to_s
.
upcase
lhs
=
self
.
to_s
;
lhs
.
upcase!
rhs
=
other
.
to_s
.
upcase
lhs
<=>
rhs
end
...
...
src/class.c
View file @
a367373f
...
...
@@ -65,23 +65,21 @@ mrb_class_name_class(mrb_state *mrb, struct RClass *outer, struct RClass *c, mrb
name
=
mrb_symbol_value
(
id
);
}
else
{
const
char
*
n
;
mrb_int
len
;
mrb_value
outer_name
=
mrb_class_path
(
mrb
,
outer
);
if
(
mrb_nil_p
(
outer_name
))
{
/* unnamed outer class */
name
=
mrb_class_path
(
mrb
,
outer
);
if
(
mrb_nil_p
(
name
))
{
/* unnamed outer class */
if
(
outer
!=
mrb
->
object_class
&&
outer
!=
c
)
{
mrb_obj_iv_set_force
(
mrb
,
(
struct
RObject
*
)
c
,
mrb_intern_lit
(
mrb
,
"__outer__"
),
mrb_obj_value
(
outer
));
}
return
;
}
n
=
mrb_sym_name_len
(
mrb
,
id
,
&
len
);
name
=
mrb_str_new_capa
(
mrb
,
RSTRING_LEN
(
outer_name
)
+
2
+
len
);
mrb_str_cat_str
(
mrb
,
name
,
outer_name
);
mrb_str_cat_lit
(
mrb
,
name
,
"::"
);
mrb_str_cat
(
mrb
,
name
,
n
,
len
);
MRB_SET_FROZEN_FLAG
(
mrb_obj_ptr
(
name
));
else
{
mrb_int
len
;
const
char
*
n
=
mrb_sym_name_len
(
mrb
,
id
,
&
len
);
mrb_str_cat_lit
(
mrb
,
name
,
"::"
);
mrb_str_cat
(
mrb
,
name
,
n
,
len
);
}
}
mrb_obj_iv_set_force
(
mrb
,
(
struct
RObject
*
)
c
,
nsym
,
name
);
}
...
...
@@ -1718,7 +1716,7 @@ mrb_class_path(mrb_state *mrb, struct RClass *c)
/* toplevel class/module */
return
mrb_sym_str
(
mrb
,
mrb_symbol
(
path
));
}
return
path
;
return
mrb_str_dup
(
mrb
,
path
)
;
}
MRB_API
struct
RClass
*
...
...
@@ -1885,8 +1883,7 @@ mrb_mod_to_s(mrb_state *mrb, mrb_value klass)
return
mrb_str_cat_lit
(
mrb
,
str
,
">"
);
}
else
{
mrb_value
str
=
class_name_str
(
mrb
,
mrb_class_ptr
(
klass
));
return
mrb_frozen_p
(
mrb_basic_ptr
(
str
))
?
mrb_str_dup
(
mrb
,
str
)
:
str
;
return
class_name_str
(
mrb
,
mrb_class_ptr
(
klass
));
}
}
...
...
src/symbol.c
View file @
a367373f
...
...
@@ -517,18 +517,14 @@ mrb_sym_str(mrb_state *mrb, mrb_sym sym)
{
mrb_int
len
;
const
char
*
name
=
mrb_sym_name_len
(
mrb
,
sym
,
&
len
);
mrb_value
str
;
if
(
!
name
)
return
mrb_undef_value
();
/* can't happen */
if
(
SYMBOL_INLINE_P
(
sym
))
{
str
=
mrb_str_new
(
mrb
,
name
,
len
);
mrb_value
str
=
mrb_str_new
(
mrb
,
name
,
len
);
RSTR_SET_ASCII_FLAG
(
mrb_str_ptr
(
str
));
return
str
;
}
else
{
str
=
mrb_str_new_static
(
mrb
,
name
,
len
);
}
MRB_SET_FROZEN_FLAG
(
mrb_str_ptr
(
str
));
return
str
;
return
mrb_str_new_static
(
mrb
,
name
,
len
);
}
static
const
char
*
...
...
src/variable.c
View file @
a367373f
...
...
@@ -1123,7 +1123,7 @@ mrb_class_find_path(mrb_state *mrb, struct RClass *c)
iv_del
(
mrb
,
c
->
iv
,
mrb_intern_lit
(
mrb
,
"__outer__"
),
NULL
);
iv_put
(
mrb
,
c
->
iv
,
mrb_intern_lit
(
mrb
,
"__classname__"
),
path
);
mrb_field_write_barrier_value
(
mrb
,
(
struct
RBasic
*
)
c
,
path
);
MRB_SET_FROZEN_FLAG
(
mrb_obj_ptr
(
path
)
);
path
=
mrb_str_dup
(
mrb
,
path
);
}
return
path
;
}
...
...
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