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

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

Issue 19605006: Roll IDL to multivm@1316 (Closed) Base URL: https://dart.googlecode.com/svn/third_party/WebCore
Patch Set: Created 7 years, 5 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
« no previous file with comments | « core/html/track/TextTrackRegion.idl ('k') | core/inspector/CodeGeneratorInspectorStrings.py » ('j') | 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 (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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 class BaseType(object): 219 class BaseType(object):
220 need_internal_runtime_cast_ = False 220 need_internal_runtime_cast_ = False
221 221
222 @classmethod 222 @classmethod
223 def request_raw_internal_runtime_cast(cls): 223 def request_raw_internal_runtime_cast(cls):
224 if not cls.need_internal_runtime_cast_: 224 if not cls.need_internal_runtime_cast_:
225 cls.need_internal_runtime_cast_ = True 225 cls.need_internal_runtime_cast_ = True
226 226
227 @classmethod 227 @classmethod
228 def get_raw_validator_call_text(cls): 228 def get_raw_validator_call_text(cls):
229 return "RuntimeCastHelper::assertType<InspectorValue::Type%s>" % cls .get_validate_method_params().template_type 229 return "RuntimeCastHelper::assertType<JSONValue::Type%s>" % cls.get_ validate_method_params().template_type
230
231 @staticmethod
232 def get_validate_method_params():
233 raise Exception("Abstract method")
230 234
231 class String(BaseType): 235 class String(BaseType):
232 @staticmethod 236 @staticmethod
233 def get_getter_name(): 237 def get_getter_name():
234 return "String" 238 return "String"
235 239
236 get_setter_name = get_getter_name 240 get_setter_name = get_getter_name
237 241
238 @staticmethod 242 @staticmethod
243 def get_constructor_pattern():
244 return "InspectorString::create(%s)"
245
246 @staticmethod
239 def get_c_initializer(): 247 def get_c_initializer():
240 return "\"\"" 248 return "\"\""
241 249
242 @staticmethod 250 @staticmethod
243 def get_validate_method_params(): 251 def get_validate_method_params():
244 class ValidateMethodParams: 252 class ValidateMethodParams:
245 template_type = "String" 253 template_type = "String"
246 return ValidateMethodParams 254 return ValidateMethodParams
247 255
248 @staticmethod 256 @staticmethod
(...skipping 15 matching lines...) Expand all
264 class Int(BaseType): 272 class Int(BaseType):
265 @staticmethod 273 @staticmethod
266 def get_getter_name(): 274 def get_getter_name():
267 return "Int" 275 return "Int"
268 276
269 @staticmethod 277 @staticmethod
270 def get_setter_name(): 278 def get_setter_name():
271 return "Number" 279 return "Number"
272 280
273 @staticmethod 281 @staticmethod
282 def get_constructor_pattern():
283 return "InspectorBasicValue::create(%s)"
284
285 @staticmethod
274 def get_c_initializer(): 286 def get_c_initializer():
275 return "0" 287 return "0"
276 288
277 @classmethod 289 @classmethod
278 def get_raw_validator_call_text(cls): 290 def get_raw_validator_call_text(cls):
279 return "RuntimeCastHelper::assertInt" 291 return "RuntimeCastHelper::assertInt"
280 292
281 @staticmethod 293 @staticmethod
282 def get_output_pass_model(): 294 def get_output_pass_model():
283 return RawTypes.OutputPassModel.ByPointer 295 return RawTypes.OutputPassModel.ByPointer
(...skipping 13 matching lines...) Expand all
297 class Number(BaseType): 309 class Number(BaseType):
298 @staticmethod 310 @staticmethod
299 def get_getter_name(): 311 def get_getter_name():
300 return "Double" 312 return "Double"
301 313
302 @staticmethod 314 @staticmethod
303 def get_setter_name(): 315 def get_setter_name():
304 return "Number" 316 return "Number"
305 317
306 @staticmethod 318 @staticmethod
319 def get_constructor_pattern():
320 return "InspectorBasicValue::create(%s)"
321
322 @staticmethod
307 def get_c_initializer(): 323 def get_c_initializer():
308 return "0" 324 return "0"
309 325
310 @staticmethod 326 @staticmethod
311 def get_validate_method_params(): 327 def get_validate_method_params():
312 class ValidateMethodParams: 328 class ValidateMethodParams:
313 template_type = "Number" 329 template_type = "Number"
314 return ValidateMethodParams 330 return ValidateMethodParams
315 331
316 @staticmethod 332 @staticmethod
(...skipping 13 matching lines...) Expand all
330 return TypeModel.Number 346 return TypeModel.Number
331 347
332 class Bool(BaseType): 348 class Bool(BaseType):
333 @staticmethod 349 @staticmethod
334 def get_getter_name(): 350 def get_getter_name():
335 return "Boolean" 351 return "Boolean"
336 352
337 get_setter_name = get_getter_name 353 get_setter_name = get_getter_name
338 354
339 @staticmethod 355 @staticmethod
356 def get_constructor_pattern():
357 return "InspectorBasicValue::create(%s)"
358
359 @staticmethod
340 def get_c_initializer(): 360 def get_c_initializer():
341 return "false" 361 return "false"
342 362
343 @staticmethod 363 @staticmethod
344 def get_validate_method_params(): 364 def get_validate_method_params():
345 class ValidateMethodParams: 365 class ValidateMethodParams:
346 template_type = "Boolean" 366 template_type = "Boolean"
347 return ValidateMethodParams 367 return ValidateMethodParams
348 368
349 @staticmethod 369 @staticmethod
(...skipping 15 matching lines...) Expand all
365 class Object(BaseType): 385 class Object(BaseType):
366 @staticmethod 386 @staticmethod
367 def get_getter_name(): 387 def get_getter_name():
368 return "Object" 388 return "Object"
369 389
370 @staticmethod 390 @staticmethod
371 def get_setter_name(): 391 def get_setter_name():
372 return "Value" 392 return "Value"
373 393
374 @staticmethod 394 @staticmethod
395 def get_constructor_pattern():
396 return "%s"
397
398 @staticmethod
375 def get_c_initializer(): 399 def get_c_initializer():
376 return "InspectorObject::create()" 400 return "JSONObject::create()"
377 401
378 @staticmethod 402 @staticmethod
379 def get_output_argument_prefix(): 403 def get_output_argument_prefix():
380 return "" 404 return ""
381 405
382 @staticmethod 406 @staticmethod
383 def get_validate_method_params(): 407 def get_validate_method_params():
384 class ValidateMethodParams: 408 class ValidateMethodParams:
385 template_type = "Object" 409 template_type = "Object"
386 return ValidateMethodParams 410 return ValidateMethodParams
387 411
388 @staticmethod 412 @staticmethod
389 def get_output_pass_model(): 413 def get_output_pass_model():
390 return RawTypes.OutputPassModel.ByReference 414 return RawTypes.OutputPassModel.ByReference
391 415
392 @staticmethod 416 @staticmethod
393 def is_heavy_value(): 417 def is_heavy_value():
394 return True 418 return True
395 419
396 @staticmethod 420 @staticmethod
397 def get_array_item_raw_c_type_text(): 421 def get_array_item_raw_c_type_text():
398 return "InspectorObject" 422 return "JSONObject"
399 423
400 @staticmethod 424 @staticmethod
401 def get_raw_type_model(): 425 def get_raw_type_model():
402 return TypeModel.Object 426 return TypeModel.Object
403 427
404 class Any(BaseType): 428 class Any(BaseType):
405 @staticmethod 429 @staticmethod
406 def get_getter_name(): 430 def get_getter_name():
407 return "Value" 431 return "Value"
408 432
409 get_setter_name = get_getter_name 433 get_setter_name = get_getter_name
410 434
411 @staticmethod 435 @staticmethod
412 def get_c_initializer(): 436 def get_c_initializer():
413 raise Exception("Unsupported") 437 raise Exception("Unsupported")
414 438
415 @staticmethod 439 @staticmethod
440 def get_constructor_pattern():
441 raise Exception("Unsupported")
442
443 @staticmethod
416 def get_raw_validator_call_text(): 444 def get_raw_validator_call_text():
417 return "RuntimeCastHelper::assertAny" 445 return "RuntimeCastHelper::assertAny"
418 446
419 @staticmethod 447 @staticmethod
420 def get_output_pass_model(): 448 def get_output_pass_model():
421 return RawTypes.OutputPassModel.ByReference 449 return RawTypes.OutputPassModel.ByReference
422 450
423 @staticmethod 451 @staticmethod
424 def is_heavy_value(): 452 def is_heavy_value():
425 return True 453 return True
426 454
427 @staticmethod 455 @staticmethod
428 def get_array_item_raw_c_type_text(): 456 def get_array_item_raw_c_type_text():
429 return "InspectorValue" 457 return "JSONValue"
430 458
431 @staticmethod 459 @staticmethod
432 def get_raw_type_model(): 460 def get_raw_type_model():
433 return TypeModel.Any 461 return TypeModel.Any
434 462
435 class Array(BaseType): 463 class Array(BaseType):
436 @staticmethod 464 @staticmethod
437 def get_getter_name(): 465 def get_getter_name():
438 return "Array" 466 return "Array"
439 467
440 @staticmethod 468 @staticmethod
441 def get_setter_name(): 469 def get_setter_name():
442 return "Value" 470 return "Value"
443 471
444 @staticmethod 472 @staticmethod
473 def get_constructor_pattern():
474 return "%s"
475
476 @staticmethod
445 def get_c_initializer(): 477 def get_c_initializer():
446 return "InspectorArray::create()" 478 return "JSONArray::create()"
447 479
448 @staticmethod 480 @staticmethod
449 def get_output_argument_prefix(): 481 def get_output_argument_prefix():
450 return "" 482 return ""
451 483
452 @staticmethod 484 @staticmethod
453 def get_validate_method_params(): 485 def get_validate_method_params():
454 class ValidateMethodParams: 486 class ValidateMethodParams:
455 template_type = "Array" 487 template_type = "Array"
456 return ValidateMethodParams 488 return ValidateMethodParams
457 489
458 @staticmethod 490 @staticmethod
459 def get_output_pass_model(): 491 def get_output_pass_model():
460 return RawTypes.OutputPassModel.ByReference 492 return RawTypes.OutputPassModel.ByReference
461 493
462 @staticmethod 494 @staticmethod
463 def is_heavy_value(): 495 def is_heavy_value():
464 return True 496 return True
465 497
466 @staticmethod 498 @staticmethod
467 def get_array_item_raw_c_type_text(): 499 def get_array_item_raw_c_type_text():
468 return "InspectorArray" 500 return "JSONArray"
469 501
470 @staticmethod 502 @staticmethod
471 def get_raw_type_model(): 503 def get_raw_type_model():
472 return TypeModel.Array 504 return TypeModel.Array
473 505
474 506
475 def replace_right_shift(input_str): 507 def replace_right_shift(input_str):
476 return input_str.replace(">>", "> >") 508 return input_str.replace(">>", "> >")
477 509
478 510
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 687
656 @classmethod 688 @classmethod
657 def init_class(cls): 689 def init_class(cls):
658 cls.Bool = cls.ValueType("bool", False) 690 cls.Bool = cls.ValueType("bool", False)
659 if EXACTLY_INT_SUPPORTED: 691 if EXACTLY_INT_SUPPORTED:
660 cls.Int = cls.ExactlyInt() 692 cls.Int = cls.ExactlyInt()
661 else: 693 else:
662 cls.Int = cls.ValueType("int", False) 694 cls.Int = cls.ValueType("int", False)
663 cls.Number = cls.ValueType("double", False) 695 cls.Number = cls.ValueType("double", False)
664 cls.String = cls.ValueType("String", True,) 696 cls.String = cls.ValueType("String", True,)
665 cls.Object = cls.RefPtrBased("InspectorObject") 697 cls.Object = cls.RefPtrBased("JSONObject")
666 cls.Array = cls.RefPtrBased("InspectorArray") 698 cls.Array = cls.RefPtrBased("JSONArray")
667 cls.Any = cls.RefPtrBased("InspectorValue") 699 cls.Any = cls.RefPtrBased("JSONValue")
668 700
669 TypeModel.init_class() 701 TypeModel.init_class()
670 702
671 703
672 # Collection of InspectorObject class methods that are likely to be overloaded i n generated class. 704 # Collection of JSONObject class methods that are likely to be overloaded in gen erated class.
673 # We must explicitly import all overloaded methods or they won't be available to user. 705 # We must explicitly import all overloaded methods or they won't be available to user.
674 INSPECTOR_OBJECT_SETTER_NAMES = frozenset(["setValue", "setBoolean", "setNumber" , "setString", "setValue", "setObject", "setArray"]) 706 INSPECTOR_OBJECT_SETTER_NAMES = frozenset(["setValue", "setBoolean", "setNumber" , "setString", "setValue", "setObject", "setArray"])
675 707
676 708
677 def fix_type_name(json_name): 709 def fix_type_name(json_name):
678 if json_name in TYPE_NAME_FIX_MAP: 710 if json_name in TYPE_NAME_FIX_MAP:
679 fixed = TYPE_NAME_FIX_MAP[json_name] 711 fixed = TYPE_NAME_FIX_MAP[json_name]
680 712
681 class Result(object): 713 class Result(object):
682 class_name = fixed 714 class_name = fixed
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 writer.append(item_c_name) 890 writer.append(item_c_name)
859 writer.append(" = ") 891 writer.append(" = ")
860 writer.append("%s" % enum_pos) 892 writer.append("%s" % enum_pos)
861 writer.append(",\n") 893 writer.append(",\n")
862 writer.newline(" };\n") 894 writer.newline(" };\n")
863 if enum_binding_cls.need_user_runtime_cast_: 895 if enum_binding_cls.need_user_runtime_cast_:
864 raise Exception("Not yet implemented") 896 raise Exception("Not yet implemented")
865 897
866 if enum_binding_cls.need_internal_runtime_cast_: 898 if enum_binding_cls.need_internal_runtime_cast_:
867 writer.append("#if %s\n" % VALIDATOR_IFDEF_N AME) 899 writer.append("#if %s\n" % VALIDATOR_IFDEF_N AME)
868 writer.newline(" static void assertCorrec tValue(InspectorValue* value);\n") 900 writer.newline(" static void assertCorrec tValue(JSONValue* value);\n")
869 writer.append("#endif // %s\n" % VALIDATOR_ IFDEF_NAME) 901 writer.append("#endif // %s\n" % VALIDATOR_ IFDEF_NAME)
870 902
871 validator_writer = generate_context.validato r_writer 903 validator_writer = generate_context.validato r_writer
872 904
873 domain_fixes = DomainNameFixes.get_fixed_dat a(context_domain_name) 905 domain_fixes = DomainNameFixes.get_fixed_dat a(context_domain_name)
874 906
875 validator_writer.newline("void %s%s::assertC orrectValue(InspectorValue* value)\n" % (helper.full_name_prefix_for_impl, enum_ name)) 907 validator_writer.newline("void %s%s::assertC orrectValue(JSONValue* value)\n" % (helper.full_name_prefix_for_impl, enum_name) )
876 validator_writer.newline("{\n") 908 validator_writer.newline("{\n")
877 validator_writer.newline(" WTF::String s; \n") 909 validator_writer.newline(" WTF::String s; \n")
878 validator_writer.newline(" bool cast_res = value->asString(&s);\n") 910 validator_writer.newline(" bool cast_res = value->asString(&s);\n")
879 validator_writer.newline(" ASSERT(cast_re s);\n") 911 validator_writer.newline(" ASSERT(cast_re s);\n")
880 if len(enum) > 0: 912 if len(enum) > 0:
881 condition_list = [] 913 condition_list = []
882 for enum_item in enum: 914 for enum_item in enum:
883 enum_pos = EnumConstants.add_constan t(enum_item) 915 enum_pos = EnumConstants.add_constan t(enum_item)
884 condition_list.append("s == \"%s\"" % enum_item) 916 condition_list.append("s == \"%s\"" % enum_item)
885 validator_writer.newline(" ASSERT(%s) ;\n" % " || ".join(condition_list)) 917 validator_writer.newline(" ASSERT(%s) ;\n" % " || ".join(condition_list))
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 @staticmethod 1043 @staticmethod
1012 def get_type_model(): 1044 def get_type_model():
1013 return TypeModel.ValueType("%s%s" % (helper.full_nam e_prefix_for_use, fixed_type_name.class_name), True) 1045 return TypeModel.ValueType("%s%s" % (helper.full_nam e_prefix_for_use, fixed_type_name.class_name), True)
1014 1046
1015 @staticmethod 1047 @staticmethod
1016 def get_setter_value_expression_pattern(): 1048 def get_setter_value_expression_pattern():
1017 return None 1049 return None
1018 1050
1019 @classmethod 1051 @classmethod
1020 def get_array_item_c_type_text(cls): 1052 def get_array_item_c_type_text(cls):
1021 return "const %s%s&" % (helper.full_name_prefix_for_ use, fixed_type_name.class_name) 1053 return "%s%s" % (helper.full_name_prefix_for_use, fi xed_type_name.class_name)
1022 1054
1023 return TypedefString 1055 return TypedefString
1024 1056
1025 elif json_typable["type"] == "object": 1057 elif json_typable["type"] == "object":
1026 if "properties" in json_typable: 1058 if "properties" in json_typable:
1027 1059
1028 class ClassBinding: 1060 class ClassBinding:
1029 resolve_data_ = None 1061 resolve_data_ = None
1030 need_user_runtime_cast_ = False 1062 need_user_runtime_cast_ = False
1031 need_internal_runtime_cast_ = False 1063 need_internal_runtime_cast_ = False
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 helper.write_doc(writer) 1128 helper.write_doc(writer)
1097 class_name = fixed_type_name.class_name 1129 class_name = fixed_type_name.class_name
1098 1130
1099 is_open_type = (context_domain_name + "." + clas s_name) in TYPES_WITH_OPEN_FIELD_LIST_SET 1131 is_open_type = (context_domain_name + "." + clas s_name) in TYPES_WITH_OPEN_FIELD_LIST_SET
1100 1132
1101 fixed_type_name.output_comment(writer) 1133 fixed_type_name.output_comment(writer)
1102 writer.newline("class ") 1134 writer.newline("class ")
1103 writer.append(class_name) 1135 writer.append(class_name)
1104 writer.append(" : public ") 1136 writer.append(" : public ")
1105 if is_open_type: 1137 if is_open_type:
1106 writer.append("InspectorObject") 1138 writer.append("JSONObject")
1107 else: 1139 else:
1108 writer.append("InspectorObjectBase") 1140 writer.append("JSONObjectBase")
1109 writer.append(" {\n") 1141 writer.append(" {\n")
1110 writer.newline("public:\n") 1142 writer.newline("public:\n")
1111 ad_hoc_type_writer = writer.insert_writer(" " ) 1143 ad_hoc_type_writer = writer.insert_writer(" " )
1112 1144
1113 for ad_hoc_type in resolve_data.ad_hoc_types: 1145 for ad_hoc_type in resolve_data.ad_hoc_types:
1114 code_generator = ad_hoc_type.get_code_genera tor() 1146 code_generator = ad_hoc_type.get_code_genera tor()
1115 if code_generator: 1147 if code_generator:
1116 code_generator.generate_type_builder(ad_ hoc_type_writer, generate_context) 1148 code_generator.generate_type_builder(ad_ hoc_type_writer, generate_context)
1117 1149
1118 writer.newline_multiline( 1150 writer.newline_multiline(
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 writer.append_multiline("\n void %s" % se tter_name) 1207 writer.append_multiline("\n void %s" % se tter_name)
1176 writer.append("(%s value)\n" % param_type_bi nding.get_type_model().get_input_param_type_text()) 1208 writer.append("(%s value)\n" % param_type_bi nding.get_type_model().get_input_param_type_text())
1177 writer.newline(" {\n") 1209 writer.newline(" {\n")
1178 writer.newline(" this->set%s(\"%s\", %s);\n" 1210 writer.newline(" this->set%s(\"%s\", %s);\n"
1179 % (param_type_binding.reduce_to_raw_type ().get_setter_name(), prop_data.p["name"], 1211 % (param_type_binding.reduce_to_raw_type ().get_setter_name(), prop_data.p["name"],
1180 format_setter_value_expression(param_ type_binding, "value"))) 1212 format_setter_value_expression(param_ type_binding, "value")))
1181 writer.newline(" }\n") 1213 writer.newline(" }\n")
1182 1214
1183 1215
1184 if setter_name in INSPECTOR_OBJECT_SETTER_NA MES: 1216 if setter_name in INSPECTOR_OBJECT_SETTER_NA MES:
1185 writer.newline(" using InspectorObjec tBase::%s;\n\n" % setter_name) 1217 writer.newline(" using JSONObjectBase ::%s;\n\n" % setter_name)
1186 1218
1187 if class_binding_cls.need_user_runtime_cast_: 1219 if class_binding_cls.need_user_runtime_cast_:
1188 writer.newline(" static PassRefPtr<%s> ru ntimeCast(PassRefPtr<InspectorValue> value)\n" % class_name) 1220 writer.newline(" static PassRefPtr<%s> ru ntimeCast(PassRefPtr<JSONValue> value)\n" % class_name)
1189 writer.newline(" {\n") 1221 writer.newline(" {\n")
1190 writer.newline(" RefPtr<InspectorObje ct> object;\n") 1222 writer.newline(" RefPtr<JSONObject> o bject;\n")
1191 writer.newline(" bool castRes = value ->asObject(&object);\n") 1223 writer.newline(" bool castRes = value ->asObject(&object);\n")
1192 writer.newline(" ASSERT_UNUSED(castRe s, castRes);\n") 1224 writer.newline(" ASSERT_UNUSED(castRe s, castRes);\n")
1193 writer.append("#if %s\n" % VALIDATOR_IFDEF_N AME) 1225 writer.append("#if %s\n" % VALIDATOR_IFDEF_N AME)
1194 writer.newline(" assertCorrectValue(o bject.get());\n") 1226 writer.newline(" assertCorrectValue(o bject.get());\n")
1195 writer.append("#endif // %s\n" % VALIDATOR_ IFDEF_NAME) 1227 writer.append("#endif // %s\n" % VALIDATOR_ IFDEF_NAME)
1196 writer.newline(" COMPILE_ASSERT(sizeo f(%s) == sizeof(InspectorObjectBase), type_cast_problem);\n" % class_name) 1228 writer.newline(" COMPILE_ASSERT(sizeo f(%s) == sizeof(JSONObjectBase), type_cast_problem);\n" % class_name)
1197 writer.newline(" return static_cast<% s*>(static_cast<InspectorObjectBase*>(object.get()));\n" % class_name) 1229 writer.newline(" return static_cast<% s*>(static_cast<JSONObjectBase*>(object.get()));\n" % class_name)
1198 writer.newline(" }\n") 1230 writer.newline(" }\n")
1199 writer.append("\n") 1231 writer.append("\n")
1200 1232
1201 if class_binding_cls.need_internal_runtime_cast_ : 1233 if class_binding_cls.need_internal_runtime_cast_ :
1202 writer.append("#if %s\n" % VALIDATOR_IFDEF_N AME) 1234 writer.append("#if %s\n" % VALIDATOR_IFDEF_N AME)
1203 writer.newline(" static void assertCorrec tValue(InspectorValue* value);\n") 1235 writer.newline(" static void assertCorrec tValue(JSONValue* value);\n")
1204 writer.append("#endif // %s\n" % VALIDATOR_ IFDEF_NAME) 1236 writer.append("#endif // %s\n" % VALIDATOR_ IFDEF_NAME)
1205 1237
1206 closed_field_set = (context_domain_name + ". " + class_name) not in TYPES_WITH_OPEN_FIELD_LIST_SET 1238 closed_field_set = (context_domain_name + ". " + class_name) not in TYPES_WITH_OPEN_FIELD_LIST_SET
1207 1239
1208 validator_writer = generate_context.validato r_writer 1240 validator_writer = generate_context.validato r_writer
1209 1241
1210 domain_fixes = DomainNameFixes.get_fixed_dat a(context_domain_name) 1242 domain_fixes = DomainNameFixes.get_fixed_dat a(context_domain_name)
1211 1243
1212 validator_writer.newline("void %s%s::assertC orrectValue(InspectorValue* value)\n" % (helper.full_name_prefix_for_impl, class _name)) 1244 validator_writer.newline("void %s%s::assertC orrectValue(JSONValue* value)\n" % (helper.full_name_prefix_for_impl, class_name ))
1213 validator_writer.newline("{\n") 1245 validator_writer.newline("{\n")
1214 validator_writer.newline(" RefPtr<Inspect orObject> object;\n") 1246 validator_writer.newline(" RefPtr<JSONObj ect> object;\n")
1215 validator_writer.newline(" bool castRes = value->asObject(&object);\n") 1247 validator_writer.newline(" bool castRes = value->asObject(&object);\n")
1216 validator_writer.newline(" ASSERT_UNUSED( castRes, castRes);\n") 1248 validator_writer.newline(" ASSERT_UNUSED( castRes, castRes);\n")
1217 for prop_data in resolve_data.main_propertie s: 1249 for prop_data in resolve_data.main_propertie s:
1218 validator_writer.newline(" {\n") 1250 validator_writer.newline(" {\n")
1219 it_name = "%sPos" % prop_data.p["name"] 1251 it_name = "%sPos" % prop_data.p["name"]
1220 validator_writer.newline(" Inspec torObject::iterator %s;\n" % it_name) 1252 validator_writer.newline(" JSONOb ject::iterator %s;\n" % it_name)
1221 validator_writer.newline(" %s = o bject->find(\"%s\");\n" % (it_name, prop_data.p["name"])) 1253 validator_writer.newline(" %s = o bject->find(\"%s\");\n" % (it_name, prop_data.p["name"]))
1222 validator_writer.newline(" ASSERT (%s != object->end());\n" % it_name) 1254 validator_writer.newline(" ASSERT (%s != object->end());\n" % it_name)
1223 validator_writer.newline(" %s(%s- >value.get());\n" % (prop_data.param_type_binding.get_validator_call_text(), it_ name)) 1255 validator_writer.newline(" %s(%s- >value.get());\n" % (prop_data.param_type_binding.get_validator_call_text(), it_ name))
1224 validator_writer.newline(" }\n") 1256 validator_writer.newline(" }\n")
1225 1257
1226 if closed_field_set: 1258 if closed_field_set:
1227 validator_writer.newline(" int foundP ropertiesCount = %s;\n" % len(resolve_data.main_properties)) 1259 validator_writer.newline(" int foundP ropertiesCount = %s;\n" % len(resolve_data.main_properties))
1228 1260
1229 for prop_data in resolve_data.optional_prope rties: 1261 for prop_data in resolve_data.optional_prope rties:
1230 validator_writer.newline(" {\n") 1262 validator_writer.newline(" {\n")
1231 it_name = "%sPos" % prop_data.p["name"] 1263 it_name = "%sPos" % prop_data.p["name"]
1232 validator_writer.newline(" Inspec torObject::iterator %s;\n" % it_name) 1264 validator_writer.newline(" JSONOb ject::iterator %s;\n" % it_name)
1233 validator_writer.newline(" %s = o bject->find(\"%s\");\n" % (it_name, prop_data.p["name"])) 1265 validator_writer.newline(" %s = o bject->find(\"%s\");\n" % (it_name, prop_data.p["name"]))
1234 validator_writer.newline(" if (%s != object->end()) {\n" % it_name) 1266 validator_writer.newline(" if (%s != object->end()) {\n" % it_name)
1235 validator_writer.newline(" %s (%s->value.get());\n" % (prop_data.param_type_binding.get_validator_call_text(), it_name)) 1267 validator_writer.newline(" %s (%s->value.get());\n" % (prop_data.param_type_binding.get_validator_call_text(), it_name))
1236 if closed_field_set: 1268 if closed_field_set:
1237 validator_writer.newline(" ++foundPropertiesCount;\n") 1269 validator_writer.newline(" ++foundPropertiesCount;\n")
1238 validator_writer.newline(" }\n") 1270 validator_writer.newline(" }\n")
1239 validator_writer.newline(" }\n") 1271 validator_writer.newline(" }\n")
1240 1272
1241 if closed_field_set: 1273 if closed_field_set:
1242 validator_writer.newline(" if (foundP ropertiesCount != object->size()) {\n") 1274 validator_writer.newline(" if (foundP ropertiesCount != object->size()) {\n")
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 @staticmethod 1365 @staticmethod
1334 def request_internal_runtime_cast(): 1366 def request_internal_runtime_cast():
1335 RawTypes.Object.request_raw_internal_runtime_cast() 1367 RawTypes.Object.request_raw_internal_runtime_cast()
1336 1368
1337 @staticmethod 1369 @staticmethod
1338 def get_code_generator(): 1370 def get_code_generator():
1339 pass 1371 pass
1340 1372
1341 @staticmethod 1373 @staticmethod
1342 def get_validator_call_text(): 1374 def get_validator_call_text():
1343 return "RuntimeCastHelper::assertType<InspectorValue::Ty peObject>" 1375 return "RuntimeCastHelper::assertType<JSONValue::TypeObj ect>"
1344 1376
1345 @classmethod 1377 @classmethod
1346 def get_array_item_c_type_text(cls): 1378 def get_array_item_c_type_text(cls):
1347 return cls.reduce_to_raw_type().get_array_item_raw_c_typ e_text() 1379 return cls.reduce_to_raw_type().get_array_item_raw_c_typ e_text()
1348 1380
1349 @staticmethod 1381 @staticmethod
1350 def get_setter_value_expression_pattern(): 1382 def get_setter_value_expression_pattern():
1351 return None 1383 return None
1352 1384
1353 @staticmethod 1385 @staticmethod
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 1675
1644 file_header_ = ("// File is generated by %s\n\n" % get_this_script_path_(sys .argv[0]) + 1676 file_header_ = ("// File is generated by %s\n\n" % get_this_script_path_(sys .argv[0]) +
1645 """// Copyright (c) 2011 The Chromium Authors. All rights reserved. 1677 """// Copyright (c) 2011 The Chromium Authors. All rights reserved.
1646 // Use of this source code is governed by a BSD-style license that can be 1678 // Use of this source code is governed by a BSD-style license that can be
1647 // found in the LICENSE file. 1679 // found in the LICENSE file.
1648 """) 1680 """)
1649 1681
1650 frontend_domain_class = string.Template(CodeGeneratorInspectorStrings.fronte nd_domain_class) 1682 frontend_domain_class = string.Template(CodeGeneratorInspectorStrings.fronte nd_domain_class)
1651 backend_method = string.Template(CodeGeneratorInspectorStrings.backend_metho d) 1683 backend_method = string.Template(CodeGeneratorInspectorStrings.backend_metho d)
1652 frontend_method = string.Template(CodeGeneratorInspectorStrings.frontend_met hod) 1684 frontend_method = string.Template(CodeGeneratorInspectorStrings.frontend_met hod)
1653 callback_method = string.Template(CodeGeneratorInspectorStrings.callback_met hod) 1685 callback_main_methods = string.Template(CodeGeneratorInspectorStrings.callba ck_main_methods)
1686 callback_failure_method = string.Template(CodeGeneratorInspectorStrings.call back_failure_method)
1654 frontend_h = string.Template(file_header_ + CodeGeneratorInspectorStrings.fr ontend_h) 1687 frontend_h = string.Template(file_header_ + CodeGeneratorInspectorStrings.fr ontend_h)
1655 backend_h = string.Template(file_header_ + CodeGeneratorInspectorStrings.bac kend_h) 1688 backend_h = string.Template(file_header_ + CodeGeneratorInspectorStrings.bac kend_h)
1656 backend_cpp = string.Template(file_header_ + CodeGeneratorInspectorStrings.b ackend_cpp) 1689 backend_cpp = string.Template(file_header_ + CodeGeneratorInspectorStrings.b ackend_cpp)
1657 frontend_cpp = string.Template(file_header_ + CodeGeneratorInspectorStrings. frontend_cpp) 1690 frontend_cpp = string.Template(file_header_ + CodeGeneratorInspectorStrings. frontend_cpp)
1658 typebuilder_h = string.Template(file_header_ + CodeGeneratorInspectorStrings .typebuilder_h) 1691 typebuilder_h = string.Template(file_header_ + CodeGeneratorInspectorStrings .typebuilder_h)
1659 typebuilder_cpp = string.Template(file_header_ + CodeGeneratorInspectorStrin gs.typebuilder_cpp) 1692 typebuilder_cpp = string.Template(file_header_ + CodeGeneratorInspectorStrin gs.typebuilder_cpp)
1660 param_container_access_code = CodeGeneratorInspectorStrings.param_container_ access_code 1693 param_container_access_code = CodeGeneratorInspectorStrings.param_container_ access_code
1661 1694
1662 1695
1663 1696
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 decl_parameter_list, 1865 decl_parameter_list,
1833 Generator.EventMethodStructTemplate, 1866 Generator.EventMethodStructTemplate,
1834 Generator.frontend_method_list, Templates .frontend_method, {"eventName": event_name}) 1867 Generator.frontend_method_list, Templates .frontend_method, {"eventName": event_name})
1835 1868
1836 frontend_method_declaration_lines.append( 1869 frontend_method_declaration_lines.append(
1837 " void %s(%s);\n" % (event_name, ", ".join(decl_parameter_lis t))) 1870 " void %s(%s);\n" % (event_name, ", ".join(decl_parameter_lis t)))
1838 1871
1839 class EventMethodStructTemplate: 1872 class EventMethodStructTemplate:
1840 @staticmethod 1873 @staticmethod
1841 def append_prolog(line_list): 1874 def append_prolog(line_list):
1842 line_list.append(" RefPtr<InspectorObject> paramsObject = Inspect orObject::create();\n") 1875 line_list.append(" RefPtr<JSONObject> paramsObject = JSONObject:: create();\n")
1843 1876
1844 @staticmethod 1877 @staticmethod
1845 def append_epilog(line_list): 1878 def append_epilog(line_list):
1846 line_list.append(" jsonMessage->setObject(\"params\", paramsObjec t);\n") 1879 line_list.append(" jsonMessage->setObject(\"params\", paramsObjec t);\n")
1847 1880
1848 container_name = "paramsObject" 1881 container_name = "paramsObject"
1849 1882
1850 @staticmethod 1883 @staticmethod
1851 def process_command(json_command, domain_name, agent_field_name, agent_inter face_name): 1884 def process_command(json_command, domain_name, agent_field_name, agent_inter face_name):
1852 json_command_name = json_command["name"] 1885 json_command_name = json_command["name"]
1853 1886
1854 cmd_enum_name = "k%s_%sCmd" % (domain_name, json_command["name"]) 1887 cmd_enum_name = "k%s_%sCmd" % (domain_name, json_command["name"])
1855 1888
1856 Generator.method_name_enum_list.append(" %s," % cmd_enum_name) 1889 Generator.method_name_enum_list.append(" %s," % cmd_enum_name)
1857 Generator.method_handler_list.append(" &InspectorBackendDispa tcherImpl::%s_%s," % (domain_name, json_command_name)) 1890 Generator.method_handler_list.append(" &InspectorBackendDispa tcherImpl::%s_%s," % (domain_name, json_command_name))
1858 Generator.backend_method_declaration_list.append(" void %s_%s(long ca llId, InspectorObject* requestMessageObject);" % (domain_name, json_command_name )) 1891 Generator.backend_method_declaration_list.append(" void %s_%s(long ca llId, JSONObject* requestMessageObject);" % (domain_name, json_command_name))
1859 1892
1860 ad_hoc_type_output = [] 1893 ad_hoc_type_output = []
1861 Generator.backend_agent_interface_list.append(ad_hoc_type_output) 1894 Generator.backend_agent_interface_list.append(ad_hoc_type_output)
1862 ad_hoc_type_writer = Writer(ad_hoc_type_output, " ") 1895 ad_hoc_type_writer = Writer(ad_hoc_type_output, " ")
1863 1896
1864 Generator.backend_agent_interface_list.append(" virtual void %s(E rrorString*" % json_command_name) 1897 Generator.backend_agent_interface_list.append(" virtual void %s(E rrorString*" % json_command_name)
1865 1898
1866 method_in_code = "" 1899 method_in_code = ""
1867 method_out_code = "" 1900 method_out_code = ""
1868 agent_call_param_list = [] 1901 agent_call_param_list = []
1869 response_cook_list = []
1870 request_message_param = "" 1902 request_message_param = ""
1903 normal_response_cook_text = ""
1904 error_response_cook_text = ""
1905 error_type_binding = None
1906 if "error" in json_command:
1907 json_error = json_command["error"]
1908 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 + "::")
1909 error_type_model = error_type_binding.get_type_model().get_optional( )
1910 error_annotated_type = error_type_model.get_command_return_pass_mode l().get_output_parameter_type()
1911 agent_call_param_list.append(", %serrorData" % error_type_model.get_ command_return_pass_model().get_output_argument_prefix())
1912 Generator.backend_agent_interface_list.append(", %s errorData" % err or_annotated_type)
1913 method_in_code += " %s errorData;\n" % error_type_model.get_comma nd_return_pass_model().get_return_var_type()
1914
1915 setter_argument = error_type_model.get_command_return_pass_model().g et_output_to_raw_expression() % "errorData"
1916 if error_type_binding.get_setter_value_expression_pattern():
1917 setter_argument = error_type_binding.get_setter_value_expression _pattern() % setter_argument
1918 error_assigment_value = error_type_binding.reduce_to_raw_type().get_ constructor_pattern() % setter_argument
1919
1920 cook = " resultErrorData = %s;\n" % error_assigment_value
1921
1922 error_condition_pattern = error_type_model.get_command_return_pass_m odel().get_set_return_condition()
1923 cook = (" if (%s)\n " % (error_condition_pattern % "er rorData")) + cook
1924 error_response_cook_text = " if (error.length()) {\n" + cook + " }\n"
1925
1871 if "parameters" in json_command: 1926 if "parameters" in json_command:
1872 json_params = json_command["parameters"] 1927 json_params = json_command["parameters"]
1873 method_in_code += Templates.param_container_access_code 1928 method_in_code += Templates.param_container_access_code
1874 request_message_param = " requestMessageObject" 1929 request_message_param = " requestMessageObject"
1875 js_param_list = []
1876 1930
1877 for json_parameter in json_params: 1931 for json_parameter in json_params:
1878 json_param_name = json_parameter["name"] 1932 json_param_name = json_parameter["name"]
1879 param_raw_type = resolve_param_raw_type(json_parameter, domain_n ame) 1933 param_raw_type = resolve_param_raw_type(json_parameter, domain_n ame)
1880 1934
1881 getter_name = param_raw_type.get_getter_name() 1935 getter_name = param_raw_type.get_getter_name()
1882 1936
1883 optional = json_parameter.get("optional") 1937 optional = json_parameter.get("optional")
1884 1938
1885 non_optional_type_model = param_raw_type.get_raw_type_model() 1939 non_optional_type_model = param_raw_type.get_raw_type_model()
(...skipping 16 matching lines...) Expand all
1902 # FIXME: pass not-optional refptr-values as NonNullPassRefPt r 1956 # FIXME: pass not-optional refptr-values as NonNullPassRefPt r
1903 if param_raw_type.is_heavy_value(): 1957 if param_raw_type.is_heavy_value():
1904 formal_param_type_pattern = "const %s&" 1958 formal_param_type_pattern = "const %s&"
1905 else: 1959 else:
1906 formal_param_type_pattern = "%s" 1960 formal_param_type_pattern = "%s"
1907 1961
1908 method_in_code += code 1962 method_in_code += code
1909 agent_call_param_list.append(param) 1963 agent_call_param_list.append(param)
1910 Generator.backend_agent_interface_list.append(", %s in_%s" % (fo rmal_param_type_pattern % non_optional_type_model.get_command_return_pass_model( ).get_return_var_type(), json_param_name)) 1964 Generator.backend_agent_interface_list.append(", %s in_%s" % (fo rmal_param_type_pattern % non_optional_type_model.get_command_return_pass_model( ).get_return_var_type(), json_param_name))
1911 1965
1912 response_cook_text = ""
1913 if json_command.get("async") == True: 1966 if json_command.get("async") == True:
1914 callback_name = Capitalizer.lower_camel_case_to_upper(json_command_n ame) + "Callback" 1967 callback_name = Capitalizer.lower_camel_case_to_upper(json_command_n ame) + "Callback"
1915 1968
1916 callback_output = [] 1969 callback_output = []
1917 callback_writer = Writer(callback_output, ad_hoc_type_writer.get_ind ent()) 1970 callback_writer = Writer(callback_output, ad_hoc_type_writer.get_ind ent())
1918 1971
1919 decl_parameter_list = [] 1972 decl_parameter_list = []
1920 Generator.generate_send_method(json_command.get("returns"), json_com mand_name, domain_name, ad_hoc_type_writer, 1973 Generator.generate_send_method(json_command.get("returns"), json_com mand_name, domain_name, ad_hoc_type_writer,
1921 decl_parameter_list, 1974 decl_parameter_list,
1922 Generator.CallbackMethodStructTemplat e, 1975 Generator.CallbackMethodStructTemplat e,
1923 Generator.backend_method_implementati on_list, Templates.callback_method, 1976 Generator.backend_method_implementati on_list, Templates.callback_main_methods,
1924 {"callbackName": callback_name, "agen tName": agent_interface_name}) 1977 {"callbackName": callback_name, "agen tName": agent_interface_name})
1925 1978
1926 callback_writer.newline("class " + callback_name + " : public Callba ckBase {\n") 1979 callback_writer.newline("class " + callback_name + " : public Callba ckBase {\n")
1927 callback_writer.newline("public:\n") 1980 callback_writer.newline("public:\n")
1928 callback_writer.newline(" " + callback_name + "(PassRefPtr<Inspec torBackendDispatcherImpl>, int id);\n") 1981 callback_writer.newline(" " + callback_name + "(PassRefPtr<Inspec torBackendDispatcherImpl>, int id);\n")
1929 callback_writer.newline(" void sendSuccess(" + ", ".join(decl_par ameter_list) + ");\n") 1982 callback_writer.newline(" void sendSuccess(" + ", ".join(decl_par ameter_list) + ");\n")
1983 error_part_writer = callback_writer.insert_writer("")
1930 callback_writer.newline("};\n") 1984 callback_writer.newline("};\n")
1931 1985
1986 if error_type_binding:
1987 annotated_type = error_type_model.get_input_param_type_text()
1988 error_part_writer.newline(" void sendFailure(const ErrorStrin g&, %s);\n" % annotated_type)
1989 error_part_writer.newline(" using CallbackBase::sendFailure;\ n")
1990
1991 assigment_value = error_type_model.get_event_setter_expression_p attern() % "errorData"
1992 assigment_value = error_type_binding.reduce_to_raw_type().get_co nstructor_pattern() % assigment_value
1993
1994 Generator.backend_method_implementation_list.append(Templates.ca llback_failure_method.substitute(None,
1995 agentName=agent_interface_name,
1996 callbackName=callback_name,
1997 parameter=annotated_type + " errorData",
1998 argument=assigment_value))
1999
2000
2001
1932 ad_hoc_type_output.append(callback_output) 2002 ad_hoc_type_output.append(callback_output)
1933 2003
1934 method_out_code += " RefPtr<" + agent_interface_name + "::" + cal lback_name + "> callback = adoptRef(new " + agent_interface_name + "::" + callba ck_name + "(this, callId));\n" 2004 method_out_code += " RefPtr<" + agent_interface_name + "::" + cal lback_name + "> callback = adoptRef(new " + agent_interface_name + "::" + callba ck_name + "(this, callId));\n"
1935 agent_call_param_list.append(", callback") 2005 agent_call_param_list.append(", callback")
1936 response_cook_text += " if (!error.length()) \n" 2006 normal_response_cook_text += " if (!error.length()) \n"
1937 response_cook_text += " return;\n" 2007 normal_response_cook_text += " return;\n"
1938 response_cook_text += " callback->disable();\n" 2008 normal_response_cook_text += " callback->disable();\n"
1939 Generator.backend_agent_interface_list.append(", PassRefPtr<%s> call back" % callback_name) 2009 Generator.backend_agent_interface_list.append(", PassRefPtr<%s> call back" % callback_name)
1940 else: 2010 else:
1941 if "returns" in json_command: 2011 if "returns" in json_command:
1942 method_out_code += "\n" 2012 method_out_code += "\n"
2013 response_cook_list = []
1943 for json_return in json_command["returns"]: 2014 for json_return in json_command["returns"]:
1944 2015
1945 json_return_name = json_return["name"] 2016 json_return_name = json_return["name"]
1946 2017
1947 optional = bool(json_return.get("optional")) 2018 optional = bool(json_return.get("optional"))
1948 2019
1949 return_type_binding = Generator.resolve_type_and_generate_ad _hoc(json_return, json_command_name, domain_name, ad_hoc_type_writer, agent_inte rface_name + "::") 2020 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 + "::")
1950 2021
1951 raw_type = return_type_binding.reduce_to_raw_type() 2022 raw_type = return_type_binding.reduce_to_raw_type()
1952 setter_type = raw_type.get_setter_name() 2023 setter_type = raw_type.get_setter_name()
1953 initializer = raw_type.get_c_initializer() 2024 initializer = raw_type.get_c_initializer()
1954 2025
1955 type_model = return_type_binding.get_type_model() 2026 type_model = return_type_binding.get_type_model()
1956 if optional: 2027 if optional:
1957 type_model = type_model.get_optional() 2028 type_model = type_model.get_optional()
1958 2029
1959 code = " %s out_%s;\n" % (type_model.get_command_return_p ass_model().get_return_var_type(), json_return_name) 2030 code = " %s out_%s;\n" % (type_model.get_command_return_p ass_model().get_return_var_type(), json_return_name)
1960 param = ", %sout_%s" % (type_model.get_command_return_pass_m odel().get_output_argument_prefix(), json_return_name) 2031 param = ", %sout_%s" % (type_model.get_command_return_pass_m odel().get_output_argument_prefix(), json_return_name)
1961 var_name = "out_%s" % json_return_name 2032 var_name = "out_%s" % json_return_name
1962 setter_argument = type_model.get_command_return_pass_model() .get_output_to_raw_expression() % var_name 2033 setter_argument = type_model.get_command_return_pass_model() .get_output_to_raw_expression() % var_name
1963 if return_type_binding.get_setter_value_expression_pattern() : 2034 if return_type_binding.get_setter_value_expression_pattern() :
1964 setter_argument = return_type_binding.get_setter_value_e xpression_pattern() % setter_argument 2035 setter_argument = return_type_binding.get_setter_value_e xpression_pattern() % setter_argument
1965 2036
1966 cook = " result->set%s(\"%s\", %s);\n" % (setter_ type, json_return_name, 2037 cook = " result->set%s(\"%s\", %s);\n" % (setter_ type, json_return_name,
1967 setter_ argument) 2038 setter_ argument)
1968 2039
1969 set_condition_pattern = type_model.get_command_return_pass_m odel().get_set_return_condition() 2040 set_condition_pattern = type_model.get_command_return_pass_m odel().get_set_return_condition()
1970 if set_condition_pattern: 2041 if set_condition_pattern:
1971 cook = (" if (%s)\n " % (set_condition_pat tern % var_name)) + cook 2042 cook = (" if (%s)\n " % (set_condition_pat tern % var_name)) + cook
1972 annotated_type = type_model.get_command_return_pass_model(). get_output_parameter_type() 2043 annotated_type = type_model.get_command_return_pass_model(). get_output_parameter_type()
1973 2044
1974 param_name = "out_%s" % json_return_name 2045 param_name = var_name
1975 if optional: 2046 if optional:
1976 param_name = "opt_" + param_name 2047 param_name = "opt_" + param_name
1977 2048
1978 Generator.backend_agent_interface_list.append(", %s %s" % (a nnotated_type, param_name)) 2049 Generator.backend_agent_interface_list.append(", %s %s" % (a nnotated_type, param_name))
1979 response_cook_list.append(cook) 2050 response_cook_list.append(cook)
1980 2051
1981 method_out_code += code 2052 method_out_code += code
1982 agent_call_param_list.append(param) 2053 agent_call_param_list.append(param)
1983 2054
1984 response_cook_text = "".join(response_cook_list) 2055 normal_response_cook_text += "".join(response_cook_list)
1985 2056
1986 if len(response_cook_text) != 0: 2057 if len(normal_response_cook_text) != 0:
1987 response_cook_text = " if (!error.length()) {\n" + re sponse_cook_text + " }" 2058 normal_response_cook_text = " if (!error.length()) {\ n" + normal_response_cook_text + " }"
1988 2059
1989 Generator.backend_method_implementation_list.append(Templates.backend_me thod.substitute(None, 2060 Generator.backend_method_implementation_list.append(Templates.backend_me thod.substitute(None,
1990 domainName=domain_name, methodName=json_command_name, 2061 domainName=domain_name, methodName=json_command_name,
1991 agentField="m_" + agent_field_name, 2062 agentField="m_" + agent_field_name,
1992 methodInCode=method_in_code, 2063 methodInCode=method_in_code,
1993 methodOutCode=method_out_code, 2064 methodOutCode=method_out_code,
1994 agentCallParams="".join(agent_call_param_list), 2065 agentCallParams="".join(agent_call_param_list),
1995 requestMessageObject=request_message_param, 2066 requestMessageObject=request_message_param,
1996 responseCook=response_cook_text, 2067 responseCook=normal_response_cook_text,
2068 errorCook=error_response_cook_text,
1997 commandNameIndex=cmd_enum_name)) 2069 commandNameIndex=cmd_enum_name))
1998 Generator.backend_method_name_declaration_list.append(" \"%s.%s\"," % (domain_name, json_command_name)) 2070 Generator.backend_method_name_declaration_list.append(" \"%s.%s\"," % (domain_name, json_command_name))
1999 2071
2000 Generator.backend_agent_interface_list.append(") = 0;\n") 2072 Generator.backend_agent_interface_list.append(") = 0;\n")
2001 2073
2002 class CallbackMethodStructTemplate: 2074 class CallbackMethodStructTemplate:
2003 @staticmethod 2075 @staticmethod
2004 def append_prolog(line_list): 2076 def append_prolog(line_list):
2005 pass 2077 pass
2006 2078
2007 @staticmethod 2079 @staticmethod
2008 def append_epilog(line_list): 2080 def append_epilog(line_list):
2009 pass 2081 pass
2010 2082
2011 container_name = "jsonMessage" 2083 container_name = "jsonMessage"
2012 2084
2013 # Generates common code for event sending and callback response data sending . 2085 # Generates common code for event sending and callback response data sending .
2014 @staticmethod 2086 @staticmethod
2015 def generate_send_method(parameters, event_name, domain_name, ad_hoc_type_wr iter, decl_parameter_list, 2087 def generate_send_method(parameters, event_name, domain_name, ad_hoc_type_wr iter, decl_parameter_list,
2016 method_struct_template, 2088 method_struct_template,
2017 generator_method_list, method_template, template_pa rams): 2089 generator_method_list, method_template, template_pa rams):
2018 method_line_list = [] 2090 method_line_list = []
2019 if parameters: 2091 if parameters:
2020 method_struct_template.append_prolog(method_line_list) 2092 method_struct_template.append_prolog(method_line_list)
2021 for json_parameter in parameters: 2093 for json_parameter in parameters:
2022 parameter_name = json_parameter["name"] 2094 parameter_name = json_parameter["name"]
2023 2095
2024 param_type_binding = Generator.resolve_type_and_generate_ad_hoc( json_parameter, event_name, domain_name, ad_hoc_type_writer, "") 2096 param_type_binding = Generator.resolve_param_type_and_generate_a d_hoc(json_parameter, event_name, domain_name, ad_hoc_type_writer, "")
2025 2097
2026 raw_type = param_type_binding.reduce_to_raw_type() 2098 raw_type = param_type_binding.reduce_to_raw_type()
2027 raw_type_binding = RawTypeBinding(raw_type) 2099 raw_type_binding = RawTypeBinding(raw_type)
2028 2100
2029 optional = bool(json_parameter.get("optional")) 2101 optional = bool(json_parameter.get("optional"))
2030 2102
2031 setter_type = raw_type.get_setter_name() 2103 setter_type = raw_type.get_setter_name()
2032 2104
2033 type_model = param_type_binding.get_type_model() 2105 type_model = param_type_binding.get_type_model()
2034 raw_type_model = raw_type_binding.get_type_model() 2106 raw_type_model = raw_type_binding.get_type_model()
(...skipping 15 matching lines...) Expand all
2050 setter_code = (" if (%s)\n " % parameter_name) + sette r_code 2122 setter_code = (" if (%s)\n " % parameter_name) + sette r_code
2051 method_line_list.append(setter_code) 2123 method_line_list.append(setter_code)
2052 2124
2053 method_struct_template.append_epilog(method_line_list) 2125 method_struct_template.append_epilog(method_line_list)
2054 2126
2055 generator_method_list.append(method_template.substitute(None, 2127 generator_method_list.append(method_template.substitute(None,
2056 domainName=domain_name, 2128 domainName=domain_name,
2057 parameters=", ".join(decl_parameter_list), 2129 parameters=", ".join(decl_parameter_list),
2058 code="".join(method_line_list), **template_params)) 2130 code="".join(method_line_list), **template_params))
2059 2131
2132 @classmethod
2133 def resolve_param_type_and_generate_ad_hoc(cls, json_param, method_name, dom ain_name, ad_hoc_type_writer, container_relative_name_prefix_param):
2134 param_name = json_param["name"]
2135 return cls.resolve_type_and_generate_ad_hoc(json_param, param_name, meth od_name, domain_name, ad_hoc_type_writer, container_relative_name_prefix_param)
2136
2060 @staticmethod 2137 @staticmethod
2061 def resolve_type_and_generate_ad_hoc(json_param, method_name, domain_name, a d_hoc_type_writer, container_relative_name_prefix_param): 2138 def resolve_type_and_generate_ad_hoc(typable_element, element_name, method_n ame, domain_name, ad_hoc_type_writer, container_relative_name_prefix_param):
2062 param_name = json_param["name"]
2063 ad_hoc_type_list = [] 2139 ad_hoc_type_list = []
2064 2140
2065 class AdHocTypeContext: 2141 class AdHocTypeContext:
2066 container_full_name_prefix = "<not yet defined>" 2142 container_full_name_prefix = "<not yet defined>"
2067 container_relative_name_prefix = container_relative_name_prefix_para m 2143 container_relative_name_prefix = container_relative_name_prefix_para m
2068 2144
2069 @staticmethod 2145 @staticmethod
2070 def get_type_name_fix(): 2146 def get_type_name_fix():
2071 class NameFix: 2147 class NameFix:
2072 class_name = Capitalizer.lower_camel_case_to_upper(param_nam e) 2148 class_name = Capitalizer.lower_camel_case_to_upper(element_n ame)
2073 2149
2074 @staticmethod 2150 @staticmethod
2075 def output_comment(writer): 2151 def output_comment(writer):
2076 writer.newline("// Named after parameter '%s' while gene rating command/event %s.\n" % (param_name, method_name)) 2152 writer.newline("// Named after parameter '%s' while gene rating command/event %s.\n" % (element_name, method_name))
2077 2153
2078 return NameFix 2154 return NameFix
2079 2155
2080 @staticmethod 2156 @staticmethod
2081 def add_type(binding): 2157 def add_type(binding):
2082 ad_hoc_type_list.append(binding) 2158 ad_hoc_type_list.append(binding)
2083 2159
2084 type_binding = resolve_param_type(json_param, domain_name, AdHocTypeCont ext) 2160 type_binding = resolve_param_type(typable_element, domain_name, AdHocTyp eContext)
2085 2161
2086 class InterfaceForwardListener: 2162 class InterfaceForwardListener:
2087 @staticmethod 2163 @staticmethod
2088 def add_type_data(type_data): 2164 def add_type_data(type_data):
2089 pass 2165 pass
2090 2166
2091 class InterfaceResolveContext: 2167 class InterfaceResolveContext:
2092 forward_listener = InterfaceForwardListener 2168 forward_listener = InterfaceForwardListener
2093 2169
2094 for type in ad_hoc_type_list: 2170 for type in ad_hoc_type_list:
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
2259 validatorIfdefName=VALIDATOR_IFDEF_NAME)) 2335 validatorIfdefName=VALIDATOR_IFDEF_NAME))
2260 2336
2261 backend_h_file.close() 2337 backend_h_file.close()
2262 backend_cpp_file.close() 2338 backend_cpp_file.close()
2263 2339
2264 frontend_h_file.close() 2340 frontend_h_file.close()
2265 frontend_cpp_file.close() 2341 frontend_cpp_file.close()
2266 2342
2267 typebuilder_h_file.close() 2343 typebuilder_h_file.close()
2268 typebuilder_cpp_file.close() 2344 typebuilder_cpp_file.close()
OLDNEW
« no previous file with comments | « core/html/track/TextTrackRegion.idl ('k') | core/inspector/CodeGeneratorInspectorStrings.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698