Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: protoc_plugins/json_values_converter.py

Issue 1551553002: Remove DOM Distiller dependency on scoped_ptr<T>::Pass(). (Closed) Base URL: https://github.com/chromium/dom-distiller.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """protoc plugin to create c++ reader/writer for json-encoded protobufs 6 """protoc plugin to create c++ reader/writer for json-encoded protobufs
7 7
8 The reader/writer use Chrome's base::Values. 8 The reader/writer use Chrome's base::Values.
9 """ 9 """
10 10
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 for field_proto in message.GetFields(): 78 for field_proto in message.GetFields():
79 self.WriteFieldRead(field_proto) 79 self.WriteFieldRead(field_proto)
80 80
81 self.Output( 81 self.Output(
82 ' return true;\n' 82 ' return true;\n'
83 '\n' 83 '\n'
84 'error:\n' 84 'error:\n'
85 ' return false;\n' 85 ' return false;\n'
86 '}}\n' 86 '}}\n'
87 '\n' 87 '\n'
88 'static scoped_ptr<base::Value> WriteToValue(const {generated_class_na me}& message) {{\n' 88 'static scoped_ptr<base::DictionaryValue> WriteToValue(const {generate d_class_name}& message) {{\n'
89 ' scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()) ;\n' 89 ' scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()) ;\n'
90 '', 90 '',
91 generated_class_name=generated_class_name) 91 generated_class_name=generated_class_name)
92 92
93 with self.AddIndent(): 93 with self.AddIndent():
94 for field_proto in message.GetFields(): 94 for field_proto in message.GetFields():
95 self.FieldWriteToValue(field_proto) 95 self.FieldWriteToValue(field_proto)
96 96
97 self.Output( 97 self.Output(
98 ' return dict.Pass();\n' 98 ' return dict;\n'
99 '', 99 '',
100 generated_class_name=generated_class_name) 100 generated_class_name=generated_class_name)
101 self.Output('}}') 101 self.Output('}}')
102 102
103 self.Output('}};') 103 self.Output('}};')
104 self.Output('') 104 self.Output('')
105 105
106 def FieldWriteToValue(self, field): 106 def FieldWriteToValue(self, field):
107 if field.IsRepeated(): 107 if field.IsRepeated():
108 self.Output('{{') 108 self.Output('{{')
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 263
264 response.AddFileWithContent(converter_filename, writer.GetValue()) 264 response.AddFileWithContent(converter_filename, writer.GetValue())
265 if writer.GetErrors(): 265 if writer.GetErrors():
266 response.AddError('\n'.join(writer.GetErrors())) 266 response.AddError('\n'.join(writer.GetErrors()))
267 267
268 response.WriteToStdout() 268 response.WriteToStdout()
269 269
270 270
271 if __name__ == '__main__': 271 if __name__ == '__main__':
272 main() 272 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698