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

Side by Side Diff: core/inspector/CodeGeneratorInspector.py

Issue 959933002: Move IDLs to 39 roll (Closed) Base URL: https://dart.googlecode.com/svn/third_party/WebCore
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 Google Inc. All rights reserved. 2 # Copyright (c) 2011 Google Inc. All rights reserved.
3 # Copyright (c) 2012 Intel Corporation. All rights reserved. 3 # Copyright (c) 2012 Intel Corporation. All rights reserved.
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are 6 # modification, are permitted provided that the following conditions are
7 # met: 7 # met:
8 # 8 #
9 # * Redistributions of source code must retain the above copyright 9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer. 10 # notice, this list of conditions and the following disclaimer.
(...skipping 30 matching lines...) Expand all
41 import CodeGeneratorInspectorStrings 41 import CodeGeneratorInspectorStrings
42 42
43 # Manually-filled map of type name replacements. 43 # Manually-filled map of type name replacements.
44 TYPE_NAME_FIX_MAP = { 44 TYPE_NAME_FIX_MAP = {
45 "RGBA": "Rgba", # RGBA is reported to be conflicting with a define name in Windows CE. 45 "RGBA": "Rgba", # RGBA is reported to be conflicting with a define name in Windows CE.
46 "": "Empty", 46 "": "Empty",
47 } 47 }
48 48
49 49
50 TYPES_WITH_RUNTIME_CAST_SET = frozenset(["Runtime.RemoteObject", "Runtime.Proper tyDescriptor", "Runtime.InternalPropertyDescriptor", 50 TYPES_WITH_RUNTIME_CAST_SET = frozenset(["Runtime.RemoteObject", "Runtime.Proper tyDescriptor", "Runtime.InternalPropertyDescriptor",
51 "Debugger.FunctionDetails", "Debugger.C allFrame", "Debugger.Location", 51 "Debugger.FunctionDetails", "Debugger.C ollectionEntry", "Debugger.CallFrame", "Debugger.Location",
52 "Canvas.TraceLog", "Canvas.ResourceStat e"]) 52 "Canvas.TraceLog", "Canvas.ResourceStat e"])
53 53
54 TYPES_WITH_OPEN_FIELD_LIST_SET = frozenset([ 54 TYPES_WITH_OPEN_FIELD_LIST_SET = frozenset([
55 # InspectorStyleSheet not only creat es this property but wants to read it and modify it. 55 # InspectorStyleSheet not only creat es this property but wants to read it and modify it.
56 "CSS.CSSProperty", 56 "CSS.CSSProperty",
57 # InspectorResourceAgent needs to up date mime-type. 57 # InspectorResourceAgent needs to up date mime-type.
58 "Network.Response"]) 58 "Network.Response"])
59 59
60 EXACTLY_INT_SUPPORTED = False
61
62 cmdline_parser = optparse.OptionParser() 60 cmdline_parser = optparse.OptionParser()
63 cmdline_parser.add_option("--output_dir") 61 cmdline_parser.add_option("--output_dir")
64 62
65 try: 63 try:
66 arg_options, arg_values = cmdline_parser.parse_args() 64 arg_options, arg_values = cmdline_parser.parse_args()
67 if (len(arg_values) != 1): 65 if (len(arg_values) != 1):
68 raise Exception("Exactly one plain argument expected (found %s)" % len(a rg_values)) 66 raise Exception("Exactly one plain argument expected (found %s)" % len(a rg_values))
69 input_json_filename = arg_values[0] 67 input_json_filename = arg_values[0]
70 output_dirname = arg_options.output_dir 68 output_dirname = arg_options.output_dir
71 if not output_dirname: 69 if not output_dirname:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 if pos == 1: 108 if pos == 1:
111 return str[0].lower() + str[1:] 109 return str[0].lower() + str[1:]
112 if pos < len(str): 110 if pos < len(str):
113 pos -= 1 111 pos -= 1
114 possible_abbreviation = str[0:pos] 112 possible_abbreviation = str[0:pos]
115 if possible_abbreviation not in Capitalizer.ABBREVIATION: 113 if possible_abbreviation not in Capitalizer.ABBREVIATION:
116 raise Exception("Unknown abbreviation %s" % possible_abbreviation) 114 raise Exception("Unknown abbreviation %s" % possible_abbreviation)
117 str = possible_abbreviation.lower() + str[pos:] 115 str = possible_abbreviation.lower() + str[pos:]
118 return str 116 return str
119 117
120 @staticmethod
121 def camel_case_to_capitalized_with_underscores(str):
122 if len(str) == 0:
123 return str
124 output = Capitalizer.split_camel_case_(str)
125 return "_".join(output).upper()
126
127 @staticmethod
128 def split_camel_case_(str):
129 output = []
130 pos_being = 0
131 pos = 1
132 has_oneletter = False
133 while pos < len(str):
134 if str[pos].isupper():
135 output.append(str[pos_being:pos].upper())
136 if pos - pos_being == 1:
137 has_oneletter = True
138 pos_being = pos
139 pos += 1
140 output.append(str[pos_being:])
141 if has_oneletter:
142 array_pos = 0
143 while array_pos < len(output) - 1:
144 if len(output[array_pos]) == 1:
145 array_pos_end = array_pos + 1
146 while array_pos_end < len(output) and len(output[array_pos_e nd]) == 1:
147 array_pos_end += 1
148 if array_pos_end - array_pos > 1:
149 possible_abbreviation = "".join(output[array_pos:array_p os_end])
150 if possible_abbreviation.upper() in Capitalizer.ABBREVIA TION:
151 output[array_pos:array_pos_end] = [possible_abbrevia tion]
152 else:
153 array_pos = array_pos_end - 1
154 array_pos += 1
155 return output
156
157 ABBREVIATION = frozenset(["XHR", "DOM", "CSS"]) 118 ABBREVIATION = frozenset(["XHR", "DOM", "CSS"])
158 119
159 VALIDATOR_IFDEF_NAME = "ENABLE(ASSERT)" 120 VALIDATOR_IFDEF_NAME = "ENABLE(ASSERT)"
160 121
161 122
162 class DomainNameFixes: 123 class DomainNameFixes:
163 @classmethod 124 @staticmethod
164 def get_fixed_data(cls, domain_name): 125 def get_fixed_data(domain_name):
165 field_name_res = Capitalizer.upper_camel_case_to_lower(domain_name) + "A gent" 126 return Capitalizer.upper_camel_case_to_lower(domain_name) + "Agent"
166
167 class Res(object):
168 agent_field_name = field_name_res
169
170 return Res
171
172 127
173 class RawTypes(object): 128 class RawTypes(object):
174 @staticmethod 129 @staticmethod
175 def get(json_type): 130 def get(json_type):
176 if json_type == "boolean": 131 if json_type == "boolean":
177 return RawTypes.Bool 132 return RawTypes.Bool
178 elif json_type == "string": 133 elif json_type == "string":
179 return RawTypes.String 134 return RawTypes.String
180 elif json_type == "array": 135 elif json_type == "array":
181 return RawTypes.Array 136 return RawTypes.Array
182 elif json_type == "object": 137 elif json_type == "object":
183 return RawTypes.Object 138 return RawTypes.Object
184 elif json_type == "integer": 139 elif json_type == "integer":
185 return RawTypes.Int 140 return RawTypes.Int
186 elif json_type == "number": 141 elif json_type == "number":
187 return RawTypes.Number 142 return RawTypes.Number
188 elif json_type == "any": 143 elif json_type == "any":
189 return RawTypes.Any 144 return RawTypes.Any
190 else: 145 else:
191 raise Exception("Unknown type: %s" % json_type) 146 raise Exception("Unknown type: %s" % json_type)
192 147
193 # For output parameter all values are passed by pointer except RefPtr-based types.
194 class OutputPassModel:
195 class ByPointer:
196 @staticmethod
197 def get_argument_prefix():
198 return "&"
199
200 @staticmethod
201 def get_parameter_type_suffix():
202 return "*"
203
204 class ByReference:
205 @staticmethod
206 def get_argument_prefix():
207 return ""
208
209 @staticmethod
210 def get_parameter_type_suffix():
211 return "&"
212
213 class BaseType(object): 148 class BaseType(object):
214 need_internal_runtime_cast_ = False
215
216 @classmethod
217 def request_raw_internal_runtime_cast(cls):
218 if not cls.need_internal_runtime_cast_:
219 cls.need_internal_runtime_cast_ = True
220
221 @classmethod 149 @classmethod
222 def get_raw_validator_call_text(cls): 150 def get_raw_validator_call_text(cls):
223 return "RuntimeCastHelper::assertType<JSONValue::Type%s>" % cls.get_ validate_method_params().template_type 151 return "RuntimeCastHelper::assertType<JSONValue::Type%s>" % cls.get_ getter_name()
224 152
225 @staticmethod 153 @staticmethod
226 def get_validate_method_params(): 154 def get_getter_name():
227 raise Exception("Abstract method") 155 raise Exception("Unsupported")
228 156
229 class String(BaseType): 157 class String(BaseType):
230 @staticmethod 158 @staticmethod
231 def get_getter_name(): 159 def get_getter_name():
232 return "String" 160 return "String"
233 161
234 get_setter_name = get_getter_name 162 get_setter_name = get_getter_name
235 163
236 @staticmethod 164 @staticmethod
237 def get_constructor_pattern(): 165 def get_constructor_pattern():
238 return "InspectorString::create(%s)" 166 return "InspectorString::create(%s)"
239 167
240 @staticmethod 168 @staticmethod
241 def get_c_initializer():
242 return "\"\""
243
244 @staticmethod
245 def get_validate_method_params():
246 class ValidateMethodParams:
247 template_type = "String"
248 return ValidateMethodParams
249
250 @staticmethod
251 def get_output_pass_model():
252 return RawTypes.OutputPassModel.ByPointer
253
254 @staticmethod
255 def is_heavy_value(): 169 def is_heavy_value():
256 return True 170 return True
257 171
258 @staticmethod 172 @staticmethod
259 def get_array_item_raw_c_type_text(): 173 def get_array_item_raw_c_type_text():
260 return "String" 174 return "String"
261 175
262 @staticmethod 176 @staticmethod
263 def get_raw_type_model(): 177 def get_raw_type_model():
264 return TypeModel.String 178 return TypeModel.String
265 179
266 class Int(BaseType): 180 class Int(BaseType):
267 @staticmethod 181 @staticmethod
268 def get_getter_name(): 182 def get_getter_name():
269 return "Int" 183 return "Int"
270 184
271 @staticmethod 185 @staticmethod
272 def get_setter_name(): 186 def get_setter_name():
273 return "Number" 187 return "Number"
274 188
275 @staticmethod 189 @staticmethod
276 def get_constructor_pattern(): 190 def get_constructor_pattern():
277 return "InspectorBasicValue::create(%s)" 191 return "InspectorBasicValue::create(%s)"
278 192
279 @staticmethod
280 def get_c_initializer():
281 return "0"
282
283 @classmethod 193 @classmethod
284 def get_raw_validator_call_text(cls): 194 def get_raw_validator_call_text(cls):
285 return "RuntimeCastHelper::assertInt" 195 return "RuntimeCastHelper::assertInt"
286 196
287 @staticmethod 197 @staticmethod
288 def get_output_pass_model():
289 return RawTypes.OutputPassModel.ByPointer
290
291 @staticmethod
292 def is_heavy_value(): 198 def is_heavy_value():
293 return False 199 return False
294 200
295 @staticmethod 201 @staticmethod
296 def get_array_item_raw_c_type_text(): 202 def get_array_item_raw_c_type_text():
297 return "int" 203 return "int"
298 204
299 @staticmethod 205 @staticmethod
300 def get_raw_type_model(): 206 def get_raw_type_model():
301 return TypeModel.Int 207 return TypeModel.Int
302 208
303 class Number(BaseType): 209 class Number(BaseType):
304 @staticmethod 210 @staticmethod
305 def get_getter_name(): 211 def get_getter_name():
306 return "Double" 212 return "Double"
307 213
308 @staticmethod 214 @staticmethod
309 def get_setter_name(): 215 def get_setter_name():
310 return "Number" 216 return "Number"
311 217
312 @staticmethod 218 @staticmethod
313 def get_constructor_pattern(): 219 def get_constructor_pattern():
314 return "InspectorBasicValue::create(%s)" 220 return "InspectorBasicValue::create(%s)"
315 221
316 @staticmethod 222 @staticmethod
317 def get_c_initializer(): 223 def get_raw_validator_call_text():
318 return "0" 224 return "RuntimeCastHelper::assertType<JSONValue::TypeNumber>"
319
320 @staticmethod
321 def get_validate_method_params():
322 class ValidateMethodParams:
323 template_type = "Number"
324 return ValidateMethodParams
325
326 @staticmethod
327 def get_output_pass_model():
328 return RawTypes.OutputPassModel.ByPointer
329 225
330 @staticmethod 226 @staticmethod
331 def is_heavy_value(): 227 def is_heavy_value():
332 return False 228 return False
333 229
334 @staticmethod 230 @staticmethod
335 def get_array_item_raw_c_type_text(): 231 def get_array_item_raw_c_type_text():
336 return "double" 232 return "double"
337 233
338 @staticmethod 234 @staticmethod
339 def get_raw_type_model(): 235 def get_raw_type_model():
340 return TypeModel.Number 236 return TypeModel.Number
341 237
342 class Bool(BaseType): 238 class Bool(BaseType):
343 @staticmethod 239 @staticmethod
344 def get_getter_name(): 240 def get_getter_name():
345 return "Boolean" 241 return "Boolean"
346 242
347 get_setter_name = get_getter_name 243 get_setter_name = get_getter_name
348 244
349 @staticmethod 245 @staticmethod
350 def get_constructor_pattern(): 246 def get_constructor_pattern():
351 return "InspectorBasicValue::create(%s)" 247 return "InspectorBasicValue::create(%s)"
352 248
353 @staticmethod 249 @staticmethod
354 def get_c_initializer():
355 return "false"
356
357 @staticmethod
358 def get_validate_method_params():
359 class ValidateMethodParams:
360 template_type = "Boolean"
361 return ValidateMethodParams
362
363 @staticmethod
364 def get_output_pass_model():
365 return RawTypes.OutputPassModel.ByPointer
366
367 @staticmethod
368 def is_heavy_value(): 250 def is_heavy_value():
369 return False 251 return False
370 252
371 @staticmethod 253 @staticmethod
372 def get_array_item_raw_c_type_text(): 254 def get_array_item_raw_c_type_text():
373 return "bool" 255 return "bool"
374 256
375 @staticmethod 257 @staticmethod
376 def get_raw_type_model(): 258 def get_raw_type_model():
377 return TypeModel.Bool 259 return TypeModel.Bool
378 260
379 class Object(BaseType): 261 class Object(BaseType):
380 @staticmethod 262 @staticmethod
381 def get_getter_name(): 263 def get_getter_name():
382 return "Object" 264 return "Object"
383 265
384 @staticmethod 266 @staticmethod
385 def get_setter_name(): 267 def get_setter_name():
386 return "Value" 268 return "Value"
387 269
388 @staticmethod 270 @staticmethod
389 def get_constructor_pattern(): 271 def get_constructor_pattern():
390 return "%s" 272 return "%s"
391 273
392 @staticmethod 274 @staticmethod
393 def get_c_initializer():
394 return "JSONObject::create()"
395
396 @staticmethod
397 def get_output_argument_prefix(): 275 def get_output_argument_prefix():
398 return "" 276 return ""
399 277
400 @staticmethod 278 @staticmethod
401 def get_validate_method_params():
402 class ValidateMethodParams:
403 template_type = "Object"
404 return ValidateMethodParams
405
406 @staticmethod
407 def get_output_pass_model():
408 return RawTypes.OutputPassModel.ByReference
409
410 @staticmethod
411 def is_heavy_value(): 279 def is_heavy_value():
412 return True 280 return True
413 281
414 @staticmethod 282 @staticmethod
415 def get_array_item_raw_c_type_text(): 283 def get_array_item_raw_c_type_text():
416 return "JSONObject" 284 return "JSONObject"
417 285
418 @staticmethod 286 @staticmethod
419 def get_raw_type_model(): 287 def get_raw_type_model():
420 return TypeModel.Object 288 return TypeModel.Object
421 289
422 class Any(BaseType): 290 class Any(BaseType):
423 @staticmethod 291 @staticmethod
424 def get_getter_name(): 292 def get_getter_name():
425 return "Value" 293 return "Value"
426 294
427 get_setter_name = get_getter_name 295 get_setter_name = get_getter_name
428 296
429 @staticmethod 297 @staticmethod
430 def get_c_initializer():
431 raise Exception("Unsupported")
432
433 @staticmethod
434 def get_constructor_pattern(): 298 def get_constructor_pattern():
435 raise Exception("Unsupported") 299 raise Exception("Unsupported")
436 300
437 @staticmethod 301 @staticmethod
438 def get_raw_validator_call_text(): 302 def get_raw_validator_call_text():
439 return "RuntimeCastHelper::assertAny" 303 return "RuntimeCastHelper::assertAny"
440 304
441 @staticmethod 305 @staticmethod
442 def get_output_pass_model():
443 return RawTypes.OutputPassModel.ByReference
444
445 @staticmethod
446 def is_heavy_value(): 306 def is_heavy_value():
447 return True 307 return True
448 308
449 @staticmethod 309 @staticmethod
450 def get_array_item_raw_c_type_text(): 310 def get_array_item_raw_c_type_text():
451 return "JSONValue" 311 return "JSONValue"
452 312
453 @staticmethod 313 @staticmethod
454 def get_raw_type_model(): 314 def get_raw_type_model():
455 return TypeModel.Any 315 return TypeModel.Any
456 316
457 class Array(BaseType): 317 class Array(BaseType):
458 @staticmethod 318 @staticmethod
459 def get_getter_name(): 319 def get_getter_name():
460 return "Array" 320 return "Array"
461 321
462 @staticmethod 322 @staticmethod
463 def get_setter_name(): 323 def get_setter_name():
464 return "Value" 324 return "Value"
465 325
466 @staticmethod 326 @staticmethod
467 def get_constructor_pattern(): 327 def get_constructor_pattern():
468 return "%s" 328 return "%s"
469 329
470 @staticmethod 330 @staticmethod
471 def get_c_initializer():
472 return "JSONArray::create()"
473
474 @staticmethod
475 def get_output_argument_prefix(): 331 def get_output_argument_prefix():
476 return "" 332 return ""
477 333
478 @staticmethod 334 @staticmethod
479 def get_validate_method_params():
480 class ValidateMethodParams:
481 template_type = "Array"
482 return ValidateMethodParams
483
484 @staticmethod
485 def get_output_pass_model():
486 return RawTypes.OutputPassModel.ByReference
487
488 @staticmethod
489 def is_heavy_value(): 335 def is_heavy_value():
490 return True 336 return True
491 337
492 @staticmethod 338 @staticmethod
493 def get_array_item_raw_c_type_text(): 339 def get_array_item_raw_c_type_text():
494 return "JSONArray" 340 return "JSONArray"
495 341
496 @staticmethod 342 @staticmethod
497 def get_raw_type_model(): 343 def get_raw_type_model():
498 return TypeModel.Array 344 return TypeModel.Array
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 def get_command_return_pass_model(self): 508 def get_command_return_pass_model(self):
663 return CommandReturnPassModel.OptOutput(self.base.get_opt_output _type_()) 509 return CommandReturnPassModel.OptOutput(self.base.get_opt_output _type_())
664 510
665 def get_input_param_type_text(self): 511 def get_input_param_type_text(self):
666 return "const %s* const" % self.base.type_name 512 return "const %s* const" % self.base.type_name
667 513
668 @staticmethod 514 @staticmethod
669 def get_event_setter_expression_pattern(): 515 def get_event_setter_expression_pattern():
670 return "*%s" 516 return "*%s"
671 517
672 class ExactlyInt(ValueType):
673 def __init__(self):
674 TypeModel.ValueType.__init__(self, "int", False)
675
676 def get_input_param_type_text(self):
677 return "TypeBuilder::ExactlyInt"
678
679 def get_opt_output_type_(self):
680 return "TypeBuilder::ExactlyInt"
681
682 @classmethod 518 @classmethod
683 def init_class(cls): 519 def init_class(cls):
684 cls.Bool = cls.ValueType("bool", False) 520 cls.Bool = cls.ValueType("bool", False)
685 if EXACTLY_INT_SUPPORTED: 521 cls.Int = cls.ValueType("int", False)
686 cls.Int = cls.ExactlyInt()
687 else:
688 cls.Int = cls.ValueType("int", False)
689 cls.Number = cls.ValueType("double", False) 522 cls.Number = cls.ValueType("double", False)
690 cls.String = cls.ValueType("String", True,) 523 cls.String = cls.ValueType("String", True,)
691 cls.Object = cls.RefPtrBased("JSONObject") 524 cls.Object = cls.RefPtrBased("JSONObject")
692 cls.Array = cls.RefPtrBased("JSONArray") 525 cls.Array = cls.RefPtrBased("JSONArray")
693 cls.Any = cls.RefPtrBased("JSONValue") 526 cls.Any = cls.RefPtrBased("JSONValue")
694 527
695 TypeModel.init_class() 528 TypeModel.init_class()
696 529
697 530
698 # Collection of JSONObject class methods that are likely to be overloaded in gen erated class. 531 # Collection of JSONObject class methods that are likely to be overloaded in gen erated class.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 parts = str.split('\n') 580 parts = str.split('\n')
748 self.append(parts[0]) 581 self.append(parts[0])
749 for p in parts[1:]: 582 for p in parts[1:]:
750 self.output.append('\n') 583 self.output.append('\n')
751 if p: 584 if p:
752 self.newline(p) 585 self.newline(p)
753 586
754 def get_indent(self): 587 def get_indent(self):
755 return self.indent 588 return self.indent
756 589
757 def get_indented(self, additional_indent):
758 return Writer(self.output, self.indent + additional_indent)
759
760 def insert_writer(self, additional_indent): 590 def insert_writer(self, additional_indent):
761 new_output = [] 591 new_output = []
762 self.output.append(new_output) 592 self.output.append(new_output)
763 return Writer(new_output, self.indent + additional_indent) 593 return Writer(new_output, self.indent + additional_indent)
764 594
765 595
766 class EnumConstants: 596 class EnumConstants:
767 map_ = {} 597 map_ = {}
768 constants_ = [] 598 constants_ = []
769 599
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 if request: 682 if request:
853 cls.need_user_runtime_cast_ = True 683 cls.need_user_runtime_cast_ = True
854 request.acknowledge() 684 request.acknowledge()
855 685
856 @classmethod 686 @classmethod
857 def request_internal_runtime_cast(cls): 687 def request_internal_runtime_cast(cls):
858 cls.need_internal_runtime_cast_ = True 688 cls.need_internal_runtime_cast_ = True
859 689
860 @classmethod 690 @classmethod
861 def get_code_generator(enum_binding_cls): 691 def get_code_generator(enum_binding_cls):
862 #FIXME: generate ad-hoc enums too once we figure out how to better implement them in C++.
863 comment_out = helper.is_ad_hoc
864 692
865 class CodeGenerator: 693 class CodeGenerator:
866 @staticmethod 694 @staticmethod
867 def generate_type_builder(writer, generate_context): 695 def generate_type_builder(writer, generate_context):
868 enum = json_typable["enum"] 696 enum = json_typable["enum"]
869 helper.write_doc(writer) 697 helper.write_doc(writer)
870 enum_name = fixed_type_name.class_name 698 enum_name = fixed_type_name.class_name
871 fixed_type_name.output_comment(writer) 699 fixed_type_name.output_comment(writer)
872 writer.newline("struct ") 700 writer.newline("struct ")
873 writer.append(enum_name) 701 writer.append(enum_name)
(...skipping 15 matching lines...) Expand all
889 if enum_binding_cls.need_user_runtime_cast_: 717 if enum_binding_cls.need_user_runtime_cast_:
890 raise Exception("Not yet implemented") 718 raise Exception("Not yet implemented")
891 719
892 if enum_binding_cls.need_internal_runtime_cast_: 720 if enum_binding_cls.need_internal_runtime_cast_:
893 writer.append("#if %s\n" % VALIDATOR_IFDEF_N AME) 721 writer.append("#if %s\n" % VALIDATOR_IFDEF_N AME)
894 writer.newline(" static void assertCorrec tValue(JSONValue* value);\n") 722 writer.newline(" static void assertCorrec tValue(JSONValue* value);\n")
895 writer.append("#endif // %s\n" % VALIDATOR_ IFDEF_NAME) 723 writer.append("#endif // %s\n" % VALIDATOR_ IFDEF_NAME)
896 724
897 validator_writer = generate_context.validato r_writer 725 validator_writer = generate_context.validato r_writer
898 726
899 domain_fixes = DomainNameFixes.get_fixed_dat a(context_domain_name)
900
901 validator_writer.newline("void %s%s::assertC orrectValue(JSONValue* value)\n" % (helper.full_name_prefix_for_impl, enum_name) ) 727 validator_writer.newline("void %s%s::assertC orrectValue(JSONValue* value)\n" % (helper.full_name_prefix_for_impl, enum_name) )
902 validator_writer.newline("{\n") 728 validator_writer.newline("{\n")
903 validator_writer.newline(" WTF::String s; \n") 729 validator_writer.newline(" WTF::String s; \n")
904 validator_writer.newline(" bool cast_res = value->asString(&s);\n") 730 validator_writer.newline(" bool cast_res = value->asString(&s);\n")
905 validator_writer.newline(" ASSERT(cast_re s);\n") 731 validator_writer.newline(" ASSERT(cast_re s);\n")
906 if len(enum) > 0: 732 if len(enum) > 0:
907 condition_list = [] 733 condition_list = []
908 for enum_item in enum: 734 for enum_item in enum:
909 enum_pos = EnumConstants.add_constan t(enum_item) 735 enum_pos = EnumConstants.add_constan t(enum_item)
910 condition_list.append("s == \"%s\"" % enum_item) 736 condition_list.append("s == \"%s\"" % enum_item)
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 @classmethod 822 @classmethod
997 def resolve_inner(cls, resolve_context): 823 def resolve_inner(cls, resolve_context):
998 pass 824 pass
999 825
1000 @staticmethod 826 @staticmethod
1001 def request_user_runtime_cast(request): 827 def request_user_runtime_cast(request):
1002 raise Exception("Unsupported") 828 raise Exception("Unsupported")
1003 829
1004 @staticmethod 830 @staticmethod
1005 def request_internal_runtime_cast(): 831 def request_internal_runtime_cast():
1006 RawTypes.String.request_raw_internal_runtime_cast() 832 pass
1007 833
1008 @staticmethod 834 @staticmethod
1009 def get_code_generator(): 835 def get_code_generator():
1010 class CodeGenerator: 836 class CodeGenerator:
1011 @staticmethod 837 @staticmethod
1012 def generate_type_builder(writer, generate_conte xt): 838 def generate_type_builder(writer, generate_conte xt):
1013 helper.write_doc(writer) 839 helper.write_doc(writer)
1014 fixed_type_name.output_comment(writer) 840 fixed_type_name.output_comment(writer)
1015 writer.newline("typedef String ") 841 writer.newline("typedef String ")
1016 writer.append(fixed_type_name.class_name) 842 writer.append(fixed_type_name.class_name)
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 writer.append_multiline("\n * .set%s (...)" % Capitalizer.lower_camel_case_to_upper(prop_data.p["name"])) 1015 writer.append_multiline("\n * .set%s (...)" % Capitalizer.lower_camel_case_to_upper(prop_data.p["name"]))
1190 writer.append_multiline(";\n */\n") 1016 writer.append_multiline(";\n */\n")
1191 1017
1192 writer.newline_multiline(CodeGeneratorInspectorS trings.class_binding_builder_part_4) 1018 writer.newline_multiline(CodeGeneratorInspectorS trings.class_binding_builder_part_4)
1193 1019
1194 writer.newline(" typedef TypeBuilder::StructI temTraits ItemTraits;\n") 1020 writer.newline(" typedef TypeBuilder::StructI temTraits ItemTraits;\n")
1195 1021
1196 for prop_data in resolve_data.main_properties: 1022 for prop_data in resolve_data.main_properties:
1197 prop_name = prop_data.p["name"] 1023 prop_name = prop_data.p["name"]
1198 param_type_binding = prop_data.param_type_bi nding 1024 param_type_binding = prop_data.param_type_bi nding
1199 raw_type = param_type_binding.reduce_to_raw_ type()
1200 if isinstance(param_type_binding.get_type_mo del(), TypeModel.ValueType): 1025 if isinstance(param_type_binding.get_type_mo del(), TypeModel.ValueType):
1201 writer.append_multiline("\n void %s" % prop_name) 1026 writer.append_multiline("\n void %s" % prop_name)
1202 writer.append("(%s value)\n" % param_typ e_binding.get_type_model().get_command_return_pass_model().get_output_parameter_ type()) 1027 writer.append("(%s value)\n" % param_typ e_binding.get_type_model().get_command_return_pass_model().get_output_parameter_ type())
1203 writer.newline(" {\n") 1028 writer.newline(" {\n")
1204 writer.newline(" JSONObjectBase:: get%s(\"%s\", value);\n" 1029 writer.newline(" JSONObjectBase:: get%s(\"%s\", value);\n"
1205 % (param_type_binding.reduce_to_raw_ type().get_setter_name(), prop_data.p["name"])) 1030 % (param_type_binding.reduce_to_raw_ type().get_setter_name(), prop_data.p["name"]))
1206 writer.newline(" }\n") 1031 writer.newline(" }\n")
1207 1032
1208 for prop_data in resolve_data.optional_propertie s: 1033 for prop_data in resolve_data.optional_propertie s:
1209 prop_name = prop_data.p["name"] 1034 prop_name = prop_data.p["name"]
(...skipping 27 matching lines...) Expand all
1237 1062
1238 if class_binding_cls.need_internal_runtime_cast_ : 1063 if class_binding_cls.need_internal_runtime_cast_ :
1239 writer.append("#if %s\n" % VALIDATOR_IFDEF_N AME) 1064 writer.append("#if %s\n" % VALIDATOR_IFDEF_N AME)
1240 writer.newline(" static void assertCorrec tValue(JSONValue* value);\n") 1065 writer.newline(" static void assertCorrec tValue(JSONValue* value);\n")
1241 writer.append("#endif // %s\n" % VALIDATOR_ IFDEF_NAME) 1066 writer.append("#endif // %s\n" % VALIDATOR_ IFDEF_NAME)
1242 1067
1243 closed_field_set = (context_domain_name + ". " + class_name) not in TYPES_WITH_OPEN_FIELD_LIST_SET 1068 closed_field_set = (context_domain_name + ". " + class_name) not in TYPES_WITH_OPEN_FIELD_LIST_SET
1244 1069
1245 validator_writer = generate_context.validato r_writer 1070 validator_writer = generate_context.validato r_writer
1246 1071
1247 domain_fixes = DomainNameFixes.get_fixed_dat a(context_domain_name)
1248
1249 validator_writer.newline("void %s%s::assertC orrectValue(JSONValue* value)\n" % (helper.full_name_prefix_for_impl, class_name )) 1072 validator_writer.newline("void %s%s::assertC orrectValue(JSONValue* value)\n" % (helper.full_name_prefix_for_impl, class_name ))
1250 validator_writer.newline("{\n") 1073 validator_writer.newline("{\n")
1251 validator_writer.newline(" RefPtr<JSONObj ect> object;\n") 1074 validator_writer.newline(" RefPtr<JSONObj ect> object;\n")
1252 validator_writer.newline(" bool castRes = value->asObject(&object);\n") 1075 validator_writer.newline(" bool castRes = value->asObject(&object);\n")
1253 validator_writer.newline(" ASSERT_UNUSED( castRes, castRes);\n") 1076 validator_writer.newline(" ASSERT_UNUSED( castRes, castRes);\n")
1254 for prop_data in resolve_data.main_propertie s: 1077 for prop_data in resolve_data.main_propertie s:
1255 validator_writer.newline(" {\n") 1078 validator_writer.newline(" {\n")
1256 it_name = "%sPos" % prop_data.p["name"] 1079 it_name = "%sPos" % prop_data.p["name"]
1257 validator_writer.newline(" JSONOb ject::iterator %s;\n" % it_name) 1080 validator_writer.newline(" JSONOb ject::iterator %s;\n" % it_name)
1258 validator_writer.newline(" %s = o bject->find(\"%s\");\n" % (it_name, prop_data.p["name"])) 1081 validator_writer.newline(" %s = o bject->find(\"%s\");\n" % (it_name, prop_data.p["name"]))
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 @classmethod 1185 @classmethod
1363 def resolve_inner(cls, resolve_context): 1186 def resolve_inner(cls, resolve_context):
1364 pass 1187 pass
1365 1188
1366 @staticmethod 1189 @staticmethod
1367 def request_user_runtime_cast(request): 1190 def request_user_runtime_cast(request):
1368 pass 1191 pass
1369 1192
1370 @staticmethod 1193 @staticmethod
1371 def request_internal_runtime_cast(): 1194 def request_internal_runtime_cast():
1372 RawTypes.Object.request_raw_internal_runtime_cast() 1195 pass
1373 1196
1374 @staticmethod 1197 @staticmethod
1375 def get_code_generator(): 1198 def get_code_generator():
1376 pass 1199 pass
1377 1200
1378 @staticmethod 1201 @staticmethod
1379 def get_validator_call_text(): 1202 def get_validator_call_text():
1380 return "RuntimeCastHelper::assertType<JSONValue::TypeObj ect>" 1203 return "RuntimeCastHelper::assertType<JSONValue::TypeObj ect>"
1381 1204
1382 @classmethod 1205 @classmethod
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 def __init__(self, raw_type): 1332 def __init__(self, raw_type):
1510 self.raw_type_ = raw_type 1333 self.raw_type_ = raw_type
1511 1334
1512 def resolve_inner(self, resolve_context): 1335 def resolve_inner(self, resolve_context):
1513 pass 1336 pass
1514 1337
1515 def request_user_runtime_cast(self, request): 1338 def request_user_runtime_cast(self, request):
1516 raise Exception("Unsupported") 1339 raise Exception("Unsupported")
1517 1340
1518 def request_internal_runtime_cast(self): 1341 def request_internal_runtime_cast(self):
1519 self.raw_type_.request_raw_internal_runtime_cast() 1342 pass
1520 1343
1521 def get_code_generator(self): 1344 def get_code_generator(self):
1522 return None 1345 return None
1523 1346
1524 def get_validator_call_text(self): 1347 def get_validator_call_text(self):
1525 return self.raw_type_.get_raw_validator_call_text() 1348 return self.raw_type_.get_raw_validator_call_text()
1526 1349
1527 def get_array_item_c_type_text(self): 1350 def get_array_item_c_type_text(self):
1528 return self.raw_type_.get_array_item_raw_c_type_text() 1351 return self.raw_type_.get_array_item_raw_c_type_text()
1529 1352
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 type_builder_fragments = [] 1619 type_builder_fragments = []
1797 type_builder_forwards = [] 1620 type_builder_forwards = []
1798 validator_impl_list = [] 1621 validator_impl_list = []
1799 type_builder_impl_list = [] 1622 type_builder_impl_list = []
1800 1623
1801 1624
1802 @staticmethod 1625 @staticmethod
1803 def go(): 1626 def go():
1804 Generator.process_types(type_map) 1627 Generator.process_types(type_map)
1805 1628
1806 first_cycle_guardable_list_list = [
1807 Generator.backend_method_declaration_list,
1808 Generator.backend_method_implementation_list,
1809 Generator.backend_method_name_declaration_list,
1810 Generator.backend_method_name_declaration_index_list,
1811 Generator.backend_agent_interface_list,
1812 Generator.frontend_class_field_lines,
1813 Generator.frontend_constructor_init_list,
1814 Generator.frontend_domain_class_lines,
1815 Generator.frontend_method_list,
1816 Generator.method_handler_list,
1817 Generator.method_name_enum_list,
1818 Generator.backend_constructor_init_list,
1819 Generator.backend_virtual_setters_list,
1820 Generator.backend_setters_list,
1821 Generator.backend_field_list]
1822
1823 for json_domain in json_api["domains"]: 1629 for json_domain in json_api["domains"]:
1824 domain_name = json_domain["domain"] 1630 domain_name = json_domain["domain"]
1825 domain_name_lower = domain_name.lower() 1631 domain_name_lower = domain_name.lower()
1826 1632
1827 domain_fixes = DomainNameFixes.get_fixed_data(domain_name) 1633 agent_field_name = DomainNameFixes.get_fixed_data(domain_name)
1828
1829 agent_field_name = domain_fixes.agent_field_name
1830 1634
1831 frontend_method_declaration_lines = [] 1635 frontend_method_declaration_lines = []
1832 1636
1833 if "events" in json_domain: 1637 if "events" in json_domain:
1834 for json_event in json_domain["events"]: 1638 for json_event in json_domain["events"]:
1835 Generator.process_event(json_event, domain_name, frontend_me thod_declaration_lines) 1639 Generator.process_event(json_event, domain_name, frontend_me thod_declaration_lines)
1836 1640
1837 Generator.frontend_class_field_lines.append(" %s m_%s;\n" % (doma in_name, domain_name_lower)) 1641 Generator.frontend_class_field_lines.append(" %s m_%s;\n" % (doma in_name, domain_name_lower))
1838 if Generator.frontend_constructor_init_list: 1642 if Generator.frontend_constructor_init_list:
1839 Generator.frontend_constructor_init_list.append(" , ") 1643 Generator.frontend_constructor_init_list.append(" , ")
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1907 backend_agent_interface_list = [] if "redirect" in json_command else Gen erator.backend_agent_interface_list 1711 backend_agent_interface_list = [] if "redirect" in json_command else Gen erator.backend_agent_interface_list
1908 1712
1909 ad_hoc_type_output = [] 1713 ad_hoc_type_output = []
1910 backend_agent_interface_list.append(ad_hoc_type_output) 1714 backend_agent_interface_list.append(ad_hoc_type_output)
1911 ad_hoc_type_writer = Writer(ad_hoc_type_output, " ") 1715 ad_hoc_type_writer = Writer(ad_hoc_type_output, " ")
1912 1716
1913 backend_agent_interface_list.append(" virtual void %s(ErrorString *" % json_command_name) 1717 backend_agent_interface_list.append(" virtual void %s(ErrorString *" % json_command_name)
1914 1718
1915 method_in_code = "" 1719 method_in_code = ""
1916 method_out_code = "" 1720 method_out_code = ""
1917 result_object_declaration = ""
1918 agent_call_param_list = ["&error"] 1721 agent_call_param_list = ["&error"]
1919 agent_call_params_declaration_list = [" ErrorString error;"] 1722 agent_call_params_declaration_list = [" ErrorString error;"]
1920 send_response_call_params_list = ["error"] 1723 send_response_call_params_list = ["error"]
1921 request_message_param = "" 1724 request_message_param = ""
1922 normal_response_cook_text = "" 1725 normal_response_cook_text = ""
1923 error_type_binding = None 1726 error_type_binding = None
1924 if "error" in json_command: 1727 if "error" in json_command:
1925 json_error = json_command["error"] 1728 json_error = json_command["error"]
1926 error_type_binding = Generator.resolve_type_and_generate_ad_hoc(json _error, json_command_name + "Error", json_command_name, domain_name, ad_hoc_type _writer, agent_interface_name + "::") 1729 error_type_binding = Generator.resolve_type_and_generate_ad_hoc(json _error, json_command_name + "Error", json_command_name, domain_name, ad_hoc_type _writer, agent_interface_name + "::")
1927 error_type_model = error_type_binding.get_type_model().get_optional( ) 1730 error_type_model = error_type_binding.get_type_model().get_optional( )
(...skipping 12 matching lines...) Expand all
1940 1743
1941 for json_parameter in json_params: 1744 for json_parameter in json_params:
1942 json_param_name = json_parameter["name"] 1745 json_param_name = json_parameter["name"]
1943 param_raw_type = resolve_param_raw_type(json_parameter, domain_n ame) 1746 param_raw_type = resolve_param_raw_type(json_parameter, domain_n ame)
1944 1747
1945 getter_name = param_raw_type.get_getter_name() 1748 getter_name = param_raw_type.get_getter_name()
1946 1749
1947 optional = json_parameter.get("optional") 1750 optional = json_parameter.get("optional")
1948 1751
1949 non_optional_type_model = param_raw_type.get_raw_type_model() 1752 non_optional_type_model = param_raw_type.get_raw_type_model()
1950 if optional:
1951 type_model = non_optional_type_model.get_optional()
1952 else:
1953 type_model = non_optional_type_model
1954 1753
1955 if optional: 1754 if optional:
1956 code = (" bool %s_valueFound = false;\n" 1755 code = (" bool %s_valueFound = false;\n"
1957 " %s in_%s = get%s(paramsContainerPtr, \"%s\", &% s_valueFound, protocolErrors);\n" % 1756 " %s in_%s = get%s(paramsContainerPtr, \"%s\", &% s_valueFound, protocolErrors);\n" %
1958 (json_param_name, non_optional_type_model.get_command _return_pass_model().get_return_var_type(), json_param_name, getter_name, json_p aram_name, json_param_name)) 1757 (json_param_name, non_optional_type_model.get_command _return_pass_model().get_return_var_type(), json_param_name, getter_name, json_p aram_name, json_param_name))
1959 param = "%s_valueFound ? &in_%s : 0" % (json_param_name, jso n_param_name) 1758 param = "%s_valueFound ? &in_%s : 0" % (json_param_name, jso n_param_name)
1960 # FIXME: pass optional refptr-values as PassRefPtr 1759 # FIXME: pass optional refptr-values as PassRefPtr
1961 formal_param_type_pattern = "const %s*" 1760 formal_param_type_pattern = "const %s*"
1962 else: 1761 else:
1963 code = (" %s in_%s = get%s(paramsContainerPtr, \"%s\", 0, protocolErrors);\n" % 1762 code = (" %s in_%s = get%s(paramsContainerPtr, \"%s\", 0, protocolErrors);\n" %
(...skipping 17 matching lines...) Expand all
1981 1780
1982 decl_parameter_list = [] 1781 decl_parameter_list = []
1983 Generator.generate_send_method(json_command.get("returns"), json_com mand_name, domain_name, ad_hoc_type_writer, 1782 Generator.generate_send_method(json_command.get("returns"), json_com mand_name, domain_name, ad_hoc_type_writer,
1984 decl_parameter_list, 1783 decl_parameter_list,
1985 Generator.CallbackMethodStructTemplat e, 1784 Generator.CallbackMethodStructTemplat e,
1986 Generator.backend_method_implementati on_list, Templates.callback_main_methods, 1785 Generator.backend_method_implementati on_list, Templates.callback_main_methods,
1987 {"callbackName": callback_name, "agen tName": agent_interface_name}) 1786 {"callbackName": callback_name, "agen tName": agent_interface_name})
1988 1787
1989 callback_writer.newline("class " + callback_name + " : public Callba ckBase {\n") 1788 callback_writer.newline("class " + callback_name + " : public Callba ckBase {\n")
1990 callback_writer.newline("public:\n") 1789 callback_writer.newline("public:\n")
1991 callback_writer.newline(" " + callback_name + "(PassRefPtr<Inspec torBackendDispatcherImpl>, int id);\n") 1790 callback_writer.newline(" " + callback_name + "(PassRefPtrWillBeR awPtr<InspectorBackendDispatcherImpl>, int id);\n")
1992 callback_writer.newline(" void sendSuccess(" + ", ".join(decl_par ameter_list) + ");\n") 1791 callback_writer.newline(" void sendSuccess(" + ", ".join(decl_par ameter_list) + ");\n")
1993 error_part_writer = callback_writer.insert_writer("") 1792 error_part_writer = callback_writer.insert_writer("")
1994 callback_writer.newline("};\n") 1793 callback_writer.newline("};\n")
1995 1794
1996 if error_type_binding: 1795 if error_type_binding:
1997 annotated_type = error_type_model.get_input_param_type_text() 1796 annotated_type = error_type_model.get_input_param_type_text()
1998 error_part_writer.newline(" void sendFailure(const ErrorStrin g&, %s);\n" % annotated_type) 1797 error_part_writer.newline(" void sendFailure(const ErrorStrin g&, %s);\n" % annotated_type)
1999 error_part_writer.newline(" using CallbackBase::sendFailure;\ n") 1798 error_part_writer.newline(" using CallbackBase::sendFailure;\ n")
2000 1799
2001 assigment_value = error_type_model.get_event_setter_expression_p attern() % "errorData" 1800 assigment_value = error_type_model.get_event_setter_expression_p attern() % "errorData"
2002 assigment_value = error_type_binding.reduce_to_raw_type().get_co nstructor_pattern() % assigment_value 1801 assigment_value = error_type_binding.reduce_to_raw_type().get_co nstructor_pattern() % assigment_value
2003 1802
2004 Generator.backend_method_implementation_list.append(Templates.ca llback_failure_method.substitute(None, 1803 Generator.backend_method_implementation_list.append(Templates.ca llback_failure_method.substitute(None,
2005 agentName=agent_interface_name, 1804 agentName=agent_interface_name,
2006 callbackName=callback_name, 1805 callbackName=callback_name,
2007 parameter=annotated_type + " errorData", 1806 parameter=annotated_type + " errorData",
2008 argument=assigment_value)) 1807 argument=assigment_value))
2009 1808
2010 ad_hoc_type_output.append(callback_output) 1809 ad_hoc_type_output.append(callback_output)
2011 1810
2012 method_out_code += " RefPtr<" + agent_interface_name + "::" + cal lback_name + "> callback = adoptRef(new " + agent_interface_name + "::" + callba ck_name + "(this, callId));\n" 1811 method_out_code += " RefPtrWillBeRawPtr<" + agent_interface_name + "::" + callback_name + "> callback = adoptRefWillBeNoop(new " + agent_interfac e_name + "::" + callback_name + "(this, callId));\n"
2013 agent_call_param_list.append("callback") 1812 agent_call_param_list.append("callback")
2014 normal_response_cook_text += " if (!error.length()) \n" 1813 normal_response_cook_text += " if (!error.length()) \n"
2015 normal_response_cook_text += " return;\n" 1814 normal_response_cook_text += " return;\n"
2016 normal_response_cook_text += " callback->disable();\n" 1815 normal_response_cook_text += " callback->disable();\n"
2017 backend_agent_interface_list.append(", PassRefPtr<%s> callback" % ca llback_name) 1816 backend_agent_interface_list.append(", PassRefPtrWillBeRawPtr<%s> ca llback" % callback_name)
2018 else: 1817 else:
2019 if "returns" in json_command: 1818 if "returns" in json_command:
2020 method_out_code += "\n" 1819 method_out_code += "\n"
2021 agent_call_params_declaration_list.append(" RefPtr<JSONObject > result = JSONObject::create();") 1820 agent_call_params_declaration_list.append(" RefPtr<JSONObject > result = JSONObject::create();")
2022 send_response_call_params_list.append("result") 1821 send_response_call_params_list.append("result")
2023 response_cook_list = [] 1822 response_cook_list = []
2024 for json_return in json_command["returns"]: 1823 for json_return in json_command["returns"]:
2025 1824
2026 json_return_name = json_return["name"] 1825 json_return_name = json_return["name"]
2027 1826
2028 optional = bool(json_return.get("optional")) 1827 optional = bool(json_return.get("optional"))
2029 1828
2030 return_type_binding = Generator.resolve_param_type_and_gener ate_ad_hoc(json_return, json_command_name, domain_name, ad_hoc_type_writer, agen t_interface_name + "::") 1829 return_type_binding = Generator.resolve_param_type_and_gener ate_ad_hoc(json_return, json_command_name, domain_name, ad_hoc_type_writer, agen t_interface_name + "::")
2031 1830
2032 raw_type = return_type_binding.reduce_to_raw_type() 1831 raw_type = return_type_binding.reduce_to_raw_type()
2033 setter_type = raw_type.get_setter_name() 1832 setter_type = raw_type.get_setter_name()
2034 initializer = raw_type.get_c_initializer()
2035 1833
2036 type_model = return_type_binding.get_type_model() 1834 type_model = return_type_binding.get_type_model()
2037 if optional: 1835 if optional:
2038 type_model = type_model.get_optional() 1836 type_model = type_model.get_optional()
2039 1837
2040 code = " %s out_%s;\n" % (type_model.get_command_return_p ass_model().get_return_var_type(), json_return_name) 1838 code = " %s out_%s;\n" % (type_model.get_command_return_p ass_model().get_return_var_type(), json_return_name)
2041 param = "%sout_%s" % (type_model.get_command_return_pass_mod el().get_output_argument_prefix(), json_return_name) 1839 param = "%sout_%s" % (type_model.get_command_return_pass_mod el().get_output_argument_prefix(), json_return_name)
2042 var_name = "out_%s" % json_return_name 1840 var_name = "out_%s" % json_return_name
2043 setter_argument = type_model.get_command_return_pass_model() .get_output_to_raw_expression() % var_name 1841 setter_argument = type_model.get_command_return_pass_model() .get_output_to_raw_expression() % var_name
2044 if return_type_binding.get_setter_value_expression_pattern() : 1842 if return_type_binding.get_setter_value_expression_pattern() :
(...skipping 18 matching lines...) Expand all
2063 agent_call_param_list.append(param) 1861 agent_call_param_list.append(param)
2064 1862
2065 normal_response_cook_text += "".join(response_cook_list) 1863 normal_response_cook_text += "".join(response_cook_list)
2066 1864
2067 if len(normal_response_cook_text) != 0: 1865 if len(normal_response_cook_text) != 0:
2068 normal_response_cook_text = " if (!error.length()) {\n" + normal_response_cook_text + " }" 1866 normal_response_cook_text = " if (!error.length()) {\n" + normal_response_cook_text + " }"
2069 1867
2070 # Redirect to another agent's implementation. 1868 # Redirect to another agent's implementation.
2071 agent_field = "m_" + agent_field_name 1869 agent_field = "m_" + agent_field_name
2072 if "redirect" in json_command: 1870 if "redirect" in json_command:
2073 domain_fixes = DomainNameFixes.get_fixed_data(json_command.get("redi rect")) 1871 agent_field = "m_" + DomainNameFixes.get_fixed_data(json_command.get ("redirect"))
2074 agent_field = "m_" + domain_fixes.agent_field_name
2075 1872
2076 Generator.backend_method_implementation_list.append(Templates.backend_me thod.substitute(None, 1873 Generator.backend_method_implementation_list.append(Templates.backend_me thod.substitute(None,
2077 domainName=domain_name, methodName=json_command_name, 1874 domainName=domain_name, methodName=json_command_name,
2078 agentField=agent_field, 1875 agentField=agent_field,
2079 methodCode="".join([method_in_code, method_out_code]), 1876 methodCode="".join([method_in_code, method_out_code]),
2080 agentCallParamsDeclaration="\n".join(agent_call_params_declaration_l ist), 1877 agentCallParamsDeclaration="\n".join(agent_call_params_declaration_l ist),
2081 agentCallParams=", ".join(agent_call_param_list), 1878 agentCallParams=", ".join(agent_call_param_list),
2082 requestMessageObject=request_message_param, 1879 requestMessageObject=request_message_param,
2083 responseCook=normal_response_cook_text, 1880 responseCook=normal_response_cook_text,
2084 sendResponseCallParams=", ".join(send_response_call_params_list), 1881 sendResponseCallParams=", ".join(send_response_call_params_list),
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2204 def process_types(type_map): 2001 def process_types(type_map):
2205 output = Generator.type_builder_fragments 2002 output = Generator.type_builder_fragments
2206 2003
2207 class GenerateContext: 2004 class GenerateContext:
2208 validator_writer = Writer(Generator.validator_impl_list, "") 2005 validator_writer = Writer(Generator.validator_impl_list, "")
2209 cpp_writer = Writer(Generator.type_builder_impl_list, "") 2006 cpp_writer = Writer(Generator.type_builder_impl_list, "")
2210 2007
2211 def generate_all_domains_code(out, type_data_callback): 2008 def generate_all_domains_code(out, type_data_callback):
2212 writer = Writer(out, "") 2009 writer = Writer(out, "")
2213 for domain_data in type_map.domains(): 2010 for domain_data in type_map.domains():
2214 domain_fixes = DomainNameFixes.get_fixed_data(domain_data.name() )
2215
2216 namespace_declared = [] 2011 namespace_declared = []
2217 2012
2218 def namespace_lazy_generator(): 2013 def namespace_lazy_generator():
2219 if not namespace_declared: 2014 if not namespace_declared:
2220 writer.newline("namespace ") 2015 writer.newline("namespace ")
2221 writer.append(domain_data.name()) 2016 writer.append(domain_data.name())
2222 writer.append(" {\n") 2017 writer.append(" {\n")
2223 # What is a better way to change value from outer scope? 2018 # What is a better way to change value from outer scope?
2224 namespace_declared.append(True) 2019 namespace_declared.append(True)
2225 return writer 2020 return writer
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2265 2060
2266 def fill_recursive(l): 2061 def fill_recursive(l):
2267 for item in l: 2062 for item in l:
2268 if isinstance(item, list): 2063 if isinstance(item, list):
2269 fill_recursive(item) 2064 fill_recursive(item)
2270 else: 2065 else:
2271 res.append(item) 2066 res.append(item)
2272 fill_recursive(input) 2067 fill_recursive(input)
2273 return res 2068 return res
2274 2069
2275
2276 # A writer that only updates file if it actually changed to better support incre mental build.
2277 class SmartOutput:
2278 def __init__(self, file_name):
2279 self.file_name_ = file_name
2280 self.output_ = ""
2281
2282 def write(self, text):
2283 self.output_ += text
2284
2285 def close(self):
2286 text_changed = True
2287
2288 try:
2289 read_file = open(self.file_name_, "r")
2290 old_text = read_file.read()
2291 read_file.close()
2292 text_changed = old_text != self.output_
2293 except:
2294 # Ignore, just overwrite by default
2295 pass
2296
2297 if text_changed:
2298 out_file = open(self.file_name_, "w")
2299 out_file.write(self.output_)
2300 out_file.close()
2301
2302
2303 def output_file(file_name): 2070 def output_file(file_name):
2304 # For now, disable the incremental build optimisation in all cases. 2071 return open(file_name, "w")
2305 if False:
2306 return SmartOutput(file_name)
2307 else:
2308 return open(file_name, "w")
2309 2072
2310 2073
2311 Generator.go() 2074 Generator.go()
2312 2075
2313 backend_h_file = output_file(output_dirname + "/InspectorBackendDispatcher.h") 2076 backend_h_file = output_file(output_dirname + "/InspectorBackendDispatcher.h")
2314 backend_cpp_file = output_file(output_dirname + "/InspectorBackendDispatcher.cpp ") 2077 backend_cpp_file = output_file(output_dirname + "/InspectorBackendDispatcher.cpp ")
2315 2078
2316 frontend_h_file = output_file(output_dirname + "/InspectorFrontend.h") 2079 frontend_h_file = output_file(output_dirname + "/InspectorFrontend.h")
2317 frontend_cpp_file = output_file(output_dirname + "/InspectorFrontend.cpp") 2080 frontend_cpp_file = output_file(output_dirname + "/InspectorFrontend.cpp")
2318 2081
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2355 validatorIfdefName=VALIDATOR_IFDEF_NAME)) 2118 validatorIfdefName=VALIDATOR_IFDEF_NAME))
2356 2119
2357 backend_h_file.close() 2120 backend_h_file.close()
2358 backend_cpp_file.close() 2121 backend_cpp_file.close()
2359 2122
2360 frontend_h_file.close() 2123 frontend_h_file.close()
2361 frontend_cpp_file.close() 2124 frontend_cpp_file.close()
2362 2125
2363 typebuilder_h_file.close() 2126 typebuilder_h_file.close()
2364 typebuilder_cpp_file.close() 2127 typebuilder_cpp_file.close()
OLDNEW
« no previous file with comments | « core/html/shadow/PluginPlaceholderElement.idl ('k') | core/inspector/CodeGeneratorInspectorStrings.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698