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

Unified Diff: Source/core/inspector/CodeGeneratorInspector.py

Issue 558593003: DevTools: Code clean up in CodeGeneratorInspector.py (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/CodeGeneratorInspector.py
diff --git a/Source/core/inspector/CodeGeneratorInspector.py b/Source/core/inspector/CodeGeneratorInspector.py
index 28ded6af65ac5785412352a8c332c5969bdce29b..d0f0421904aca6a4f9514f557680604134aa1b25 100755
--- a/Source/core/inspector/CodeGeneratorInspector.py
+++ b/Source/core/inspector/CodeGeneratorInspector.py
@@ -160,15 +160,9 @@ VALIDATOR_IFDEF_NAME = "ENABLE(ASSERT)"
class DomainNameFixes:
- @classmethod
- def get_fixed_data(cls, domain_name):
- field_name_res = Capitalizer.upper_camel_case_to_lower(domain_name) + "Agent"
-
- class Res(object):
- agent_field_name = field_name_res
-
- return Res
-
+ @staticmethod
+ def get_fixed_data(domain_name):
+ return Capitalizer.upper_camel_case_to_lower(domain_name) + "Agent"
class RawTypes(object):
@staticmethod
@@ -211,20 +205,13 @@ class RawTypes(object):
return "&"
class BaseType(object):
- need_internal_runtime_cast_ = False
-
- @classmethod
- def request_raw_internal_runtime_cast(cls):
- if not cls.need_internal_runtime_cast_:
- cls.need_internal_runtime_cast_ = True
-
@classmethod
def get_raw_validator_call_text(cls):
- return "RuntimeCastHelper::assertType<JSONValue::Type%s>" % cls.get_validate_method_params().template_type
+ return "RuntimeCastHelper::assertType<JSONValue::Type%s>" % cls.get_getter_name()
@staticmethod
- def get_validate_method_params():
- raise Exception("Abstract method")
+ def get_getter_name():
+ raise Exception("Unsupported")
class String(BaseType):
@staticmethod
@@ -238,16 +225,6 @@ class RawTypes(object):
return "InspectorString::create(%s)"
@staticmethod
- def get_c_initializer():
- return "\"\""
-
- @staticmethod
- def get_validate_method_params():
- class ValidateMethodParams:
- template_type = "String"
- return ValidateMethodParams
-
- @staticmethod
def get_output_pass_model():
return RawTypes.OutputPassModel.ByPointer
@@ -276,10 +253,6 @@ class RawTypes(object):
def get_constructor_pattern():
return "InspectorBasicValue::create(%s)"
- @staticmethod
- def get_c_initializer():
- return "0"
-
@classmethod
def get_raw_validator_call_text(cls):
return "RuntimeCastHelper::assertInt"
@@ -314,14 +287,8 @@ class RawTypes(object):
return "InspectorBasicValue::create(%s)"
@staticmethod
- def get_c_initializer():
- return "0"
-
- @staticmethod
- def get_validate_method_params():
- class ValidateMethodParams:
- template_type = "Number"
- return ValidateMethodParams
+ def get_raw_validator_call_text():
+ return "RuntimeCastHelper::assertType<JSONValue::TypeNumber>"
@staticmethod
def get_output_pass_model():
@@ -351,16 +318,6 @@ class RawTypes(object):
return "InspectorBasicValue::create(%s)"
@staticmethod
- def get_c_initializer():
- return "false"
-
- @staticmethod
- def get_validate_method_params():
- class ValidateMethodParams:
- template_type = "Boolean"
- return ValidateMethodParams
-
- @staticmethod
def get_output_pass_model():
return RawTypes.OutputPassModel.ByPointer
@@ -390,20 +347,10 @@ class RawTypes(object):
return "%s"
@staticmethod
- def get_c_initializer():
- return "JSONObject::create()"
-
- @staticmethod
def get_output_argument_prefix():
return ""
@staticmethod
- def get_validate_method_params():
- class ValidateMethodParams:
- template_type = "Object"
- return ValidateMethodParams
-
- @staticmethod
def get_output_pass_model():
return RawTypes.OutputPassModel.ByReference
@@ -427,10 +374,6 @@ class RawTypes(object):
get_setter_name = get_getter_name
@staticmethod
- def get_c_initializer():
- raise Exception("Unsupported")
-
- @staticmethod
def get_constructor_pattern():
raise Exception("Unsupported")
@@ -468,20 +411,10 @@ class RawTypes(object):
return "%s"
@staticmethod
- def get_c_initializer():
- return "JSONArray::create()"
-
- @staticmethod
def get_output_argument_prefix():
return ""
@staticmethod
- def get_validate_method_params():
- class ValidateMethodParams:
- template_type = "Array"
- return ValidateMethodParams
-
- @staticmethod
def get_output_pass_model():
return RawTypes.OutputPassModel.ByReference
@@ -754,9 +687,6 @@ class Writer:
def get_indent(self):
return self.indent
- def get_indented(self, additional_indent):
- return Writer(self.output, self.indent + additional_indent)
-
def insert_writer(self, additional_indent):
new_output = []
self.output.append(new_output)
@@ -859,8 +789,6 @@ class TypeBindings:
@classmethod
def get_code_generator(enum_binding_cls):
- #FIXME: generate ad-hoc enums too once we figure out how to better implement them in C++.
- comment_out = helper.is_ad_hoc
class CodeGenerator:
@staticmethod
@@ -896,8 +824,6 @@ class TypeBindings:
validator_writer = generate_context.validator_writer
- domain_fixes = DomainNameFixes.get_fixed_data(context_domain_name)
-
validator_writer.newline("void %s%s::assertCorrectValue(JSONValue* value)\n" % (helper.full_name_prefix_for_impl, enum_name))
validator_writer.newline("{\n")
validator_writer.newline(" WTF::String s;\n")
@@ -1003,7 +929,7 @@ class TypeBindings:
@staticmethod
def request_internal_runtime_cast():
- RawTypes.String.request_raw_internal_runtime_cast()
+ pass
@staticmethod
def get_code_generator():
@@ -1196,7 +1122,6 @@ class TypeBindings:
for prop_data in resolve_data.main_properties:
prop_name = prop_data.p["name"]
param_type_binding = prop_data.param_type_binding
- raw_type = param_type_binding.reduce_to_raw_type()
if isinstance(param_type_binding.get_type_model(), TypeModel.ValueType):
writer.append_multiline("\n void %s" % prop_name)
writer.append("(%s value)\n" % param_type_binding.get_type_model().get_command_return_pass_model().get_output_parameter_type())
@@ -1244,8 +1169,6 @@ class TypeBindings:
validator_writer = generate_context.validator_writer
- domain_fixes = DomainNameFixes.get_fixed_data(context_domain_name)
-
validator_writer.newline("void %s%s::assertCorrectValue(JSONValue* value)\n" % (helper.full_name_prefix_for_impl, class_name))
validator_writer.newline("{\n")
validator_writer.newline(" RefPtr<JSONObject> object;\n")
@@ -1369,7 +1292,7 @@ class TypeBindings:
@staticmethod
def request_internal_runtime_cast():
- RawTypes.Object.request_raw_internal_runtime_cast()
+ pass
@staticmethod
def get_code_generator():
@@ -1516,7 +1439,7 @@ class RawTypeBinding:
raise Exception("Unsupported")
def request_internal_runtime_cast(self):
- self.raw_type_.request_raw_internal_runtime_cast()
+ pass
def get_code_generator(self):
return None
@@ -1803,30 +1726,11 @@ class Generator:
def go():
Generator.process_types(type_map)
- first_cycle_guardable_list_list = [
- Generator.backend_method_declaration_list,
- Generator.backend_method_implementation_list,
- Generator.backend_method_name_declaration_list,
- Generator.backend_method_name_declaration_index_list,
- Generator.backend_agent_interface_list,
- Generator.frontend_class_field_lines,
- Generator.frontend_constructor_init_list,
- Generator.frontend_domain_class_lines,
- Generator.frontend_method_list,
- Generator.method_handler_list,
- Generator.method_name_enum_list,
- Generator.backend_constructor_init_list,
- Generator.backend_virtual_setters_list,
- Generator.backend_setters_list,
- Generator.backend_field_list]
-
for json_domain in json_api["domains"]:
domain_name = json_domain["domain"]
domain_name_lower = domain_name.lower()
- domain_fixes = DomainNameFixes.get_fixed_data(domain_name)
-
- agent_field_name = domain_fixes.agent_field_name
+ agent_field_name = DomainNameFixes.get_fixed_data(domain_name)
frontend_method_declaration_lines = []
@@ -1914,7 +1818,6 @@ class Generator:
method_in_code = ""
method_out_code = ""
- result_object_declaration = ""
agent_call_param_list = ["&error"]
agent_call_params_declaration_list = [" ErrorString error;"]
send_response_call_params_list = ["error"]
@@ -1947,10 +1850,6 @@ class Generator:
optional = json_parameter.get("optional")
non_optional_type_model = param_raw_type.get_raw_type_model()
- if optional:
- type_model = non_optional_type_model.get_optional()
- else:
- type_model = non_optional_type_model
if optional:
code = (" bool %s_valueFound = false;\n"
@@ -2031,7 +1930,6 @@ class Generator:
raw_type = return_type_binding.reduce_to_raw_type()
setter_type = raw_type.get_setter_name()
- initializer = raw_type.get_c_initializer()
type_model = return_type_binding.get_type_model()
if optional:
@@ -2070,8 +1968,7 @@ class Generator:
# Redirect to another agent's implementation.
agent_field = "m_" + agent_field_name
if "redirect" in json_command:
- domain_fixes = DomainNameFixes.get_fixed_data(json_command.get("redirect"))
- agent_field = "m_" + domain_fixes.agent_field_name
+ agent_field = "m_" + DomainNameFixes.get_fixed_data(json_command.get("redirect"))
Generator.backend_method_implementation_list.append(Templates.backend_method.substitute(None,
domainName=domain_name, methodName=json_command_name,
@@ -2211,8 +2108,6 @@ class Generator:
def generate_all_domains_code(out, type_data_callback):
writer = Writer(out, "")
for domain_data in type_map.domains():
- domain_fixes = DomainNameFixes.get_fixed_data(domain_data.name())
-
namespace_declared = []
def namespace_lazy_generator():
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698