Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
d5758134
Unverified
Commit
d5758134
authored
May 14, 2019
by
Joshua Haberman
Committed by
GitHub
May 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Convert Google::Protobuf.deep_copy to pure Ruby"
parent
16d00213
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
17 deletions
+27
-17
map.c
ruby/ext/google/protobuf_c/map.c
+2
-3
message.c
ruby/ext/google/protobuf_c/message.c
+20
-3
protobuf.h
ruby/ext/google/protobuf_c/protobuf.h
+3
-0
repeated_field.c
ruby/ext/google/protobuf_c/repeated_field.c
+2
-3
protobuf.rb
ruby/lib/google/protobuf.rb
+0
-8
No files found.
ruby/ext/google/protobuf_c/map.c
View file @
d5758134
...
...
@@ -538,8 +538,8 @@ VALUE Map_dup(VALUE _self) {
return
new_map
;
}
/
* :nodoc: */
static
VALUE
Map_deep_copy
(
VALUE
_self
)
{
/
/ Used by Google::Protobuf.deep_copy but not exposed directly.
VALUE
Map_deep_copy
(
VALUE
_self
)
{
Map
*
self
=
ruby_to_Map
(
_self
);
VALUE
new_map
=
Map_new_this_type
(
_self
);
Map
*
new_self
=
ruby_to_Map
(
new_map
);
...
...
@@ -851,6 +851,5 @@ void Map_register(VALUE module) {
rb_define_method
(
klass
,
"to_h"
,
Map_to_h
,
0
);
rb_define_method
(
klass
,
"inspect"
,
Map_inspect
,
0
);
rb_define_method
(
klass
,
"merge"
,
Map_merge
,
1
);
rb_define_method
(
klass
,
"deep_copy"
,
Map_deep_copy
,
0
);
rb_include_module
(
klass
,
rb_mEnumerable
);
}
ruby/ext/google/protobuf_c/message.c
View file @
d5758134
...
...
@@ -511,8 +511,8 @@ VALUE Message_dup(VALUE _self) {
return
new_msg
;
}
/
* :nodoc: */
static
VALUE
Message_deep_copy
(
VALUE
_self
)
{
/
/ Internal only; used by Google::Protobuf.deep_copy.
VALUE
Message_deep_copy
(
VALUE
_self
)
{
MessageHeader
*
self
;
MessageHeader
*
new_msg_self
;
VALUE
new_msg
;
...
...
@@ -742,7 +742,6 @@ VALUE build_class_from_descriptor(Descriptor* desc) {
rb_define_method
(
klass
,
"to_s"
,
Message_inspect
,
0
);
rb_define_method
(
klass
,
"[]"
,
Message_index
,
1
);
rb_define_method
(
klass
,
"[]="
,
Message_index_set
,
2
);
rb_define_method
(
klass
,
"deep_copy"
,
Message_deep_copy
,
0
);
rb_define_singleton_method
(
klass
,
"decode"
,
Message_decode
,
1
);
rb_define_singleton_method
(
klass
,
"encode"
,
Message_encode
,
1
);
rb_define_singleton_method
(
klass
,
"decode_json"
,
Message_decode_json
,
-
1
);
...
...
@@ -830,3 +829,21 @@ VALUE build_module_from_enumdesc(EnumDescriptor* enumdesc) {
return
mod
;
}
/*
* call-seq:
* Google::Protobuf.deep_copy(obj) => copy_of_obj
*
* Performs a deep copy of a RepeatedField instance, a Map instance, or a
* message object, recursively copying its members.
*/
VALUE
Google_Protobuf_deep_copy
(
VALUE
self
,
VALUE
obj
)
{
VALUE
klass
=
CLASS_OF
(
obj
);
if
(
klass
==
cRepeatedField
)
{
return
RepeatedField_deep_copy
(
obj
);
}
else
if
(
klass
==
cMap
)
{
return
Map_deep_copy
(
obj
);
}
else
{
return
Message_deep_copy
(
obj
);
}
}
ruby/ext/google/protobuf_c/protobuf.h
View file @
d5758134
...
...
@@ -425,6 +425,7 @@ VALUE RepeatedField_replace(VALUE _self, VALUE list);
VALUE
RepeatedField_clear
(
VALUE
_self
);
VALUE
RepeatedField_length
(
VALUE
_self
);
VALUE
RepeatedField_dup
(
VALUE
_self
);
VALUE
RepeatedField_deep_copy
(
VALUE
_self
);
VALUE
RepeatedField_to_ary
(
VALUE
_self
);
VALUE
RepeatedField_eq
(
VALUE
_self
,
VALUE
_other
);
VALUE
RepeatedField_hash
(
VALUE
_self
);
...
...
@@ -468,6 +469,7 @@ VALUE Map_delete(VALUE _self, VALUE key);
VALUE
Map_clear
(
VALUE
_self
);
VALUE
Map_length
(
VALUE
_self
);
VALUE
Map_dup
(
VALUE
_self
);
VALUE
Map_deep_copy
(
VALUE
_self
);
VALUE
Map_eq
(
VALUE
_self
,
VALUE
_other
);
VALUE
Map_hash
(
VALUE
_self
);
VALUE
Map_to_h
(
VALUE
_self
);
...
...
@@ -562,6 +564,7 @@ VALUE Message_alloc(VALUE klass);
VALUE
Message_method_missing
(
int
argc
,
VALUE
*
argv
,
VALUE
_self
);
VALUE
Message_initialize
(
int
argc
,
VALUE
*
argv
,
VALUE
_self
);
VALUE
Message_dup
(
VALUE
_self
);
VALUE
Message_deep_copy
(
VALUE
_self
);
VALUE
Message_eq
(
VALUE
_self
,
VALUE
_other
);
VALUE
Message_hash
(
VALUE
_self
);
VALUE
Message_inspect
(
VALUE
_self
);
...
...
ruby/ext/google/protobuf_c/repeated_field.c
View file @
d5758134
...
...
@@ -355,8 +355,8 @@ VALUE RepeatedField_dup(VALUE _self) {
return
new_rptfield
;
}
/
* :nodoc: */
static
VALUE
RepeatedField_deep_copy
(
VALUE
_self
)
{
/
/ Internal only: used by Google::Protobuf.deep_copy.
VALUE
RepeatedField_deep_copy
(
VALUE
_self
)
{
RepeatedField
*
self
=
ruby_to_RepeatedField
(
_self
);
VALUE
new_rptfield
=
RepeatedField_new_this_type
(
_self
);
RepeatedField
*
new_rptfield_self
=
ruby_to_RepeatedField
(
new_rptfield
);
...
...
@@ -656,6 +656,5 @@ void RepeatedField_register(VALUE module) {
rb_define_method
(
klass
,
"hash"
,
RepeatedField_hash
,
0
);
rb_define_method
(
klass
,
"+"
,
RepeatedField_plus
,
1
);
rb_define_method
(
klass
,
"concat"
,
RepeatedField_concat
,
1
);
rb_define_method
(
klass
,
"deep_copy"
,
RepeatedField_deep_copy
,
0
);
rb_include_module
(
klass
,
rb_mEnumerable
);
}
ruby/lib/google/protobuf.rb
View file @
d5758134
...
...
@@ -73,13 +73,5 @@ module Google
klass
.
decode_json
(
json
,
options
)
end
# call-seq:
# Google::Protobuf.deep_copy(obj) => copy_of_obj
#
# Performs a deep copy of a RepeatedField instance, a Map instance, or a
# message object, recursively copying its members.
def
self
.
deep_copy
(
obj
)
obj
.
deep_copy
end
end
end
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