diff options
Diffstat (limited to 'Source/JavaScriptCore/inspector/scripts')
104 files changed, 28275 insertions, 3431 deletions
diff --git a/Source/JavaScriptCore/inspector/scripts/CodeGeneratorInspector.py b/Source/JavaScriptCore/inspector/scripts/CodeGeneratorInspector.py deleted file mode 100755 index 9c6195ff4..000000000 --- a/Source/JavaScriptCore/inspector/scripts/CodeGeneratorInspector.py +++ /dev/null @@ -1,2613 +0,0 @@ -#!/usr/bin/env python -# Copyright (c) 2011 Google Inc. All rights reserved. -# Copyright (c) 2012 Intel Corporation. All rights reserved. -# Copyright (c) 2013 Apple Inc. All Rights Reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -import os.path -import sys -import string -import optparse -import re -try: - import json -except ImportError: - import simplejson as json - -import CodeGeneratorInspectorStrings - - -DOMAIN_DEFINE_NAME_MAP = { - "Database": "SQL_DATABASE", - "IndexedDB": "INDEXED_DATABASE", -} - - -# Manually-filled map of type name replacements. -TYPE_NAME_FIX_MAP = { - "RGBA": "Rgba", # RGBA is reported to be conflicting with a define name in Windows CE. - "": "Empty", -} - - -TYPES_WITH_RUNTIME_CAST_SET = frozenset(["Runtime.RemoteObject", "Runtime.PropertyDescriptor", "Runtime.InternalPropertyDescriptor", - "Debugger.FunctionDetails", "Debugger.CallFrame", - "Canvas.TraceLog", "Canvas.ResourceInfo", "Canvas.ResourceState", - # This should be a temporary hack. TimelineEvent should be created via generated C++ API. - "Timeline.TimelineEvent"]) - -TYPES_WITH_OPEN_FIELD_LIST_SET = frozenset(["Timeline.TimelineEvent", - # InspectorStyleSheet not only creates this property but wants to read it and modify it. - "CSS.CSSProperty", - # InspectorResourceAgent needs to update mime-type. - "Network.Response"]) - -EXACTLY_INT_SUPPORTED = False - -INSPECTOR_TYPES_GENERATOR_CONFIG_MAP = { - "JavaScript": { - "prefix": "JS", - "typebuilder_dependency": "", - "export_macro": "JS_EXPORT_PRIVATE", - }, - "Web": { - "prefix": "Web", - "typebuilder_dependency": "#include <inspector/InspectorJSTypeBuilders.h>", - "export_macro": "", - }, -} - -cmdline_parser = optparse.OptionParser(usage="usage: %prog [options] <Inspector.json>") -cmdline_parser.add_option("--output_h_dir") -cmdline_parser.add_option("--output_cpp_dir") -cmdline_parser.add_option("--output_js_dir") -cmdline_parser.add_option("--output_type") # JavaScript, Web -cmdline_parser.add_option("--write_always", action="store_true") -cmdline_parser.add_option("--no_verification", action="store_true") - -try: - arg_options, arg_values = cmdline_parser.parse_args() - if (len(arg_values) < 1): - raise Exception("At least one plain argument expected") - - input_json_filename = arg_values[0] - dependency_json_filenames = arg_values[1:] - - output_header_dirname = arg_options.output_h_dir - output_cpp_dirname = arg_options.output_cpp_dir - output_js_dirname = arg_options.output_js_dir - output_type = arg_options.output_type - - write_always = arg_options.write_always - verification = not arg_options.no_verification - if not output_header_dirname: - raise Exception("Output .h directory must be specified") - if not output_cpp_dirname: - raise Exception("Output .cpp directory must be specified") - if not output_js_dirname: - raise Exception("Output .js directory must be specified") - if output_type not in INSPECTOR_TYPES_GENERATOR_CONFIG_MAP.keys(): - raise Exception("Unknown output type. Allowed types are: %s" % INSPECTOR_TYPES_GENERATOR_CONFIG_MAP.keys()) -except Exception: - # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html - exc = sys.exc_info()[1] - sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % exc) - sys.stderr.write("Usage: <script> Inspector.json --output_h_dir <output_header_dir> --output_cpp_dir <output_cpp_dir> --output_js_dir <output_js_dir> [--write_always] [--no_verification]\n") - exit(1) - - -def dash_to_camelcase(word): - return ''.join(x.capitalize() or '-' for x in word.split('-')) - - -def fix_camel_case(name): - refined = re.sub(r'-(\w)', lambda pat: pat.group(1).upper(), name) - refined = to_title_case(refined) - return re.sub(r'(?i)HTML|XML|WML|API|GC|XHR|DOM|CSS', lambda pat: pat.group(0).upper(), refined) - - -def to_title_case(name): - return name[:1].upper() + name[1:] - - -class Capitalizer: - @staticmethod - def lower_camel_case_to_upper(str): - if len(str) > 0 and str[0].islower(): - str = str[0].upper() + str[1:] - return str - - @staticmethod - def upper_camel_case_to_lower(str): - pos = 0 - while pos < len(str) and str[pos].isupper(): - pos += 1 - if pos == 0: - return str - if pos == 1: - return str[0].lower() + str[1:] - if pos < len(str): - pos -= 1 - possible_abbreviation = str[0:pos] - if possible_abbreviation not in Capitalizer.ABBREVIATION: - raise Exception("Unknown abbreviation %s" % possible_abbreviation) - str = possible_abbreviation.lower() + str[pos:] - return str - - @staticmethod - def camel_case_to_capitalized_with_underscores(str): - if len(str) == 0: - return str - output = Capitalizer.split_camel_case_(str) - return "_".join(output).upper() - - @staticmethod - def split_camel_case_(str): - output = [] - pos_being = 0 - pos = 1 - has_oneletter = False - while pos < len(str): - if str[pos].isupper(): - output.append(str[pos_being:pos].upper()) - if pos - pos_being == 1: - has_oneletter = True - pos_being = pos - pos += 1 - output.append(str[pos_being:]) - if has_oneletter: - array_pos = 0 - while array_pos < len(output) - 1: - if len(output[array_pos]) == 1: - array_pos_end = array_pos + 1 - while array_pos_end < len(output) and len(output[array_pos_end]) == 1: - array_pos_end += 1 - if array_pos_end - array_pos > 1: - possible_abbreviation = "".join(output[array_pos:array_pos_end]) - if possible_abbreviation.upper() in Capitalizer.ABBREVIATION: - output[array_pos:array_pos_end] = [possible_abbreviation] - else: - array_pos = array_pos_end - 1 - array_pos += 1 - return output - - ABBREVIATION = frozenset(["XHR", "DOM", "CSS"]) - -VALIDATOR_IFDEF_NAME = "!ASSERT_DISABLED" - - -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): - skip_js_bind = domain_name in cls.skip_js_bind_domains - - @staticmethod - def get_guard(): - if domain_name in DOMAIN_DEFINE_NAME_MAP: - define_name = DOMAIN_DEFINE_NAME_MAP[domain_name] - - class Guard: - @staticmethod - def generate_open(output): - output.append("#if ENABLE(%s)\n" % define_name) - - @staticmethod - def generate_close(output): - output.append("#endif // ENABLE(%s)\n" % define_name) - - return Guard - - return Res - - skip_js_bind_domains = set(["DOMDebugger"]) - - -class RawTypes(object): - @staticmethod - def get(json_type): - if json_type == "boolean": - return RawTypes.Bool - elif json_type == "string": - return RawTypes.String - elif json_type == "array": - return RawTypes.Array - elif json_type == "object": - return RawTypes.Object - elif json_type == "integer": - return RawTypes.Int - elif json_type == "number": - return RawTypes.Number - elif json_type == "any": - return RawTypes.Any - else: - raise Exception("Unknown type: %s" % json_type) - - # For output parameter all values are passed by pointer except RefPtr-based types. - class OutputPassModel: - class ByPointer: - @staticmethod - def get_argument_prefix(): - return "&" - - @staticmethod - def get_parameter_type_suffix(): - return "*" - - class ByReference: - @staticmethod - def get_argument_prefix(): - return "" - - @staticmethod - def get_parameter_type_suffix(): - 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<Inspector::InspectorValue::Type%s>" % cls.get_validate_method_params().template_type - - class String(BaseType): - @staticmethod - def get_getter_name(): - return "String" - - get_setter_name = get_getter_name - - @staticmethod - def get_c_initializer(): - return "\"\"" - - @staticmethod - def get_js_bind_type(): - return "string" - - @staticmethod - def get_validate_method_params(): - class ValidateMethodParams: - template_type = "String" - return ValidateMethodParams - - @staticmethod - def get_output_pass_model(): - return RawTypes.OutputPassModel.ByPointer - - @staticmethod - def is_heavy_value(): - return True - - @staticmethod - def get_array_item_raw_c_type_text(): - return "String" - - @staticmethod - def get_raw_type_model(): - return TypeModel.String - - class Int(BaseType): - @staticmethod - def get_getter_name(): - return "Int" - - @staticmethod - def get_setter_name(): - return "Number" - - @staticmethod - def get_c_initializer(): - return "0" - - @staticmethod - def get_js_bind_type(): - return "number" - - @classmethod - def get_raw_validator_call_text(cls): - return "RuntimeCastHelper::assertInt" - - @staticmethod - def get_output_pass_model(): - return RawTypes.OutputPassModel.ByPointer - - @staticmethod - def is_heavy_value(): - return False - - @staticmethod - def get_array_item_raw_c_type_text(): - return "int" - - @staticmethod - def get_raw_type_model(): - return TypeModel.Int - - class Number(BaseType): - @staticmethod - def get_getter_name(): - return "Double" - - @staticmethod - def get_setter_name(): - return "Number" - - @staticmethod - def get_c_initializer(): - return "0" - - @staticmethod - def get_js_bind_type(): - return "number" - - @staticmethod - def get_validate_method_params(): - class ValidateMethodParams: - template_type = "Number" - return ValidateMethodParams - - @staticmethod - def get_output_pass_model(): - return RawTypes.OutputPassModel.ByPointer - - @staticmethod - def is_heavy_value(): - return False - - @staticmethod - def get_array_item_raw_c_type_text(): - return "double" - - @staticmethod - def get_raw_type_model(): - return TypeModel.Number - - class Bool(BaseType): - @staticmethod - def get_getter_name(): - return "Boolean" - - get_setter_name = get_getter_name - - @staticmethod - def get_c_initializer(): - return "false" - - @staticmethod - def get_js_bind_type(): - return "boolean" - - @staticmethod - def get_validate_method_params(): - class ValidateMethodParams: - template_type = "Boolean" - return ValidateMethodParams - - @staticmethod - def get_output_pass_model(): - return RawTypes.OutputPassModel.ByPointer - - @staticmethod - def is_heavy_value(): - return False - - @staticmethod - def get_array_item_raw_c_type_text(): - return "bool" - - @staticmethod - def get_raw_type_model(): - return TypeModel.Bool - - class Object(BaseType): - @staticmethod - def get_getter_name(): - return "Object" - - @staticmethod - def get_setter_name(): - return "Value" - - @staticmethod - def get_c_initializer(): - return "InspectorObject::create()" - - @staticmethod - def get_js_bind_type(): - return "object" - - @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 - - @staticmethod - def is_heavy_value(): - return True - - @staticmethod - def get_array_item_raw_c_type_text(): - return "Inspector::InspectorObject" - - @staticmethod - def get_raw_type_model(): - return TypeModel.Object - - class Any(BaseType): - @staticmethod - def get_getter_name(): - return "Value" - - get_setter_name = get_getter_name - - @staticmethod - def get_c_initializer(): - raise Exception("Unsupported") - - @staticmethod - def get_js_bind_type(): - raise Exception("Unsupported") - - @staticmethod - def get_raw_validator_call_text(): - return "RuntimeCastHelper::assertAny" - - @staticmethod - def get_output_pass_model(): - return RawTypes.OutputPassModel.ByReference - - @staticmethod - def is_heavy_value(): - return True - - @staticmethod - def get_array_item_raw_c_type_text(): - return "Inspector::InspectorValue" - - @staticmethod - def get_raw_type_model(): - return TypeModel.Any - - class Array(BaseType): - @staticmethod - def get_getter_name(): - return "Array" - - @staticmethod - def get_setter_name(): - return "Value" - - @staticmethod - def get_c_initializer(): - return "InspectorArray::create()" - - @staticmethod - def get_js_bind_type(): - return "object" - - @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 - - @staticmethod - def is_heavy_value(): - return True - - @staticmethod - def get_array_item_raw_c_type_text(): - return "Inspector::InspectorArray" - - @staticmethod - def get_raw_type_model(): - return TypeModel.Array - - -def replace_right_shift(input_str): - return input_str.replace(">>", "> >") - - -class CommandReturnPassModel: - class ByReference: - def __init__(self, var_type, set_condition): - self.var_type = var_type - self.set_condition = set_condition - - def get_return_var_type(self): - return self.var_type - - @staticmethod - def get_output_argument_prefix(): - return "" - - @staticmethod - def get_output_to_raw_expression(): - return "%s" - - def get_output_parameter_type(self): - return self.var_type + "&" - - def get_set_return_condition(self): - return self.set_condition - - class ByPointer: - def __init__(self, var_type): - self.var_type = var_type - - def get_return_var_type(self): - return self.var_type - - @staticmethod - def get_output_argument_prefix(): - return "&" - - @staticmethod - def get_output_to_raw_expression(): - return "%s" - - def get_output_parameter_type(self): - return self.var_type + "*" - - @staticmethod - def get_set_return_condition(): - return None - - class OptOutput: - def __init__(self, var_type): - self.var_type = var_type - - def get_return_var_type(self): - return "Inspector::TypeBuilder::OptOutput<%s>" % self.var_type - - @staticmethod - def get_output_argument_prefix(): - return "&" - - @staticmethod - def get_output_to_raw_expression(): - return "%s.getValue()" - - def get_output_parameter_type(self): - return "Inspector::TypeBuilder::OptOutput<%s>*" % self.var_type - - @staticmethod - def get_set_return_condition(): - return "%s.isAssigned()" - - -class TypeModel: - class RefPtrBased(object): - def __init__(self, class_name): - self.class_name = class_name - self.optional = False - - def get_optional(self): - result = TypeModel.RefPtrBased(self.class_name) - result.optional = True - return result - - def get_command_return_pass_model(self): - if self.optional: - set_condition = "%s" - else: - set_condition = None - return CommandReturnPassModel.ByReference(replace_right_shift("RefPtr<%s>" % self.class_name), set_condition) - - def get_input_param_type_text(self): - return replace_right_shift("PassRefPtr<%s>" % self.class_name) - - @staticmethod - def get_event_setter_expression_pattern(): - return "%s" - - class Enum(object): - def __init__(self, base_type_name): - self.type_name = base_type_name + "::Enum" - - def get_optional(base_self): - class EnumOptional: - @classmethod - def get_optional(cls): - return cls - - @staticmethod - def get_command_return_pass_model(): - return CommandReturnPassModel.OptOutput(base_self.type_name) - - @staticmethod - def get_input_param_type_text(): - return base_self.type_name + "*" - - @staticmethod - def get_event_setter_expression_pattern(): - raise Exception("TODO") - return EnumOptional - - def get_command_return_pass_model(self): - return CommandReturnPassModel.ByPointer(self.type_name) - - def get_input_param_type_text(self): - return self.type_name - - @staticmethod - def get_event_setter_expression_pattern(): - return "%s" - - class ValueType(object): - def __init__(self, type_name, is_heavy): - self.type_name = type_name - self.is_heavy = is_heavy - - def get_optional(self): - return self.ValueOptional(self) - - def get_command_return_pass_model(self): - return CommandReturnPassModel.ByPointer(self.type_name) - - def get_input_param_type_text(self): - if self.is_heavy: - return "const %s&" % self.type_name - else: - return self.type_name - - def get_opt_output_type_(self): - return self.type_name - - @staticmethod - def get_event_setter_expression_pattern(): - return "%s" - - class ValueOptional: - def __init__(self, base): - self.base = base - - def get_optional(self): - return self - - def get_command_return_pass_model(self): - return CommandReturnPassModel.OptOutput(self.base.get_opt_output_type_()) - - def get_input_param_type_text(self): - return "const %s* const" % self.base.type_name - - @staticmethod - def get_event_setter_expression_pattern(): - return "*%s" - - class ExactlyInt(ValueType): - def __init__(self): - TypeModel.ValueType.__init__(self, "int", False) - - def get_input_param_type_text(self): - return "Inspector::TypeBuilder::ExactlyInt" - - def get_opt_output_type_(self): - return "Inspector::TypeBuilder::ExactlyInt" - - @classmethod - def init_class(cls): - cls.Bool = cls.ValueType("bool", False) - if EXACTLY_INT_SUPPORTED: - cls.Int = cls.ExactlyInt() - else: - cls.Int = cls.ValueType("int", False) - cls.Number = cls.ValueType("double", False) - cls.String = cls.ValueType("String", True,) - cls.Object = cls.RefPtrBased("Inspector::InspectorObject") - cls.Array = cls.RefPtrBased("Inspector::InspectorArray") - cls.Any = cls.RefPtrBased("Inspector::InspectorValue") - -TypeModel.init_class() - - -# Collection of InspectorObject class methods that are likely to be overloaded in generated class. -# We must explicitly import all overloaded methods or they won't be available to user. -INSPECTOR_OBJECT_SETTER_NAMES = frozenset(["setValue", "setBoolean", "setNumber", "setString", "setValue", "setObject", "setArray"]) - - -def fix_type_name(json_name): - if json_name in TYPE_NAME_FIX_MAP: - fixed = TYPE_NAME_FIX_MAP[json_name] - - class Result(object): - class_name = fixed - - @staticmethod - def output_comment(writer): - writer.newline("// Type originally was named '%s'.\n" % json_name) - else: - - class Result(object): - class_name = json_name - - @staticmethod - def output_comment(writer): - pass - - return Result - - -class Writer: - def __init__(self, output, indent): - self.output = output - self.indent = indent - - def newline(self, str): - if (self.indent): - self.output.append(self.indent) - self.output.append(str) - - def append(self, str): - self.output.append(str) - - def newline_multiline(self, str): - parts = str.split('\n') - self.newline(parts[0]) - for p in parts[1:]: - self.output.append('\n') - if p: - self.newline(p) - - def append_multiline(self, str): - parts = str.split('\n') - self.append(parts[0]) - for p in parts[1:]: - self.output.append('\n') - if p: - self.newline(p) - - 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) - return Writer(new_output, self.indent + additional_indent) - - -class EnumConstants: - map_ = {} - constants_ = [] - - @classmethod - def add_constant(cls, value): - if value in cls.map_: - return cls.map_[value] - else: - pos = len(cls.map_) - cls.map_[value] = pos - cls.constants_.append(value) - return pos - - @classmethod - def get_enum_constant_code(cls): - output = [] - for item in cls.constants_: - output.append(" \"" + item + "\"") - return ",\n".join(output) + "\n" - - -# Typebuilder code is generated in several passes: first typedefs, then other classes. -# Manual pass management is needed because we cannot have forward declarations for typedefs. -class TypeBuilderPass: - TYPEDEF = "typedef" - MAIN = "main" - - -class TypeBindings: - @staticmethod - def create_named_type_declaration(json_typable, context_domain_name, type_data): - json_type = type_data.get_json_type() - - class Helper: - is_ad_hoc = False - full_name_prefix_for_use = "Inspector::TypeBuilder::" + context_domain_name + "::" - full_name_prefix_for_impl = "Inspector::TypeBuilder::" + context_domain_name + "::" - - @staticmethod - def write_doc(writer): - if "description" in json_type: - writer.newline("/* ") - writer.append(json_type["description"]) - writer.append(" */\n") - - @staticmethod - def add_to_forward_listener(forward_listener): - forward_listener.add_type_data(type_data) - - - fixed_type_name = fix_type_name(json_type["id"]) - return TypeBindings.create_type_declaration_(json_typable, context_domain_name, fixed_type_name, Helper) - - @staticmethod - def create_ad_hoc_type_declaration(json_typable, context_domain_name, ad_hoc_type_context): - class Helper: - is_ad_hoc = True - full_name_prefix_for_use = ad_hoc_type_context.container_relative_name_prefix - full_name_prefix_for_impl = ad_hoc_type_context.container_full_name_prefix - - @staticmethod - def write_doc(writer): - pass - - @staticmethod - def add_to_forward_listener(forward_listener): - pass - fixed_type_name = ad_hoc_type_context.get_type_name_fix() - return TypeBindings.create_type_declaration_(json_typable, context_domain_name, fixed_type_name, Helper) - - @staticmethod - def create_type_declaration_(json_typable, context_domain_name, fixed_type_name, helper): - if json_typable["type"] == "string": - if "enum" in json_typable: - - class EnumBinding: - need_user_runtime_cast_ = False - need_internal_runtime_cast_ = False - - @classmethod - def resolve_inner(cls, resolve_context): - pass - - @classmethod - def request_user_runtime_cast(cls, request): - if request: - cls.need_user_runtime_cast_ = True - request.acknowledge() - - @classmethod - def request_internal_runtime_cast(cls): - cls.need_internal_runtime_cast_ = True - - @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 - def generate_type_builder(writer, generate_context): - enum = json_typable["enum"] - helper.write_doc(writer) - enum_name = fixed_type_name.class_name - fixed_type_name.output_comment(writer) - writer.newline("struct ") - writer.append(enum_name) - writer.append(" {\n") - writer.newline(" enum Enum {\n") - for enum_item in enum: - enum_pos = EnumConstants.add_constant(enum_item) - - item_c_name = fix_camel_case(enum_item) - if item_c_name in TYPE_NAME_FIX_MAP: - item_c_name = TYPE_NAME_FIX_MAP[item_c_name] - writer.newline(" ") - writer.append(item_c_name) - writer.append(" = ") - writer.append("%s" % enum_pos) - writer.append(",\n") - writer.newline(" };\n") - if enum_binding_cls.need_user_runtime_cast_: - raise Exception("Not yet implemented") - - if enum_binding_cls.need_internal_runtime_cast_: - writer.append("#if %s\n" % VALIDATOR_IFDEF_NAME) - writer.newline(" static void assertCorrectValue(Inspector::InspectorValue* value);\n") - writer.append("#endif // %s\n" % VALIDATOR_IFDEF_NAME) - - validator_writer = generate_context.validator_writer - - domain_fixes = DomainNameFixes.get_fixed_data(context_domain_name) - domain_guard = domain_fixes.get_guard() - if domain_guard: - domain_guard.generate_open(validator_writer) - - validator_writer.newline("void %s%s::assertCorrectValue(Inspector::InspectorValue* value)\n" % (helper.full_name_prefix_for_impl, enum_name)) - validator_writer.newline("{\n") - validator_writer.newline(" WTF::String s;\n") - validator_writer.newline(" bool cast_res = value->asString(&s);\n") - validator_writer.newline(" ASSERT(cast_res);\n") - if len(enum) > 0: - condition_list = [] - for enum_item in enum: - enum_pos = EnumConstants.add_constant(enum_item) - condition_list.append("s == \"%s\"" % enum_item) - validator_writer.newline(" ASSERT(%s);\n" % " || ".join(condition_list)) - validator_writer.newline("}\n") - - if domain_guard: - domain_guard.generate_close(validator_writer) - - validator_writer.newline("\n\n") - - writer.newline("}; // struct ") - writer.append(enum_name) - writer.append("\n") - - @staticmethod - def register_use(forward_listener): - pass - - @staticmethod - def get_generate_pass_id(): - return TypeBuilderPass.MAIN - - return CodeGenerator - - @classmethod - def get_validator_call_text(cls): - return helper.full_name_prefix_for_use + fixed_type_name.class_name + "::assertCorrectValue" - - @classmethod - def get_array_item_c_type_text(cls): - return helper.full_name_prefix_for_use + fixed_type_name.class_name + "::Enum" - - @staticmethod - def get_setter_value_expression_pattern(): - return "Inspector::TypeBuilder::get%sEnumConstantValue(%s)" - - @staticmethod - def reduce_to_raw_type(): - return RawTypes.String - - @staticmethod - def get_type_model(): - return TypeModel.Enum(helper.full_name_prefix_for_use + fixed_type_name.class_name) - - return EnumBinding - else: - if helper.is_ad_hoc: - - class PlainString: - @classmethod - def resolve_inner(cls, resolve_context): - pass - - @staticmethod - def request_user_runtime_cast(request): - raise Exception("Unsupported") - - @staticmethod - def request_internal_runtime_cast(): - pass - - @staticmethod - def get_code_generator(): - return None - - @classmethod - def get_validator_call_text(cls): - return RawTypes.String.get_raw_validator_call_text() - - @staticmethod - def reduce_to_raw_type(): - return RawTypes.String - - @staticmethod - def get_type_model(): - return TypeModel.String - - @staticmethod - def get_setter_value_expression_pattern(): - return None - - @classmethod - def get_array_item_c_type_text(cls): - return cls.reduce_to_raw_type().get_array_item_raw_c_type_text() - - return PlainString - - else: - - class TypedefString: - @classmethod - def resolve_inner(cls, resolve_context): - pass - - @staticmethod - def request_user_runtime_cast(request): - raise Exception("Unsupported") - - @staticmethod - def request_internal_runtime_cast(): - RawTypes.String.request_raw_internal_runtime_cast() - - @staticmethod - def get_code_generator(): - class CodeGenerator: - @staticmethod - def generate_type_builder(writer, generate_context): - helper.write_doc(writer) - fixed_type_name.output_comment(writer) - writer.newline("typedef String ") - writer.append(fixed_type_name.class_name) - writer.append(";\n\n") - - @staticmethod - def register_use(forward_listener): - pass - - @staticmethod - def get_generate_pass_id(): - return TypeBuilderPass.TYPEDEF - - return CodeGenerator - - @classmethod - def get_validator_call_text(cls): - return RawTypes.String.get_raw_validator_call_text() - - @staticmethod - def reduce_to_raw_type(): - return RawTypes.String - - @staticmethod - def get_type_model(): - return TypeModel.ValueType("%s%s" % (helper.full_name_prefix_for_use, fixed_type_name.class_name), True) - - @staticmethod - def get_setter_value_expression_pattern(): - return None - - @classmethod - def get_array_item_c_type_text(cls): - return "const %s%s&" % (helper.full_name_prefix_for_use, fixed_type_name.class_name) - - return TypedefString - - elif json_typable["type"] == "integer": - if helper.is_ad_hoc: - - class PlainInteger: - @classmethod - def resolve_inner(cls, resolve_context): - pass - - @staticmethod - def request_user_runtime_cast(request): - raise Exception("Unsupported") - - @staticmethod - def request_internal_runtime_cast(): - pass - - @staticmethod - def get_code_generator(): - return None - - @classmethod - def get_validator_call_text(cls): - return RawTypes.Int.get_raw_validator_call_text() - - @staticmethod - def reduce_to_raw_type(): - return RawTypes.Int - - @staticmethod - def get_type_model(): - return TypeModel.Int - - @staticmethod - def get_setter_value_expression_pattern(): - return None - - @classmethod - def get_array_item_c_type_text(cls): - return cls.reduce_to_raw_type().get_array_item_raw_c_type_text() - - return PlainInteger - - else: - - class TypedefInteger: - @classmethod - def resolve_inner(cls, resolve_context): - pass - - @staticmethod - def request_user_runtime_cast(request): - raise Exception("Unsupported") - - @staticmethod - def request_internal_runtime_cast(): - RawTypes.Int.request_raw_internal_runtime_cast() - - @staticmethod - def get_code_generator(): - class CodeGenerator: - @staticmethod - def generate_type_builder(writer, generate_context): - helper.write_doc(writer) - fixed_type_name.output_comment(writer) - writer.newline("typedef int ") - writer.append(fixed_type_name.class_name) - writer.append(";\n\n") - - @staticmethod - def register_use(forward_listener): - pass - - @staticmethod - def get_generate_pass_id(): - return TypeBuilderPass.TYPEDEF - - return CodeGenerator - - @classmethod - def get_validator_call_text(cls): - return RawTypes.Int.get_raw_validator_call_text() - - @staticmethod - def reduce_to_raw_type(): - return RawTypes.Int - - @staticmethod - def get_type_model(): - return TypeModel.Int - - @staticmethod - def get_setter_value_expression_pattern(): - return None - - @classmethod - def get_array_item_c_type_text(cls): - return helper.full_name_prefix_for_use + fixed_type_name.class_name - - return TypedefInteger - - elif json_typable["type"] == "object": - if "properties" in json_typable: - - class ClassBinding: - resolve_data_ = None - need_user_runtime_cast_ = False - need_internal_runtime_cast_ = False - - @classmethod - def resolve_inner(cls, resolve_context): - if cls.resolve_data_: - return - - properties = json_typable["properties"] - main = [] - optional = [] - - ad_hoc_type_list = [] - - for prop in properties: - prop_name = prop["name"] - ad_hoc_type_context = cls.AdHocTypeContextImpl(prop_name, fixed_type_name.class_name, resolve_context, ad_hoc_type_list, helper.full_name_prefix_for_impl) - binding = resolve_param_type(prop, context_domain_name, ad_hoc_type_context) - - code_generator = binding.get_code_generator() - if code_generator: - code_generator.register_use(resolve_context.forward_listener) - - class PropertyData: - param_type_binding = binding - p = prop - - if prop.get("optional"): - optional.append(PropertyData) - else: - main.append(PropertyData) - - class ResolveData: - main_properties = main - optional_properties = optional - ad_hoc_types = ad_hoc_type_list - - cls.resolve_data_ = ResolveData - - for ad_hoc in ad_hoc_type_list: - ad_hoc.resolve_inner(resolve_context) - - @classmethod - def request_user_runtime_cast(cls, request): - if not request: - return - cls.need_user_runtime_cast_ = True - request.acknowledge() - cls.request_internal_runtime_cast() - - @classmethod - def request_internal_runtime_cast(cls): - if cls.need_internal_runtime_cast_: - return - cls.need_internal_runtime_cast_ = True - for p in cls.resolve_data_.main_properties: - p.param_type_binding.request_internal_runtime_cast() - for p in cls.resolve_data_.optional_properties: - p.param_type_binding.request_internal_runtime_cast() - - @classmethod - def get_code_generator(class_binding_cls): - class CodeGenerator: - @classmethod - def generate_type_builder(cls, writer, generate_context): - resolve_data = class_binding_cls.resolve_data_ - helper.write_doc(writer) - class_name = fixed_type_name.class_name - - is_open_type = (context_domain_name + "." + class_name) in TYPES_WITH_OPEN_FIELD_LIST_SET - - fixed_type_name.output_comment(writer) - writer.newline("class ") - writer.append(class_name) - writer.append(" : public ") - if is_open_type: - writer.append("Inspector::InspectorObject") - else: - writer.append("Inspector::InspectorObjectBase") - writer.append(" {\n") - writer.newline("public:\n") - ad_hoc_type_writer = writer.insert_writer(" ") - - for ad_hoc_type in resolve_data.ad_hoc_types: - code_generator = ad_hoc_type.get_code_generator() - if code_generator: - code_generator.generate_type_builder(ad_hoc_type_writer, generate_context) - - writer.newline_multiline( -""" enum { - NoFieldsSet = 0, -""") - - state_enum_items = [] - if len(resolve_data.main_properties) > 0: - pos = 0 - for prop_data in resolve_data.main_properties: - item_name = Capitalizer.lower_camel_case_to_upper(prop_data.p["name"]) + "Set" - state_enum_items.append(item_name) - writer.newline(" %s = 1 << %s,\n" % (item_name, pos)) - pos += 1 - all_fields_set_value = "(" + (" | ".join(state_enum_items)) + ")" - else: - all_fields_set_value = "0" - - writer.newline_multiline(CodeGeneratorInspectorStrings.class_binding_builder_part_1 - % (all_fields_set_value, class_name, class_name)) - - pos = 0 - for prop_data in resolve_data.main_properties: - prop_name = prop_data.p["name"] - - param_type_binding = prop_data.param_type_binding - param_raw_type = param_type_binding.reduce_to_raw_type() - - writer.newline_multiline(CodeGeneratorInspectorStrings.class_binding_builder_part_2 - % (state_enum_items[pos], - Capitalizer.lower_camel_case_to_upper(prop_name), - param_type_binding.get_type_model().get_input_param_type_text(), - state_enum_items[pos], prop_name, - param_raw_type.get_setter_name(), prop_name, - format_setter_value_expression(param_type_binding, "value"), - state_enum_items[pos])) - - pos += 1 - - writer.newline_multiline(CodeGeneratorInspectorStrings.class_binding_builder_part_3 - % (class_name, class_name, class_name, class_name, class_name)) - - writer.newline(" /*\n") - writer.newline(" * Synthetic constructor:\n") - writer.newline(" * RefPtr<%s> result = %s::create()" % (class_name, class_name)) - for prop_data in resolve_data.main_properties: - writer.append_multiline("\n * .set%s(...)" % Capitalizer.lower_camel_case_to_upper(prop_data.p["name"])) - writer.append_multiline(";\n */\n") - - writer.newline_multiline(CodeGeneratorInspectorStrings.class_binding_builder_part_4) - - writer.newline(" typedef Inspector::TypeBuilder::StructItemTraits ItemTraits;\n") - - for prop_data in resolve_data.optional_properties: - prop_name = prop_data.p["name"] - param_type_binding = prop_data.param_type_binding - setter_name = "set%s" % Capitalizer.lower_camel_case_to_upper(prop_name) - - writer.append_multiline("\n void %s" % setter_name) - writer.append("(%s value)\n" % param_type_binding.get_type_model().get_input_param_type_text()) - writer.newline(" {\n") - writer.newline(" this->set%s(ASCIILiteral(\"%s\"), %s);\n" - % (param_type_binding.reduce_to_raw_type().get_setter_name(), prop_data.p["name"], - format_setter_value_expression(param_type_binding, "value"))) - writer.newline(" }\n") - - - if setter_name in INSPECTOR_OBJECT_SETTER_NAMES: - writer.newline(" using Inspector::InspectorObjectBase::%s;\n\n" % setter_name) - - if class_binding_cls.need_user_runtime_cast_: - writer.newline(" static PassRefPtr<%s> runtimeCast(PassRefPtr<Inspector::InspectorValue> value)\n" % class_name) - writer.newline(" {\n") - writer.newline(" RefPtr<Inspector::InspectorObject> object;\n") - writer.newline(" bool castRes = value->asObject(&object);\n") - writer.newline(" ASSERT_UNUSED(castRes, castRes);\n") - writer.append("#if %s\n" % VALIDATOR_IFDEF_NAME) - writer.newline(" assertCorrectValue(object.get());\n") - writer.append("#endif // %s\n" % VALIDATOR_IFDEF_NAME) - writer.newline(" COMPILE_ASSERT(sizeof(%s) == sizeof(Inspector::InspectorObjectBase), type_cast_problem);\n" % class_name) - writer.newline(" return static_cast<%s*>(static_cast<Inspector::InspectorObjectBase*>(object.get()));\n" % class_name) - writer.newline(" }\n") - writer.append("\n") - - if class_binding_cls.need_internal_runtime_cast_: - writer.append("#if %s\n" % VALIDATOR_IFDEF_NAME) - writer.newline(" static %s void assertCorrectValue(Inspector::InspectorValue* value);\n" % INSPECTOR_TYPES_GENERATOR_CONFIG_MAP[output_type]["export_macro"]) - writer.append("#endif // %s\n" % VALIDATOR_IFDEF_NAME) - - closed_field_set = (context_domain_name + "." + class_name) not in TYPES_WITH_OPEN_FIELD_LIST_SET - - validator_writer = generate_context.validator_writer - - domain_fixes = DomainNameFixes.get_fixed_data(context_domain_name) - domain_guard = domain_fixes.get_guard() - if domain_guard: - domain_guard.generate_open(validator_writer) - - validator_writer.newline("void %s%s::assertCorrectValue(Inspector::InspectorValue* value)\n" % (helper.full_name_prefix_for_impl, class_name)) - validator_writer.newline("{\n") - validator_writer.newline(" RefPtr<InspectorObject> object;\n") - validator_writer.newline(" bool castRes = value->asObject(&object);\n") - validator_writer.newline(" ASSERT_UNUSED(castRes, castRes);\n") - for prop_data in resolve_data.main_properties: - validator_writer.newline(" {\n") - it_name = "%sPos" % prop_data.p["name"] - validator_writer.newline(" InspectorObject::iterator %s;\n" % it_name) - validator_writer.newline(" %s = object->find(\"%s\");\n" % (it_name, prop_data.p["name"])) - validator_writer.newline(" ASSERT(%s != object->end());\n" % it_name) - validator_writer.newline(" %s(%s->value.get());\n" % (prop_data.param_type_binding.get_validator_call_text(), it_name)) - validator_writer.newline(" }\n") - - if closed_field_set: - validator_writer.newline(" int foundPropertiesCount = %s;\n" % len(resolve_data.main_properties)) - - for prop_data in resolve_data.optional_properties: - validator_writer.newline(" {\n") - it_name = "%sPos" % prop_data.p["name"] - validator_writer.newline(" InspectorObject::iterator %s;\n" % it_name) - validator_writer.newline(" %s = object->find(\"%s\");\n" % (it_name, prop_data.p["name"])) - validator_writer.newline(" if (%s != object->end()) {\n" % it_name) - validator_writer.newline(" %s(%s->value.get());\n" % (prop_data.param_type_binding.get_validator_call_text(), it_name)) - if closed_field_set: - validator_writer.newline(" ++foundPropertiesCount;\n") - validator_writer.newline(" }\n") - validator_writer.newline(" }\n") - - if closed_field_set: - validator_writer.newline(" if (foundPropertiesCount != object->size())\n") - validator_writer.newline(" FATAL(\"Unexpected properties in object: %s\\n\", object->toJSONString().ascii().data());\n") - validator_writer.newline("}\n") - - if domain_guard: - domain_guard.generate_close(validator_writer) - - validator_writer.newline("\n\n") - - if is_open_type: - cpp_writer = generate_context.cpp_writer - writer.append("\n") - writer.newline(" // Property names for type generated as open.\n") - for prop_data in resolve_data.main_properties + resolve_data.optional_properties: - prop_name = prop_data.p["name"] - prop_field_name = Capitalizer.lower_camel_case_to_upper(prop_name) - writer.newline(" static const char* %s;\n" % (prop_field_name)) - cpp_writer.newline("const char* %s%s::%s = \"%s\";\n" % (helper.full_name_prefix_for_impl, class_name, prop_field_name, prop_name)) - - - writer.newline("};\n\n") - - @staticmethod - def generate_forward_declaration(writer): - class_name = fixed_type_name.class_name - writer.newline("class ") - writer.append(class_name) - writer.append(";\n") - - @staticmethod - def register_use(forward_listener): - helper.add_to_forward_listener(forward_listener) - - @staticmethod - def get_generate_pass_id(): - return TypeBuilderPass.MAIN - - return CodeGenerator - - @staticmethod - def get_validator_call_text(): - return helper.full_name_prefix_for_use + fixed_type_name.class_name + "::assertCorrectValue" - - @classmethod - def get_array_item_c_type_text(cls): - return helper.full_name_prefix_for_use + fixed_type_name.class_name - - @staticmethod - def get_setter_value_expression_pattern(): - return None - - @staticmethod - def reduce_to_raw_type(): - return RawTypes.Object - - @staticmethod - def get_type_model(): - return TypeModel.RefPtrBased(helper.full_name_prefix_for_use + fixed_type_name.class_name) - - class AdHocTypeContextImpl: - def __init__(self, property_name, class_name, resolve_context, ad_hoc_type_list, parent_full_name_prefix): - self.property_name = property_name - self.class_name = class_name - self.resolve_context = resolve_context - self.ad_hoc_type_list = ad_hoc_type_list - self.container_full_name_prefix = parent_full_name_prefix + class_name + "::" - self.container_relative_name_prefix = "" - - def get_type_name_fix(self): - class NameFix: - class_name = Capitalizer.lower_camel_case_to_upper(self.property_name) - - @staticmethod - def output_comment(writer): - writer.newline("// Named after property name '%s' while generating %s.\n" % (self.property_name, self.class_name)) - - return NameFix - - def add_type(self, binding): - self.ad_hoc_type_list.append(binding) - - return ClassBinding - else: - - class PlainObjectBinding: - @classmethod - def resolve_inner(cls, resolve_context): - pass - - @staticmethod - def request_user_runtime_cast(request): - pass - - @staticmethod - def request_internal_runtime_cast(): - RawTypes.Object.request_raw_internal_runtime_cast() - - @staticmethod - def get_code_generator(): - pass - - @staticmethod - def get_validator_call_text(): - return "RuntimeCastHelper::assertType<InspectorValue::TypeObject>" - - @classmethod - def get_array_item_c_type_text(cls): - return cls.reduce_to_raw_type().get_array_item_raw_c_type_text() - - @staticmethod - def get_setter_value_expression_pattern(): - return None - - @staticmethod - def reduce_to_raw_type(): - return RawTypes.Object - - @staticmethod - def get_type_model(): - return TypeModel.Object - - return PlainObjectBinding - elif json_typable["type"] == "array": - if "items" in json_typable: - - ad_hoc_types = [] - - class AdHocTypeContext: - container_full_name_prefix = "<not yet defined>" - container_relative_name_prefix = "" - - @staticmethod - def get_type_name_fix(): - return fixed_type_name - - @staticmethod - def add_type(binding): - ad_hoc_types.append(binding) - - item_binding = resolve_param_type(json_typable["items"], context_domain_name, AdHocTypeContext) - - class ArrayBinding: - resolve_data_ = None - need_internal_runtime_cast_ = False - - @classmethod - def resolve_inner(cls, resolve_context): - if cls.resolve_data_: - return - - class ResolveData: - item_type_binding = item_binding - ad_hoc_type_list = ad_hoc_types - - cls.resolve_data_ = ResolveData - - for t in ad_hoc_types: - t.resolve_inner(resolve_context) - - @classmethod - def request_user_runtime_cast(cls, request): - raise Exception("Not implemented yet") - - @classmethod - def request_internal_runtime_cast(cls): - if cls.need_internal_runtime_cast_: - return - cls.need_internal_runtime_cast_ = True - cls.resolve_data_.item_type_binding.request_internal_runtime_cast() - - @classmethod - def get_code_generator(array_binding_cls): - - class CodeGenerator: - @staticmethod - def generate_type_builder(writer, generate_context): - ad_hoc_type_writer = writer - - resolve_data = array_binding_cls.resolve_data_ - - for ad_hoc_type in resolve_data.ad_hoc_type_list: - code_generator = ad_hoc_type.get_code_generator() - if code_generator: - code_generator.generate_type_builder(ad_hoc_type_writer, generate_context) - - @staticmethod - def generate_forward_declaration(writer): - pass - - @staticmethod - def register_use(forward_listener): - item_code_generator = item_binding.get_code_generator() - if item_code_generator: - item_code_generator.register_use(forward_listener) - - @staticmethod - def get_generate_pass_id(): - return TypeBuilderPass.MAIN - - return CodeGenerator - - @classmethod - def get_validator_call_text(cls): - return cls.get_array_item_c_type_text() + "::assertCorrectValue" - - @classmethod - def get_array_item_c_type_text(cls): - return replace_right_shift("Inspector::TypeBuilder::Array<%s>" % cls.resolve_data_.item_type_binding.get_array_item_c_type_text()) - - @staticmethod - def get_setter_value_expression_pattern(): - return None - - @staticmethod - def reduce_to_raw_type(): - return RawTypes.Array - - @classmethod - def get_type_model(cls): - return TypeModel.RefPtrBased(cls.get_array_item_c_type_text()) - - return ArrayBinding - else: - # Fall-through to raw type. - pass - - raw_type = RawTypes.get(json_typable["type"]) - - return RawTypeBinding(raw_type) - - -class RawTypeBinding: - def __init__(self, raw_type): - self.raw_type_ = raw_type - - def resolve_inner(self, resolve_context): - pass - - def request_user_runtime_cast(self, request): - raise Exception("Unsupported") - - def request_internal_runtime_cast(self): - self.raw_type_.request_raw_internal_runtime_cast() - - def get_code_generator(self): - return None - - def get_validator_call_text(self): - return self.raw_type_.get_raw_validator_call_text() - - def get_array_item_c_type_text(self): - return self.raw_type_.get_array_item_raw_c_type_text() - - def get_setter_value_expression_pattern(self): - return None - - def reduce_to_raw_type(self): - return self.raw_type_ - - def get_type_model(self): - return self.raw_type_.get_raw_type_model() - - -class TypeData(object): - def __init__(self, json_type, json_domain, domain_data): - self.json_type_ = json_type - self.json_domain_ = json_domain - self.domain_data_ = domain_data - - if "type" not in json_type: - raise Exception("Unknown type") - - json_type_name = json_type["type"] - self.raw_type_ = RawTypes.get(json_type_name) - self.binding_being_resolved_ = False - self.binding_ = None - - def get_raw_type(self): - return self.raw_type_ - - def get_binding(self): - if not self.binding_: - if self.binding_being_resolved_: - raise Exception("Type %s is already being resolved" % self.json_type_["type"]) - # Resolve only lazily, because resolving one named type may require resolving some other named type. - self.binding_being_resolved_ = True - try: - self.binding_ = TypeBindings.create_named_type_declaration(self.json_type_, self.json_domain_["domain"], self) - finally: - self.binding_being_resolved_ = False - - return self.binding_ - - def get_json_type(self): - return self.json_type_ - - def get_name(self): - return self.json_type_["id"] - - def get_domain_name(self): - return self.json_domain_["domain"] - - -class DomainData: - def __init__(self, json_domain): - self.json_domain = json_domain - self.types_ = [] - - def add_type(self, type_data): - self.types_.append(type_data) - - def name(self): - return self.json_domain["domain"] - - def types(self): - return self.types_ - - -class TypeMap: - def __init__(self, api, dependency_api): - self.map_ = {} - self.domains_ = [] - self.domains_to_generate_ = [] - for json_domain in api["domains"]: - self.add_domain(json_domain, True) - for json_domain in dependency_api["domains"]: - self.add_domain(json_domain, False) - - def add_domain(self, json_domain, should_generate): - domain_name = json_domain["domain"] - - domain_map = {} - self.map_[domain_name] = domain_map - - domain_data = DomainData(json_domain) - self.domains_.append(domain_data) - - if should_generate: - # FIXME: The order of types should not matter. The generated code should work regardless of the order of types. - if domain_name == "Page": - self.domains_to_generate_.insert(0, domain_data) - else: - self.domains_to_generate_.append(domain_data) - - if "types" in json_domain: - for json_type in json_domain["types"]: - type_name = json_type["id"] - type_data = TypeData(json_type, json_domain, domain_data) - domain_map[type_name] = type_data - domain_data.add_type(type_data) - - def domains(self): - return self.domains_ - - def domains_to_generate(self): - return self.domains_to_generate_ - - def get(self, domain_name, type_name): - return self.map_[domain_name][type_name] - - -def resolve_param_type(json_parameter, scope_domain_name, ad_hoc_type_context): - if "$ref" in json_parameter: - json_ref = json_parameter["$ref"] - type_data = get_ref_data(json_ref, scope_domain_name) - return type_data.get_binding() - elif "type" in json_parameter: - result = TypeBindings.create_ad_hoc_type_declaration(json_parameter, scope_domain_name, ad_hoc_type_context) - ad_hoc_type_context.add_type(result) - return result - else: - raise Exception("Unknown type") - - -def resolve_param_raw_type(json_parameter, scope_domain_name): - if "$ref" in json_parameter: - json_ref = json_parameter["$ref"] - type_data = get_ref_data(json_ref, scope_domain_name) - return type_data.get_raw_type() - elif "type" in json_parameter: - json_type = json_parameter["type"] - return RawTypes.get(json_type) - else: - raise Exception("Unknown type") - - -def get_ref_data(json_ref, scope_domain_name): - dot_pos = json_ref.find(".") - if dot_pos == -1: - domain_name = scope_domain_name - type_name = json_ref - else: - domain_name = json_ref[:dot_pos] - type_name = json_ref[dot_pos + 1:] - - return type_map.get(domain_name, type_name) - - -input_file = open(input_json_filename, "r") -json_string = input_file.read() -json_api = json.loads(json_string) -input_file.close() -if not "domains" in json_api: - json_api = {"domains": [json_api]} - -dependency_api = {"domains": []} -for dependency_json_filename in dependency_json_filenames: - dependency_input_file = open(dependency_json_filename, "r") - dependency_json_string = dependency_input_file.read() - dependency_json_api = json.loads(dependency_json_string) - dependency_input_file.close() - if not "domains" in dependency_json_api: - dependency_json_api = {"domains": [dependency_json_api]} - dependency_api["domains"] += dependency_json_api["domains"] - - -class Templates: - def get_this_script_path_(absolute_path): - absolute_path = os.path.abspath(absolute_path) - components = [] - - def fill_recursive(path_part, depth): - if depth <= 0 or path_part == '/': - return - fill_recursive(os.path.dirname(path_part), depth - 1) - components.append(os.path.basename(path_part)) - - # Typical path is /Source/WebCore/inspector/CodeGeneratorInspector.py - # Let's take 4 components from the real path then. - fill_recursive(absolute_path, 4) - - return "/".join(components) - - file_header_ = ("// File is generated by %s\n\n" % get_this_script_path_(sys.argv[0]) + -"""// Copyright (c) 2013 Apple Inc. All Rights Reserved. -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -""") - - frontend_domain_class = string.Template(CodeGeneratorInspectorStrings.frontend_domain_class) - backend_dispatcher_constructor = string.Template(CodeGeneratorInspectorStrings.backend_dispatcher_constructor) - backend_dispatcher_dispatch_method = string.Template(CodeGeneratorInspectorStrings.backend_dispatcher_dispatch_method) - backend_dispatcher_dispatch_method_simple = string.Template(CodeGeneratorInspectorStrings.backend_dispatcher_dispatch_method_simple) - backend_method = string.Template(CodeGeneratorInspectorStrings.backend_method) - frontend_method = string.Template(CodeGeneratorInspectorStrings.frontend_method) - callback_method = string.Template(CodeGeneratorInspectorStrings.callback_method) - frontend_h = string.Template(file_header_ + CodeGeneratorInspectorStrings.frontend_h) - backend_h = string.Template(file_header_ + CodeGeneratorInspectorStrings.backend_h) - backend_cpp = string.Template(file_header_ + CodeGeneratorInspectorStrings.backend_cpp) - frontend_cpp = string.Template(file_header_ + CodeGeneratorInspectorStrings.frontend_cpp) - typebuilder_h = string.Template(file_header_ + CodeGeneratorInspectorStrings.typebuilder_h) - typebuilder_cpp = string.Template(file_header_ + CodeGeneratorInspectorStrings.typebuilder_cpp) - backend_js = string.Template(file_header_ + CodeGeneratorInspectorStrings.backend_js) - param_container_access_code = CodeGeneratorInspectorStrings.param_container_access_code - - - - - -type_map = TypeMap(json_api, dependency_api) - - -class NeedRuntimeCastRequest: - def __init__(self): - self.ack_ = None - - def acknowledge(self): - self.ack_ = True - - def is_acknowledged(self): - return self.ack_ - - -def resolve_all_types(): - runtime_cast_generate_requests = {} - for type_name in TYPES_WITH_RUNTIME_CAST_SET: - runtime_cast_generate_requests[type_name] = NeedRuntimeCastRequest() - - class ForwardListener: - type_data_set = set() - already_declared_set = set() - - @classmethod - def add_type_data(cls, type_data): - if type_data not in cls.already_declared_set: - cls.type_data_set.add(type_data) - - class ResolveContext: - forward_listener = ForwardListener - - for domain_data in type_map.domains(): - for type_data in domain_data.types(): - binding = type_data.get_binding() - binding.resolve_inner(ResolveContext) - # Do not generate forwards for this type any longer. - ForwardListener.already_declared_set.add(type_data) - - for domain_data in type_map.domains(): - for type_data in domain_data.types(): - full_type_name = "%s.%s" % (type_data.get_domain_name(), type_data.get_name()) - request = runtime_cast_generate_requests.pop(full_type_name, None) - binding = type_data.get_binding() - if request: - binding.request_user_runtime_cast(request) - - if request and not request.is_acknowledged(): - raise Exception("Failed to generate runtimeCast in " + full_type_name) - - # FIXME: This assumes all the domains are processed at once. Change this verification - # to only verify runtime casts for the domains being generated. - # if verification: - # for full_type_name in runtime_cast_generate_requests: - # raise Exception("Failed to generate runtimeCast. Type " + full_type_name + " not found") - - return ForwardListener - - -global_forward_listener = resolve_all_types() - - -def get_annotated_type_text(raw_type, annotated_type): - if annotated_type != raw_type: - return "/*%s*/ %s" % (annotated_type, raw_type) - else: - return raw_type - - -def format_setter_value_expression(param_type_binding, value_ref): - pattern = param_type_binding.get_setter_value_expression_pattern() - if pattern: - return pattern % (INSPECTOR_TYPES_GENERATOR_CONFIG_MAP[output_type]["prefix"], value_ref) - else: - return value_ref - - -class Generator: - frontend_domain_class_lines = [] - - backend_method_implementation_list = [] - frontend_method_list = [] - backend_js_domain_initializer_list = [] - - backend_handler_interface_list = [] - backend_handler_implementation_list = [] - backend_dispatcher_interface_list = [] - type_builder_fragments = [] - type_builder_forwards = [] - validator_impl_list = [] - type_builder_impl_list = [] - - - @staticmethod - def go(): - Generator.process_types(type_map) - - first_cycle_guardable_list_list = [ - Generator.backend_method_implementation_list, - Generator.backend_handler_interface_list, - Generator.backend_handler_implementation_list, - Generator.backend_dispatcher_interface_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) - - domain_guard = domain_fixes.get_guard() - - if domain_guard: - for l in first_cycle_guardable_list_list: - domain_guard.generate_open(l) - - frontend_method_declaration_lines = [] - - if ("commands" in json_domain or "events" in json_domain): - Generator.backend_js_domain_initializer_list.append("// %s.\n" % domain_name) - if not domain_fixes.skip_js_bind: - Generator.backend_js_domain_initializer_list.append("InspectorBackend.register%sDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, \"%s\");\n" % (domain_name, domain_name)) - - if "types" in json_domain: - for json_type in json_domain["types"]: - if "type" in json_type and json_type["type"] == "string" and "enum" in json_type: - enum_name = "%s.%s" % (domain_name, json_type["id"]) - Generator.process_enum(json_type, enum_name) - elif json_type["type"] == "object": - if "properties" in json_type: - for json_property in json_type["properties"]: - if "type" in json_property and json_property["type"] == "string" and "enum" in json_property: - enum_name = "%s.%s%s" % (domain_name, json_type["id"], to_title_case(json_property["name"])) - Generator.process_enum(json_property, enum_name) - - if "events" in json_domain: - if domain_guard: - domain_guard.generate_open(Generator.frontend_method_list) - domain_guard.generate_open(Generator.frontend_domain_class_lines) - - for json_event in json_domain["events"]: - Generator.process_event(json_event, domain_name, frontend_method_declaration_lines) - - Generator.frontend_domain_class_lines.append(Templates.frontend_domain_class.substitute(None, - exportMacro=INSPECTOR_TYPES_GENERATOR_CONFIG_MAP[output_type]["export_macro"], - domainClassName="Inspector%sFrontendDispatcher" % domain_name, - frontendDomainMethodDeclarations="".join(flatten_list(frontend_method_declaration_lines)))) - - if domain_guard: - domain_guard.generate_close(Generator.frontend_method_list) - domain_guard.generate_close(Generator.frontend_domain_class_lines) - - dispatcher_name = "Inspector" + Capitalizer.lower_camel_case_to_upper(domain_name) + "BackendDispatcher" - agent_interface_name = dispatcher_name + "Handler" - - if "commands" in json_domain: - Generator.backend_dispatcher_interface_list.append("class %s %s final : public Inspector::InspectorSupplementalBackendDispatcher {\n" % (INSPECTOR_TYPES_GENERATOR_CONFIG_MAP[output_type]["export_macro"], dispatcher_name)) - Generator.backend_dispatcher_interface_list.append("public:\n") - Generator.backend_dispatcher_interface_list.append(" static PassRefPtr<%s> create(Inspector::InspectorBackendDispatcher*, %s*);\n" % (dispatcher_name, agent_interface_name)) - Generator.backend_dispatcher_interface_list.append(" virtual void dispatch(long callId, const String& method, PassRefPtr<Inspector::InspectorObject> message) override;\n") - Generator.backend_dispatcher_interface_list.append("private:\n") - - Generator.backend_handler_interface_list.append("class %s %s {\n" % (INSPECTOR_TYPES_GENERATOR_CONFIG_MAP[output_type]["export_macro"], agent_interface_name)) - Generator.backend_handler_interface_list.append("public:\n") - - backend_method_count = len(Generator.backend_method_implementation_list) - - dispatcher_if_chain = [] - dispatcher_commands_list = [] - for json_command in json_domain["commands"]: - Generator.process_command(json_command, domain_name, agent_interface_name, dispatcher_name, dispatcher_if_chain, dispatcher_commands_list) - - Generator.backend_handler_interface_list.append("protected:\n") - Generator.backend_handler_interface_list.append(" virtual ~%s();\n" % agent_interface_name) - Generator.backend_handler_interface_list.append("};\n\n") - - Generator.backend_handler_implementation_list.append("%s::~%s() { }\n" % (agent_interface_name, agent_interface_name)) - - Generator.backend_dispatcher_interface_list.append("private:\n") - Generator.backend_dispatcher_interface_list.append(" %s(Inspector::InspectorBackendDispatcher*, %s*);\n" % (dispatcher_name, agent_interface_name)) - Generator.backend_dispatcher_interface_list.append(" %s* m_agent;\n" % agent_interface_name) - Generator.backend_dispatcher_interface_list.append("};\n\n") - - Generator.backend_method_implementation_list.insert(backend_method_count, Templates.backend_dispatcher_constructor.substitute(None, - domainName=domain_name, - dispatcherName=dispatcher_name, - agentName=agent_interface_name)) - - if len(json_domain["commands"]) <= 5: - Generator.backend_method_implementation_list.insert(backend_method_count + 1, Templates.backend_dispatcher_dispatch_method_simple.substitute(None, - domainName=domain_name, - dispatcherName=dispatcher_name, - ifChain="\n".join(dispatcher_if_chain))) - else: - Generator.backend_method_implementation_list.insert(backend_method_count + 1, Templates.backend_dispatcher_dispatch_method.substitute(None, - domainName=domain_name, - dispatcherName=dispatcher_name, - dispatcherCommands="\n".join(dispatcher_commands_list))) - - if domain_guard: - for l in reversed(first_cycle_guardable_list_list): - domain_guard.generate_close(l) - Generator.backend_js_domain_initializer_list.append("\n") - - @staticmethod - def process_enum(json_enum, enum_name): - enum_members = [] - for member in json_enum["enum"]: - enum_members.append("%s: \"%s\"" % (fix_camel_case(member), member)) - - Generator.backend_js_domain_initializer_list.append("InspectorBackend.registerEnum(\"%s\", {%s});\n" % ( - enum_name, ", ".join(enum_members))) - - @staticmethod - def process_event(json_event, domain_name, frontend_method_declaration_lines): - event_name = json_event["name"] - - ad_hoc_type_output = [] - frontend_method_declaration_lines.append(ad_hoc_type_output) - ad_hoc_type_writer = Writer(ad_hoc_type_output, " ") - - decl_parameter_list = [] - - json_parameters = json_event.get("parameters") - Generator.generate_send_method(json_parameters, event_name, domain_name, ad_hoc_type_writer, - decl_parameter_list, - Generator.EventMethodStructTemplate, - Generator.frontend_method_list, Templates.frontend_method, {"eventName": event_name}) - - backend_js_event_param_list = [] - if json_parameters: - for parameter in json_parameters: - parameter_name = parameter["name"] - backend_js_event_param_list.append("\"%s\"" % parameter_name) - - frontend_method_declaration_lines.append( - " void %s(%s);\n" % (event_name, ", ".join(decl_parameter_list))) - - Generator.backend_js_domain_initializer_list.append("InspectorBackend.registerEvent(\"%s.%s\", [%s]);\n" % ( - domain_name, event_name, ", ".join(backend_js_event_param_list))) - - class EventMethodStructTemplate: - @staticmethod - def append_prolog(line_list): - line_list.append(" RefPtr<InspectorObject> paramsObject = InspectorObject::create();\n") - - @staticmethod - def append_epilog(line_list): - line_list.append(" jsonMessage->setObject(ASCIILiteral(\"params\"), paramsObject);\n") - - container_name = "paramsObject" - - @staticmethod - def process_command(json_command, domain_name, agent_interface_name, dispatcher_name, dispatcher_if_chain, dispatcher_commands_list): - json_command_name = json_command["name"] - - ad_hoc_type_output = [] - Generator.backend_handler_interface_list.append(ad_hoc_type_output) - ad_hoc_type_writer = Writer(ad_hoc_type_output, " ") - - Generator.backend_dispatcher_interface_list.append(" void %s(long callId, const Inspector::InspectorObject& message);\n" % json_command_name) - - Generator.backend_handler_interface_list.append(" virtual void %s(ErrorString*" % json_command_name) - - if not dispatcher_if_chain: - dispatcher_if_chain.append(" if (method == \"%s\")" % json_command_name) - else: - dispatcher_if_chain.append(" else if (method == \"%s\")" % json_command_name) - dispatcher_if_chain.append(" %s(callId, *message.get());" % json_command_name) - dispatcher_commands_list.append(" { \"%s\", &%s::%s }," % (json_command_name, dispatcher_name, json_command_name)) - - method_in_params_handling = [] - method_dispatch_handling = [] - method_out_params_handling = [] - method_ending_handling = [] - method_request_message_param_name = "" - agent_call_param_list = [] - js_parameters_text = "" - if "parameters" in json_command: - json_params = json_command["parameters"] - method_request_message_param_name = " message" - method_in_params_handling.append(" RefPtr<InspectorArray> protocolErrors = InspectorArray::create();\n") - method_in_params_handling.append(" RefPtr<InspectorObject> paramsContainer = message.getObject(ASCIILiteral(\"params\"));\n") - method_in_params_handling.append(" InspectorObject* paramsContainerPtr = paramsContainer.get();\n") - method_in_params_handling.append(" InspectorArray* protocolErrorsPtr = protocolErrors.get();\n") - js_param_list = [] - - for json_parameter in json_params: - json_param_name = json_parameter["name"] - param_raw_type = resolve_param_raw_type(json_parameter, domain_name) - - getter_name = param_raw_type.get_getter_name() - - 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" - " %s in_%s = InspectorBackendDispatcher::get%s(paramsContainerPtr, ASCIILiteral(\"%s\"), &%s_valueFound, protocolErrorsPtr);\n" % - (json_param_name, non_optional_type_model.get_command_return_pass_model().get_return_var_type(), json_param_name, getter_name, json_param_name, json_param_name)) - param = ", %s_valueFound ? &in_%s : nullptr" % (json_param_name, json_param_name) - # FIXME: pass optional refptr-values as PassRefPtr - formal_param_type_pattern = "const %s*" - else: - code = (" %s in_%s = InspectorBackendDispatcher::get%s(paramsContainerPtr, ASCIILiteral(\"%s\"), nullptr, protocolErrorsPtr);\n" % - (non_optional_type_model.get_command_return_pass_model().get_return_var_type(), json_param_name, getter_name, json_param_name)) - param = ", in_%s" % json_param_name - # FIXME: pass not-optional refptr-values as NonNullPassRefPtr - if param_raw_type.is_heavy_value(): - formal_param_type_pattern = "const %s&" - else: - formal_param_type_pattern = "%s" - - method_in_params_handling.append(code) - agent_call_param_list.append(param) - Generator.backend_handler_interface_list.append(", %s in_%s" % (formal_param_type_pattern % non_optional_type_model.get_command_return_pass_model().get_return_var_type(), json_param_name)) - - js_bind_type = param_raw_type.get_js_bind_type() - js_param_text = "{\"name\": \"%s\", \"type\": \"%s\", \"optional\": %s}" % ( - json_param_name, - js_bind_type, - ("true" if ("optional" in json_parameter and json_parameter["optional"]) else "false")) - - js_param_list.append(js_param_text) - - method_in_params_handling.append(" if (protocolErrors->length()) {\n") - method_in_params_handling.append(" String errorMessage = String::format(\"Some arguments of method '%%s' can't be processed\", \"%s.%s\");\n" % (domain_name, json_command_name)) - method_in_params_handling.append(" m_backendDispatcher->reportProtocolError(&callId, InspectorBackendDispatcher::InvalidParams, errorMessage, protocolErrors.release());\n") - method_in_params_handling.append(" return;\n") - method_in_params_handling.append(" }\n") - method_in_params_handling.append("\n") - - js_parameters_text = ", ".join(js_param_list) - - method_dispatch_handling.append(" ErrorString error;\n") - method_dispatch_handling.append(" RefPtr<InspectorObject> result = InspectorObject::create();\n") - - if json_command.get("async") == True: - callback_name = Capitalizer.lower_camel_case_to_upper(json_command_name) + "Callback" - - callback_output = [] - callback_writer = Writer(callback_output, ad_hoc_type_writer.get_indent()) - - decl_parameter_list = [] - Generator.generate_send_method(json_command.get("returns"), json_command_name, domain_name, ad_hoc_type_writer, - decl_parameter_list, - Generator.CallbackMethodStructTemplate, - Generator.backend_method_implementation_list, Templates.callback_method, - {"callbackName": callback_name, "handlerName": agent_interface_name}) - - callback_writer.newline("class " + callback_name + " : public Inspector::InspectorBackendDispatcher::CallbackBase {\n") - callback_writer.newline("public:\n") - callback_writer.newline(" " + callback_name + "(PassRefPtr<Inspector::InspectorBackendDispatcher>, int id);\n") - callback_writer.newline(" void sendSuccess(" + ", ".join(decl_parameter_list) + ");\n") - callback_writer.newline("};\n") - - ad_hoc_type_output.append(callback_output) - - method_dispatch_handling.append(" RefPtr<%s::%s> callback = adoptRef(new %s::%s(m_backendDispatcher,callId));\n" % (agent_interface_name, callback_name, agent_interface_name, callback_name)) - method_ending_handling.append(" if (error.length()) {\n") - method_ending_handling.append(" callback->disable();\n") - method_ending_handling.append(" m_backendDispatcher->reportProtocolError(&callId, Inspector::InspectorBackendDispatcher::ServerError, error);\n") - method_ending_handling.append(" return;\n") - method_ending_handling.append(" }") - - agent_call_param_list.append(", callback") - Generator.backend_handler_interface_list.append(", PassRefPtr<%s> callback" % callback_name) - elif "returns" in json_command: - has_multiple_returns = len(json_command["returns"]) > 1 - if has_multiple_returns: - method_out_params_handling.append(" if (!error.length()) {\n") - else: - method_out_params_handling.append(" if (!error.length())\n") - - for json_return in json_command["returns"]: - - json_return_name = json_return["name"] - - optional = bool(json_return.get("optional")) - - return_type_binding = Generator.resolve_type_and_generate_ad_hoc(json_return, json_command_name, domain_name, ad_hoc_type_writer, agent_interface_name + "::") - - 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: - type_model = type_model.get_optional() - - code = " %s out_%s;\n" % (type_model.get_command_return_pass_model().get_return_var_type(), json_return_name) - param = ", %sout_%s" % (type_model.get_command_return_pass_model().get_output_argument_prefix(), json_return_name) - var_name = "out_%s" % json_return_name - setter_argument = type_model.get_command_return_pass_model().get_output_to_raw_expression() % var_name - if return_type_binding.get_setter_value_expression_pattern(): - setter_argument = return_type_binding.get_setter_value_expression_pattern() % (INSPECTOR_TYPES_GENERATOR_CONFIG_MAP[output_type]["prefix"], setter_argument) - - cook = " result->set%s(ASCIILiteral(\"%s\"), %s);\n" % (setter_type, json_return_name, setter_argument) - - set_condition_pattern = type_model.get_command_return_pass_model().get_set_return_condition() - if set_condition_pattern: - cook = (" if (%s)\n " % (set_condition_pattern % var_name)) + cook - annotated_type = type_model.get_command_return_pass_model().get_output_parameter_type() - - param_name = "out_%s" % json_return_name - if optional: - param_name = "opt_" + param_name - - Generator.backend_handler_interface_list.append(", %s %s" % (annotated_type, param_name)) - method_out_params_handling.append(cook) - method_dispatch_handling.append(code) - - agent_call_param_list.append(param) - - if has_multiple_returns: - method_out_params_handling.append(" }\n") - method_out_params_handling.append("\n") - - method_dispatch_handling.append(" m_agent->%s(&error%s);\n" % (json_command_name, "".join(agent_call_param_list))) - method_dispatch_handling.append("\n") - - if not method_ending_handling: - method_ending_handling.append(" m_backendDispatcher->sendResponse(callId, result.release(), error);") - - backend_js_reply_param_list = [] - if "returns" in json_command: - for json_return in json_command["returns"]: - json_return_name = json_return["name"] - backend_js_reply_param_list.append("\"%s\"" % json_return_name) - - js_reply_list = "[%s]" % ", ".join(backend_js_reply_param_list) - - Generator.backend_method_implementation_list.append(Templates.backend_method.substitute(None, - dispatcherName=dispatcher_name, - methodName=json_command_name, - requestMessageObject=method_request_message_param_name, - methodInParametersHandling="".join(method_in_params_handling), - methodDispatchHandling="".join(method_dispatch_handling), - methodOutParametersHandling="".join(method_out_params_handling), - methodEndingHandling="".join(method_ending_handling))) - - Generator.backend_js_domain_initializer_list.append("InspectorBackend.registerCommand(\"%s.%s\", [%s], %s);\n" % (domain_name, json_command_name, js_parameters_text, js_reply_list)) - Generator.backend_handler_interface_list.append(") = 0;\n") - - class CallbackMethodStructTemplate: - @staticmethod - def append_prolog(line_list): - pass - - @staticmethod - def append_epilog(line_list): - pass - - container_name = "jsonMessage" - - # Generates common code for event sending and callback response data sending. - @staticmethod - def generate_send_method(parameters, event_name, domain_name, ad_hoc_type_writer, decl_parameter_list, - method_struct_template, - generator_method_list, method_template, template_params): - method_line_list = [] - if parameters: - method_struct_template.append_prolog(method_line_list) - for json_parameter in parameters: - parameter_name = json_parameter["name"] - - param_type_binding = Generator.resolve_type_and_generate_ad_hoc(json_parameter, event_name, domain_name, ad_hoc_type_writer, "") - - raw_type = param_type_binding.reduce_to_raw_type() - raw_type_binding = RawTypeBinding(raw_type) - - optional = bool(json_parameter.get("optional")) - - setter_type = raw_type.get_setter_name() - - type_model = param_type_binding.get_type_model() - raw_type_model = raw_type_binding.get_type_model() - if optional: - type_model = type_model.get_optional() - raw_type_model = raw_type_model.get_optional() - - annotated_type = type_model.get_input_param_type_text() - mode_type_binding = param_type_binding - - decl_parameter_list.append("%s %s" % (annotated_type, parameter_name)) - - setter_argument = raw_type_model.get_event_setter_expression_pattern() % parameter_name - if mode_type_binding.get_setter_value_expression_pattern(): - setter_argument = mode_type_binding.get_setter_value_expression_pattern() % (INSPECTOR_TYPES_GENERATOR_CONFIG_MAP[output_type]["prefix"], setter_argument) - - setter_code = " %s->set%s(ASCIILiteral(\"%s\"), %s);\n" % (method_struct_template.container_name, setter_type, parameter_name, setter_argument) - if optional: - setter_code = (" if (%s)\n " % parameter_name) + setter_code - method_line_list.append(setter_code) - - method_struct_template.append_epilog(method_line_list) - - generator_method_list.append(method_template.substitute(None, - domainName=domain_name, - parameters=", ".join(decl_parameter_list), - code="".join(method_line_list), **template_params)) - - @staticmethod - def resolve_type_and_generate_ad_hoc(json_param, method_name, domain_name, ad_hoc_type_writer, container_relative_name_prefix_param): - param_name = json_param["name"] - ad_hoc_type_list = [] - - class AdHocTypeContext: - container_full_name_prefix = "<not yet defined>" - container_relative_name_prefix = container_relative_name_prefix_param - - @staticmethod - def get_type_name_fix(): - class NameFix: - class_name = Capitalizer.lower_camel_case_to_upper(param_name) - - @staticmethod - def output_comment(writer): - writer.newline("// Named after parameter '%s' while generating command/event %s.\n" % (param_name, method_name)) - - return NameFix - - @staticmethod - def add_type(binding): - ad_hoc_type_list.append(binding) - - type_binding = resolve_param_type(json_param, domain_name, AdHocTypeContext) - - class InterfaceForwardListener: - @staticmethod - def add_type_data(type_data): - pass - - class InterfaceResolveContext: - forward_listener = InterfaceForwardListener - - for type in ad_hoc_type_list: - type.resolve_inner(InterfaceResolveContext) - - class InterfaceGenerateContext: - validator_writer = "not supported in InterfaceGenerateContext" - cpp_writer = validator_writer - - for type in ad_hoc_type_list: - generator = type.get_code_generator() - if generator: - generator.generate_type_builder(ad_hoc_type_writer, InterfaceGenerateContext) - - return type_binding - - @staticmethod - def process_types(type_map): - output = Generator.type_builder_fragments - - class GenerateContext: - validator_writer = Writer(Generator.validator_impl_list, "") - cpp_writer = Writer(Generator.type_builder_impl_list, "") - - def generate_all_domains_code(out, type_data_callback): - writer = Writer(out, "") - for domain_data in type_map.domains_to_generate(): - domain_fixes = DomainNameFixes.get_fixed_data(domain_data.name()) - domain_guard = domain_fixes.get_guard() - - namespace_declared = [] - - def namespace_lazy_generator(): - if not namespace_declared: - if domain_guard: - domain_guard.generate_open(out) - writer.newline("namespace ") - writer.append(domain_data.name()) - writer.append(" {\n") - # What is a better way to change value from outer scope? - namespace_declared.append(True) - return writer - - for type_data in domain_data.types(): - type_data_callback(type_data, namespace_lazy_generator) - - if namespace_declared: - writer.append("} // ") - writer.append(domain_data.name()) - writer.append("\n\n") - - if domain_guard: - domain_guard.generate_close(out) - - def create_type_builder_caller(generate_pass_id): - def call_type_builder(type_data, writer_getter): - code_generator = type_data.get_binding().get_code_generator() - if code_generator and generate_pass_id == code_generator.get_generate_pass_id(): - writer = writer_getter() - - code_generator.generate_type_builder(writer, GenerateContext) - return call_type_builder - - generate_all_domains_code(output, create_type_builder_caller(TypeBuilderPass.MAIN)) - - Generator.type_builder_forwards.append("// Forward declarations.\n") - - def generate_forward_callback(type_data, writer_getter): - if type_data in global_forward_listener.type_data_set: - binding = type_data.get_binding() - binding.get_code_generator().generate_forward_declaration(writer_getter()) - generate_all_domains_code(Generator.type_builder_forwards, generate_forward_callback) - - Generator.type_builder_forwards.append("// End of forward declarations.\n\n") - - Generator.type_builder_forwards.append("// Typedefs.\n") - - generate_all_domains_code(Generator.type_builder_forwards, create_type_builder_caller(TypeBuilderPass.TYPEDEF)) - - Generator.type_builder_forwards.append("// End of typedefs.\n\n") - - -def flatten_list(input): - res = [] - - def fill_recursive(l): - for item in l: - if isinstance(item, list): - fill_recursive(item) - else: - res.append(item) - fill_recursive(input) - return res - - -# A writer that only updates file if it actually changed to better support incremental build. -class SmartOutput: - def __init__(self, file_name): - self.file_name_ = file_name - self.output_ = "" - - def write(self, text): - self.output_ += text - - def close(self): - text_changed = True - self.output_ = self.output_.rstrip() + "\n" - - try: - read_file = open(self.file_name_, "r") - old_text = read_file.read() - read_file.close() - text_changed = old_text != self.output_ - except: - # Ignore, just overwrite by default - pass - - if text_changed or write_always: - out_file = open(self.file_name_, "w") - out_file.write(self.output_) - out_file.close() - - -Generator.go() - -output_file_name_prefix = INSPECTOR_TYPES_GENERATOR_CONFIG_MAP[output_type]["prefix"] - -backend_h_file = SmartOutput(output_header_dirname + ("/Inspector%sBackendDispatchers.h" % output_file_name_prefix)) -backend_cpp_file = SmartOutput(output_cpp_dirname + ("/Inspector%sBackendDispatchers.cpp" % output_file_name_prefix)) - -frontend_h_file = SmartOutput(output_header_dirname + ("/Inspector%sFrontendDispatchers.h" % output_file_name_prefix)) -frontend_cpp_file = SmartOutput(output_cpp_dirname + ("/Inspector%sFrontendDispatchers.cpp" % output_file_name_prefix)) - -typebuilder_h_file = SmartOutput(output_header_dirname + ("/Inspector%sTypeBuilders.h" % output_file_name_prefix)) -typebuilder_cpp_file = SmartOutput(output_cpp_dirname + ("/Inspector%sTypeBuilders.cpp" % output_file_name_prefix)) - -backend_js_file = SmartOutput(output_js_dirname + ("/Inspector%sBackendCommands.js" % output_file_name_prefix)) - - -backend_h_file.write(Templates.backend_h.substitute(None, - outputFileNamePrefix=output_file_name_prefix, - handlerInterfaces="".join(flatten_list(Generator.backend_handler_interface_list)), - dispatcherInterfaces="".join(flatten_list(Generator.backend_dispatcher_interface_list)))) - -backend_cpp_file.write(Templates.backend_cpp.substitute(None, - outputFileNamePrefix=output_file_name_prefix, - handlerImplementations="".join(flatten_list(Generator.backend_handler_implementation_list)), - methods="\n".join(Generator.backend_method_implementation_list))) - -frontend_h_file.write(Templates.frontend_h.substitute(None, - outputFileNamePrefix=output_file_name_prefix, - domainClassList="".join(Generator.frontend_domain_class_lines))) - -frontend_cpp_file.write(Templates.frontend_cpp.substitute(None, - outputFileNamePrefix=output_file_name_prefix, - methods="\n".join(Generator.frontend_method_list))) - -typebuilder_h_file.write(Templates.typebuilder_h.substitute(None, - outputFileNamePrefix=output_file_name_prefix, - typeBuilderDependencies=INSPECTOR_TYPES_GENERATOR_CONFIG_MAP[output_type]["typebuilder_dependency"], - exportMacro=INSPECTOR_TYPES_GENERATOR_CONFIG_MAP[output_type]["export_macro"], - typeBuilders="".join(flatten_list(Generator.type_builder_fragments)), - forwards="".join(Generator.type_builder_forwards), - validatorIfdefName=VALIDATOR_IFDEF_NAME)) - -typebuilder_cpp_file.write(Templates.typebuilder_cpp.substitute(None, - outputFileNamePrefix=output_file_name_prefix, - enumConstantValues=EnumConstants.get_enum_constant_code(), - implCode="".join(flatten_list(Generator.type_builder_impl_list)), - validatorCode="".join(flatten_list(Generator.validator_impl_list)), - validatorIfdefName=VALIDATOR_IFDEF_NAME)) - -backend_js_file.write(Templates.backend_js.substitute(None, - domainInitializers="".join(Generator.backend_js_domain_initializer_list))) - -backend_h_file.close() -backend_cpp_file.close() - -frontend_h_file.close() -frontend_cpp_file.close() - -typebuilder_h_file.close() -typebuilder_cpp_file.close() - -backend_js_file.close() diff --git a/Source/JavaScriptCore/inspector/scripts/CodeGeneratorInspectorStrings.py b/Source/JavaScriptCore/inspector/scripts/CodeGeneratorInspectorStrings.py deleted file mode 100644 index 8de2cb0fa..000000000 --- a/Source/JavaScriptCore/inspector/scripts/CodeGeneratorInspectorStrings.py +++ /dev/null @@ -1,342 +0,0 @@ -# Copyright (c) 2013 Google Inc. All rights reserved. -# Copyright (c) 2013 Apple Inc. All Rights Reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -# This file contains string resources for CodeGeneratorInspector. -# Its syntax is a Python syntax subset, suitable for manual parsing. - -frontend_domain_class = ( -"""class ${exportMacro} ${domainClassName} { -public: - ${domainClassName}(InspectorFrontendChannel* inspectorFrontendChannel) : m_inspectorFrontendChannel(inspectorFrontendChannel) { } -${frontendDomainMethodDeclarations}private: - InspectorFrontendChannel* m_inspectorFrontendChannel; -}; - -""") - -backend_dispatcher_constructor = ( -"""PassRefPtr<${dispatcherName}> ${dispatcherName}::create(InspectorBackendDispatcher* backendDispatcher, ${agentName}* agent) -{ - return adoptRef(new ${dispatcherName}(backendDispatcher, agent)); -} - -${dispatcherName}::${dispatcherName}(InspectorBackendDispatcher* backendDispatcher, ${agentName}* agent) - : InspectorSupplementalBackendDispatcher(backendDispatcher) - , m_agent(agent) -{ - m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("${domainName}"), this); -} -""") - -backend_dispatcher_dispatch_method_simple = ( -"""void ${dispatcherName}::dispatch(long callId, const String& method, PassRefPtr<InspectorObject> message) -{ - Ref<${dispatcherName}> protect(*this); - -${ifChain} - else - m_backendDispatcher->reportProtocolError(&callId, InspectorBackendDispatcher::MethodNotFound, String("'") + "${domainName}" + '.' + method + "' was not found"); -} -""") - -backend_dispatcher_dispatch_method = ( -"""void ${dispatcherName}::dispatch(long callId, const String& method, PassRefPtr<InspectorObject> message) -{ - Ref<${dispatcherName}> protect(*this); - - typedef void (${dispatcherName}::*CallHandler)(long callId, const Inspector::InspectorObject& message); - typedef HashMap<String, CallHandler> DispatchMap; - DEFINE_STATIC_LOCAL(DispatchMap, dispatchMap, ()); - if (dispatchMap.isEmpty()) { - static const struct MethodTable { - const char* name; - CallHandler handler; - } commands[] = { -${dispatcherCommands} - }; - size_t length = WTF_ARRAY_LENGTH(commands); - for (size_t i = 0; i < length; ++i) - dispatchMap.add(commands[i].name, commands[i].handler); - } - - HashMap<String, CallHandler>::iterator it = dispatchMap.find(method); - if (it == dispatchMap.end()) { - m_backendDispatcher->reportProtocolError(&callId, InspectorBackendDispatcher::MethodNotFound, String("'") + "${domainName}" + '.' + method + "' was not found"); - return; - } - - ((*this).*it->value)(callId, *message.get()); -} -""") - -backend_method = ( -"""void ${dispatcherName}::${methodName}(long callId, const InspectorObject&${requestMessageObject}) -{ -${methodInParametersHandling}${methodDispatchHandling}${methodOutParametersHandling}${methodEndingHandling} -} -""") - -frontend_method = ("""void Inspector${domainName}FrontendDispatcher::${eventName}(${parameters}) -{ - RefPtr<InspectorObject> jsonMessage = InspectorObject::create(); - jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("${domainName}.${eventName}")); -${code} - m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString()); -} -""") - -callback_method = ( -"""${handlerName}::${callbackName}::${callbackName}(PassRefPtr<InspectorBackendDispatcher> backendDispatcher, int id) : Inspector::InspectorBackendDispatcher::CallbackBase(backendDispatcher, id) { } - -void ${handlerName}::${callbackName}::sendSuccess(${parameters}) -{ - RefPtr<InspectorObject> jsonMessage = InspectorObject::create(); -${code} sendIfActive(jsonMessage, ErrorString()); -} -""") - -frontend_h = ( -"""#ifndef Inspector${outputFileNamePrefix}FrontendDispatchers_h -#define Inspector${outputFileNamePrefix}FrontendDispatchers_h - -#include "Inspector${outputFileNamePrefix}TypeBuilders.h" -#include <inspector/InspectorFrontendChannel.h> -#include <inspector/InspectorValues.h> -#include <wtf/PassRefPtr.h> -#include <wtf/text/WTFString.h> - -namespace Inspector { - -#if ENABLE(INSPECTOR) - -${domainClassList} - -#endif // ENABLE(INSPECTOR) - -} // namespace Inspector - -#endif // !defined(Inspector${outputFileNamePrefix}FrontendDispatchers_h) -""") - -backend_h = ( -"""#ifndef Inspector${outputFileNamePrefix}BackendDispatchers_h -#define Inspector${outputFileNamePrefix}BackendDispatchers_h - -#include "Inspector${outputFileNamePrefix}TypeBuilders.h" -#include <inspector/InspectorBackendDispatcher.h> -#include <wtf/PassRefPtr.h> -#include <wtf/text/WTFString.h> - -namespace Inspector { - -typedef String ErrorString; - -${handlerInterfaces} - -${dispatcherInterfaces} -} // namespace Inspector - -#endif // !defined(Inspector${outputFileNamePrefix}BackendDispatchers_h) -""") - -backend_cpp = ( -""" -#include "config.h" -#include "Inspector${outputFileNamePrefix}BackendDispatchers.h" - -#if ENABLE(INSPECTOR) - -#include <inspector/InspectorFrontendChannel.h> -#include <inspector/InspectorValues.h> -#include <wtf/text/CString.h> -#include <wtf/text/WTFString.h> - -namespace Inspector { - -${handlerImplementations} - -${methods} -} // namespace Inspector - -#endif // ENABLE(INSPECTOR) -""") - -frontend_cpp = ( -""" - -#include "config.h" -#include "Inspector${outputFileNamePrefix}FrontendDispatchers.h" - -#if ENABLE(INSPECTOR) - -#include <wtf/text/CString.h> -#include <wtf/text/WTFString.h> - -namespace Inspector { - -${methods} - -} // namespace Inspector - -#endif // ENABLE(INSPECTOR) -""") - -typebuilder_h = ( -""" -#ifndef Inspector${outputFileNamePrefix}TypeBuilders_h -#define Inspector${outputFileNamePrefix}TypeBuilders_h - -#if ENABLE(INSPECTOR) - -#include <inspector/InspectorTypeBuilder.h> -${typeBuilderDependencies} -#include <wtf/Assertions.h> -#include <wtf/PassRefPtr.h> - -namespace Inspector { - -namespace TypeBuilder { - -${forwards} - -${exportMacro} String get${outputFileNamePrefix}EnumConstantValue(int code); - -${typeBuilders} -} // namespace TypeBuilder - -} // namespace Inspector - -#endif // ENABLE(INSPECTOR) - -#endif // !defined(Inspector${outputFileNamePrefix}TypeBuilders_h) - -""") - -typebuilder_cpp = ( -""" - -#include "config.h" -#include "Inspector${outputFileNamePrefix}TypeBuilders.h" - -#if ENABLE(INSPECTOR) - -#include <wtf/text/CString.h> - -namespace Inspector { - -namespace TypeBuilder { - -static const char* const enum_constant_values[] = { -${enumConstantValues}}; - -String get${outputFileNamePrefix}EnumConstantValue(int code) { - return enum_constant_values[code]; -} - -} // namespace TypeBuilder - -${implCode} - -#if ${validatorIfdefName} - -${validatorCode} - -#endif // ${validatorIfdefName} - -} // namespace Inspector - -#endif // ENABLE(INSPECTOR) -""") - -backend_js = ( -""" - -${domainInitializers} -""") - -param_container_access_code = """ - RefPtr<InspectorObject> paramsContainer = message.getObject("params"); - InspectorObject* paramsContainerPtr = paramsContainer.get(); - InspectorArray* protocolErrorsPtr = protocolErrors.get(); -""" - -class_binding_builder_part_1 = ( -""" AllFieldsSet = %s - }; - - template<int STATE> - class Builder { - private: - RefPtr<Inspector::InspectorObject> m_result; - - template<int STEP> Builder<STATE | STEP>& castState() - { - return *reinterpret_cast<Builder<STATE | STEP>*>(this); - } - - Builder(PassRefPtr</*%s*/Inspector::InspectorObject> ptr) - { - COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); - m_result = ptr; - } - friend class %s; - public: -""") - -class_binding_builder_part_2 = (""" - Builder<STATE | %s>& set%s(%s value) - { - COMPILE_ASSERT(!(STATE & %s), property_%s_already_set); - m_result->set%s(ASCIILiteral("%s"), %s); - return castState<%s>(); - } -""") - -class_binding_builder_part_3 = (""" - operator RefPtr<%s>& () - { - COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); - COMPILE_ASSERT(sizeof(%s) == sizeof(Inspector::InspectorObject), cannot_cast); - return *reinterpret_cast<RefPtr<%s>*>(&m_result); - } - - PassRefPtr<%s> release() - { - return RefPtr<%s>(*this).release(); - } - }; - -""") - -class_binding_builder_part_4 = ( -""" static Builder<NoFieldsSet> create() - { - return Builder<NoFieldsSet>(Inspector::InspectorObject::create()); - } -""") diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/__init__.py b/Source/JavaScriptCore/inspector/scripts/codegen/__init__.py new file mode 100644 index 000000000..37dbe9436 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/__init__.py @@ -0,0 +1,25 @@ +# Required for Python to search this directory for module files + +from models import * +from generator import * +from cpp_generator import * +from objc_generator import * + +from generate_cpp_alternate_backend_dispatcher_header import * +from generate_cpp_backend_dispatcher_header import * +from generate_cpp_backend_dispatcher_implementation import * +from generate_cpp_frontend_dispatcher_header import * +from generate_cpp_frontend_dispatcher_implementation import * +from generate_cpp_protocol_types_header import * +from generate_cpp_protocol_types_implementation import * +from generate_js_backend_commands import * +from generate_objc_backend_dispatcher_header import * +from generate_objc_backend_dispatcher_implementation import * +from generate_objc_configuration_header import * +from generate_objc_configuration_implementation import * +from generate_objc_frontend_dispatcher_implementation import * +from generate_objc_header import * +from generate_objc_internal_header import * +from generate_objc_protocol_types_implementation import * +from generate_objc_protocol_type_conversions_header import * +from generate_objc_protocol_type_conversions_implementation import * diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/cpp_generator.py b/Source/JavaScriptCore/inspector/scripts/codegen/cpp_generator.py new file mode 100644 index 000000000..c459fcac3 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/cpp_generator.py @@ -0,0 +1,319 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014, 2016 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + +import logging +import os.path +import re + +from generator import ucfirst, Generator +from models import PrimitiveType, ObjectType, ArrayType, EnumType, AliasedType, Frameworks + +log = logging.getLogger('global') + +_PRIMITIVE_TO_CPP_NAME_MAP = { + 'boolean': 'bool', + 'integer': 'int', + 'number': 'double', + 'string': 'String', + 'object': 'Inspector::InspectorObject', + 'array': 'Inspector::InspectorArray', + 'any': 'Inspector::InspectorValue' +} + +class CppGenerator(Generator): + def __init__(self, *args, **kwargs): + Generator.__init__(self, *args, **kwargs) + + def protocol_name(self): + return self.model().framework.setting('cpp_protocol_group', '') + + def helpers_namespace(self): + return '%sHelpers' % self.protocol_name() + + # Miscellaneous text manipulation routines. + @staticmethod + def cpp_getter_method_for_type(_type): + if isinstance(_type, ObjectType): + return 'getObject' + if isinstance(_type, ArrayType): + return 'getArray' + if isinstance(_type, PrimitiveType): + if _type.raw_name() is 'integer': + return 'getInteger' + elif _type.raw_name() is 'number': + return 'getDouble' + elif _type.raw_name() is 'any': + return 'getValue' + else: + return 'get' + ucfirst(_type.raw_name()) + if isinstance(_type, AliasedType): + return CppGenerator.cpp_getter_method_for_type(_type.aliased_type) + if isinstance(_type, EnumType): + return CppGenerator.cpp_getter_method_for_type(_type.primitive_type) + + @staticmethod + def cpp_setter_method_for_type(_type): + if isinstance(_type, ObjectType): + return 'setObject' + if isinstance(_type, ArrayType): + return 'setArray' + if isinstance(_type, PrimitiveType): + if _type.raw_name() is 'integer': + return 'setInteger' + elif _type.raw_name() is 'number': + return 'setDouble' + elif _type.raw_name() is 'any': + return 'setValue' + else: + return 'set' + ucfirst(_type.raw_name()) + if isinstance(_type, AliasedType): + return CppGenerator.cpp_setter_method_for_type(_type.aliased_type) + if isinstance(_type, EnumType): + return CppGenerator.cpp_setter_method_for_type(_type.primitive_type) + + # Generate type representations for various situations. + @staticmethod + def cpp_protocol_type_for_type(_type): + if isinstance(_type, ObjectType) and len(_type.members) == 0: + return 'Inspector::InspectorObject' + if isinstance(_type, ArrayType): + if _type.raw_name() is None: # Otherwise, fall through and use typedef'd name. + return 'Inspector::Protocol::Array<%s>' % CppGenerator.cpp_protocol_type_for_type(_type.element_type) + if isinstance(_type, (ObjectType, AliasedType, EnumType, ArrayType)): + return 'Inspector::Protocol::%s::%s' % (_type.type_domain().domain_name, _type.raw_name()) + if isinstance(_type, PrimitiveType): + return CppGenerator.cpp_name_for_primitive_type(_type) + + @staticmethod + def cpp_protocol_type_for_type_member(type_member, object_declaration): + if isinstance(type_member.type, EnumType) and type_member.type.is_anonymous: + return '::'.join([CppGenerator.cpp_protocol_type_for_type(object_declaration.type), ucfirst(type_member.member_name)]) + else: + return CppGenerator.cpp_protocol_type_for_type(type_member.type) + + @staticmethod + def cpp_type_for_unchecked_formal_in_parameter(parameter): + _type = parameter.type + if isinstance(_type, AliasedType): + _type = _type.aliased_type # Fall through to enum or primitive. + + if isinstance(_type, EnumType): + _type = _type.primitive_type # Fall through to primitive. + + # This handles the 'any' type and objects with defined properties. + if isinstance(_type, ObjectType) or _type.qualified_name() is 'object': + cpp_name = 'Inspector::InspectorObject' + if parameter.is_optional: + return 'const %s*' % cpp_name + else: + return 'const %s&' % cpp_name + if isinstance(_type, ArrayType): + cpp_name = 'Inspector::InspectorArray' + if parameter.is_optional: + return 'const %s*' % cpp_name + else: + return 'const %s&' % cpp_name + if isinstance(_type, PrimitiveType): + cpp_name = CppGenerator.cpp_name_for_primitive_type(_type) + if parameter.is_optional: + return 'const %s* const' % cpp_name + elif _type.raw_name() in ['string']: + return 'const %s&' % cpp_name + else: + return cpp_name + + return "unknown_unchecked_formal_in_parameter_type" + + @staticmethod + def cpp_type_for_checked_formal_event_parameter(parameter): + return CppGenerator.cpp_type_for_type_with_name(parameter.type, parameter.parameter_name, parameter.is_optional) + + @staticmethod + def cpp_type_for_type_member(member): + return CppGenerator.cpp_type_for_type_with_name(member.type, member.member_name, False) + + @staticmethod + def cpp_type_for_type_with_name(_type, type_name, is_optional): + if isinstance(_type, (ArrayType, ObjectType)): + return 'RefPtr<%s>' % CppGenerator.cpp_protocol_type_for_type(_type) + if isinstance(_type, AliasedType): + builder_type = CppGenerator.cpp_protocol_type_for_type(_type) + if is_optional: + return 'const %s* const' % builder_type + elif _type.aliased_type.qualified_name() in ['integer', 'number']: + return CppGenerator.cpp_name_for_primitive_type(_type.aliased_type) + elif _type.aliased_type.qualified_name() in ['string']: + return 'const %s&' % builder_type + else: + return builder_type + if isinstance(_type, PrimitiveType): + cpp_name = CppGenerator.cpp_name_for_primitive_type(_type) + if _type.qualified_name() in ['object']: + return 'RefPtr<Inspector::InspectorObject>' + elif _type.qualified_name() in ['any']: + return 'RefPtr<Inspector::InspectorValue>' + elif is_optional: + return 'const %s* const' % cpp_name + elif _type.qualified_name() in ['string']: + return 'const %s&' % cpp_name + else: + return cpp_name + if isinstance(_type, EnumType): + if _type.is_anonymous: + enum_type_name = ucfirst(type_name) + else: + enum_type_name = 'Inspector::Protocol::%s::%s' % (_type.type_domain().domain_name, _type.raw_name()) + + if is_optional: + return '%s*' % enum_type_name + else: + return '%s' % enum_type_name + + @staticmethod + def cpp_type_for_formal_out_parameter(parameter): + _type = parameter.type + + if isinstance(_type, AliasedType): + _type = _type.aliased_type # Fall through. + + if isinstance(_type, (ObjectType, ArrayType)): + return 'RefPtr<%s>&' % CppGenerator.cpp_protocol_type_for_type(_type) + if isinstance(_type, PrimitiveType): + cpp_name = CppGenerator.cpp_name_for_primitive_type(_type) + if parameter.is_optional: + return "Inspector::Protocol::OptOutput<%s>*" % cpp_name + else: + return '%s*' % cpp_name + if isinstance(_type, EnumType): + if _type.is_anonymous: + return '%sBackendDispatcherHandler::%s*' % (_type.type_domain().domain_name, ucfirst(parameter.parameter_name)) + else: + return 'Inspector::Protocol::%s::%s*' % (_type.type_domain().domain_name, _type.raw_name()) + + raise ValueError("unknown formal out parameter type.") + + # FIXME: this is only slightly different from out parameters; they could be unified. + @staticmethod + def cpp_type_for_formal_async_parameter(parameter): + _type = parameter.type + if isinstance(_type, AliasedType): + _type = _type.aliased_type # Fall through. + + if isinstance(_type, EnumType): + _type = _type.primitive_type # Fall through. + + if isinstance(_type, (ObjectType, ArrayType)): + return 'RefPtr<%s>&&' % CppGenerator.cpp_protocol_type_for_type(_type) + if isinstance(_type, PrimitiveType): + cpp_name = CppGenerator.cpp_name_for_primitive_type(_type) + if parameter.is_optional: + return "Inspector::Protocol::OptOutput<%s>*" % cpp_name + elif _type.qualified_name() in ['integer', 'number']: + return CppGenerator.cpp_name_for_primitive_type(_type) + elif _type.qualified_name() in ['string']: + return 'const %s&' % cpp_name + else: + return cpp_name + + raise ValueError("Unknown formal async parameter type.") + + # In-parameters don't use builder types, because they could be passed + # "open types" that are manually constructed out of InspectorObjects. + + # FIXME: Only parameters that are actually open types should need non-builder parameter types. + @staticmethod + def cpp_type_for_stack_in_parameter(parameter): + _type = parameter.type + if isinstance(_type, AliasedType): + _type = _type.aliased_type # Fall through. + + if isinstance(_type, EnumType): + _type = _type.primitive_type # Fall through. + + if isinstance(_type, ObjectType): + return "RefPtr<Inspector::InspectorObject>" + if isinstance(_type, ArrayType): + return "RefPtr<Inspector::InspectorArray>" + if isinstance(_type, PrimitiveType): + cpp_name = CppGenerator.cpp_name_for_primitive_type(_type) + if _type.qualified_name() in ['any', 'object']: + return "RefPtr<%s>" % CppGenerator.cpp_name_for_primitive_type(_type) + elif parameter.is_optional and _type.qualified_name() not in ['boolean', 'string', 'integer']: + return "Inspector::Protocol::OptOutput<%s>" % cpp_name + else: + return cpp_name + + @staticmethod + def cpp_type_for_stack_out_parameter(parameter): + _type = parameter.type + if isinstance(_type, (ArrayType, ObjectType)): + return 'RefPtr<%s>' % CppGenerator.cpp_protocol_type_for_type(_type) + if isinstance(_type, AliasedType): + builder_type = CppGenerator.cpp_protocol_type_for_type(_type) + if parameter.is_optional: + return "Inspector::Protocol::OptOutput<%s>" % builder_type + return '%s' % builder_type + if isinstance(_type, PrimitiveType): + cpp_name = CppGenerator.cpp_name_for_primitive_type(_type) + if parameter.is_optional: + return "Inspector::Protocol::OptOutput<%s>" % cpp_name + else: + return cpp_name + if isinstance(_type, EnumType): + if _type.is_anonymous: + return '%sBackendDispatcherHandler::%s' % (_type.type_domain().domain_name, ucfirst(parameter.parameter_name)) + else: + return 'Inspector::Protocol::%s::%s' % (_type.type_domain().domain_name, _type.raw_name()) + + @staticmethod + def cpp_assertion_method_for_type_member(type_member, object_declaration): + + def assertion_method_for_type(_type): + return 'BindingTraits<%s>::assertValueHasExpectedType' % CppGenerator.cpp_protocol_type_for_type(_type) + + if isinstance(type_member.type, AliasedType): + return assertion_method_for_type(type_member.type.aliased_type) + if isinstance(type_member.type, EnumType) and type_member.type.is_anonymous: + return 'BindingTraits<%s>::assertValueHasExpectedType' % CppGenerator.cpp_protocol_type_for_type_member(type_member, object_declaration) + + return assertion_method_for_type(type_member.type) + + @staticmethod + def cpp_name_for_primitive_type(_type): + return _PRIMITIVE_TO_CPP_NAME_MAP.get(_type.raw_name()) + + # Decide whether certain helpers are necessary in a situation. + @staticmethod + def should_use_wrapper_for_return_type(_type): + return not isinstance(_type, (ArrayType, ObjectType)) + + @staticmethod + def should_use_references_for_type(_type): + return isinstance(_type, (ArrayType, ObjectType)) or (isinstance(_type, (PrimitiveType)) and _type.qualified_name() in ["any", "object"]) + + @staticmethod + def should_pass_by_copy_for_return_type(_type): + return isinstance(_type, (ArrayType, ObjectType)) or (isinstance(_type, (PrimitiveType)) and _type.qualified_name() == "object") diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/cpp_generator_templates.py b/Source/JavaScriptCore/inspector/scripts/codegen/cpp_generator_templates.py new file mode 100755 index 000000000..b2523ffe2 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/cpp_generator_templates.py @@ -0,0 +1,258 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014, 2015 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + +# Generator templates, which can be filled with string.Template. +# Following are classes that fill the templates from the typechecked model. + +class CppGeneratorTemplates: + + HeaderPrelude = ( + """#pragma once + +${includes} + +namespace Inspector { + +${typedefs}""") + + HeaderPostlude = ( + """} // namespace Inspector""") + + ImplementationPrelude = ( + """#include "config.h" +#include ${primaryInclude} + +${secondaryIncludes} + +namespace Inspector {""") + + ImplementationPostlude = ( + """} // namespace Inspector +""") + + AlternateDispatchersHeaderPrelude = ( + """#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +${includes} + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr<BackendDispatcher>&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr<BackendDispatcher> m_backendDispatcher; +}; +""") + + AlternateDispatchersHeaderPostlude = ( + """} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)""") + + AlternateBackendDispatcherHeaderDomainHandlerInterfaceDeclaration = ( + """class Alternate${domainName}BackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~Alternate${domainName}BackendDispatcher() { } +${commandDeclarations} +};""") + + BackendDispatcherHeaderDomainHandlerDeclaration = ( + """${classAndExportMacro} ${domainName}BackendDispatcherHandler { +public: +${commandDeclarations} +protected: + virtual ~${domainName}BackendDispatcherHandler(); +};""") + + BackendDispatcherHeaderDomainDispatcherDeclaration = ( + """${classAndExportMacro} ${domainName}BackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref<${domainName}BackendDispatcher> create(BackendDispatcher&, ${domainName}BackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) override; +${commandDeclarations} +private: + ${domainName}BackendDispatcher(BackendDispatcher&, ${domainName}BackendDispatcherHandler*); + ${domainName}BackendDispatcherHandler* m_agent { nullptr }; +};""") + + BackendDispatcherHeaderDomainDispatcherAlternatesDeclaration = ( + """#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(Alternate${domainName}BackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + Alternate${domainName}BackendDispatcher* m_alternateDispatcher { nullptr }; +#endif""") + + BackendDispatcherHeaderAsyncCommandDeclaration = ( + """ ${classAndExportMacro} ${callbackName} : public BackendDispatcher::CallbackBase { + public: + ${callbackName}(Ref<BackendDispatcher>&&, int id); + void sendSuccess(${outParameters}); + }; + virtual void ${commandName}(${inParameters}) = 0;""") + + BackendDispatcherImplementationSmallSwitch = ( + """void ${domainName}BackendDispatcher::dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) +{ + Ref<${domainName}BackendDispatcher> protect(*this); + + RefPtr<InspectorObject> parameters; + message->getObject(ASCIILiteral("params"), parameters); + +${dispatchCases} + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\\'', "${domainName}", '.', method, "' was not found")); +}""") + + BackendDispatcherImplementationLargeSwitch = ( +"""void ${domainName}BackendDispatcher::dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) +{ + Ref<${domainName}BackendDispatcher> protect(*this); + + RefPtr<InspectorObject> parameters; + message->getObject(ASCIILiteral("params"), parameters); + + typedef void (${domainName}BackendDispatcher::*CallHandler)(long requestId, RefPtr<InspectorObject>&& message); + typedef HashMap<String, CallHandler> DispatchMap; + static NeverDestroyed<DispatchMap> dispatchMap; + if (dispatchMap.get().isEmpty()) { + static const struct MethodTable { + const char* name; + CallHandler handler; + } commands[] = { +${dispatchCases} + }; + size_t length = WTF_ARRAY_LENGTH(commands); + for (size_t i = 0; i < length; ++i) + dispatchMap.get().add(commands[i].name, commands[i].handler); + } + + auto findResult = dispatchMap.get().find(method); + if (findResult == dispatchMap.get().end()) { + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\\'', "${domainName}", '.', method, "' was not found")); + return; + } + + ((*this).*findResult->value)(requestId, WTFMove(parameters)); +}""") + + BackendDispatcherImplementationDomainConstructor = ( + """Ref<${domainName}BackendDispatcher> ${domainName}BackendDispatcher::create(BackendDispatcher& backendDispatcher, ${domainName}BackendDispatcherHandler* agent) +{ + return adoptRef(*new ${domainName}BackendDispatcher(backendDispatcher, agent)); +} + +${domainName}BackendDispatcher::${domainName}BackendDispatcher(BackendDispatcher& backendDispatcher, ${domainName}BackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("${domainName}"), this); +}""") + + BackendDispatcherImplementationPrepareCommandArguments = ( +"""${inParameterDeclarations} + if (m_backendDispatcher->hasProtocolErrors()) { + m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Some arguments of method \'%s\' can't be processed", "${domainName}.${commandName}")); + return; + } +""") + + BackendDispatcherImplementationAsyncCommand = ( +"""${domainName}BackendDispatcherHandler::${callbackName}::${callbackName}(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } + +void ${domainName}BackendDispatcherHandler::${callbackName}::sendSuccess(${formalParameters}) +{ + Ref<InspectorObject> jsonMessage = InspectorObject::create(); +${outParameterAssignments} + CallbackBase::sendSuccess(WTFMove(jsonMessage)); +}""") + + FrontendDispatcherDomainDispatcherDeclaration = ( +"""${classAndExportMacro} ${domainName}FrontendDispatcher { +public: + ${domainName}FrontendDispatcher(FrontendRouter& frontendRouter) : m_frontendRouter(frontendRouter) { } +${eventDeclarations} +private: + FrontendRouter& m_frontendRouter; +};""") + + ProtocolObjectBuilderDeclarationPrelude = ( +""" template<int STATE> + class Builder { + private: + RefPtr<InspectorObject> m_result; + + template<int STEP> Builder<STATE | STEP>& castState() + { + return *reinterpret_cast<Builder<STATE | STEP>*>(this); + } + + Builder(Ref</*${objectType}*/InspectorObject>&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class ${objectType}; + public:""") + + ProtocolObjectBuilderDeclarationPostlude = ( +""" + Ref<${objectType}> release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(${objectType}) == sizeof(InspectorObject), cannot_cast); + + Ref<InspectorObject> result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast<Ref<${objectType}>*>(&result)); + } + }; + + /* + * Synthetic constructor: +${constructorExample} + */ + static Builder<NoFieldsSet> create() + { + return Builder<NoFieldsSet>(InspectorObject::create()); + }""") + + ProtocolObjectRuntimeCast = ( +"""RefPtr<${objectType}> BindingTraits<${objectType}>::runtimeCast(RefPtr<InspectorValue>&& value) +{ + RefPtr<InspectorObject> result; + bool castSucceeded = value->asObject(result); + ASSERT_UNUSED(castSucceeded, castSucceeded); +#if !ASSERT_DISABLED + BindingTraits<${objectType}>::assertValueHasExpectedType(result.get()); +#endif // !ASSERT_DISABLED + COMPILE_ASSERT(sizeof(${objectType}) == sizeof(InspectorObjectBase), type_cast_problem); + return static_cast<${objectType}*>(static_cast<InspectorObjectBase*>(result.get())); +} +""") diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py new file mode 100755 index 000000000..86e864974 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014, 2016 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + + +import logging +import string +import re +from string import Template + +from cpp_generator import CppGenerator +from cpp_generator_templates import CppGeneratorTemplates as CppTemplates + +log = logging.getLogger('global') + + +class CppAlternateBackendDispatcherHeaderGenerator(CppGenerator): + def __init__(self, *args, **kwargs): + CppGenerator.__init__(self, *args, **kwargs) + + def output_filename(self): + return '%sAlternateBackendDispatchers.h' % self.protocol_name() + + def generate_output(self): + headers = [ + '"%sProtocolTypes.h"' % self.protocol_name(), + '<inspector/InspectorFrontendRouter.h>', + '<JavaScriptCore/InspectorBackendDispatcher.h>', + ] + + header_args = { + 'includes': '\n'.join(['#include ' + header for header in headers]), + } + + domains = self.domains_to_generate() + sections = [] + sections.append(self.generate_license()) + sections.append(Template(CppTemplates.AlternateDispatchersHeaderPrelude).substitute(None, **header_args)) + sections.append('\n'.join(filter(None, map(self._generate_handler_declarations_for_domain, domains)))) + sections.append(Template(CppTemplates.AlternateDispatchersHeaderPostlude).substitute(None, **header_args)) + return '\n\n'.join(sections) + + def _generate_handler_declarations_for_domain(self, domain): + commands = self.commands_for_domain(domain) + + if not len(commands): + return '' + + command_declarations = [] + for command in commands: + command_declarations.append(self._generate_handler_declaration_for_command(command)) + + handler_args = { + 'domainName': domain.domain_name, + 'commandDeclarations': '\n'.join(command_declarations), + } + + return self.wrap_with_guard_for_domain(domain, Template(CppTemplates.AlternateBackendDispatcherHeaderDomainHandlerInterfaceDeclaration).substitute(None, **handler_args)) + + def _generate_handler_declaration_for_command(self, command): + lines = [] + parameters = ['long callId'] + for _parameter in command.call_parameters: + parameters.append('%s in_%s' % (CppGenerator.cpp_type_for_unchecked_formal_in_parameter(_parameter), _parameter.parameter_name)) + + command_args = { + 'commandName': command.command_name, + 'parameters': ', '.join(parameters), + } + lines.append(' virtual void %(commandName)s(%(parameters)s) = 0;' % command_args) + return '\n'.join(lines) diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py new file mode 100755 index 000000000..992622bdd --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py @@ -0,0 +1,217 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014-2016 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + + +import logging +import re +import string +from string import Template + +from cpp_generator import CppGenerator +from cpp_generator_templates import CppGeneratorTemplates as CppTemplates +from generator import Generator, ucfirst +from models import EnumType + +log = logging.getLogger('global') + + +class CppBackendDispatcherHeaderGenerator(CppGenerator): + def __init__(self, *args, **kwargs): + CppGenerator.__init__(self, *args, **kwargs) + + def output_filename(self): + return "%sBackendDispatchers.h" % self.protocol_name() + + def domains_to_generate(self): + return filter(lambda domain: len(self.commands_for_domain(domain)) > 0, Generator.domains_to_generate(self)) + + def generate_output(self): + headers = [ + '"%sProtocolObjects.h"' % self.protocol_name(), + '<inspector/InspectorBackendDispatcher.h>', + '<wtf/text/WTFString.h>'] + + typedefs = [('String', 'ErrorString')] + + header_args = { + 'includes': '\n'.join(['#include ' + header for header in headers]), + 'typedefs': '\n'.join(['typedef %s %s;' % typedef for typedef in typedefs]), + } + + domains = self.domains_to_generate() + + sections = [] + sections.append(self.generate_license()) + sections.append(Template(CppTemplates.HeaderPrelude).substitute(None, **header_args)) + if self.model().framework.setting('alternate_dispatchers', False): + sections.append(self._generate_alternate_handler_forward_declarations_for_domains(domains)) + sections.extend(map(self._generate_handler_declarations_for_domain, domains)) + sections.extend(map(self._generate_dispatcher_declarations_for_domain, domains)) + sections.append(Template(CppTemplates.HeaderPostlude).substitute(None, **header_args)) + return "\n\n".join(sections) + + # Private methods. + + def _generate_alternate_handler_forward_declarations_for_domains(self, domains): + if not domains: + return '' + + lines = [] + lines.append('#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)') + for domain in domains: + lines.append(self.wrap_with_guard_for_domain(domain, 'class Alternate%sBackendDispatcher;' % domain.domain_name)) + lines.append('#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)') + return '\n'.join(lines) + + def _generate_handler_declarations_for_domain(self, domain): + classComponents = ['class'] + exportMacro = self.model().framework.setting('export_macro', None) + if exportMacro is not None: + classComponents.append(exportMacro) + + used_enum_names = set() + + command_declarations = [] + for command in self.commands_for_domain(domain): + command_declarations.append(self._generate_handler_declaration_for_command(command, used_enum_names)) + + handler_args = { + 'classAndExportMacro': " ".join(classComponents), + 'domainName': domain.domain_name, + 'commandDeclarations': "\n".join(command_declarations) + } + + return self.wrap_with_guard_for_domain(domain, Template(CppTemplates.BackendDispatcherHeaderDomainHandlerDeclaration).substitute(None, **handler_args)) + + def _generate_anonymous_enum_for_parameter(self, parameter, command): + enum_args = { + 'parameterName': parameter.parameter_name, + 'commandName': command.command_name + } + + lines = [] + lines.append(' // Named after parameter \'%(parameterName)s\' while generating command/event %(commandName)s.' % enum_args) + lines.append(' enum class %s {' % ucfirst(parameter.parameter_name)) + for enum_value in parameter.type.enum_values(): + lines.append(' %s = %d,' % (Generator.stylized_name_for_enum_value(enum_value), self.encoding_for_enum_value(enum_value))) + lines.append(' }; // enum class %s' % ucfirst(parameter.parameter_name)) + return '\n'.join(lines) + + def _generate_handler_declaration_for_command(self, command, used_enum_names): + if command.is_async: + return self._generate_async_handler_declaration_for_command(command) + + lines = [] + parameters = ['ErrorString&'] + for _parameter in command.call_parameters: + parameter_name = 'in_' + _parameter.parameter_name + if _parameter.is_optional: + parameter_name = 'opt_' + parameter_name + + parameters.append("%s %s" % (CppGenerator.cpp_type_for_unchecked_formal_in_parameter(_parameter), parameter_name)) + + if isinstance(_parameter.type, EnumType) and _parameter.type.is_anonymous and _parameter.parameter_name not in used_enum_names: + lines.append(self._generate_anonymous_enum_for_parameter(_parameter, command)) + used_enum_names.add(_parameter.parameter_name) + + for _parameter in command.return_parameters: + parameter_name = 'out_' + _parameter.parameter_name + if _parameter.is_optional: + parameter_name = 'opt_' + parameter_name + parameters.append("%s %s" % (CppGenerator.cpp_type_for_formal_out_parameter(_parameter), parameter_name)) + + if isinstance(_parameter.type, EnumType) and _parameter.type.is_anonymous and _parameter.parameter_name not in used_enum_names: + lines.append(self._generate_anonymous_enum_for_parameter(_parameter, command)) + used_enum_names.add(_parameter.parameter_name) + + command_args = { + 'commandName': command.command_name, + 'parameters': ", ".join(parameters) + } + lines.append(' virtual void %(commandName)s(%(parameters)s) = 0;' % command_args) + return '\n'.join(lines) + + def _generate_async_handler_declaration_for_command(self, command): + callbackName = "%sCallback" % ucfirst(command.command_name) + + in_parameters = ['ErrorString&'] + for _parameter in command.call_parameters: + parameter_name = 'in_' + _parameter.parameter_name + if _parameter.is_optional: + parameter_name = 'opt_' + parameter_name + + in_parameters.append("%s %s" % (CppGenerator.cpp_type_for_unchecked_formal_in_parameter(_parameter), parameter_name)) + in_parameters.append("Ref<%s>&& callback" % callbackName) + + out_parameters = [] + for _parameter in command.return_parameters: + out_parameters.append("%s %s" % (CppGenerator.cpp_type_for_formal_async_parameter(_parameter), _parameter.parameter_name)) + + class_components = ['class'] + export_macro = self.model().framework.setting('export_macro', None) + if export_macro: + class_components.append(export_macro) + + command_args = { + 'classAndExportMacro': ' '.join(class_components), + 'callbackName': callbackName, + 'commandName': command.command_name, + 'inParameters': ", ".join(in_parameters), + 'outParameters': ", ".join(out_parameters), + } + + return Template(CppTemplates.BackendDispatcherHeaderAsyncCommandDeclaration).substitute(None, **command_args) + + def _generate_dispatcher_declarations_for_domain(self, domain): + classComponents = ['class'] + exportMacro = self.model().framework.setting('export_macro', None) + if exportMacro is not None: + classComponents.append(exportMacro) + + declarations = [] + commands = self.commands_for_domain(domain) + if len(commands) > 0: + declarations.append('private:') + declarations.extend(map(self._generate_dispatcher_declaration_for_command, commands)) + + declaration_args = { + 'domainName': domain.domain_name, + } + + # Add in a few more declarations at the end if needed. + if self.model().framework.setting('alternate_dispatchers', False): + declarations.append(Template(CppTemplates.BackendDispatcherHeaderDomainDispatcherAlternatesDeclaration).substitute(None, **declaration_args)) + + handler_args = { + 'classAndExportMacro': " ".join(classComponents), + 'domainName': domain.domain_name, + 'commandDeclarations': "\n".join(declarations) + } + + return self.wrap_with_guard_for_domain(domain, Template(CppTemplates.BackendDispatcherHeaderDomainDispatcherDeclaration).substitute(None, **handler_args)) + + def _generate_dispatcher_declaration_for_command(self, command): + return " void %s(long requestId, RefPtr<InspectorObject>&& parameters);" % command.command_name diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py new file mode 100755 index 000000000..fccedcba7 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py @@ -0,0 +1,324 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014-2016 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + + +import logging +import string +from string import Template + +from cpp_generator import CppGenerator +from cpp_generator_templates import CppGeneratorTemplates as CppTemplates +from generator import Generator, ucfirst +from models import ObjectType, ArrayType + +log = logging.getLogger('global') + + +class CppBackendDispatcherImplementationGenerator(CppGenerator): + def __init__(self, *args, **kwargs): + CppGenerator.__init__(self, *args, **kwargs) + + def output_filename(self): + return "%sBackendDispatchers.cpp" % self.protocol_name() + + def domains_to_generate(self): + return filter(lambda domain: len(self.commands_for_domain(domain)) > 0, Generator.domains_to_generate(self)) + + def generate_output(self): + secondary_headers = [ + '<inspector/InspectorFrontendRouter.h>', + '<inspector/InspectorValues.h>', + '<wtf/NeverDestroyed.h>', + '<wtf/text/CString.h>'] + + secondary_includes = ['#include %s' % header for header in secondary_headers] + + if self.model().framework.setting('alternate_dispatchers', False): + secondary_includes.append('') + secondary_includes.append('#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)') + secondary_includes.append('#include "%sAlternateBackendDispatchers.h"' % self.protocol_name()) + secondary_includes.append('#endif') + + header_args = { + 'primaryInclude': '"%sBackendDispatchers.h"' % self.protocol_name(), + 'secondaryIncludes': '\n'.join(secondary_includes), + } + + sections = [] + sections.append(self.generate_license()) + sections.append(Template(CppTemplates.ImplementationPrelude).substitute(None, **header_args)) + sections.append("\n".join(map(self._generate_handler_class_destructor_for_domain, self.domains_to_generate()))) + sections.extend(map(self._generate_dispatcher_implementations_for_domain, self.domains_to_generate())) + sections.append(Template(CppTemplates.ImplementationPostlude).substitute(None, **header_args)) + return "\n\n".join(sections) + + # Private methods. + + def _generate_handler_class_destructor_for_domain(self, domain): + destructor_args = { + 'domainName': domain.domain_name + } + destructor = '%(domainName)sBackendDispatcherHandler::~%(domainName)sBackendDispatcherHandler() { }' % destructor_args + return self.wrap_with_guard_for_domain(domain, destructor) + + def _generate_dispatcher_implementations_for_domain(self, domain): + implementations = [] + + constructor_args = { + 'domainName': domain.domain_name, + } + implementations.append(Template(CppTemplates.BackendDispatcherImplementationDomainConstructor).substitute(None, **constructor_args)) + + commands = self.commands_for_domain(domain) + + if len(commands) <= 5: + implementations.append(self._generate_small_dispatcher_switch_implementation_for_domain(domain)) + else: + implementations.append(self._generate_large_dispatcher_switch_implementation_for_domain(domain)) + + for command in commands: + if command.is_async: + implementations.append(self._generate_async_dispatcher_class_for_domain(command, domain)) + implementations.append(self._generate_dispatcher_implementation_for_command(command, domain)) + + return self.wrap_with_guard_for_domain(domain, '\n\n'.join(implementations)) + + def _generate_small_dispatcher_switch_implementation_for_domain(self, domain): + commands = self.commands_for_domain(domain) + + cases = [] + cases.append(' if (method == "%s")' % commands[0].command_name) + cases.append(' %s(requestId, WTFMove(parameters));' % commands[0].command_name) + for command in commands[1:]: + cases.append(' else if (method == "%s")' % command.command_name) + cases.append(' %s(requestId, WTFMove(parameters));' % command.command_name) + + switch_args = { + 'domainName': domain.domain_name, + 'dispatchCases': "\n".join(cases) + } + + return Template(CppTemplates.BackendDispatcherImplementationSmallSwitch).substitute(None, **switch_args) + + def _generate_large_dispatcher_switch_implementation_for_domain(self, domain): + commands = self.commands_for_domain(domain) + + cases = [] + for command in commands: + args = { + 'domainName': domain.domain_name, + 'commandName': command.command_name + } + cases.append(' { "%(commandName)s", &%(domainName)sBackendDispatcher::%(commandName)s },' % args) + + switch_args = { + 'domainName': domain.domain_name, + 'dispatchCases': "\n".join(cases) + } + + return Template(CppTemplates.BackendDispatcherImplementationLargeSwitch).substitute(None, **switch_args) + + def _generate_async_dispatcher_class_for_domain(self, command, domain): + out_parameter_assignments = [] + formal_parameters = [] + + for parameter in command.return_parameters: + param_args = { + 'keyedSetMethod': CppGenerator.cpp_setter_method_for_type(parameter.type), + 'parameterKey': parameter.parameter_name, + 'parameterName': parameter.parameter_name, + 'parameterType': CppGenerator.cpp_type_for_stack_in_parameter(parameter), + 'helpersNamespace': self.helpers_namespace(), + } + + formal_parameters.append('%s %s' % (CppGenerator.cpp_type_for_formal_async_parameter(parameter), parameter.parameter_name)) + + if parameter.is_optional: + if CppGenerator.should_use_wrapper_for_return_type(parameter.type): + out_parameter_assignments.append(' if (%(parameterName)s.isAssigned())' % param_args) + out_parameter_assignments.append(' jsonMessage->%(keyedSetMethod)s(ASCIILiteral("%(parameterKey)s"), %(parameterName)s.getValue());' % param_args) + else: + out_parameter_assignments.append(' if (%(parameterName)s)' % param_args) + out_parameter_assignments.append(' jsonMessage->%(keyedSetMethod)s(ASCIILiteral("%(parameterKey)s"), %(parameterName)s);' % param_args) + elif parameter.type.is_enum(): + out_parameter_assignments.append(' jsonMessage->%(keyedSetMethod)s(ASCIILiteral("%(parameterKey)s"), Inspector::Protocol::%(helpersNamespace)s::getEnumConstantValue(%(parameterName)s));' % param_args) + else: + out_parameter_assignments.append(' jsonMessage->%(keyedSetMethod)s(ASCIILiteral("%(parameterKey)s"), %(parameterName)s);' % param_args) + + async_args = { + 'domainName': domain.domain_name, + 'callbackName': ucfirst(command.command_name) + 'Callback', + 'formalParameters': ", ".join(formal_parameters), + 'outParameterAssignments': "\n".join(out_parameter_assignments) + } + return Template(CppTemplates.BackendDispatcherImplementationAsyncCommand).substitute(None, **async_args) + + def _generate_dispatcher_implementation_for_command(self, command, domain): + in_parameter_declarations = [] + out_parameter_declarations = [] + out_parameter_assignments = [] + alternate_dispatcher_method_parameters = ['requestId'] + method_parameters = ['error'] + + for parameter in command.call_parameters: + parameter_name = 'in_' + parameter.parameter_name + if parameter.is_optional: + parameter_name = 'opt_' + parameter_name + + out_success_argument = 'nullptr' + if parameter.is_optional: + out_success_argument = '&%s_valueFound' % parameter_name + in_parameter_declarations.append(' bool %s_valueFound = false;' % parameter_name) + + # Now add appropriate operators. + parameter_expression = parameter_name + + if CppGenerator.should_use_references_for_type(parameter.type): + if parameter.is_optional: + parameter_expression = '%s.get()' % parameter_expression + else: + # This assumes that we have already proved the object is non-null. + # If a required property is missing, InspectorBackend::getObject will + # append a protocol error, and the method dispatcher will return without + # invoking the backend method (and dereferencing the object). + parameter_expression = '*%s' % parameter_expression + elif parameter.is_optional: + parameter_expression = '&%s' % parameter_expression + + param_args = { + 'parameterType': CppGenerator.cpp_type_for_stack_in_parameter(parameter), + 'parameterKey': parameter.parameter_name, + 'parameterName': parameter_name, + 'parameterExpression': parameter_expression, + 'keyedGetMethod': CppGenerator.cpp_getter_method_for_type(parameter.type), + 'successOutParam': out_success_argument + } + + in_parameter_declarations.append(' %(parameterType)s %(parameterName)s = m_backendDispatcher->%(keyedGetMethod)s(parameters.get(), ASCIILiteral("%(parameterKey)s"), %(successOutParam)s);' % param_args) + + if parameter.is_optional: + optional_in_parameter_string = '%(parameterName)s_valueFound ? %(parameterExpression)s : nullptr' % param_args + alternate_dispatcher_method_parameters.append(optional_in_parameter_string) + method_parameters.append(optional_in_parameter_string) + else: + alternate_dispatcher_method_parameters.append(parameter_expression) + method_parameters.append(parameter_expression) + + if command.is_async: + async_args = { + 'domainName': domain.domain_name, + 'callbackName': ucfirst(command.command_name) + 'Callback' + } + + out_parameter_assignments.append(' callback->disable();') + out_parameter_assignments.append(' m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, error);') + out_parameter_assignments.append(' return;') + method_parameters.append('callback.copyRef()') + + else: + for parameter in command.return_parameters: + param_args = { + 'parameterType': CppGenerator.cpp_type_for_stack_out_parameter(parameter), + 'parameterKey': parameter.parameter_name, + 'parameterName': parameter.parameter_name, + 'keyedSetMethod': CppGenerator.cpp_setter_method_for_type(parameter.type), + 'helpersNamespace': self.helpers_namespace(), + } + + out_parameter_declarations.append(' %(parameterType)s out_%(parameterName)s;' % param_args) + if parameter.is_optional: + if CppGenerator.should_use_wrapper_for_return_type(parameter.type): + out_parameter_assignments.append(' if (out_%(parameterName)s.isAssigned())' % param_args) + out_parameter_assignments.append(' result->%(keyedSetMethod)s(ASCIILiteral("%(parameterKey)s"), out_%(parameterName)s.getValue());' % param_args) + else: + out_parameter_assignments.append(' if (out_%(parameterName)s)' % param_args) + out_parameter_assignments.append(' result->%(keyedSetMethod)s(ASCIILiteral("%(parameterKey)s"), out_%(parameterName)s);' % param_args) + elif parameter.type.is_enum(): + out_parameter_assignments.append(' result->%(keyedSetMethod)s(ASCIILiteral("%(parameterKey)s"), Inspector::Protocol::%(helpersNamespace)s::getEnumConstantValue(out_%(parameterName)s));' % param_args) + else: + out_parameter_assignments.append(' result->%(keyedSetMethod)s(ASCIILiteral("%(parameterKey)s"), out_%(parameterName)s);' % param_args) + + if CppGenerator.should_pass_by_copy_for_return_type(parameter.type): + method_parameters.append('out_' + parameter.parameter_name) + else: + method_parameters.append('&out_' + parameter.parameter_name) + + command_args = { + 'domainName': domain.domain_name, + 'callbackName': '%sCallback' % ucfirst(command.command_name), + 'commandName': command.command_name, + 'inParameterDeclarations': '\n'.join(in_parameter_declarations), + 'invocationParameters': ', '.join(method_parameters), + 'alternateInvocationParameters': ', '.join(alternate_dispatcher_method_parameters), + } + + lines = [] + if len(command.call_parameters) == 0: + lines.append('void %(domainName)sBackendDispatcher::%(commandName)s(long requestId, RefPtr<InspectorObject>&&)' % command_args) + else: + lines.append('void %(domainName)sBackendDispatcher::%(commandName)s(long requestId, RefPtr<InspectorObject>&& parameters)' % command_args) + lines.append('{') + + if len(command.call_parameters) > 0: + lines.append(Template(CppTemplates.BackendDispatcherImplementationPrepareCommandArguments).substitute(None, **command_args)) + + if self.model().framework.setting('alternate_dispatchers', False): + lines.append('#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)') + lines.append(' if (m_alternateDispatcher) {') + lines.append(' m_alternateDispatcher->%(commandName)s(%(alternateInvocationParameters)s);' % command_args) + lines.append(' return;') + lines.append(' }') + lines.append('#endif') + lines.append('') + + lines.append(' ErrorString error;') + lines.append(' Ref<InspectorObject> result = InspectorObject::create();') + if command.is_async: + lines.append(' Ref<%(domainName)sBackendDispatcherHandler::%(callbackName)s> callback = adoptRef(*new %(domainName)sBackendDispatcherHandler::%(callbackName)s(m_backendDispatcher.copyRef(), requestId));' % command_args) + if len(command.return_parameters) > 0: + lines.extend(out_parameter_declarations) + lines.append(' m_agent->%(commandName)s(%(invocationParameters)s);' % command_args) + lines.append('') + if command.is_async: + lines.append(' if (error.length()) {') + lines.extend(out_parameter_assignments) + lines.append(' }') + elif len(command.return_parameters) > 1: + lines.append(' if (!error.length()) {') + lines.extend(out_parameter_assignments) + lines.append(' }') + elif len(command.return_parameters) == 1: + lines.append(' if (!error.length())') + lines.extend(out_parameter_assignments) + lines.append('') + + if not command.is_async: + lines.append(' if (!error.length())') + lines.append(' m_backendDispatcher->sendResponse(requestId, WTFMove(result));') + lines.append(' else') + lines.append(' m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error));') + lines.append('}') + return "\n".join(lines) diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py new file mode 100755 index 000000000..ed58b1e2f --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py @@ -0,0 +1,116 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014-2016 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + + +import logging +import re +import string +from string import Template + +from cpp_generator import CppGenerator +from cpp_generator_templates import CppGeneratorTemplates as CppTemplates +from generator import Generator, ucfirst +from models import EnumType + +log = logging.getLogger('global') + + +class CppFrontendDispatcherHeaderGenerator(CppGenerator): + def __init__(self, *args, **kwargs): + CppGenerator.__init__(self, *args, **kwargs) + + def output_filename(self): + return "%sFrontendDispatchers.h" % self.protocol_name() + + def domains_to_generate(self): + return filter(lambda domain: len(self.events_for_domain(domain)) > 0, Generator.domains_to_generate(self)) + + def generate_output(self): + headers = [ + '"%sProtocolObjects.h"' % self.protocol_name(), + '<inspector/InspectorValues.h>', + '<wtf/text/WTFString.h>'] + + header_args = { + 'includes': '\n'.join(['#include ' + header for header in headers]), + 'typedefs': 'class FrontendRouter;', + } + + sections = [] + sections.append(self.generate_license()) + sections.append(Template(CppTemplates.HeaderPrelude).substitute(None, **header_args)) + sections.extend(map(self._generate_dispatcher_declarations_for_domain, self.domains_to_generate())) + sections.append(Template(CppTemplates.HeaderPostlude).substitute(None, **header_args)) + return "\n\n".join(sections) + + # Private methods. + + def _generate_anonymous_enum_for_parameter(self, parameter, event): + enum_args = { + 'parameterName': parameter.parameter_name, + 'eventName': event.event_name + } + + lines = [] + lines.append(' // Named after parameter \'%(parameterName)s\' while generating command/event %(eventName)s.' % enum_args) + lines.append(' enum class %s {' % ucfirst(parameter.parameter_name)) + for enum_value in parameter.type.enum_values(): + lines.append(' %s = %d,' % (Generator.stylized_name_for_enum_value(enum_value), self.encoding_for_enum_value(enum_value))) + lines.append(' }; // enum class %s' % ucfirst(parameter.parameter_name)) + return "\n".join(lines) + + def _generate_dispatcher_declarations_for_domain(self, domain): + classComponents = ['class'] + exportMacro = self.model().framework.setting('export_macro', None) + if exportMacro is not None: + classComponents.append(exportMacro) + + used_enum_names = set([]) + + events = self.events_for_domain(domain) + event_declarations = [] + for event in events: + event_declarations.append(self._generate_dispatcher_declaration_for_event(event, domain, used_enum_names)) + + handler_args = { + 'classAndExportMacro': " ".join(classComponents), + 'domainName': domain.domain_name, + 'eventDeclarations': "\n".join(event_declarations) + } + + return self.wrap_with_guard_for_domain(domain, Template(CppTemplates.FrontendDispatcherDomainDispatcherDeclaration).substitute(None, **handler_args)) + + def _generate_dispatcher_declaration_for_event(self, event, domain, used_enum_names): + formal_parameters = [] + lines = [] + for parameter in event.event_parameters: + formal_parameters.append('%s %s' % (CppGenerator.cpp_type_for_checked_formal_event_parameter(parameter), parameter.parameter_name)) + if isinstance(parameter.type, EnumType) and parameter.parameter_name not in used_enum_names: + lines.append(self._generate_anonymous_enum_for_parameter(parameter, event)) + used_enum_names.add(parameter.parameter_name) + + lines.append(" void %s(%s);" % (event.event_name, ", ".join(formal_parameters))) + return "\n".join(lines) diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py new file mode 100755 index 000000000..0d0806903 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py @@ -0,0 +1,125 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014-2016 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + + +import logging +import string +from string import Template + +from cpp_generator import CppGenerator +from cpp_generator_templates import CppGeneratorTemplates as CppTemplates +from generator import Generator, ucfirst +from models import ObjectType, ArrayType + +log = logging.getLogger('global') + + +class CppFrontendDispatcherImplementationGenerator(CppGenerator): + def __init__(self, *args, **kwargs): + CppGenerator.__init__(self, *args, **kwargs) + + def output_filename(self): + return "%sFrontendDispatchers.cpp" % self.protocol_name() + + def domains_to_generate(self): + return filter(lambda domain: len(self.events_for_domain(domain)) > 0, Generator.domains_to_generate(self)) + + def generate_output(self): + secondary_headers = [ + '"InspectorFrontendRouter.h"', + '<wtf/text/CString.h>', + ] + + header_args = { + 'primaryInclude': '"%sFrontendDispatchers.h"' % self.protocol_name(), + 'secondaryIncludes': "\n".join(['#include %s' % header for header in secondary_headers]), + } + + sections = [] + sections.append(self.generate_license()) + sections.append(Template(CppTemplates.ImplementationPrelude).substitute(None, **header_args)) + sections.extend(map(self._generate_dispatcher_implementations_for_domain, self.domains_to_generate())) + sections.append(Template(CppTemplates.ImplementationPostlude).substitute(None, **header_args)) + return "\n\n".join(sections) + + # Private methods. + + def _generate_dispatcher_implementations_for_domain(self, domain): + implementations = [] + events = self.events_for_domain(domain) + for event in events: + implementations.append(self._generate_dispatcher_implementation_for_event(event, domain)) + + return self.wrap_with_guard_for_domain(domain, '\n\n'.join(implementations)) + + def _generate_dispatcher_implementation_for_event(self, event, domain): + lines = [] + parameter_assignments = [] + formal_parameters = [] + + for parameter in event.event_parameters: + + parameter_value = parameter.parameter_name + if parameter.is_optional and not CppGenerator.should_pass_by_copy_for_return_type(parameter.type): + parameter_value = '*' + parameter_value + if parameter.type.is_enum(): + parameter_value = 'Inspector::Protocol::%s::getEnumConstantValue(%s)' % (self.helpers_namespace(), parameter_value) + + parameter_args = { + 'parameterType': CppGenerator.cpp_type_for_stack_out_parameter(parameter), + 'parameterName': parameter.parameter_name, + 'parameterValue': parameter_value, + 'keyedSetMethod': CppGenerator.cpp_setter_method_for_type(parameter.type), + } + + if parameter.is_optional: + parameter_assignments.append(' if (%(parameterName)s)' % parameter_args) + parameter_assignments.append(' paramsObject->%(keyedSetMethod)s(ASCIILiteral("%(parameterName)s"), %(parameterValue)s);' % parameter_args) + else: + parameter_assignments.append(' paramsObject->%(keyedSetMethod)s(ASCIILiteral("%(parameterName)s"), %(parameterValue)s);' % parameter_args) + + formal_parameters.append('%s %s' % (CppGenerator.cpp_type_for_checked_formal_event_parameter(parameter), parameter.parameter_name)) + + event_args = { + 'domainName': domain.domain_name, + 'eventName': event.event_name, + 'formalParameters': ", ".join(formal_parameters) + } + + lines.append('void %(domainName)sFrontendDispatcher::%(eventName)s(%(formalParameters)s)' % event_args) + lines.append('{') + lines.append(' Ref<InspectorObject> jsonMessage = InspectorObject::create();') + lines.append(' jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("%(domainName)s.%(eventName)s"));' % event_args) + + if len(parameter_assignments) > 0: + lines.append(' Ref<InspectorObject> paramsObject = InspectorObject::create();') + lines.extend(parameter_assignments) + lines.append(' jsonMessage->setObject(ASCIILiteral("params"), WTFMove(paramsObject));') + + lines.append('') + lines.append(' m_frontendRouter.sendEvent(jsonMessage->toJSONString());') + lines.append('}') + return "\n".join(lines) diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_header.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_header.py new file mode 100755 index 000000000..1f91cdd0f --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_header.py @@ -0,0 +1,424 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014, 2016 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + + +import logging +import re +import string +from operator import methodcaller +from string import Template + +from cpp_generator import CppGenerator +from cpp_generator_templates import CppGeneratorTemplates as CppTemplates +from generator import Generator, ucfirst +from models import EnumType, ObjectType, PrimitiveType, AliasedType, ArrayType, Frameworks + +log = logging.getLogger('global') + + +class CppProtocolTypesHeaderGenerator(CppGenerator): + def __init__(self, *args, **kwargs): + CppGenerator.__init__(self, *args, **kwargs) + + def output_filename(self): + return "%sProtocolObjects.h" % self.protocol_name() + + def generate_output(self): + domains = self.domains_to_generate() + self.calculate_types_requiring_shape_assertions(domains) + + headers = set([ + '<inspector/InspectorProtocolTypes.h>', + '<wtf/Assertions.h>', + ]) + + header_args = { + 'includes': '\n'.join(['#include ' + header for header in sorted(headers)]), + 'typedefs': '', + } + + sections = [] + sections.append(self.generate_license()) + sections.append(Template(CppTemplates.HeaderPrelude).substitute(None, **header_args)) + sections.append('namespace Protocol {') + sections.append(self._generate_forward_declarations(domains)) + sections.append(self._generate_typedefs(domains)) + sections.extend(self._generate_enum_constant_value_conversion_methods()) + builder_sections = map(self._generate_builders_for_domain, domains) + sections.extend(filter(lambda section: len(section) > 0, builder_sections)) + sections.append(self._generate_forward_declarations_for_binding_traits()) + sections.extend(self._generate_declarations_for_enum_conversion_methods()) + sections.append('} // namespace Protocol') + sections.append(Template(CppTemplates.HeaderPostlude).substitute(None, **header_args)) + return "\n\n".join(sections) + + # Private methods. + + # FIXME: move builders out of classes, uncomment forward declaration + + def _generate_forward_declarations(self, domains): + sections = [] + + for domain in domains: + declaration_types = [decl.type for decl in self.type_declarations_for_domain(domain)] + object_types = filter(lambda _type: isinstance(_type, ObjectType), declaration_types) + enum_types = filter(lambda _type: isinstance(_type, EnumType), declaration_types) + sorted(object_types, key=methodcaller('raw_name')) + sorted(enum_types, key=methodcaller('raw_name')) + + if len(object_types) + len(enum_types) == 0: + continue + + domain_lines = [] + domain_lines.append('namespace %s {' % domain.domain_name) + + # Forward-declare all classes so the type builders won't break if rearranged. + domain_lines.extend('class %s;' % object_type.raw_name() for object_type in object_types) + domain_lines.extend('enum class %s;' % enum_type.raw_name() for enum_type in enum_types) + domain_lines.append('} // %s' % domain.domain_name) + sections.append(self.wrap_with_guard_for_domain(domain, '\n'.join(domain_lines))) + + if len(sections) == 0: + return '' + else: + return """// Forward declarations. +%s +// End of forward declarations. +""" % '\n\n'.join(sections) + + def _generate_typedefs(self, domains): + sections = map(self._generate_typedefs_for_domain, domains) + sections = filter(lambda text: len(text) > 0, sections) + + if len(sections) == 0: + return '' + else: + return """// Typedefs. +%s +// End of typedefs.""" % '\n\n'.join(sections) + + def _generate_typedefs_for_domain(self, domain): + type_declarations = self.type_declarations_for_domain(domain) + primitive_declarations = filter(lambda decl: isinstance(decl.type, AliasedType), type_declarations) + array_declarations = filter(lambda decl: isinstance(decl.type, ArrayType), type_declarations) + if len(primitive_declarations) == 0 and len(array_declarations) == 0: + return '' + + sections = [] + for declaration in primitive_declarations: + primitive_name = CppGenerator.cpp_name_for_primitive_type(declaration.type.aliased_type) + typedef_lines = [] + if len(declaration.description) > 0: + typedef_lines.append('/* %s */' % declaration.description) + typedef_lines.append('typedef %s %s;' % (primitive_name, declaration.type_name)) + sections.append('\n'.join(typedef_lines)) + + for declaration in array_declarations: + element_type = CppGenerator.cpp_protocol_type_for_type(declaration.type.element_type) + typedef_lines = [] + if len(declaration.description) > 0: + typedef_lines.append('/* %s */' % declaration.description) + typedef_lines.append('typedef Inspector::Protocol::Array<%s> %s;' % (element_type, declaration.type_name)) + sections.append('\n'.join(typedef_lines)) + + lines = [] + lines.append('namespace %s {' % domain.domain_name) + lines.append('\n'.join(sections)) + lines.append('} // %s' % domain.domain_name) + return self.wrap_with_guard_for_domain(domain, '\n'.join(lines)) + + def _generate_enum_constant_value_conversion_methods(self): + if not self.assigned_enum_values(): + return [] + + return_type = 'String' + return_type_with_export_macro = [return_type] + export_macro = self.model().framework.setting('export_macro', None) + if export_macro is not None: + return_type_with_export_macro[:0] = [export_macro] + + lines = [] + lines.append('namespace %s {' % self.helpers_namespace()) + lines.append('\n'.join([ + '%s getEnumConstantValue(int code);' % ' '.join(return_type_with_export_macro), + '', + 'template<typename T> %s getEnumConstantValue(T enumValue)' % return_type, + '{', + ' return getEnumConstantValue(static_cast<int>(enumValue));', + '}', + ])) + lines.append('} // namespace %s' % self.helpers_namespace()) + return lines + + def _generate_builders_for_domain(self, domain): + sections = [] + + type_declarations = self.type_declarations_for_domain(domain) + for type_declaration in type_declarations: + if isinstance(type_declaration.type, EnumType): + sections.append(self._generate_struct_for_enum_declaration(type_declaration)) + elif isinstance(type_declaration.type, ObjectType): + sections.append(self._generate_class_for_object_declaration(type_declaration, domain)) + + sections = filter(lambda section: len(section) > 0, sections) + if len(sections) == 0: + return '' + + lines = [] + lines.append('namespace %s {' % domain.domain_name) + lines.append('\n'.join(sections)) + lines.append('} // %s' % domain.domain_name) + return self.wrap_with_guard_for_domain(domain, '\n'.join(lines)) + + def _generate_class_for_object_declaration(self, type_declaration, domain): + if len(type_declaration.type_members) == 0: + return '' + + enum_members = filter(lambda member: isinstance(member.type, EnumType) and member.type.is_anonymous, type_declaration.type_members) + required_members = filter(lambda member: not member.is_optional, type_declaration.type_members) + optional_members = filter(lambda member: member.is_optional, type_declaration.type_members) + object_name = type_declaration.type_name + + lines = [] + if len(type_declaration.description) > 0: + lines.append('/* %s */' % type_declaration.description) + base_class = 'Inspector::InspectorObject' + if not Generator.type_has_open_fields(type_declaration.type): + base_class = base_class + 'Base' + lines.append('class %s : public %s {' % (object_name, base_class)) + lines.append('public:') + for enum_member in enum_members: + lines.append(' // Named after property name \'%s\' while generating %s.' % (enum_member.member_name, object_name)) + lines.append(self._generate_struct_for_anonymous_enum_member(enum_member)) + lines.append(self._generate_builder_state_enum(type_declaration)) + + constructor_example = [] + constructor_example.append(' * Ref<%s> result = %s::create()' % (object_name, object_name)) + for member in required_members: + constructor_example.append(' * .set%s(...)' % ucfirst(member.member_name)) + constructor_example.append(' * .release()') + + builder_args = { + 'objectType': object_name, + 'constructorExample': '\n'.join(constructor_example) + ';', + } + + lines.append(Template(CppTemplates.ProtocolObjectBuilderDeclarationPrelude).substitute(None, **builder_args)) + for type_member in required_members: + lines.append(self._generate_builder_setter_for_member(type_member, domain)) + lines.append(Template(CppTemplates.ProtocolObjectBuilderDeclarationPostlude).substitute(None, **builder_args)) + for member in optional_members: + lines.append(self._generate_unchecked_setter_for_member(member, domain)) + + if Generator.type_has_open_fields(type_declaration.type): + lines.append('') + lines.append(' // Property names for type generated as open.') + for type_member in type_declaration.type_members: + export_macro = self.model().framework.setting('export_macro', None) + lines.append(' %s static const char* %s;' % (export_macro, ucfirst(type_member.member_name))) + + lines.append('};') + lines.append('') + return '\n'.join(lines) + + def _generate_struct_for_enum_declaration(self, enum_declaration): + lines = [] + lines.append('/* %s */' % enum_declaration.description) + lines.extend(self._generate_struct_for_enum_type(enum_declaration.type_name, enum_declaration.type)) + return '\n'.join(lines) + + def _generate_struct_for_anonymous_enum_member(self, enum_member): + def apply_indentation(line): + if line.startswith(('#', '/*', '*/', '//')) or len(line) is 0: + return line + else: + return ' ' + line + + indented_lines = map(apply_indentation, self._generate_struct_for_enum_type(enum_member.member_name, enum_member.type)) + return '\n'.join(indented_lines) + + def _generate_struct_for_enum_type(self, enum_name, enum_type): + lines = [] + enum_name = ucfirst(enum_name) + lines.append('enum class %s {' % enum_name) + for enum_value in enum_type.enum_values(): + lines.append(' %s = %s,' % (Generator.stylized_name_for_enum_value(enum_value), self.encoding_for_enum_value(enum_value))) + lines.append('}; // enum class %s' % enum_name) + return lines # The caller may want to adjust indentation, so don't join these lines. + + def _generate_builder_state_enum(self, type_declaration): + lines = [] + required_members = filter(lambda member: not member.is_optional, type_declaration.type_members) + enum_values = [] + + lines.append(' enum {') + lines.append(' NoFieldsSet = 0,') + for i in range(len(required_members)): + enum_value = "%sSet" % ucfirst(required_members[i].member_name) + enum_values.append(enum_value) + lines.append(' %s = 1 << %d,' % (enum_value, i)) + if len(enum_values) > 0: + lines.append(' AllFieldsSet = (%s)' % ' | '.join(enum_values)) + else: + lines.append(' AllFieldsSet = 0') + lines.append(' };') + lines.append('') + return '\n'.join(lines) + + def _generate_builder_setter_for_member(self, type_member, domain): + setter_args = { + 'camelName': ucfirst(type_member.member_name), + 'keyedSet': CppGenerator.cpp_setter_method_for_type(type_member.type), + 'name': type_member.member_name, + 'parameterType': CppGenerator.cpp_type_for_type_member(type_member), + 'helpersNamespace': self.helpers_namespace(), + } + + lines = [] + lines.append('') + lines.append(' Builder<STATE | %(camelName)sSet>& set%(camelName)s(%(parameterType)s value)' % setter_args) + lines.append(' {') + lines.append(' COMPILE_ASSERT(!(STATE & %(camelName)sSet), property_%(name)s_already_set);' % setter_args) + + if isinstance(type_member.type, EnumType): + lines.append(' m_result->%(keyedSet)s(ASCIILiteral("%(name)s"), Inspector::Protocol::%(helpersNamespace)s::getEnumConstantValue(value));' % setter_args) + else: + lines.append(' m_result->%(keyedSet)s(ASCIILiteral("%(name)s"), value);' % setter_args) + lines.append(' return castState<%(camelName)sSet>();' % setter_args) + lines.append(' }') + return '\n'.join(lines) + + def _generate_unchecked_setter_for_member(self, type_member, domain): + setter_args = { + 'camelName': ucfirst(type_member.member_name), + 'keyedSet': CppGenerator.cpp_setter_method_for_type(type_member.type), + 'name': type_member.member_name, + 'parameterType': CppGenerator.cpp_type_for_type_member(type_member), + 'helpersNamespace': self.helpers_namespace(), + } + + lines = [] + lines.append('') + lines.append(' void set%(camelName)s(%(parameterType)s value)' % setter_args) + lines.append(' {') + if isinstance(type_member.type, EnumType): + lines.append(' InspectorObjectBase::%(keyedSet)s(ASCIILiteral("%(name)s"), Inspector::Protocol::%(helpersNamespace)s::getEnumConstantValue(value));' % setter_args) + elif CppGenerator.should_use_references_for_type(type_member.type): + lines.append(' InspectorObjectBase::%(keyedSet)s(ASCIILiteral("%(name)s"), WTFMove(value));' % setter_args) + else: + lines.append(' InspectorObjectBase::%(keyedSet)s(ASCIILiteral("%(name)s"), value);' % setter_args) + lines.append(' }') + return '\n'.join(lines) + + def _generate_forward_declarations_for_binding_traits(self): + # A list of (builder_type, needs_runtime_cast) + type_arguments = [] + + for domain in self.domains_to_generate(): + type_declarations = self.type_declarations_for_domain(domain) + declarations_to_generate = filter(lambda decl: self.type_needs_shape_assertions(decl.type), type_declarations) + + for type_declaration in declarations_to_generate: + for type_member in type_declaration.type_members: + if isinstance(type_member.type, EnumType): + type_arguments.append((CppGenerator.cpp_protocol_type_for_type_member(type_member, type_declaration), False)) + + if isinstance(type_declaration.type, ObjectType): + type_arguments.append((CppGenerator.cpp_protocol_type_for_type(type_declaration.type), Generator.type_needs_runtime_casts(type_declaration.type))) + + struct_keywords = ['struct'] + function_keywords = ['static void'] + export_macro = self.model().framework.setting('export_macro', None) + if export_macro is not None: + struct_keywords.append(export_macro) + #function_keywords[1:1] = [export_macro] + + lines = [] + for argument in type_arguments: + lines.append('template<> %s BindingTraits<%s> {' % (' '.join(struct_keywords), argument[0])) + if argument[1]: + lines.append('static RefPtr<%s> runtimeCast(RefPtr<Inspector::InspectorValue>&& value);' % argument[0]) + lines.append('#if !ASSERT_DISABLED') + lines.append('%s assertValueHasExpectedType(Inspector::InspectorValue*);' % ' '.join(function_keywords)) + lines.append('#endif // !ASSERT_DISABLED') + lines.append('};') + return '\n'.join(lines) + + def _generate_declarations_for_enum_conversion_methods(self): + sections = [] + sections.append('\n'.join([ + 'namespace %s {' % self.helpers_namespace(), + '', + 'template<typename ProtocolEnumType>', + 'std::optional<ProtocolEnumType> parseEnumValueFromString(const String&);', + ])) + + def return_type_with_export_macro(cpp_protocol_type): + enum_return_type = 'std::optional<%s>' % cpp_protocol_type + result_terms = [enum_return_type] + export_macro = self.model().framework.setting('export_macro', None) + if export_macro is not None: + result_terms[:0] = [export_macro] + return ' '.join(result_terms) + + def type_member_is_anonymous_enum_type(type_member): + return isinstance(type_member.type, EnumType) and type_member.type.is_anonymous + + for domain in self.domains_to_generate(): + type_declarations = self.type_declarations_for_domain(domain) + declaration_types = [decl.type for decl in type_declarations] + object_types = filter(lambda _type: isinstance(_type, ObjectType), declaration_types) + enum_types = filter(lambda _type: isinstance(_type, EnumType), declaration_types) + if len(object_types) + len(enum_types) == 0: + continue + + sorted(object_types, key=methodcaller('raw_name')) + sorted(enum_types, key=methodcaller('raw_name')) + + domain_lines = [] + domain_lines.append("// Enums in the '%s' Domain" % domain.domain_name) + for enum_type in enum_types: + cpp_protocol_type = CppGenerator.cpp_protocol_type_for_type(enum_type) + domain_lines.append('template<>') + domain_lines.append('%s parseEnumValueFromString<%s>(const String&);' % (return_type_with_export_macro(cpp_protocol_type), cpp_protocol_type)) + + for object_type in object_types: + for enum_member in filter(type_member_is_anonymous_enum_type, object_type.members): + cpp_protocol_type = CppGenerator.cpp_protocol_type_for_type_member(enum_member, object_type.declaration()) + domain_lines.append('template<>') + domain_lines.append('%s parseEnumValueFromString<%s>(const String&);' % (return_type_with_export_macro(cpp_protocol_type), cpp_protocol_type)) + + if len(domain_lines) == 1: + continue # No real declarations to emit, just the domain comment. Skip. + + sections.append(self.wrap_with_guard_for_domain(domain, '\n'.join(domain_lines))) + + if len(sections) == 1: + return [] # No real sections to emit, just the namespace and template declaration. Skip. + + sections.append('} // namespace %s' % self.helpers_namespace()) + + return ['\n\n'.join(sections)] diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py new file mode 100755 index 000000000..f302a7342 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py @@ -0,0 +1,260 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014, 2016 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + + +import logging +import string +from string import Template +from operator import methodcaller + +from cpp_generator import CppGenerator +from cpp_generator_templates import CppGeneratorTemplates as CppTemplates +from generator import Generator, ucfirst +from models import AliasedType, ArrayType, EnumType, ObjectType + +log = logging.getLogger('global') + + +class CppProtocolTypesImplementationGenerator(CppGenerator): + def __init__(self, *args, **kwargs): + CppGenerator.__init__(self, *args, **kwargs) + + def output_filename(self): + return "%sProtocolObjects.cpp" % self.protocol_name() + + def generate_output(self): + domains = self.domains_to_generate() + self.calculate_types_requiring_shape_assertions(domains) + + secondary_headers = [ + '<wtf/Optional.h>', + '<wtf/text/CString.h>', + ] + + header_args = { + 'primaryInclude': '"%sProtocolObjects.h"' % self.protocol_name(), + 'secondaryIncludes': "\n".join(['#include %s' % header for header in secondary_headers]), + } + + sections = [] + sections.append(self.generate_license()) + sections.append(Template(CppTemplates.ImplementationPrelude).substitute(None, **header_args)) + sections.append('namespace Protocol {') + sections.extend(self._generate_enum_mapping_and_conversion_methods(domains)) + sections.append(self._generate_open_field_names()) + builder_sections = map(self._generate_builders_for_domain, domains) + sections.extend(filter(lambda section: len(section) > 0, builder_sections)) + sections.append('} // namespace Protocol') + sections.append(Template(CppTemplates.ImplementationPostlude).substitute(None, **header_args)) + + return "\n\n".join(sections) + + # Private methods. + + def _generate_enum_mapping(self): + if not self.assigned_enum_values(): + return [] + + lines = [] + lines.append('static const char* const enum_constant_values[] = {') + lines.extend([' "%s",' % enum_value for enum_value in self.assigned_enum_values()]) + lines.append('};') + lines.append('') + lines.append('String getEnumConstantValue(int code) {') + lines.append(' return enum_constant_values[code];') + lines.append('}') + return ['\n'.join(lines)] + + def _generate_enum_conversion_methods_for_domain(self, domain): + + def type_member_is_anonymous_enum_type(type_member): + return isinstance(type_member.type, EnumType) and type_member.type.is_anonymous + + def generate_conversion_method_body(enum_type, cpp_protocol_type): + body_lines = [] + body_lines.extend([ + 'template<>', + 'std::optional<%s> parseEnumValueFromString<%s>(const String& protocolString)' % (cpp_protocol_type, cpp_protocol_type), + '{', + ' static const size_t constantValues[] = {', + ]) + + enum_values = enum_type.enum_values() + for enum_value in enum_values: + body_lines.append(' (size_t)%s::%s,' % (cpp_protocol_type, Generator.stylized_name_for_enum_value(enum_value))) + + body_lines.extend([ + ' };', + ' for (size_t i = 0; i < %d; ++i)' % len(enum_values), + ' if (protocolString == enum_constant_values[constantValues[i]])', + ' return (%s)constantValues[i];' % cpp_protocol_type, + '', + ' return std::nullopt;', + '}', + '', + ]) + return body_lines + + type_declarations = self.type_declarations_for_domain(domain) + declaration_types = [decl.type for decl in type_declarations] + object_types = filter(lambda _type: isinstance(_type, ObjectType), declaration_types) + enum_types = filter(lambda _type: isinstance(_type, EnumType), declaration_types) + if len(object_types) + len(enum_types) == 0: + return '' + + sorted(object_types, key=methodcaller('raw_name')) + sorted(enum_types, key=methodcaller('raw_name')) + + lines = [] + lines.append("// Enums in the '%s' Domain" % domain.domain_name) + for enum_type in enum_types: + cpp_protocol_type = CppGenerator.cpp_protocol_type_for_type(enum_type) + lines.extend(generate_conversion_method_body(enum_type, cpp_protocol_type)) + + for object_type in object_types: + for enum_member in filter(type_member_is_anonymous_enum_type, object_type.members): + cpp_protocol_type = CppGenerator.cpp_protocol_type_for_type_member(enum_member, object_type.declaration()) + lines.extend(generate_conversion_method_body(enum_member.type, cpp_protocol_type)) + + if len(lines) == 1: + return '' # No real declarations to emit, just the domain comment. + + return self.wrap_with_guard_for_domain(domain, '\n'.join(lines)) + + def _generate_enum_mapping_and_conversion_methods(self, domains): + sections = [] + sections.append('namespace %s {' % self.helpers_namespace()) + sections.extend(self._generate_enum_mapping()) + enum_parser_sections = map(self._generate_enum_conversion_methods_for_domain, domains) + sections.extend(filter(lambda section: len(section) > 0, enum_parser_sections)) + if len(sections) == 1: + return [] # No declarations to emit, just the namespace. + + sections.append('} // namespace %s' % self.helpers_namespace()) + return sections + + def _generate_open_field_names(self): + lines = [] + for domain in self.domains_to_generate(): + type_declarations = self.type_declarations_for_domain(domain) + for type_declaration in filter(lambda decl: Generator.type_has_open_fields(decl.type), type_declarations): + for type_member in sorted(type_declaration.type_members, key=lambda member: member.member_name): + field_name = '::'.join(['Inspector', 'Protocol', domain.domain_name, ucfirst(type_declaration.type_name), ucfirst(type_member.member_name)]) + lines.append('const char* %s = "%s";' % (field_name, type_member.member_name)) + + return '\n'.join(lines) + + def _generate_builders_for_domain(self, domain): + sections = [] + type_declarations = self.type_declarations_for_domain(domain) + declarations_to_generate = filter(lambda decl: self.type_needs_shape_assertions(decl.type), type_declarations) + + for type_declaration in declarations_to_generate: + for type_member in type_declaration.type_members: + if isinstance(type_member.type, EnumType): + sections.append(self._generate_assertion_for_enum(type_member, type_declaration)) + + if isinstance(type_declaration.type, ObjectType): + sections.append(self._generate_assertion_for_object_declaration(type_declaration)) + if Generator.type_needs_runtime_casts(type_declaration.type): + sections.append(self._generate_runtime_cast_for_object_declaration(type_declaration)) + + return '\n\n'.join(sections) + + def _generate_runtime_cast_for_object_declaration(self, object_declaration): + args = { + 'objectType': CppGenerator.cpp_protocol_type_for_type(object_declaration.type) + } + return Template(CppTemplates.ProtocolObjectRuntimeCast).substitute(None, **args) + + def _generate_assertion_for_object_declaration(self, object_declaration): + required_members = filter(lambda member: not member.is_optional, object_declaration.type_members) + optional_members = filter(lambda member: member.is_optional, object_declaration.type_members) + should_count_properties = not Generator.type_has_open_fields(object_declaration.type) + lines = [] + + lines.append('#if !ASSERT_DISABLED') + lines.append('void BindingTraits<%s>::assertValueHasExpectedType(Inspector::InspectorValue* value)' % (CppGenerator.cpp_protocol_type_for_type(object_declaration.type))) + lines.append("""{ + ASSERT_ARG(value, value); + RefPtr<InspectorObject> object; + bool castSucceeded = value->asObject(object); + ASSERT_UNUSED(castSucceeded, castSucceeded);""") + for type_member in required_members: + args = { + 'memberName': type_member.member_name, + 'assertMethod': CppGenerator.cpp_assertion_method_for_type_member(type_member, object_declaration) + } + + lines.append(""" { + InspectorObject::iterator %(memberName)sPos = object->find(ASCIILiteral("%(memberName)s")); + ASSERT(%(memberName)sPos != object->end()); + %(assertMethod)s(%(memberName)sPos->value.get()); + }""" % args) + + if should_count_properties: + lines.append('') + lines.append(' int foundPropertiesCount = %s;' % len(required_members)) + + for type_member in optional_members: + args = { + 'memberName': type_member.member_name, + 'assertMethod': CppGenerator.cpp_assertion_method_for_type_member(type_member, object_declaration) + } + + lines.append(""" { + InspectorObject::iterator %(memberName)sPos = object->find(ASCIILiteral("%(memberName)s")); + if (%(memberName)sPos != object->end()) { + %(assertMethod)s(%(memberName)sPos->value.get());""" % args) + + if should_count_properties: + lines.append(' ++foundPropertiesCount;') + lines.append(' }') + lines.append(' }') + + if should_count_properties: + lines.append(' if (foundPropertiesCount != object->size())') + lines.append(' FATAL("Unexpected properties in object: %s\\n", object->toJSONString().ascii().data());') + lines.append('}') + lines.append('#endif // !ASSERT_DISABLED') + return '\n'.join(lines) + + def _generate_assertion_for_enum(self, enum_member, object_declaration): + lines = [] + lines.append('#if !ASSERT_DISABLED') + lines.append('void %s(Inspector::InspectorValue* value)' % CppGenerator.cpp_assertion_method_for_type_member(enum_member, object_declaration)) + lines.append('{') + lines.append(' ASSERT_ARG(value, value);') + lines.append(' String result;') + lines.append(' bool castSucceeded = value->asString(result);') + lines.append(' ASSERT(castSucceeded);') + + assert_condition = ' || '.join(['result == "%s"' % enum_value for enum_value in enum_member.type.enum_values()]) + lines.append(' ASSERT(%s);' % assert_condition) + lines.append('}') + lines.append('#endif // !ASSERT_DISABLED') + + return '\n'.join(lines) diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_js_backend_commands.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_js_backend_commands.py new file mode 100755 index 000000000..555c12f89 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_js_backend_commands.py @@ -0,0 +1,145 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014, 2016 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + + +import logging +import string +from string import Template + +from generator import Generator, ucfirst +from generator_templates import GeneratorTemplates as Templates +from models import EnumType + +log = logging.getLogger('global') + + +class JSBackendCommandsGenerator(Generator): + def __init__(self, *args, **kwargs): + Generator.__init__(self, *args, **kwargs) + + def output_filename(self): + return "InspectorBackendCommands.js" + + def should_generate_domain(self, domain): + type_declarations = self.type_declarations_for_domain(domain) + domain_enum_types = filter(lambda declaration: isinstance(declaration.type, EnumType), type_declarations) + return len(self.commands_for_domain(domain)) > 0 or len(self.events_for_domain(domain)) > 0 or len(domain_enum_types) > 0 + + def domains_to_generate(self): + return filter(self.should_generate_domain, Generator.domains_to_generate(self)) + + def generate_output(self): + sections = [] + sections.append(self.generate_license()) + sections.extend(map(self.generate_domain, self.domains_to_generate())) + return "\n\n".join(sections) + + def generate_domain(self, domain): + lines = [] + args = { + 'domain': domain.domain_name + } + + lines.append('// %(domain)s.' % args) + + type_declarations = self.type_declarations_for_domain(domain) + commands = self.commands_for_domain(domain) + events = self.events_for_domain(domain) + + has_async_commands = any(map(lambda command: command.is_async, commands)) + if len(events) > 0 or has_async_commands: + lines.append('InspectorBackend.register%(domain)sDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "%(domain)s");' % args) + + for declaration in type_declarations: + if declaration.type.is_enum(): + enum_args = { + 'domain': domain.domain_name, + 'enumName': declaration.type_name, + 'enumMap': ", ".join(['%s: "%s"' % (Generator.stylized_name_for_enum_value(enum_value), enum_value) for enum_value in declaration.type.enum_values()]) + } + lines.append('InspectorBackend.registerEnum("%(domain)s.%(enumName)s", {%(enumMap)s});' % enum_args) + + def is_anonymous_enum_member(type_member): + return isinstance(type_member.type, EnumType) and type_member.type.is_anonymous + + for _member in filter(is_anonymous_enum_member, declaration.type_members): + enum_args = { + 'domain': domain.domain_name, + 'enumName': '%s%s' % (declaration.type_name, ucfirst(_member.member_name)), + 'enumMap': ", ".join(['%s: "%s"' % (Generator.stylized_name_for_enum_value(enum_value), enum_value) for enum_value in _member.type.enum_values()]) + } + lines.append('InspectorBackend.registerEnum("%(domain)s.%(enumName)s", {%(enumMap)s});' % enum_args) + + def is_anonymous_enum_param(param): + return isinstance(param.type, EnumType) and param.type.is_anonymous + + for event in events: + for param in filter(is_anonymous_enum_param, event.event_parameters): + enum_args = { + 'domain': domain.domain_name, + 'enumName': '%s%s' % (ucfirst(event.event_name), ucfirst(param.parameter_name)), + 'enumMap': ", ".join(['%s: "%s"' % (Generator.stylized_name_for_enum_value(enum_value), enum_value) for enum_value in param.type.enum_values()]) + } + lines.append('InspectorBackend.registerEnum("%(domain)s.%(enumName)s", {%(enumMap)s});' % enum_args) + + event_args = { + 'domain': domain.domain_name, + 'eventName': event.event_name, + 'params': ", ".join(['"%s"' % parameter.parameter_name for parameter in event.event_parameters]) + } + lines.append('InspectorBackend.registerEvent("%(domain)s.%(eventName)s", [%(params)s]);' % event_args) + + for command in commands: + def generate_parameter_object(parameter): + optional_string = "true" if parameter.is_optional else "false" + pairs = [] + pairs.append('"name": "%s"' % parameter.parameter_name) + pairs.append('"type": "%s"' % Generator.js_name_for_parameter_type(parameter.type)) + pairs.append('"optional": %s' % optional_string) + return "{%s}" % ", ".join(pairs) + + command_args = { + 'domain': domain.domain_name, + 'commandName': command.command_name, + 'callParams': ", ".join([generate_parameter_object(parameter) for parameter in command.call_parameters]), + 'returnParams': ", ".join(['"%s"' % parameter.parameter_name for parameter in command.return_parameters]), + } + lines.append('InspectorBackend.registerCommand("%(domain)s.%(commandName)s", [%(callParams)s], [%(returnParams)s]);' % command_args) + + if commands or events: + activate_args = { + 'domain': domain.domain_name, + 'availability': domain.availability, + } + if domain.availability: + lines.append('InspectorBackend.activateDomain("%(domain)s", "%(availability)s");' % activate_args) + else: + lines.append('InspectorBackend.activateDomain("%(domain)s");' % activate_args) + + if domain.workerSupported: + lines.append('InspectorBackend.workerSupportedDomain("%s");' % domain.domain_name) + + return "\n".join(lines) diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py new file mode 100755 index 000000000..0531ed53b --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py @@ -0,0 +1,106 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014, 2016 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + + +import logging +import string +import re +from string import Template + +from cpp_generator import CppGenerator +from generator import Generator +from models import Frameworks +from objc_generator import ObjCGenerator +from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates + +log = logging.getLogger('global') + + +class ObjCBackendDispatcherHeaderGenerator(ObjCGenerator): + def __init__(self, *args, **kwargs): + ObjCGenerator.__init__(self, *args, **kwargs) + + def output_filename(self): + return '%sBackendDispatchers.h' % self.protocol_name() + + def domains_to_generate(self): + return filter(self.should_generate_commands_for_domain, Generator.domains_to_generate(self)) + + def generate_output(self): + headers = [ + '<JavaScriptCore/InspectorAlternateBackendDispatchers.h>', + '<wtf/RetainPtr.h>', + ] + + header_args = { + 'includes': '\n'.join(['#include ' + header for header in headers]), + 'forwardDeclarations': self._generate_objc_forward_declarations(), + } + + domains = self.domains_to_generate() + sections = [] + sections.append(self.generate_license()) + sections.append(Template(ObjCTemplates.BackendDispatcherHeaderPrelude).substitute(None, **header_args)) + sections.extend(map(self._generate_objc_handler_declarations_for_domain, domains)) + sections.append(Template(ObjCTemplates.BackendDispatcherHeaderPostlude).substitute(None, **header_args)) + return '\n\n'.join(sections) + + def _generate_objc_forward_declarations(self): + lines = [] + for domain in self.domains_to_generate(): + if self.commands_for_domain(domain): + lines.append('@protocol %s%sDomainHandler;' % (self.objc_prefix(), domain.domain_name)) + return '\n'.join(lines) + + def _generate_objc_handler_declarations_for_domain(self, domain): + commands = self.commands_for_domain(domain) + if not commands: + return '' + + command_declarations = [] + for command in commands: + command_declarations.append(self._generate_objc_handler_declaration_for_command(command)) + + handler_args = { + 'domainName': domain.domain_name, + 'commandDeclarations': '\n'.join(command_declarations), + 'objcPrefix': self.objc_prefix(), + } + + return self.wrap_with_guard_for_domain(domain, Template(ObjCTemplates.BackendDispatcherHeaderDomainHandlerObjCDeclaration).substitute(None, **handler_args)) + + def _generate_objc_handler_declaration_for_command(self, command): + lines = [] + parameters = ['long requestId'] + for _parameter in command.call_parameters: + parameters.append('%s in_%s' % (CppGenerator.cpp_type_for_unchecked_formal_in_parameter(_parameter), _parameter.parameter_name)) + + command_args = { + 'commandName': command.command_name, + 'parameters': ', '.join(parameters), + } + lines.append(' virtual void %(commandName)s(%(parameters)s) override;' % command_args) + return '\n'.join(lines) diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py new file mode 100755 index 000000000..0b1055d24 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py @@ -0,0 +1,210 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014-2016 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + + +import logging +import string +import re +from string import Template + +from cpp_generator import CppGenerator +from generator import Generator +from models import PrimitiveType, EnumType, AliasedType, Frameworks +from objc_generator import ObjCTypeCategory, ObjCGenerator, join_type_and_name +from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates + +log = logging.getLogger('global') + + +class ObjCBackendDispatcherImplementationGenerator(ObjCGenerator): + def __init__(self, *args, **kwargs): + ObjCGenerator.__init__(self, *args, **kwargs) + + def output_filename(self): + return '%sBackendDispatchers.mm' % self.protocol_name() + + def domains_to_generate(self): + return filter(self.should_generate_commands_for_domain, Generator.domains_to_generate(self)) + + def generate_output(self): + secondary_headers = [ + '"%sInternal.h"' % self.protocol_name(), + '"%sTypeConversions.h"' % self.protocol_name(), + '<JavaScriptCore/InspectorValues.h>', + ] + + header_args = { + 'primaryInclude': '"%sBackendDispatchers.h"' % self.protocol_name(), + 'secondaryIncludes': '\n'.join(['#include %s' % header for header in secondary_headers]), + } + + domains = self.domains_to_generate() + sections = [] + sections.append(self.generate_license()) + sections.append(Template(ObjCTemplates.BackendDispatcherImplementationPrelude).substitute(None, **header_args)) + sections.extend(map(self._generate_handler_implementation_for_domain, domains)) + sections.append(Template(ObjCTemplates.BackendDispatcherImplementationPostlude).substitute(None, **header_args)) + return '\n\n'.join(sections) + + def _generate_handler_implementation_for_domain(self, domain): + commands = self.commands_for_domain(domain) + + if not commands: + return '' + + command_declarations = [] + for command in commands: + command_declarations.append(self._generate_handler_implementation_for_command(domain, command)) + + return '\n'.join(command_declarations) + + def _generate_handler_implementation_for_command(self, domain, command): + lines = [] + parameters = ['long requestId'] + for parameter in command.call_parameters: + parameters.append('%s in_%s' % (CppGenerator.cpp_type_for_unchecked_formal_in_parameter(parameter), parameter.parameter_name)) + + command_args = { + 'domainName': domain.domain_name, + 'commandName': command.command_name, + 'parameters': ', '.join(parameters), + 'successCallback': self._generate_success_block_for_command(domain, command), + 'conversions': self._generate_conversions_for_command(domain, command), + 'invocation': self._generate_invocation_for_command(domain, command), + } + + return self.wrap_with_guard_for_domain(domain, Template(ObjCTemplates.BackendDispatcherHeaderDomainHandlerImplementation).substitute(None, **command_args)) + + def _generate_success_block_for_command(self, domain, command): + lines = [] + + if command.return_parameters: + success_block_parameters = [] + for parameter in command.return_parameters: + objc_type = self.objc_type_for_param(domain, command.command_name, parameter) + var_name = ObjCGenerator.identifier_to_objc_identifier(parameter.parameter_name) + success_block_parameters.append(join_type_and_name(objc_type, var_name)) + lines.append(' id successCallback = ^(%s) {' % ', '.join(success_block_parameters)) + else: + lines.append(' id successCallback = ^{') + + if command.return_parameters: + lines.append(' Ref<InspectorObject> resultObject = InspectorObject::create();') + + required_pointer_parameters = filter(lambda parameter: not parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type), command.return_parameters) + for parameter in required_pointer_parameters: + var_name = ObjCGenerator.identifier_to_objc_identifier(parameter.parameter_name) + lines.append(' THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(%s, @"%s");' % (var_name, var_name)) + objc_array_class = self.objc_class_for_array_type(parameter.type) + if objc_array_class and objc_array_class.startswith(self.objc_prefix()): + lines.append(' THROW_EXCEPTION_FOR_BAD_TYPE_IN_ARRAY(%s, [%s class]);' % (var_name, objc_array_class)) + + optional_pointer_parameters = filter(lambda parameter: parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type), command.return_parameters) + for parameter in optional_pointer_parameters: + var_name = ObjCGenerator.identifier_to_objc_identifier(parameter.parameter_name) + lines.append(' THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(%s, @"%s");' % (var_name, var_name)) + objc_array_class = self.objc_class_for_array_type(parameter.type) + if objc_array_class and objc_array_class.startswith(self.objc_prefix()): + lines.append(' THROW_EXCEPTION_FOR_BAD_TYPE_IN_OPTIONAL_ARRAY(%s, [%s class]);' % (var_name, objc_array_class)) + + for parameter in command.return_parameters: + keyed_set_method = CppGenerator.cpp_setter_method_for_type(parameter.type) + var_name = ObjCGenerator.identifier_to_objc_identifier(parameter.parameter_name) + var_expression = '*%s' % var_name if parameter.is_optional else var_name + export_expression = self.objc_protocol_export_expression_for_variable(parameter.type, var_expression) + if not parameter.is_optional: + lines.append(' resultObject->%s(ASCIILiteral("%s"), %s);' % (keyed_set_method, parameter.parameter_name, export_expression)) + else: + lines.append(' if (%s)' % var_name) + lines.append(' resultObject->%s(ASCIILiteral("%s"), %s);' % (keyed_set_method, parameter.parameter_name, export_expression)) + lines.append(' backendDispatcher()->sendResponse(requestId, WTFMove(resultObject));') + else: + lines.append(' backendDispatcher()->sendResponse(requestId, InspectorObject::create());') + + lines.append(' };') + return '\n'.join(lines) + + def _generate_conversions_for_command(self, domain, command): + lines = [] + if command.call_parameters: + lines.append('') + + def in_param_expression(param_name, parameter): + _type = parameter.type + if isinstance(_type, AliasedType): + _type = _type.aliased_type # Fall through to enum or primitive. + if isinstance(_type, EnumType): + _type = _type.primitive_type # Fall through to primitive. + if isinstance(_type, PrimitiveType): + if _type.raw_name() in ['array', 'any', 'object']: + return '&%s' % param_name if not parameter.is_optional else param_name + return '*%s' % param_name if parameter.is_optional else param_name + return '&%s' % param_name if not parameter.is_optional else param_name + + for parameter in command.call_parameters: + in_param_name = 'in_%s' % parameter.parameter_name + objc_in_param_name = 'o_%s' % in_param_name + objc_type = self.objc_type_for_param(domain, command.command_name, parameter, False) + if isinstance(parameter.type, EnumType): + objc_type = 'std::optional<%s>' % objc_type + param_expression = in_param_expression(in_param_name, parameter) + import_expression = self.objc_protocol_import_expression_for_parameter(param_expression, domain, command.command_name, parameter) + if not parameter.is_optional: + lines.append(' %s = %s;' % (join_type_and_name(objc_type, objc_in_param_name), import_expression)) + + if isinstance(parameter.type, EnumType): + lines.append(' if (!%s) {' % objc_in_param_name) + lines.append(' backendDispatcher()->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Parameter \'%%s\' of method \'%%s\' cannot be processed", "%s", "%s.%s"));' % (parameter.parameter_name, domain.domain_name, command.command_name)) + lines.append(' return;') + lines.append(' }') + + else: + lines.append(' %s;' % join_type_and_name(objc_type, objc_in_param_name)) + lines.append(' if (%s)' % in_param_name) + lines.append(' %s = %s;' % (objc_in_param_name, import_expression)) + + if lines: + lines.append('') + return '\n'.join(lines) + + def _generate_invocation_for_command(self, domain, command): + pairs = [] + pairs.append('WithErrorCallback:errorCallback') + pairs.append('successCallback:successCallback') + for parameter in command.call_parameters: + in_param_name = 'in_%s' % parameter.parameter_name + objc_in_param_expression = 'o_%s' % in_param_name + if not parameter.is_optional: + # FIXME: we don't handle optional enum values in commands here because it isn't used anywhere yet. + # We'd need to change the delegate's signature to take std::optional for optional enum values. + if isinstance(parameter.type, EnumType): + objc_in_param_expression = '%s.value()' % objc_in_param_expression + + pairs.append('%s:%s' % (parameter.parameter_name, objc_in_param_expression)) + else: + optional_expression = '(%s ? &%s : nil)' % (in_param_name, objc_in_param_expression) + pairs.append('%s:%s' % (parameter.parameter_name, optional_expression)) + return ' [m_delegate %s%s];' % (command.command_name, ' '.join(pairs)) diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_header.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_header.py new file mode 100755 index 000000000..a232e2ce4 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_header.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014, 2016 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + + +import logging +import string +from string import Template + +from generator import Generator +from objc_generator import ObjCGenerator +from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates + +log = logging.getLogger('global') + + +class ObjCConfigurationHeaderGenerator(ObjCGenerator): + def __init__(self, *args, **kwargs): + ObjCGenerator.__init__(self, *args, **kwargs) + + def output_filename(self): + return '%sConfiguration.h' % self.protocol_name() + + def generate_output(self): + headers = [ + '<WebInspector/%s.h>' % self.protocol_name(), + ] + + header_args = { + 'includes': '\n'.join(['#import ' + header for header in headers]), + } + + domains = self.domains_to_generate() + sections = [] + sections.append(self.generate_license()) + sections.append(Template(ObjCTemplates.GenericHeaderPrelude).substitute(None, **header_args)) + sections.append(self._generate_configuration_interface_for_domains(domains)) + sections.append(Template(ObjCTemplates.GenericHeaderPostlude).substitute(None, **header_args)) + return '\n\n'.join(sections) + + def _generate_configuration_interface_for_domains(self, domains): + lines = [] + lines.append('__attribute__((visibility ("default")))') + lines.append('@interface %sConfiguration : NSObject' % self.protocol_name()) + for domain in domains: + lines.extend(self._generate_properties_for_domain(domain)) + lines.append('@end') + return '\n'.join(lines) + + def _generate_properties_for_domain(self, domain): + property_args = { + 'objcPrefix': self.objc_prefix(), + 'domainName': domain.domain_name, + 'variableNamePrefix': ObjCGenerator.variable_name_prefix_for_domain(domain), + } + + lines = [] + + if self.should_generate_commands_for_domain(domain): + lines.append(Template(ObjCTemplates.ConfigurationCommandProperty).substitute(None, **property_args)) + if self.should_generate_events_for_domain(domain): + lines.append(Template(ObjCTemplates.ConfigurationEventProperty).substitute(None, **property_args)) + return lines diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_implementation.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_implementation.py new file mode 100755 index 000000000..910bcbab1 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_implementation.py @@ -0,0 +1,147 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014, 2016 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + + +import logging +import string +from string import Template + +from generator import Generator +from objc_generator import ObjCGenerator +from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates + +log = logging.getLogger('global') + + +class ObjCConfigurationImplementationGenerator(ObjCGenerator): + def __init__(self, *args, **kwargs): + ObjCGenerator.__init__(self, *args, **kwargs) + + def output_filename(self): + return '%sConfiguration.mm' % self.protocol_name() + + def generate_output(self): + secondary_headers = [ + '"%sInternal.h"' % self.protocol_name(), + '"%sBackendDispatchers.h"' % self.protocol_name(), + '<JavaScriptCore/AlternateDispatchableAgent.h>', + '<JavaScriptCore/AugmentableInspectorController.h>', + '<JavaScriptCore/InspectorAlternateBackendDispatchers.h>', + '<JavaScriptCore/InspectorBackendDispatchers.h>', + ] + + header_args = { + 'primaryInclude': '"%sConfiguration.h"' % self.protocol_name(), + 'secondaryIncludes': '\n'.join(['#import %s' % header for header in secondary_headers]), + } + + domains = self.domains_to_generate() + sections = [] + sections.append(self.generate_license()) + sections.append(Template(ObjCTemplates.ImplementationPrelude).substitute(None, **header_args)) + sections.append(self._generate_configuration_implementation_for_domains(domains)) + sections.append(Template(ObjCTemplates.ImplementationPostlude).substitute(None, **header_args)) + return '\n\n'.join(sections) + + def _generate_configuration_implementation_for_domains(self, domains): + lines = [] + lines.append('@implementation %sConfiguration' % self.protocol_name()) + lines.append('{') + lines.append(' AugmentableInspectorController* _controller;') + lines.extend(self._generate_ivars(domains)) + lines.append('}') + lines.append('') + lines.append('- (instancetype)initWithController:(AugmentableInspectorController*)controller') + lines.append('{') + lines.append(' self = [super init];') + lines.append(' if (!self)') + lines.append(' return nil;') + lines.append(' ASSERT(controller);') + lines.append(' _controller = controller;') + lines.append(' return self;') + lines.append('}') + lines.append('') + lines.extend(self._generate_dealloc(domains)) + lines.append('') + for domain in domains: + if self.should_generate_commands_for_domain(domain): + lines.append(self._generate_handler_setter_for_domain(domain)) + lines.append('') + if self.should_generate_events_for_domain(domain): + lines.append(self._generate_event_dispatcher_getter_for_domain(domain)) + lines.append('') + lines.append('@end') + return '\n'.join(lines) + + def _generate_ivars(self, domains): + lines = [] + for domain in domains: + if self.should_generate_commands_for_domain(domain): + objc_class_name = '%s%sDomainHandler' % (self.objc_prefix(), domain.domain_name) + ivar_name = '_%sHandler' % ObjCGenerator.variable_name_prefix_for_domain(domain) + lines.append(' id<%s> %s;' % (objc_class_name, ivar_name)) + if self.should_generate_events_for_domain(domain): + objc_class_name = '%s%sDomainEventDispatcher' % (self.objc_prefix(), domain.domain_name) + ivar_name = '_%sEventDispatcher' % ObjCGenerator.variable_name_prefix_for_domain(domain) + lines.append(' %s *%s;' % (objc_class_name, ivar_name)) + return lines + + def _generate_dealloc(self, domains): + lines = [] + lines.append('- (void)dealloc') + lines.append('{') + for domain in domains: + if self.should_generate_commands_for_domain(domain): + lines.append(' [_%sHandler release];' % ObjCGenerator.variable_name_prefix_for_domain(domain)) + if self.should_generate_events_for_domain(domain): + lines.append(' [_%sEventDispatcher release];' % ObjCGenerator.variable_name_prefix_for_domain(domain)) + lines.append(' [super dealloc];') + lines.append('}') + return lines + + def _generate_handler_setter_for_domain(self, domain): + setter_args = { + 'objcPrefix': self.objc_prefix(), + 'domainName': domain.domain_name, + 'variableNamePrefix': ObjCGenerator.variable_name_prefix_for_domain(domain), + } + return Template(ObjCTemplates.ConfigurationCommandPropertyImplementation).substitute(None, **setter_args) + + def _generate_event_dispatcher_getter_for_domain(self, domain): + getter_args = { + 'objcPrefix': self.objc_prefix(), + 'domainName': domain.domain_name, + 'variableNamePrefix': ObjCGenerator.variable_name_prefix_for_domain(domain), + } + return Template(ObjCTemplates.ConfigurationGetterImplementation).substitute(None, **getter_args) + + def _variable_name_prefix_for_domain(self, domain): + domain_name = domain.domain_name + if domain_name.startswith('DOM'): + return 'dom' + domain_name[3:] + if domain_name.startswith('CSS'): + return 'css' + domain_name[3:] + return domain_name[:1].lower() + domain_name[1:] diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py new file mode 100755 index 000000000..722d5d392 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py @@ -0,0 +1,154 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014-2016 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + + +import logging +import string +from string import Template + +from cpp_generator import CppGenerator +from generator import Generator, ucfirst +from objc_generator import ObjCGenerator +from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates + +log = logging.getLogger('global') + + +class ObjCFrontendDispatcherImplementationGenerator(ObjCGenerator): + def __init__(self, *args, **kwargs): + ObjCGenerator.__init__(self, *args, **kwargs) + + def output_filename(self): + return '%sEventDispatchers.mm' % self.protocol_name() + + def domains_to_generate(self): + return filter(self.should_generate_events_for_domain, Generator.domains_to_generate(self)) + + def generate_output(self): + secondary_headers = [ + '"%sTypeConversions.h"' % self.protocol_name(), + '<JavaScriptCore/InspectorValues.h>', + ] + + header_args = { + 'primaryInclude': '"%sInternal.h"' % self.protocol_name(), + 'secondaryIncludes': '\n'.join(['#import %s' % header for header in secondary_headers]), + } + + domains = self.domains_to_generate() + sections = [] + sections.append(self.generate_license()) + sections.append(Template(ObjCTemplates.ImplementationPrelude).substitute(None, **header_args)) + sections.extend(map(self._generate_event_dispatcher_implementations, domains)) + sections.append(Template(ObjCTemplates.ImplementationPostlude).substitute(None, **header_args)) + return '\n\n'.join(sections) + + def _generate_event_dispatcher_implementations(self, domain): + if not self.should_generate_events_for_domain(domain): + return '' + + lines = [] + objc_name = '%s%sDomainEventDispatcher' % (self.objc_prefix(), domain.domain_name) + lines.append('@implementation %s' % objc_name) + lines.append('{') + lines.append(' AugmentableInspectorController* _controller;') + lines.append('}') + lines.append('') + lines.append('- (instancetype)initWithController:(AugmentableInspectorController*)controller;') + lines.append('{') + lines.append(' self = [super init];') + lines.append(' if (!self)') + lines.append(' return nil;') + lines.append(' ASSERT(controller);') + lines.append(' _controller = controller;') + lines.append(' return self;') + lines.append('}') + lines.append('') + for event in self.events_for_domain(domain): + lines.append(self._generate_event(domain, event)) + lines.append('') + lines.append('@end') + return '\n'.join(lines) + + def _generate_event(self, domain, event): + lines = [] + lines.append(self._generate_event_signature(domain, event)) + lines.append('{') + lines.append(' const FrontendRouter& router = _controller->frontendRouter();') + lines.append('') + + required_pointer_parameters = filter(lambda parameter: not parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type), event.event_parameters) + for parameter in required_pointer_parameters: + var_name = ObjCGenerator.identifier_to_objc_identifier(parameter.parameter_name) + lines.append(' THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(%s, @"%s");' % (var_name, var_name)) + objc_array_class = self.objc_class_for_array_type(parameter.type) + if objc_array_class and objc_array_class.startswith(self.objc_prefix()): + lines.append(' THROW_EXCEPTION_FOR_BAD_TYPE_IN_ARRAY(%s, [%s class]);' % (var_name, objc_array_class)) + + optional_pointer_parameters = filter(lambda parameter: parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type), event.event_parameters) + for parameter in optional_pointer_parameters: + var_name = ObjCGenerator.identifier_to_objc_identifier(parameter.parameter_name) + lines.append(' THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(%s, @"%s");' % (var_name, var_name)) + objc_array_class = self.objc_class_for_array_type(parameter.type) + if objc_array_class and objc_array_class.startswith(self.objc_prefix()): + lines.append(' THROW_EXCEPTION_FOR_BAD_TYPE_IN_OPTIONAL_ARRAY(%s, [%s class]);' % (var_name, objc_array_class)) + + if required_pointer_parameters or optional_pointer_parameters: + lines.append('') + + lines.append(' Ref<InspectorObject> jsonMessage = InspectorObject::create();') + lines.append(' jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("%s.%s"));' % (domain.domain_name, event.event_name)) + if event.event_parameters: + lines.extend(self._generate_event_out_parameters(domain, event)) + lines.append(' router.sendEvent(jsonMessage->toJSONString());') + lines.append('}') + return '\n'.join(lines) + + def _generate_event_signature(self, domain, event): + if not event.event_parameters: + return '- (void)%s' % event.event_name + pairs = [] + for parameter in event.event_parameters: + param_name = parameter.parameter_name + pairs.append('%s:(%s)%s' % (param_name, self.objc_type_for_param(domain, event.event_name, parameter), param_name)) + pairs[0] = ucfirst(pairs[0]) + return '- (void)%sWith%s' % (event.event_name, ' '.join(pairs)) + + def _generate_event_out_parameters(self, domain, event): + lines = [] + lines.append(' Ref<InspectorObject> paramsObject = InspectorObject::create();') + for parameter in event.event_parameters: + keyed_set_method = CppGenerator.cpp_setter_method_for_type(parameter.type) + var_name = parameter.parameter_name + safe_var_name = '(*%s)' % var_name if parameter.is_optional else var_name + export_expression = self.objc_protocol_export_expression_for_variable(parameter.type, safe_var_name) + if not parameter.is_optional: + lines.append(' paramsObject->%s(ASCIILiteral("%s"), %s);' % (keyed_set_method, parameter.parameter_name, export_expression)) + else: + lines.append(' if (%s)' % (parameter.parameter_name)) + lines.append(' paramsObject->%s(ASCIILiteral("%s"), %s);' % (keyed_set_method, parameter.parameter_name, export_expression)) + lines.append(' jsonMessage->setObject(ASCIILiteral("params"), WTFMove(paramsObject));') + return lines diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_header.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_header.py new file mode 100755 index 000000000..801f40a86 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_header.py @@ -0,0 +1,245 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014, 2016 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + + +import logging +import string +from string import Template + +from generator import Generator, ucfirst +from models import ObjectType, EnumType, Platforms +from objc_generator import ObjCGenerator, join_type_and_name +from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates + +log = logging.getLogger('global') + + +def add_newline(lines): + if lines and lines[-1] == '': + return + lines.append('') + + +class ObjCHeaderGenerator(ObjCGenerator): + def __init__(self, *args, **kwargs): + ObjCGenerator.__init__(self, *args, **kwargs) + + def output_filename(self): + return '%s.h' % self.protocol_name() + + def generate_output(self): + headers = set([ + '<WebInspector/%sJSONObject.h>' % ObjCGenerator.OBJC_STATIC_PREFIX, + ]) + + header_args = { + 'includes': '\n'.join(['#import ' + header for header in sorted(headers)]), + } + + domains = self.domains_to_generate() + type_domains = filter(self.should_generate_types_for_domain, domains) + command_domains = filter(self.should_generate_commands_for_domain, domains) + event_domains = filter(self.should_generate_events_for_domain, domains) + + # FIXME: <https://webkit.org/b/138222> Web Inspector: Reduce unnecessary enums/types generated in ObjC Protocol Interfaces + # Currently we generate enums/types for all types in the type_domains. For the built-in + # JSC domains (Debugger, Runtime) this produces extra unused types. We only need to + # generate these types if they are referenced by the command_domains or event_domains. + + sections = [] + sections.append(self.generate_license()) + sections.append(Template(ObjCTemplates.HeaderPrelude).substitute(None, **header_args)) + sections.append('\n'.join(filter(None, map(self._generate_forward_declarations, type_domains)))) + sections.append(self._generate_enum_for_platforms()) + sections.append('\n'.join(filter(None, map(self._generate_enums, type_domains)))) + sections.append('\n'.join(filter(None, map(self._generate_types, type_domains)))) + + if self.get_generator_setting('generate_backend', False): + sections.append('\n\n'.join(filter(None, map(self._generate_command_protocols, command_domains)))) + sections.append('\n\n'.join(filter(None, map(self._generate_event_interfaces, event_domains)))) + + sections.append(Template(ObjCTemplates.HeaderPostlude).substitute(None)) + return '\n\n'.join(sections) + + def _generate_forward_declarations(self, domain): + lines = [] + for declaration in self.type_declarations_for_domain(domain): + if (isinstance(declaration.type, ObjectType)): + objc_name = self.objc_name_for_type(declaration.type) + lines.append('@class %s;' % objc_name) + return '\n'.join(lines) + + def _generate_enums(self, domain): + lines = [] + + # Type enums and member enums. + for declaration in self.type_declarations_for_domain(domain): + if isinstance(declaration.type, EnumType): + add_newline(lines) + lines.append(self._generate_anonymous_enum_for_declaration(domain, declaration)) + else: + for member in declaration.type_members: + if isinstance(member.type, EnumType) and member.type.is_anonymous: + add_newline(lines) + lines.append(self._generate_anonymous_enum_for_member(domain, declaration, member)) + + # Anonymous command enums. + for command in self.commands_for_domain(domain): + for parameter in command.call_parameters: + if isinstance(parameter.type, EnumType) and parameter.type.is_anonymous: + add_newline(lines) + lines.append(self._generate_anonymous_enum_for_parameter(domain, command.command_name, parameter)) + for parameter in command.return_parameters: + if isinstance(parameter.type, EnumType) and parameter.type.is_anonymous: + add_newline(lines) + lines.append(self._generate_anonymous_enum_for_parameter(domain, command.command_name, parameter)) + + # Anonymous event enums. + for event in self.events_for_domain(domain): + for parameter in event.event_parameters: + if isinstance(parameter.type, EnumType) and parameter.type.is_anonymous: + add_newline(lines) + lines.append(self._generate_anonymous_enum_for_parameter(domain, event.event_name, parameter)) + + return '\n'.join(lines) + + def _generate_types(self, domain): + lines = [] + # Type interfaces. + for declaration in self.type_declarations_for_domain(domain): + if isinstance(declaration.type, ObjectType): + add_newline(lines) + lines.append(self._generate_type_interface(domain, declaration)) + return '\n'.join(lines) + + def _generate_enum_for_platforms(self): + objc_enum_name = '%sPlatform' % self.objc_prefix() + enum_values = [platform.name for platform in Platforms] + return self._generate_enum(objc_enum_name, enum_values) + + def _generate_anonymous_enum_for_declaration(self, domain, declaration): + objc_enum_name = self.objc_enum_name_for_anonymous_enum_declaration(declaration) + return self._generate_enum(objc_enum_name, declaration.type.enum_values()) + + def _generate_anonymous_enum_for_member(self, domain, declaration, member): + objc_enum_name = self.objc_enum_name_for_anonymous_enum_member(declaration, member) + return self._generate_enum(objc_enum_name, member.type.enum_values()) + + def _generate_anonymous_enum_for_parameter(self, domain, event_or_command_name, parameter): + objc_enum_name = self.objc_enum_name_for_anonymous_enum_parameter(domain, event_or_command_name, parameter) + return self._generate_enum(objc_enum_name, parameter.type.enum_values()) + + def _generate_enum(self, enum_name, enum_values): + lines = [] + lines.append('typedef NS_ENUM(NSInteger, %s) {' % enum_name) + for enum_value in enum_values: + lines.append(' %s%s,' % (enum_name, Generator.stylized_name_for_enum_value(enum_value))) + lines.append('};') + return '\n'.join(lines) + + def _generate_type_interface(self, domain, declaration): + lines = [] + objc_name = self.objc_name_for_type(declaration.type) + lines.append('__attribute__((visibility ("default")))') + lines.append('@interface %s : %sJSONObject' % (objc_name, ObjCGenerator.OBJC_STATIC_PREFIX)) + + # The initializers that take a payload or inspector object are only needed by the frontend. + if self.get_generator_setting('generate_frontend', False): + lines.append('- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload;') + lines.append('- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject;') + + required_members = filter(lambda member: not member.is_optional, declaration.type_members) + optional_members = filter(lambda member: member.is_optional, declaration.type_members) + if required_members: + lines.append(self._generate_init_method_for_required_members(domain, declaration, required_members)) + for member in required_members: + lines.append('/* required */ ' + self._generate_member_property(declaration, member)) + for member in optional_members: + lines.append('/* optional */ ' + self._generate_member_property(declaration, member)) + lines.append('@end') + return '\n'.join(lines) + + def _generate_init_method_for_required_members(self, domain, declaration, required_members): + pairs = [] + for member in required_members: + objc_type = self.objc_type_for_member(declaration, member) + var_name = ObjCGenerator.identifier_to_objc_identifier(member.member_name) + pairs.append('%s:(%s)%s' % (var_name, objc_type, var_name)) + pairs[0] = ucfirst(pairs[0]) + return '- (instancetype)initWith%s;' % ' '.join(pairs) + + def _generate_member_property(self, declaration, member): + accessor_type = self.objc_accessor_type_for_member(member) + objc_type = self.objc_type_for_member(declaration, member) + return '@property (nonatomic, %s) %s;' % (accessor_type, join_type_and_name(objc_type, ObjCGenerator.identifier_to_objc_identifier(member.member_name))) + + def _generate_command_protocols(self, domain): + lines = [] + if self.commands_for_domain(domain): + objc_name = '%s%sDomainHandler' % (self.objc_prefix(), domain.domain_name) + lines.append('@protocol %s <NSObject>' % objc_name) + lines.append('@required') + for command in self.commands_for_domain(domain): + lines.append(self._generate_single_command_protocol(domain, command)) + lines.append('@end') + return '\n'.join(lines) + + def _generate_single_command_protocol(self, domain, command): + pairs = [] + pairs.append('ErrorCallback:(void(^)(NSString *error))errorCallback') + pairs.append('successCallback:(%s)successCallback' % self._callback_block_for_command(domain, command)) + for parameter in command.call_parameters: + param_name = parameter.parameter_name + pairs.append('%s:(%s)%s' % (param_name, self.objc_type_for_param(domain, command.command_name, parameter), param_name)) + return '- (void)%sWith%s;' % (command.command_name, ' '.join(pairs)) + + def _callback_block_for_command(self, domain, command): + pairs = [] + for parameter in command.return_parameters: + pairs.append(join_type_and_name(self.objc_type_for_param(domain, command.command_name, parameter), parameter.parameter_name)) + return 'void(^)(%s)' % ', '.join(pairs) + + def _generate_event_interfaces(self, domain): + lines = [] + events = self.events_for_domain(domain) + if len(events): + objc_name = '%s%sDomainEventDispatcher' % (self.objc_prefix(), domain.domain_name) + lines.append('__attribute__((visibility ("default")))') + lines.append('@interface %s : NSObject' % objc_name) + for event in events: + lines.append(self._generate_single_event_interface(domain, event)) + lines.append('@end') + return '\n'.join(lines) + + def _generate_single_event_interface(self, domain, event): + if not event.event_parameters: + return '- (void)%s;' % event.event_name + pairs = [] + for parameter in event.event_parameters: + param_name = parameter.parameter_name + pairs.append('%s:(%s)%s' % (param_name, self.objc_type_for_param(domain, event.event_name, parameter), param_name)) + pairs[0] = ucfirst(pairs[0]) + return '- (void)%sWith%s;' % (event.event_name, ' '.join(pairs)) diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_internal_header.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_internal_header.py new file mode 100755 index 000000000..9f06ced40 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_internal_header.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014, 2016 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + + +import logging +import string +from string import Template + +from generator import Generator, ucfirst +from objc_generator import ObjCGenerator +from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates + +log = logging.getLogger('global') + + +class ObjCInternalHeaderGenerator(ObjCGenerator): + def __init__(self, *args, **kwargs): + ObjCGenerator.__init__(self, *args, **kwargs) + + def output_filename(self): + return '%sInternal.h' % self.protocol_name() + + def generate_output(self): + headers = set([ + '"%s.h"' % self.protocol_name(), + '"%sJSONObjectPrivate.h"' % self.protocol_name(), + '<JavaScriptCore/InspectorValues.h>', + '<JavaScriptCore/AugmentableInspectorController.h>', + ]) + + header_args = { + 'includes': '\n'.join(['#import ' + header for header in sorted(headers)]), + } + + event_domains = filter(self.should_generate_events_for_domain, self.domains_to_generate()) + + sections = [] + sections.append(self.generate_license()) + sections.append(Template(ObjCTemplates.GenericHeaderPrelude).substitute(None, **header_args)) + sections.append('\n\n'.join(filter(None, map(self._generate_event_dispatcher_private_interfaces, event_domains)))) + sections.append(Template(ObjCTemplates.GenericHeaderPostlude).substitute(None, **header_args)) + return '\n\n'.join(sections) + + def _generate_event_dispatcher_private_interfaces(self, domain): + lines = [] + if len(self.events_for_domain(domain)): + objc_name = '%s%sDomainEventDispatcher' % (self.objc_prefix(), domain.domain_name) + lines.append('@interface %s (Private)' % objc_name) + lines.append('- (instancetype)initWithController:(Inspector::AugmentableInspectorController*)controller;') + lines.append('@end') + return '\n'.join(lines) diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py new file mode 100755 index 000000000..ea9e6e2d7 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py @@ -0,0 +1,165 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014, 2016 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + + +import logging +import string +from string import Template + +from generator import Generator +from models import EnumType, Frameworks, Platforms +from objc_generator import ObjCGenerator +from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates + +log = logging.getLogger('global') + + +def add_newline(lines): + if lines and lines[-1] == '': + return + lines.append('') + + +class ObjCProtocolTypeConversionsHeaderGenerator(ObjCGenerator): + def __init__(self, *args, **kwargs): + ObjCGenerator.__init__(self, *args, **kwargs) + + def output_filename(self): + return '%sTypeConversions.h' % self.protocol_name() + + def domains_to_generate(self): + return filter(self.should_generate_types_for_domain, Generator.domains_to_generate(self)) + + def generate_output(self): + headers = [ + '"%s.h"' % self.protocol_name(), + Generator.string_for_file_include('%sArrayConversions.h' % ObjCGenerator.OBJC_STATIC_PREFIX, Frameworks.WebInspector, self.model().framework), + ] + headers.sort() + + header_args = { + 'includes': '\n'.join(['#import ' + header for header in headers]), + } + + domains = self.domains_to_generate() + sections = [] + sections.append(self.generate_license()) + sections.append(Template(ObjCTemplates.TypeConversionsHeaderPrelude).substitute(None, **header_args)) + sections.append(Template(ObjCTemplates.TypeConversionsHeaderStandard).substitute(None)) + sections.append(self._generate_enum_conversion_for_platforms()) + sections.extend(map(self._generate_enum_conversion_functions, domains)) + sections.append(Template(ObjCTemplates.TypeConversionsHeaderPostlude).substitute(None, **header_args)) + return '\n\n'.join(sections) + + def _generate_enum_conversion_functions(self, domain): + lines = [] + + # Type enums and member enums. + for declaration in self.type_declarations_for_domain(domain): + if isinstance(declaration.type, EnumType): + add_newline(lines) + lines.append(self._generate_anonymous_enum_conversion_for_declaration(domain, declaration)) + else: + for member in declaration.type_members: + if (isinstance(member.type, EnumType) and member.type.is_anonymous): + add_newline(lines) + lines.append(self._generate_anonymous_enum_conversion_for_member(domain, declaration, member)) + + # Anonymous command enums. + for command in self.commands_for_domain(domain): + for parameter in command.call_parameters: + if (isinstance(parameter.type, EnumType) and parameter.type.is_anonymous): + add_newline(lines) + lines.append(self._generate_anonymous_enum_conversion_for_parameter(domain, command.command_name, parameter)) + for parameter in command.return_parameters: + if (isinstance(parameter.type, EnumType) and parameter.type.is_anonymous): + add_newline(lines) + lines.append(self._generate_anonymous_enum_conversion_for_parameter(domain, command.command_name, parameter)) + + # Anonymous event enums. + for event in self.events_for_domain(domain): + for parameter in event.event_parameters: + if (isinstance(parameter.type, EnumType) and parameter.type.is_anonymous): + add_newline(lines) + lines.append(self._generate_anonymous_enum_conversion_for_parameter(domain, event.event_name, parameter)) + + return '\n'.join(lines) + + def _generate_enum_conversion_for_platforms(self): + objc_enum_name = '%sPlatform' % self.objc_prefix() + enum_values = [platform.name for platform in Platforms] + lines = [] + lines.append(self._generate_enum_objc_to_protocol_string(objc_enum_name, enum_values)) + lines.append(self._generate_enum_from_protocol_string(objc_enum_name, enum_values)) + return '\n\n'.join(lines) + + def _generate_anonymous_enum_conversion_for_declaration(self, domain, declaration): + objc_enum_name = self.objc_enum_name_for_anonymous_enum_declaration(declaration) + enum_values = declaration.type.enum_values() + lines = [] + lines.append(self._generate_enum_objc_to_protocol_string(objc_enum_name, enum_values)) + lines.append(self._generate_enum_from_protocol_string(objc_enum_name, enum_values)) + return '\n\n'.join(lines) + + def _generate_anonymous_enum_conversion_for_member(self, domain, declaration, member): + objc_enum_name = self.objc_enum_name_for_anonymous_enum_member(declaration, member) + enum_values = member.type.enum_values() + lines = [] + lines.append(self._generate_enum_objc_to_protocol_string(objc_enum_name, enum_values)) + lines.append(self._generate_enum_from_protocol_string(objc_enum_name, enum_values)) + return '\n\n'.join(lines) + + def _generate_anonymous_enum_conversion_for_parameter(self, domain, event_or_command_name, parameter): + objc_enum_name = self.objc_enum_name_for_anonymous_enum_parameter(domain, event_or_command_name, parameter) + enum_values = parameter.type.enum_values() + lines = [] + lines.append(self._generate_enum_objc_to_protocol_string(objc_enum_name, enum_values)) + lines.append(self._generate_enum_from_protocol_string(objc_enum_name, enum_values)) + return '\n\n'.join(lines) + + def _generate_enum_objc_to_protocol_string(self, objc_enum_name, enum_values): + lines = [] + lines.append('inline String toProtocolString(%s value)' % objc_enum_name) + lines.append('{') + lines.append(' switch(value) {') + for enum_value in enum_values: + lines.append(' case %s%s:' % (objc_enum_name, Generator.stylized_name_for_enum_value(enum_value))) + lines.append(' return ASCIILiteral("%s");' % enum_value) + lines.append(' }') + lines.append('}') + return '\n'.join(lines) + + def _generate_enum_from_protocol_string(self, objc_enum_name, enum_values): + lines = [] + lines.append('template<>') + lines.append('inline std::optional<%s> fromProtocolString(const String& value)' % objc_enum_name) + lines.append('{') + for enum_value in enum_values: + lines.append(' if (value == "%s")' % enum_value) + lines.append(' return %s%s;' % (objc_enum_name, Generator.stylized_name_for_enum_value(enum_value))) + lines.append(' return std::nullopt;') + lines.append('}') + return '\n'.join(lines) diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_implementation.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_implementation.py new file mode 100644 index 000000000..4293e3bd8 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_implementation.py @@ -0,0 +1,138 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016 Apple Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + + +import logging +import string +from string import Template + +from generator import Generator +from models import EnumType, ObjectType, ArrayType, AliasedType, PrimitiveType, Frameworks +from objc_generator import ObjCGenerator +from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates + +log = logging.getLogger('global') + + +def add_newline(lines): + if lines and lines[-1] == '': + return + lines.append('') + + +class ObjCProtocolTypeConversionsImplementationGenerator(ObjCGenerator): + def __init__(self, *args, **kwargs): + ObjCGenerator.__init__(self, *args, **kwargs) + + def output_filename(self): + return '%sTypeConversions.mm' % self.protocol_name() + + def domains_to_generate(self): + return filter(self.should_generate_types_for_domain, Generator.domains_to_generate(self)) + + def generate_output(self): + secondary_headers = [ + '"%s.h"' % self.protocol_name(), + '"%sTypeParser.h"' % self.protocol_name(), + Generator.string_for_file_include('%sJSONObjectPrivate.h' % ObjCGenerator.OBJC_STATIC_PREFIX, Frameworks.WebInspector, self.model().framework), + ] + secondary_headers.sort() + + header_args = { + 'primaryInclude': '"%sTypeConversions.h"' % self.protocol_name(), + 'secondaryIncludes': '\n'.join(['#import ' + header for header in secondary_headers]), + } + + domains = self.domains_to_generate() + sections = [] + sections.append(self.generate_license()) + sections.append(Template(ObjCTemplates.ImplementationPrelude).substitute(None, **header_args)) + sections.append(self._generate_type_factory_category_interface(domains)) + sections.append(self._generate_type_factory_category_implementation(domains)) + sections.append(Template(ObjCTemplates.ImplementationPostlude).substitute(None, **header_args)) + return '\n\n'.join(sections) + + def _generate_type_factory_category_interface(self, domains): + lines = [] + for domain in domains: + lines.append('@interface %sTypeConversions (%sDomain)' % (self.protocol_name(), domain.domain_name)) + lines.append('') + + for declaration in self.type_declarations_for_domain(domain): + lines.append(self._generate_type_factory_method_declaration(domain, declaration)) + + add_newline(lines) + lines.append('@end') + + return '\n'.join(lines) + + def _generate_type_factory_method_declaration(self, domain, declaration): + resolved_type = declaration.type + if isinstance(resolved_type, AliasedType): + resolved_type = resolved_type.aliased_type + if isinstance(resolved_type, (ObjectType, ArrayType, PrimitiveType)): + objc_type = self.objc_class_for_type(resolved_type) + return '+ (void)_parse%s:(%s **)outValue fromPayload:(id)payload;' % (declaration.type.raw_name(), objc_type) + if isinstance(resolved_type, EnumType): + return '+ (void)_parse%s:(NSNumber **)outValue fromPayload:(id)payload;' % declaration.type.raw_name() + + def _generate_type_factory_category_implementation(self, domains): + lines = [] + for domain in domains: + lines.append('@implementation %sTypeConversions (%sDomain)' % (self.protocol_name(), domain.domain_name)) + lines.append('') + + for declaration in self.type_declarations_for_domain(domain): + lines.append(self._generate_type_factory_method_implementation(domain, declaration)) + add_newline(lines) + lines.append('@end') + return '\n'.join(lines) + + def _generate_type_factory_method_implementation(self, domain, declaration): + lines = [] + resolved_type = declaration.type + if isinstance(resolved_type, AliasedType): + resolved_type = resolved_type.aliased_type + + objc_class = self.objc_class_for_type(resolved_type) + if isinstance(resolved_type, (ObjectType, ArrayType, PrimitiveType)): + lines.append('+ (void)_parse%s:(%s **)outValue fromPayload:(id)payload' % (declaration.type.raw_name(), objc_class)) + if isinstance(resolved_type, EnumType): + lines.append('+ (void)_parse%s:(NSNumber **)outValue fromPayload:(id)payload' % declaration.type.raw_name()) + + lines.append('{') + if isinstance(resolved_type, EnumType): + lines.append(' THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]);') + lines.append(' std::optional<%(type)s> result = Inspector::fromProtocolString<%(type)s>(payload);' % {'type': self.objc_name_for_type(resolved_type)}) + lines.append(' THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"%s");' % declaration.type.raw_name()) + lines.append(' *outValue = @(result.value());') + elif isinstance(resolved_type, (ArrayType, PrimitiveType)): + lines.append(' THROW_EXCEPTION_FOR_BAD_TYPE(payload, [%s class]);' % objc_class) + lines.append(' *outValue = (%s *)payload;' % objc_class) + elif isinstance(resolved_type, ObjectType): + lines.append(' THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]);') + lines.append(' *outValue = [[%s alloc] initWithPayload:payload];' % (objc_class)) + lines.append('}') + return '\n'.join(lines) diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_types_implementation.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_types_implementation.py new file mode 100755 index 000000000..a319c94d7 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_types_implementation.py @@ -0,0 +1,215 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014, 2016 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + + +import logging +import string +from string import Template + +from generator import Generator, ucfirst +from models import ObjectType, EnumType, Frameworks +from objc_generator import ObjCGenerator +from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates + +log = logging.getLogger('global') + + +def add_newline(lines): + if lines and lines[-1] == '': + return + lines.append('') + + +class ObjCProtocolTypesImplementationGenerator(ObjCGenerator): + def __init__(self, *args, **kwargs): + ObjCGenerator.__init__(self, *args, **kwargs) + + def output_filename(self): + return '%sTypes.mm' % self.protocol_name() + + def domains_to_generate(self): + return filter(self.should_generate_types_for_domain, Generator.domains_to_generate(self)) + + def generate_output(self): + secondary_headers = [ + '"%sTypeConversions.h"' % self.protocol_name(), + Generator.string_for_file_include('%sJSONObjectPrivate.h' % ObjCGenerator.OBJC_STATIC_PREFIX, Frameworks.WebInspector, self.model().framework), + '<JavaScriptCore/InspectorValues.h>', + '<wtf/Assertions.h>', + ] + + # The FooProtocolInternal.h header is only needed to declare the backend-side event dispatcher bindings. + primaryIncludeName = self.protocol_name() + if self.get_generator_setting('generate_backend', False): + primaryIncludeName += 'Internal' + + header_args = { + 'primaryInclude': '"%s.h"' % primaryIncludeName, + 'secondaryIncludes': '\n'.join(['#import %s' % header for header in secondary_headers]), + } + + domains = self.domains_to_generate() + sections = [] + sections.append(self.generate_license()) + sections.append(Template(ObjCTemplates.ImplementationPrelude).substitute(None, **header_args)) + sections.extend(map(self.generate_type_implementations, domains)) + sections.append(Template(ObjCTemplates.ImplementationPostlude).substitute(None, **header_args)) + return '\n\n'.join(sections) + + def generate_type_implementations(self, domain): + lines = [] + for declaration in self.type_declarations_for_domain(domain): + if (isinstance(declaration.type, ObjectType)): + add_newline(lines) + lines.append(self.generate_type_implementation(domain, declaration)) + return '\n'.join(lines) + + def generate_type_implementation(self, domain, declaration): + lines = [] + lines.append('@implementation %s' % self.objc_name_for_type(declaration.type)) + # The initializer that takes a payload is only needed by the frontend. + if self.get_generator_setting('generate_frontend', False): + lines.append('') + lines.append(self._generate_init_method_for_payload(domain, declaration)) + lines.append(self._generate_init_method_for_json_object(domain, declaration)) + required_members = filter(lambda member: not member.is_optional, declaration.type_members) + if required_members: + lines.append('') + lines.append(self._generate_init_method_for_required_members(domain, declaration, required_members)) + for member in declaration.type_members: + lines.append('') + lines.append(self._generate_setter_for_member(domain, declaration, member)) + lines.append('') + lines.append(self._generate_getter_for_member(domain, declaration, member)) + lines.append('') + lines.append('@end') + return '\n'.join(lines) + + def _generate_init_method_for_json_object(self, domain, declaration): + lines = [] + lines.append('- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject') + lines.append('{') + lines.append(' if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()]))') + lines.append(' return nil;') + lines.append('') + lines.append(' return self;') + lines.append('}') + return '\n'.join(lines) + + def _generate_init_method_for_payload(self, domain, declaration): + lines = [] + lines.append('- (instancetype)initWithPayload:(nonnull NSDictionary<NSString *, id> *)payload') + lines.append('{') + lines.append(' if (!(self = [super init]))') + lines.append(' return nil;') + lines.append('') + + for member in declaration.type_members: + member_name = member.member_name + + if not member.is_optional: + lines.append(' THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"%s"], @"%s");' % (member_name, member_name)) + + objc_type = self.objc_type_for_member(declaration, member) + var_name = ObjCGenerator.identifier_to_objc_identifier(member_name) + conversion_expression = self.payload_to_objc_expression_for_member(declaration, member) + if isinstance(member.type, EnumType): + lines.append(' std::optional<%s> %s = %s;' % (objc_type, var_name, conversion_expression)) + if not member.is_optional: + lines.append(' THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(%s, @"%s");' % (var_name, member_name)) + lines.append(' self.%s = %s.value();' % (var_name, var_name)) + else: + lines.append(' if (%s)' % var_name) + lines.append(' self.%s = %s.value();' % (var_name, var_name)) + else: + lines.append(' self.%s = %s;' % (var_name, conversion_expression)) + + lines.append('') + + lines.append(' return self;') + lines.append('}') + return '\n'.join(lines) + + def _generate_init_method_for_required_members(self, domain, declaration, required_members): + pairs = [] + for member in required_members: + objc_type = self.objc_type_for_member(declaration, member) + var_name = ObjCGenerator.identifier_to_objc_identifier(member.member_name) + pairs.append('%s:(%s)%s' % (var_name, objc_type, var_name)) + pairs[0] = ucfirst(pairs[0]) + lines = [] + lines.append('- (instancetype)initWith%s' % ' '.join(pairs)) + lines.append('{') + lines.append(' if (!(self = [super init]))') + lines.append(' return nil;') + lines.append('') + + required_pointer_members = filter(lambda member: ObjCGenerator.is_type_objc_pointer_type(member.type), required_members) + if required_pointer_members: + for member in required_pointer_members: + var_name = ObjCGenerator.identifier_to_objc_identifier(member.member_name) + lines.append(' THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(%s, @"%s");' % (var_name, var_name)) + objc_array_class = self.objc_class_for_array_type(member.type) + if objc_array_class and objc_array_class.startswith(self.objc_prefix()): + lines.append(' THROW_EXCEPTION_FOR_BAD_TYPE_IN_ARRAY(%s, [%s class]);' % (var_name, objc_array_class)) + lines.append('') + + for member in required_members: + var_name = ObjCGenerator.identifier_to_objc_identifier(member.member_name) + lines.append(' self.%s = %s;' % (var_name, var_name)) + + lines.append('') + lines.append(' return self;') + lines.append('}') + return '\n'.join(lines) + + def _generate_setter_for_member(self, domain, declaration, member): + objc_type = self.objc_type_for_member(declaration, member) + var_name = ObjCGenerator.identifier_to_objc_identifier(member.member_name) + setter_method = ObjCGenerator.objc_setter_method_for_member(declaration, member) + conversion_expression = self.objc_to_protocol_expression_for_member(declaration, member, var_name) + lines = [] + lines.append('- (void)set%s:(%s)%s' % (ucfirst(var_name), objc_type, var_name)) + lines.append('{') + objc_array_class = self.objc_class_for_array_type(member.type) + if objc_array_class and objc_array_class.startswith(self.objc_prefix()): + lines.append(' THROW_EXCEPTION_FOR_BAD_TYPE_IN_ARRAY(%s, [%s class]);' % (var_name, objc_array_class)) + lines.append(' [super %s:%s forKey:@"%s"];' % (setter_method, conversion_expression, member.member_name)) + lines.append('}') + return '\n'.join(lines) + + def _generate_getter_for_member(self, domain, declaration, member): + objc_type = self.objc_type_for_member(declaration, member) + var_name = ObjCGenerator.identifier_to_objc_identifier(member.member_name) + getter_method = ObjCGenerator.objc_getter_method_for_member(declaration, member) + basic_expression = '[super %s:@"%s"]' % (getter_method, member.member_name) + conversion_expression = self.protocol_to_objc_expression_for_member(declaration, member, basic_expression) + lines = [] + lines.append('- (%s)%s' % (objc_type, var_name)) + lines.append('{') + lines.append(' return %s;' % conversion_expression) + lines.append('}') + return '\n'.join(lines) diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generator.py b/Source/JavaScriptCore/inspector/scripts/codegen/generator.py new file mode 100755 index 000000000..2d33b94ea --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/generator.py @@ -0,0 +1,274 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + +import logging +import os.path +import re +from string import Template + +from generator_templates import GeneratorTemplates as Templates +from models import PrimitiveType, ObjectType, ArrayType, EnumType, AliasedType, Frameworks, Platforms + +log = logging.getLogger('global') + + +def ucfirst(str): + return str[:1].upper() + str[1:] + +_ALWAYS_SPECIALCASED_ENUM_VALUE_SUBSTRINGS = set(['API', 'CSS', 'DOM', 'HTML', 'JIT', 'XHR', 'XML', 'IOS', 'MacOS']) +_ALWAYS_SPECIALCASED_ENUM_VALUE_LOOKUP_TABLE = dict([(s.upper(), s) for s in _ALWAYS_SPECIALCASED_ENUM_VALUE_SUBSTRINGS]) + +# These objects are built manually by creating and setting InspectorValues. +# Before sending these over the protocol, their shapes are checked against the specification. +# So, any types referenced by these types require debug-only assertions that check values. +# Calculating necessary assertions is annoying, and adds a lot of complexity to the generator. + +# FIXME: This should be converted into a property in JSON. +_TYPES_NEEDING_RUNTIME_CASTS = set([ + "Runtime.ObjectPreview", + "Runtime.RemoteObject", + "Runtime.PropertyDescriptor", + "Runtime.InternalPropertyDescriptor", + "Runtime.CollectionEntry", + "Debugger.FunctionDetails", + "Debugger.CallFrame", + "Canvas.TraceLog", + "Canvas.ResourceInfo", + "Canvas.ResourceState", + # This should be a temporary hack. TimelineEvent should be created via generated C++ API. + "Timeline.TimelineEvent", + # For testing purposes only. + "Test.TypeNeedingCast" +]) + +# FIXME: This should be converted into a property in JSON. +_TYPES_WITH_OPEN_FIELDS = set([ + "Timeline.TimelineEvent", + # InspectorStyleSheet not only creates this property but wants to read it and modify it. + "CSS.CSSProperty", + # InspectorNetworkAgent needs to update mime-type. + "Network.Response", + # For testing purposes only. + "Test.OpenParameterBundle" +]) + + +class Generator: + def __init__(self, model, platform, input_filepath): + self._model = model + self._platform = platform + self._input_filepath = input_filepath + self._settings = {} + + def model(self): + return self._model + + def platform(self): + return self._platform + + def set_generator_setting(self, key, value): + self._settings[key] = value + + def can_generate_platform(self, model_platform): + return model_platform is Platforms.Generic or self._platform is Platforms.All or model_platform is self._platform + + def type_declarations_for_domain(self, domain): + return [type_declaration for type_declaration in domain.all_type_declarations() if self.can_generate_platform(type_declaration.platform)] + + def commands_for_domain(self, domain): + return [command for command in domain.all_commands() if self.can_generate_platform(command.platform)] + + def events_for_domain(self, domain): + return [event for event in domain.all_events() if self.can_generate_platform(event.platform)] + + # The goofy name is to disambiguate generator settings from framework settings. + def get_generator_setting(self, key, default=None): + return self._settings.get(key, default) + + def generate_license(self): + return Template(Templates.CopyrightBlock).substitute(None, inputFilename=os.path.basename(self._input_filepath)) + + # These methods are overridden by subclasses. + def non_supplemental_domains(self): + return filter(lambda domain: not domain.is_supplemental, self.model().domains) + + def domains_to_generate(self): + return self.non_supplemental_domains() + + def generate_output(self): + pass + + def output_filename(self): + pass + + def encoding_for_enum_value(self, enum_value): + if not hasattr(self, "_assigned_enum_values"): + self._traverse_and_assign_enum_values() + + return self._enum_value_encodings[enum_value] + + def assigned_enum_values(self): + if not hasattr(self, "_assigned_enum_values"): + self._traverse_and_assign_enum_values() + + return self._assigned_enum_values[:] # Slice. + + @staticmethod + def type_needs_runtime_casts(_type): + return _type.qualified_name() in _TYPES_NEEDING_RUNTIME_CASTS + + @staticmethod + def type_has_open_fields(_type): + return _type.qualified_name() in _TYPES_WITH_OPEN_FIELDS + + def type_needs_shape_assertions(self, _type): + if not hasattr(self, "_types_needing_shape_assertions"): + self.calculate_types_requiring_shape_assertions(self.model().domains) + + return _type in self._types_needing_shape_assertions + + # To restrict the domains over which we compute types needing assertions, call this method + # before generating any output with the desired domains parameter. The computed + # set of types will not be automatically regenerated on subsequent calls to + # Generator.types_needing_shape_assertions(). + def calculate_types_requiring_shape_assertions(self, domains): + domain_names = map(lambda domain: domain.domain_name, domains) + log.debug("> Calculating types that need shape assertions (eligible domains: %s)" % ", ".join(domain_names)) + + # Mutates the passed-in set; this simplifies checks to prevent infinite recursion. + def gather_transitively_referenced_types(_type, gathered_types): + if _type in gathered_types: + return + + if isinstance(_type, ObjectType): + log.debug("> Adding type %s to list of types needing shape assertions." % _type.qualified_name()) + gathered_types.add(_type) + for type_member in _type.members: + gather_transitively_referenced_types(type_member.type, gathered_types) + elif isinstance(_type, EnumType): + log.debug("> Adding type %s to list of types needing shape assertions." % _type.qualified_name()) + gathered_types.add(_type) + elif isinstance(_type, AliasedType): + gather_transitively_referenced_types(_type.aliased_type, gathered_types) + elif isinstance(_type, ArrayType): + gather_transitively_referenced_types(_type.element_type, gathered_types) + + found_types = set() + for domain in domains: + for declaration in self.type_declarations_for_domain(domain): + if declaration.type.qualified_name() in _TYPES_NEEDING_RUNTIME_CASTS: + log.debug("> Gathering types referenced by %s to generate shape assertions." % declaration.type.qualified_name()) + gather_transitively_referenced_types(declaration.type, found_types) + + self._types_needing_shape_assertions = found_types + + # Private helper instance methods. + def _traverse_and_assign_enum_values(self): + self._enum_value_encodings = {} + self._assigned_enum_values = [] + all_types = [] + + domains = self.non_supplemental_domains() + + for domain in domains: + for type_declaration in self.type_declarations_for_domain(domain): + all_types.append(type_declaration.type) + for type_member in type_declaration.type_members: + all_types.append(type_member.type) + + for domain in domains: + for event in self.events_for_domain(domain): + all_types.extend([parameter.type for parameter in event.event_parameters]) + + for domain in domains: + for command in self.commands_for_domain(domain): + all_types.extend([parameter.type for parameter in command.call_parameters]) + all_types.extend([parameter.type for parameter in command.return_parameters]) + + for _type in all_types: + if not isinstance(_type, EnumType): + continue + map(self._assign_encoding_for_enum_value, _type.enum_values()) + + def _assign_encoding_for_enum_value(self, enum_value): + if enum_value in self._enum_value_encodings: + return + + self._enum_value_encodings[enum_value] = len(self._assigned_enum_values) + self._assigned_enum_values.append(enum_value) + + # Miscellaneous text manipulation routines. + def wrap_with_guard_for_domain(self, domain, text): + if self.model().framework is Frameworks.WebInspector: + return text + guard = domain.feature_guard + if guard: + return Generator.wrap_with_guard(guard, text) + return text + + @staticmethod + def wrap_with_guard(guard, text): + return '\n'.join([ + '#if %s' % guard, + text, + '#endif // %s' % guard, + ]) + + @staticmethod + def stylized_name_for_enum_value(enum_value): + regex = '(%s)' % "|".join(_ALWAYS_SPECIALCASED_ENUM_VALUE_SUBSTRINGS) + + def replaceCallback(match): + return _ALWAYS_SPECIALCASED_ENUM_VALUE_LOOKUP_TABLE[match.group(1).upper()] + + # Split on hyphen, introduce camelcase, and force uppercasing of acronyms. + subwords = map(ucfirst, enum_value.split('-')) + return re.sub(re.compile(regex, re.IGNORECASE), replaceCallback, "".join(subwords)) + + @staticmethod + def js_name_for_parameter_type(_type): + _type = _type + if isinstance(_type, AliasedType): + _type = _type.aliased_type # Fall through. + if isinstance(_type, EnumType): + _type = _type.primitive_type # Fall through. + + if isinstance(_type, (ArrayType, ObjectType)): + return 'object' + if isinstance(_type, PrimitiveType): + if _type.qualified_name() in ['object', 'any']: + return 'object' + elif _type.qualified_name() in ['integer', 'number']: + return 'number' + else: + return _type.qualified_name() + + @staticmethod + def string_for_file_include(filename, file_framework, target_framework): + if file_framework is target_framework: + return '"%s"' % filename + else: + return '<%s/%s>' % (file_framework.name, filename) diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generator_templates.py b/Source/JavaScriptCore/inspector/scripts/codegen/generator_templates.py new file mode 100644 index 000000000..891681ffd --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/generator_templates.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014, 2016 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + +# Generator templates, which can be filled with string.Template. +# Following are classes that fill the templates from the typechecked model. + + +class GeneratorTemplates: + CopyrightBlock = ( + """/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from ${inputFilename} +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py""") diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/models.py b/Source/JavaScriptCore/inspector/scripts/codegen/models.py new file mode 100755 index 000000000..b286a5c40 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/models.py @@ -0,0 +1,680 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + +import logging +import collections + +log = logging.getLogger('global') + + +def ucfirst(str): + return str[:1].upper() + str[1:] + + +def find_duplicates(l): + return [key for key, count in collections.Counter(l).items() if count > 1] + + +_FRAMEWORK_CONFIG_MAP = { + "Global": { + }, + "JavaScriptCore": { + "cpp_protocol_group": "Inspector", + "export_macro": "JS_EXPORT_PRIVATE", + "alternate_dispatchers": True, + }, + "WebKit": { + "cpp_protocol_group": "Automation", + "objc_protocol_group": "WD", + "objc_prefix": "WD", + }, + "WebInspector": { + "objc_protocol_group": "RWI", + "objc_prefix": "RWI", + }, + # Used for code generator tests. + "Test": { + "alternate_dispatchers": True, + "cpp_protocol_group": "Test", + "objc_protocol_group": "Test", + "objc_prefix": "Test", + } +} + + +class ParseException(Exception): + pass + + +class TypecheckException(Exception): + pass + + +class Framework: + def __init__(self, name): + self._settings = _FRAMEWORK_CONFIG_MAP[name] + self.name = name + + def setting(self, key, default=''): + return self._settings.get(key, default) + + @staticmethod + def fromString(frameworkString): + if frameworkString == "Global": + return Frameworks.Global + + if frameworkString == "JavaScriptCore": + return Frameworks.JavaScriptCore + + if frameworkString == "WebKit": + return Frameworks.WebKit + + if frameworkString == "WebInspector": + return Frameworks.WebInspector + + if frameworkString == "Test": + return Frameworks.Test + + raise ParseException("Unknown framework: %s" % frameworkString) + + +class Frameworks: + Global = Framework("Global") + JavaScriptCore = Framework("JavaScriptCore") + WebKit = Framework("WebKit") + WebInspector = Framework("WebInspector") + Test = Framework("Test") + + +class Platform: + def __init__(self, name): + self.name = name + + @staticmethod + def fromString(platformString): + platformString = platformString.lower() + if platformString == "ios": + return Platforms.iOS + + if platformString == "macos": + return Platforms.macOS + + if platformString == "all": + return Platforms.All + + if platformString == "generic" or not platformString: + return Platforms.Generic + + raise ParseException("Unknown platform: %s" % platformString) + + +class Platforms: + All = Platform("all") + Generic = Platform("generic") + iOS = Platform("ios") + macOS = Platform("macos") + + # Allow iteration over all platforms. See <http://stackoverflow.com/questions/5434400/>. + class __metaclass__(type): + def __iter__(self): + for attr in dir(Platforms): + if not attr.startswith("__"): + yield getattr(Platforms, attr) + +class TypeReference: + def __init__(self, type_kind, referenced_type_name, enum_values, array_items): + self.type_kind = type_kind + self.referenced_type_name = referenced_type_name + self.enum_values = enum_values + if array_items is None: + self.array_type_ref = None + else: + self.array_type_ref = TypeReference(array_items.get('type'), array_items.get('$ref'), array_items.get('enum'), array_items.get('items')) + + if type_kind is not None and referenced_type_name is not None: + raise ParseException("Type reference cannot have both 'type' and '$ref' keys.") + + all_primitive_types = ["integer", "number", "string", "boolean", "enum", "object", "array", "any"] + if type_kind is not None and type_kind not in all_primitive_types: + raise ParseException("Type reference '%s' is not a primitive type. Allowed values: %s" % (type_kind, ', '.join(all_primitive_types))) + + if type_kind == "array" and array_items is None: + raise ParseException("Type reference with type 'array' must have key 'items' to define array element type.") + + if enum_values is not None and len(enum_values) == 0: + raise ParseException("Type reference with enum values must have at least one enum value.") + + def referenced_name(self): + if self.referenced_type_name is not None: + return self.referenced_type_name + else: + return self.type_kind # one of all_primitive_types + + +class Type: + def __init__(self): + pass + + def __eq__(self, other): + return self.qualified_name() == other.qualified_name() + + def __hash__(self): + return self.qualified_name().__hash__() + + def raw_name(self): + return self._name + + # These methods should be overridden by subclasses. + def is_enum(self): + return False + + def type_domain(self): + pass + + def qualified_name(self): + pass + + # This is used to resolve nested types after instances are created. + def resolve_type_references(self, protocol): + pass + + +class PrimitiveType(Type): + def __init__(self, name): + self._name = name + + def __repr__(self): + return 'PrimitiveType[%s]' % self.qualified_name() + + def type_domain(self): + return None + + def qualified_name(self): + return self.raw_name() + + +class AliasedType(Type): + def __init__(self, declaration, domain, aliased_type_ref): + self._name = declaration.type_name + self._declaration = declaration + self._domain = domain + self._aliased_type_ref = aliased_type_ref + self.aliased_type = None + + def __repr__(self): + if self.aliased_type is not None: + return 'AliasedType[%s -> %r]' % (self.qualified_name(), self.aliased_type) + else: + return 'AliasedType[%s -> (unresolved)]' % self.qualified_name() + + def is_enum(self): + return self.aliased_type.is_enum() + + def type_domain(self): + return self._domain + + def qualified_name(self): + return ".".join([self.type_domain().domain_name, self.raw_name()]) + + def resolve_type_references(self, protocol): + if self.aliased_type is not None: + return + + self.aliased_type = protocol.lookup_type_reference(self._aliased_type_ref, self.type_domain()) + log.debug("< Resolved type reference for aliased type in %s: %s" % (self.qualified_name(), self.aliased_type.qualified_name())) + + +class EnumType(Type): + def __init__(self, declaration, domain, values, primitive_type_ref, is_anonymous=False): + self._name = "(anonymous)" if declaration is None else declaration.type_name + self._declaration = declaration + self._domain = domain + self._values = values + self._primitive_type_ref = primitive_type_ref + self.primitive_type = None + self.is_anonymous = is_anonymous + + def __repr__(self): + return 'EnumType[value_type=%s; values=%s]' % (self.qualified_name(), ', '.join(map(str, self.enum_values()))) + + def is_enum(self): + return True + + def enum_values(self): + return self._values + + def type_domain(self): + return self._domain + + def declaration(self): + return self._declaration + + def qualified_name(self): + return ".".join([self.type_domain().domain_name, self.raw_name()]) + + def resolve_type_references(self, protocol): + if self.primitive_type is not None: + return + + self.primitive_type = protocol.lookup_type_reference(self._primitive_type_ref, Domains.GLOBAL) + log.debug("< Resolved type reference for enum type in %s: %s" % (self.qualified_name(), self.primitive_type.qualified_name())) + log.debug("<< enum values: %s" % self.enum_values()) + + +class ArrayType(Type): + def __init__(self, declaration, element_type_ref, domain): + self._name = None if declaration is None else declaration.type_name + self._declaration = declaration + self._domain = domain + self._element_type_ref = element_type_ref + self.element_type = None + + def __repr__(self): + if self.element_type is not None: + return 'ArrayType[element_type=%r]' % self.element_type + else: + return 'ArrayType[element_type=(unresolved)]' + + def declaration(self): + return self._declaration + + def type_domain(self): + return self._domain + + def qualified_name(self): + return ".".join(["array", self.element_type.qualified_name()]) + + def resolve_type_references(self, protocol): + if self.element_type is not None: + return + + self.element_type = protocol.lookup_type_reference(self._element_type_ref, self.type_domain()) + log.debug("< Resolved type reference for element type in %s: %s" % (self.qualified_name(), self.element_type.qualified_name())) + + +class ObjectType(Type): + def __init__(self, declaration, domain): + self._name = declaration.type_name + self._declaration = declaration + self._domain = domain + self.members = declaration.type_members + + def __repr__(self): + return 'ObjectType[%s]' % self.qualified_name() + + def declaration(self): + return self._declaration + + def type_domain(self): + return self._domain + + def qualified_name(self): + return ".".join([self.type_domain().domain_name, self.raw_name()]) + + +def check_for_required_properties(props, obj, what): + for prop in props: + if prop not in obj: + raise ParseException("When parsing %s, required property missing: %s" % (what, prop)) + + +class Protocol: + def __init__(self, framework_name): + self.domains = [] + self.types_by_name = {} + self.framework = Framework.fromString(framework_name) + + def parse_specification(self, json, isSupplemental): + log.debug("parse toplevel") + + if isinstance(json, dict) and 'domains' in json: + json = json['domains'] + if not isinstance(json, list): + json = [json] + + for domain in json: + self.parse_domain(domain, isSupplemental) + + def parse_domain(self, json, isSupplemental): + check_for_required_properties(['domain'], json, "domain") + log.debug("parse domain " + json['domain']) + + types = [] + commands = [] + events = [] + + if 'types' in json: + if not isinstance(json['types'], list): + raise ParseException("Malformed domain specification: types is not an array") + types.extend([self.parse_type_declaration(declaration) for declaration in json['types']]) + + if 'commands' in json: + if not isinstance(json['commands'], list): + raise ParseException("Malformed domain specification: commands is not an array") + commands.extend([self.parse_command(command) for command in json['commands']]) + + if 'events' in json: + if not isinstance(json['events'], list): + raise ParseException("Malformed domain specification: events is not an array") + events.extend([self.parse_event(event) for event in json['events']]) + + if 'availability' in json: + if not commands and not events: + raise ParseException("Malformed domain specification: availability should only be included if there are commands or events.") + allowed_activation_strings = set(['web']) + if json['availability'] not in allowed_activation_strings: + raise ParseException('Malformed domain specification: availability is an unsupported string. Was: "%s", Allowed values: %s' % (json['availability'], ', '.join(allowed_activation_strings))) + + if 'workerSupported' in json: + if not isinstance(json['workerSupported'], bool): + raise ParseException('Malformed domain specification: workerSupported is not a boolean. Was: "%s"' % json['availability']) + + self.domains.append(Domain(json['domain'], json.get('description', ''), json.get('featureGuard'), json.get('availability'), json.get('workerSupported', False), isSupplemental, types, commands, events)) + + def parse_type_declaration(self, json): + check_for_required_properties(['id', 'type'], json, "type") + log.debug("parse type %s" % json['id']) + + type_members = [] + + if 'properties' in json: + if not isinstance(json['properties'], list): + raise ParseException("Malformed type specification: properties is not an array") + type_members.extend([self.parse_type_member(member) for member in json['properties']]) + + duplicate_names = find_duplicates([member.member_name for member in type_members]) + if len(duplicate_names) > 0: + raise ParseException("Malformed domain specification: type declaration for %s has duplicate member names" % json['id']) + + type_ref = TypeReference(json['type'], json.get('$ref'), json.get('enum'), json.get('items')) + platform = Platform.fromString(json.get('platform', 'generic')) + return TypeDeclaration(json['id'], type_ref, json.get("description", ""), platform, type_members) + + def parse_type_member(self, json): + check_for_required_properties(['name'], json, "type member") + log.debug("parse type member %s" % json['name']) + + type_ref = TypeReference(json.get('type'), json.get('$ref'), json.get('enum'), json.get('items')) + return TypeMember(json['name'], type_ref, json.get('optional', False), json.get('description', "")) + + def parse_command(self, json): + check_for_required_properties(['name'], json, "command") + log.debug("parse command %s" % json['name']) + + call_parameters = [] + return_parameters = [] + + if 'parameters' in json: + if not isinstance(json['parameters'], list): + raise ParseException("Malformed command specification: parameters is not an array") + call_parameters.extend([self.parse_call_or_return_parameter(parameter) for parameter in json['parameters']]) + + duplicate_names = find_duplicates([param.parameter_name for param in call_parameters]) + if len(duplicate_names) > 0: + raise ParseException("Malformed domain specification: call parameter list for command %s has duplicate parameter names" % json['name']) + + if 'returns' in json: + if not isinstance(json['returns'], list): + raise ParseException("Malformed command specification: returns is not an array") + return_parameters.extend([self.parse_call_or_return_parameter(parameter) for parameter in json['returns']]) + + duplicate_names = find_duplicates([param.parameter_name for param in return_parameters]) + if len(duplicate_names) > 0: + raise ParseException("Malformed domain specification: return parameter list for command %s has duplicate parameter names" % json['name']) + + platform = Platform.fromString(json.get('platform', 'generic')) + return Command(json['name'], call_parameters, return_parameters, json.get('description', ""), platform, json.get('async', False)) + + def parse_event(self, json): + check_for_required_properties(['name'], json, "event") + log.debug("parse event %s" % json['name']) + + event_parameters = [] + + if 'parameters' in json: + if not isinstance(json['parameters'], list): + raise ParseException("Malformed event specification: parameters is not an array") + event_parameters.extend([self.parse_call_or_return_parameter(parameter) for parameter in json['parameters']]) + + duplicate_names = find_duplicates([param.parameter_name for param in event_parameters]) + if len(duplicate_names) > 0: + raise ParseException("Malformed domain specification: parameter list for event %s has duplicate parameter names" % json['name']) + + platform = Platform.fromString(json.get('platform', 'generic')) + return Event(json['name'], event_parameters, json.get('description', ""), platform) + + def parse_call_or_return_parameter(self, json): + check_for_required_properties(['name'], json, "parameter") + log.debug("parse parameter %s" % json['name']) + + type_ref = TypeReference(json.get('type'), json.get('$ref'), json.get('enum'), json.get('items')) + return Parameter(json['name'], type_ref, json.get('optional', False), json.get('description', "")) + + def resolve_types(self): + qualified_declared_type_names = set(['boolean', 'string', 'integer', 'number', 'enum', 'array', 'object', 'any']) + + self.types_by_name['string'] = PrimitiveType('string') + for _primitive_type in ['boolean', 'integer', 'number']: + self.types_by_name[_primitive_type] = PrimitiveType(_primitive_type) + for _object_type in ['any', 'object']: + self.types_by_name[_object_type] = PrimitiveType(_object_type) + + # Gather qualified type names from type declarations in each domain. + for domain in self.domains: + for declaration in domain.all_type_declarations(): + # Basic sanity checking. + if declaration.type_ref.referenced_type_name is not None: + raise TypecheckException("Type declarations must name a base type, not a type reference.") + + # Find duplicate qualified type names. + qualified_type_name = ".".join([domain.domain_name, declaration.type_name]) + if qualified_type_name in qualified_declared_type_names: + raise TypecheckException("Duplicate type declaration: %s" % qualified_type_name) + + qualified_declared_type_names.add(qualified_type_name) + + type_instance = None + + kind = declaration.type_ref.type_kind + if declaration.type_ref.enum_values is not None: + primitive_type_ref = TypeReference(declaration.type_ref.type_kind, None, None, None) + type_instance = EnumType(declaration, domain, declaration.type_ref.enum_values, primitive_type_ref) + elif kind == "array": + type_instance = ArrayType(declaration, declaration.type_ref.array_type_ref, domain) + elif kind == "object": + type_instance = ObjectType(declaration, domain) + else: + type_instance = AliasedType(declaration, domain, declaration.type_ref) + + log.debug("< Created fresh type %r for declaration %s" % (type_instance, qualified_type_name)) + self.types_by_name[qualified_type_name] = type_instance + + # Resolve all type references recursively. + for domain in self.domains: + domain.resolve_type_references(self) + + def lookup_type_for_declaration(self, declaration, domain): + # This will only match a type defined in the same domain, where prefixes aren't required. + qualified_name = ".".join([domain.domain_name, declaration.type_name]) + if qualified_name in self.types_by_name: + found_type = self.types_by_name[qualified_name] + found_type.resolve_type_references(self) + return found_type + + raise TypecheckException("Lookup failed for type declaration: %s (referenced from domain: %s)" % (declaration.type_name, domain.domain_name)) + + def lookup_type_reference(self, type_ref, domain): + # If reference is to an anonymous array type, create a fresh instance. + if type_ref.type_kind == "array": + type_instance = ArrayType(None, type_ref.array_type_ref, domain) + type_instance.resolve_type_references(self) + log.debug("< Created fresh type instance for anonymous array type: %s" % type_instance.qualified_name()) + return type_instance + + # If reference is to an anonymous enum type, create a fresh instance. + if type_ref.enum_values is not None: + # We need to create a type reference without enum values as the enum's nested type. + primitive_type_ref = TypeReference(type_ref.type_kind, None, None, None) + type_instance = EnumType(None, domain, type_ref.enum_values, primitive_type_ref, True) + type_instance.resolve_type_references(self) + log.debug("< Created fresh type instance for anonymous enum type: %s" % type_instance.qualified_name()) + return type_instance + + # This will match when referencing a type defined in the same domain, where prefixes aren't required. + qualified_name = ".".join([domain.domain_name, type_ref.referenced_name()]) + if qualified_name in self.types_by_name: + found_type = self.types_by_name[qualified_name] + found_type.resolve_type_references(self) + log.debug("< Lookup succeeded for unqualified type: %s" % found_type.qualified_name()) + return found_type + + # This will match primitive types and fully-qualified types from a different domain. + if type_ref.referenced_name() in self.types_by_name: + found_type = self.types_by_name[type_ref.referenced_name()] + found_type.resolve_type_references(self) + log.debug("< Lookup succeeded for primitive or qualified type: %s" % found_type.qualified_name()) + return found_type + + raise TypecheckException("Lookup failed for type reference: %s (referenced from domain: %s)" % (type_ref.referenced_name(), domain.domain_name)) + + +class Domain: + def __init__(self, domain_name, description, feature_guard, availability, workerSupported, isSupplemental, type_declarations, commands, events): + self.domain_name = domain_name + self.description = description + self.feature_guard = feature_guard + self.availability = availability + self.workerSupported = workerSupported + self.is_supplemental = isSupplemental + self._type_declarations = type_declarations + self._commands = commands + self._events = events + + def all_type_declarations(self): + return self._type_declarations + + def all_commands(self): + return self._commands + + def all_events(self): + return self._events + + def resolve_type_references(self, protocol): + log.debug("> Resolving type declarations for domain: %s" % self.domain_name) + for declaration in self._type_declarations: + declaration.resolve_type_references(protocol, self) + + log.debug("> Resolving types in commands for domain: %s" % self.domain_name) + for command in self._commands: + command.resolve_type_references(protocol, self) + + log.debug("> Resolving types in events for domain: %s" % self.domain_name) + for event in self._events: + event.resolve_type_references(protocol, self) + + +class Domains: + GLOBAL = Domain("", "The global domain, in which primitive types are implicitly declared.", None, None, True, False, [], [], []) + + +class TypeDeclaration: + def __init__(self, type_name, type_ref, description, platform, type_members): + self.type_name = type_name + self.type_ref = type_ref + self.description = description + self.platform = platform + self.type_members = type_members + + if self.type_name != ucfirst(self.type_name): + raise ParseException("Types must begin with an uppercase character.") + + def resolve_type_references(self, protocol, domain): + log.debug(">> Resolving type references for type declaration: %s" % self.type_name) + self.type = protocol.lookup_type_for_declaration(self, domain) + for member in self.type_members: + member.resolve_type_references(protocol, domain) + + +class TypeMember: + def __init__(self, member_name, type_ref, is_optional, description): + self.member_name = member_name + self.type_ref = type_ref + self.is_optional = is_optional + self.description = description + + if not isinstance(self.is_optional, bool): + raise ParseException("The 'optional' flag for a type member must be a boolean literal.") + + def resolve_type_references(self, protocol, domain): + log.debug(">>> Resolving type references for type member: %s" % self.member_name) + self.type = protocol.lookup_type_reference(self.type_ref, domain) + + +class Parameter: + def __init__(self, parameter_name, type_ref, is_optional, description): + self.parameter_name = parameter_name + self.type_ref = type_ref + self.is_optional = is_optional + self.description = description + + if not isinstance(self.is_optional, bool): + raise ParseException("The 'optional' flag for a parameter must be a boolean literal.") + + def resolve_type_references(self, protocol, domain): + log.debug(">>> Resolving type references for parameter: %s" % self.parameter_name) + self.type = protocol.lookup_type_reference(self.type_ref, domain) + + +class Command: + def __init__(self, command_name, call_parameters, return_parameters, description, platform, is_async): + self.command_name = command_name + self.call_parameters = call_parameters + self.return_parameters = return_parameters + self.description = description + self.platform = platform + self.is_async = is_async + + def resolve_type_references(self, protocol, domain): + log.debug(">> Resolving type references for call parameters in command: %s" % self.command_name) + for parameter in self.call_parameters: + parameter.resolve_type_references(protocol, domain) + + log.debug(">> Resolving type references for return parameters in command: %s" % self.command_name) + for parameter in self.return_parameters: + parameter.resolve_type_references(protocol, domain) + + +class Event: + def __init__(self, event_name, event_parameters, description, platform): + self.event_name = event_name + self.event_parameters = event_parameters + self.description = description + self.platform = platform + + def resolve_type_references(self, protocol, domain): + log.debug(">> Resolving type references for parameters in event: %s" % self.event_name) + for parameter in self.event_parameters: + parameter.resolve_type_references(protocol, domain) diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/objc_generator.py b/Source/JavaScriptCore/inspector/scripts/codegen/objc_generator.py new file mode 100755 index 000000000..21e179148 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/objc_generator.py @@ -0,0 +1,554 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014, 2016 Apple Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + +import logging +from generator import Generator, ucfirst +from models import PrimitiveType, ObjectType, ArrayType, EnumType, AliasedType, Frameworks + +log = logging.getLogger('global') + + +def join_type_and_name(type_str, name_str): + if type_str.endswith('*'): + return type_str + name_str + return type_str + ' ' + name_str + + +def strip_block_comment_markers(str): + return str.replace('/*', '').replace('*/', '') + + +def remove_duplicate_from_str(str, possible_duplicate): + return str.replace(possible_duplicate + possible_duplicate, possible_duplicate) + + +_OBJC_IDENTIFIER_RENAME_MAP = { + 'this': 'thisObject', # Debugger.CallFrame.this + 'description': 'stringRepresentation', # Runtime.RemoteObject.description + 'id': 'identifier', # Page.Frame.id, Runtime.ExecutionContextDescription.id, Debugger.BreakpointAction.id +} + +_OBJC_IDENTIFIER_REVERSE_RENAME_MAP = dict((v, k) for k, v in _OBJC_IDENTIFIER_RENAME_MAP.iteritems()) + + +class ObjCTypeCategory: + Simple = 0 + String = 1 + Object = 2 + Array = 3 + + @staticmethod + def category_for_type(_type): + if (isinstance(_type, PrimitiveType)): + if _type.raw_name() is 'string': + return ObjCTypeCategory.String + if _type.raw_name() in ['object', 'any']: + return ObjCTypeCategory.Object + if _type.raw_name() is 'array': + return ObjCTypeCategory.Array + return ObjCTypeCategory.Simple + if (isinstance(_type, ObjectType)): + return ObjCTypeCategory.Object + if (isinstance(_type, ArrayType)): + return ObjCTypeCategory.Array + if (isinstance(_type, AliasedType)): + return ObjCTypeCategory.category_for_type(_type.aliased_type) + if (isinstance(_type, EnumType)): + return ObjCTypeCategory.category_for_type(_type.primitive_type) + return None + +# Almost all Objective-C class names require the use of a prefix that depends on the +# target framework's 'objc_prefix' setting. So, most helpers are instance methods. + +class ObjCGenerator(Generator): + # Do not use a dynamic prefix for RWIProtocolJSONObject since it's used as a common + # base class and needs a consistent Objective-C prefix to be in a reusable framework. + OBJC_HELPER_PREFIX = 'RWI' + OBJC_SHARED_PREFIX = 'Protocol' + OBJC_STATIC_PREFIX = '%s%s' % (OBJC_HELPER_PREFIX, OBJC_SHARED_PREFIX) + + def __init__(self, *args, **kwargs): + Generator.__init__(self, *args, **kwargs) + + # The 'protocol name' is used to prefix filenames for a protocol group (a set of domains generated together). + def protocol_name(self): + protocol_group = self.model().framework.setting('objc_protocol_group', '') + return '%s%s' % (protocol_group, ObjCGenerator.OBJC_SHARED_PREFIX) + + # The 'ObjC prefix' is used to prefix Objective-C class names and enums with a + # framework-specific prefix. It is separate from filename prefixes. + def objc_prefix(self): + framework_prefix = self.model().framework.setting('objc_prefix', None) + if not framework_prefix: + return '' + else: + return '%s%s' % (framework_prefix, ObjCGenerator.OBJC_SHARED_PREFIX) + + # Adjust identifier names that collide with ObjC keywords. + + @staticmethod + def identifier_to_objc_identifier(name): + return _OBJC_IDENTIFIER_RENAME_MAP.get(name, name) + + @staticmethod + def objc_identifier_to_identifier(name): + return _OBJC_IDENTIFIER_REVERSE_RENAME_MAP.get(name, name) + + # Generate ObjC types, command handlers, and event dispatchers for a subset of domains. + + DOMAINS_TO_GENERATE = ['CSS', 'DOM', 'DOMStorage', 'Network', 'Page', 'Automation', 'GenericTypes'] + + def should_generate_types_for_domain(self, domain): + if not len(self.type_declarations_for_domain(domain)): + return False + + if self.model().framework is Frameworks.Test: + return True + + whitelist = set(ObjCGenerator.DOMAINS_TO_GENERATE) + whitelist.update(set(['Console', 'Debugger', 'Runtime'])) + return domain.domain_name in whitelist + + def should_generate_commands_for_domain(self, domain): + if not len(self.commands_for_domain(domain)): + return False + + if self.model().framework is Frameworks.Test: + return True + + whitelist = set(ObjCGenerator.DOMAINS_TO_GENERATE) + return domain.domain_name in whitelist + + def should_generate_events_for_domain(self, domain): + if not len(self.events_for_domain(domain)): + return False + + if self.model().framework is Frameworks.Test: + return True + + whitelist = set(ObjCGenerator.DOMAINS_TO_GENERATE) + whitelist.add('Console') + return domain.domain_name in whitelist + + # ObjC enum and type names. + + def objc_name_for_type(self, type): + name = type.qualified_name().replace('.', '') + name = remove_duplicate_from_str(name, type.type_domain().domain_name) + return '%s%s' % (self.objc_prefix(), name) + + def objc_enum_name_for_anonymous_enum_declaration(self, declaration): + domain_name = declaration.type.type_domain().domain_name + name = '%s%s' % (domain_name, declaration.type.raw_name()) + name = remove_duplicate_from_str(name, domain_name) + return '%s%s' % (self.objc_prefix(), name) + + def objc_enum_name_for_anonymous_enum_member(self, declaration, member): + domain_name = member.type.type_domain().domain_name + name = '%s%s%s' % (domain_name, declaration.type.raw_name(), ucfirst(member.member_name)) + name = remove_duplicate_from_str(name, domain_name) + return '%s%s' % (self.objc_prefix(), name) + + def objc_enum_name_for_anonymous_enum_parameter(self, domain, event_or_command_name, parameter): + domain_name = domain.domain_name + name = '%s%s%s' % (domain_name, ucfirst(event_or_command_name), ucfirst(parameter.parameter_name)) + name = remove_duplicate_from_str(name, domain_name) + return '%s%s' % (self.objc_prefix(), name) + + def objc_enum_name_for_non_anonymous_enum(self, _type): + domain_name = _type.type_domain().domain_name + name = _type.qualified_name().replace('.', '') + name = remove_duplicate_from_str(name, domain_name) + return '%s%s' % (self.objc_prefix(), name) + + # Miscellaneous name handling. + + @staticmethod + def variable_name_prefix_for_domain(domain): + domain_name = domain.domain_name + if domain_name.startswith('DOM'): + return 'dom' + domain_name[3:] + if domain_name.startswith('CSS'): + return 'css' + domain_name[3:] + return domain_name[:1].lower() + domain_name[1:] + + # Type basics. + + @staticmethod + def objc_accessor_type_for_raw_name(raw_name): + if raw_name in ['string', 'array']: + return 'copy' + if raw_name in ['integer', 'number', 'boolean']: + return 'assign' + if raw_name in ['any', 'object']: + return 'retain' + return None + + @staticmethod + def objc_type_for_raw_name(raw_name): + if raw_name is 'string': + return 'NSString *' + if raw_name is 'array': + return 'NSArray *' + if raw_name is 'integer': + return 'int' + if raw_name is 'number': + return 'double' + if raw_name is 'boolean': + return 'BOOL' + if raw_name in ['any', 'object']: + return '%sJSONObject *' % ObjCGenerator.OBJC_STATIC_PREFIX + return None + + @staticmethod + def objc_class_for_raw_name(raw_name): + if raw_name is 'string': + return 'NSString' + if raw_name is 'array': + return 'NSArray' + if raw_name in ['integer', 'number', 'boolean']: + return 'NSNumber' + if raw_name in ['any', 'object']: + return '%sJSONObject' % ObjCGenerator.OBJC_STATIC_PREFIX + return None + + # FIXME: Can these protocol_type functions be removed in favor of C++ generators functions? + + @staticmethod + def protocol_type_for_raw_name(raw_name): + if raw_name is 'string': + return 'String' + if raw_name is 'integer': + return 'int' + if raw_name is 'number': + return 'double' + if raw_name is 'boolean': + return 'bool' + if raw_name in ['any', 'object']: + return 'InspectorObject' + return None + + @staticmethod + def protocol_type_for_type(_type): + if (isinstance(_type, AliasedType)): + _type = _type.aliased_type + if (isinstance(_type, PrimitiveType)): + return ObjCGenerator.protocol_type_for_raw_name(_type.raw_name()) + if (isinstance(_type, EnumType)): + return ObjCGenerator.protocol_type_for_type(_type.primitive_type) + if (isinstance(_type, ObjectType)): + return 'Inspector::Protocol::%s::%s' % (_type.type_domain().domain_name, _type.raw_name()) + if (isinstance(_type, ArrayType)): + sub_type = ObjCGenerator.protocol_type_for_type(_type.element_type) + return 'Inspector::Protocol::Array<%s>' % sub_type + return None + + @staticmethod + def is_type_objc_pointer_type(_type): + if (isinstance(_type, AliasedType)): + _type = _type.aliased_type + if (isinstance(_type, PrimitiveType)): + return _type.raw_name() in ['string', 'array', 'any', 'object'] + if (isinstance(_type, EnumType)): + return False + if (isinstance(_type, ObjectType)): + return True + if (isinstance(_type, ArrayType)): + return True + return None + + def objc_class_for_type(self, _type): + if (isinstance(_type, AliasedType)): + _type = _type.aliased_type + if (isinstance(_type, PrimitiveType)): + return ObjCGenerator.objc_class_for_raw_name(_type.raw_name()) + if (isinstance(_type, EnumType)): + return ObjCGenerator.objc_class_for_raw_name(_type.primitive_type.raw_name()) + if (isinstance(_type, ObjectType)): + return self.objc_name_for_type(_type) + if (isinstance(_type, ArrayType)): + sub_type = strip_block_comment_markers(self.objc_class_for_type(_type.element_type)) + return 'NSArray/*<%s>*/' % sub_type + return None + + def objc_class_for_array_type(self, _type): + if isinstance(_type, AliasedType): + _type = _type.aliased_type + if isinstance(_type, ArrayType): + return self.objc_class_for_type(_type.element_type) + return None + + def objc_accessor_type_for_member(self, member): + return self.objc_accessor_type_for_member_internal(member.type) + + def objc_accessor_type_for_member_internal(self, _type): + if (isinstance(_type, AliasedType)): + _type = _type.aliased_type + if (isinstance(_type, PrimitiveType)): + return self.objc_accessor_type_for_raw_name(_type.raw_name()) + if (isinstance(_type, EnumType)): + return 'assign' + if (isinstance(_type, ObjectType)): + return 'retain' + if (isinstance(_type, ArrayType)): + return 'copy' + return None + + def objc_type_for_member(self, declaration, member): + return self.objc_type_for_member_internal(member.type, declaration, member) + + def objc_type_for_member_internal(self, _type, declaration, member): + if (isinstance(_type, AliasedType)): + _type = _type.aliased_type + if (isinstance(_type, PrimitiveType)): + return self.objc_type_for_raw_name(_type.raw_name()) + if (isinstance(_type, EnumType)): + if (_type.is_anonymous): + return self.objc_enum_name_for_anonymous_enum_member(declaration, member) + return self.objc_enum_name_for_non_anonymous_enum(_type) + if (isinstance(_type, ObjectType)): + return self.objc_name_for_type(_type) + ' *' + if (isinstance(_type, ArrayType)): + sub_type = strip_block_comment_markers(self.objc_class_for_type(_type.element_type)) + return 'NSArray/*<%s>*/ *' % sub_type + return None + + def objc_type_for_param(self, domain, event_or_command_name, parameter, respect_optional=True): + objc_type = self.objc_type_for_param_internal(parameter.type, domain, event_or_command_name, parameter) + if respect_optional and parameter.is_optional: + if objc_type.endswith('*'): + return objc_type + '*' + return objc_type + ' *' + return objc_type + + def objc_type_for_param_internal(self, _type, domain, event_or_command_name, parameter): + if (isinstance(_type, AliasedType)): + _type = _type.aliased_type + if (isinstance(_type, PrimitiveType)): + return self.objc_type_for_raw_name(_type.raw_name()) + if (isinstance(_type, EnumType)): + if _type.is_anonymous: + return self.objc_enum_name_for_anonymous_enum_parameter(domain, event_or_command_name, parameter) + return self.objc_enum_name_for_non_anonymous_enum(_type) + if (isinstance(_type, ObjectType)): + return self.objc_name_for_type(_type) + ' *' + if (isinstance(_type, ArrayType)): + sub_type = strip_block_comment_markers(self.objc_class_for_type(_type.element_type)) + return 'NSArray/*<%s>*/ *' % sub_type + return None + + # ObjC <-> Protocol conversion for commands and events. + # - convert a command call parameter received from Protocol to ObjC for handler + # - convert a command return parameter in callback block from ObjC to Protocol to send + # - convert an event parameter from ObjC API to Protocol to send + + def objc_protocol_export_expression_for_variable(self, var_type, var_name): + category = ObjCTypeCategory.category_for_type(var_type) + if category in [ObjCTypeCategory.Simple, ObjCTypeCategory.String]: + if isinstance(var_type, EnumType): + return 'toProtocolString(%s)' % var_name + return var_name + if category is ObjCTypeCategory.Object: + return '[%s toInspectorObject]' % var_name + if category is ObjCTypeCategory.Array: + protocol_type = ObjCGenerator.protocol_type_for_type(var_type.element_type) + objc_class = self.objc_class_for_type(var_type.element_type) + if protocol_type == 'Inspector::Protocol::Array<String>': + return 'inspectorStringArrayArray(%s)' % var_name + if protocol_type is 'String' and objc_class is 'NSString': + return 'inspectorStringArray(%s)' % var_name + if protocol_type is 'int' and objc_class is 'NSNumber': + return 'inspectorIntegerArray(%s)' % var_name + if protocol_type is 'double' and objc_class is 'NSNumber': + return 'inspectorDoubleArray(%s)' % var_name + return 'inspectorObjectArray(%s)' % var_name + + def objc_protocol_import_expression_for_member(self, name, declaration, member): + if isinstance(member.type, EnumType): + if member.type.is_anonymous: + return 'fromProtocolString<%s>(%s)' % (self.objc_enum_name_for_anonymous_enum_member(declaration, member), name) + return 'fromProtocolString<%s>(%s)' % (self.objc_enum_name_for_non_anonymous_enum(member.type), name) + return self.objc_protocol_import_expression_for_variable(member.type, name) + + def objc_protocol_import_expression_for_parameter(self, name, domain, event_or_command_name, parameter): + if isinstance(parameter.type, EnumType): + if parameter.type.is_anonymous: + return 'fromProtocolString<%s>(%s)' % (self.objc_enum_name_for_anonymous_enum_parameter(domain, event_or_command_name, parameter), name) + return 'fromProtocolString<%s>(%s)' % (self.objc_enum_name_for_non_anonymous_enum(parameter.type), name) + return self.objc_protocol_import_expression_for_variable(parameter.type, name) + + def objc_protocol_import_expression_for_variable(self, var_type, var_name): + category = ObjCTypeCategory.category_for_type(var_type) + if category in [ObjCTypeCategory.Simple, ObjCTypeCategory.String]: + return var_name + if category is ObjCTypeCategory.Object: + objc_class = self.objc_class_for_type(var_type) + return '[[[%s alloc] initWithInspectorObject:%s] autorelease]' % (objc_class, var_name) + if category is ObjCTypeCategory.Array: + objc_class = self.objc_class_for_type(var_type.element_type) + if objc_class is 'NSString': + return 'objcStringArray(%s)' % var_name + if objc_class is 'NSNumber': # FIXME: Integer or Double? + return 'objcIntegerArray(%s)' % var_name + return 'objcArray<%s>(%s)' % (objc_class, var_name) + + # ObjC <-> JSON object conversion for types getters/setters. + # - convert a member setter from ObjC API to JSON object setter + # - convert a member getter from JSON object to ObjC API + + def objc_to_protocol_expression_for_member(self, declaration, member, sub_expression): + category = ObjCTypeCategory.category_for_type(member.type) + if category in [ObjCTypeCategory.Simple, ObjCTypeCategory.String]: + if isinstance(member.type, EnumType): + return 'toProtocolString(%s)' % sub_expression + return sub_expression + if category is ObjCTypeCategory.Object: + return sub_expression + if category is ObjCTypeCategory.Array: + objc_class = self.objc_class_for_type(member.type.element_type) + if objc_class is 'NSString': + return 'inspectorStringArray(%s)' % sub_expression + if objc_class is 'NSNumber': + protocol_type = ObjCGenerator.protocol_type_for_type(member.type.element_type) + if protocol_type is 'double': + return 'inspectorDoubleArray(%s)' % sub_expression + return 'inspectorIntegerArray(%s)' % sub_expression + return 'inspectorObjectArray(%s)' % sub_expression + + def protocol_to_objc_expression_for_member(self, declaration, member, sub_expression): + category = ObjCTypeCategory.category_for_type(member.type) + if category in [ObjCTypeCategory.Simple, ObjCTypeCategory.String]: + if isinstance(member.type, EnumType): + if member.type.is_anonymous: + return 'fromProtocolString<%s>(%s).value()' % (self.objc_enum_name_for_anonymous_enum_member(declaration, member), sub_expression) + return 'fromProtocolString<%s>(%s).value()' % (self.objc_enum_name_for_non_anonymous_enum(member.type), sub_expression) + return sub_expression + if category is ObjCTypeCategory.Object: + objc_class = self.objc_class_for_type(member.type) + return '[[%s alloc] initWithInspectorObject:[%s toInspectorObject].get()]' % (objc_class, sub_expression) + if category is ObjCTypeCategory.Array: + protocol_type = ObjCGenerator.protocol_type_for_type(member.type.element_type) + objc_class = self.objc_class_for_type(member.type.element_type) + if objc_class is 'NSString': + return 'objcStringArray(%s)' % sub_expression + if objc_class is 'NSNumber': + protocol_type = ObjCGenerator.protocol_type_for_type(member.type.element_type) + if protocol_type is 'double': + return 'objcDoubleArray(%s)' % sub_expression + return 'objcIntegerArray(%s)' % sub_expression + return 'objcArray<%s>(%s)' % (objc_class, sub_expression) + + def payload_to_objc_expression_for_member(self, declaration, member): + _type = member.type + if isinstance(_type, AliasedType): + _type = _type.aliased_type + if isinstance(_type, PrimitiveType): + sub_expression = 'payload[@"%s"]' % member.member_name + raw_name = _type.raw_name() + if raw_name is 'boolean': + return '[%s boolValue]' % sub_expression + if raw_name is 'integer': + return '[%s integerValue]' % sub_expression + if raw_name is 'number': + return '[%s doubleValue]' % sub_expression + if raw_name in ['any', 'object', 'array', 'string']: + return sub_expression # The setter will check the incoming value. + return None + if isinstance(member.type, EnumType): + sub_expression = 'payload[@"%s"]' % member.member_name + if member.type.is_anonymous: + return 'fromProtocolString<%s>(%s)' % (self.objc_enum_name_for_anonymous_enum_member(declaration, member), sub_expression) + else: + return 'fromProtocolString<%s>(%s)' % (self.objc_enum_name_for_non_anonymous_enum(member.type), sub_expression) + if isinstance(_type, ObjectType): + objc_class = self.objc_class_for_type(member.type) + return '[[%s alloc] initWithPayload:payload[@"%s"]]' % (objc_class, member.member_name) + if isinstance(_type, ArrayType): + objc_class = self.objc_class_for_type(member.type.element_type) + return 'objcArrayFromPayload<%s>(payload[@"%s"])' % (objc_class, member.member_name) + + # JSON object setter/getter selectors for types. + + @staticmethod + def objc_setter_method_for_member(declaration, member): + return ObjCGenerator.objc_setter_method_for_member_internal(member.type, declaration, member) + + @staticmethod + def objc_setter_method_for_member_internal(_type, declaration, member): + if (isinstance(_type, AliasedType)): + _type = _type.aliased_type + if (isinstance(_type, PrimitiveType)): + raw_name = _type.raw_name() + if raw_name is 'boolean': + return 'setBool' + if raw_name is 'integer': + return 'setInteger' + if raw_name is 'number': + return 'setDouble' + if raw_name is 'string': + return 'setString' + if raw_name in ['any', 'object']: + return 'setObject' + if raw_name is 'array': + return 'setInspectorArray' + return None + if (isinstance(_type, EnumType)): + return 'setString' + if (isinstance(_type, ObjectType)): + return 'setObject' + if (isinstance(_type, ArrayType)): + return 'setInspectorArray' + return None + + @staticmethod + def objc_getter_method_for_member(declaration, member): + return ObjCGenerator.objc_getter_method_for_member_internal(member.type, declaration, member) + + @staticmethod + def objc_getter_method_for_member_internal(_type, declaration, member): + if (isinstance(_type, AliasedType)): + _type = _type.aliased_type + if (isinstance(_type, PrimitiveType)): + raw_name = _type.raw_name() + if raw_name is 'boolean': + return 'boolForKey' + if raw_name is 'integer': + return 'integerForKey' + if raw_name is 'number': + return 'doubleForKey' + if raw_name is 'string': + return 'stringForKey' + if raw_name in ['any', 'object']: + return 'objectForKey' + if raw_name is 'array': + return 'inspectorArrayForKey' + return None + if (isinstance(_type, EnumType)): + return 'stringForKey' + if (isinstance(_type, ObjectType)): + return 'objectForKey' + if (isinstance(_type, ArrayType)): + return 'inspectorArrayForKey' + return None diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/objc_generator_templates.py b/Source/JavaScriptCore/inspector/scripts/codegen/objc_generator_templates.py new file mode 100755 index 000000000..1c30c40d4 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/codegen/objc_generator_templates.py @@ -0,0 +1,155 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + +# Generator templates, which can be filled with string.Template. +# Following are classes that fill the templates from the typechecked model. + +class ObjCGeneratorTemplates: + + HeaderPrelude = ( + """#import <Foundation/Foundation.h> + +${includes} +""") + + HeaderPostlude = ( + """""") + + TypeConversionsHeaderPrelude = ( + """${includes} + +namespace Inspector {""") + + TypeConversionsHeaderPostlude = ( + """} // namespace Inspector +""") + + GenericHeaderPrelude = ( + """${includes}""") + + GenericHeaderPostlude = ( + """""") + + TypeConversionsHeaderStandard = ( + """template<typename ObjCEnumType> +std::optional<ObjCEnumType> fromProtocolString(const String& value);""") + + BackendDispatcherHeaderPrelude = ( + """${includes} + +${forwardDeclarations} + +namespace Inspector { +""") + + BackendDispatcherHeaderPostlude = ( + """} // namespace Inspector +""") + + BackendDispatcherImplementationPrelude = ( + """#import "config.h" +#import ${primaryInclude} + +${secondaryIncludes} + +namespace Inspector {""") + + BackendDispatcherImplementationPostlude = ( + """} // namespace Inspector +""") + + ImplementationPrelude = ( + """#import ${primaryInclude} + +${secondaryIncludes} + +using namespace Inspector;""") + + ImplementationPostlude = ( + """""") + + BackendDispatcherHeaderDomainHandlerInterfaceDeclaration = ( + """class Alternate${domainName}BackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~Alternate${domainName}BackendDispatcher() { } +${commandDeclarations} +};""") + + BackendDispatcherHeaderDomainHandlerObjCDeclaration = ( + """class ObjCInspector${domainName}BackendDispatcher final : public Alternate${domainName}BackendDispatcher { +public: + ObjCInspector${domainName}BackendDispatcher(id<${objcPrefix}${domainName}DomainHandler> handler) { m_delegate = handler; } +${commandDeclarations} +private: + RetainPtr<id<${objcPrefix}${domainName}DomainHandler>> m_delegate; +};""") + + BackendDispatcherHeaderDomainHandlerImplementation = ( + """void ObjCInspector${domainName}BackendDispatcher::${commandName}(${parameters}) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + +${successCallback} +${conversions} +${invocation} +} +""") + + ConfigurationCommandProperty = ( + """@property (nonatomic, retain, setter=set${domainName}Handler:) id<${objcPrefix}${domainName}DomainHandler> ${variableNamePrefix}Handler;""") + + ConfigurationEventProperty = ( + """@property (nonatomic, readonly) ${objcPrefix}${domainName}DomainEventDispatcher *${variableNamePrefix}EventDispatcher;""") + + ConfigurationCommandPropertyImplementation = ( + """- (void)set${domainName}Handler:(id<${objcPrefix}${domainName}DomainHandler>)handler +{ + if (handler == _${variableNamePrefix}Handler) + return; + + [_${variableNamePrefix}Handler release]; + _${variableNamePrefix}Handler = [handler retain]; + + auto alternateDispatcher = std::make_unique<ObjCInspector${domainName}BackendDispatcher>(handler); + auto alternateAgent = std::make_unique<AlternateDispatchableAgent<${domainName}BackendDispatcher, Alternate${domainName}BackendDispatcher>>(ASCIILiteral("${domainName}"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id<${objcPrefix}${domainName}DomainHandler>)${variableNamePrefix}Handler +{ + return _${variableNamePrefix}Handler; +}""") + + ConfigurationGetterImplementation = ( + """- (${objcPrefix}${domainName}DomainEventDispatcher *)${variableNamePrefix}EventDispatcher +{ + if (!_${variableNamePrefix}EventDispatcher) + _${variableNamePrefix}EventDispatcher = [[${objcPrefix}${domainName}DomainEventDispatcher alloc] initWithController:_controller]; + return _${variableNamePrefix}EventDispatcher; +}""") diff --git a/Source/JavaScriptCore/inspector/scripts/cssmin.py b/Source/JavaScriptCore/inspector/scripts/cssmin.py deleted file mode 100644 index a0640eb28..000000000 --- a/Source/JavaScriptCore/inspector/scripts/cssmin.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/python - -# Copyright (C) 2013 Apple Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -# THE POSSIBILITY OF SUCH DAMAGE. - -import re - -def cssminify(css): - rules = ( - (r"\/\*.*?\*\/", ""), # delete comments - (r"\n", ""), # delete new lines - (r"\s+", " "), # change multiple spaces to one space - (r"\s?([;:{},+>])\s?", r"\1"), # delete space where it is not needed - (r";}", "}") # change ';}' to '}' because the semicolon is not needed - ) - - css = css.replace("\r\n", "\n") - for rule in rules: - css = re.compile(rule[0], re.MULTILINE | re.UNICODE | re.DOTALL).sub(rule[1], css) - return css - -if __name__ == "__main__": - import sys - sys.stdout.write(cssminify(sys.stdin.read())) diff --git a/Source/JavaScriptCore/inspector/scripts/generate-combined-inspector-json.py b/Source/JavaScriptCore/inspector/scripts/generate-combined-inspector-json.py deleted file mode 100755 index db163bfe4..000000000 --- a/Source/JavaScriptCore/inspector/scripts/generate-combined-inspector-json.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/python - -# Copyright (C) 2013 Apple Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -# THE POSSIBILITY OF SUCH DAMAGE. - -import glob -import json -import os -import sys - -if len(sys.argv) < 2: - print("usage: %s [json files or directory of json files ...]" % os.path.basename(sys.argv[0])) - sys.exit(1) - -files = [] -for arg in sys.argv[1:]: - if not os.access(arg, os.F_OK): - raise Exception("File \"%s\" not found" % arg) - elif os.path.isdir(arg): - files.extend(glob.glob(os.path.join(arg, "*.json"))) - else: - files.append(arg) -files.sort() - -# To keep as close to the original JSON formatting as possible, just -# dump each JSON input file unmodified into an array of "domains". -# Validate each file is valid JSON and that there is a "domain" key. - -first = True -print("{\"domains\":[") -for file in files: - if first: - first = False - else: - print(",") - - string = open(file).read() - - try: - dictionary = json.loads(string) - if not "domain" in dictionary: - raise Exception("File \"%s\" does not contains a \"domain\" key." % file) - except ValueError: - sys.stderr.write("File \"%s\" does not contain valid JSON:\n" % file) - raise - - print(string.rstrip()) -print("]}") diff --git a/Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py b/Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py new file mode 100755 index 000000000..e39a604fc --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py @@ -0,0 +1,270 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014, 2016 Apple Inc. All rights reserved. +# Copyright (c) 2014 University of Washington. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. + +# This script generates JS, Objective C, and C++ bindings for the inspector protocol. +# Generators for individual files are located in the codegen/ directory. + +import os.path +import re +import sys +import string +from string import Template +import optparse +import logging + +try: + import json +except ImportError: + import simplejson as json + +logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.ERROR) +log = logging.getLogger('global') + +try: + from codegen import * + +# When copying generator files to JavaScriptCore's private headers on Mac, +# the codegen/ module directory is flattened. So, import directly. +except ImportError, e: + # log.error(e) # Uncomment this to debug early import errors. + import models + from models import * + from generator import * + from cpp_generator import * + from objc_generator import * + + from generate_cpp_alternate_backend_dispatcher_header import * + from generate_cpp_backend_dispatcher_header import * + from generate_cpp_backend_dispatcher_implementation import * + from generate_cpp_frontend_dispatcher_header import * + from generate_cpp_frontend_dispatcher_implementation import * + from generate_cpp_protocol_types_header import * + from generate_cpp_protocol_types_implementation import * + from generate_js_backend_commands import * + from generate_objc_backend_dispatcher_header import * + from generate_objc_backend_dispatcher_implementation import * + from generate_objc_configuration_header import * + from generate_objc_configuration_implementation import * + from generate_objc_frontend_dispatcher_implementation import * + from generate_objc_header import * + from generate_objc_internal_header import * + from generate_objc_protocol_type_conversions_header import * + from generate_objc_protocol_type_conversions_implementation import * + from generate_objc_protocol_types_implementation import * + + +# A writer that only updates file if it actually changed. +class IncrementalFileWriter: + def __init__(self, filepath, force_output): + self._filepath = filepath + self._output = "" + self.force_output = force_output + + def write(self, text): + self._output += text + + def close(self): + text_changed = True + self._output = self._output.rstrip() + "\n" + + try: + if self.force_output: + raise + + read_file = open(self._filepath, "r") + old_text = read_file.read() + read_file.close() + text_changed = old_text != self._output + except: + # Ignore, just overwrite by default + pass + + if text_changed or self.force_output: + out_file = open(self._filepath, "w") + out_file.write(self._output) + out_file.close() + + +def generate_from_specification(primary_specification_filepath=None, + supplemental_specification_filepaths=[], + concatenate_output=False, + output_dirpath=None, + force_output=False, + framework_name="", + platform_name="", + generate_frontend=True, + generate_backend=True): + + def load_specification(protocol, filepath, isSupplemental=False): + try: + with open(filepath, "r") as input_file: + parsed_json = json.load(input_file) + protocol.parse_specification(parsed_json, isSupplemental) + except ValueError as e: + raise Exception("Error parsing valid JSON in file: " + filepath + "\nParse error: " + str(e)) + + platform = Platform.fromString(platform_name) + protocol = models.Protocol(framework_name) + for specification in supplemental_specification_filepaths: + load_specification(protocol, specification, isSupplemental=True) + load_specification(protocol, primary_specification_filepath, isSupplemental=False) + + protocol.resolve_types() + + generator_arguments = [protocol, platform, primary_specification_filepath] + generators = [] + + if protocol.framework is Frameworks.Test: + generators.append(JSBackendCommandsGenerator(*generator_arguments)) + generators.append(CppAlternateBackendDispatcherHeaderGenerator(*generator_arguments)) + generators.append(CppBackendDispatcherHeaderGenerator(*generator_arguments)) + generators.append(CppBackendDispatcherImplementationGenerator(*generator_arguments)) + generators.append(CppFrontendDispatcherHeaderGenerator(*generator_arguments)) + generators.append(CppFrontendDispatcherImplementationGenerator(*generator_arguments)) + generators.append(CppProtocolTypesHeaderGenerator(*generator_arguments)) + generators.append(CppProtocolTypesImplementationGenerator(*generator_arguments)) + generators.append(ObjCBackendDispatcherHeaderGenerator(*generator_arguments)) + generators.append(ObjCBackendDispatcherImplementationGenerator(*generator_arguments)) + generators.append(ObjCConfigurationHeaderGenerator(*generator_arguments)) + generators.append(ObjCConfigurationImplementationGenerator(*generator_arguments)) + generators.append(ObjCFrontendDispatcherImplementationGenerator(*generator_arguments)) + generators.append(ObjCHeaderGenerator(*generator_arguments)) + generators.append(ObjCInternalHeaderGenerator(*generator_arguments)) + generators.append(ObjCProtocolTypeConversionsHeaderGenerator(*generator_arguments)) + generators.append(ObjCProtocolTypeConversionsImplementationGenerator(*generator_arguments)) + generators.append(ObjCProtocolTypesImplementationGenerator(*generator_arguments)) + + elif protocol.framework is Frameworks.JavaScriptCore: + generators.append(JSBackendCommandsGenerator(*generator_arguments)) + generators.append(CppAlternateBackendDispatcherHeaderGenerator(*generator_arguments)) + generators.append(CppBackendDispatcherHeaderGenerator(*generator_arguments)) + generators.append(CppBackendDispatcherImplementationGenerator(*generator_arguments)) + generators.append(CppFrontendDispatcherHeaderGenerator(*generator_arguments)) + generators.append(CppFrontendDispatcherImplementationGenerator(*generator_arguments)) + generators.append(CppProtocolTypesHeaderGenerator(*generator_arguments)) + generators.append(CppProtocolTypesImplementationGenerator(*generator_arguments)) + + elif protocol.framework is Frameworks.WebKit and generate_backend: + generators.append(CppBackendDispatcherHeaderGenerator(*generator_arguments)) + generators.append(CppBackendDispatcherImplementationGenerator(*generator_arguments)) + generators.append(CppProtocolTypesHeaderGenerator(*generator_arguments)) + generators.append(CppProtocolTypesImplementationGenerator(*generator_arguments)) + + elif protocol.framework is Frameworks.WebKit and generate_frontend: + generators.append(ObjCHeaderGenerator(*generator_arguments)) + generators.append(ObjCProtocolTypeConversionsHeaderGenerator(*generator_arguments)) + generators.append(ObjCProtocolTypeConversionsImplementationGenerator(*generator_arguments)) + generators.append(ObjCProtocolTypesImplementationGenerator(*generator_arguments)) + + elif protocol.framework is Frameworks.WebInspector: + generators.append(ObjCBackendDispatcherHeaderGenerator(*generator_arguments)) + generators.append(ObjCBackendDispatcherImplementationGenerator(*generator_arguments)) + generators.append(ObjCConfigurationHeaderGenerator(*generator_arguments)) + generators.append(ObjCConfigurationImplementationGenerator(*generator_arguments)) + generators.append(ObjCFrontendDispatcherImplementationGenerator(*generator_arguments)) + generators.append(ObjCHeaderGenerator(*generator_arguments)) + generators.append(ObjCInternalHeaderGenerator(*generator_arguments)) + generators.append(ObjCProtocolTypeConversionsHeaderGenerator(*generator_arguments)) + generators.append(ObjCProtocolTypesImplementationGenerator(*generator_arguments)) + + single_output_file_contents = [] + + for generator in generators: + # Only some generators care whether frontend or backend was specified, but it is + # set on all of them to avoid adding more constructor arguments or thinking too hard. + if generate_backend: + generator.set_generator_setting('generate_backend', True) + if generate_frontend: + generator.set_generator_setting('generate_frontend', True) + + output = generator.generate_output() + if concatenate_output: + single_output_file_contents.append('### Begin File: %s' % generator.output_filename()) + single_output_file_contents.append(output) + single_output_file_contents.append('### End File: %s' % generator.output_filename()) + single_output_file_contents.append('') + else: + output_file = IncrementalFileWriter(os.path.join(output_dirpath, generator.output_filename()), force_output) + output_file.write(output) + output_file.close() + + if concatenate_output: + filename = os.path.join(os.path.basename(primary_specification_filepath) + '-result') + output_file = IncrementalFileWriter(os.path.join(output_dirpath, filename), force_output) + output_file.write('\n'.join(single_output_file_contents)) + output_file.close() + + +if __name__ == '__main__': + allowed_framework_names = ['JavaScriptCore', 'WebInspector', 'WebKit', 'Test'] + allowed_platform_names = ['iOS', 'macOS', 'all', 'generic'] + cli_parser = optparse.OptionParser(usage="usage: %prog [options] PrimaryProtocol.json [SupplementalProtocol.json ...]") + cli_parser.add_option("-o", "--outputDir", help="Directory where generated files should be written.") + cli_parser.add_option("--framework", type="choice", choices=allowed_framework_names, help="The framework that the primary specification belongs to.") + cli_parser.add_option("--force", action="store_true", help="Force output of generated scripts, even if nothing changed.") + cli_parser.add_option("-v", "--debug", action="store_true", help="Log extra output for debugging the generator itself.") + cli_parser.add_option("-t", "--test", action="store_true", help="Enable test mode. Use unique output filenames created by prepending the input filename.") + cli_parser.add_option("--frontend", action="store_true", help="Generate code for the frontend-side of the protocol only.") + cli_parser.add_option("--backend", action="store_true", help="Generate code for the backend-side of the protocol only.") + cli_parser.add_option("--platform", default="generic", help="The platform of the backend being generated. For example, we compile WebKit2 for either macOS or iOS. This value is case-insensitive. Allowed values: %s" % ", ".join(allowed_platform_names)) + options = None + + arg_options, arg_values = cli_parser.parse_args() + if (len(arg_values) < 1): + raise ParseException("At least one plain argument expected") + + if not arg_options.outputDir: + raise ParseException("Missing output directory") + + if arg_options.debug: + log.setLevel(logging.DEBUG) + + generate_backend = arg_options.backend; + generate_frontend = arg_options.frontend; + # Default to generating both the frontend and backend if neither is specified. + if not generate_backend and not generate_frontend: + generate_backend = True + generate_frontend = True + + options = { + 'primary_specification_filepath': arg_values[0], + 'supplemental_specification_filepaths': arg_values[1:], + 'output_dirpath': arg_options.outputDir, + 'concatenate_output': arg_options.test, + 'framework_name': arg_options.framework, + 'platform_name': arg_options.platform, + 'force_output': arg_options.force, + 'generate_backend': generate_backend, + 'generate_frontend': generate_frontend, + } + + try: + generate_from_specification(**options) + except (ParseException, TypecheckException) as e: + if arg_options.test: + log.error(e.message) + else: + raise # Force the build to fail. diff --git a/Source/JavaScriptCore/inspector/scripts/inline-and-minify-stylesheets-and-scripts.py b/Source/JavaScriptCore/inspector/scripts/inline-and-minify-stylesheets-and-scripts.py deleted file mode 100755 index 89200c84e..000000000 --- a/Source/JavaScriptCore/inspector/scripts/inline-and-minify-stylesheets-and-scripts.py +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (C) 2013 Apple Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -# THE POSSIBILITY OF SUCH DAMAGE. - -# This script inlines and minifies external stylesheets and scripts. -# - <link href="..." rel="stylesheet"> => <style>...</style> -# - <script src="..."> => <script>...</script> - -import cssmin -import jsmin -import os.path -import re -import sys - - -def main(argv): - - if len(argv) < 2: - print('usage: %s inputFile outputFile' % argv[0]) - return 1 - - inputFileName = argv[1] - outputFileName = argv[2] - importsDir = os.path.dirname(inputFileName) - - inputFile = open(inputFileName, 'r') - inputContent = inputFile.read() - inputFile.close() - - def inline(match, minifier, prefix, postfix): - importFileName = match.group(1) - fullPath = os.path.join(importsDir, importFileName) - if not os.access(fullPath, os.F_OK): - raise Exception('File %s referenced in %s not found' % (importFileName, inputFileName)) - importFile = open(fullPath, 'r') - importContent = minifier(importFile.read()) - importFile.close() - return '%s%s%s' % (prefix, importContent, postfix) - - def inlineStylesheet(match): - return inline(match, cssmin.cssminify, "<style>", "</style>") - - def inlineScript(match): - return inline(match, jsmin.jsmin, "<script>", "</script>") - - outputContent = re.sub(r'<link rel="stylesheet" href=[\'"]([^\'"]+)[\'"]>', inlineStylesheet, inputContent) - outputContent = re.sub(r'<script src=[\'"]([^\'"]+)[\'"]></script>', inlineScript, outputContent) - - outputFile = open(outputFileName, 'w') - outputFile.write(outputContent) - outputFile.close() - - # Touch output file directory to make sure that Xcode will copy - # modified resource files. - if sys.platform == 'darwin': - outputDirName = os.path.dirname(outputFileName) - os.utime(outputDirName, None) - -if __name__ == '__main__': - sys.exit(main(sys.argv)) diff --git a/Source/JavaScriptCore/inspector/scripts/jsmin.py b/Source/JavaScriptCore/inspector/scripts/jsmin.py deleted file mode 100644 index 83d2a50ac..000000000 --- a/Source/JavaScriptCore/inspector/scripts/jsmin.py +++ /dev/null @@ -1,238 +0,0 @@ -# This code is original from jsmin by Douglas Crockford, it was translated to -# Python by Baruch Even. It was rewritten by Dave St.Germain for speed. -# -# The MIT License (MIT) -# -# Copyright (c) 2013 Dave St.Germain -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. - - -import sys -is_3 = sys.version_info >= (3, 0) -if is_3: - import io -else: - import StringIO - try: - import cStringIO - except ImportError: - cStringIO = None - - -__all__ = ['jsmin', 'JavascriptMinify'] -__version__ = '2.0.9' - - -def jsmin(js): - """ - returns a minified version of the javascript string - """ - if not is_3: - if cStringIO and not isinstance(js, unicode): - # strings can use cStringIO for a 3x performance - # improvement, but unicode (in python2) cannot - klass = cStringIO.StringIO - else: - klass = StringIO.StringIO - else: - klass = io.StringIO - ins = klass(js) - outs = klass() - JavascriptMinify(ins, outs).minify() - return outs.getvalue() - - -class JavascriptMinify(object): - """ - Minify an input stream of javascript, writing - to an output stream - """ - - def __init__(self, instream=None, outstream=None): - self.ins = instream - self.outs = outstream - - def minify(self, instream=None, outstream=None): - if instream and outstream: - self.ins, self.outs = instream, outstream - - self.is_return = False - self.return_buf = '' - - def write(char): - # all of this is to support literal regular expressions. - # sigh - if char in 'return': - self.return_buf += char - self.is_return = self.return_buf == 'return' - self.outs.write(char) - if self.is_return: - self.return_buf = '' - - read = self.ins.read - - space_strings = "abcdefghijklmnopqrstuvwxyz"\ - "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$\\" - starters, enders = '{[(+-', '}])+-"\'' - newlinestart_strings = starters + space_strings - newlineend_strings = enders + space_strings - do_newline = False - do_space = False - escape_slash_count = 0 - doing_single_comment = False - previous_before_comment = '' - doing_multi_comment = False - in_re = False - in_quote = '' - quote_buf = [] - - previous = read(1) - if previous == '\\': - escape_slash_count += 1 - next1 = read(1) - if previous == '/': - if next1 == '/': - doing_single_comment = True - elif next1 == '*': - doing_multi_comment = True - previous = next1 - next1 = read(1) - else: - write(previous) - elif not previous: - return - elif previous >= '!': - if previous in "'\"": - in_quote = previous - write(previous) - previous_non_space = previous - else: - previous_non_space = ' ' - if not next1: - return - - while 1: - next2 = read(1) - if not next2: - last = next1.strip() - if not (doing_single_comment or doing_multi_comment)\ - and last not in ('', '/'): - if in_quote: - write(''.join(quote_buf)) - write(last) - break - if doing_multi_comment: - if next1 == '*' and next2 == '/': - doing_multi_comment = False - next2 = read(1) - elif doing_single_comment: - if next1 in '\r\n': - doing_single_comment = False - while next2 in '\r\n': - next2 = read(1) - if not next2: - break - if previous_before_comment in ')}]': - do_newline = True - elif previous_before_comment in space_strings: - write('\n') - elif in_quote: - quote_buf.append(next1) - - if next1 == in_quote: - numslashes = 0 - for c in reversed(quote_buf[:-1]): - if c != '\\': - break - else: - numslashes += 1 - if numslashes % 2 == 0: - in_quote = '' - write(''.join(quote_buf)) - elif next1 in '\r\n': - if previous_non_space in newlineend_strings \ - or previous_non_space > '~': - while 1: - if next2 < '!': - next2 = read(1) - if not next2: - break - else: - if next2 in newlinestart_strings \ - or next2 > '~' or next2 == '/': - do_newline = True - break - elif next1 < '!' and not in_re: - if (previous_non_space in space_strings \ - or previous_non_space > '~') \ - and (next2 in space_strings or next2 > '~'): - do_space = True - elif previous_non_space in '-+' and next2 == previous_non_space: - # protect against + ++ or - -- sequences - do_space = True - elif self.is_return and next2 == '/': - # returning a regex... - write(' ') - elif next1 == '/': - if do_space: - write(' ') - if in_re: - if previous != '\\' or (not escape_slash_count % 2) or next2 in 'gimy': - in_re = False - write('/') - elif next2 == '/': - doing_single_comment = True - previous_before_comment = previous_non_space - elif next2 == '*': - doing_multi_comment = True - previous = next1 - next1 = next2 - next2 = read(1) - else: - in_re = previous_non_space in '(,=:[?!&|' or self.is_return # literal regular expression - write('/') - else: - if do_space: - do_space = False - write(' ') - if do_newline: - write('\n') - do_newline = False - - write(next1) - if not in_re and next1 in "'\"": - in_quote = next1 - quote_buf = [] - - previous = next1 - next1 = next2 - - if previous >= '!': - previous_non_space = previous - - if previous == '\\': - escape_slash_count += 1 - else: - escape_slash_count = 0 - -if __name__ == '__main__': - minifier = JavascriptMinify(sys.stdin, sys.stdout) - minifier.minify() - sys.stdout.write('\n') diff --git a/Source/JavaScriptCore/inspector/scripts/tests/all/definitions-with-mac-platform.json b/Source/JavaScriptCore/inspector/scripts/tests/all/definitions-with-mac-platform.json new file mode 100644 index 000000000..817f135ee --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/all/definitions-with-mac-platform.json @@ -0,0 +1,28 @@ +{ + "domain": "Network", + "types": [ + { + "id": "NetworkError", + "type": "object", + "platform": "macos", + "properties": [ + { "name": "message", "type": "string", "description": "Error message." }, + { "name": "code", "type": "integer", "description": "Error code." } + ] + } + ], + "commands": [ + { + "name": "loadResource", + "platform": "macos", + "description": "Loads a resource in the context of a frame on the inspected page without cross origin checks." + } + ], + "events": [ + { + "name": "resourceLoaded", + "platform": "macos", + "description": "A resource was loaded." + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/all/expected/definitions-with-mac-platform.json-result b/Source/JavaScriptCore/inspector/scripts/tests/all/expected/definitions-with-mac-platform.json-result new file mode 100644 index 000000000..170d57c0a --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/all/expected/definitions-with-mac-platform.json-result @@ -0,0 +1,1203 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// Network. +InspectorBackend.registerNetworkDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "Network"); +InspectorBackend.registerEvent("Network.resourceLoaded", []); +InspectorBackend.registerCommand("Network.loadResource", [], []); +InspectorBackend.activateDomain("Network"); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include <inspector/InspectorFrontendRouter.h> +#include <JavaScriptCore/InspectorBackendDispatcher.h> + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr<BackendDispatcher>&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr<BackendDispatcher> m_backendDispatcher; +}; + + +class AlternateNetworkBackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~AlternateNetworkBackendDispatcher() { } + virtual void loadResource(long callId) = 0; +}; + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorBackendDispatcher.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +typedef String ErrorString; + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +class AlternateNetworkBackendDispatcher; +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +class NetworkBackendDispatcherHandler { +public: + virtual void loadResource(ErrorString&) = 0; +protected: + virtual ~NetworkBackendDispatcherHandler(); +}; + +class NetworkBackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref<NetworkBackendDispatcher> create(BackendDispatcher&, NetworkBackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) override; +private: + void loadResource(long requestId, RefPtr<InspectorObject>&& parameters); +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(AlternateNetworkBackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + AlternateNetworkBackendDispatcher* m_alternateDispatcher { nullptr }; +#endif +private: + NetworkBackendDispatcher(BackendDispatcher&, NetworkBackendDispatcherHandler*); + NetworkBackendDispatcherHandler* m_agent { nullptr }; +}; + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include <inspector/InspectorFrontendRouter.h> +#include <inspector/InspectorValues.h> +#include <wtf/NeverDestroyed.h> +#include <wtf/text/CString.h> + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + +NetworkBackendDispatcherHandler::~NetworkBackendDispatcherHandler() { } + +Ref<NetworkBackendDispatcher> NetworkBackendDispatcher::create(BackendDispatcher& backendDispatcher, NetworkBackendDispatcherHandler* agent) +{ + return adoptRef(*new NetworkBackendDispatcher(backendDispatcher, agent)); +} + +NetworkBackendDispatcher::NetworkBackendDispatcher(BackendDispatcher& backendDispatcher, NetworkBackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("Network"), this); +} + +void NetworkBackendDispatcher::dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) +{ + Ref<NetworkBackendDispatcher> protect(*this); + + RefPtr<InspectorObject> parameters; + message->getObject(ASCIILiteral("params"), parameters); + + if (method == "loadResource") + loadResource(requestId, WTFMove(parameters)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\'', "Network", '.', method, "' was not found")); +} + +void NetworkBackendDispatcher::loadResource(long requestId, RefPtr<InspectorObject>&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->loadResource(requestId); + return; + } +#endif + + ErrorString error; + Ref<InspectorObject> result = InspectorObject::create(); + m_agent->loadResource(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorValues.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +class FrontendRouter; + +class NetworkFrontendDispatcher { +public: + NetworkFrontendDispatcher(FrontendRouter& frontendRouter) : m_frontendRouter(frontendRouter) { } + void resourceLoaded(); +private: + FrontendRouter& m_frontendRouter; +}; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include <wtf/text/CString.h> + +namespace Inspector { + +void NetworkFrontendDispatcher::resourceLoaded() +{ + Ref<InspectorObject> jsonMessage = InspectorObject::create(); + jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("Network.resourceLoaded")); + + m_frontendRouter.sendEvent(jsonMessage->toJSONString()); +} + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include <inspector/InspectorProtocolTypes.h> +#include <wtf/Assertions.h> + +namespace Inspector { + + + +namespace Protocol { + +// Forward declarations. +namespace Network { +class NetworkError; +} // Network +// End of forward declarations. + + + + +namespace Network { +class NetworkError : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + MessageSet = 1 << 0, + CodeSet = 1 << 1, + AllFieldsSet = (MessageSet | CodeSet) + }; + + template<int STATE> + class Builder { + private: + RefPtr<InspectorObject> m_result; + + template<int STEP> Builder<STATE | STEP>& castState() + { + return *reinterpret_cast<Builder<STATE | STEP>*>(this); + } + + Builder(Ref</*NetworkError*/InspectorObject>&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class NetworkError; + public: + + Builder<STATE | MessageSet>& setMessage(const String& value) + { + COMPILE_ASSERT(!(STATE & MessageSet), property_message_already_set); + m_result->setString(ASCIILiteral("message"), value); + return castState<MessageSet>(); + } + + Builder<STATE | CodeSet>& setCode(int value) + { + COMPILE_ASSERT(!(STATE & CodeSet), property_code_already_set); + m_result->setInteger(ASCIILiteral("code"), value); + return castState<CodeSet>(); + } + + Ref<NetworkError> release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(NetworkError) == sizeof(InspectorObject), cannot_cast); + + Ref<InspectorObject> result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast<Ref<NetworkError>*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref<NetworkError> result = NetworkError::create() + * .setMessage(...) + * .setCode(...) + * .release(); + */ + static Builder<NoFieldsSet> create() + { + return Builder<NoFieldsSet>(InspectorObject::create()); + } +}; + +} // Network + + + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include <wtf/Optional.h> +#include <wtf/text/CString.h> + +namespace Inspector { + +namespace Protocol { + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#include <wtf/RetainPtr.h> + +@protocol TestProtocolNetworkDomainHandler; + +namespace Inspector { + + +class ObjCInspectorNetworkBackendDispatcher final : public AlternateNetworkBackendDispatcher { +public: + ObjCInspectorNetworkBackendDispatcher(id<TestProtocolNetworkDomainHandler> handler) { m_delegate = handler; } + virtual void loadResource(long requestId) override; +private: + RetainPtr<id<TestProtocolNetworkDomainHandler>> m_delegate; +}; + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include <JavaScriptCore/InspectorValues.h> + +namespace Inspector { + +void ObjCInspectorNetworkBackendDispatcher::loadResource(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate loadResourceWithErrorCallback:errorCallback successCallback:successCallback]; +} + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <WebInspector/TestProtocol.h> + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@property (nonatomic, retain, setter=setNetworkHandler:) id<TestProtocolNetworkDomainHandler> networkHandler; +@property (nonatomic, readonly) TestProtocolNetworkDomainEventDispatcher *networkEventDispatcher; +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import <JavaScriptCore/AlternateDispatchableAgent.h> +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#import <JavaScriptCore/InspectorBackendDispatchers.h> + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; + id<TestProtocolNetworkDomainHandler> _networkHandler; + TestProtocolNetworkDomainEventDispatcher *_networkEventDispatcher; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [_networkHandler release]; + [_networkEventDispatcher release]; + [super dealloc]; +} + +- (void)setNetworkHandler:(id<TestProtocolNetworkDomainHandler>)handler +{ + if (handler == _networkHandler) + return; + + [_networkHandler release]; + _networkHandler = [handler retain]; + + auto alternateDispatcher = std::make_unique<ObjCInspectorNetworkBackendDispatcher>(handler); + auto alternateAgent = std::make_unique<AlternateDispatchableAgent<NetworkBackendDispatcher, AlternateNetworkBackendDispatcher>>(ASCIILiteral("Network"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id<TestProtocolNetworkDomainHandler>)networkHandler +{ + return _networkHandler; +} + +- (TestProtocolNetworkDomainEventDispatcher *)networkEventDispatcher +{ + if (!_networkEventDispatcher) + _networkEventDispatcher = [[TestProtocolNetworkDomainEventDispatcher alloc] initWithController:_controller]; + return _networkEventDispatcher; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <JavaScriptCore/InspectorValues.h> + +using namespace Inspector; + +@implementation TestProtocolNetworkDomainEventDispatcher +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller; +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)resourceLoaded +{ + const FrontendRouter& router = _controller->frontendRouter(); + + Ref<InspectorObject> jsonMessage = InspectorObject::create(); + jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("Network.resourceLoaded")); + router.sendEvent(jsonMessage->toJSONString()); +} + +@end + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <Foundation/Foundation.h> + +#import <WebInspector/RWIProtocolJSONObject.h> + + +@class TestProtocolNetworkError; + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + + + +__attribute__((visibility ("default"))) +@interface TestProtocolNetworkError : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +- (instancetype)initWithMessage:(NSString *)message code:(int)code; +/* required */ @property (nonatomic, copy) NSString *message; +/* required */ @property (nonatomic, assign) int code; +@end + +@protocol TestProtocolNetworkDomainHandler <NSObject> +@required +- (void)loadResourceWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +@end + +__attribute__((visibility ("default"))) +@interface TestProtocolNetworkDomainEventDispatcher : NSObject +- (void)resourceLoaded; +@end + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorValues.h> + +@interface TestProtocolNetworkDomainEventDispatcher (Private) +- (instancetype)initWithController:(Inspector::AugmentableInspectorController*)controller; +@end + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import <WebInspector/RWIProtocolArrayConversions.h> + +namespace Inspector { + +template<typename ObjCEnumType> +std::optional<ObjCEnumType> fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> + +using namespace Inspector; + +@interface TestProtocolTypeConversions (NetworkDomain) + ++ (void)_parseNetworkError:(TestProtocolNetworkError **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (NetworkDomain) + ++ (void)_parseNetworkError:(TestProtocolNetworkError **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolNetworkError alloc] initWithPayload:payload]; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> +#import <JavaScriptCore/InspectorValues.h> +#import <wtf/Assertions.h> + +using namespace Inspector; + + +@implementation TestProtocolNetworkError + +- (instancetype)initWithPayload:(nonnull NSDictionary<NSString *, id> *)payload +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"message"], @"message"); + self.message = payload[@"message"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"code"], @"code"); + self.code = [payload[@"code"] integerValue]; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (instancetype)initWithMessage:(NSString *)message code:(int)code +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(message, @"message"); + + self.message = message; + self.code = code; + + return self; +} + +- (void)setMessage:(NSString *)message +{ + [super setString:message forKey:@"message"]; +} + +- (NSString *)message +{ + return [super stringForKey:@"message"]; +} + +- (void)setCode:(int)code +{ + [super setInteger:code forKey:@"code"]; +} + +- (int)code +{ + return [super integerForKey:@"code"]; +} + +@end + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/commands-with-async-attribute.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/commands-with-async-attribute.json new file mode 100644 index 000000000..11262e889 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/commands-with-async-attribute.json @@ -0,0 +1,109 @@ +{ + "domain": "Database", + "types": [ + { + "id": "DatabaseId", + "type": "integer", + "description": "Unique identifier of Database object." + }, + { + "id": "PrimaryColors", + "type": "string", + "enum": ["red", "green", "blue"] + }, + { + "id": "ColorList", + "type": "array", + "items": { "$ref": "PrimaryColors" } + }, + { + "id": "Error", + "type": "object", + "description": "Database error.", + "properties": [ + { "name": "message", "type": "string", "description": "Error message." }, + { "name": "code", "type": "integer", "description": "Error code." } + ] + } + ], + "commands": [ + { + "name": "executeSQLSyncOptionalReturnValues", + "parameters": [ + { "name": "databaseId", "$ref": "DatabaseId" }, + { "name": "query", "type": "string" } + ], + "returns": [ + { "name": "columnNames", "type": "array", "optional": true, "items": { "type": "string" } }, + { "name": "notes", "type": "string", "optional": true }, + { "name": "timestamp", "type": "number", "optional": true }, + { "name": "values", "type": "object", "optional": true }, + { "name": "payload", "type": "any", "optional": true }, + { "name": "databaseId", "$ref": "DatabaseId", "optional": true }, + { "name": "sqlError", "$ref": "Error", "optional": true }, + { "name": "screenColor", "$ref": "PrimaryColors", "optional": true }, + { "name": "alternateColors", "$ref": "ColorList", "optional": true }, + { "name": "printColor", "type": "string", "enum": ["cyan", "magenta", "yellow", "black"], "optional": true } + ] + }, + { + "name": "executeSQLAsyncOptionalReturnValues", + "async": true, + "parameters": [ + { "name": "databaseId", "$ref": "DatabaseId" }, + { "name": "query", "type": "string" } + ], + "returns": [ + { "name": "columnNames", "type": "array", "optional": true, "items": { "type": "string" } }, + { "name": "notes", "type": "string", "optional": true }, + { "name": "timestamp", "type": "number", "optional": true }, + { "name": "values", "type": "object", "optional": true }, + { "name": "payload", "type": "any", "optional": true }, + { "name": "databaseId", "$ref": "DatabaseId", "optional": true }, + { "name": "sqlError", "$ref": "Error", "optional": true }, + { "name": "screenColor", "$ref": "PrimaryColors", "optional": true }, + { "name": "alternateColors", "$ref": "ColorList", "optional": true }, + { "name": "printColor", "type": "string", "enum": ["cyan", "magenta", "yellow", "black"], "optional": true } + ] + }, + { + "name": "executeSQLSync", + "parameters": [ + { "name": "databaseId", "$ref": "DatabaseId" }, + { "name": "query", "type": "string" } + ], + "returns": [ + { "name": "columnNames", "type": "array", "items": { "type": "string" } }, + { "name": "notes", "type": "string" }, + { "name": "timestamp", "type": "number" }, + { "name": "values", "type": "object" }, + { "name": "payload", "type": "any" }, + { "name": "databaseId", "$ref": "DatabaseId" }, + { "name": "sqlError", "$ref": "Error" }, + { "name": "alternateColors", "$ref": "ColorList" }, + { "name": "screenColor", "$ref": "PrimaryColors" }, + { "name": "printColor", "type": "string", "enum": ["cyan", "magenta", "yellow", "black"] } + ] + }, + { + "name": "executeSQLAsync", + "async": true, + "parameters": [ + { "name": "databaseId", "$ref": "DatabaseId" }, + { "name": "query", "type": "string" } + ], + "returns": [ + { "name": "columnNames", "type": "array", "items": { "type": "string" } }, + { "name": "notes", "type": "string" }, + { "name": "timestamp", "type": "number" }, + { "name": "values", "type": "object" }, + { "name": "payload", "type": "any" }, + { "name": "databaseId", "$ref": "DatabaseId" }, + { "name": "sqlError", "$ref": "Error" }, + { "name": "screenColor", "$ref": "PrimaryColors" }, + { "name": "alternateColors", "$ref": "ColorList" }, + { "name": "printColor", "type": "string", "enum": ["cyan", "magenta", "yellow", "black"] } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/commands-with-optional-call-return-parameters.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/commands-with-optional-call-return-parameters.json new file mode 100644 index 000000000..361d57d82 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/commands-with-optional-call-return-parameters.json @@ -0,0 +1,85 @@ +{ + "domain": "Database", + "types": [ + { + "id": "DatabaseId", + "type": "integer", + "description": "Unique identifier of Database object." + }, + { + "id": "PrimaryColors", + "type": "string", + "enum": ["red", "green", "blue"] + }, + { + "id": "ColorList", + "type": "array", + "items": { "$ref": "PrimaryColors" } + }, + { + "id": "Error", + "type": "object", + "description": "Database error.", + "properties": [ + { "name": "message", "type": "string", "description": "Error message." }, + { "name": "code", "type": "integer", "description": "Error code." } + ] + } + ], + "commands": [ + { + "name": "executeAllOptionalParameters", + "parameters": [ + { "name": "columnNames", "type": "array", "optional": true, "items": { "type": "string" } }, + { "name": "notes", "type": "string", "optional": true }, + { "name": "timestamp", "type": "number", "optional": true }, + { "name": "values", "type": "object", "optional": true }, + { "name": "payload", "type": "any", "optional": true }, + { "name": "databaseId", "$ref": "DatabaseId", "optional": true }, + { "name": "sqlError", "$ref": "Error", "optional": true }, + { "name": "screenColor", "$ref": "PrimaryColors", "optional": true }, + { "name": "alternateColors", "$ref": "ColorList", "optional": true }, + { "name": "printColor", "type": "string", "enum": ["cyan", "magenta", "yellow", "black"], "optional": true } + ], + "returns": [ + { "name": "columnNames", "type": "array", "optional": true, "items": { "type": "string" } }, + { "name": "notes", "type": "string", "optional": true }, + { "name": "timestamp", "type": "number", "optional": true }, + { "name": "values", "type": "object", "optional": true }, + { "name": "payload", "type": "any", "optional": true }, + { "name": "databaseId", "$ref": "DatabaseId", "optional": true }, + { "name": "sqlError", "$ref": "Error", "optional": true }, + { "name": "screenColor", "$ref": "PrimaryColors", "optional": true }, + { "name": "alternateColors", "$ref": "ColorList", "optional": true }, + { "name": "printColor", "type": "string", "enum": ["cyan", "magenta", "yellow", "black"], "optional": true } + ] + }, + { + "name": "executeNoOptionalParameters", + "parameters": [ + { "name": "columnNames", "type": "array", "items": { "type": "string" } }, + { "name": "notes", "type": "string" }, + { "name": "timestamp", "type": "number" }, + { "name": "values", "type": "object" }, + { "name": "payload", "type": "any" }, + { "name": "databaseId", "$ref": "DatabaseId" }, + { "name": "sqlError", "$ref": "Error" }, + { "name": "screenColor", "$ref": "PrimaryColors" }, + { "name": "alternateColors", "$ref": "ColorList" }, + { "name": "printColor", "type": "string", "enum": ["cyan", "magenta", "yellow", "black"] } + ], + "returns": [ + { "name": "columnNames", "type": "array", "items": { "type": "string" } }, + { "name": "notes", "type": "string" }, + { "name": "timestamp", "type": "number" }, + { "name": "values", "type": "object" }, + { "name": "payload", "type": "any" }, + { "name": "databaseId", "$ref": "DatabaseId" }, + { "name": "sqlError", "$ref": "Error" }, + { "name": "screenColor", "$ref": "PrimaryColors" }, + { "name": "alternateColors", "$ref": "ColorList" }, + { "name": "printColor", "type": "string", "enum": ["cyan", "magenta", "yellow", "black"] } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/definitions-with-mac-platform.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/definitions-with-mac-platform.json new file mode 100644 index 000000000..817f135ee --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/definitions-with-mac-platform.json @@ -0,0 +1,28 @@ +{ + "domain": "Network", + "types": [ + { + "id": "NetworkError", + "type": "object", + "platform": "macos", + "properties": [ + { "name": "message", "type": "string", "description": "Error message." }, + { "name": "code", "type": "integer", "description": "Error code." } + ] + } + ], + "commands": [ + { + "name": "loadResource", + "platform": "macos", + "description": "Loads a resource in the context of a frame on the inspected page without cross origin checks." + } + ], + "events": [ + { + "name": "resourceLoaded", + "platform": "macos", + "description": "A resource was loaded." + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/domain-availability.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/domain-availability.json new file mode 100644 index 000000000..5939996e3 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/domain-availability.json @@ -0,0 +1,11 @@ +[ +{ + "domain": "DomainA", + "availability": "web", + "commands": [{"name": "enable"}] +}, +{ + "domain": "DomainB", + "commands": [{"name": "enable"}] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/domains-with-varying-command-sizes.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/domains-with-varying-command-sizes.json new file mode 100644 index 000000000..94a8ecb17 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/domains-with-varying-command-sizes.json @@ -0,0 +1,54 @@ +[ +{ + "domain": "Network1", + "commands": [ + { + "name": "loadResource1", + "description": "Loads a resource in the context of a frame on the inspected page without cross origin checks." + } + ] +}, +{ + "domain": "Network2", + "types": [ + { + "id": "LoaderId", + "type": "string", + "description": "Unique loader identifier." + } + ] +}, +{ + "domain": "Network3", + "commands": [ + { + "name": "loadResource1", + "description": "Loads a resource in the context of a frame on the inspected page without cross origin checks." + }, + { + "name": "loadResource2", + "description": "Loads a resource in the context of a frame on the inspected page without cross origin checks." + }, + { + "name": "loadResource3", + "description": "Loads a resource in the context of a frame on the inspected page without cross origin checks." + }, + { + "name": "loadResource4", + "description": "Loads a resource in the context of a frame on the inspected page without cross origin checks." + }, + { + "name": "loadResource5", + "description": "Loads a resource in the context of a frame on the inspected page without cross origin checks." + }, + { + "name": "loadResource6", + "description": "Loads a resource in the context of a frame on the inspected page without cross origin checks." + }, + { + "name": "loadResource7", + "description": "Loads a resource in the context of a frame on the inspected page without cross origin checks." + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/enum-values.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/enum-values.json new file mode 100644 index 000000000..cdad61df7 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/enum-values.json @@ -0,0 +1,35 @@ +{"domains":[ +{ + "domain": "TypeDomain", + "types": [ + { + "id": "TypeDomainEnum", + "type": "string", + "enum": ["shared", "red", "green", "blue"] + } + ] +}, +{ + "domain": "CommandDomain", + "commands": [ + { + "name": "commandWithEnumReturnValue", + "parameters": [], + "returns": [ + { "name": "returnValue", "type": "string", "enum": ["shared", "cyan", "magenta", "yellow"] } + ] + } + ] +}, +{ + "domain": "EventDomain", + "events": [ + { + "name": "eventWithEnumParameter", + "parameters": [ + { "name": "parameter", "type": "string", "enum": ["shared", "black", "white"] } + ] + } + ] +} +]} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/events-with-optional-parameters.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/events-with-optional-parameters.json new file mode 100644 index 000000000..cabbf10b8 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/events-with-optional-parameters.json @@ -0,0 +1,59 @@ +{ + "domain": "Database", + "types": [ + { + "id": "DatabaseId", + "type": "string", + "description": "Unique identifier of Database object." + }, + { + "id": "PrimaryColors", + "type": "string", + "values": ["red", "green", "blue"] + }, + { + "id": "ColorList", + "type": "array", + "items": { "$ref": "PrimaryColors" } + }, + { + "id": "Error", + "type": "object", + "description": "Database error.", + "properties": [ + { "name": "message", "type": "string", "description": "Error message." }, + { "name": "code", "type": "integer", "description": "Error code." } + ] + } + ], + "events": [ + { + "name": "didExecuteOptionalParameters", + "parameters": [ + { "name": "columnNames", "type": "array", "optional": true, "items": { "type": "string" } }, + { "name": "notes", "type": "string", "optional": true }, + { "name": "timestamp", "type": "number", "optional": true }, + { "name": "values", "type": "object", "optional": true }, + { "name": "payload", "type": "any", "optional": true }, + { "name": "sqlError", "$ref": "Error", "optional": true }, + { "name": "screenColor", "$ref": "PrimaryColors", "optional": true }, + { "name": "alternateColors", "$ref": "ColorList", "optional": true }, + { "name": "printColor", "type": "string", "values": ["cyan", "magenta", "yellow", "black"], "optional": true } + ] + }, + { + "name": "didExecuteNoOptionalParameters", + "parameters": [ + { "name": "columnNames", "type": "array", "items": { "type": "string" } }, + { "name": "notes", "type": "string" }, + { "name": "timestamp", "type": "number" }, + { "name": "values", "type": "object" }, + { "name": "payload", "type": "any" }, + { "name": "sqlError", "$ref": "Error" }, + { "name": "screenColor", "$ref": "PrimaryColors" }, + { "name": "alternateColors", "$ref": "ColorList" }, + { "name": "printColor", "type": "string", "values": ["cyan", "magenta", "yellow", "black"] } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result new file mode 100644 index 000000000..ef9a2488d --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result @@ -0,0 +1,1780 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// Database. +InspectorBackend.registerDatabaseDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "Database"); +InspectorBackend.registerEnum("Database.PrimaryColors", {Red: "red", Green: "green", Blue: "blue"}); +InspectorBackend.registerCommand("Database.executeSQLSyncOptionalReturnValues", [{"name": "databaseId", "type": "number", "optional": false}, {"name": "query", "type": "string", "optional": false}], ["columnNames", "notes", "timestamp", "values", "payload", "databaseId", "sqlError", "screenColor", "alternateColors", "printColor"]); +InspectorBackend.registerCommand("Database.executeSQLAsyncOptionalReturnValues", [{"name": "databaseId", "type": "number", "optional": false}, {"name": "query", "type": "string", "optional": false}], ["columnNames", "notes", "timestamp", "values", "payload", "databaseId", "sqlError", "screenColor", "alternateColors", "printColor"]); +InspectorBackend.registerCommand("Database.executeSQLSync", [{"name": "databaseId", "type": "number", "optional": false}, {"name": "query", "type": "string", "optional": false}], ["columnNames", "notes", "timestamp", "values", "payload", "databaseId", "sqlError", "alternateColors", "screenColor", "printColor"]); +InspectorBackend.registerCommand("Database.executeSQLAsync", [{"name": "databaseId", "type": "number", "optional": false}, {"name": "query", "type": "string", "optional": false}], ["columnNames", "notes", "timestamp", "values", "payload", "databaseId", "sqlError", "screenColor", "alternateColors", "printColor"]); +InspectorBackend.activateDomain("Database"); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include <inspector/InspectorFrontendRouter.h> +#include <JavaScriptCore/InspectorBackendDispatcher.h> + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr<BackendDispatcher>&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr<BackendDispatcher> m_backendDispatcher; +}; + + +class AlternateDatabaseBackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~AlternateDatabaseBackendDispatcher() { } + virtual void executeSQLSyncOptionalReturnValues(long callId, int in_databaseId, const String& in_query) = 0; + virtual void executeSQLAsyncOptionalReturnValues(long callId, int in_databaseId, const String& in_query) = 0; + virtual void executeSQLSync(long callId, int in_databaseId, const String& in_query) = 0; + virtual void executeSQLAsync(long callId, int in_databaseId, const String& in_query) = 0; +}; + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorBackendDispatcher.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +typedef String ErrorString; + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +class AlternateDatabaseBackendDispatcher; +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +class DatabaseBackendDispatcherHandler { +public: + // Named after parameter 'printColor' while generating command/event executeSQLSyncOptionalReturnValues. + enum class PrintColor { + Cyan = 3, + Magenta = 4, + Yellow = 5, + Black = 6, + }; // enum class PrintColor + virtual void executeSQLSyncOptionalReturnValues(ErrorString&, int in_databaseId, const String& in_query, RefPtr<Inspector::Protocol::Array<String>>& opt_out_columnNames, Inspector::Protocol::OptOutput<String>* opt_out_notes, Inspector::Protocol::OptOutput<double>* opt_out_timestamp, Inspector::Protocol::OptOutput<Inspector::InspectorObject>* opt_out_values, Inspector::Protocol::OptOutput<Inspector::InspectorValue>* opt_out_payload, Inspector::Protocol::OptOutput<int>* opt_out_databaseId, RefPtr<Inspector::Protocol::Database::Error>& opt_out_sqlError, Inspector::Protocol::Database::PrimaryColors* opt_out_screenColor, RefPtr<Inspector::Protocol::Database::ColorList>& opt_out_alternateColors, DatabaseBackendDispatcherHandler::PrintColor* opt_out_printColor) = 0; + class ExecuteSQLAsyncOptionalReturnValuesCallback : public BackendDispatcher::CallbackBase { + public: + ExecuteSQLAsyncOptionalReturnValuesCallback(Ref<BackendDispatcher>&&, int id); + void sendSuccess(RefPtr<Inspector::Protocol::Array<String>>&& columnNames, Inspector::Protocol::OptOutput<String>* notes, Inspector::Protocol::OptOutput<double>* timestamp, Inspector::Protocol::OptOutput<Inspector::InspectorObject>* values, Inspector::Protocol::OptOutput<Inspector::InspectorValue>* payload, Inspector::Protocol::OptOutput<int>* databaseId, RefPtr<Inspector::Protocol::Database::Error>&& sqlError, Inspector::Protocol::OptOutput<String>* screenColor, RefPtr<Inspector::Protocol::Database::ColorList>&& alternateColors, Inspector::Protocol::OptOutput<String>* printColor); + }; + virtual void executeSQLAsyncOptionalReturnValues(ErrorString&, int in_databaseId, const String& in_query, Ref<ExecuteSQLAsyncOptionalReturnValuesCallback>&& callback) = 0; + virtual void executeSQLSync(ErrorString&, int in_databaseId, const String& in_query, RefPtr<Inspector::Protocol::Array<String>>& out_columnNames, String* out_notes, double* out_timestamp, Inspector::InspectorObject* out_values, Inspector::InspectorValue* out_payload, int* out_databaseId, RefPtr<Inspector::Protocol::Database::Error>& out_sqlError, RefPtr<Inspector::Protocol::Database::ColorList>& out_alternateColors, Inspector::Protocol::Database::PrimaryColors* out_screenColor, DatabaseBackendDispatcherHandler::PrintColor* out_printColor) = 0; + class ExecuteSQLAsyncCallback : public BackendDispatcher::CallbackBase { + public: + ExecuteSQLAsyncCallback(Ref<BackendDispatcher>&&, int id); + void sendSuccess(RefPtr<Inspector::Protocol::Array<String>>&& columnNames, const String& notes, double timestamp, Inspector::InspectorObject values, Inspector::InspectorValue payload, int databaseId, RefPtr<Inspector::Protocol::Database::Error>&& sqlError, const String& screenColor, RefPtr<Inspector::Protocol::Database::ColorList>&& alternateColors, const String& printColor); + }; + virtual void executeSQLAsync(ErrorString&, int in_databaseId, const String& in_query, Ref<ExecuteSQLAsyncCallback>&& callback) = 0; +protected: + virtual ~DatabaseBackendDispatcherHandler(); +}; + +class DatabaseBackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref<DatabaseBackendDispatcher> create(BackendDispatcher&, DatabaseBackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) override; +private: + void executeSQLSyncOptionalReturnValues(long requestId, RefPtr<InspectorObject>&& parameters); + void executeSQLAsyncOptionalReturnValues(long requestId, RefPtr<InspectorObject>&& parameters); + void executeSQLSync(long requestId, RefPtr<InspectorObject>&& parameters); + void executeSQLAsync(long requestId, RefPtr<InspectorObject>&& parameters); +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(AlternateDatabaseBackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + AlternateDatabaseBackendDispatcher* m_alternateDispatcher { nullptr }; +#endif +private: + DatabaseBackendDispatcher(BackendDispatcher&, DatabaseBackendDispatcherHandler*); + DatabaseBackendDispatcherHandler* m_agent { nullptr }; +}; + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include <inspector/InspectorFrontendRouter.h> +#include <inspector/InspectorValues.h> +#include <wtf/NeverDestroyed.h> +#include <wtf/text/CString.h> + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + +DatabaseBackendDispatcherHandler::~DatabaseBackendDispatcherHandler() { } + +Ref<DatabaseBackendDispatcher> DatabaseBackendDispatcher::create(BackendDispatcher& backendDispatcher, DatabaseBackendDispatcherHandler* agent) +{ + return adoptRef(*new DatabaseBackendDispatcher(backendDispatcher, agent)); +} + +DatabaseBackendDispatcher::DatabaseBackendDispatcher(BackendDispatcher& backendDispatcher, DatabaseBackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("Database"), this); +} + +void DatabaseBackendDispatcher::dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) +{ + Ref<DatabaseBackendDispatcher> protect(*this); + + RefPtr<InspectorObject> parameters; + message->getObject(ASCIILiteral("params"), parameters); + + if (method == "executeSQLSyncOptionalReturnValues") + executeSQLSyncOptionalReturnValues(requestId, WTFMove(parameters)); + else if (method == "executeSQLAsyncOptionalReturnValues") + executeSQLAsyncOptionalReturnValues(requestId, WTFMove(parameters)); + else if (method == "executeSQLSync") + executeSQLSync(requestId, WTFMove(parameters)); + else if (method == "executeSQLAsync") + executeSQLAsync(requestId, WTFMove(parameters)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\'', "Database", '.', method, "' was not found")); +} + +void DatabaseBackendDispatcher::executeSQLSyncOptionalReturnValues(long requestId, RefPtr<InspectorObject>&& parameters) +{ + int in_databaseId = m_backendDispatcher->getInteger(parameters.get(), ASCIILiteral("databaseId"), nullptr); + String in_query = m_backendDispatcher->getString(parameters.get(), ASCIILiteral("query"), nullptr); + if (m_backendDispatcher->hasProtocolErrors()) { + m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Some arguments of method '%s' can't be processed", "Database.executeSQLSyncOptionalReturnValues")); + return; + } + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->executeSQLSyncOptionalReturnValues(requestId, in_databaseId, in_query); + return; + } +#endif + + ErrorString error; + Ref<InspectorObject> result = InspectorObject::create(); + RefPtr<Inspector::Protocol::Array<String>> out_columnNames; + Inspector::Protocol::OptOutput<String> out_notes; + Inspector::Protocol::OptOutput<double> out_timestamp; + Inspector::Protocol::OptOutput<Inspector::InspectorObject> out_values; + Inspector::Protocol::OptOutput<Inspector::InspectorValue> out_payload; + Inspector::Protocol::OptOutput<Inspector::Protocol::Database::DatabaseId> out_databaseId; + RefPtr<Inspector::Protocol::Database::Error> out_sqlError; + Inspector::Protocol::Database::PrimaryColors out_screenColor; + RefPtr<Inspector::Protocol::Database::ColorList> out_alternateColors; + DatabaseBackendDispatcherHandler::PrintColor out_printColor; + m_agent->executeSQLSyncOptionalReturnValues(error, in_databaseId, in_query, out_columnNames, &out_notes, &out_timestamp, out_values, &out_payload, &out_databaseId, out_sqlError, &out_screenColor, out_alternateColors, &out_printColor); + + if (!error.length()) { + if (out_columnNames) + result->setArray(ASCIILiteral("columnNames"), out_columnNames); + if (out_notes.isAssigned()) + result->setString(ASCIILiteral("notes"), out_notes.getValue()); + if (out_timestamp.isAssigned()) + result->setDouble(ASCIILiteral("timestamp"), out_timestamp.getValue()); + if (out_values.isAssigned()) + result->setObject(ASCIILiteral("values"), out_values.getValue()); + if (out_payload.isAssigned()) + result->setValue(ASCIILiteral("payload"), out_payload.getValue()); + if (out_databaseId.isAssigned()) + result->setInteger(ASCIILiteral("databaseId"), out_databaseId.getValue()); + if (out_sqlError) + result->setObject(ASCIILiteral("sqlError"), out_sqlError); + if (out_screenColor.isAssigned()) + result->setString(ASCIILiteral("screenColor"), out_screenColor.getValue()); + if (out_alternateColors) + result->setArray(ASCIILiteral("alternateColors"), out_alternateColors); + if (out_printColor.isAssigned()) + result->setString(ASCIILiteral("printColor"), out_printColor.getValue()); + } + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +DatabaseBackendDispatcherHandler::ExecuteSQLAsyncOptionalReturnValuesCallback::ExecuteSQLAsyncOptionalReturnValuesCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } + +void DatabaseBackendDispatcherHandler::ExecuteSQLAsyncOptionalReturnValuesCallback::sendSuccess(RefPtr<Inspector::Protocol::Array<String>>&& columnNames, Inspector::Protocol::OptOutput<String>* notes, Inspector::Protocol::OptOutput<double>* timestamp, Inspector::Protocol::OptOutput<Inspector::InspectorObject>* values, Inspector::Protocol::OptOutput<Inspector::InspectorValue>* payload, Inspector::Protocol::OptOutput<int>* databaseId, RefPtr<Inspector::Protocol::Database::Error>&& sqlError, Inspector::Protocol::OptOutput<String>* screenColor, RefPtr<Inspector::Protocol::Database::ColorList>&& alternateColors, Inspector::Protocol::OptOutput<String>* printColor) +{ + Ref<InspectorObject> jsonMessage = InspectorObject::create(); + if (columnNames) + jsonMessage->setArray(ASCIILiteral("columnNames"), columnNames); + if (notes.isAssigned()) + jsonMessage->setString(ASCIILiteral("notes"), notes.getValue()); + if (timestamp.isAssigned()) + jsonMessage->setDouble(ASCIILiteral("timestamp"), timestamp.getValue()); + if (values.isAssigned()) + jsonMessage->setObject(ASCIILiteral("values"), values.getValue()); + if (payload.isAssigned()) + jsonMessage->setValue(ASCIILiteral("payload"), payload.getValue()); + if (databaseId.isAssigned()) + jsonMessage->setInteger(ASCIILiteral("databaseId"), databaseId.getValue()); + if (sqlError) + jsonMessage->setObject(ASCIILiteral("sqlError"), sqlError); + if (screenColor.isAssigned()) + jsonMessage->setString(ASCIILiteral("screenColor"), screenColor.getValue()); + if (alternateColors) + jsonMessage->setArray(ASCIILiteral("alternateColors"), alternateColors); + if (printColor.isAssigned()) + jsonMessage->setString(ASCIILiteral("printColor"), printColor.getValue()); + CallbackBase::sendSuccess(WTFMove(jsonMessage)); +} + +void DatabaseBackendDispatcher::executeSQLAsyncOptionalReturnValues(long requestId, RefPtr<InspectorObject>&& parameters) +{ + int in_databaseId = m_backendDispatcher->getInteger(parameters.get(), ASCIILiteral("databaseId"), nullptr); + String in_query = m_backendDispatcher->getString(parameters.get(), ASCIILiteral("query"), nullptr); + if (m_backendDispatcher->hasProtocolErrors()) { + m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Some arguments of method '%s' can't be processed", "Database.executeSQLAsyncOptionalReturnValues")); + return; + } + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->executeSQLAsyncOptionalReturnValues(requestId, in_databaseId, in_query); + return; + } +#endif + + ErrorString error; + Ref<InspectorObject> result = InspectorObject::create(); + Ref<DatabaseBackendDispatcherHandler::ExecuteSQLAsyncOptionalReturnValuesCallback> callback = adoptRef(*new DatabaseBackendDispatcherHandler::ExecuteSQLAsyncOptionalReturnValuesCallback(m_backendDispatcher.copyRef(), requestId)); + m_agent->executeSQLAsyncOptionalReturnValues(error, in_databaseId, in_query, callback.copyRef()); + + if (error.length()) { + callback->disable(); + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, error); + return; + } +} + +void DatabaseBackendDispatcher::executeSQLSync(long requestId, RefPtr<InspectorObject>&& parameters) +{ + int in_databaseId = m_backendDispatcher->getInteger(parameters.get(), ASCIILiteral("databaseId"), nullptr); + String in_query = m_backendDispatcher->getString(parameters.get(), ASCIILiteral("query"), nullptr); + if (m_backendDispatcher->hasProtocolErrors()) { + m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Some arguments of method '%s' can't be processed", "Database.executeSQLSync")); + return; + } + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->executeSQLSync(requestId, in_databaseId, in_query); + return; + } +#endif + + ErrorString error; + Ref<InspectorObject> result = InspectorObject::create(); + RefPtr<Inspector::Protocol::Array<String>> out_columnNames; + String out_notes; + double out_timestamp; + Inspector::InspectorObject out_values; + Inspector::InspectorValue out_payload; + Inspector::Protocol::Database::DatabaseId out_databaseId; + RefPtr<Inspector::Protocol::Database::Error> out_sqlError; + RefPtr<Inspector::Protocol::Database::ColorList> out_alternateColors; + Inspector::Protocol::Database::PrimaryColors out_screenColor; + DatabaseBackendDispatcherHandler::PrintColor out_printColor; + m_agent->executeSQLSync(error, in_databaseId, in_query, out_columnNames, &out_notes, &out_timestamp, out_values, &out_payload, &out_databaseId, out_sqlError, out_alternateColors, &out_screenColor, &out_printColor); + + if (!error.length()) { + result->setArray(ASCIILiteral("columnNames"), out_columnNames); + result->setString(ASCIILiteral("notes"), out_notes); + result->setDouble(ASCIILiteral("timestamp"), out_timestamp); + result->setObject(ASCIILiteral("values"), out_values); + result->setValue(ASCIILiteral("payload"), out_payload); + result->setInteger(ASCIILiteral("databaseId"), out_databaseId); + result->setObject(ASCIILiteral("sqlError"), out_sqlError); + result->setArray(ASCIILiteral("alternateColors"), out_alternateColors); + result->setString(ASCIILiteral("screenColor"), Inspector::Protocol::TestHelpers::getEnumConstantValue(out_screenColor)); + result->setString(ASCIILiteral("printColor"), Inspector::Protocol::TestHelpers::getEnumConstantValue(out_printColor)); + } + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +DatabaseBackendDispatcherHandler::ExecuteSQLAsyncCallback::ExecuteSQLAsyncCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } + +void DatabaseBackendDispatcherHandler::ExecuteSQLAsyncCallback::sendSuccess(RefPtr<Inspector::Protocol::Array<String>>&& columnNames, const String& notes, double timestamp, Inspector::InspectorObject values, Inspector::InspectorValue payload, int databaseId, RefPtr<Inspector::Protocol::Database::Error>&& sqlError, const String& screenColor, RefPtr<Inspector::Protocol::Database::ColorList>&& alternateColors, const String& printColor) +{ + Ref<InspectorObject> jsonMessage = InspectorObject::create(); + jsonMessage->setArray(ASCIILiteral("columnNames"), columnNames); + jsonMessage->setString(ASCIILiteral("notes"), notes); + jsonMessage->setDouble(ASCIILiteral("timestamp"), timestamp); + jsonMessage->setObject(ASCIILiteral("values"), values); + jsonMessage->setValue(ASCIILiteral("payload"), payload); + jsonMessage->setInteger(ASCIILiteral("databaseId"), databaseId); + jsonMessage->setObject(ASCIILiteral("sqlError"), sqlError); + jsonMessage->setString(ASCIILiteral("screenColor"), Inspector::Protocol::TestHelpers::getEnumConstantValue(screenColor)); + jsonMessage->setArray(ASCIILiteral("alternateColors"), alternateColors); + jsonMessage->setString(ASCIILiteral("printColor"), Inspector::Protocol::TestHelpers::getEnumConstantValue(printColor)); + CallbackBase::sendSuccess(WTFMove(jsonMessage)); +} + +void DatabaseBackendDispatcher::executeSQLAsync(long requestId, RefPtr<InspectorObject>&& parameters) +{ + int in_databaseId = m_backendDispatcher->getInteger(parameters.get(), ASCIILiteral("databaseId"), nullptr); + String in_query = m_backendDispatcher->getString(parameters.get(), ASCIILiteral("query"), nullptr); + if (m_backendDispatcher->hasProtocolErrors()) { + m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Some arguments of method '%s' can't be processed", "Database.executeSQLAsync")); + return; + } + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->executeSQLAsync(requestId, in_databaseId, in_query); + return; + } +#endif + + ErrorString error; + Ref<InspectorObject> result = InspectorObject::create(); + Ref<DatabaseBackendDispatcherHandler::ExecuteSQLAsyncCallback> callback = adoptRef(*new DatabaseBackendDispatcherHandler::ExecuteSQLAsyncCallback(m_backendDispatcher.copyRef(), requestId)); + m_agent->executeSQLAsync(error, in_databaseId, in_query, callback.copyRef()); + + if (error.length()) { + callback->disable(); + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, error); + return; + } +} + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorValues.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include <wtf/text/CString.h> + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include <inspector/InspectorProtocolTypes.h> +#include <wtf/Assertions.h> + +namespace Inspector { + + + +namespace Protocol { + +// Forward declarations. +namespace Database { +class Error; +enum class PrimaryColors; +} // Database +// End of forward declarations. + + +// Typedefs. +namespace Database { +/* Unique identifier of Database object. */ +typedef int DatabaseId; +typedef Inspector::Protocol::Array<Inspector::Protocol::Database::PrimaryColors> ColorList; +} // Database +// End of typedefs. + +namespace TestHelpers { + +String getEnumConstantValue(int code); + +template<typename T> String getEnumConstantValue(T enumValue) +{ + return getEnumConstantValue(static_cast<int>(enumValue)); +} + +} // namespace TestHelpers + +namespace Database { +/* */ +enum class PrimaryColors { + Red = 0, + Green = 1, + Blue = 2, +}; // enum class PrimaryColors +/* Database error. */ +class Error : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + MessageSet = 1 << 0, + CodeSet = 1 << 1, + AllFieldsSet = (MessageSet | CodeSet) + }; + + template<int STATE> + class Builder { + private: + RefPtr<InspectorObject> m_result; + + template<int STEP> Builder<STATE | STEP>& castState() + { + return *reinterpret_cast<Builder<STATE | STEP>*>(this); + } + + Builder(Ref</*Error*/InspectorObject>&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class Error; + public: + + Builder<STATE | MessageSet>& setMessage(const String& value) + { + COMPILE_ASSERT(!(STATE & MessageSet), property_message_already_set); + m_result->setString(ASCIILiteral("message"), value); + return castState<MessageSet>(); + } + + Builder<STATE | CodeSet>& setCode(int value) + { + COMPILE_ASSERT(!(STATE & CodeSet), property_code_already_set); + m_result->setInteger(ASCIILiteral("code"), value); + return castState<CodeSet>(); + } + + Ref<Error> release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(Error) == sizeof(InspectorObject), cannot_cast); + + Ref<InspectorObject> result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast<Ref<Error>*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref<Error> result = Error::create() + * .setMessage(...) + * .setCode(...) + * .release(); + */ + static Builder<NoFieldsSet> create() + { + return Builder<NoFieldsSet>(InspectorObject::create()); + } +}; + +} // Database + + + +namespace TestHelpers { + +template<typename ProtocolEnumType> +std::optional<ProtocolEnumType> parseEnumValueFromString(const String&); + +// Enums in the 'Database' Domain +template<> +std::optional<Inspector::Protocol::Database::PrimaryColors> parseEnumValueFromString<Inspector::Protocol::Database::PrimaryColors>(const String&); + +} // namespace TestHelpers + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include <wtf/Optional.h> +#include <wtf/text/CString.h> + +namespace Inspector { + +namespace Protocol { + +namespace TestHelpers { + +static const char* const enum_constant_values[] = { + "red", + "green", + "blue", + "cyan", + "magenta", + "yellow", + "black", +}; + +String getEnumConstantValue(int code) { + return enum_constant_values[code]; +} + +// Enums in the 'Database' Domain +template<> +std::optional<Inspector::Protocol::Database::PrimaryColors> parseEnumValueFromString<Inspector::Protocol::Database::PrimaryColors>(const String& protocolString) +{ + static const size_t constantValues[] = { + (size_t)Inspector::Protocol::Database::PrimaryColors::Red, + (size_t)Inspector::Protocol::Database::PrimaryColors::Green, + (size_t)Inspector::Protocol::Database::PrimaryColors::Blue, + }; + for (size_t i = 0; i < 3; ++i) + if (protocolString == enum_constant_values[constantValues[i]]) + return (Inspector::Protocol::Database::PrimaryColors)constantValues[i]; + + return std::nullopt; +} + + +} // namespace TestHelpers + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#include <wtf/RetainPtr.h> + +@protocol TestProtocolDatabaseDomainHandler; + +namespace Inspector { + + +class ObjCInspectorDatabaseBackendDispatcher final : public AlternateDatabaseBackendDispatcher { +public: + ObjCInspectorDatabaseBackendDispatcher(id<TestProtocolDatabaseDomainHandler> handler) { m_delegate = handler; } + virtual void executeSQLSyncOptionalReturnValues(long requestId, int in_databaseId, const String& in_query) override; + virtual void executeSQLAsyncOptionalReturnValues(long requestId, int in_databaseId, const String& in_query) override; + virtual void executeSQLSync(long requestId, int in_databaseId, const String& in_query) override; + virtual void executeSQLAsync(long requestId, int in_databaseId, const String& in_query) override; +private: + RetainPtr<id<TestProtocolDatabaseDomainHandler>> m_delegate; +}; + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include <JavaScriptCore/InspectorValues.h> + +namespace Inspector { + +void ObjCInspectorDatabaseBackendDispatcher::executeSQLSyncOptionalReturnValues(long requestId, int in_databaseId, const String& in_query) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^(NSArray/*<NSString>*/ **columnNames, NSString **notes, double *timestamp, RWIProtocolJSONObject **values, RWIProtocolJSONObject **payload, int *databaseId, TestProtocolDatabaseError **sqlError, TestProtocolDatabasePrimaryColors *screenColor, NSArray/*<NSString>*/ **alternateColors, TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColor *printColor) { + Ref<InspectorObject> resultObject = InspectorObject::create(); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(columnNames, @"columnNames"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(notes, @"notes"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(values, @"values"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(payload, @"payload"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(sqlError, @"sqlError"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(alternateColors, @"alternateColors"); + if (columnNames) + resultObject->setArray(ASCIILiteral("columnNames"), inspectorStringArray(*columnNames)); + if (notes) + resultObject->setString(ASCIILiteral("notes"), *notes); + if (timestamp) + resultObject->setDouble(ASCIILiteral("timestamp"), *timestamp); + if (values) + resultObject->setObject(ASCIILiteral("values"), [*values toInspectorObject]); + if (payload) + resultObject->setValue(ASCIILiteral("payload"), [*payload toInspectorObject]); + if (databaseId) + resultObject->setInteger(ASCIILiteral("databaseId"), *databaseId); + if (sqlError) + resultObject->setObject(ASCIILiteral("sqlError"), [*sqlError toInspectorObject]); + if (screenColor) + resultObject->setString(ASCIILiteral("screenColor"), toProtocolString(*screenColor)); + if (alternateColors) + resultObject->setArray(ASCIILiteral("alternateColors"), inspectorStringArray(*alternateColors)); + if (printColor) + resultObject->setString(ASCIILiteral("printColor"), toProtocolString(*printColor)); + backendDispatcher()->sendResponse(requestId, WTFMove(resultObject)); + }; + + int o_in_databaseId = in_databaseId; + NSString *o_in_query = in_query; + + [m_delegate executeSQLSyncOptionalReturnValuesWithErrorCallback:errorCallback successCallback:successCallback databaseId:o_in_databaseId query:o_in_query]; +} + +void ObjCInspectorDatabaseBackendDispatcher::executeSQLAsyncOptionalReturnValues(long requestId, int in_databaseId, const String& in_query) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^(NSArray/*<NSString>*/ **columnNames, NSString **notes, double *timestamp, RWIProtocolJSONObject **values, RWIProtocolJSONObject **payload, int *databaseId, TestProtocolDatabaseError **sqlError, TestProtocolDatabasePrimaryColors *screenColor, NSArray/*<NSString>*/ **alternateColors, TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColor *printColor) { + Ref<InspectorObject> resultObject = InspectorObject::create(); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(columnNames, @"columnNames"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(notes, @"notes"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(values, @"values"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(payload, @"payload"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(sqlError, @"sqlError"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(alternateColors, @"alternateColors"); + if (columnNames) + resultObject->setArray(ASCIILiteral("columnNames"), inspectorStringArray(*columnNames)); + if (notes) + resultObject->setString(ASCIILiteral("notes"), *notes); + if (timestamp) + resultObject->setDouble(ASCIILiteral("timestamp"), *timestamp); + if (values) + resultObject->setObject(ASCIILiteral("values"), [*values toInspectorObject]); + if (payload) + resultObject->setValue(ASCIILiteral("payload"), [*payload toInspectorObject]); + if (databaseId) + resultObject->setInteger(ASCIILiteral("databaseId"), *databaseId); + if (sqlError) + resultObject->setObject(ASCIILiteral("sqlError"), [*sqlError toInspectorObject]); + if (screenColor) + resultObject->setString(ASCIILiteral("screenColor"), toProtocolString(*screenColor)); + if (alternateColors) + resultObject->setArray(ASCIILiteral("alternateColors"), inspectorStringArray(*alternateColors)); + if (printColor) + resultObject->setString(ASCIILiteral("printColor"), toProtocolString(*printColor)); + backendDispatcher()->sendResponse(requestId, WTFMove(resultObject)); + }; + + int o_in_databaseId = in_databaseId; + NSString *o_in_query = in_query; + + [m_delegate executeSQLAsyncOptionalReturnValuesWithErrorCallback:errorCallback successCallback:successCallback databaseId:o_in_databaseId query:o_in_query]; +} + +void ObjCInspectorDatabaseBackendDispatcher::executeSQLSync(long requestId, int in_databaseId, const String& in_query) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^(NSArray/*<NSString>*/ *columnNames, NSString *notes, double timestamp, RWIProtocolJSONObject *values, RWIProtocolJSONObject *payload, int databaseId, TestProtocolDatabaseError *sqlError, NSArray/*<NSString>*/ *alternateColors, TestProtocolDatabasePrimaryColors screenColor, TestProtocolDatabaseExecuteSQLSyncPrintColor printColor) { + Ref<InspectorObject> resultObject = InspectorObject::create(); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(columnNames, @"columnNames"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(notes, @"notes"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(values, @"values"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(payload, @"payload"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(sqlError, @"sqlError"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(alternateColors, @"alternateColors"); + resultObject->setArray(ASCIILiteral("columnNames"), inspectorStringArray(columnNames)); + resultObject->setString(ASCIILiteral("notes"), notes); + resultObject->setDouble(ASCIILiteral("timestamp"), timestamp); + resultObject->setObject(ASCIILiteral("values"), [values toInspectorObject]); + resultObject->setValue(ASCIILiteral("payload"), [payload toInspectorObject]); + resultObject->setInteger(ASCIILiteral("databaseId"), databaseId); + resultObject->setObject(ASCIILiteral("sqlError"), [sqlError toInspectorObject]); + resultObject->setArray(ASCIILiteral("alternateColors"), inspectorStringArray(alternateColors)); + resultObject->setString(ASCIILiteral("screenColor"), toProtocolString(screenColor)); + resultObject->setString(ASCIILiteral("printColor"), toProtocolString(printColor)); + backendDispatcher()->sendResponse(requestId, WTFMove(resultObject)); + }; + + int o_in_databaseId = in_databaseId; + NSString *o_in_query = in_query; + + [m_delegate executeSQLSyncWithErrorCallback:errorCallback successCallback:successCallback databaseId:o_in_databaseId query:o_in_query]; +} + +void ObjCInspectorDatabaseBackendDispatcher::executeSQLAsync(long requestId, int in_databaseId, const String& in_query) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^(NSArray/*<NSString>*/ *columnNames, NSString *notes, double timestamp, RWIProtocolJSONObject *values, RWIProtocolJSONObject *payload, int databaseId, TestProtocolDatabaseError *sqlError, TestProtocolDatabasePrimaryColors screenColor, NSArray/*<NSString>*/ *alternateColors, TestProtocolDatabaseExecuteSQLAsyncPrintColor printColor) { + Ref<InspectorObject> resultObject = InspectorObject::create(); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(columnNames, @"columnNames"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(notes, @"notes"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(values, @"values"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(payload, @"payload"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(sqlError, @"sqlError"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(alternateColors, @"alternateColors"); + resultObject->setArray(ASCIILiteral("columnNames"), inspectorStringArray(columnNames)); + resultObject->setString(ASCIILiteral("notes"), notes); + resultObject->setDouble(ASCIILiteral("timestamp"), timestamp); + resultObject->setObject(ASCIILiteral("values"), [values toInspectorObject]); + resultObject->setValue(ASCIILiteral("payload"), [payload toInspectorObject]); + resultObject->setInteger(ASCIILiteral("databaseId"), databaseId); + resultObject->setObject(ASCIILiteral("sqlError"), [sqlError toInspectorObject]); + resultObject->setString(ASCIILiteral("screenColor"), toProtocolString(screenColor)); + resultObject->setArray(ASCIILiteral("alternateColors"), inspectorStringArray(alternateColors)); + resultObject->setString(ASCIILiteral("printColor"), toProtocolString(printColor)); + backendDispatcher()->sendResponse(requestId, WTFMove(resultObject)); + }; + + int o_in_databaseId = in_databaseId; + NSString *o_in_query = in_query; + + [m_delegate executeSQLAsyncWithErrorCallback:errorCallback successCallback:successCallback databaseId:o_in_databaseId query:o_in_query]; +} + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <WebInspector/TestProtocol.h> + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@property (nonatomic, retain, setter=setDatabaseHandler:) id<TestProtocolDatabaseDomainHandler> databaseHandler; +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import <JavaScriptCore/AlternateDispatchableAgent.h> +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#import <JavaScriptCore/InspectorBackendDispatchers.h> + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; + id<TestProtocolDatabaseDomainHandler> _databaseHandler; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [_databaseHandler release]; + [super dealloc]; +} + +- (void)setDatabaseHandler:(id<TestProtocolDatabaseDomainHandler>)handler +{ + if (handler == _databaseHandler) + return; + + [_databaseHandler release]; + _databaseHandler = [handler retain]; + + auto alternateDispatcher = std::make_unique<ObjCInspectorDatabaseBackendDispatcher>(handler); + auto alternateAgent = std::make_unique<AlternateDispatchableAgent<DatabaseBackendDispatcher, AlternateDatabaseBackendDispatcher>>(ASCIILiteral("Database"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id<TestProtocolDatabaseDomainHandler>)databaseHandler +{ + return _databaseHandler; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <JavaScriptCore/InspectorValues.h> + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <Foundation/Foundation.h> + +#import <WebInspector/RWIProtocolJSONObject.h> + + +@class TestProtocolDatabaseError; + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + +typedef NS_ENUM(NSInteger, TestProtocolDatabasePrimaryColors) { + TestProtocolDatabasePrimaryColorsRed, + TestProtocolDatabasePrimaryColorsGreen, + TestProtocolDatabasePrimaryColorsBlue, +}; + +typedef NS_ENUM(NSInteger, TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColor) { + TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorCyan, + TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorMagenta, + TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorYellow, + TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorBlack, +}; + +typedef NS_ENUM(NSInteger, TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColor) { + TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorCyan, + TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorMagenta, + TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorYellow, + TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorBlack, +}; + +typedef NS_ENUM(NSInteger, TestProtocolDatabaseExecuteSQLSyncPrintColor) { + TestProtocolDatabaseExecuteSQLSyncPrintColorCyan, + TestProtocolDatabaseExecuteSQLSyncPrintColorMagenta, + TestProtocolDatabaseExecuteSQLSyncPrintColorYellow, + TestProtocolDatabaseExecuteSQLSyncPrintColorBlack, +}; + +typedef NS_ENUM(NSInteger, TestProtocolDatabaseExecuteSQLAsyncPrintColor) { + TestProtocolDatabaseExecuteSQLAsyncPrintColorCyan, + TestProtocolDatabaseExecuteSQLAsyncPrintColorMagenta, + TestProtocolDatabaseExecuteSQLAsyncPrintColorYellow, + TestProtocolDatabaseExecuteSQLAsyncPrintColorBlack, +}; + + +__attribute__((visibility ("default"))) +@interface TestProtocolDatabaseError : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +- (instancetype)initWithMessage:(NSString *)message code:(int)code; +/* required */ @property (nonatomic, copy) NSString *message; +/* required */ @property (nonatomic, assign) int code; +@end + +@protocol TestProtocolDatabaseDomainHandler <NSObject> +@required +- (void)executeSQLSyncOptionalReturnValuesWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)(NSArray/*<NSString>*/ **columnNames, NSString **notes, double *timestamp, RWIProtocolJSONObject **values, RWIProtocolJSONObject **payload, int *databaseId, TestProtocolDatabaseError **sqlError, TestProtocolDatabasePrimaryColors *screenColor, NSArray/*<NSString>*/ **alternateColors, TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColor *printColor))successCallback databaseId:(int)databaseId query:(NSString *)query; +- (void)executeSQLAsyncOptionalReturnValuesWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)(NSArray/*<NSString>*/ **columnNames, NSString **notes, double *timestamp, RWIProtocolJSONObject **values, RWIProtocolJSONObject **payload, int *databaseId, TestProtocolDatabaseError **sqlError, TestProtocolDatabasePrimaryColors *screenColor, NSArray/*<NSString>*/ **alternateColors, TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColor *printColor))successCallback databaseId:(int)databaseId query:(NSString *)query; +- (void)executeSQLSyncWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)(NSArray/*<NSString>*/ *columnNames, NSString *notes, double timestamp, RWIProtocolJSONObject *values, RWIProtocolJSONObject *payload, int databaseId, TestProtocolDatabaseError *sqlError, NSArray/*<NSString>*/ *alternateColors, TestProtocolDatabasePrimaryColors screenColor, TestProtocolDatabaseExecuteSQLSyncPrintColor printColor))successCallback databaseId:(int)databaseId query:(NSString *)query; +- (void)executeSQLAsyncWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)(NSArray/*<NSString>*/ *columnNames, NSString *notes, double timestamp, RWIProtocolJSONObject *values, RWIProtocolJSONObject *payload, int databaseId, TestProtocolDatabaseError *sqlError, TestProtocolDatabasePrimaryColors screenColor, NSArray/*<NSString>*/ *alternateColors, TestProtocolDatabaseExecuteSQLAsyncPrintColor printColor))successCallback databaseId:(int)databaseId query:(NSString *)query; +@end + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorValues.h> + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import <WebInspector/RWIProtocolArrayConversions.h> + +namespace Inspector { + +template<typename ObjCEnumType> +std::optional<ObjCEnumType> fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + +inline String toProtocolString(TestProtocolDatabasePrimaryColors value) +{ + switch(value) { + case TestProtocolDatabasePrimaryColorsRed: + return ASCIILiteral("red"); + case TestProtocolDatabasePrimaryColorsGreen: + return ASCIILiteral("green"); + case TestProtocolDatabasePrimaryColorsBlue: + return ASCIILiteral("blue"); + } +} + +template<> +inline std::optional<TestProtocolDatabasePrimaryColors> fromProtocolString(const String& value) +{ + if (value == "red") + return TestProtocolDatabasePrimaryColorsRed; + if (value == "green") + return TestProtocolDatabasePrimaryColorsGreen; + if (value == "blue") + return TestProtocolDatabasePrimaryColorsBlue; + return std::nullopt; +} + +inline String toProtocolString(TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColor value) +{ + switch(value) { + case TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorCyan: + return ASCIILiteral("cyan"); + case TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorMagenta: + return ASCIILiteral("magenta"); + case TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorYellow: + return ASCIILiteral("yellow"); + case TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorBlack: + return ASCIILiteral("black"); + } +} + +template<> +inline std::optional<TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColor> fromProtocolString(const String& value) +{ + if (value == "cyan") + return TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorCyan; + if (value == "magenta") + return TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorMagenta; + if (value == "yellow") + return TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorYellow; + if (value == "black") + return TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorBlack; + return std::nullopt; +} + +inline String toProtocolString(TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColor value) +{ + switch(value) { + case TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorCyan: + return ASCIILiteral("cyan"); + case TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorMagenta: + return ASCIILiteral("magenta"); + case TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorYellow: + return ASCIILiteral("yellow"); + case TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorBlack: + return ASCIILiteral("black"); + } +} + +template<> +inline std::optional<TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColor> fromProtocolString(const String& value) +{ + if (value == "cyan") + return TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorCyan; + if (value == "magenta") + return TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorMagenta; + if (value == "yellow") + return TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorYellow; + if (value == "black") + return TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorBlack; + return std::nullopt; +} + +inline String toProtocolString(TestProtocolDatabaseExecuteSQLSyncPrintColor value) +{ + switch(value) { + case TestProtocolDatabaseExecuteSQLSyncPrintColorCyan: + return ASCIILiteral("cyan"); + case TestProtocolDatabaseExecuteSQLSyncPrintColorMagenta: + return ASCIILiteral("magenta"); + case TestProtocolDatabaseExecuteSQLSyncPrintColorYellow: + return ASCIILiteral("yellow"); + case TestProtocolDatabaseExecuteSQLSyncPrintColorBlack: + return ASCIILiteral("black"); + } +} + +template<> +inline std::optional<TestProtocolDatabaseExecuteSQLSyncPrintColor> fromProtocolString(const String& value) +{ + if (value == "cyan") + return TestProtocolDatabaseExecuteSQLSyncPrintColorCyan; + if (value == "magenta") + return TestProtocolDatabaseExecuteSQLSyncPrintColorMagenta; + if (value == "yellow") + return TestProtocolDatabaseExecuteSQLSyncPrintColorYellow; + if (value == "black") + return TestProtocolDatabaseExecuteSQLSyncPrintColorBlack; + return std::nullopt; +} + +inline String toProtocolString(TestProtocolDatabaseExecuteSQLAsyncPrintColor value) +{ + switch(value) { + case TestProtocolDatabaseExecuteSQLAsyncPrintColorCyan: + return ASCIILiteral("cyan"); + case TestProtocolDatabaseExecuteSQLAsyncPrintColorMagenta: + return ASCIILiteral("magenta"); + case TestProtocolDatabaseExecuteSQLAsyncPrintColorYellow: + return ASCIILiteral("yellow"); + case TestProtocolDatabaseExecuteSQLAsyncPrintColorBlack: + return ASCIILiteral("black"); + } +} + +template<> +inline std::optional<TestProtocolDatabaseExecuteSQLAsyncPrintColor> fromProtocolString(const String& value) +{ + if (value == "cyan") + return TestProtocolDatabaseExecuteSQLAsyncPrintColorCyan; + if (value == "magenta") + return TestProtocolDatabaseExecuteSQLAsyncPrintColorMagenta; + if (value == "yellow") + return TestProtocolDatabaseExecuteSQLAsyncPrintColorYellow; + if (value == "black") + return TestProtocolDatabaseExecuteSQLAsyncPrintColorBlack; + return std::nullopt; +} + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> + +using namespace Inspector; + +@interface TestProtocolTypeConversions (DatabaseDomain) + ++ (void)_parseDatabaseId:(NSNumber **)outValue fromPayload:(id)payload; ++ (void)_parsePrimaryColors:(NSNumber **)outValue fromPayload:(id)payload; ++ (void)_parseColorList:(NSArray/*<NSString>*/ **)outValue fromPayload:(id)payload; ++ (void)_parseError:(TestProtocolDatabaseError **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (DatabaseDomain) + ++ (void)_parseDatabaseId:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSNumber class]); + *outValue = (NSNumber *)payload; +} + ++ (void)_parsePrimaryColors:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + std::optional<TestProtocolDatabasePrimaryColors> result = Inspector::fromProtocolString<TestProtocolDatabasePrimaryColors>(payload); + THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"PrimaryColors"); + *outValue = @(result.value()); +} + ++ (void)_parseColorList:(NSArray/*<NSString>*/ **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSArray/*<NSString>*/ class]); + *outValue = (NSArray/*<NSString>*/ *)payload; +} + ++ (void)_parseError:(TestProtocolDatabaseError **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolDatabaseError alloc] initWithPayload:payload]; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-async-attribute.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> +#import <JavaScriptCore/InspectorValues.h> +#import <wtf/Assertions.h> + +using namespace Inspector; + + +@implementation TestProtocolDatabaseError + +- (instancetype)initWithPayload:(nonnull NSDictionary<NSString *, id> *)payload +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"message"], @"message"); + self.message = payload[@"message"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"code"], @"code"); + self.code = [payload[@"code"] integerValue]; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (instancetype)initWithMessage:(NSString *)message code:(int)code +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(message, @"message"); + + self.message = message; + self.code = code; + + return self; +} + +- (void)setMessage:(NSString *)message +{ + [super setString:message forKey:@"message"]; +} + +- (NSString *)message +{ + return [super stringForKey:@"message"]; +} + +- (void)setCode:(int)code +{ + [super setInteger:code forKey:@"code"]; +} + +- (int)code +{ + return [super integerForKey:@"code"]; +} + +@end + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result new file mode 100644 index 000000000..4c9e42618 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result @@ -0,0 +1,1643 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// Database. +InspectorBackend.registerEnum("Database.PrimaryColors", {Red: "red", Green: "green", Blue: "blue"}); +InspectorBackend.registerCommand("Database.executeAllOptionalParameters", [{"name": "columnNames", "type": "object", "optional": true}, {"name": "notes", "type": "string", "optional": true}, {"name": "timestamp", "type": "number", "optional": true}, {"name": "values", "type": "object", "optional": true}, {"name": "payload", "type": "object", "optional": true}, {"name": "databaseId", "type": "number", "optional": true}, {"name": "sqlError", "type": "object", "optional": true}, {"name": "screenColor", "type": "string", "optional": true}, {"name": "alternateColors", "type": "object", "optional": true}, {"name": "printColor", "type": "string", "optional": true}], ["columnNames", "notes", "timestamp", "values", "payload", "databaseId", "sqlError", "screenColor", "alternateColors", "printColor"]); +InspectorBackend.registerCommand("Database.executeNoOptionalParameters", [{"name": "columnNames", "type": "object", "optional": false}, {"name": "notes", "type": "string", "optional": false}, {"name": "timestamp", "type": "number", "optional": false}, {"name": "values", "type": "object", "optional": false}, {"name": "payload", "type": "object", "optional": false}, {"name": "databaseId", "type": "number", "optional": false}, {"name": "sqlError", "type": "object", "optional": false}, {"name": "screenColor", "type": "string", "optional": false}, {"name": "alternateColors", "type": "object", "optional": false}, {"name": "printColor", "type": "string", "optional": false}], ["columnNames", "notes", "timestamp", "values", "payload", "databaseId", "sqlError", "screenColor", "alternateColors", "printColor"]); +InspectorBackend.activateDomain("Database"); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include <inspector/InspectorFrontendRouter.h> +#include <JavaScriptCore/InspectorBackendDispatcher.h> + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr<BackendDispatcher>&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr<BackendDispatcher> m_backendDispatcher; +}; + + +class AlternateDatabaseBackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~AlternateDatabaseBackendDispatcher() { } + virtual void executeAllOptionalParameters(long callId, const Inspector::InspectorArray* in_columnNames, const String* const in_notes, const double* const in_timestamp, const Inspector::InspectorObject* in_values, const Inspector::InspectorValue* const in_payload, const int* const in_databaseId, const Inspector::InspectorObject* in_sqlError, const String* const in_screenColor, const Inspector::InspectorArray* in_alternateColors, const String* const in_printColor) = 0; + virtual void executeNoOptionalParameters(long callId, const Inspector::InspectorArray& in_columnNames, const String& in_notes, double in_timestamp, const Inspector::InspectorObject& in_values, Inspector::InspectorValue in_payload, int in_databaseId, const Inspector::InspectorObject& in_sqlError, const String& in_screenColor, const Inspector::InspectorArray& in_alternateColors, const String& in_printColor) = 0; +}; + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorBackendDispatcher.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +typedef String ErrorString; + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +class AlternateDatabaseBackendDispatcher; +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +class DatabaseBackendDispatcherHandler { +public: + // Named after parameter 'printColor' while generating command/event executeAllOptionalParameters. + enum class PrintColor { + Cyan = 3, + Magenta = 4, + Yellow = 5, + Black = 6, + }; // enum class PrintColor + virtual void executeAllOptionalParameters(ErrorString&, const Inspector::InspectorArray* opt_in_columnNames, const String* const opt_in_notes, const double* const opt_in_timestamp, const Inspector::InspectorObject* opt_in_values, const Inspector::InspectorValue* const opt_in_payload, const int* const opt_in_databaseId, const Inspector::InspectorObject* opt_in_sqlError, const String* const opt_in_screenColor, const Inspector::InspectorArray* opt_in_alternateColors, const String* const opt_in_printColor, RefPtr<Inspector::Protocol::Array<String>>& opt_out_columnNames, Inspector::Protocol::OptOutput<String>* opt_out_notes, Inspector::Protocol::OptOutput<double>* opt_out_timestamp, Inspector::Protocol::OptOutput<Inspector::InspectorObject>* opt_out_values, Inspector::Protocol::OptOutput<Inspector::InspectorValue>* opt_out_payload, Inspector::Protocol::OptOutput<int>* opt_out_databaseId, RefPtr<Inspector::Protocol::Database::Error>& opt_out_sqlError, Inspector::Protocol::Database::PrimaryColors* opt_out_screenColor, RefPtr<Inspector::Protocol::Database::ColorList>& opt_out_alternateColors, DatabaseBackendDispatcherHandler::PrintColor* opt_out_printColor) = 0; + virtual void executeNoOptionalParameters(ErrorString&, const Inspector::InspectorArray& in_columnNames, const String& in_notes, double in_timestamp, const Inspector::InspectorObject& in_values, Inspector::InspectorValue in_payload, int in_databaseId, const Inspector::InspectorObject& in_sqlError, const String& in_screenColor, const Inspector::InspectorArray& in_alternateColors, const String& in_printColor, RefPtr<Inspector::Protocol::Array<String>>& out_columnNames, String* out_notes, double* out_timestamp, Inspector::InspectorObject* out_values, Inspector::InspectorValue* out_payload, int* out_databaseId, RefPtr<Inspector::Protocol::Database::Error>& out_sqlError, Inspector::Protocol::Database::PrimaryColors* out_screenColor, RefPtr<Inspector::Protocol::Database::ColorList>& out_alternateColors, DatabaseBackendDispatcherHandler::PrintColor* out_printColor) = 0; +protected: + virtual ~DatabaseBackendDispatcherHandler(); +}; + +class DatabaseBackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref<DatabaseBackendDispatcher> create(BackendDispatcher&, DatabaseBackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) override; +private: + void executeAllOptionalParameters(long requestId, RefPtr<InspectorObject>&& parameters); + void executeNoOptionalParameters(long requestId, RefPtr<InspectorObject>&& parameters); +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(AlternateDatabaseBackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + AlternateDatabaseBackendDispatcher* m_alternateDispatcher { nullptr }; +#endif +private: + DatabaseBackendDispatcher(BackendDispatcher&, DatabaseBackendDispatcherHandler*); + DatabaseBackendDispatcherHandler* m_agent { nullptr }; +}; + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include <inspector/InspectorFrontendRouter.h> +#include <inspector/InspectorValues.h> +#include <wtf/NeverDestroyed.h> +#include <wtf/text/CString.h> + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + +DatabaseBackendDispatcherHandler::~DatabaseBackendDispatcherHandler() { } + +Ref<DatabaseBackendDispatcher> DatabaseBackendDispatcher::create(BackendDispatcher& backendDispatcher, DatabaseBackendDispatcherHandler* agent) +{ + return adoptRef(*new DatabaseBackendDispatcher(backendDispatcher, agent)); +} + +DatabaseBackendDispatcher::DatabaseBackendDispatcher(BackendDispatcher& backendDispatcher, DatabaseBackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("Database"), this); +} + +void DatabaseBackendDispatcher::dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) +{ + Ref<DatabaseBackendDispatcher> protect(*this); + + RefPtr<InspectorObject> parameters; + message->getObject(ASCIILiteral("params"), parameters); + + if (method == "executeAllOptionalParameters") + executeAllOptionalParameters(requestId, WTFMove(parameters)); + else if (method == "executeNoOptionalParameters") + executeNoOptionalParameters(requestId, WTFMove(parameters)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\'', "Database", '.', method, "' was not found")); +} + +void DatabaseBackendDispatcher::executeAllOptionalParameters(long requestId, RefPtr<InspectorObject>&& parameters) +{ + bool opt_in_columnNames_valueFound = false; + RefPtr<Inspector::InspectorArray> opt_in_columnNames = m_backendDispatcher->getArray(parameters.get(), ASCIILiteral("columnNames"), &opt_in_columnNames_valueFound); + bool opt_in_notes_valueFound = false; + String opt_in_notes = m_backendDispatcher->getString(parameters.get(), ASCIILiteral("notes"), &opt_in_notes_valueFound); + bool opt_in_timestamp_valueFound = false; + Inspector::Protocol::OptOutput<double> opt_in_timestamp = m_backendDispatcher->getDouble(parameters.get(), ASCIILiteral("timestamp"), &opt_in_timestamp_valueFound); + bool opt_in_values_valueFound = false; + RefPtr<Inspector::InspectorObject> opt_in_values = m_backendDispatcher->getObject(parameters.get(), ASCIILiteral("values"), &opt_in_values_valueFound); + bool opt_in_payload_valueFound = false; + RefPtr<Inspector::InspectorValue> opt_in_payload = m_backendDispatcher->getValue(parameters.get(), ASCIILiteral("payload"), &opt_in_payload_valueFound); + bool opt_in_databaseId_valueFound = false; + int opt_in_databaseId = m_backendDispatcher->getInteger(parameters.get(), ASCIILiteral("databaseId"), &opt_in_databaseId_valueFound); + bool opt_in_sqlError_valueFound = false; + RefPtr<Inspector::InspectorObject> opt_in_sqlError = m_backendDispatcher->getObject(parameters.get(), ASCIILiteral("sqlError"), &opt_in_sqlError_valueFound); + bool opt_in_screenColor_valueFound = false; + String opt_in_screenColor = m_backendDispatcher->getString(parameters.get(), ASCIILiteral("screenColor"), &opt_in_screenColor_valueFound); + bool opt_in_alternateColors_valueFound = false; + RefPtr<Inspector::InspectorArray> opt_in_alternateColors = m_backendDispatcher->getArray(parameters.get(), ASCIILiteral("alternateColors"), &opt_in_alternateColors_valueFound); + bool opt_in_printColor_valueFound = false; + String opt_in_printColor = m_backendDispatcher->getString(parameters.get(), ASCIILiteral("printColor"), &opt_in_printColor_valueFound); + if (m_backendDispatcher->hasProtocolErrors()) { + m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Some arguments of method '%s' can't be processed", "Database.executeAllOptionalParameters")); + return; + } + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->executeAllOptionalParameters(requestId, opt_in_columnNames_valueFound ? opt_in_columnNames.get() : nullptr, opt_in_notes_valueFound ? &opt_in_notes : nullptr, opt_in_timestamp_valueFound ? &opt_in_timestamp : nullptr, opt_in_values_valueFound ? opt_in_values.get() : nullptr, opt_in_payload_valueFound ? opt_in_payload.get() : nullptr, opt_in_databaseId_valueFound ? &opt_in_databaseId : nullptr, opt_in_sqlError_valueFound ? opt_in_sqlError.get() : nullptr, opt_in_screenColor_valueFound ? &opt_in_screenColor : nullptr, opt_in_alternateColors_valueFound ? opt_in_alternateColors.get() : nullptr, opt_in_printColor_valueFound ? &opt_in_printColor : nullptr); + return; + } +#endif + + ErrorString error; + Ref<InspectorObject> result = InspectorObject::create(); + RefPtr<Inspector::Protocol::Array<String>> out_columnNames; + Inspector::Protocol::OptOutput<String> out_notes; + Inspector::Protocol::OptOutput<double> out_timestamp; + Inspector::Protocol::OptOutput<Inspector::InspectorObject> out_values; + Inspector::Protocol::OptOutput<Inspector::InspectorValue> out_payload; + Inspector::Protocol::OptOutput<Inspector::Protocol::Database::DatabaseId> out_databaseId; + RefPtr<Inspector::Protocol::Database::Error> out_sqlError; + Inspector::Protocol::Database::PrimaryColors out_screenColor; + RefPtr<Inspector::Protocol::Database::ColorList> out_alternateColors; + DatabaseBackendDispatcherHandler::PrintColor out_printColor; + m_agent->executeAllOptionalParameters(error, opt_in_columnNames_valueFound ? opt_in_columnNames.get() : nullptr, opt_in_notes_valueFound ? &opt_in_notes : nullptr, opt_in_timestamp_valueFound ? &opt_in_timestamp : nullptr, opt_in_values_valueFound ? opt_in_values.get() : nullptr, opt_in_payload_valueFound ? opt_in_payload.get() : nullptr, opt_in_databaseId_valueFound ? &opt_in_databaseId : nullptr, opt_in_sqlError_valueFound ? opt_in_sqlError.get() : nullptr, opt_in_screenColor_valueFound ? &opt_in_screenColor : nullptr, opt_in_alternateColors_valueFound ? opt_in_alternateColors.get() : nullptr, opt_in_printColor_valueFound ? &opt_in_printColor : nullptr, out_columnNames, &out_notes, &out_timestamp, out_values, &out_payload, &out_databaseId, out_sqlError, &out_screenColor, out_alternateColors, &out_printColor); + + if (!error.length()) { + if (out_columnNames) + result->setArray(ASCIILiteral("columnNames"), out_columnNames); + if (out_notes.isAssigned()) + result->setString(ASCIILiteral("notes"), out_notes.getValue()); + if (out_timestamp.isAssigned()) + result->setDouble(ASCIILiteral("timestamp"), out_timestamp.getValue()); + if (out_values.isAssigned()) + result->setObject(ASCIILiteral("values"), out_values.getValue()); + if (out_payload.isAssigned()) + result->setValue(ASCIILiteral("payload"), out_payload.getValue()); + if (out_databaseId.isAssigned()) + result->setInteger(ASCIILiteral("databaseId"), out_databaseId.getValue()); + if (out_sqlError) + result->setObject(ASCIILiteral("sqlError"), out_sqlError); + if (out_screenColor.isAssigned()) + result->setString(ASCIILiteral("screenColor"), out_screenColor.getValue()); + if (out_alternateColors) + result->setArray(ASCIILiteral("alternateColors"), out_alternateColors); + if (out_printColor.isAssigned()) + result->setString(ASCIILiteral("printColor"), out_printColor.getValue()); + } + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +void DatabaseBackendDispatcher::executeNoOptionalParameters(long requestId, RefPtr<InspectorObject>&& parameters) +{ + RefPtr<Inspector::InspectorArray> in_columnNames = m_backendDispatcher->getArray(parameters.get(), ASCIILiteral("columnNames"), nullptr); + String in_notes = m_backendDispatcher->getString(parameters.get(), ASCIILiteral("notes"), nullptr); + double in_timestamp = m_backendDispatcher->getDouble(parameters.get(), ASCIILiteral("timestamp"), nullptr); + RefPtr<Inspector::InspectorObject> in_values = m_backendDispatcher->getObject(parameters.get(), ASCIILiteral("values"), nullptr); + RefPtr<Inspector::InspectorValue> in_payload = m_backendDispatcher->getValue(parameters.get(), ASCIILiteral("payload"), nullptr); + int in_databaseId = m_backendDispatcher->getInteger(parameters.get(), ASCIILiteral("databaseId"), nullptr); + RefPtr<Inspector::InspectorObject> in_sqlError = m_backendDispatcher->getObject(parameters.get(), ASCIILiteral("sqlError"), nullptr); + String in_screenColor = m_backendDispatcher->getString(parameters.get(), ASCIILiteral("screenColor"), nullptr); + RefPtr<Inspector::InspectorArray> in_alternateColors = m_backendDispatcher->getArray(parameters.get(), ASCIILiteral("alternateColors"), nullptr); + String in_printColor = m_backendDispatcher->getString(parameters.get(), ASCIILiteral("printColor"), nullptr); + if (m_backendDispatcher->hasProtocolErrors()) { + m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Some arguments of method '%s' can't be processed", "Database.executeNoOptionalParameters")); + return; + } + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->executeNoOptionalParameters(requestId, *in_columnNames, in_notes, in_timestamp, *in_values, *in_payload, in_databaseId, *in_sqlError, in_screenColor, *in_alternateColors, in_printColor); + return; + } +#endif + + ErrorString error; + Ref<InspectorObject> result = InspectorObject::create(); + RefPtr<Inspector::Protocol::Array<String>> out_columnNames; + String out_notes; + double out_timestamp; + Inspector::InspectorObject out_values; + Inspector::InspectorValue out_payload; + Inspector::Protocol::Database::DatabaseId out_databaseId; + RefPtr<Inspector::Protocol::Database::Error> out_sqlError; + Inspector::Protocol::Database::PrimaryColors out_screenColor; + RefPtr<Inspector::Protocol::Database::ColorList> out_alternateColors; + DatabaseBackendDispatcherHandler::PrintColor out_printColor; + m_agent->executeNoOptionalParameters(error, *in_columnNames, in_notes, in_timestamp, *in_values, *in_payload, in_databaseId, *in_sqlError, in_screenColor, *in_alternateColors, in_printColor, out_columnNames, &out_notes, &out_timestamp, out_values, &out_payload, &out_databaseId, out_sqlError, &out_screenColor, out_alternateColors, &out_printColor); + + if (!error.length()) { + result->setArray(ASCIILiteral("columnNames"), out_columnNames); + result->setString(ASCIILiteral("notes"), out_notes); + result->setDouble(ASCIILiteral("timestamp"), out_timestamp); + result->setObject(ASCIILiteral("values"), out_values); + result->setValue(ASCIILiteral("payload"), out_payload); + result->setInteger(ASCIILiteral("databaseId"), out_databaseId); + result->setObject(ASCIILiteral("sqlError"), out_sqlError); + result->setString(ASCIILiteral("screenColor"), Inspector::Protocol::TestHelpers::getEnumConstantValue(out_screenColor)); + result->setArray(ASCIILiteral("alternateColors"), out_alternateColors); + result->setString(ASCIILiteral("printColor"), Inspector::Protocol::TestHelpers::getEnumConstantValue(out_printColor)); + } + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorValues.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include <wtf/text/CString.h> + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include <inspector/InspectorProtocolTypes.h> +#include <wtf/Assertions.h> + +namespace Inspector { + + + +namespace Protocol { + +// Forward declarations. +namespace Database { +class Error; +enum class PrimaryColors; +} // Database +// End of forward declarations. + + +// Typedefs. +namespace Database { +/* Unique identifier of Database object. */ +typedef int DatabaseId; +typedef Inspector::Protocol::Array<Inspector::Protocol::Database::PrimaryColors> ColorList; +} // Database +// End of typedefs. + +namespace TestHelpers { + +String getEnumConstantValue(int code); + +template<typename T> String getEnumConstantValue(T enumValue) +{ + return getEnumConstantValue(static_cast<int>(enumValue)); +} + +} // namespace TestHelpers + +namespace Database { +/* */ +enum class PrimaryColors { + Red = 0, + Green = 1, + Blue = 2, +}; // enum class PrimaryColors +/* Database error. */ +class Error : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + MessageSet = 1 << 0, + CodeSet = 1 << 1, + AllFieldsSet = (MessageSet | CodeSet) + }; + + template<int STATE> + class Builder { + private: + RefPtr<InspectorObject> m_result; + + template<int STEP> Builder<STATE | STEP>& castState() + { + return *reinterpret_cast<Builder<STATE | STEP>*>(this); + } + + Builder(Ref</*Error*/InspectorObject>&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class Error; + public: + + Builder<STATE | MessageSet>& setMessage(const String& value) + { + COMPILE_ASSERT(!(STATE & MessageSet), property_message_already_set); + m_result->setString(ASCIILiteral("message"), value); + return castState<MessageSet>(); + } + + Builder<STATE | CodeSet>& setCode(int value) + { + COMPILE_ASSERT(!(STATE & CodeSet), property_code_already_set); + m_result->setInteger(ASCIILiteral("code"), value); + return castState<CodeSet>(); + } + + Ref<Error> release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(Error) == sizeof(InspectorObject), cannot_cast); + + Ref<InspectorObject> result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast<Ref<Error>*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref<Error> result = Error::create() + * .setMessage(...) + * .setCode(...) + * .release(); + */ + static Builder<NoFieldsSet> create() + { + return Builder<NoFieldsSet>(InspectorObject::create()); + } +}; + +} // Database + + + +namespace TestHelpers { + +template<typename ProtocolEnumType> +std::optional<ProtocolEnumType> parseEnumValueFromString(const String&); + +// Enums in the 'Database' Domain +template<> +std::optional<Inspector::Protocol::Database::PrimaryColors> parseEnumValueFromString<Inspector::Protocol::Database::PrimaryColors>(const String&); + +} // namespace TestHelpers + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include <wtf/Optional.h> +#include <wtf/text/CString.h> + +namespace Inspector { + +namespace Protocol { + +namespace TestHelpers { + +static const char* const enum_constant_values[] = { + "red", + "green", + "blue", + "cyan", + "magenta", + "yellow", + "black", +}; + +String getEnumConstantValue(int code) { + return enum_constant_values[code]; +} + +// Enums in the 'Database' Domain +template<> +std::optional<Inspector::Protocol::Database::PrimaryColors> parseEnumValueFromString<Inspector::Protocol::Database::PrimaryColors>(const String& protocolString) +{ + static const size_t constantValues[] = { + (size_t)Inspector::Protocol::Database::PrimaryColors::Red, + (size_t)Inspector::Protocol::Database::PrimaryColors::Green, + (size_t)Inspector::Protocol::Database::PrimaryColors::Blue, + }; + for (size_t i = 0; i < 3; ++i) + if (protocolString == enum_constant_values[constantValues[i]]) + return (Inspector::Protocol::Database::PrimaryColors)constantValues[i]; + + return std::nullopt; +} + + +} // namespace TestHelpers + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#include <wtf/RetainPtr.h> + +@protocol TestProtocolDatabaseDomainHandler; + +namespace Inspector { + + +class ObjCInspectorDatabaseBackendDispatcher final : public AlternateDatabaseBackendDispatcher { +public: + ObjCInspectorDatabaseBackendDispatcher(id<TestProtocolDatabaseDomainHandler> handler) { m_delegate = handler; } + virtual void executeAllOptionalParameters(long requestId, const Inspector::InspectorArray* in_columnNames, const String* const in_notes, const double* const in_timestamp, const Inspector::InspectorObject* in_values, const Inspector::InspectorValue* const in_payload, const int* const in_databaseId, const Inspector::InspectorObject* in_sqlError, const String* const in_screenColor, const Inspector::InspectorArray* in_alternateColors, const String* const in_printColor) override; + virtual void executeNoOptionalParameters(long requestId, const Inspector::InspectorArray& in_columnNames, const String& in_notes, double in_timestamp, const Inspector::InspectorObject& in_values, Inspector::InspectorValue in_payload, int in_databaseId, const Inspector::InspectorObject& in_sqlError, const String& in_screenColor, const Inspector::InspectorArray& in_alternateColors, const String& in_printColor) override; +private: + RetainPtr<id<TestProtocolDatabaseDomainHandler>> m_delegate; +}; + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include <JavaScriptCore/InspectorValues.h> + +namespace Inspector { + +void ObjCInspectorDatabaseBackendDispatcher::executeAllOptionalParameters(long requestId, const Inspector::InspectorArray* in_columnNames, const String* const in_notes, const double* const in_timestamp, const Inspector::InspectorObject* in_values, const Inspector::InspectorValue* const in_payload, const int* const in_databaseId, const Inspector::InspectorObject* in_sqlError, const String* const in_screenColor, const Inspector::InspectorArray* in_alternateColors, const String* const in_printColor) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^(NSArray/*<NSString>*/ **columnNames, NSString **notes, double *timestamp, RWIProtocolJSONObject **values, RWIProtocolJSONObject **payload, int *databaseId, TestProtocolDatabaseError **sqlError, TestProtocolDatabasePrimaryColors *screenColor, NSArray/*<NSString>*/ **alternateColors, TestProtocolDatabaseExecuteAllOptionalParametersPrintColor *printColor) { + Ref<InspectorObject> resultObject = InspectorObject::create(); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(columnNames, @"columnNames"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(notes, @"notes"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(values, @"values"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(payload, @"payload"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(sqlError, @"sqlError"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(alternateColors, @"alternateColors"); + if (columnNames) + resultObject->setArray(ASCIILiteral("columnNames"), inspectorStringArray(*columnNames)); + if (notes) + resultObject->setString(ASCIILiteral("notes"), *notes); + if (timestamp) + resultObject->setDouble(ASCIILiteral("timestamp"), *timestamp); + if (values) + resultObject->setObject(ASCIILiteral("values"), [*values toInspectorObject]); + if (payload) + resultObject->setValue(ASCIILiteral("payload"), [*payload toInspectorObject]); + if (databaseId) + resultObject->setInteger(ASCIILiteral("databaseId"), *databaseId); + if (sqlError) + resultObject->setObject(ASCIILiteral("sqlError"), [*sqlError toInspectorObject]); + if (screenColor) + resultObject->setString(ASCIILiteral("screenColor"), toProtocolString(*screenColor)); + if (alternateColors) + resultObject->setArray(ASCIILiteral("alternateColors"), inspectorStringArray(*alternateColors)); + if (printColor) + resultObject->setString(ASCIILiteral("printColor"), toProtocolString(*printColor)); + backendDispatcher()->sendResponse(requestId, WTFMove(resultObject)); + }; + + NSArray/*<NSString>*/ *o_in_columnNames; + if (in_columnNames) + o_in_columnNames = objcStringArray(in_columnNames); + NSString *o_in_notes; + if (in_notes) + o_in_notes = *in_notes; + double o_in_timestamp; + if (in_timestamp) + o_in_timestamp = *in_timestamp; + RWIProtocolJSONObject *o_in_values; + if (in_values) + o_in_values = [[[RWIProtocolJSONObject alloc] initWithInspectorObject:in_values] autorelease]; + RWIProtocolJSONObject *o_in_payload; + if (in_payload) + o_in_payload = [[[RWIProtocolJSONObject alloc] initWithInspectorObject:in_payload] autorelease]; + int o_in_databaseId; + if (in_databaseId) + o_in_databaseId = *in_databaseId; + TestProtocolDatabaseError *o_in_sqlError; + if (in_sqlError) + o_in_sqlError = [[[TestProtocolDatabaseError alloc] initWithInspectorObject:in_sqlError] autorelease]; + std::optional<TestProtocolDatabasePrimaryColors> o_in_screenColor; + if (in_screenColor) + o_in_screenColor = fromProtocolString<TestProtocolDatabasePrimaryColors>(*in_screenColor); + NSArray/*<NSString>*/ *o_in_alternateColors; + if (in_alternateColors) + o_in_alternateColors = objcStringArray(in_alternateColors); + std::optional<TestProtocolDatabaseExecuteAllOptionalParametersPrintColor> o_in_printColor; + if (in_printColor) + o_in_printColor = fromProtocolString<TestProtocolDatabaseExecuteAllOptionalParametersPrintColor>(*in_printColor); + + [m_delegate executeAllOptionalParametersWithErrorCallback:errorCallback successCallback:successCallback columnNames:(in_columnNames ? &o_in_columnNames : nil) notes:(in_notes ? &o_in_notes : nil) timestamp:(in_timestamp ? &o_in_timestamp : nil) values:(in_values ? &o_in_values : nil) payload:(in_payload ? &o_in_payload : nil) databaseId:(in_databaseId ? &o_in_databaseId : nil) sqlError:(in_sqlError ? &o_in_sqlError : nil) screenColor:(in_screenColor ? &o_in_screenColor : nil) alternateColors:(in_alternateColors ? &o_in_alternateColors : nil) printColor:(in_printColor ? &o_in_printColor : nil)]; +} + +void ObjCInspectorDatabaseBackendDispatcher::executeNoOptionalParameters(long requestId, const Inspector::InspectorArray& in_columnNames, const String& in_notes, double in_timestamp, const Inspector::InspectorObject& in_values, Inspector::InspectorValue in_payload, int in_databaseId, const Inspector::InspectorObject& in_sqlError, const String& in_screenColor, const Inspector::InspectorArray& in_alternateColors, const String& in_printColor) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^(NSArray/*<NSString>*/ *columnNames, NSString *notes, double timestamp, RWIProtocolJSONObject *values, RWIProtocolJSONObject *payload, int databaseId, TestProtocolDatabaseError *sqlError, TestProtocolDatabasePrimaryColors screenColor, NSArray/*<NSString>*/ *alternateColors, TestProtocolDatabaseExecuteNoOptionalParametersPrintColor printColor) { + Ref<InspectorObject> resultObject = InspectorObject::create(); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(columnNames, @"columnNames"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(notes, @"notes"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(values, @"values"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(payload, @"payload"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(sqlError, @"sqlError"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(alternateColors, @"alternateColors"); + resultObject->setArray(ASCIILiteral("columnNames"), inspectorStringArray(columnNames)); + resultObject->setString(ASCIILiteral("notes"), notes); + resultObject->setDouble(ASCIILiteral("timestamp"), timestamp); + resultObject->setObject(ASCIILiteral("values"), [values toInspectorObject]); + resultObject->setValue(ASCIILiteral("payload"), [payload toInspectorObject]); + resultObject->setInteger(ASCIILiteral("databaseId"), databaseId); + resultObject->setObject(ASCIILiteral("sqlError"), [sqlError toInspectorObject]); + resultObject->setString(ASCIILiteral("screenColor"), toProtocolString(screenColor)); + resultObject->setArray(ASCIILiteral("alternateColors"), inspectorStringArray(alternateColors)); + resultObject->setString(ASCIILiteral("printColor"), toProtocolString(printColor)); + backendDispatcher()->sendResponse(requestId, WTFMove(resultObject)); + }; + + NSArray/*<NSString>*/ *o_in_columnNames = objcStringArray(&in_columnNames); + NSString *o_in_notes = in_notes; + double o_in_timestamp = in_timestamp; + RWIProtocolJSONObject *o_in_values = [[[RWIProtocolJSONObject alloc] initWithInspectorObject:&in_values] autorelease]; + RWIProtocolJSONObject *o_in_payload = [[[RWIProtocolJSONObject alloc] initWithInspectorObject:&in_payload] autorelease]; + int o_in_databaseId = in_databaseId; + TestProtocolDatabaseError *o_in_sqlError = [[[TestProtocolDatabaseError alloc] initWithInspectorObject:&in_sqlError] autorelease]; + std::optional<TestProtocolDatabasePrimaryColors> o_in_screenColor = fromProtocolString<TestProtocolDatabasePrimaryColors>(in_screenColor); + if (!o_in_screenColor) { + backendDispatcher()->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Parameter '%s' of method '%s' cannot be processed", "screenColor", "Database.executeNoOptionalParameters")); + return; + } + NSArray/*<NSString>*/ *o_in_alternateColors = objcStringArray(&in_alternateColors); + std::optional<TestProtocolDatabaseExecuteNoOptionalParametersPrintColor> o_in_printColor = fromProtocolString<TestProtocolDatabaseExecuteNoOptionalParametersPrintColor>(in_printColor); + if (!o_in_printColor) { + backendDispatcher()->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Parameter '%s' of method '%s' cannot be processed", "printColor", "Database.executeNoOptionalParameters")); + return; + } + + [m_delegate executeNoOptionalParametersWithErrorCallback:errorCallback successCallback:successCallback columnNames:o_in_columnNames notes:o_in_notes timestamp:o_in_timestamp values:o_in_values payload:o_in_payload databaseId:o_in_databaseId sqlError:o_in_sqlError screenColor:o_in_screenColor.value() alternateColors:o_in_alternateColors printColor:o_in_printColor.value()]; +} + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <WebInspector/TestProtocol.h> + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@property (nonatomic, retain, setter=setDatabaseHandler:) id<TestProtocolDatabaseDomainHandler> databaseHandler; +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import <JavaScriptCore/AlternateDispatchableAgent.h> +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#import <JavaScriptCore/InspectorBackendDispatchers.h> + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; + id<TestProtocolDatabaseDomainHandler> _databaseHandler; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [_databaseHandler release]; + [super dealloc]; +} + +- (void)setDatabaseHandler:(id<TestProtocolDatabaseDomainHandler>)handler +{ + if (handler == _databaseHandler) + return; + + [_databaseHandler release]; + _databaseHandler = [handler retain]; + + auto alternateDispatcher = std::make_unique<ObjCInspectorDatabaseBackendDispatcher>(handler); + auto alternateAgent = std::make_unique<AlternateDispatchableAgent<DatabaseBackendDispatcher, AlternateDatabaseBackendDispatcher>>(ASCIILiteral("Database"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id<TestProtocolDatabaseDomainHandler>)databaseHandler +{ + return _databaseHandler; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <JavaScriptCore/InspectorValues.h> + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <Foundation/Foundation.h> + +#import <WebInspector/RWIProtocolJSONObject.h> + + +@class TestProtocolDatabaseError; + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + +typedef NS_ENUM(NSInteger, TestProtocolDatabasePrimaryColors) { + TestProtocolDatabasePrimaryColorsRed, + TestProtocolDatabasePrimaryColorsGreen, + TestProtocolDatabasePrimaryColorsBlue, +}; + +typedef NS_ENUM(NSInteger, TestProtocolDatabaseExecuteAllOptionalParametersPrintColor) { + TestProtocolDatabaseExecuteAllOptionalParametersPrintColorCyan, + TestProtocolDatabaseExecuteAllOptionalParametersPrintColorMagenta, + TestProtocolDatabaseExecuteAllOptionalParametersPrintColorYellow, + TestProtocolDatabaseExecuteAllOptionalParametersPrintColorBlack, +}; + +typedef NS_ENUM(NSInteger, TestProtocolDatabaseExecuteAllOptionalParametersPrintColor) { + TestProtocolDatabaseExecuteAllOptionalParametersPrintColorCyan, + TestProtocolDatabaseExecuteAllOptionalParametersPrintColorMagenta, + TestProtocolDatabaseExecuteAllOptionalParametersPrintColorYellow, + TestProtocolDatabaseExecuteAllOptionalParametersPrintColorBlack, +}; + +typedef NS_ENUM(NSInteger, TestProtocolDatabaseExecuteNoOptionalParametersPrintColor) { + TestProtocolDatabaseExecuteNoOptionalParametersPrintColorCyan, + TestProtocolDatabaseExecuteNoOptionalParametersPrintColorMagenta, + TestProtocolDatabaseExecuteNoOptionalParametersPrintColorYellow, + TestProtocolDatabaseExecuteNoOptionalParametersPrintColorBlack, +}; + +typedef NS_ENUM(NSInteger, TestProtocolDatabaseExecuteNoOptionalParametersPrintColor) { + TestProtocolDatabaseExecuteNoOptionalParametersPrintColorCyan, + TestProtocolDatabaseExecuteNoOptionalParametersPrintColorMagenta, + TestProtocolDatabaseExecuteNoOptionalParametersPrintColorYellow, + TestProtocolDatabaseExecuteNoOptionalParametersPrintColorBlack, +}; + + +__attribute__((visibility ("default"))) +@interface TestProtocolDatabaseError : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +- (instancetype)initWithMessage:(NSString *)message code:(int)code; +/* required */ @property (nonatomic, copy) NSString *message; +/* required */ @property (nonatomic, assign) int code; +@end + +@protocol TestProtocolDatabaseDomainHandler <NSObject> +@required +- (void)executeAllOptionalParametersWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)(NSArray/*<NSString>*/ **columnNames, NSString **notes, double *timestamp, RWIProtocolJSONObject **values, RWIProtocolJSONObject **payload, int *databaseId, TestProtocolDatabaseError **sqlError, TestProtocolDatabasePrimaryColors *screenColor, NSArray/*<NSString>*/ **alternateColors, TestProtocolDatabaseExecuteAllOptionalParametersPrintColor *printColor))successCallback columnNames:(NSArray/*<NSString>*/ **)columnNames notes:(NSString **)notes timestamp:(double *)timestamp values:(RWIProtocolJSONObject **)values payload:(RWIProtocolJSONObject **)payload databaseId:(int *)databaseId sqlError:(TestProtocolDatabaseError **)sqlError screenColor:(TestProtocolDatabasePrimaryColors *)screenColor alternateColors:(NSArray/*<NSString>*/ **)alternateColors printColor:(TestProtocolDatabaseExecuteAllOptionalParametersPrintColor *)printColor; +- (void)executeNoOptionalParametersWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)(NSArray/*<NSString>*/ *columnNames, NSString *notes, double timestamp, RWIProtocolJSONObject *values, RWIProtocolJSONObject *payload, int databaseId, TestProtocolDatabaseError *sqlError, TestProtocolDatabasePrimaryColors screenColor, NSArray/*<NSString>*/ *alternateColors, TestProtocolDatabaseExecuteNoOptionalParametersPrintColor printColor))successCallback columnNames:(NSArray/*<NSString>*/ *)columnNames notes:(NSString *)notes timestamp:(double)timestamp values:(RWIProtocolJSONObject *)values payload:(RWIProtocolJSONObject *)payload databaseId:(int)databaseId sqlError:(TestProtocolDatabaseError *)sqlError screenColor:(TestProtocolDatabasePrimaryColors)screenColor alternateColors:(NSArray/*<NSString>*/ *)alternateColors printColor:(TestProtocolDatabaseExecuteNoOptionalParametersPrintColor)printColor; +@end + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorValues.h> + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import <WebInspector/RWIProtocolArrayConversions.h> + +namespace Inspector { + +template<typename ObjCEnumType> +std::optional<ObjCEnumType> fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + +inline String toProtocolString(TestProtocolDatabasePrimaryColors value) +{ + switch(value) { + case TestProtocolDatabasePrimaryColorsRed: + return ASCIILiteral("red"); + case TestProtocolDatabasePrimaryColorsGreen: + return ASCIILiteral("green"); + case TestProtocolDatabasePrimaryColorsBlue: + return ASCIILiteral("blue"); + } +} + +template<> +inline std::optional<TestProtocolDatabasePrimaryColors> fromProtocolString(const String& value) +{ + if (value == "red") + return TestProtocolDatabasePrimaryColorsRed; + if (value == "green") + return TestProtocolDatabasePrimaryColorsGreen; + if (value == "blue") + return TestProtocolDatabasePrimaryColorsBlue; + return std::nullopt; +} + +inline String toProtocolString(TestProtocolDatabaseExecuteAllOptionalParametersPrintColor value) +{ + switch(value) { + case TestProtocolDatabaseExecuteAllOptionalParametersPrintColorCyan: + return ASCIILiteral("cyan"); + case TestProtocolDatabaseExecuteAllOptionalParametersPrintColorMagenta: + return ASCIILiteral("magenta"); + case TestProtocolDatabaseExecuteAllOptionalParametersPrintColorYellow: + return ASCIILiteral("yellow"); + case TestProtocolDatabaseExecuteAllOptionalParametersPrintColorBlack: + return ASCIILiteral("black"); + } +} + +template<> +inline std::optional<TestProtocolDatabaseExecuteAllOptionalParametersPrintColor> fromProtocolString(const String& value) +{ + if (value == "cyan") + return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorCyan; + if (value == "magenta") + return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorMagenta; + if (value == "yellow") + return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorYellow; + if (value == "black") + return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorBlack; + return std::nullopt; +} + +inline String toProtocolString(TestProtocolDatabaseExecuteAllOptionalParametersPrintColor value) +{ + switch(value) { + case TestProtocolDatabaseExecuteAllOptionalParametersPrintColorCyan: + return ASCIILiteral("cyan"); + case TestProtocolDatabaseExecuteAllOptionalParametersPrintColorMagenta: + return ASCIILiteral("magenta"); + case TestProtocolDatabaseExecuteAllOptionalParametersPrintColorYellow: + return ASCIILiteral("yellow"); + case TestProtocolDatabaseExecuteAllOptionalParametersPrintColorBlack: + return ASCIILiteral("black"); + } +} + +template<> +inline std::optional<TestProtocolDatabaseExecuteAllOptionalParametersPrintColor> fromProtocolString(const String& value) +{ + if (value == "cyan") + return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorCyan; + if (value == "magenta") + return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorMagenta; + if (value == "yellow") + return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorYellow; + if (value == "black") + return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorBlack; + return std::nullopt; +} + +inline String toProtocolString(TestProtocolDatabaseExecuteNoOptionalParametersPrintColor value) +{ + switch(value) { + case TestProtocolDatabaseExecuteNoOptionalParametersPrintColorCyan: + return ASCIILiteral("cyan"); + case TestProtocolDatabaseExecuteNoOptionalParametersPrintColorMagenta: + return ASCIILiteral("magenta"); + case TestProtocolDatabaseExecuteNoOptionalParametersPrintColorYellow: + return ASCIILiteral("yellow"); + case TestProtocolDatabaseExecuteNoOptionalParametersPrintColorBlack: + return ASCIILiteral("black"); + } +} + +template<> +inline std::optional<TestProtocolDatabaseExecuteNoOptionalParametersPrintColor> fromProtocolString(const String& value) +{ + if (value == "cyan") + return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorCyan; + if (value == "magenta") + return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorMagenta; + if (value == "yellow") + return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorYellow; + if (value == "black") + return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorBlack; + return std::nullopt; +} + +inline String toProtocolString(TestProtocolDatabaseExecuteNoOptionalParametersPrintColor value) +{ + switch(value) { + case TestProtocolDatabaseExecuteNoOptionalParametersPrintColorCyan: + return ASCIILiteral("cyan"); + case TestProtocolDatabaseExecuteNoOptionalParametersPrintColorMagenta: + return ASCIILiteral("magenta"); + case TestProtocolDatabaseExecuteNoOptionalParametersPrintColorYellow: + return ASCIILiteral("yellow"); + case TestProtocolDatabaseExecuteNoOptionalParametersPrintColorBlack: + return ASCIILiteral("black"); + } +} + +template<> +inline std::optional<TestProtocolDatabaseExecuteNoOptionalParametersPrintColor> fromProtocolString(const String& value) +{ + if (value == "cyan") + return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorCyan; + if (value == "magenta") + return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorMagenta; + if (value == "yellow") + return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorYellow; + if (value == "black") + return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorBlack; + return std::nullopt; +} + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> + +using namespace Inspector; + +@interface TestProtocolTypeConversions (DatabaseDomain) + ++ (void)_parseDatabaseId:(NSNumber **)outValue fromPayload:(id)payload; ++ (void)_parsePrimaryColors:(NSNumber **)outValue fromPayload:(id)payload; ++ (void)_parseColorList:(NSArray/*<NSString>*/ **)outValue fromPayload:(id)payload; ++ (void)_parseError:(TestProtocolDatabaseError **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (DatabaseDomain) + ++ (void)_parseDatabaseId:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSNumber class]); + *outValue = (NSNumber *)payload; +} + ++ (void)_parsePrimaryColors:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + std::optional<TestProtocolDatabasePrimaryColors> result = Inspector::fromProtocolString<TestProtocolDatabasePrimaryColors>(payload); + THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"PrimaryColors"); + *outValue = @(result.value()); +} + ++ (void)_parseColorList:(NSArray/*<NSString>*/ **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSArray/*<NSString>*/ class]); + *outValue = (NSArray/*<NSString>*/ *)payload; +} + ++ (void)_parseError:(TestProtocolDatabaseError **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolDatabaseError alloc] initWithPayload:payload]; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from commands-with-optional-call-return-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> +#import <JavaScriptCore/InspectorValues.h> +#import <wtf/Assertions.h> + +using namespace Inspector; + + +@implementation TestProtocolDatabaseError + +- (instancetype)initWithPayload:(nonnull NSDictionary<NSString *, id> *)payload +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"message"], @"message"); + self.message = payload[@"message"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"code"], @"code"); + self.code = [payload[@"code"] integerValue]; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (instancetype)initWithMessage:(NSString *)message code:(int)code +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(message, @"message"); + + self.message = message; + self.code = code; + + return self; +} + +- (void)setMessage:(NSString *)message +{ + [super setString:message forKey:@"message"]; +} + +- (NSString *)message +{ + return [super stringForKey:@"message"]; +} + +- (void)setCode:(int)code +{ + [super setInteger:code forKey:@"code"]; +} + +- (int)code +{ + return [super integerForKey:@"code"]; +} + +@end + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/definitions-with-mac-platform.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/definitions-with-mac-platform.json-result new file mode 100644 index 000000000..d9cec9c61 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/definitions-with-mac-platform.json-result @@ -0,0 +1,866 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include <inspector/InspectorFrontendRouter.h> +#include <JavaScriptCore/InspectorBackendDispatcher.h> + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr<BackendDispatcher>&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr<BackendDispatcher> m_backendDispatcher; +}; + + + + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorBackendDispatcher.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +typedef String ErrorString; + + + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include <inspector/InspectorFrontendRouter.h> +#include <inspector/InspectorValues.h> +#include <wtf/NeverDestroyed.h> +#include <wtf/text/CString.h> + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + + + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorValues.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include <wtf/text/CString.h> + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include <inspector/InspectorProtocolTypes.h> +#include <wtf/Assertions.h> + +namespace Inspector { + + + +namespace Protocol { + + + + + + + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include <wtf/Optional.h> +#include <wtf/text/CString.h> + +namespace Inspector { + +namespace Protocol { + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#include <wtf/RetainPtr.h> + + + +namespace Inspector { + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include <JavaScriptCore/InspectorValues.h> + +namespace Inspector { + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <WebInspector/TestProtocol.h> + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import <JavaScriptCore/AlternateDispatchableAgent.h> +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#import <JavaScriptCore/InspectorBackendDispatchers.h> + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [super dealloc]; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <JavaScriptCore/InspectorValues.h> + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <Foundation/Foundation.h> + +#import <WebInspector/RWIProtocolJSONObject.h> + + + + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + + + + + + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorValues.h> + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import <WebInspector/RWIProtocolArrayConversions.h> + +namespace Inspector { + +template<typename ObjCEnumType> +std::optional<ObjCEnumType> fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> + +using namespace Inspector; + + + + + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from definitions-with-mac-platform.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> +#import <JavaScriptCore/InspectorValues.h> +#import <wtf/Assertions.h> + +using namespace Inspector; + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/domain-availability.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/domain-availability.json-result new file mode 100644 index 000000000..0c4c30499 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/domain-availability.json-result @@ -0,0 +1,1120 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// DomainA. +InspectorBackend.registerCommand("DomainA.enable", [], []); +InspectorBackend.activateDomain("DomainA", "web"); + +// DomainB. +InspectorBackend.registerCommand("DomainB.enable", [], []); +InspectorBackend.activateDomain("DomainB"); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include <inspector/InspectorFrontendRouter.h> +#include <JavaScriptCore/InspectorBackendDispatcher.h> + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr<BackendDispatcher>&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr<BackendDispatcher> m_backendDispatcher; +}; + + +class AlternateDomainABackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~AlternateDomainABackendDispatcher() { } + virtual void enable(long callId) = 0; +}; +class AlternateDomainBBackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~AlternateDomainBBackendDispatcher() { } + virtual void enable(long callId) = 0; +}; + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorBackendDispatcher.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +typedef String ErrorString; + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +class AlternateDomainABackendDispatcher; +class AlternateDomainBBackendDispatcher; +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +class DomainABackendDispatcherHandler { +public: + virtual void enable(ErrorString&) = 0; +protected: + virtual ~DomainABackendDispatcherHandler(); +}; + +class DomainBBackendDispatcherHandler { +public: + virtual void enable(ErrorString&) = 0; +protected: + virtual ~DomainBBackendDispatcherHandler(); +}; + +class DomainABackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref<DomainABackendDispatcher> create(BackendDispatcher&, DomainABackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) override; +private: + void enable(long requestId, RefPtr<InspectorObject>&& parameters); +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(AlternateDomainABackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + AlternateDomainABackendDispatcher* m_alternateDispatcher { nullptr }; +#endif +private: + DomainABackendDispatcher(BackendDispatcher&, DomainABackendDispatcherHandler*); + DomainABackendDispatcherHandler* m_agent { nullptr }; +}; + +class DomainBBackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref<DomainBBackendDispatcher> create(BackendDispatcher&, DomainBBackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) override; +private: + void enable(long requestId, RefPtr<InspectorObject>&& parameters); +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(AlternateDomainBBackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + AlternateDomainBBackendDispatcher* m_alternateDispatcher { nullptr }; +#endif +private: + DomainBBackendDispatcher(BackendDispatcher&, DomainBBackendDispatcherHandler*); + DomainBBackendDispatcherHandler* m_agent { nullptr }; +}; + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include <inspector/InspectorFrontendRouter.h> +#include <inspector/InspectorValues.h> +#include <wtf/NeverDestroyed.h> +#include <wtf/text/CString.h> + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + +DomainABackendDispatcherHandler::~DomainABackendDispatcherHandler() { } +DomainBBackendDispatcherHandler::~DomainBBackendDispatcherHandler() { } + +Ref<DomainABackendDispatcher> DomainABackendDispatcher::create(BackendDispatcher& backendDispatcher, DomainABackendDispatcherHandler* agent) +{ + return adoptRef(*new DomainABackendDispatcher(backendDispatcher, agent)); +} + +DomainABackendDispatcher::DomainABackendDispatcher(BackendDispatcher& backendDispatcher, DomainABackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("DomainA"), this); +} + +void DomainABackendDispatcher::dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) +{ + Ref<DomainABackendDispatcher> protect(*this); + + RefPtr<InspectorObject> parameters; + message->getObject(ASCIILiteral("params"), parameters); + + if (method == "enable") + enable(requestId, WTFMove(parameters)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\'', "DomainA", '.', method, "' was not found")); +} + +void DomainABackendDispatcher::enable(long requestId, RefPtr<InspectorObject>&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->enable(requestId); + return; + } +#endif + + ErrorString error; + Ref<InspectorObject> result = InspectorObject::create(); + m_agent->enable(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +Ref<DomainBBackendDispatcher> DomainBBackendDispatcher::create(BackendDispatcher& backendDispatcher, DomainBBackendDispatcherHandler* agent) +{ + return adoptRef(*new DomainBBackendDispatcher(backendDispatcher, agent)); +} + +DomainBBackendDispatcher::DomainBBackendDispatcher(BackendDispatcher& backendDispatcher, DomainBBackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("DomainB"), this); +} + +void DomainBBackendDispatcher::dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) +{ + Ref<DomainBBackendDispatcher> protect(*this); + + RefPtr<InspectorObject> parameters; + message->getObject(ASCIILiteral("params"), parameters); + + if (method == "enable") + enable(requestId, WTFMove(parameters)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\'', "DomainB", '.', method, "' was not found")); +} + +void DomainBBackendDispatcher::enable(long requestId, RefPtr<InspectorObject>&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->enable(requestId); + return; + } +#endif + + ErrorString error; + Ref<InspectorObject> result = InspectorObject::create(); + m_agent->enable(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorValues.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include <wtf/text/CString.h> + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include <inspector/InspectorProtocolTypes.h> +#include <wtf/Assertions.h> + +namespace Inspector { + + + +namespace Protocol { + + + + + + + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include <wtf/Optional.h> +#include <wtf/text/CString.h> + +namespace Inspector { + +namespace Protocol { + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#include <wtf/RetainPtr.h> + +@protocol TestProtocolDomainADomainHandler; +@protocol TestProtocolDomainBDomainHandler; + +namespace Inspector { + + +class ObjCInspectorDomainABackendDispatcher final : public AlternateDomainABackendDispatcher { +public: + ObjCInspectorDomainABackendDispatcher(id<TestProtocolDomainADomainHandler> handler) { m_delegate = handler; } + virtual void enable(long requestId) override; +private: + RetainPtr<id<TestProtocolDomainADomainHandler>> m_delegate; +}; + +class ObjCInspectorDomainBBackendDispatcher final : public AlternateDomainBBackendDispatcher { +public: + ObjCInspectorDomainBBackendDispatcher(id<TestProtocolDomainBDomainHandler> handler) { m_delegate = handler; } + virtual void enable(long requestId) override; +private: + RetainPtr<id<TestProtocolDomainBDomainHandler>> m_delegate; +}; + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include <JavaScriptCore/InspectorValues.h> + +namespace Inspector { + +void ObjCInspectorDomainABackendDispatcher::enable(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate enableWithErrorCallback:errorCallback successCallback:successCallback]; +} + + +void ObjCInspectorDomainBBackendDispatcher::enable(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate enableWithErrorCallback:errorCallback successCallback:successCallback]; +} + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <WebInspector/TestProtocol.h> + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@property (nonatomic, retain, setter=setDomainAHandler:) id<TestProtocolDomainADomainHandler> domainAHandler; +@property (nonatomic, retain, setter=setDomainBHandler:) id<TestProtocolDomainBDomainHandler> domainBHandler; +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import <JavaScriptCore/AlternateDispatchableAgent.h> +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#import <JavaScriptCore/InspectorBackendDispatchers.h> + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; + id<TestProtocolDomainADomainHandler> _domainAHandler; + id<TestProtocolDomainBDomainHandler> _domainBHandler; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [_domainAHandler release]; + [_domainBHandler release]; + [super dealloc]; +} + +- (void)setDomainAHandler:(id<TestProtocolDomainADomainHandler>)handler +{ + if (handler == _domainAHandler) + return; + + [_domainAHandler release]; + _domainAHandler = [handler retain]; + + auto alternateDispatcher = std::make_unique<ObjCInspectorDomainABackendDispatcher>(handler); + auto alternateAgent = std::make_unique<AlternateDispatchableAgent<DomainABackendDispatcher, AlternateDomainABackendDispatcher>>(ASCIILiteral("DomainA"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id<TestProtocolDomainADomainHandler>)domainAHandler +{ + return _domainAHandler; +} + +- (void)setDomainBHandler:(id<TestProtocolDomainBDomainHandler>)handler +{ + if (handler == _domainBHandler) + return; + + [_domainBHandler release]; + _domainBHandler = [handler retain]; + + auto alternateDispatcher = std::make_unique<ObjCInspectorDomainBBackendDispatcher>(handler); + auto alternateAgent = std::make_unique<AlternateDispatchableAgent<DomainBBackendDispatcher, AlternateDomainBBackendDispatcher>>(ASCIILiteral("DomainB"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id<TestProtocolDomainBDomainHandler>)domainBHandler +{ + return _domainBHandler; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <JavaScriptCore/InspectorValues.h> + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <Foundation/Foundation.h> + +#import <WebInspector/RWIProtocolJSONObject.h> + + + + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + + + + +@protocol TestProtocolDomainADomainHandler <NSObject> +@required +- (void)enableWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +@end + +@protocol TestProtocolDomainBDomainHandler <NSObject> +@required +- (void)enableWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +@end + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorValues.h> + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import <WebInspector/RWIProtocolArrayConversions.h> + +namespace Inspector { + +template<typename ObjCEnumType> +std::optional<ObjCEnumType> fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> + +using namespace Inspector; + + + + + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domain-availability.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> +#import <JavaScriptCore/InspectorValues.h> +#import <wtf/Assertions.h> + +using namespace Inspector; + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/domains-with-varying-command-sizes.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/domains-with-varying-command-sizes.json-result new file mode 100644 index 000000000..e9afc2a18 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/domains-with-varying-command-sizes.json-result @@ -0,0 +1,1399 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// Network1. +InspectorBackend.registerCommand("Network1.loadResource1", [], []); +InspectorBackend.activateDomain("Network1"); + +// Network3. +InspectorBackend.registerCommand("Network3.loadResource1", [], []); +InspectorBackend.registerCommand("Network3.loadResource2", [], []); +InspectorBackend.registerCommand("Network3.loadResource3", [], []); +InspectorBackend.registerCommand("Network3.loadResource4", [], []); +InspectorBackend.registerCommand("Network3.loadResource5", [], []); +InspectorBackend.registerCommand("Network3.loadResource6", [], []); +InspectorBackend.registerCommand("Network3.loadResource7", [], []); +InspectorBackend.activateDomain("Network3"); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include <inspector/InspectorFrontendRouter.h> +#include <JavaScriptCore/InspectorBackendDispatcher.h> + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr<BackendDispatcher>&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr<BackendDispatcher> m_backendDispatcher; +}; + + +class AlternateNetwork1BackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~AlternateNetwork1BackendDispatcher() { } + virtual void loadResource1(long callId) = 0; +}; +class AlternateNetwork3BackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~AlternateNetwork3BackendDispatcher() { } + virtual void loadResource1(long callId) = 0; + virtual void loadResource2(long callId) = 0; + virtual void loadResource3(long callId) = 0; + virtual void loadResource4(long callId) = 0; + virtual void loadResource5(long callId) = 0; + virtual void loadResource6(long callId) = 0; + virtual void loadResource7(long callId) = 0; +}; + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorBackendDispatcher.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +typedef String ErrorString; + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +class AlternateNetwork1BackendDispatcher; +class AlternateNetwork3BackendDispatcher; +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +class Network1BackendDispatcherHandler { +public: + virtual void loadResource1(ErrorString&) = 0; +protected: + virtual ~Network1BackendDispatcherHandler(); +}; + +class Network3BackendDispatcherHandler { +public: + virtual void loadResource1(ErrorString&) = 0; + virtual void loadResource2(ErrorString&) = 0; + virtual void loadResource3(ErrorString&) = 0; + virtual void loadResource4(ErrorString&) = 0; + virtual void loadResource5(ErrorString&) = 0; + virtual void loadResource6(ErrorString&) = 0; + virtual void loadResource7(ErrorString&) = 0; +protected: + virtual ~Network3BackendDispatcherHandler(); +}; + +class Network1BackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref<Network1BackendDispatcher> create(BackendDispatcher&, Network1BackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) override; +private: + void loadResource1(long requestId, RefPtr<InspectorObject>&& parameters); +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(AlternateNetwork1BackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + AlternateNetwork1BackendDispatcher* m_alternateDispatcher { nullptr }; +#endif +private: + Network1BackendDispatcher(BackendDispatcher&, Network1BackendDispatcherHandler*); + Network1BackendDispatcherHandler* m_agent { nullptr }; +}; + +class Network3BackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref<Network3BackendDispatcher> create(BackendDispatcher&, Network3BackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) override; +private: + void loadResource1(long requestId, RefPtr<InspectorObject>&& parameters); + void loadResource2(long requestId, RefPtr<InspectorObject>&& parameters); + void loadResource3(long requestId, RefPtr<InspectorObject>&& parameters); + void loadResource4(long requestId, RefPtr<InspectorObject>&& parameters); + void loadResource5(long requestId, RefPtr<InspectorObject>&& parameters); + void loadResource6(long requestId, RefPtr<InspectorObject>&& parameters); + void loadResource7(long requestId, RefPtr<InspectorObject>&& parameters); +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(AlternateNetwork3BackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + AlternateNetwork3BackendDispatcher* m_alternateDispatcher { nullptr }; +#endif +private: + Network3BackendDispatcher(BackendDispatcher&, Network3BackendDispatcherHandler*); + Network3BackendDispatcherHandler* m_agent { nullptr }; +}; + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include <inspector/InspectorFrontendRouter.h> +#include <inspector/InspectorValues.h> +#include <wtf/NeverDestroyed.h> +#include <wtf/text/CString.h> + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + +Network1BackendDispatcherHandler::~Network1BackendDispatcherHandler() { } +Network3BackendDispatcherHandler::~Network3BackendDispatcherHandler() { } + +Ref<Network1BackendDispatcher> Network1BackendDispatcher::create(BackendDispatcher& backendDispatcher, Network1BackendDispatcherHandler* agent) +{ + return adoptRef(*new Network1BackendDispatcher(backendDispatcher, agent)); +} + +Network1BackendDispatcher::Network1BackendDispatcher(BackendDispatcher& backendDispatcher, Network1BackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("Network1"), this); +} + +void Network1BackendDispatcher::dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) +{ + Ref<Network1BackendDispatcher> protect(*this); + + RefPtr<InspectorObject> parameters; + message->getObject(ASCIILiteral("params"), parameters); + + if (method == "loadResource1") + loadResource1(requestId, WTFMove(parameters)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\'', "Network1", '.', method, "' was not found")); +} + +void Network1BackendDispatcher::loadResource1(long requestId, RefPtr<InspectorObject>&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->loadResource1(requestId); + return; + } +#endif + + ErrorString error; + Ref<InspectorObject> result = InspectorObject::create(); + m_agent->loadResource1(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +Ref<Network3BackendDispatcher> Network3BackendDispatcher::create(BackendDispatcher& backendDispatcher, Network3BackendDispatcherHandler* agent) +{ + return adoptRef(*new Network3BackendDispatcher(backendDispatcher, agent)); +} + +Network3BackendDispatcher::Network3BackendDispatcher(BackendDispatcher& backendDispatcher, Network3BackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("Network3"), this); +} + +void Network3BackendDispatcher::dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) +{ + Ref<Network3BackendDispatcher> protect(*this); + + RefPtr<InspectorObject> parameters; + message->getObject(ASCIILiteral("params"), parameters); + + typedef void (Network3BackendDispatcher::*CallHandler)(long requestId, RefPtr<InspectorObject>&& message); + typedef HashMap<String, CallHandler> DispatchMap; + static NeverDestroyed<DispatchMap> dispatchMap; + if (dispatchMap.get().isEmpty()) { + static const struct MethodTable { + const char* name; + CallHandler handler; + } commands[] = { + { "loadResource1", &Network3BackendDispatcher::loadResource1 }, + { "loadResource2", &Network3BackendDispatcher::loadResource2 }, + { "loadResource3", &Network3BackendDispatcher::loadResource3 }, + { "loadResource4", &Network3BackendDispatcher::loadResource4 }, + { "loadResource5", &Network3BackendDispatcher::loadResource5 }, + { "loadResource6", &Network3BackendDispatcher::loadResource6 }, + { "loadResource7", &Network3BackendDispatcher::loadResource7 }, + }; + size_t length = WTF_ARRAY_LENGTH(commands); + for (size_t i = 0; i < length; ++i) + dispatchMap.get().add(commands[i].name, commands[i].handler); + } + + auto findResult = dispatchMap.get().find(method); + if (findResult == dispatchMap.get().end()) { + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\'', "Network3", '.', method, "' was not found")); + return; + } + + ((*this).*findResult->value)(requestId, WTFMove(parameters)); +} + +void Network3BackendDispatcher::loadResource1(long requestId, RefPtr<InspectorObject>&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->loadResource1(requestId); + return; + } +#endif + + ErrorString error; + Ref<InspectorObject> result = InspectorObject::create(); + m_agent->loadResource1(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +void Network3BackendDispatcher::loadResource2(long requestId, RefPtr<InspectorObject>&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->loadResource2(requestId); + return; + } +#endif + + ErrorString error; + Ref<InspectorObject> result = InspectorObject::create(); + m_agent->loadResource2(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +void Network3BackendDispatcher::loadResource3(long requestId, RefPtr<InspectorObject>&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->loadResource3(requestId); + return; + } +#endif + + ErrorString error; + Ref<InspectorObject> result = InspectorObject::create(); + m_agent->loadResource3(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +void Network3BackendDispatcher::loadResource4(long requestId, RefPtr<InspectorObject>&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->loadResource4(requestId); + return; + } +#endif + + ErrorString error; + Ref<InspectorObject> result = InspectorObject::create(); + m_agent->loadResource4(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +void Network3BackendDispatcher::loadResource5(long requestId, RefPtr<InspectorObject>&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->loadResource5(requestId); + return; + } +#endif + + ErrorString error; + Ref<InspectorObject> result = InspectorObject::create(); + m_agent->loadResource5(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +void Network3BackendDispatcher::loadResource6(long requestId, RefPtr<InspectorObject>&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->loadResource6(requestId); + return; + } +#endif + + ErrorString error; + Ref<InspectorObject> result = InspectorObject::create(); + m_agent->loadResource6(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +void Network3BackendDispatcher::loadResource7(long requestId, RefPtr<InspectorObject>&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->loadResource7(requestId); + return; + } +#endif + + ErrorString error; + Ref<InspectorObject> result = InspectorObject::create(); + m_agent->loadResource7(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorValues.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include <wtf/text/CString.h> + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include <inspector/InspectorProtocolTypes.h> +#include <wtf/Assertions.h> + +namespace Inspector { + + + +namespace Protocol { + + + +// Typedefs. +namespace Network2 { +/* Unique loader identifier. */ +typedef String LoaderId; +} // Network2 +// End of typedefs. + + + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include <wtf/Optional.h> +#include <wtf/text/CString.h> + +namespace Inspector { + +namespace Protocol { + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#include <wtf/RetainPtr.h> + +@protocol TestProtocolNetwork1DomainHandler; +@protocol TestProtocolNetwork3DomainHandler; + +namespace Inspector { + + +class ObjCInspectorNetwork1BackendDispatcher final : public AlternateNetwork1BackendDispatcher { +public: + ObjCInspectorNetwork1BackendDispatcher(id<TestProtocolNetwork1DomainHandler> handler) { m_delegate = handler; } + virtual void loadResource1(long requestId) override; +private: + RetainPtr<id<TestProtocolNetwork1DomainHandler>> m_delegate; +}; + +class ObjCInspectorNetwork3BackendDispatcher final : public AlternateNetwork3BackendDispatcher { +public: + ObjCInspectorNetwork3BackendDispatcher(id<TestProtocolNetwork3DomainHandler> handler) { m_delegate = handler; } + virtual void loadResource1(long requestId) override; + virtual void loadResource2(long requestId) override; + virtual void loadResource3(long requestId) override; + virtual void loadResource4(long requestId) override; + virtual void loadResource5(long requestId) override; + virtual void loadResource6(long requestId) override; + virtual void loadResource7(long requestId) override; +private: + RetainPtr<id<TestProtocolNetwork3DomainHandler>> m_delegate; +}; + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include <JavaScriptCore/InspectorValues.h> + +namespace Inspector { + +void ObjCInspectorNetwork1BackendDispatcher::loadResource1(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate loadResource1WithErrorCallback:errorCallback successCallback:successCallback]; +} + + +void ObjCInspectorNetwork3BackendDispatcher::loadResource1(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate loadResource1WithErrorCallback:errorCallback successCallback:successCallback]; +} + +void ObjCInspectorNetwork3BackendDispatcher::loadResource2(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate loadResource2WithErrorCallback:errorCallback successCallback:successCallback]; +} + +void ObjCInspectorNetwork3BackendDispatcher::loadResource3(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate loadResource3WithErrorCallback:errorCallback successCallback:successCallback]; +} + +void ObjCInspectorNetwork3BackendDispatcher::loadResource4(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate loadResource4WithErrorCallback:errorCallback successCallback:successCallback]; +} + +void ObjCInspectorNetwork3BackendDispatcher::loadResource5(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate loadResource5WithErrorCallback:errorCallback successCallback:successCallback]; +} + +void ObjCInspectorNetwork3BackendDispatcher::loadResource6(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate loadResource6WithErrorCallback:errorCallback successCallback:successCallback]; +} + +void ObjCInspectorNetwork3BackendDispatcher::loadResource7(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate loadResource7WithErrorCallback:errorCallback successCallback:successCallback]; +} + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <WebInspector/TestProtocol.h> + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@property (nonatomic, retain, setter=setNetwork1Handler:) id<TestProtocolNetwork1DomainHandler> network1Handler; +@property (nonatomic, retain, setter=setNetwork3Handler:) id<TestProtocolNetwork3DomainHandler> network3Handler; +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import <JavaScriptCore/AlternateDispatchableAgent.h> +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#import <JavaScriptCore/InspectorBackendDispatchers.h> + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; + id<TestProtocolNetwork1DomainHandler> _network1Handler; + id<TestProtocolNetwork3DomainHandler> _network3Handler; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [_network1Handler release]; + [_network3Handler release]; + [super dealloc]; +} + +- (void)setNetwork1Handler:(id<TestProtocolNetwork1DomainHandler>)handler +{ + if (handler == _network1Handler) + return; + + [_network1Handler release]; + _network1Handler = [handler retain]; + + auto alternateDispatcher = std::make_unique<ObjCInspectorNetwork1BackendDispatcher>(handler); + auto alternateAgent = std::make_unique<AlternateDispatchableAgent<Network1BackendDispatcher, AlternateNetwork1BackendDispatcher>>(ASCIILiteral("Network1"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id<TestProtocolNetwork1DomainHandler>)network1Handler +{ + return _network1Handler; +} + +- (void)setNetwork3Handler:(id<TestProtocolNetwork3DomainHandler>)handler +{ + if (handler == _network3Handler) + return; + + [_network3Handler release]; + _network3Handler = [handler retain]; + + auto alternateDispatcher = std::make_unique<ObjCInspectorNetwork3BackendDispatcher>(handler); + auto alternateAgent = std::make_unique<AlternateDispatchableAgent<Network3BackendDispatcher, AlternateNetwork3BackendDispatcher>>(ASCIILiteral("Network3"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id<TestProtocolNetwork3DomainHandler>)network3Handler +{ + return _network3Handler; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <JavaScriptCore/InspectorValues.h> + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <Foundation/Foundation.h> + +#import <WebInspector/RWIProtocolJSONObject.h> + + + + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + + + + +@protocol TestProtocolNetwork1DomainHandler <NSObject> +@required +- (void)loadResource1WithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +@end + +@protocol TestProtocolNetwork3DomainHandler <NSObject> +@required +- (void)loadResource1WithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +- (void)loadResource2WithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +- (void)loadResource3WithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +- (void)loadResource4WithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +- (void)loadResource5WithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +- (void)loadResource6WithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +- (void)loadResource7WithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +@end + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorValues.h> + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import <WebInspector/RWIProtocolArrayConversions.h> + +namespace Inspector { + +template<typename ObjCEnumType> +std::optional<ObjCEnumType> fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> + +using namespace Inspector; + +@interface TestProtocolTypeConversions (Network2Domain) + ++ (void)_parseLoaderId:(NSString **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (Network2Domain) + ++ (void)_parseLoaderId:(NSString **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + *outValue = (NSString *)payload; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from domains-with-varying-command-sizes.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> +#import <JavaScriptCore/InspectorValues.h> +#import <wtf/Assertions.h> + +using namespace Inspector; + + + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/enum-values.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/enum-values.json-result new file mode 100644 index 000000000..d2a01c84e --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/enum-values.json-result @@ -0,0 +1,1208 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// TypeDomain. +InspectorBackend.registerEnum("TypeDomain.TypeDomainEnum", {Shared: "shared", Red: "red", Green: "green", Blue: "blue"}); + +// CommandDomain. +InspectorBackend.registerCommand("CommandDomain.commandWithEnumReturnValue", [], ["returnValue"]); +InspectorBackend.activateDomain("CommandDomain"); + +// EventDomain. +InspectorBackend.registerEventDomainDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "EventDomain"); +InspectorBackend.registerEnum("EventDomain.EventWithEnumParameterParameter", {Shared: "shared", Black: "black", White: "white"}); +InspectorBackend.registerEvent("EventDomain.eventWithEnumParameter", ["parameter"]); +InspectorBackend.activateDomain("EventDomain"); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include <inspector/InspectorFrontendRouter.h> +#include <JavaScriptCore/InspectorBackendDispatcher.h> + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr<BackendDispatcher>&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr<BackendDispatcher> m_backendDispatcher; +}; + + +class AlternateCommandDomainBackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~AlternateCommandDomainBackendDispatcher() { } + virtual void commandWithEnumReturnValue(long callId) = 0; +}; + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorBackendDispatcher.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +typedef String ErrorString; + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +class AlternateCommandDomainBackendDispatcher; +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +class CommandDomainBackendDispatcherHandler { +public: + // Named after parameter 'returnValue' while generating command/event commandWithEnumReturnValue. + enum class ReturnValue { + Shared = 0, + Cyan = 6, + Magenta = 7, + Yellow = 8, + }; // enum class ReturnValue + virtual void commandWithEnumReturnValue(ErrorString&, CommandDomainBackendDispatcherHandler::ReturnValue* out_returnValue) = 0; +protected: + virtual ~CommandDomainBackendDispatcherHandler(); +}; + +class CommandDomainBackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref<CommandDomainBackendDispatcher> create(BackendDispatcher&, CommandDomainBackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) override; +private: + void commandWithEnumReturnValue(long requestId, RefPtr<InspectorObject>&& parameters); +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(AlternateCommandDomainBackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + AlternateCommandDomainBackendDispatcher* m_alternateDispatcher { nullptr }; +#endif +private: + CommandDomainBackendDispatcher(BackendDispatcher&, CommandDomainBackendDispatcherHandler*); + CommandDomainBackendDispatcherHandler* m_agent { nullptr }; +}; + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include <inspector/InspectorFrontendRouter.h> +#include <inspector/InspectorValues.h> +#include <wtf/NeverDestroyed.h> +#include <wtf/text/CString.h> + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + +CommandDomainBackendDispatcherHandler::~CommandDomainBackendDispatcherHandler() { } + +Ref<CommandDomainBackendDispatcher> CommandDomainBackendDispatcher::create(BackendDispatcher& backendDispatcher, CommandDomainBackendDispatcherHandler* agent) +{ + return adoptRef(*new CommandDomainBackendDispatcher(backendDispatcher, agent)); +} + +CommandDomainBackendDispatcher::CommandDomainBackendDispatcher(BackendDispatcher& backendDispatcher, CommandDomainBackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("CommandDomain"), this); +} + +void CommandDomainBackendDispatcher::dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) +{ + Ref<CommandDomainBackendDispatcher> protect(*this); + + RefPtr<InspectorObject> parameters; + message->getObject(ASCIILiteral("params"), parameters); + + if (method == "commandWithEnumReturnValue") + commandWithEnumReturnValue(requestId, WTFMove(parameters)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\'', "CommandDomain", '.', method, "' was not found")); +} + +void CommandDomainBackendDispatcher::commandWithEnumReturnValue(long requestId, RefPtr<InspectorObject>&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->commandWithEnumReturnValue(requestId); + return; + } +#endif + + ErrorString error; + Ref<InspectorObject> result = InspectorObject::create(); + CommandDomainBackendDispatcherHandler::ReturnValue out_returnValue; + m_agent->commandWithEnumReturnValue(error, &out_returnValue); + + if (!error.length()) + result->setString(ASCIILiteral("returnValue"), Inspector::Protocol::TestHelpers::getEnumConstantValue(out_returnValue)); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorValues.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +class FrontendRouter; + +class EventDomainFrontendDispatcher { +public: + EventDomainFrontendDispatcher(FrontendRouter& frontendRouter) : m_frontendRouter(frontendRouter) { } + // Named after parameter 'parameter' while generating command/event eventWithEnumParameter. + enum class Parameter { + Shared = 0, + Black = 4, + White = 5, + }; // enum class Parameter + void eventWithEnumParameter(Parameter parameter); +private: + FrontendRouter& m_frontendRouter; +}; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include <wtf/text/CString.h> + +namespace Inspector { + +void EventDomainFrontendDispatcher::eventWithEnumParameter(Parameter parameter) +{ + Ref<InspectorObject> jsonMessage = InspectorObject::create(); + jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("EventDomain.eventWithEnumParameter")); + Ref<InspectorObject> paramsObject = InspectorObject::create(); + paramsObject->setString(ASCIILiteral("parameter"), Inspector::Protocol::TestHelpers::getEnumConstantValue(parameter)); + jsonMessage->setObject(ASCIILiteral("params"), WTFMove(paramsObject)); + + m_frontendRouter.sendEvent(jsonMessage->toJSONString()); +} + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include <inspector/InspectorProtocolTypes.h> +#include <wtf/Assertions.h> + +namespace Inspector { + + + +namespace Protocol { + +// Forward declarations. +namespace TypeDomain { +enum class TypeDomainEnum; +} // TypeDomain +// End of forward declarations. + + + + +namespace TestHelpers { + +String getEnumConstantValue(int code); + +template<typename T> String getEnumConstantValue(T enumValue) +{ + return getEnumConstantValue(static_cast<int>(enumValue)); +} + +} // namespace TestHelpers + +namespace TypeDomain { +/* */ +enum class TypeDomainEnum { + Shared = 0, + Red = 1, + Green = 2, + Blue = 3, +}; // enum class TypeDomainEnum +} // TypeDomain + + + +namespace TestHelpers { + +template<typename ProtocolEnumType> +std::optional<ProtocolEnumType> parseEnumValueFromString(const String&); + +// Enums in the 'TypeDomain' Domain +template<> +std::optional<Inspector::Protocol::TypeDomain::TypeDomainEnum> parseEnumValueFromString<Inspector::Protocol::TypeDomain::TypeDomainEnum>(const String&); + +} // namespace TestHelpers + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include <wtf/Optional.h> +#include <wtf/text/CString.h> + +namespace Inspector { + +namespace Protocol { + +namespace TestHelpers { + +static const char* const enum_constant_values[] = { + "shared", + "red", + "green", + "blue", + "black", + "white", + "cyan", + "magenta", + "yellow", +}; + +String getEnumConstantValue(int code) { + return enum_constant_values[code]; +} + +// Enums in the 'TypeDomain' Domain +template<> +std::optional<Inspector::Protocol::TypeDomain::TypeDomainEnum> parseEnumValueFromString<Inspector::Protocol::TypeDomain::TypeDomainEnum>(const String& protocolString) +{ + static const size_t constantValues[] = { + (size_t)Inspector::Protocol::TypeDomain::TypeDomainEnum::Shared, + (size_t)Inspector::Protocol::TypeDomain::TypeDomainEnum::Red, + (size_t)Inspector::Protocol::TypeDomain::TypeDomainEnum::Green, + (size_t)Inspector::Protocol::TypeDomain::TypeDomainEnum::Blue, + }; + for (size_t i = 0; i < 4; ++i) + if (protocolString == enum_constant_values[constantValues[i]]) + return (Inspector::Protocol::TypeDomain::TypeDomainEnum)constantValues[i]; + + return std::nullopt; +} + + +} // namespace TestHelpers + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#include <wtf/RetainPtr.h> + +@protocol TestProtocolCommandDomainDomainHandler; + +namespace Inspector { + + +class ObjCInspectorCommandDomainBackendDispatcher final : public AlternateCommandDomainBackendDispatcher { +public: + ObjCInspectorCommandDomainBackendDispatcher(id<TestProtocolCommandDomainDomainHandler> handler) { m_delegate = handler; } + virtual void commandWithEnumReturnValue(long requestId) override; +private: + RetainPtr<id<TestProtocolCommandDomainDomainHandler>> m_delegate; +}; + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include <JavaScriptCore/InspectorValues.h> + +namespace Inspector { + +void ObjCInspectorCommandDomainBackendDispatcher::commandWithEnumReturnValue(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^(TestProtocolCommandDomainCommandWithEnumReturnValueReturnValue returnValue) { + Ref<InspectorObject> resultObject = InspectorObject::create(); + resultObject->setString(ASCIILiteral("returnValue"), toProtocolString(returnValue)); + backendDispatcher()->sendResponse(requestId, WTFMove(resultObject)); + }; + + [m_delegate commandWithEnumReturnValueWithErrorCallback:errorCallback successCallback:successCallback]; +} + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <WebInspector/TestProtocol.h> + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@property (nonatomic, retain, setter=setCommandDomainHandler:) id<TestProtocolCommandDomainDomainHandler> commandDomainHandler; +@property (nonatomic, readonly) TestProtocolEventDomainDomainEventDispatcher *eventDomainEventDispatcher; +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import <JavaScriptCore/AlternateDispatchableAgent.h> +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#import <JavaScriptCore/InspectorBackendDispatchers.h> + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; + id<TestProtocolCommandDomainDomainHandler> _commandDomainHandler; + TestProtocolEventDomainDomainEventDispatcher *_eventDomainEventDispatcher; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [_commandDomainHandler release]; + [_eventDomainEventDispatcher release]; + [super dealloc]; +} + +- (void)setCommandDomainHandler:(id<TestProtocolCommandDomainDomainHandler>)handler +{ + if (handler == _commandDomainHandler) + return; + + [_commandDomainHandler release]; + _commandDomainHandler = [handler retain]; + + auto alternateDispatcher = std::make_unique<ObjCInspectorCommandDomainBackendDispatcher>(handler); + auto alternateAgent = std::make_unique<AlternateDispatchableAgent<CommandDomainBackendDispatcher, AlternateCommandDomainBackendDispatcher>>(ASCIILiteral("CommandDomain"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id<TestProtocolCommandDomainDomainHandler>)commandDomainHandler +{ + return _commandDomainHandler; +} + +- (TestProtocolEventDomainDomainEventDispatcher *)eventDomainEventDispatcher +{ + if (!_eventDomainEventDispatcher) + _eventDomainEventDispatcher = [[TestProtocolEventDomainDomainEventDispatcher alloc] initWithController:_controller]; + return _eventDomainEventDispatcher; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <JavaScriptCore/InspectorValues.h> + +using namespace Inspector; + +@implementation TestProtocolEventDomainDomainEventDispatcher +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller; +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)eventWithEnumParameterWithParameter:(TestProtocolEventDomainEventWithEnumParameterParameter)parameter +{ + const FrontendRouter& router = _controller->frontendRouter(); + + Ref<InspectorObject> jsonMessage = InspectorObject::create(); + jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("EventDomain.eventWithEnumParameter")); + Ref<InspectorObject> paramsObject = InspectorObject::create(); + paramsObject->setString(ASCIILiteral("parameter"), toProtocolString(parameter)); + jsonMessage->setObject(ASCIILiteral("params"), WTFMove(paramsObject)); + router.sendEvent(jsonMessage->toJSONString()); +} + +@end + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <Foundation/Foundation.h> + +#import <WebInspector/RWIProtocolJSONObject.h> + + + + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + +typedef NS_ENUM(NSInteger, TestProtocolTypeDomainEnum) { + TestProtocolTypeDomainEnumShared, + TestProtocolTypeDomainEnumRed, + TestProtocolTypeDomainEnumGreen, + TestProtocolTypeDomainEnumBlue, +}; + + + +@protocol TestProtocolCommandDomainDomainHandler <NSObject> +@required +- (void)commandWithEnumReturnValueWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)(TestProtocolCommandDomainCommandWithEnumReturnValueReturnValue returnValue))successCallback; +@end + +__attribute__((visibility ("default"))) +@interface TestProtocolEventDomainDomainEventDispatcher : NSObject +- (void)eventWithEnumParameterWithParameter:(TestProtocolEventDomainEventWithEnumParameterParameter)parameter; +@end + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorValues.h> + +@interface TestProtocolEventDomainDomainEventDispatcher (Private) +- (instancetype)initWithController:(Inspector::AugmentableInspectorController*)controller; +@end + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import <WebInspector/RWIProtocolArrayConversions.h> + +namespace Inspector { + +template<typename ObjCEnumType> +std::optional<ObjCEnumType> fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + +inline String toProtocolString(TestProtocolTypeDomainEnum value) +{ + switch(value) { + case TestProtocolTypeDomainEnumShared: + return ASCIILiteral("shared"); + case TestProtocolTypeDomainEnumRed: + return ASCIILiteral("red"); + case TestProtocolTypeDomainEnumGreen: + return ASCIILiteral("green"); + case TestProtocolTypeDomainEnumBlue: + return ASCIILiteral("blue"); + } +} + +template<> +inline std::optional<TestProtocolTypeDomainEnum> fromProtocolString(const String& value) +{ + if (value == "shared") + return TestProtocolTypeDomainEnumShared; + if (value == "red") + return TestProtocolTypeDomainEnumRed; + if (value == "green") + return TestProtocolTypeDomainEnumGreen; + if (value == "blue") + return TestProtocolTypeDomainEnumBlue; + return std::nullopt; +} + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> + +using namespace Inspector; + +@interface TestProtocolTypeConversions (TypeDomainDomain) + ++ (void)_parseTypeDomainEnum:(NSNumber **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (TypeDomainDomain) + ++ (void)_parseTypeDomainEnum:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + std::optional<TestProtocolTypeDomainEnum> result = Inspector::fromProtocolString<TestProtocolTypeDomainEnum>(payload); + THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"TypeDomainEnum"); + *outValue = @(result.value()); +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from enum-values.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> +#import <JavaScriptCore/InspectorValues.h> +#import <wtf/Assertions.h> + +using namespace Inspector; + + + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/events-with-optional-parameters.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/events-with-optional-parameters.json-result new file mode 100644 index 000000000..137d1827e --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/events-with-optional-parameters.json-result @@ -0,0 +1,1210 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// Database. +InspectorBackend.registerDatabaseDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "Database"); +InspectorBackend.registerEvent("Database.didExecuteOptionalParameters", ["columnNames", "notes", "timestamp", "values", "payload", "sqlError", "screenColor", "alternateColors", "printColor"]); +InspectorBackend.registerEvent("Database.didExecuteNoOptionalParameters", ["columnNames", "notes", "timestamp", "values", "payload", "sqlError", "screenColor", "alternateColors", "printColor"]); +InspectorBackend.activateDomain("Database"); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include <inspector/InspectorFrontendRouter.h> +#include <JavaScriptCore/InspectorBackendDispatcher.h> + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr<BackendDispatcher>&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr<BackendDispatcher> m_backendDispatcher; +}; + + + + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorBackendDispatcher.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +typedef String ErrorString; + + + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include <inspector/InspectorFrontendRouter.h> +#include <inspector/InspectorValues.h> +#include <wtf/NeverDestroyed.h> +#include <wtf/text/CString.h> + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + + + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorValues.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +class FrontendRouter; + +class DatabaseFrontendDispatcher { +public: + DatabaseFrontendDispatcher(FrontendRouter& frontendRouter) : m_frontendRouter(frontendRouter) { } + void didExecuteOptionalParameters(RefPtr<Inspector::Protocol::Array<String>> columnNames, const String* const notes, const double* const timestamp, RefPtr<Inspector::InspectorObject> values, RefPtr<Inspector::InspectorValue> payload, RefPtr<Inspector::Protocol::Database::Error> sqlError, const Inspector::Protocol::Database::PrimaryColors* const screenColor, RefPtr<Inspector::Protocol::Database::ColorList> alternateColors, const String* const printColor); + void didExecuteNoOptionalParameters(RefPtr<Inspector::Protocol::Array<String>> columnNames, const String& notes, double timestamp, RefPtr<Inspector::InspectorObject> values, RefPtr<Inspector::InspectorValue> payload, RefPtr<Inspector::Protocol::Database::Error> sqlError, const Inspector::Protocol::Database::PrimaryColors& screenColor, RefPtr<Inspector::Protocol::Database::ColorList> alternateColors, const String& printColor); +private: + FrontendRouter& m_frontendRouter; +}; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include <wtf/text/CString.h> + +namespace Inspector { + +void DatabaseFrontendDispatcher::didExecuteOptionalParameters(RefPtr<Inspector::Protocol::Array<String>> columnNames, const String* const notes, const double* const timestamp, RefPtr<Inspector::InspectorObject> values, RefPtr<Inspector::InspectorValue> payload, RefPtr<Inspector::Protocol::Database::Error> sqlError, const Inspector::Protocol::Database::PrimaryColors* const screenColor, RefPtr<Inspector::Protocol::Database::ColorList> alternateColors, const String* const printColor) +{ + Ref<InspectorObject> jsonMessage = InspectorObject::create(); + jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("Database.didExecuteOptionalParameters")); + Ref<InspectorObject> paramsObject = InspectorObject::create(); + if (columnNames) + paramsObject->setArray(ASCIILiteral("columnNames"), columnNames); + if (notes) + paramsObject->setString(ASCIILiteral("notes"), *notes); + if (timestamp) + paramsObject->setDouble(ASCIILiteral("timestamp"), *timestamp); + if (values) + paramsObject->setObject(ASCIILiteral("values"), values); + if (payload) + paramsObject->setValue(ASCIILiteral("payload"), *payload); + if (sqlError) + paramsObject->setObject(ASCIILiteral("sqlError"), sqlError); + if (screenColor) + paramsObject->setString(ASCIILiteral("screenColor"), *screenColor); + if (alternateColors) + paramsObject->setArray(ASCIILiteral("alternateColors"), alternateColors); + if (printColor) + paramsObject->setString(ASCIILiteral("printColor"), *printColor); + jsonMessage->setObject(ASCIILiteral("params"), WTFMove(paramsObject)); + + m_frontendRouter.sendEvent(jsonMessage->toJSONString()); +} + +void DatabaseFrontendDispatcher::didExecuteNoOptionalParameters(RefPtr<Inspector::Protocol::Array<String>> columnNames, const String& notes, double timestamp, RefPtr<Inspector::InspectorObject> values, RefPtr<Inspector::InspectorValue> payload, RefPtr<Inspector::Protocol::Database::Error> sqlError, const Inspector::Protocol::Database::PrimaryColors& screenColor, RefPtr<Inspector::Protocol::Database::ColorList> alternateColors, const String& printColor) +{ + Ref<InspectorObject> jsonMessage = InspectorObject::create(); + jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("Database.didExecuteNoOptionalParameters")); + Ref<InspectorObject> paramsObject = InspectorObject::create(); + paramsObject->setArray(ASCIILiteral("columnNames"), columnNames); + paramsObject->setString(ASCIILiteral("notes"), notes); + paramsObject->setDouble(ASCIILiteral("timestamp"), timestamp); + paramsObject->setObject(ASCIILiteral("values"), values); + paramsObject->setValue(ASCIILiteral("payload"), payload); + paramsObject->setObject(ASCIILiteral("sqlError"), sqlError); + paramsObject->setString(ASCIILiteral("screenColor"), screenColor); + paramsObject->setArray(ASCIILiteral("alternateColors"), alternateColors); + paramsObject->setString(ASCIILiteral("printColor"), printColor); + jsonMessage->setObject(ASCIILiteral("params"), WTFMove(paramsObject)); + + m_frontendRouter.sendEvent(jsonMessage->toJSONString()); +} + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include <inspector/InspectorProtocolTypes.h> +#include <wtf/Assertions.h> + +namespace Inspector { + + + +namespace Protocol { + +// Forward declarations. +namespace Database { +class Error; +} // Database +// End of forward declarations. + + +// Typedefs. +namespace Database { +/* Unique identifier of Database object. */ +typedef String DatabaseId; +typedef String PrimaryColors; +typedef Inspector::Protocol::Array<Inspector::Protocol::Database::PrimaryColors> ColorList; +} // Database +// End of typedefs. + +namespace Database { +/* Database error. */ +class Error : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + MessageSet = 1 << 0, + CodeSet = 1 << 1, + AllFieldsSet = (MessageSet | CodeSet) + }; + + template<int STATE> + class Builder { + private: + RefPtr<InspectorObject> m_result; + + template<int STEP> Builder<STATE | STEP>& castState() + { + return *reinterpret_cast<Builder<STATE | STEP>*>(this); + } + + Builder(Ref</*Error*/InspectorObject>&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class Error; + public: + + Builder<STATE | MessageSet>& setMessage(const String& value) + { + COMPILE_ASSERT(!(STATE & MessageSet), property_message_already_set); + m_result->setString(ASCIILiteral("message"), value); + return castState<MessageSet>(); + } + + Builder<STATE | CodeSet>& setCode(int value) + { + COMPILE_ASSERT(!(STATE & CodeSet), property_code_already_set); + m_result->setInteger(ASCIILiteral("code"), value); + return castState<CodeSet>(); + } + + Ref<Error> release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(Error) == sizeof(InspectorObject), cannot_cast); + + Ref<InspectorObject> result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast<Ref<Error>*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref<Error> result = Error::create() + * .setMessage(...) + * .setCode(...) + * .release(); + */ + static Builder<NoFieldsSet> create() + { + return Builder<NoFieldsSet>(InspectorObject::create()); + } +}; + +} // Database + + + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include <wtf/Optional.h> +#include <wtf/text/CString.h> + +namespace Inspector { + +namespace Protocol { + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#include <wtf/RetainPtr.h> + + + +namespace Inspector { + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include <JavaScriptCore/InspectorValues.h> + +namespace Inspector { + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <WebInspector/TestProtocol.h> + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@property (nonatomic, readonly) TestProtocolDatabaseDomainEventDispatcher *databaseEventDispatcher; +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import <JavaScriptCore/AlternateDispatchableAgent.h> +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#import <JavaScriptCore/InspectorBackendDispatchers.h> + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; + TestProtocolDatabaseDomainEventDispatcher *_databaseEventDispatcher; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [_databaseEventDispatcher release]; + [super dealloc]; +} + +- (TestProtocolDatabaseDomainEventDispatcher *)databaseEventDispatcher +{ + if (!_databaseEventDispatcher) + _databaseEventDispatcher = [[TestProtocolDatabaseDomainEventDispatcher alloc] initWithController:_controller]; + return _databaseEventDispatcher; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <JavaScriptCore/InspectorValues.h> + +using namespace Inspector; + +@implementation TestProtocolDatabaseDomainEventDispatcher +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller; +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)didExecuteOptionalParametersWithColumnNames:(NSArray/*<NSString>*/ **)columnNames notes:(NSString **)notes timestamp:(double *)timestamp values:(RWIProtocolJSONObject **)values payload:(RWIProtocolJSONObject **)payload sqlError:(TestProtocolDatabaseError **)sqlError screenColor:(NSString **)screenColor alternateColors:(NSArray/*<NSString>*/ **)alternateColors printColor:(NSString **)printColor +{ + const FrontendRouter& router = _controller->frontendRouter(); + + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(columnNames, @"columnNames"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(notes, @"notes"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(values, @"values"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(payload, @"payload"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(sqlError, @"sqlError"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(screenColor, @"screenColor"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(alternateColors, @"alternateColors"); + THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(printColor, @"printColor"); + + Ref<InspectorObject> jsonMessage = InspectorObject::create(); + jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("Database.didExecuteOptionalParameters")); + Ref<InspectorObject> paramsObject = InspectorObject::create(); + if (columnNames) + paramsObject->setArray(ASCIILiteral("columnNames"), inspectorStringArray((*columnNames))); + if (notes) + paramsObject->setString(ASCIILiteral("notes"), (*notes)); + if (timestamp) + paramsObject->setDouble(ASCIILiteral("timestamp"), (*timestamp)); + if (values) + paramsObject->setObject(ASCIILiteral("values"), [(*values) toInspectorObject]); + if (payload) + paramsObject->setValue(ASCIILiteral("payload"), [(*payload) toInspectorObject]); + if (sqlError) + paramsObject->setObject(ASCIILiteral("sqlError"), [(*sqlError) toInspectorObject]); + if (screenColor) + paramsObject->setString(ASCIILiteral("screenColor"), (*screenColor)); + if (alternateColors) + paramsObject->setArray(ASCIILiteral("alternateColors"), inspectorStringArray((*alternateColors))); + if (printColor) + paramsObject->setString(ASCIILiteral("printColor"), (*printColor)); + jsonMessage->setObject(ASCIILiteral("params"), WTFMove(paramsObject)); + router.sendEvent(jsonMessage->toJSONString()); +} + +- (void)didExecuteNoOptionalParametersWithColumnNames:(NSArray/*<NSString>*/ *)columnNames notes:(NSString *)notes timestamp:(double)timestamp values:(RWIProtocolJSONObject *)values payload:(RWIProtocolJSONObject *)payload sqlError:(TestProtocolDatabaseError *)sqlError screenColor:(NSString *)screenColor alternateColors:(NSArray/*<NSString>*/ *)alternateColors printColor:(NSString *)printColor +{ + const FrontendRouter& router = _controller->frontendRouter(); + + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(columnNames, @"columnNames"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(notes, @"notes"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(values, @"values"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(payload, @"payload"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(sqlError, @"sqlError"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(screenColor, @"screenColor"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(alternateColors, @"alternateColors"); + THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(printColor, @"printColor"); + + Ref<InspectorObject> jsonMessage = InspectorObject::create(); + jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("Database.didExecuteNoOptionalParameters")); + Ref<InspectorObject> paramsObject = InspectorObject::create(); + paramsObject->setArray(ASCIILiteral("columnNames"), inspectorStringArray(columnNames)); + paramsObject->setString(ASCIILiteral("notes"), notes); + paramsObject->setDouble(ASCIILiteral("timestamp"), timestamp); + paramsObject->setObject(ASCIILiteral("values"), [values toInspectorObject]); + paramsObject->setValue(ASCIILiteral("payload"), [payload toInspectorObject]); + paramsObject->setObject(ASCIILiteral("sqlError"), [sqlError toInspectorObject]); + paramsObject->setString(ASCIILiteral("screenColor"), screenColor); + paramsObject->setArray(ASCIILiteral("alternateColors"), inspectorStringArray(alternateColors)); + paramsObject->setString(ASCIILiteral("printColor"), printColor); + jsonMessage->setObject(ASCIILiteral("params"), WTFMove(paramsObject)); + router.sendEvent(jsonMessage->toJSONString()); +} + +@end + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <Foundation/Foundation.h> + +#import <WebInspector/RWIProtocolJSONObject.h> + + +@class TestProtocolDatabaseError; + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + + + +__attribute__((visibility ("default"))) +@interface TestProtocolDatabaseError : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +- (instancetype)initWithMessage:(NSString *)message code:(int)code; +/* required */ @property (nonatomic, copy) NSString *message; +/* required */ @property (nonatomic, assign) int code; +@end + + + +__attribute__((visibility ("default"))) +@interface TestProtocolDatabaseDomainEventDispatcher : NSObject +- (void)didExecuteOptionalParametersWithColumnNames:(NSArray/*<NSString>*/ **)columnNames notes:(NSString **)notes timestamp:(double *)timestamp values:(RWIProtocolJSONObject **)values payload:(RWIProtocolJSONObject **)payload sqlError:(TestProtocolDatabaseError **)sqlError screenColor:(NSString **)screenColor alternateColors:(NSArray/*<NSString>*/ **)alternateColors printColor:(NSString **)printColor; +- (void)didExecuteNoOptionalParametersWithColumnNames:(NSArray/*<NSString>*/ *)columnNames notes:(NSString *)notes timestamp:(double)timestamp values:(RWIProtocolJSONObject *)values payload:(RWIProtocolJSONObject *)payload sqlError:(TestProtocolDatabaseError *)sqlError screenColor:(NSString *)screenColor alternateColors:(NSArray/*<NSString>*/ *)alternateColors printColor:(NSString *)printColor; +@end + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorValues.h> + +@interface TestProtocolDatabaseDomainEventDispatcher (Private) +- (instancetype)initWithController:(Inspector::AugmentableInspectorController*)controller; +@end + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import <WebInspector/RWIProtocolArrayConversions.h> + +namespace Inspector { + +template<typename ObjCEnumType> +std::optional<ObjCEnumType> fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> + +using namespace Inspector; + +@interface TestProtocolTypeConversions (DatabaseDomain) + ++ (void)_parseDatabaseId:(NSString **)outValue fromPayload:(id)payload; ++ (void)_parsePrimaryColors:(NSString **)outValue fromPayload:(id)payload; ++ (void)_parseColorList:(NSArray/*<NSString>*/ **)outValue fromPayload:(id)payload; ++ (void)_parseError:(TestProtocolDatabaseError **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (DatabaseDomain) + ++ (void)_parseDatabaseId:(NSString **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + *outValue = (NSString *)payload; +} + ++ (void)_parsePrimaryColors:(NSString **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + *outValue = (NSString *)payload; +} + ++ (void)_parseColorList:(NSArray/*<NSString>*/ **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSArray/*<NSString>*/ class]); + *outValue = (NSArray/*<NSString>*/ *)payload; +} + ++ (void)_parseError:(TestProtocolDatabaseError **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolDatabaseError alloc] initWithPayload:payload]; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from events-with-optional-parameters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> +#import <JavaScriptCore/InspectorValues.h> +#import <wtf/Assertions.h> + +using namespace Inspector; + + +@implementation TestProtocolDatabaseError + +- (instancetype)initWithPayload:(nonnull NSDictionary<NSString *, id> *)payload +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"message"], @"message"); + self.message = payload[@"message"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"code"], @"code"); + self.code = [payload[@"code"] integerValue]; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (instancetype)initWithMessage:(NSString *)message code:(int)code +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(message, @"message"); + + self.message = message; + self.code = code; + + return self; +} + +- (void)setMessage:(NSString *)message +{ + [super setString:message forKey:@"message"]; +} + +- (NSString *)message +{ + return [super stringForKey:@"message"]; +} + +- (void)setCode:(int)code +{ + [super setInteger:code forKey:@"code"]; +} + +- (int)code +{ + return [super integerForKey:@"code"]; +} + +@end + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-command-with-invalid-platform.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-command-with-invalid-platform.json-error new file mode 100644 index 000000000..ec636c54b --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-command-with-invalid-platform.json-error @@ -0,0 +1 @@ +ERROR: Unknown platform: invalid diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-domain-availability.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-domain-availability.json-error new file mode 100644 index 000000000..90d7195d6 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-domain-availability.json-error @@ -0,0 +1 @@ +ERROR: Malformed domain specification: availability is an unsupported string. Was: "webb", Allowed values: web diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-command-call-parameter-names.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-command-call-parameter-names.json-error new file mode 100644 index 000000000..3f756de32 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-command-call-parameter-names.json-error @@ -0,0 +1 @@ +ERROR: Malformed domain specification: call parameter list for command processPoints has duplicate parameter names diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-command-return-parameter-names.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-command-return-parameter-names.json-error new file mode 100644 index 000000000..ea148ff67 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-command-return-parameter-names.json-error @@ -0,0 +1 @@ +ERROR: Malformed domain specification: return parameter list for command processPoints has duplicate parameter names diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-event-parameter-names.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-event-parameter-names.json-error new file mode 100644 index 000000000..c71bbd21c --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-event-parameter-names.json-error @@ -0,0 +1 @@ +ERROR: Malformed domain specification: parameter list for event processedPoints has duplicate parameter names diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-type-declarations.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-type-declarations.json-error new file mode 100644 index 000000000..447cdf8e2 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-type-declarations.json-error @@ -0,0 +1 @@ +ERROR: Duplicate type declaration: Runtime.RemoteObjectId diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-type-member-names.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-type-member-names.json-error new file mode 100644 index 000000000..d5376a77a --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-duplicate-type-member-names.json-error @@ -0,0 +1 @@ +ERROR: Malformed domain specification: type declaration for Point has duplicate member names diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-enum-with-no-values.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-enum-with-no-values.json-error new file mode 100644 index 000000000..2655c2b90 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-enum-with-no-values.json-error @@ -0,0 +1 @@ +ERROR: Type reference with enum values must have at least one enum value. diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-number-typed-optional-parameter-flag.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-number-typed-optional-parameter-flag.json-error new file mode 100644 index 000000000..97b2af0e4 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-number-typed-optional-parameter-flag.json-error @@ -0,0 +1 @@ +ERROR: The 'optional' flag for a parameter must be a boolean literal. diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-number-typed-optional-type-member.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-number-typed-optional-type-member.json-error new file mode 100644 index 000000000..86df3750c --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-number-typed-optional-type-member.json-error @@ -0,0 +1 @@ +ERROR: The 'optional' flag for a type member must be a boolean literal. diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-string-typed-optional-parameter-flag.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-string-typed-optional-parameter-flag.json-error new file mode 100644 index 000000000..97b2af0e4 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-string-typed-optional-parameter-flag.json-error @@ -0,0 +1 @@ +ERROR: The 'optional' flag for a parameter must be a boolean literal. diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-string-typed-optional-type-member.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-string-typed-optional-type-member.json-error new file mode 100644 index 000000000..86df3750c --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-string-typed-optional-type-member.json-error @@ -0,0 +1 @@ +ERROR: The 'optional' flag for a type member must be a boolean literal. diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-declaration-using-type-reference.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-declaration-using-type-reference.json-error new file mode 100644 index 000000000..42f5753a4 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-declaration-using-type-reference.json-error @@ -0,0 +1 @@ +ERROR: Type reference cannot have both 'type' and '$ref' keys. diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-reference-as-primitive-type.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-reference-as-primitive-type.json-error new file mode 100644 index 000000000..d76bc1c77 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-reference-as-primitive-type.json-error @@ -0,0 +1 @@ +ERROR: Type reference 'DatabaseId' is not a primitive type. Allowed values: integer, number, string, boolean, enum, object, array, any diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-with-invalid-platform.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-with-invalid-platform.json-error new file mode 100644 index 000000000..ec636c54b --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-with-invalid-platform.json-error @@ -0,0 +1 @@ +ERROR: Unknown platform: invalid diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-with-lowercase-name.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-with-lowercase-name.json-error new file mode 100644 index 000000000..4e462250c --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-type-with-lowercase-name.json-error @@ -0,0 +1 @@ +ERROR: Types must begin with an uppercase character. diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-unknown-type-reference-in-type-declaration.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-unknown-type-reference-in-type-declaration.json-error new file mode 100644 index 000000000..2d38e6467 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-unknown-type-reference-in-type-declaration.json-error @@ -0,0 +1 @@ +ERROR: Type reference 'dragon' is not a primitive type. Allowed values: integer, number, string, boolean, enum, object, array, any diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-unknown-type-reference-in-type-member.json-error b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-unknown-type-reference-in-type-member.json-error new file mode 100644 index 000000000..faf6672cb --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/fail-on-unknown-type-reference-in-type-member.json-error @@ -0,0 +1 @@ +ERROR: Lookup failed for type reference: Color (referenced from domain: Fantasy) diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/generate-domains-with-feature-guards.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/generate-domains-with-feature-guards.json-result new file mode 100644 index 000000000..9eeb0b1c9 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/generate-domains-with-feature-guards.json-result @@ -0,0 +1,1230 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// Network1. +InspectorBackend.registerCommand("Network1.loadResource", [], []); +InspectorBackend.activateDomain("Network1"); + +// Network3. +InspectorBackend.registerNetwork3Dispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "Network3"); +InspectorBackend.registerEvent("Network3.resourceLoaded", []); +InspectorBackend.activateDomain("Network3"); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include <inspector/InspectorFrontendRouter.h> +#include <JavaScriptCore/InspectorBackendDispatcher.h> + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr<BackendDispatcher>&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr<BackendDispatcher> m_backendDispatcher; +}; + + +#if PLATFORM(WEB_COMMANDS) +class AlternateNetwork1BackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~AlternateNetwork1BackendDispatcher() { } + virtual void loadResource(long callId) = 0; +}; +#endif // PLATFORM(WEB_COMMANDS) + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorBackendDispatcher.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +typedef String ErrorString; + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#if PLATFORM(WEB_COMMANDS) +class AlternateNetwork1BackendDispatcher; +#endif // PLATFORM(WEB_COMMANDS) +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#if PLATFORM(WEB_COMMANDS) +class Network1BackendDispatcherHandler { +public: + virtual void loadResource(ErrorString&) = 0; +protected: + virtual ~Network1BackendDispatcherHandler(); +}; +#endif // PLATFORM(WEB_COMMANDS) + +#if PLATFORM(WEB_COMMANDS) +class Network1BackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref<Network1BackendDispatcher> create(BackendDispatcher&, Network1BackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) override; +private: + void loadResource(long requestId, RefPtr<InspectorObject>&& parameters); +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(AlternateNetwork1BackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + AlternateNetwork1BackendDispatcher* m_alternateDispatcher { nullptr }; +#endif +private: + Network1BackendDispatcher(BackendDispatcher&, Network1BackendDispatcherHandler*); + Network1BackendDispatcherHandler* m_agent { nullptr }; +}; +#endif // PLATFORM(WEB_COMMANDS) + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include <inspector/InspectorFrontendRouter.h> +#include <inspector/InspectorValues.h> +#include <wtf/NeverDestroyed.h> +#include <wtf/text/CString.h> + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + +#if PLATFORM(WEB_COMMANDS) +Network1BackendDispatcherHandler::~Network1BackendDispatcherHandler() { } +#endif // PLATFORM(WEB_COMMANDS) + +#if PLATFORM(WEB_COMMANDS) +Ref<Network1BackendDispatcher> Network1BackendDispatcher::create(BackendDispatcher& backendDispatcher, Network1BackendDispatcherHandler* agent) +{ + return adoptRef(*new Network1BackendDispatcher(backendDispatcher, agent)); +} + +Network1BackendDispatcher::Network1BackendDispatcher(BackendDispatcher& backendDispatcher, Network1BackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("Network1"), this); +} + +void Network1BackendDispatcher::dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) +{ + Ref<Network1BackendDispatcher> protect(*this); + + RefPtr<InspectorObject> parameters; + message->getObject(ASCIILiteral("params"), parameters); + + if (method == "loadResource") + loadResource(requestId, WTFMove(parameters)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\'', "Network1", '.', method, "' was not found")); +} + +void Network1BackendDispatcher::loadResource(long requestId, RefPtr<InspectorObject>&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->loadResource(requestId); + return; + } +#endif + + ErrorString error; + Ref<InspectorObject> result = InspectorObject::create(); + m_agent->loadResource(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} +#endif // PLATFORM(WEB_COMMANDS) + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorValues.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +class FrontendRouter; + +#if PLATFORM(WEB_EVENTS) +class Network3FrontendDispatcher { +public: + Network3FrontendDispatcher(FrontendRouter& frontendRouter) : m_frontendRouter(frontendRouter) { } + void resourceLoaded(); +private: + FrontendRouter& m_frontendRouter; +}; +#endif // PLATFORM(WEB_EVENTS) + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include <wtf/text/CString.h> + +namespace Inspector { + +#if PLATFORM(WEB_EVENTS) +void Network3FrontendDispatcher::resourceLoaded() +{ + Ref<InspectorObject> jsonMessage = InspectorObject::create(); + jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("Network3.resourceLoaded")); + + m_frontendRouter.sendEvent(jsonMessage->toJSONString()); +} +#endif // PLATFORM(WEB_EVENTS) + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include <inspector/InspectorProtocolTypes.h> +#include <wtf/Assertions.h> + +namespace Inspector { + + + +namespace Protocol { + +// Forward declarations. +#if PLATFORM(WEB_TYPES) +namespace Network2 { +class NetworkError; +} // Network2 +#endif // PLATFORM(WEB_TYPES) +// End of forward declarations. + + + + +#if PLATFORM(WEB_TYPES) +namespace Network2 { +class NetworkError : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + MessageSet = 1 << 0, + CodeSet = 1 << 1, + AllFieldsSet = (MessageSet | CodeSet) + }; + + template<int STATE> + class Builder { + private: + RefPtr<InspectorObject> m_result; + + template<int STEP> Builder<STATE | STEP>& castState() + { + return *reinterpret_cast<Builder<STATE | STEP>*>(this); + } + + Builder(Ref</*NetworkError*/InspectorObject>&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class NetworkError; + public: + + Builder<STATE | MessageSet>& setMessage(const String& value) + { + COMPILE_ASSERT(!(STATE & MessageSet), property_message_already_set); + m_result->setString(ASCIILiteral("message"), value); + return castState<MessageSet>(); + } + + Builder<STATE | CodeSet>& setCode(int value) + { + COMPILE_ASSERT(!(STATE & CodeSet), property_code_already_set); + m_result->setInteger(ASCIILiteral("code"), value); + return castState<CodeSet>(); + } + + Ref<NetworkError> release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(NetworkError) == sizeof(InspectorObject), cannot_cast); + + Ref<InspectorObject> result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast<Ref<NetworkError>*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref<NetworkError> result = NetworkError::create() + * .setMessage(...) + * .setCode(...) + * .release(); + */ + static Builder<NoFieldsSet> create() + { + return Builder<NoFieldsSet>(InspectorObject::create()); + } +}; + +} // Network2 +#endif // PLATFORM(WEB_TYPES) + + + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include <wtf/Optional.h> +#include <wtf/text/CString.h> + +namespace Inspector { + +namespace Protocol { + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#include <wtf/RetainPtr.h> + +@protocol TestProtocolNetwork1DomainHandler; + +namespace Inspector { + + +#if PLATFORM(WEB_COMMANDS) +class ObjCInspectorNetwork1BackendDispatcher final : public AlternateNetwork1BackendDispatcher { +public: + ObjCInspectorNetwork1BackendDispatcher(id<TestProtocolNetwork1DomainHandler> handler) { m_delegate = handler; } + virtual void loadResource(long requestId) override; +private: + RetainPtr<id<TestProtocolNetwork1DomainHandler>> m_delegate; +}; +#endif // PLATFORM(WEB_COMMANDS) + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include <JavaScriptCore/InspectorValues.h> + +namespace Inspector { + +#if PLATFORM(WEB_COMMANDS) +void ObjCInspectorNetwork1BackendDispatcher::loadResource(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate loadResourceWithErrorCallback:errorCallback successCallback:successCallback]; +} + +#endif // PLATFORM(WEB_COMMANDS) + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <WebInspector/TestProtocol.h> + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@property (nonatomic, retain, setter=setNetwork1Handler:) id<TestProtocolNetwork1DomainHandler> network1Handler; +@property (nonatomic, readonly) TestProtocolNetwork3DomainEventDispatcher *network3EventDispatcher; +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import <JavaScriptCore/AlternateDispatchableAgent.h> +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#import <JavaScriptCore/InspectorBackendDispatchers.h> + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; + id<TestProtocolNetwork1DomainHandler> _network1Handler; + TestProtocolNetwork3DomainEventDispatcher *_network3EventDispatcher; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [_network1Handler release]; + [_network3EventDispatcher release]; + [super dealloc]; +} + +- (void)setNetwork1Handler:(id<TestProtocolNetwork1DomainHandler>)handler +{ + if (handler == _network1Handler) + return; + + [_network1Handler release]; + _network1Handler = [handler retain]; + + auto alternateDispatcher = std::make_unique<ObjCInspectorNetwork1BackendDispatcher>(handler); + auto alternateAgent = std::make_unique<AlternateDispatchableAgent<Network1BackendDispatcher, AlternateNetwork1BackendDispatcher>>(ASCIILiteral("Network1"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id<TestProtocolNetwork1DomainHandler>)network1Handler +{ + return _network1Handler; +} + +- (TestProtocolNetwork3DomainEventDispatcher *)network3EventDispatcher +{ + if (!_network3EventDispatcher) + _network3EventDispatcher = [[TestProtocolNetwork3DomainEventDispatcher alloc] initWithController:_controller]; + return _network3EventDispatcher; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <JavaScriptCore/InspectorValues.h> + +using namespace Inspector; + +@implementation TestProtocolNetwork3DomainEventDispatcher +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller; +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)resourceLoaded +{ + const FrontendRouter& router = _controller->frontendRouter(); + + Ref<InspectorObject> jsonMessage = InspectorObject::create(); + jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("Network3.resourceLoaded")); + router.sendEvent(jsonMessage->toJSONString()); +} + +@end + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <Foundation/Foundation.h> + +#import <WebInspector/RWIProtocolJSONObject.h> + + +@class TestProtocolNetwork2NetworkError; + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + + + +__attribute__((visibility ("default"))) +@interface TestProtocolNetwork2NetworkError : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +- (instancetype)initWithMessage:(NSString *)message code:(int)code; +/* required */ @property (nonatomic, copy) NSString *message; +/* required */ @property (nonatomic, assign) int code; +@end + +@protocol TestProtocolNetwork1DomainHandler <NSObject> +@required +- (void)loadResourceWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +@end + +__attribute__((visibility ("default"))) +@interface TestProtocolNetwork3DomainEventDispatcher : NSObject +- (void)resourceLoaded; +@end + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorValues.h> + +@interface TestProtocolNetwork3DomainEventDispatcher (Private) +- (instancetype)initWithController:(Inspector::AugmentableInspectorController*)controller; +@end + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import <WebInspector/RWIProtocolArrayConversions.h> + +namespace Inspector { + +template<typename ObjCEnumType> +std::optional<ObjCEnumType> fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> + +using namespace Inspector; + +@interface TestProtocolTypeConversions (Network2Domain) + ++ (void)_parseNetworkError:(TestProtocolNetwork2NetworkError **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (Network2Domain) + ++ (void)_parseNetworkError:(TestProtocolNetwork2NetworkError **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolNetwork2NetworkError alloc] initWithPayload:payload]; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-domains-with-feature-guards.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> +#import <JavaScriptCore/InspectorValues.h> +#import <wtf/Assertions.h> + +using namespace Inspector; + + +@implementation TestProtocolNetwork2NetworkError + +- (instancetype)initWithPayload:(nonnull NSDictionary<NSString *, id> *)payload +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"message"], @"message"); + self.message = payload[@"message"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"code"], @"code"); + self.code = [payload[@"code"] integerValue]; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (instancetype)initWithMessage:(NSString *)message code:(int)code +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(message, @"message"); + + self.message = message; + self.code = code; + + return self; +} + +- (void)setMessage:(NSString *)message +{ + [super setString:message forKey:@"message"]; +} + +- (NSString *)message +{ + return [super stringForKey:@"message"]; +} + +- (void)setCode:(int)code +{ + [super setInteger:code forKey:@"code"]; +} + +- (int)code +{ + return [super integerForKey:@"code"]; +} + +@end + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/same-type-id-different-domain.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/same-type-id-different-domain.json-result new file mode 100644 index 000000000..d65129eb8 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/same-type-id-different-domain.json-result @@ -0,0 +1,910 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include <inspector/InspectorFrontendRouter.h> +#include <JavaScriptCore/InspectorBackendDispatcher.h> + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr<BackendDispatcher>&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr<BackendDispatcher> m_backendDispatcher; +}; + + + + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorBackendDispatcher.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +typedef String ErrorString; + + + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include <inspector/InspectorFrontendRouter.h> +#include <inspector/InspectorValues.h> +#include <wtf/NeverDestroyed.h> +#include <wtf/text/CString.h> + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + + + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorValues.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include <wtf/text/CString.h> + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include <inspector/InspectorProtocolTypes.h> +#include <wtf/Assertions.h> + +namespace Inspector { + + + +namespace Protocol { + + + +// Typedefs. +namespace Runtime { +/* Unique object identifier. */ +typedef String RemoteObjectId; +} // Runtime + +namespace Runtime2 { +/* Unique object identifier. */ +typedef String RemoteObjectId; +} // Runtime2 +// End of typedefs. + + + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include <wtf/Optional.h> +#include <wtf/text/CString.h> + +namespace Inspector { + +namespace Protocol { + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#include <wtf/RetainPtr.h> + + + +namespace Inspector { + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include <JavaScriptCore/InspectorValues.h> + +namespace Inspector { + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <WebInspector/TestProtocol.h> + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import <JavaScriptCore/AlternateDispatchableAgent.h> +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#import <JavaScriptCore/InspectorBackendDispatchers.h> + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [super dealloc]; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <JavaScriptCore/InspectorValues.h> + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <Foundation/Foundation.h> + +#import <WebInspector/RWIProtocolJSONObject.h> + + + + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + + + + + + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorValues.h> + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import <WebInspector/RWIProtocolArrayConversions.h> + +namespace Inspector { + +template<typename ObjCEnumType> +std::optional<ObjCEnumType> fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + + + + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> + +using namespace Inspector; + +@interface TestProtocolTypeConversions (RuntimeDomain) + ++ (void)_parseRemoteObjectId:(NSString **)outValue fromPayload:(id)payload; + +@end +@interface TestProtocolTypeConversions (Runtime2Domain) + ++ (void)_parseRemoteObjectId:(NSString **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (RuntimeDomain) + ++ (void)_parseRemoteObjectId:(NSString **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + *outValue = (NSString *)payload; +} + +@end +@implementation TestProtocolTypeConversions (Runtime2Domain) + ++ (void)_parseRemoteObjectId:(NSString **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + *outValue = (NSString *)payload; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from same-type-id-different-domain.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> +#import <JavaScriptCore/InspectorValues.h> +#import <wtf/Assertions.h> + +using namespace Inspector; + + + + + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/shadowed-optional-type-setters.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/shadowed-optional-type-setters.json-result new file mode 100644 index 000000000..b7eff1b15 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/shadowed-optional-type-setters.json-result @@ -0,0 +1,1119 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include <inspector/InspectorFrontendRouter.h> +#include <JavaScriptCore/InspectorBackendDispatcher.h> + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr<BackendDispatcher>&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr<BackendDispatcher> m_backendDispatcher; +}; + + + + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorBackendDispatcher.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +typedef String ErrorString; + + + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include <inspector/InspectorFrontendRouter.h> +#include <inspector/InspectorValues.h> +#include <wtf/NeverDestroyed.h> +#include <wtf/text/CString.h> + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + + + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorValues.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include <wtf/text/CString.h> + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include <inspector/InspectorProtocolTypes.h> +#include <wtf/Assertions.h> + +namespace Inspector { + + + +namespace Protocol { + +// Forward declarations. +namespace Runtime { +class KeyPath; +} // Runtime +// End of forward declarations. + + + + +namespace TestHelpers { + +String getEnumConstantValue(int code); + +template<typename T> String getEnumConstantValue(T enumValue) +{ + return getEnumConstantValue(static_cast<int>(enumValue)); +} + +} // namespace TestHelpers + +namespace Runtime { +/* Key path. */ +class KeyPath : public Inspector::InspectorObjectBase { +public: + // Named after property name 'type' while generating KeyPath. + enum class Type { + Null = 0, + String = 1, + Array = 2, + }; // enum class Type + enum { + NoFieldsSet = 0, + TypeSet = 1 << 0, + AllFieldsSet = (TypeSet) + }; + + template<int STATE> + class Builder { + private: + RefPtr<InspectorObject> m_result; + + template<int STEP> Builder<STATE | STEP>& castState() + { + return *reinterpret_cast<Builder<STATE | STEP>*>(this); + } + + Builder(Ref</*KeyPath*/InspectorObject>&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class KeyPath; + public: + + Builder<STATE | TypeSet>& setType(Type value) + { + COMPILE_ASSERT(!(STATE & TypeSet), property_type_already_set); + m_result->setString(ASCIILiteral("type"), Inspector::Protocol::TestHelpers::getEnumConstantValue(value)); + return castState<TypeSet>(); + } + + Ref<KeyPath> release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(KeyPath) == sizeof(InspectorObject), cannot_cast); + + Ref<InspectorObject> result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast<Ref<KeyPath>*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref<KeyPath> result = KeyPath::create() + * .setType(...) + * .release(); + */ + static Builder<NoFieldsSet> create() + { + return Builder<NoFieldsSet>(InspectorObject::create()); + } + + void setString(const String& value) + { + InspectorObjectBase::setString(ASCIILiteral("string"), value); + } + + void setArray(RefPtr<Inspector::Protocol::Array<String>> value) + { + InspectorObjectBase::setArray(ASCIILiteral("array"), WTFMove(value)); + } +}; + +} // Runtime + + + +namespace TestHelpers { + +template<typename ProtocolEnumType> +std::optional<ProtocolEnumType> parseEnumValueFromString(const String&); + +// Enums in the 'Runtime' Domain +template<> +std::optional<Inspector::Protocol::Runtime::KeyPath::Type> parseEnumValueFromString<Inspector::Protocol::Runtime::KeyPath::Type>(const String&); + +} // namespace TestHelpers + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include <wtf/Optional.h> +#include <wtf/text/CString.h> + +namespace Inspector { + +namespace Protocol { + +namespace TestHelpers { + +static const char* const enum_constant_values[] = { + "null", + "string", + "array", +}; + +String getEnumConstantValue(int code) { + return enum_constant_values[code]; +} + +// Enums in the 'Runtime' Domain +template<> +std::optional<Inspector::Protocol::Runtime::KeyPath::Type> parseEnumValueFromString<Inspector::Protocol::Runtime::KeyPath::Type>(const String& protocolString) +{ + static const size_t constantValues[] = { + (size_t)Inspector::Protocol::Runtime::KeyPath::Type::Null, + (size_t)Inspector::Protocol::Runtime::KeyPath::Type::String, + (size_t)Inspector::Protocol::Runtime::KeyPath::Type::Array, + }; + for (size_t i = 0; i < 3; ++i) + if (protocolString == enum_constant_values[constantValues[i]]) + return (Inspector::Protocol::Runtime::KeyPath::Type)constantValues[i]; + + return std::nullopt; +} + + +} // namespace TestHelpers + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#include <wtf/RetainPtr.h> + + + +namespace Inspector { + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include <JavaScriptCore/InspectorValues.h> + +namespace Inspector { + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <WebInspector/TestProtocol.h> + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import <JavaScriptCore/AlternateDispatchableAgent.h> +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#import <JavaScriptCore/InspectorBackendDispatchers.h> + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [super dealloc]; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <JavaScriptCore/InspectorValues.h> + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <Foundation/Foundation.h> + +#import <WebInspector/RWIProtocolJSONObject.h> + + +@class TestProtocolRuntimeKeyPath; + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + +typedef NS_ENUM(NSInteger, TestProtocolRuntimeKeyPathType) { + TestProtocolRuntimeKeyPathTypeNull, + TestProtocolRuntimeKeyPathTypeString, + TestProtocolRuntimeKeyPathTypeArray, +}; + + +__attribute__((visibility ("default"))) +@interface TestProtocolRuntimeKeyPath : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +- (instancetype)initWithType:(TestProtocolRuntimeKeyPathType)type; +/* required */ @property (nonatomic, assign) TestProtocolRuntimeKeyPathType type; +/* optional */ @property (nonatomic, copy) NSString *string; +/* optional */ @property (nonatomic, copy) NSArray/*<NSString>*/ *array; +@end + + + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorValues.h> + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import <WebInspector/RWIProtocolArrayConversions.h> + +namespace Inspector { + +template<typename ObjCEnumType> +std::optional<ObjCEnumType> fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + +inline String toProtocolString(TestProtocolRuntimeKeyPathType value) +{ + switch(value) { + case TestProtocolRuntimeKeyPathTypeNull: + return ASCIILiteral("null"); + case TestProtocolRuntimeKeyPathTypeString: + return ASCIILiteral("string"); + case TestProtocolRuntimeKeyPathTypeArray: + return ASCIILiteral("array"); + } +} + +template<> +inline std::optional<TestProtocolRuntimeKeyPathType> fromProtocolString(const String& value) +{ + if (value == "null") + return TestProtocolRuntimeKeyPathTypeNull; + if (value == "string") + return TestProtocolRuntimeKeyPathTypeString; + if (value == "array") + return TestProtocolRuntimeKeyPathTypeArray; + return std::nullopt; +} + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> + +using namespace Inspector; + +@interface TestProtocolTypeConversions (RuntimeDomain) + ++ (void)_parseKeyPath:(TestProtocolRuntimeKeyPath **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (RuntimeDomain) + ++ (void)_parseKeyPath:(TestProtocolRuntimeKeyPath **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolRuntimeKeyPath alloc] initWithPayload:payload]; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from shadowed-optional-type-setters.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> +#import <JavaScriptCore/InspectorValues.h> +#import <wtf/Assertions.h> + +using namespace Inspector; + + +@implementation TestProtocolRuntimeKeyPath + +- (instancetype)initWithPayload:(nonnull NSDictionary<NSString *, id> *)payload +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"type"], @"type"); + std::optional<TestProtocolRuntimeKeyPathType> type = fromProtocolString<TestProtocolRuntimeKeyPathType>(payload[@"type"]); + THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(type, @"type"); + self.type = type.value(); + + self.string = payload[@"string"]; + + self.array = objcArrayFromPayload<NSString>(payload[@"array"]); + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (instancetype)initWithType:(TestProtocolRuntimeKeyPathType)type +{ + if (!(self = [super init])) + return nil; + + self.type = type; + + return self; +} + +- (void)setType:(TestProtocolRuntimeKeyPathType)type +{ + [super setString:toProtocolString(type) forKey:@"type"]; +} + +- (TestProtocolRuntimeKeyPathType)type +{ + return fromProtocolString<TestProtocolRuntimeKeyPathType>([super stringForKey:@"type"]).value(); +} + +- (void)setString:(NSString *)string +{ + [super setString:string forKey:@"string"]; +} + +- (NSString *)string +{ + return [super stringForKey:@"string"]; +} + +- (void)setArray:(NSArray/*<NSString>*/ *)array +{ + [super setInspectorArray:inspectorStringArray(array) forKey:@"array"]; +} + +- (NSArray/*<NSString>*/ *)array +{ + return objcStringArray([super inspectorArrayForKey:@"array"]); +} + +@end + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-aliased-primitive-type.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-aliased-primitive-type.json-result new file mode 100644 index 000000000..6ece43d9c --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-aliased-primitive-type.json-result @@ -0,0 +1,887 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include <inspector/InspectorFrontendRouter.h> +#include <JavaScriptCore/InspectorBackendDispatcher.h> + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr<BackendDispatcher>&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr<BackendDispatcher> m_backendDispatcher; +}; + + + + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorBackendDispatcher.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +typedef String ErrorString; + + + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include <inspector/InspectorFrontendRouter.h> +#include <inspector/InspectorValues.h> +#include <wtf/NeverDestroyed.h> +#include <wtf/text/CString.h> + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + + + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorValues.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include <wtf/text/CString.h> + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include <inspector/InspectorProtocolTypes.h> +#include <wtf/Assertions.h> + +namespace Inspector { + + + +namespace Protocol { + + + +// Typedefs. +namespace Runtime { +/* Unique object identifier. */ +typedef int RemoteObjectId; +} // Runtime +// End of typedefs. + + + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include <wtf/Optional.h> +#include <wtf/text/CString.h> + +namespace Inspector { + +namespace Protocol { + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#include <wtf/RetainPtr.h> + + + +namespace Inspector { + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include <JavaScriptCore/InspectorValues.h> + +namespace Inspector { + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <WebInspector/TestProtocol.h> + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import <JavaScriptCore/AlternateDispatchableAgent.h> +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#import <JavaScriptCore/InspectorBackendDispatchers.h> + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [super dealloc]; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <JavaScriptCore/InspectorValues.h> + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <Foundation/Foundation.h> + +#import <WebInspector/RWIProtocolJSONObject.h> + + + + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + + + + + + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorValues.h> + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import <WebInspector/RWIProtocolArrayConversions.h> + +namespace Inspector { + +template<typename ObjCEnumType> +std::optional<ObjCEnumType> fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> + +using namespace Inspector; + +@interface TestProtocolTypeConversions (RuntimeDomain) + ++ (void)_parseRemoteObjectId:(NSNumber **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (RuntimeDomain) + ++ (void)_parseRemoteObjectId:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSNumber class]); + *outValue = (NSNumber *)payload; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-aliased-primitive-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> +#import <JavaScriptCore/InspectorValues.h> +#import <wtf/Assertions.h> + +using namespace Inspector; + + + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result new file mode 100644 index 000000000..d2a62c9ff --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result @@ -0,0 +1,1055 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// Debugger. +InspectorBackend.registerEnum("Debugger.Reason", {Died: "Died", Fainted: "Fainted", Hungry: "Hungry"}); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include <inspector/InspectorFrontendRouter.h> +#include <JavaScriptCore/InspectorBackendDispatcher.h> + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr<BackendDispatcher>&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr<BackendDispatcher> m_backendDispatcher; +}; + + + + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorBackendDispatcher.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +typedef String ErrorString; + + + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include <inspector/InspectorFrontendRouter.h> +#include <inspector/InspectorValues.h> +#include <wtf/NeverDestroyed.h> +#include <wtf/text/CString.h> + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + + + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorValues.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include <wtf/text/CString.h> + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include <inspector/InspectorProtocolTypes.h> +#include <wtf/Assertions.h> + +namespace Inspector { + + + +namespace Protocol { + +// Forward declarations. +namespace Debugger { +enum class Reason; +} // Debugger +// End of forward declarations. + + +// Typedefs. +namespace Debugger { +typedef int BreakpointId; +} // Debugger + +namespace Runtime { +typedef int ObjectId; +typedef Inspector::Protocol::Array<int> LuckyNumbers; +typedef Inspector::Protocol::Array<String> BabyNames; +typedef Inspector::Protocol::Array<Inspector::Protocol::Runtime::ObjectId> NewObjects; +typedef Inspector::Protocol::Array<Inspector::Protocol::Debugger::BreakpointId> OldObjects; +typedef Inspector::Protocol::Array<Inspector::Protocol::Debugger::Reason> StopReasons; +} // Runtime +// End of typedefs. + +namespace TestHelpers { + +String getEnumConstantValue(int code); + +template<typename T> String getEnumConstantValue(T enumValue) +{ + return getEnumConstantValue(static_cast<int>(enumValue)); +} + +} // namespace TestHelpers + +namespace Debugger { +/* */ +enum class Reason { + Died = 0, + Fainted = 1, + Hungry = 2, +}; // enum class Reason +} // Debugger + + + +namespace TestHelpers { + +template<typename ProtocolEnumType> +std::optional<ProtocolEnumType> parseEnumValueFromString(const String&); + +// Enums in the 'Debugger' Domain +template<> +std::optional<Inspector::Protocol::Debugger::Reason> parseEnumValueFromString<Inspector::Protocol::Debugger::Reason>(const String&); + +} // namespace TestHelpers + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include <wtf/Optional.h> +#include <wtf/text/CString.h> + +namespace Inspector { + +namespace Protocol { + +namespace TestHelpers { + +static const char* const enum_constant_values[] = { + "Died", + "Fainted", + "Hungry", +}; + +String getEnumConstantValue(int code) { + return enum_constant_values[code]; +} + +// Enums in the 'Debugger' Domain +template<> +std::optional<Inspector::Protocol::Debugger::Reason> parseEnumValueFromString<Inspector::Protocol::Debugger::Reason>(const String& protocolString) +{ + static const size_t constantValues[] = { + (size_t)Inspector::Protocol::Debugger::Reason::Died, + (size_t)Inspector::Protocol::Debugger::Reason::Fainted, + (size_t)Inspector::Protocol::Debugger::Reason::Hungry, + }; + for (size_t i = 0; i < 3; ++i) + if (protocolString == enum_constant_values[constantValues[i]]) + return (Inspector::Protocol::Debugger::Reason)constantValues[i]; + + return std::nullopt; +} + + +} // namespace TestHelpers + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#include <wtf/RetainPtr.h> + + + +namespace Inspector { + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include <JavaScriptCore/InspectorValues.h> + +namespace Inspector { + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <WebInspector/TestProtocol.h> + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import <JavaScriptCore/AlternateDispatchableAgent.h> +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#import <JavaScriptCore/InspectorBackendDispatchers.h> + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [super dealloc]; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <JavaScriptCore/InspectorValues.h> + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <Foundation/Foundation.h> + +#import <WebInspector/RWIProtocolJSONObject.h> + + + + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + +typedef NS_ENUM(NSInteger, TestProtocolDebuggerReason) { + TestProtocolDebuggerReasonDied, + TestProtocolDebuggerReasonFainted, + TestProtocolDebuggerReasonHungry, +}; + + + + + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorValues.h> + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import <WebInspector/RWIProtocolArrayConversions.h> + +namespace Inspector { + +template<typename ObjCEnumType> +std::optional<ObjCEnumType> fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + +inline String toProtocolString(TestProtocolDebuggerReason value) +{ + switch(value) { + case TestProtocolDebuggerReasonDied: + return ASCIILiteral("Died"); + case TestProtocolDebuggerReasonFainted: + return ASCIILiteral("Fainted"); + case TestProtocolDebuggerReasonHungry: + return ASCIILiteral("Hungry"); + } +} + +template<> +inline std::optional<TestProtocolDebuggerReason> fromProtocolString(const String& value) +{ + if (value == "Died") + return TestProtocolDebuggerReasonDied; + if (value == "Fainted") + return TestProtocolDebuggerReasonFainted; + if (value == "Hungry") + return TestProtocolDebuggerReasonHungry; + return std::nullopt; +} + + + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> + +using namespace Inspector; + +@interface TestProtocolTypeConversions (DebuggerDomain) + ++ (void)_parseBreakpointId:(NSNumber **)outValue fromPayload:(id)payload; ++ (void)_parseReason:(NSNumber **)outValue fromPayload:(id)payload; + +@end +@interface TestProtocolTypeConversions (RuntimeDomain) + ++ (void)_parseObjectId:(NSNumber **)outValue fromPayload:(id)payload; ++ (void)_parseLuckyNumbers:(NSArray/*<NSNumber>*/ **)outValue fromPayload:(id)payload; ++ (void)_parseBabyNames:(NSArray/*<NSString>*/ **)outValue fromPayload:(id)payload; ++ (void)_parseNewObjects:(NSArray/*<NSNumber>*/ **)outValue fromPayload:(id)payload; ++ (void)_parseOldObjects:(NSArray/*<NSNumber>*/ **)outValue fromPayload:(id)payload; ++ (void)_parseStopReasons:(NSArray/*<NSString>*/ **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (DebuggerDomain) + ++ (void)_parseBreakpointId:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSNumber class]); + *outValue = (NSNumber *)payload; +} + ++ (void)_parseReason:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + std::optional<TestProtocolDebuggerReason> result = Inspector::fromProtocolString<TestProtocolDebuggerReason>(payload); + THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"Reason"); + *outValue = @(result.value()); +} + +@end +@implementation TestProtocolTypeConversions (RuntimeDomain) + ++ (void)_parseObjectId:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSNumber class]); + *outValue = (NSNumber *)payload; +} + ++ (void)_parseLuckyNumbers:(NSArray/*<NSNumber>*/ **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSArray/*<NSNumber>*/ class]); + *outValue = (NSArray/*<NSNumber>*/ *)payload; +} + ++ (void)_parseBabyNames:(NSArray/*<NSString>*/ **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSArray/*<NSString>*/ class]); + *outValue = (NSArray/*<NSString>*/ *)payload; +} + ++ (void)_parseNewObjects:(NSArray/*<NSNumber>*/ **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSArray/*<NSNumber>*/ class]); + *outValue = (NSArray/*<NSNumber>*/ *)payload; +} + ++ (void)_parseOldObjects:(NSArray/*<NSNumber>*/ **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSArray/*<NSNumber>*/ class]); + *outValue = (NSArray/*<NSNumber>*/ *)payload; +} + ++ (void)_parseStopReasons:(NSArray/*<NSString>*/ **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSArray/*<NSString>*/ class]); + *outValue = (NSArray/*<NSString>*/ *)payload; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-array-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> +#import <JavaScriptCore/InspectorValues.h> +#import <wtf/Assertions.h> + +using namespace Inspector; + + + + + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result new file mode 100644 index 000000000..a1cfcf54b --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result @@ -0,0 +1,1064 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// Runtime. +InspectorBackend.registerEnum("Runtime.FarmAnimals", {Pigs: "Pigs", Cows: "Cows", Cats: "Cats", Hens: "Hens"}); +InspectorBackend.registerEnum("Runtime.TwoLeggedAnimals", {Ducks: "Ducks", Hens: "Hens", Crows: "Crows", Flamingos: "Flamingos"}); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include <inspector/InspectorFrontendRouter.h> +#include <JavaScriptCore/InspectorBackendDispatcher.h> + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr<BackendDispatcher>&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr<BackendDispatcher> m_backendDispatcher; +}; + + + + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorBackendDispatcher.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +typedef String ErrorString; + + + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include <inspector/InspectorFrontendRouter.h> +#include <inspector/InspectorValues.h> +#include <wtf/NeverDestroyed.h> +#include <wtf/text/CString.h> + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + + + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorValues.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include <wtf/text/CString.h> + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include <inspector/InspectorProtocolTypes.h> +#include <wtf/Assertions.h> + +namespace Inspector { + + + +namespace Protocol { + +// Forward declarations. +namespace Runtime { +enum class FarmAnimals; +enum class TwoLeggedAnimals; +} // Runtime +// End of forward declarations. + + + + +namespace TestHelpers { + +String getEnumConstantValue(int code); + +template<typename T> String getEnumConstantValue(T enumValue) +{ + return getEnumConstantValue(static_cast<int>(enumValue)); +} + +} // namespace TestHelpers + +namespace Runtime { +/* */ +enum class FarmAnimals { + Pigs = 0, + Cows = 1, + Cats = 2, + Hens = 3, +}; // enum class FarmAnimals +/* */ +enum class TwoLeggedAnimals { + Ducks = 4, + Hens = 3, + Crows = 5, + Flamingos = 6, +}; // enum class TwoLeggedAnimals +} // Runtime + + + +namespace TestHelpers { + +template<typename ProtocolEnumType> +std::optional<ProtocolEnumType> parseEnumValueFromString(const String&); + +// Enums in the 'Runtime' Domain +template<> +std::optional<Inspector::Protocol::Runtime::FarmAnimals> parseEnumValueFromString<Inspector::Protocol::Runtime::FarmAnimals>(const String&); +template<> +std::optional<Inspector::Protocol::Runtime::TwoLeggedAnimals> parseEnumValueFromString<Inspector::Protocol::Runtime::TwoLeggedAnimals>(const String&); + +} // namespace TestHelpers + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include <wtf/Optional.h> +#include <wtf/text/CString.h> + +namespace Inspector { + +namespace Protocol { + +namespace TestHelpers { + +static const char* const enum_constant_values[] = { + "Pigs", + "Cows", + "Cats", + "Hens", + "Ducks", + "Crows", + "Flamingos", +}; + +String getEnumConstantValue(int code) { + return enum_constant_values[code]; +} + +// Enums in the 'Runtime' Domain +template<> +std::optional<Inspector::Protocol::Runtime::FarmAnimals> parseEnumValueFromString<Inspector::Protocol::Runtime::FarmAnimals>(const String& protocolString) +{ + static const size_t constantValues[] = { + (size_t)Inspector::Protocol::Runtime::FarmAnimals::Pigs, + (size_t)Inspector::Protocol::Runtime::FarmAnimals::Cows, + (size_t)Inspector::Protocol::Runtime::FarmAnimals::Cats, + (size_t)Inspector::Protocol::Runtime::FarmAnimals::Hens, + }; + for (size_t i = 0; i < 4; ++i) + if (protocolString == enum_constant_values[constantValues[i]]) + return (Inspector::Protocol::Runtime::FarmAnimals)constantValues[i]; + + return std::nullopt; +} + +template<> +std::optional<Inspector::Protocol::Runtime::TwoLeggedAnimals> parseEnumValueFromString<Inspector::Protocol::Runtime::TwoLeggedAnimals>(const String& protocolString) +{ + static const size_t constantValues[] = { + (size_t)Inspector::Protocol::Runtime::TwoLeggedAnimals::Ducks, + (size_t)Inspector::Protocol::Runtime::TwoLeggedAnimals::Hens, + (size_t)Inspector::Protocol::Runtime::TwoLeggedAnimals::Crows, + (size_t)Inspector::Protocol::Runtime::TwoLeggedAnimals::Flamingos, + }; + for (size_t i = 0; i < 4; ++i) + if (protocolString == enum_constant_values[constantValues[i]]) + return (Inspector::Protocol::Runtime::TwoLeggedAnimals)constantValues[i]; + + return std::nullopt; +} + + +} // namespace TestHelpers + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#include <wtf/RetainPtr.h> + + + +namespace Inspector { + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include <JavaScriptCore/InspectorValues.h> + +namespace Inspector { + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <WebInspector/TestProtocol.h> + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import <JavaScriptCore/AlternateDispatchableAgent.h> +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#import <JavaScriptCore/InspectorBackendDispatchers.h> + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [super dealloc]; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <JavaScriptCore/InspectorValues.h> + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <Foundation/Foundation.h> + +#import <WebInspector/RWIProtocolJSONObject.h> + + + + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + +typedef NS_ENUM(NSInteger, TestProtocolRuntimeFarmAnimals) { + TestProtocolRuntimeFarmAnimalsPigs, + TestProtocolRuntimeFarmAnimalsCows, + TestProtocolRuntimeFarmAnimalsCats, + TestProtocolRuntimeFarmAnimalsHens, +}; + +typedef NS_ENUM(NSInteger, TestProtocolRuntimeTwoLeggedAnimals) { + TestProtocolRuntimeTwoLeggedAnimalsDucks, + TestProtocolRuntimeTwoLeggedAnimalsHens, + TestProtocolRuntimeTwoLeggedAnimalsCrows, + TestProtocolRuntimeTwoLeggedAnimalsFlamingos, +}; + + + + + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorValues.h> + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import <WebInspector/RWIProtocolArrayConversions.h> + +namespace Inspector { + +template<typename ObjCEnumType> +std::optional<ObjCEnumType> fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + +inline String toProtocolString(TestProtocolRuntimeFarmAnimals value) +{ + switch(value) { + case TestProtocolRuntimeFarmAnimalsPigs: + return ASCIILiteral("Pigs"); + case TestProtocolRuntimeFarmAnimalsCows: + return ASCIILiteral("Cows"); + case TestProtocolRuntimeFarmAnimalsCats: + return ASCIILiteral("Cats"); + case TestProtocolRuntimeFarmAnimalsHens: + return ASCIILiteral("Hens"); + } +} + +template<> +inline std::optional<TestProtocolRuntimeFarmAnimals> fromProtocolString(const String& value) +{ + if (value == "Pigs") + return TestProtocolRuntimeFarmAnimalsPigs; + if (value == "Cows") + return TestProtocolRuntimeFarmAnimalsCows; + if (value == "Cats") + return TestProtocolRuntimeFarmAnimalsCats; + if (value == "Hens") + return TestProtocolRuntimeFarmAnimalsHens; + return std::nullopt; +} + +inline String toProtocolString(TestProtocolRuntimeTwoLeggedAnimals value) +{ + switch(value) { + case TestProtocolRuntimeTwoLeggedAnimalsDucks: + return ASCIILiteral("Ducks"); + case TestProtocolRuntimeTwoLeggedAnimalsHens: + return ASCIILiteral("Hens"); + case TestProtocolRuntimeTwoLeggedAnimalsCrows: + return ASCIILiteral("Crows"); + case TestProtocolRuntimeTwoLeggedAnimalsFlamingos: + return ASCIILiteral("Flamingos"); + } +} + +template<> +inline std::optional<TestProtocolRuntimeTwoLeggedAnimals> fromProtocolString(const String& value) +{ + if (value == "Ducks") + return TestProtocolRuntimeTwoLeggedAnimalsDucks; + if (value == "Hens") + return TestProtocolRuntimeTwoLeggedAnimalsHens; + if (value == "Crows") + return TestProtocolRuntimeTwoLeggedAnimalsCrows; + if (value == "Flamingos") + return TestProtocolRuntimeTwoLeggedAnimalsFlamingos; + return std::nullopt; +} + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> + +using namespace Inspector; + +@interface TestProtocolTypeConversions (RuntimeDomain) + ++ (void)_parseFarmAnimals:(NSNumber **)outValue fromPayload:(id)payload; ++ (void)_parseTwoLeggedAnimals:(NSNumber **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (RuntimeDomain) + ++ (void)_parseFarmAnimals:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + std::optional<TestProtocolRuntimeFarmAnimals> result = Inspector::fromProtocolString<TestProtocolRuntimeFarmAnimals>(payload); + THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"FarmAnimals"); + *outValue = @(result.value()); +} + ++ (void)_parseTwoLeggedAnimals:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + std::optional<TestProtocolRuntimeTwoLeggedAnimals> result = Inspector::fromProtocolString<TestProtocolRuntimeTwoLeggedAnimals>(payload); + THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"TwoLeggedAnimals"); + *outValue = @(result.value()); +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-enum-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> +#import <JavaScriptCore/InspectorValues.h> +#import <wtf/Assertions.h> + +using namespace Inspector; + + + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result new file mode 100644 index 000000000..1b23ab2a9 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result @@ -0,0 +1,2012 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include <inspector/InspectorFrontendRouter.h> +#include <JavaScriptCore/InspectorBackendDispatcher.h> + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr<BackendDispatcher>&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr<BackendDispatcher> m_backendDispatcher; +}; + + + + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorBackendDispatcher.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +typedef String ErrorString; + + + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include <inspector/InspectorFrontendRouter.h> +#include <inspector/InspectorValues.h> +#include <wtf/NeverDestroyed.h> +#include <wtf/text/CString.h> + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + + + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorValues.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include <wtf/text/CString.h> + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include <inspector/InspectorProtocolTypes.h> +#include <wtf/Assertions.h> + +namespace Inspector { + + + +namespace Protocol { + +// Forward declarations. +namespace Database { +class Error; +class OptionalParameterBundle; +class ParameterBundle; +class ObjectWithPropertyNameConflicts; +class DummyObject; +} // Database + +namespace Test { +class ParameterBundle; +} // Test +// End of forward declarations. + + +// Typedefs. +namespace Database { +typedef Inspector::Protocol::Array<Inspector::Protocol::Database::Error> ErrorList; +} // Database +// End of typedefs. + +namespace Database { +/* Database error. */ +class Error : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + MessageSet = 1 << 0, + CodeSet = 1 << 1, + AllFieldsSet = (MessageSet | CodeSet) + }; + + template<int STATE> + class Builder { + private: + RefPtr<InspectorObject> m_result; + + template<int STEP> Builder<STATE | STEP>& castState() + { + return *reinterpret_cast<Builder<STATE | STEP>*>(this); + } + + Builder(Ref</*Error*/InspectorObject>&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class Error; + public: + + Builder<STATE | MessageSet>& setMessage(const String& value) + { + COMPILE_ASSERT(!(STATE & MessageSet), property_message_already_set); + m_result->setString(ASCIILiteral("message"), value); + return castState<MessageSet>(); + } + + Builder<STATE | CodeSet>& setCode(int value) + { + COMPILE_ASSERT(!(STATE & CodeSet), property_code_already_set); + m_result->setInteger(ASCIILiteral("code"), value); + return castState<CodeSet>(); + } + + Ref<Error> release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(Error) == sizeof(InspectorObject), cannot_cast); + + Ref<InspectorObject> result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast<Ref<Error>*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref<Error> result = Error::create() + * .setMessage(...) + * .setCode(...) + * .release(); + */ + static Builder<NoFieldsSet> create() + { + return Builder<NoFieldsSet>(InspectorObject::create()); + } +}; + +class OptionalParameterBundle : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + AllFieldsSet = 0 + }; + + template<int STATE> + class Builder { + private: + RefPtr<InspectorObject> m_result; + + template<int STEP> Builder<STATE | STEP>& castState() + { + return *reinterpret_cast<Builder<STATE | STEP>*>(this); + } + + Builder(Ref</*OptionalParameterBundle*/InspectorObject>&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class OptionalParameterBundle; + public: + + Ref<OptionalParameterBundle> release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(OptionalParameterBundle) == sizeof(InspectorObject), cannot_cast); + + Ref<InspectorObject> result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast<Ref<OptionalParameterBundle>*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref<OptionalParameterBundle> result = OptionalParameterBundle::create() + * .release(); + */ + static Builder<NoFieldsSet> create() + { + return Builder<NoFieldsSet>(InspectorObject::create()); + } + + void setColumnNames(RefPtr<Inspector::Protocol::Array<String>> value) + { + InspectorObjectBase::setArray(ASCIILiteral("columnNames"), WTFMove(value)); + } + + void setNotes(const String& value) + { + InspectorObjectBase::setString(ASCIILiteral("notes"), value); + } + + void setTimestamp(double value) + { + InspectorObjectBase::setDouble(ASCIILiteral("timestamp"), value); + } + + void setValues(RefPtr<Inspector::InspectorObject> value) + { + InspectorObjectBase::setObject(ASCIILiteral("values"), WTFMove(value)); + } + + void setPayload(RefPtr<Inspector::InspectorValue> value) + { + InspectorObjectBase::setValue(ASCIILiteral("payload"), WTFMove(value)); + } + + void setError(RefPtr<Inspector::Protocol::Database::Error> value) + { + InspectorObjectBase::setObject(ASCIILiteral("error"), WTFMove(value)); + } + + void setErrorList(RefPtr<Inspector::Protocol::Database::ErrorList> value) + { + InspectorObjectBase::setArray(ASCIILiteral("errorList"), WTFMove(value)); + } +}; + +class ParameterBundle : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + ColumnNamesSet = 1 << 0, + NotesSet = 1 << 1, + TimestampSet = 1 << 2, + ValuesSet = 1 << 3, + PayloadSet = 1 << 4, + ErrorSet = 1 << 5, + ErrorListSet = 1 << 6, + AllFieldsSet = (ColumnNamesSet | NotesSet | TimestampSet | ValuesSet | PayloadSet | ErrorSet | ErrorListSet) + }; + + template<int STATE> + class Builder { + private: + RefPtr<InspectorObject> m_result; + + template<int STEP> Builder<STATE | STEP>& castState() + { + return *reinterpret_cast<Builder<STATE | STEP>*>(this); + } + + Builder(Ref</*ParameterBundle*/InspectorObject>&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class ParameterBundle; + public: + + Builder<STATE | ColumnNamesSet>& setColumnNames(RefPtr<Inspector::Protocol::Array<String>> value) + { + COMPILE_ASSERT(!(STATE & ColumnNamesSet), property_columnNames_already_set); + m_result->setArray(ASCIILiteral("columnNames"), value); + return castState<ColumnNamesSet>(); + } + + Builder<STATE | NotesSet>& setNotes(const String& value) + { + COMPILE_ASSERT(!(STATE & NotesSet), property_notes_already_set); + m_result->setString(ASCIILiteral("notes"), value); + return castState<NotesSet>(); + } + + Builder<STATE | TimestampSet>& setTimestamp(double value) + { + COMPILE_ASSERT(!(STATE & TimestampSet), property_timestamp_already_set); + m_result->setDouble(ASCIILiteral("timestamp"), value); + return castState<TimestampSet>(); + } + + Builder<STATE | ValuesSet>& setValues(RefPtr<Inspector::InspectorObject> value) + { + COMPILE_ASSERT(!(STATE & ValuesSet), property_values_already_set); + m_result->setObject(ASCIILiteral("values"), value); + return castState<ValuesSet>(); + } + + Builder<STATE | PayloadSet>& setPayload(RefPtr<Inspector::InspectorValue> value) + { + COMPILE_ASSERT(!(STATE & PayloadSet), property_payload_already_set); + m_result->setValue(ASCIILiteral("payload"), value); + return castState<PayloadSet>(); + } + + Builder<STATE | ErrorSet>& setError(RefPtr<Inspector::Protocol::Database::Error> value) + { + COMPILE_ASSERT(!(STATE & ErrorSet), property_error_already_set); + m_result->setObject(ASCIILiteral("error"), value); + return castState<ErrorSet>(); + } + + Builder<STATE | ErrorListSet>& setErrorList(RefPtr<Inspector::Protocol::Database::ErrorList> value) + { + COMPILE_ASSERT(!(STATE & ErrorListSet), property_errorList_already_set); + m_result->setArray(ASCIILiteral("errorList"), value); + return castState<ErrorListSet>(); + } + + Ref<ParameterBundle> release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(ParameterBundle) == sizeof(InspectorObject), cannot_cast); + + Ref<InspectorObject> result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast<Ref<ParameterBundle>*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref<ParameterBundle> result = ParameterBundle::create() + * .setColumnNames(...) + * .setNotes(...) + * .setTimestamp(...) + * .setValues(...) + * .setPayload(...) + * .setError(...) + * .setErrorList(...) + * .release(); + */ + static Builder<NoFieldsSet> create() + { + return Builder<NoFieldsSet>(InspectorObject::create()); + } +}; + +/* Conflicted names may cause generated getters/setters to clash with built-in InspectorObject methods. */ +class ObjectWithPropertyNameConflicts : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + IntegerSet = 1 << 0, + ArraySet = 1 << 1, + StringSet = 1 << 2, + ValueSet = 1 << 3, + ObjectSet = 1 << 4, + AllFieldsSet = (IntegerSet | ArraySet | StringSet | ValueSet | ObjectSet) + }; + + template<int STATE> + class Builder { + private: + RefPtr<InspectorObject> m_result; + + template<int STEP> Builder<STATE | STEP>& castState() + { + return *reinterpret_cast<Builder<STATE | STEP>*>(this); + } + + Builder(Ref</*ObjectWithPropertyNameConflicts*/InspectorObject>&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class ObjectWithPropertyNameConflicts; + public: + + Builder<STATE | IntegerSet>& setInteger(const String& value) + { + COMPILE_ASSERT(!(STATE & IntegerSet), property_integer_already_set); + m_result->setString(ASCIILiteral("integer"), value); + return castState<IntegerSet>(); + } + + Builder<STATE | ArraySet>& setArray(const String& value) + { + COMPILE_ASSERT(!(STATE & ArraySet), property_array_already_set); + m_result->setString(ASCIILiteral("array"), value); + return castState<ArraySet>(); + } + + Builder<STATE | StringSet>& setString(const String& value) + { + COMPILE_ASSERT(!(STATE & StringSet), property_string_already_set); + m_result->setString(ASCIILiteral("string"), value); + return castState<StringSet>(); + } + + Builder<STATE | ValueSet>& setValue(const String& value) + { + COMPILE_ASSERT(!(STATE & ValueSet), property_value_already_set); + m_result->setString(ASCIILiteral("value"), value); + return castState<ValueSet>(); + } + + Builder<STATE | ObjectSet>& setObject(const String& value) + { + COMPILE_ASSERT(!(STATE & ObjectSet), property_object_already_set); + m_result->setString(ASCIILiteral("object"), value); + return castState<ObjectSet>(); + } + + Ref<ObjectWithPropertyNameConflicts> release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(ObjectWithPropertyNameConflicts) == sizeof(InspectorObject), cannot_cast); + + Ref<InspectorObject> result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast<Ref<ObjectWithPropertyNameConflicts>*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref<ObjectWithPropertyNameConflicts> result = ObjectWithPropertyNameConflicts::create() + * .setInteger(...) + * .setArray(...) + * .setString(...) + * .setValue(...) + * .setObject(...) + * .release(); + */ + static Builder<NoFieldsSet> create() + { + return Builder<NoFieldsSet>(InspectorObject::create()); + } +}; + +} // Database + +namespace Test { +class ParameterBundle : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + ColumnNamesSet = 1 << 0, + NotesSet = 1 << 1, + TimestampSet = 1 << 2, + ValuesSet = 1 << 3, + PayloadSet = 1 << 4, + ErrorSet = 1 << 5, + AllFieldsSet = (ColumnNamesSet | NotesSet | TimestampSet | ValuesSet | PayloadSet | ErrorSet) + }; + + template<int STATE> + class Builder { + private: + RefPtr<InspectorObject> m_result; + + template<int STEP> Builder<STATE | STEP>& castState() + { + return *reinterpret_cast<Builder<STATE | STEP>*>(this); + } + + Builder(Ref</*ParameterBundle*/InspectorObject>&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class ParameterBundle; + public: + + Builder<STATE | ColumnNamesSet>& setColumnNames(RefPtr<Inspector::Protocol::Array<String>> value) + { + COMPILE_ASSERT(!(STATE & ColumnNamesSet), property_columnNames_already_set); + m_result->setArray(ASCIILiteral("columnNames"), value); + return castState<ColumnNamesSet>(); + } + + Builder<STATE | NotesSet>& setNotes(const String& value) + { + COMPILE_ASSERT(!(STATE & NotesSet), property_notes_already_set); + m_result->setString(ASCIILiteral("notes"), value); + return castState<NotesSet>(); + } + + Builder<STATE | TimestampSet>& setTimestamp(double value) + { + COMPILE_ASSERT(!(STATE & TimestampSet), property_timestamp_already_set); + m_result->setDouble(ASCIILiteral("timestamp"), value); + return castState<TimestampSet>(); + } + + Builder<STATE | ValuesSet>& setValues(RefPtr<Inspector::InspectorObject> value) + { + COMPILE_ASSERT(!(STATE & ValuesSet), property_values_already_set); + m_result->setObject(ASCIILiteral("values"), value); + return castState<ValuesSet>(); + } + + Builder<STATE | PayloadSet>& setPayload(RefPtr<Inspector::InspectorValue> value) + { + COMPILE_ASSERT(!(STATE & PayloadSet), property_payload_already_set); + m_result->setValue(ASCIILiteral("payload"), value); + return castState<PayloadSet>(); + } + + Builder<STATE | ErrorSet>& setError(RefPtr<Inspector::Protocol::Database::Error> value) + { + COMPILE_ASSERT(!(STATE & ErrorSet), property_error_already_set); + m_result->setObject(ASCIILiteral("error"), value); + return castState<ErrorSet>(); + } + + Ref<ParameterBundle> release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(ParameterBundle) == sizeof(InspectorObject), cannot_cast); + + Ref<InspectorObject> result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast<Ref<ParameterBundle>*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref<ParameterBundle> result = ParameterBundle::create() + * .setColumnNames(...) + * .setNotes(...) + * .setTimestamp(...) + * .setValues(...) + * .setPayload(...) + * .setError(...) + * .release(); + */ + static Builder<NoFieldsSet> create() + { + return Builder<NoFieldsSet>(InspectorObject::create()); + } +}; + +} // Test + + + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include <wtf/Optional.h> +#include <wtf/text/CString.h> + +namespace Inspector { + +namespace Protocol { + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#include <wtf/RetainPtr.h> + + + +namespace Inspector { + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include <JavaScriptCore/InspectorValues.h> + +namespace Inspector { + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <WebInspector/TestProtocol.h> + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import <JavaScriptCore/AlternateDispatchableAgent.h> +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#import <JavaScriptCore/InspectorBackendDispatchers.h> + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [super dealloc]; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <JavaScriptCore/InspectorValues.h> + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <Foundation/Foundation.h> + +#import <WebInspector/RWIProtocolJSONObject.h> + + +@class TestProtocolDatabaseError; +@class TestProtocolDatabaseOptionalParameterBundle; +@class TestProtocolDatabaseParameterBundle; +@class TestProtocolDatabaseObjectWithPropertyNameConflicts; +@class TestProtocolDatabaseDummyObject; +@class TestProtocolTestParameterBundle; + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + + + +__attribute__((visibility ("default"))) +@interface TestProtocolDatabaseError : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +- (instancetype)initWithMessage:(NSString *)message code:(int)code; +/* required */ @property (nonatomic, copy) NSString *message; +/* required */ @property (nonatomic, assign) int code; +@end + +__attribute__((visibility ("default"))) +@interface TestProtocolDatabaseOptionalParameterBundle : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +/* optional */ @property (nonatomic, copy) NSArray/*<NSString>*/ *columnNames; +/* optional */ @property (nonatomic, copy) NSString *notes; +/* optional */ @property (nonatomic, assign) double timestamp; +/* optional */ @property (nonatomic, retain) RWIProtocolJSONObject *values; +/* optional */ @property (nonatomic, retain) RWIProtocolJSONObject *payload; +/* optional */ @property (nonatomic, retain) TestProtocolDatabaseError *error; +/* optional */ @property (nonatomic, copy) NSArray/*<TestProtocolDatabaseError>*/ *errorList; +@end + +__attribute__((visibility ("default"))) +@interface TestProtocolDatabaseParameterBundle : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +- (instancetype)initWithColumnNames:(NSArray/*<NSString>*/ *)columnNames notes:(NSString *)notes timestamp:(double)timestamp values:(RWIProtocolJSONObject *)values payload:(RWIProtocolJSONObject *)payload error:(TestProtocolDatabaseError *)error errorList:(NSArray/*<TestProtocolDatabaseError>*/ *)errorList; +/* required */ @property (nonatomic, copy) NSArray/*<NSString>*/ *columnNames; +/* required */ @property (nonatomic, copy) NSString *notes; +/* required */ @property (nonatomic, assign) double timestamp; +/* required */ @property (nonatomic, retain) RWIProtocolJSONObject *values; +/* required */ @property (nonatomic, retain) RWIProtocolJSONObject *payload; +/* required */ @property (nonatomic, retain) TestProtocolDatabaseError *error; +/* required */ @property (nonatomic, copy) NSArray/*<TestProtocolDatabaseError>*/ *errorList; +@end + +__attribute__((visibility ("default"))) +@interface TestProtocolDatabaseObjectWithPropertyNameConflicts : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +- (instancetype)initWithInteger:(NSString *)integer array:(NSString *)array string:(NSString *)string value:(NSString *)value object:(NSString *)object; +/* required */ @property (nonatomic, copy) NSString *integer; +/* required */ @property (nonatomic, copy) NSString *array; +/* required */ @property (nonatomic, copy) NSString *string; +/* required */ @property (nonatomic, copy) NSString *value; +/* required */ @property (nonatomic, copy) NSString *object; +@end + +__attribute__((visibility ("default"))) +@interface TestProtocolDatabaseDummyObject : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +@end + +__attribute__((visibility ("default"))) +@interface TestProtocolTestParameterBundle : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +- (instancetype)initWithColumnNames:(NSArray/*<NSString>*/ *)columnNames notes:(NSString *)notes timestamp:(double)timestamp values:(RWIProtocolJSONObject *)values payload:(RWIProtocolJSONObject *)payload error:(TestProtocolDatabaseError *)error; +/* required */ @property (nonatomic, copy) NSArray/*<NSString>*/ *columnNames; +/* required */ @property (nonatomic, copy) NSString *notes; +/* required */ @property (nonatomic, assign) double timestamp; +/* required */ @property (nonatomic, retain) RWIProtocolJSONObject *values; +/* required */ @property (nonatomic, retain) RWIProtocolJSONObject *payload; +/* required */ @property (nonatomic, retain) TestProtocolDatabaseError *error; +@end + + + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorValues.h> + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import <WebInspector/RWIProtocolArrayConversions.h> + +namespace Inspector { + +template<typename ObjCEnumType> +std::optional<ObjCEnumType> fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + + + + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> + +using namespace Inspector; + +@interface TestProtocolTypeConversions (DatabaseDomain) + ++ (void)_parseError:(TestProtocolDatabaseError **)outValue fromPayload:(id)payload; ++ (void)_parseErrorList:(NSArray/*<TestProtocolDatabaseError>*/ **)outValue fromPayload:(id)payload; ++ (void)_parseOptionalParameterBundle:(TestProtocolDatabaseOptionalParameterBundle **)outValue fromPayload:(id)payload; ++ (void)_parseParameterBundle:(TestProtocolDatabaseParameterBundle **)outValue fromPayload:(id)payload; ++ (void)_parseObjectWithPropertyNameConflicts:(TestProtocolDatabaseObjectWithPropertyNameConflicts **)outValue fromPayload:(id)payload; ++ (void)_parseDummyObject:(TestProtocolDatabaseDummyObject **)outValue fromPayload:(id)payload; + +@end +@interface TestProtocolTypeConversions (TestDomain) + ++ (void)_parseParameterBundle:(TestProtocolTestParameterBundle **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (DatabaseDomain) + ++ (void)_parseError:(TestProtocolDatabaseError **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolDatabaseError alloc] initWithPayload:payload]; +} + ++ (void)_parseErrorList:(NSArray/*<TestProtocolDatabaseError>*/ **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSArray/*<TestProtocolDatabaseError>*/ class]); + *outValue = (NSArray/*<TestProtocolDatabaseError>*/ *)payload; +} + ++ (void)_parseOptionalParameterBundle:(TestProtocolDatabaseOptionalParameterBundle **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolDatabaseOptionalParameterBundle alloc] initWithPayload:payload]; +} + ++ (void)_parseParameterBundle:(TestProtocolDatabaseParameterBundle **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolDatabaseParameterBundle alloc] initWithPayload:payload]; +} + ++ (void)_parseObjectWithPropertyNameConflicts:(TestProtocolDatabaseObjectWithPropertyNameConflicts **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolDatabaseObjectWithPropertyNameConflicts alloc] initWithPayload:payload]; +} + ++ (void)_parseDummyObject:(TestProtocolDatabaseDummyObject **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolDatabaseDummyObject alloc] initWithPayload:payload]; +} + +@end +@implementation TestProtocolTypeConversions (TestDomain) + ++ (void)_parseParameterBundle:(TestProtocolTestParameterBundle **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolTestParameterBundle alloc] initWithPayload:payload]; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-declaration-object-type.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> +#import <JavaScriptCore/InspectorValues.h> +#import <wtf/Assertions.h> + +using namespace Inspector; + + +@implementation TestProtocolDatabaseError + +- (instancetype)initWithPayload:(nonnull NSDictionary<NSString *, id> *)payload +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"message"], @"message"); + self.message = payload[@"message"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"code"], @"code"); + self.code = [payload[@"code"] integerValue]; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (instancetype)initWithMessage:(NSString *)message code:(int)code +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(message, @"message"); + + self.message = message; + self.code = code; + + return self; +} + +- (void)setMessage:(NSString *)message +{ + [super setString:message forKey:@"message"]; +} + +- (NSString *)message +{ + return [super stringForKey:@"message"]; +} + +- (void)setCode:(int)code +{ + [super setInteger:code forKey:@"code"]; +} + +- (int)code +{ + return [super integerForKey:@"code"]; +} + +@end + +@implementation TestProtocolDatabaseOptionalParameterBundle + +- (instancetype)initWithPayload:(nonnull NSDictionary<NSString *, id> *)payload +{ + if (!(self = [super init])) + return nil; + + self.columnNames = objcArrayFromPayload<NSString>(payload[@"columnNames"]); + + self.notes = payload[@"notes"]; + + self.timestamp = [payload[@"timestamp"] doubleValue]; + + self.values = payload[@"values"]; + + self.payload = payload[@"payload"]; + + self.error = [[TestProtocolDatabaseError alloc] initWithPayload:payload[@"error"]]; + + self.errorList = objcArrayFromPayload<TestProtocolDatabaseError>(payload[@"errorList"]); + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (void)setColumnNames:(NSArray/*<NSString>*/ *)columnNames +{ + [super setInspectorArray:inspectorStringArray(columnNames) forKey:@"columnNames"]; +} + +- (NSArray/*<NSString>*/ *)columnNames +{ + return objcStringArray([super inspectorArrayForKey:@"columnNames"]); +} + +- (void)setNotes:(NSString *)notes +{ + [super setString:notes forKey:@"notes"]; +} + +- (NSString *)notes +{ + return [super stringForKey:@"notes"]; +} + +- (void)setTimestamp:(double)timestamp +{ + [super setDouble:timestamp forKey:@"timestamp"]; +} + +- (double)timestamp +{ + return [super doubleForKey:@"timestamp"]; +} + +- (void)setValues:(RWIProtocolJSONObject *)values +{ + [super setObject:values forKey:@"values"]; +} + +- (RWIProtocolJSONObject *)values +{ + return [[RWIProtocolJSONObject alloc] initWithInspectorObject:[[super objectForKey:@"values"] toInspectorObject].get()]; +} + +- (void)setPayload:(RWIProtocolJSONObject *)payload +{ + [super setObject:payload forKey:@"payload"]; +} + +- (RWIProtocolJSONObject *)payload +{ + return [[RWIProtocolJSONObject alloc] initWithInspectorObject:[[super objectForKey:@"payload"] toInspectorObject].get()]; +} + +- (void)setError:(TestProtocolDatabaseError *)error +{ + [super setObject:error forKey:@"error"]; +} + +- (TestProtocolDatabaseError *)error +{ + return [[TestProtocolDatabaseError alloc] initWithInspectorObject:[[super objectForKey:@"error"] toInspectorObject].get()]; +} + +- (void)setErrorList:(NSArray/*<TestProtocolDatabaseError>*/ *)errorList +{ + THROW_EXCEPTION_FOR_BAD_TYPE_IN_ARRAY(errorList, [TestProtocolDatabaseError class]); + [super setInspectorArray:inspectorObjectArray(errorList) forKey:@"errorList"]; +} + +- (NSArray/*<TestProtocolDatabaseError>*/ *)errorList +{ + return objcArray<TestProtocolDatabaseError>([super inspectorArrayForKey:@"errorList"]); +} + +@end + +@implementation TestProtocolDatabaseParameterBundle + +- (instancetype)initWithPayload:(nonnull NSDictionary<NSString *, id> *)payload +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"columnNames"], @"columnNames"); + self.columnNames = objcArrayFromPayload<NSString>(payload[@"columnNames"]); + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"notes"], @"notes"); + self.notes = payload[@"notes"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"timestamp"], @"timestamp"); + self.timestamp = [payload[@"timestamp"] doubleValue]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"values"], @"values"); + self.values = payload[@"values"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"payload"], @"payload"); + self.payload = payload[@"payload"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"error"], @"error"); + self.error = [[TestProtocolDatabaseError alloc] initWithPayload:payload[@"error"]]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"errorList"], @"errorList"); + self.errorList = objcArrayFromPayload<TestProtocolDatabaseError>(payload[@"errorList"]); + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (instancetype)initWithColumnNames:(NSArray/*<NSString>*/ *)columnNames notes:(NSString *)notes timestamp:(double)timestamp values:(RWIProtocolJSONObject *)values payload:(RWIProtocolJSONObject *)payload error:(TestProtocolDatabaseError *)error errorList:(NSArray/*<TestProtocolDatabaseError>*/ *)errorList +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(columnNames, @"columnNames"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(notes, @"notes"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(values, @"values"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload, @"payload"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(error, @"error"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(errorList, @"errorList"); + THROW_EXCEPTION_FOR_BAD_TYPE_IN_ARRAY(errorList, [TestProtocolDatabaseError class]); + + self.columnNames = columnNames; + self.notes = notes; + self.timestamp = timestamp; + self.values = values; + self.payload = payload; + self.error = error; + self.errorList = errorList; + + return self; +} + +- (void)setColumnNames:(NSArray/*<NSString>*/ *)columnNames +{ + [super setInspectorArray:inspectorStringArray(columnNames) forKey:@"columnNames"]; +} + +- (NSArray/*<NSString>*/ *)columnNames +{ + return objcStringArray([super inspectorArrayForKey:@"columnNames"]); +} + +- (void)setNotes:(NSString *)notes +{ + [super setString:notes forKey:@"notes"]; +} + +- (NSString *)notes +{ + return [super stringForKey:@"notes"]; +} + +- (void)setTimestamp:(double)timestamp +{ + [super setDouble:timestamp forKey:@"timestamp"]; +} + +- (double)timestamp +{ + return [super doubleForKey:@"timestamp"]; +} + +- (void)setValues:(RWIProtocolJSONObject *)values +{ + [super setObject:values forKey:@"values"]; +} + +- (RWIProtocolJSONObject *)values +{ + return [[RWIProtocolJSONObject alloc] initWithInspectorObject:[[super objectForKey:@"values"] toInspectorObject].get()]; +} + +- (void)setPayload:(RWIProtocolJSONObject *)payload +{ + [super setObject:payload forKey:@"payload"]; +} + +- (RWIProtocolJSONObject *)payload +{ + return [[RWIProtocolJSONObject alloc] initWithInspectorObject:[[super objectForKey:@"payload"] toInspectorObject].get()]; +} + +- (void)setError:(TestProtocolDatabaseError *)error +{ + [super setObject:error forKey:@"error"]; +} + +- (TestProtocolDatabaseError *)error +{ + return [[TestProtocolDatabaseError alloc] initWithInspectorObject:[[super objectForKey:@"error"] toInspectorObject].get()]; +} + +- (void)setErrorList:(NSArray/*<TestProtocolDatabaseError>*/ *)errorList +{ + THROW_EXCEPTION_FOR_BAD_TYPE_IN_ARRAY(errorList, [TestProtocolDatabaseError class]); + [super setInspectorArray:inspectorObjectArray(errorList) forKey:@"errorList"]; +} + +- (NSArray/*<TestProtocolDatabaseError>*/ *)errorList +{ + return objcArray<TestProtocolDatabaseError>([super inspectorArrayForKey:@"errorList"]); +} + +@end + +@implementation TestProtocolDatabaseObjectWithPropertyNameConflicts + +- (instancetype)initWithPayload:(nonnull NSDictionary<NSString *, id> *)payload +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"integer"], @"integer"); + self.integer = payload[@"integer"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"array"], @"array"); + self.array = payload[@"array"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"string"], @"string"); + self.string = payload[@"string"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"value"], @"value"); + self.value = payload[@"value"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"object"], @"object"); + self.object = payload[@"object"]; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (instancetype)initWithInteger:(NSString *)integer array:(NSString *)array string:(NSString *)string value:(NSString *)value object:(NSString *)object +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(integer, @"integer"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(array, @"array"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(string, @"string"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(value, @"value"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(object, @"object"); + + self.integer = integer; + self.array = array; + self.string = string; + self.value = value; + self.object = object; + + return self; +} + +- (void)setInteger:(NSString *)integer +{ + [super setString:integer forKey:@"integer"]; +} + +- (NSString *)integer +{ + return [super stringForKey:@"integer"]; +} + +- (void)setArray:(NSString *)array +{ + [super setString:array forKey:@"array"]; +} + +- (NSString *)array +{ + return [super stringForKey:@"array"]; +} + +- (void)setString:(NSString *)string +{ + [super setString:string forKey:@"string"]; +} + +- (NSString *)string +{ + return [super stringForKey:@"string"]; +} + +- (void)setValue:(NSString *)value +{ + [super setString:value forKey:@"value"]; +} + +- (NSString *)value +{ + return [super stringForKey:@"value"]; +} + +- (void)setObject:(NSString *)object +{ + [super setString:object forKey:@"object"]; +} + +- (NSString *)object +{ + return [super stringForKey:@"object"]; +} + +@end + +@implementation TestProtocolDatabaseDummyObject + +- (instancetype)initWithPayload:(nonnull NSDictionary<NSString *, id> *)payload +{ + if (!(self = [super init])) + return nil; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +@end + + +@implementation TestProtocolTestParameterBundle + +- (instancetype)initWithPayload:(nonnull NSDictionary<NSString *, id> *)payload +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"columnNames"], @"columnNames"); + self.columnNames = objcArrayFromPayload<NSString>(payload[@"columnNames"]); + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"notes"], @"notes"); + self.notes = payload[@"notes"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"timestamp"], @"timestamp"); + self.timestamp = [payload[@"timestamp"] doubleValue]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"values"], @"values"); + self.values = payload[@"values"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"payload"], @"payload"); + self.payload = payload[@"payload"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"error"], @"error"); + self.error = [[TestProtocolDatabaseError alloc] initWithPayload:payload[@"error"]]; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (instancetype)initWithColumnNames:(NSArray/*<NSString>*/ *)columnNames notes:(NSString *)notes timestamp:(double)timestamp values:(RWIProtocolJSONObject *)values payload:(RWIProtocolJSONObject *)payload error:(TestProtocolDatabaseError *)error +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(columnNames, @"columnNames"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(notes, @"notes"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(values, @"values"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload, @"payload"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(error, @"error"); + + self.columnNames = columnNames; + self.notes = notes; + self.timestamp = timestamp; + self.values = values; + self.payload = payload; + self.error = error; + + return self; +} + +- (void)setColumnNames:(NSArray/*<NSString>*/ *)columnNames +{ + [super setInspectorArray:inspectorStringArray(columnNames) forKey:@"columnNames"]; +} + +- (NSArray/*<NSString>*/ *)columnNames +{ + return objcStringArray([super inspectorArrayForKey:@"columnNames"]); +} + +- (void)setNotes:(NSString *)notes +{ + [super setString:notes forKey:@"notes"]; +} + +- (NSString *)notes +{ + return [super stringForKey:@"notes"]; +} + +- (void)setTimestamp:(double)timestamp +{ + [super setDouble:timestamp forKey:@"timestamp"]; +} + +- (double)timestamp +{ + return [super doubleForKey:@"timestamp"]; +} + +- (void)setValues:(RWIProtocolJSONObject *)values +{ + [super setObject:values forKey:@"values"]; +} + +- (RWIProtocolJSONObject *)values +{ + return [[RWIProtocolJSONObject alloc] initWithInspectorObject:[[super objectForKey:@"values"] toInspectorObject].get()]; +} + +- (void)setPayload:(RWIProtocolJSONObject *)payload +{ + [super setObject:payload forKey:@"payload"]; +} + +- (RWIProtocolJSONObject *)payload +{ + return [[RWIProtocolJSONObject alloc] initWithInspectorObject:[[super objectForKey:@"payload"] toInspectorObject].get()]; +} + +- (void)setError:(TestProtocolDatabaseError *)error +{ + [super setObject:error forKey:@"error"]; +} + +- (TestProtocolDatabaseError *)error +{ + return [[TestProtocolDatabaseError alloc] initWithInspectorObject:[[super objectForKey:@"error"] toInspectorObject].get()]; +} + +@end + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result new file mode 100644 index 000000000..893692982 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result @@ -0,0 +1,1617 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// Test. +InspectorBackend.registerEnum("Test.UncastedAnimals", {Pigs: "Pigs", Cows: "Cows", Cats: "Cats", Hens: "Hens"}); +InspectorBackend.registerEnum("Test.CastedAnimals", {Ducks: "Ducks", Hens: "Hens", Crows: "Crows", Flamingos: "Flamingos"}); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include <inspector/InspectorFrontendRouter.h> +#include <JavaScriptCore/InspectorBackendDispatcher.h> + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr<BackendDispatcher>&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr<BackendDispatcher> m_backendDispatcher; +}; + + + + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorBackendDispatcher.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +typedef String ErrorString; + + + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include <inspector/InspectorFrontendRouter.h> +#include <inspector/InspectorValues.h> +#include <wtf/NeverDestroyed.h> +#include <wtf/text/CString.h> + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + + + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorValues.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include <wtf/text/CString.h> + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include <inspector/InspectorProtocolTypes.h> +#include <wtf/Assertions.h> + +namespace Inspector { + + + +namespace Protocol { + +// Forward declarations. +namespace Test { +class TypeNeedingCast; +class RecursiveObject1; +class RecursiveObject2; +enum class UncastedAnimals; +enum class CastedAnimals; +} // Test +// End of forward declarations. + + +// Typedefs. +namespace Test { +typedef int CastedObjectId; +typedef int UncastedObjectId; +} // Test +// End of typedefs. + +namespace TestHelpers { + +String getEnumConstantValue(int code); + +template<typename T> String getEnumConstantValue(T enumValue) +{ + return getEnumConstantValue(static_cast<int>(enumValue)); +} + +} // namespace TestHelpers + +namespace Test { +/* A dummy type that requires runtime casts, and forces non-primitive referenced types to also emit runtime cast helpers. */ +class TypeNeedingCast : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + StringSet = 1 << 0, + NumberSet = 1 << 1, + AnimalsSet = 1 << 2, + IdSet = 1 << 3, + TreeSet = 1 << 4, + AllFieldsSet = (StringSet | NumberSet | AnimalsSet | IdSet | TreeSet) + }; + + template<int STATE> + class Builder { + private: + RefPtr<InspectorObject> m_result; + + template<int STEP> Builder<STATE | STEP>& castState() + { + return *reinterpret_cast<Builder<STATE | STEP>*>(this); + } + + Builder(Ref</*TypeNeedingCast*/InspectorObject>&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class TypeNeedingCast; + public: + + Builder<STATE | StringSet>& setString(const String& value) + { + COMPILE_ASSERT(!(STATE & StringSet), property_string_already_set); + m_result->setString(ASCIILiteral("string"), value); + return castState<StringSet>(); + } + + Builder<STATE | NumberSet>& setNumber(int value) + { + COMPILE_ASSERT(!(STATE & NumberSet), property_number_already_set); + m_result->setInteger(ASCIILiteral("number"), value); + return castState<NumberSet>(); + } + + Builder<STATE | AnimalsSet>& setAnimals(Inspector::Protocol::Test::CastedAnimals value) + { + COMPILE_ASSERT(!(STATE & AnimalsSet), property_animals_already_set); + m_result->setString(ASCIILiteral("animals"), Inspector::Protocol::TestHelpers::getEnumConstantValue(value)); + return castState<AnimalsSet>(); + } + + Builder<STATE | IdSet>& setId(int value) + { + COMPILE_ASSERT(!(STATE & IdSet), property_id_already_set); + m_result->setInteger(ASCIILiteral("id"), value); + return castState<IdSet>(); + } + + Builder<STATE | TreeSet>& setTree(RefPtr<Inspector::Protocol::Test::RecursiveObject1> value) + { + COMPILE_ASSERT(!(STATE & TreeSet), property_tree_already_set); + m_result->setObject(ASCIILiteral("tree"), value); + return castState<TreeSet>(); + } + + Ref<TypeNeedingCast> release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(TypeNeedingCast) == sizeof(InspectorObject), cannot_cast); + + Ref<InspectorObject> result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast<Ref<TypeNeedingCast>*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref<TypeNeedingCast> result = TypeNeedingCast::create() + * .setString(...) + * .setNumber(...) + * .setAnimals(...) + * .setId(...) + * .setTree(...) + * .release(); + */ + static Builder<NoFieldsSet> create() + { + return Builder<NoFieldsSet>(InspectorObject::create()); + } +}; + +/* */ +enum class UncastedAnimals { + Pigs = 4, + Cows = 5, + Cats = 6, + Hens = 1, +}; // enum class UncastedAnimals +/* */ +enum class CastedAnimals { + Ducks = 0, + Hens = 1, + Crows = 2, + Flamingos = 3, +}; // enum class CastedAnimals +class RecursiveObject1 : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + AllFieldsSet = 0 + }; + + template<int STATE> + class Builder { + private: + RefPtr<InspectorObject> m_result; + + template<int STEP> Builder<STATE | STEP>& castState() + { + return *reinterpret_cast<Builder<STATE | STEP>*>(this); + } + + Builder(Ref</*RecursiveObject1*/InspectorObject>&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class RecursiveObject1; + public: + + Ref<RecursiveObject1> release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(RecursiveObject1) == sizeof(InspectorObject), cannot_cast); + + Ref<InspectorObject> result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast<Ref<RecursiveObject1>*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref<RecursiveObject1> result = RecursiveObject1::create() + * .release(); + */ + static Builder<NoFieldsSet> create() + { + return Builder<NoFieldsSet>(InspectorObject::create()); + } + + void setObj(RefPtr<Inspector::Protocol::Test::RecursiveObject2> value) + { + InspectorObjectBase::setObject(ASCIILiteral("obj"), WTFMove(value)); + } +}; + +class RecursiveObject2 : public Inspector::InspectorObjectBase { +public: + enum { + NoFieldsSet = 0, + AllFieldsSet = 0 + }; + + template<int STATE> + class Builder { + private: + RefPtr<InspectorObject> m_result; + + template<int STEP> Builder<STATE | STEP>& castState() + { + return *reinterpret_cast<Builder<STATE | STEP>*>(this); + } + + Builder(Ref</*RecursiveObject2*/InspectorObject>&& object) + : m_result(WTFMove(object)) + { + COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); + } + friend class RecursiveObject2; + public: + + Ref<RecursiveObject2> release() + { + COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); + COMPILE_ASSERT(sizeof(RecursiveObject2) == sizeof(InspectorObject), cannot_cast); + + Ref<InspectorObject> result = m_result.releaseNonNull(); + return WTFMove(*reinterpret_cast<Ref<RecursiveObject2>*>(&result)); + } + }; + + /* + * Synthetic constructor: + * Ref<RecursiveObject2> result = RecursiveObject2::create() + * .release(); + */ + static Builder<NoFieldsSet> create() + { + return Builder<NoFieldsSet>(InspectorObject::create()); + } + + void setObj(RefPtr<Inspector::Protocol::Test::RecursiveObject1> value) + { + InspectorObjectBase::setObject(ASCIILiteral("obj"), WTFMove(value)); + } +}; + +} // Test + +template<> struct BindingTraits<Inspector::Protocol::Test::CastedAnimals> { +#if !ASSERT_DISABLED +static void assertValueHasExpectedType(Inspector::InspectorValue*); +#endif // !ASSERT_DISABLED +}; +template<> struct BindingTraits<Inspector::Protocol::Test::TypeNeedingCast> { +static RefPtr<Inspector::Protocol::Test::TypeNeedingCast> runtimeCast(RefPtr<Inspector::InspectorValue>&& value); +#if !ASSERT_DISABLED +static void assertValueHasExpectedType(Inspector::InspectorValue*); +#endif // !ASSERT_DISABLED +}; +template<> struct BindingTraits<Inspector::Protocol::Test::RecursiveObject1> { +#if !ASSERT_DISABLED +static void assertValueHasExpectedType(Inspector::InspectorValue*); +#endif // !ASSERT_DISABLED +}; +template<> struct BindingTraits<Inspector::Protocol::Test::RecursiveObject2> { +#if !ASSERT_DISABLED +static void assertValueHasExpectedType(Inspector::InspectorValue*); +#endif // !ASSERT_DISABLED +}; + +namespace TestHelpers { + +template<typename ProtocolEnumType> +std::optional<ProtocolEnumType> parseEnumValueFromString(const String&); + +// Enums in the 'Test' Domain +template<> +std::optional<Inspector::Protocol::Test::UncastedAnimals> parseEnumValueFromString<Inspector::Protocol::Test::UncastedAnimals>(const String&); +template<> +std::optional<Inspector::Protocol::Test::CastedAnimals> parseEnumValueFromString<Inspector::Protocol::Test::CastedAnimals>(const String&); + +} // namespace TestHelpers + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include <wtf/Optional.h> +#include <wtf/text/CString.h> + +namespace Inspector { + +namespace Protocol { + +namespace TestHelpers { + +static const char* const enum_constant_values[] = { + "Ducks", + "Hens", + "Crows", + "Flamingos", + "Pigs", + "Cows", + "Cats", +}; + +String getEnumConstantValue(int code) { + return enum_constant_values[code]; +} + +// Enums in the 'Test' Domain +template<> +std::optional<Inspector::Protocol::Test::UncastedAnimals> parseEnumValueFromString<Inspector::Protocol::Test::UncastedAnimals>(const String& protocolString) +{ + static const size_t constantValues[] = { + (size_t)Inspector::Protocol::Test::UncastedAnimals::Pigs, + (size_t)Inspector::Protocol::Test::UncastedAnimals::Cows, + (size_t)Inspector::Protocol::Test::UncastedAnimals::Cats, + (size_t)Inspector::Protocol::Test::UncastedAnimals::Hens, + }; + for (size_t i = 0; i < 4; ++i) + if (protocolString == enum_constant_values[constantValues[i]]) + return (Inspector::Protocol::Test::UncastedAnimals)constantValues[i]; + + return std::nullopt; +} + +template<> +std::optional<Inspector::Protocol::Test::CastedAnimals> parseEnumValueFromString<Inspector::Protocol::Test::CastedAnimals>(const String& protocolString) +{ + static const size_t constantValues[] = { + (size_t)Inspector::Protocol::Test::CastedAnimals::Ducks, + (size_t)Inspector::Protocol::Test::CastedAnimals::Hens, + (size_t)Inspector::Protocol::Test::CastedAnimals::Crows, + (size_t)Inspector::Protocol::Test::CastedAnimals::Flamingos, + }; + for (size_t i = 0; i < 4; ++i) + if (protocolString == enum_constant_values[constantValues[i]]) + return (Inspector::Protocol::Test::CastedAnimals)constantValues[i]; + + return std::nullopt; +} + + +} // namespace TestHelpers + + + +#if !ASSERT_DISABLED +void BindingTraits<Inspector::Protocol::Test::CastedAnimals>::assertValueHasExpectedType(Inspector::InspectorValue* value) +{ + ASSERT_ARG(value, value); + String result; + bool castSucceeded = value->asString(result); + ASSERT(castSucceeded); + ASSERT(result == "Ducks" || result == "Hens" || result == "Crows" || result == "Flamingos"); +} +#endif // !ASSERT_DISABLED + +#if !ASSERT_DISABLED +void BindingTraits<Inspector::Protocol::Test::TypeNeedingCast>::assertValueHasExpectedType(Inspector::InspectorValue* value) +{ + ASSERT_ARG(value, value); + RefPtr<InspectorObject> object; + bool castSucceeded = value->asObject(object); + ASSERT_UNUSED(castSucceeded, castSucceeded); + { + InspectorObject::iterator stringPos = object->find(ASCIILiteral("string")); + ASSERT(stringPos != object->end()); + BindingTraits<String>::assertValueHasExpectedType(stringPos->value.get()); + } + { + InspectorObject::iterator numberPos = object->find(ASCIILiteral("number")); + ASSERT(numberPos != object->end()); + BindingTraits<int>::assertValueHasExpectedType(numberPos->value.get()); + } + { + InspectorObject::iterator animalsPos = object->find(ASCIILiteral("animals")); + ASSERT(animalsPos != object->end()); + BindingTraits<Inspector::Protocol::Test::CastedAnimals>::assertValueHasExpectedType(animalsPos->value.get()); + } + { + InspectorObject::iterator idPos = object->find(ASCIILiteral("id")); + ASSERT(idPos != object->end()); + BindingTraits<int>::assertValueHasExpectedType(idPos->value.get()); + } + { + InspectorObject::iterator treePos = object->find(ASCIILiteral("tree")); + ASSERT(treePos != object->end()); + BindingTraits<Inspector::Protocol::Test::RecursiveObject1>::assertValueHasExpectedType(treePos->value.get()); + } + + int foundPropertiesCount = 5; + if (foundPropertiesCount != object->size()) + FATAL("Unexpected properties in object: %s\n", object->toJSONString().ascii().data()); +} +#endif // !ASSERT_DISABLED + +RefPtr<Inspector::Protocol::Test::TypeNeedingCast> BindingTraits<Inspector::Protocol::Test::TypeNeedingCast>::runtimeCast(RefPtr<InspectorValue>&& value) +{ + RefPtr<InspectorObject> result; + bool castSucceeded = value->asObject(result); + ASSERT_UNUSED(castSucceeded, castSucceeded); +#if !ASSERT_DISABLED + BindingTraits<Inspector::Protocol::Test::TypeNeedingCast>::assertValueHasExpectedType(result.get()); +#endif // !ASSERT_DISABLED + COMPILE_ASSERT(sizeof(Inspector::Protocol::Test::TypeNeedingCast) == sizeof(InspectorObjectBase), type_cast_problem); + return static_cast<Inspector::Protocol::Test::TypeNeedingCast*>(static_cast<InspectorObjectBase*>(result.get())); +} + + +#if !ASSERT_DISABLED +void BindingTraits<Inspector::Protocol::Test::RecursiveObject1>::assertValueHasExpectedType(Inspector::InspectorValue* value) +{ + ASSERT_ARG(value, value); + RefPtr<InspectorObject> object; + bool castSucceeded = value->asObject(object); + ASSERT_UNUSED(castSucceeded, castSucceeded); + + int foundPropertiesCount = 0; + { + InspectorObject::iterator objPos = object->find(ASCIILiteral("obj")); + if (objPos != object->end()) { + BindingTraits<Inspector::Protocol::Test::RecursiveObject2>::assertValueHasExpectedType(objPos->value.get()); + ++foundPropertiesCount; + } + } + if (foundPropertiesCount != object->size()) + FATAL("Unexpected properties in object: %s\n", object->toJSONString().ascii().data()); +} +#endif // !ASSERT_DISABLED + +#if !ASSERT_DISABLED +void BindingTraits<Inspector::Protocol::Test::RecursiveObject2>::assertValueHasExpectedType(Inspector::InspectorValue* value) +{ + ASSERT_ARG(value, value); + RefPtr<InspectorObject> object; + bool castSucceeded = value->asObject(object); + ASSERT_UNUSED(castSucceeded, castSucceeded); + + int foundPropertiesCount = 0; + { + InspectorObject::iterator objPos = object->find(ASCIILiteral("obj")); + if (objPos != object->end()) { + BindingTraits<Inspector::Protocol::Test::RecursiveObject1>::assertValueHasExpectedType(objPos->value.get()); + ++foundPropertiesCount; + } + } + if (foundPropertiesCount != object->size()) + FATAL("Unexpected properties in object: %s\n", object->toJSONString().ascii().data()); +} +#endif // !ASSERT_DISABLED + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#include <wtf/RetainPtr.h> + + + +namespace Inspector { + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include <JavaScriptCore/InspectorValues.h> + +namespace Inspector { + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <WebInspector/TestProtocol.h> + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import <JavaScriptCore/AlternateDispatchableAgent.h> +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#import <JavaScriptCore/InspectorBackendDispatchers.h> + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [super dealloc]; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <JavaScriptCore/InspectorValues.h> + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <Foundation/Foundation.h> + +#import <WebInspector/RWIProtocolJSONObject.h> + + +@class TestProtocolTestTypeNeedingCast; +@class TestProtocolTestRecursiveObject1; +@class TestProtocolTestRecursiveObject2; + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + +typedef NS_ENUM(NSInteger, TestProtocolTestUncastedAnimals) { + TestProtocolTestUncastedAnimalsPigs, + TestProtocolTestUncastedAnimalsCows, + TestProtocolTestUncastedAnimalsCats, + TestProtocolTestUncastedAnimalsHens, +}; + +typedef NS_ENUM(NSInteger, TestProtocolTestCastedAnimals) { + TestProtocolTestCastedAnimalsDucks, + TestProtocolTestCastedAnimalsHens, + TestProtocolTestCastedAnimalsCrows, + TestProtocolTestCastedAnimalsFlamingos, +}; + + +__attribute__((visibility ("default"))) +@interface TestProtocolTestTypeNeedingCast : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +- (instancetype)initWithString:(NSString *)string number:(int)number animals:(TestProtocolTestCastedAnimals)animals identifier:(int)identifier tree:(TestProtocolTestRecursiveObject1 *)tree; +/* required */ @property (nonatomic, copy) NSString *string; +/* required */ @property (nonatomic, assign) int number; +/* required */ @property (nonatomic, assign) TestProtocolTestCastedAnimals animals; +/* required */ @property (nonatomic, assign) int identifier; +/* required */ @property (nonatomic, retain) TestProtocolTestRecursiveObject1 *tree; +@end + +__attribute__((visibility ("default"))) +@interface TestProtocolTestRecursiveObject1 : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +/* optional */ @property (nonatomic, retain) TestProtocolTestRecursiveObject2 *obj; +@end + +__attribute__((visibility ("default"))) +@interface TestProtocolTestRecursiveObject2 : RWIProtocolJSONObject +- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload; +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject; +/* optional */ @property (nonatomic, retain) TestProtocolTestRecursiveObject1 *obj; +@end + + + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorValues.h> + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import <WebInspector/RWIProtocolArrayConversions.h> + +namespace Inspector { + +template<typename ObjCEnumType> +std::optional<ObjCEnumType> fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + + +inline String toProtocolString(TestProtocolTestUncastedAnimals value) +{ + switch(value) { + case TestProtocolTestUncastedAnimalsPigs: + return ASCIILiteral("Pigs"); + case TestProtocolTestUncastedAnimalsCows: + return ASCIILiteral("Cows"); + case TestProtocolTestUncastedAnimalsCats: + return ASCIILiteral("Cats"); + case TestProtocolTestUncastedAnimalsHens: + return ASCIILiteral("Hens"); + } +} + +template<> +inline std::optional<TestProtocolTestUncastedAnimals> fromProtocolString(const String& value) +{ + if (value == "Pigs") + return TestProtocolTestUncastedAnimalsPigs; + if (value == "Cows") + return TestProtocolTestUncastedAnimalsCows; + if (value == "Cats") + return TestProtocolTestUncastedAnimalsCats; + if (value == "Hens") + return TestProtocolTestUncastedAnimalsHens; + return std::nullopt; +} + +inline String toProtocolString(TestProtocolTestCastedAnimals value) +{ + switch(value) { + case TestProtocolTestCastedAnimalsDucks: + return ASCIILiteral("Ducks"); + case TestProtocolTestCastedAnimalsHens: + return ASCIILiteral("Hens"); + case TestProtocolTestCastedAnimalsCrows: + return ASCIILiteral("Crows"); + case TestProtocolTestCastedAnimalsFlamingos: + return ASCIILiteral("Flamingos"); + } +} + +template<> +inline std::optional<TestProtocolTestCastedAnimals> fromProtocolString(const String& value) +{ + if (value == "Ducks") + return TestProtocolTestCastedAnimalsDucks; + if (value == "Hens") + return TestProtocolTestCastedAnimalsHens; + if (value == "Crows") + return TestProtocolTestCastedAnimalsCrows; + if (value == "Flamingos") + return TestProtocolTestCastedAnimalsFlamingos; + return std::nullopt; +} + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> + +using namespace Inspector; + +@interface TestProtocolTypeConversions (TestDomain) + ++ (void)_parseTypeNeedingCast:(TestProtocolTestTypeNeedingCast **)outValue fromPayload:(id)payload; ++ (void)_parseCastedObjectId:(NSNumber **)outValue fromPayload:(id)payload; ++ (void)_parseUncastedObjectId:(NSNumber **)outValue fromPayload:(id)payload; ++ (void)_parseUncastedAnimals:(NSNumber **)outValue fromPayload:(id)payload; ++ (void)_parseCastedAnimals:(NSNumber **)outValue fromPayload:(id)payload; ++ (void)_parseRecursiveObject1:(TestProtocolTestRecursiveObject1 **)outValue fromPayload:(id)payload; ++ (void)_parseRecursiveObject2:(TestProtocolTestRecursiveObject2 **)outValue fromPayload:(id)payload; + +@end + +@implementation TestProtocolTypeConversions (TestDomain) + ++ (void)_parseTypeNeedingCast:(TestProtocolTestTypeNeedingCast **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolTestTypeNeedingCast alloc] initWithPayload:payload]; +} + ++ (void)_parseCastedObjectId:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSNumber class]); + *outValue = (NSNumber *)payload; +} + ++ (void)_parseUncastedObjectId:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSNumber class]); + *outValue = (NSNumber *)payload; +} + ++ (void)_parseUncastedAnimals:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + std::optional<TestProtocolTestUncastedAnimals> result = Inspector::fromProtocolString<TestProtocolTestUncastedAnimals>(payload); + THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"UncastedAnimals"); + *outValue = @(result.value()); +} + ++ (void)_parseCastedAnimals:(NSNumber **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]); + std::optional<TestProtocolTestCastedAnimals> result = Inspector::fromProtocolString<TestProtocolTestCastedAnimals>(payload); + THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"CastedAnimals"); + *outValue = @(result.value()); +} + ++ (void)_parseRecursiveObject1:(TestProtocolTestRecursiveObject1 **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolTestRecursiveObject1 alloc] initWithPayload:payload]; +} + ++ (void)_parseRecursiveObject2:(TestProtocolTestRecursiveObject2 **)outValue fromPayload:(id)payload +{ + THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSDictionary class]); + *outValue = [[TestProtocolTestRecursiveObject2 alloc] initWithPayload:payload]; +} + +@end + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from type-requiring-runtime-casts.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> +#import <JavaScriptCore/InspectorValues.h> +#import <wtf/Assertions.h> + +using namespace Inspector; + + +@implementation TestProtocolTestTypeNeedingCast + +- (instancetype)initWithPayload:(nonnull NSDictionary<NSString *, id> *)payload +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"string"], @"string"); + self.string = payload[@"string"]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"number"], @"number"); + self.number = [payload[@"number"] integerValue]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"animals"], @"animals"); + std::optional<TestProtocolTestCastedAnimals> animals = fromProtocolString<TestProtocolTestCastedAnimals>(payload[@"animals"]); + THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(animals, @"animals"); + self.animals = animals.value(); + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"id"], @"id"); + self.identifier = [payload[@"id"] integerValue]; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"tree"], @"tree"); + self.tree = [[TestProtocolTestRecursiveObject1 alloc] initWithPayload:payload[@"tree"]]; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (instancetype)initWithString:(NSString *)string number:(int)number animals:(TestProtocolTestCastedAnimals)animals identifier:(int)identifier tree:(TestProtocolTestRecursiveObject1 *)tree +{ + if (!(self = [super init])) + return nil; + + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(string, @"string"); + THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(tree, @"tree"); + + self.string = string; + self.number = number; + self.animals = animals; + self.identifier = identifier; + self.tree = tree; + + return self; +} + +- (void)setString:(NSString *)string +{ + [super setString:string forKey:@"string"]; +} + +- (NSString *)string +{ + return [super stringForKey:@"string"]; +} + +- (void)setNumber:(int)number +{ + [super setInteger:number forKey:@"number"]; +} + +- (int)number +{ + return [super integerForKey:@"number"]; +} + +- (void)setAnimals:(TestProtocolTestCastedAnimals)animals +{ + [super setString:toProtocolString(animals) forKey:@"animals"]; +} + +- (TestProtocolTestCastedAnimals)animals +{ + return fromProtocolString<TestProtocolTestCastedAnimals>([super stringForKey:@"animals"]).value(); +} + +- (void)setIdentifier:(int)identifier +{ + [super setInteger:identifier forKey:@"id"]; +} + +- (int)identifier +{ + return [super integerForKey:@"id"]; +} + +- (void)setTree:(TestProtocolTestRecursiveObject1 *)tree +{ + [super setObject:tree forKey:@"tree"]; +} + +- (TestProtocolTestRecursiveObject1 *)tree +{ + return [[TestProtocolTestRecursiveObject1 alloc] initWithInspectorObject:[[super objectForKey:@"tree"] toInspectorObject].get()]; +} + +@end + +@implementation TestProtocolTestRecursiveObject1 + +- (instancetype)initWithPayload:(nonnull NSDictionary<NSString *, id> *)payload +{ + if (!(self = [super init])) + return nil; + + self.obj = [[TestProtocolTestRecursiveObject2 alloc] initWithPayload:payload[@"obj"]]; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (void)setObj:(TestProtocolTestRecursiveObject2 *)obj +{ + [super setObject:obj forKey:@"obj"]; +} + +- (TestProtocolTestRecursiveObject2 *)obj +{ + return [[TestProtocolTestRecursiveObject2 alloc] initWithInspectorObject:[[super objectForKey:@"obj"] toInspectorObject].get()]; +} + +@end + +@implementation TestProtocolTestRecursiveObject2 + +- (instancetype)initWithPayload:(nonnull NSDictionary<NSString *, id> *)payload +{ + if (!(self = [super init])) + return nil; + + self.obj = [[TestProtocolTestRecursiveObject1 alloc] initWithPayload:payload[@"obj"]]; + + return self; +} +- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject +{ + if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()])) + return nil; + + return self; +} + +- (void)setObj:(TestProtocolTestRecursiveObject1 *)obj +{ + [super setObject:obj forKey:@"obj"]; +} + +- (TestProtocolTestRecursiveObject1 *)obj +{ + return [[TestProtocolTestRecursiveObject1 alloc] initWithInspectorObject:[[super objectForKey:@"obj"] toInspectorObject].get()]; +} + +@end + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/worker-supported-domains.json-result b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/worker-supported-domains.json-result new file mode 100644 index 000000000..bb4dc2213 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/worker-supported-domains.json-result @@ -0,0 +1,1121 @@ +### Begin File: InspectorBackendCommands.js +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +// DomainA. +InspectorBackend.registerCommand("DomainA.enable", [], []); +InspectorBackend.activateDomain("DomainA"); +InspectorBackend.workerSupportedDomain("DomainA"); + +// DomainB. +InspectorBackend.registerCommand("DomainB.enable", [], []); +InspectorBackend.activateDomain("DomainB"); +### End File: InspectorBackendCommands.js + +### Begin File: TestAlternateBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +#include "TestProtocolTypes.h" +#include <inspector/InspectorFrontendRouter.h> +#include <JavaScriptCore/InspectorBackendDispatcher.h> + +namespace Inspector { + +class AlternateBackendDispatcher { +public: + void setBackendDispatcher(RefPtr<BackendDispatcher>&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); } + BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); } +private: + RefPtr<BackendDispatcher> m_backendDispatcher; +}; + + +class AlternateDomainABackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~AlternateDomainABackendDispatcher() { } + virtual void enable(long callId) = 0; +}; +class AlternateDomainBBackendDispatcher : public AlternateBackendDispatcher { +public: + virtual ~AlternateDomainBBackendDispatcher() { } + virtual void enable(long callId) = 0; +}; + +} // namespace Inspector + +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +### End File: TestAlternateBackendDispatchers.h + +### Begin File: TestBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorBackendDispatcher.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +typedef String ErrorString; + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +class AlternateDomainABackendDispatcher; +class AlternateDomainBBackendDispatcher; +#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + +class DomainABackendDispatcherHandler { +public: + virtual void enable(ErrorString&) = 0; +protected: + virtual ~DomainABackendDispatcherHandler(); +}; + +class DomainBBackendDispatcherHandler { +public: + virtual void enable(ErrorString&) = 0; +protected: + virtual ~DomainBBackendDispatcherHandler(); +}; + +class DomainABackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref<DomainABackendDispatcher> create(BackendDispatcher&, DomainABackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) override; +private: + void enable(long requestId, RefPtr<InspectorObject>&& parameters); +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(AlternateDomainABackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + AlternateDomainABackendDispatcher* m_alternateDispatcher { nullptr }; +#endif +private: + DomainABackendDispatcher(BackendDispatcher&, DomainABackendDispatcherHandler*); + DomainABackendDispatcherHandler* m_agent { nullptr }; +}; + +class DomainBBackendDispatcher final : public SupplementalBackendDispatcher { +public: + static Ref<DomainBBackendDispatcher> create(BackendDispatcher&, DomainBBackendDispatcherHandler*); + void dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) override; +private: + void enable(long requestId, RefPtr<InspectorObject>&& parameters); +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +public: + void setAlternateDispatcher(AlternateDomainBBackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; } +private: + AlternateDomainBBackendDispatcher* m_alternateDispatcher { nullptr }; +#endif +private: + DomainBBackendDispatcher(BackendDispatcher&, DomainBBackendDispatcherHandler*); + DomainBBackendDispatcherHandler* m_agent { nullptr }; +}; + +} // namespace Inspector +### End File: TestBackendDispatchers.h + +### Begin File: TestBackendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestBackendDispatchers.h" + +#include <inspector/InspectorFrontendRouter.h> +#include <inspector/InspectorValues.h> +#include <wtf/NeverDestroyed.h> +#include <wtf/text/CString.h> + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +#include "TestAlternateBackendDispatchers.h" +#endif + +namespace Inspector { + +DomainABackendDispatcherHandler::~DomainABackendDispatcherHandler() { } +DomainBBackendDispatcherHandler::~DomainBBackendDispatcherHandler() { } + +Ref<DomainABackendDispatcher> DomainABackendDispatcher::create(BackendDispatcher& backendDispatcher, DomainABackendDispatcherHandler* agent) +{ + return adoptRef(*new DomainABackendDispatcher(backendDispatcher, agent)); +} + +DomainABackendDispatcher::DomainABackendDispatcher(BackendDispatcher& backendDispatcher, DomainABackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("DomainA"), this); +} + +void DomainABackendDispatcher::dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) +{ + Ref<DomainABackendDispatcher> protect(*this); + + RefPtr<InspectorObject> parameters; + message->getObject(ASCIILiteral("params"), parameters); + + if (method == "enable") + enable(requestId, WTFMove(parameters)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\'', "DomainA", '.', method, "' was not found")); +} + +void DomainABackendDispatcher::enable(long requestId, RefPtr<InspectorObject>&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->enable(requestId); + return; + } +#endif + + ErrorString error; + Ref<InspectorObject> result = InspectorObject::create(); + m_agent->enable(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +Ref<DomainBBackendDispatcher> DomainBBackendDispatcher::create(BackendDispatcher& backendDispatcher, DomainBBackendDispatcherHandler* agent) +{ + return adoptRef(*new DomainBBackendDispatcher(backendDispatcher, agent)); +} + +DomainBBackendDispatcher::DomainBBackendDispatcher(BackendDispatcher& backendDispatcher, DomainBBackendDispatcherHandler* agent) + : SupplementalBackendDispatcher(backendDispatcher) + , m_agent(agent) +{ + m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("DomainB"), this); +} + +void DomainBBackendDispatcher::dispatch(long requestId, const String& method, Ref<InspectorObject>&& message) +{ + Ref<DomainBBackendDispatcher> protect(*this); + + RefPtr<InspectorObject> parameters; + message->getObject(ASCIILiteral("params"), parameters); + + if (method == "enable") + enable(requestId, WTFMove(parameters)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, makeString('\'', "DomainB", '.', method, "' was not found")); +} + +void DomainBBackendDispatcher::enable(long requestId, RefPtr<InspectorObject>&&) +{ +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_alternateDispatcher) { + m_alternateDispatcher->enable(requestId); + return; + } +#endif + + ErrorString error; + Ref<InspectorObject> result = InspectorObject::create(); + m_agent->enable(error); + + if (!error.length()) + m_backendDispatcher->sendResponse(requestId, WTFMove(result)); + else + m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); +} + +} // namespace Inspector + +### End File: TestBackendDispatchers.cpp + +### Begin File: TestFrontendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include "TestProtocolObjects.h" +#include <inspector/InspectorValues.h> +#include <wtf/text/WTFString.h> + +namespace Inspector { + +class FrontendRouter; + +} // namespace Inspector +### End File: TestFrontendDispatchers.h + +### Begin File: TestFrontendDispatchers.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestFrontendDispatchers.h" + +#include "InspectorFrontendRouter.h" +#include <wtf/text/CString.h> + +namespace Inspector { + +} // namespace Inspector + +### End File: TestFrontendDispatchers.cpp + +### Begin File: TestProtocolObjects.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#pragma once + +#include <inspector/InspectorProtocolTypes.h> +#include <wtf/Assertions.h> + +namespace Inspector { + + + +namespace Protocol { + + + + + + + +} // namespace Protocol + +} // namespace Inspector +### End File: TestProtocolObjects.h + +### Begin File: TestProtocolObjects.cpp +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include "config.h" +#include "TestProtocolObjects.h" + +#include <wtf/Optional.h> +#include <wtf/text/CString.h> + +namespace Inspector { + +namespace Protocol { + + + +} // namespace Protocol + +} // namespace Inspector + +### End File: TestProtocolObjects.cpp + +### Begin File: TestProtocolBackendDispatchers.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#include <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#include <wtf/RetainPtr.h> + +@protocol TestProtocolDomainADomainHandler; +@protocol TestProtocolDomainBDomainHandler; + +namespace Inspector { + + +class ObjCInspectorDomainABackendDispatcher final : public AlternateDomainABackendDispatcher { +public: + ObjCInspectorDomainABackendDispatcher(id<TestProtocolDomainADomainHandler> handler) { m_delegate = handler; } + virtual void enable(long requestId) override; +private: + RetainPtr<id<TestProtocolDomainADomainHandler>> m_delegate; +}; + +class ObjCInspectorDomainBBackendDispatcher final : public AlternateDomainBBackendDispatcher { +public: + ObjCInspectorDomainBBackendDispatcher(id<TestProtocolDomainBDomainHandler> handler) { m_delegate = handler; } + virtual void enable(long requestId) override; +private: + RetainPtr<id<TestProtocolDomainBDomainHandler>> m_delegate; +}; + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.h + +### Begin File: TestProtocolBackendDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "config.h" +#import "TestProtocolBackendDispatchers.h" + +#include "TestProtocolInternal.h" +#include "TestProtocolTypeConversions.h" +#include <JavaScriptCore/InspectorValues.h> + +namespace Inspector { + +void ObjCInspectorDomainABackendDispatcher::enable(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate enableWithErrorCallback:errorCallback successCallback:successCallback]; +} + + +void ObjCInspectorDomainBBackendDispatcher::enable(long requestId) +{ + id errorCallback = ^(NSString *error) { + backendDispatcher()->reportProtocolError(requestId, BackendDispatcher::ServerError, error); + backendDispatcher()->sendPendingErrors(); + }; + + id successCallback = ^{ + backendDispatcher()->sendResponse(requestId, InspectorObject::create()); + }; + + [m_delegate enableWithErrorCallback:errorCallback successCallback:successCallback]; +} + + +} // namespace Inspector + +### End File: TestProtocolBackendDispatchers.mm + +### Begin File: TestProtocolConfiguration.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <WebInspector/TestProtocol.h> + +__attribute__((visibility ("default"))) +@interface TestProtocolConfiguration : NSObject +@property (nonatomic, retain, setter=setDomainAHandler:) id<TestProtocolDomainADomainHandler> domainAHandler; +@property (nonatomic, retain, setter=setDomainBHandler:) id<TestProtocolDomainBDomainHandler> domainBHandler; +@end + + +### End File: TestProtocolConfiguration.h + +### Begin File: TestProtocolConfiguration.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolConfiguration.h" + +#import "TestProtocolInternal.h" +#import "TestProtocolBackendDispatchers.h" +#import <JavaScriptCore/AlternateDispatchableAgent.h> +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorAlternateBackendDispatchers.h> +#import <JavaScriptCore/InspectorBackendDispatchers.h> + +using namespace Inspector; + +@implementation TestProtocolConfiguration +{ + AugmentableInspectorController* _controller; + id<TestProtocolDomainADomainHandler> _domainAHandler; + id<TestProtocolDomainBDomainHandler> _domainBHandler; +} + +- (instancetype)initWithController:(AugmentableInspectorController*)controller +{ + self = [super init]; + if (!self) + return nil; + ASSERT(controller); + _controller = controller; + return self; +} + +- (void)dealloc +{ + [_domainAHandler release]; + [_domainBHandler release]; + [super dealloc]; +} + +- (void)setDomainAHandler:(id<TestProtocolDomainADomainHandler>)handler +{ + if (handler == _domainAHandler) + return; + + [_domainAHandler release]; + _domainAHandler = [handler retain]; + + auto alternateDispatcher = std::make_unique<ObjCInspectorDomainABackendDispatcher>(handler); + auto alternateAgent = std::make_unique<AlternateDispatchableAgent<DomainABackendDispatcher, AlternateDomainABackendDispatcher>>(ASCIILiteral("DomainA"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id<TestProtocolDomainADomainHandler>)domainAHandler +{ + return _domainAHandler; +} + +- (void)setDomainBHandler:(id<TestProtocolDomainBDomainHandler>)handler +{ + if (handler == _domainBHandler) + return; + + [_domainBHandler release]; + _domainBHandler = [handler retain]; + + auto alternateDispatcher = std::make_unique<ObjCInspectorDomainBBackendDispatcher>(handler); + auto alternateAgent = std::make_unique<AlternateDispatchableAgent<DomainBBackendDispatcher, AlternateDomainBBackendDispatcher>>(ASCIILiteral("DomainB"), *_controller, WTFMove(alternateDispatcher)); + _controller->appendExtraAgent(WTFMove(alternateAgent)); +} + +- (id<TestProtocolDomainBDomainHandler>)domainBHandler +{ + return _domainBHandler; +} + +@end + + +### End File: TestProtocolConfiguration.mm + +### Begin File: TestProtocolEventDispatchers.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <JavaScriptCore/InspectorValues.h> + +using namespace Inspector; + + +### End File: TestProtocolEventDispatchers.mm + +### Begin File: TestProtocol.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import <Foundation/Foundation.h> + +#import <WebInspector/RWIProtocolJSONObject.h> + + + + +typedef NS_ENUM(NSInteger, TestProtocolPlatform) { + TestProtocolPlatformAll, + TestProtocolPlatformGeneric, + TestProtocolPlatformIOS, + TestProtocolPlatformMacOS, +}; + + + + + +@protocol TestProtocolDomainADomainHandler <NSObject> +@required +- (void)enableWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +@end + +@protocol TestProtocolDomainBDomainHandler <NSObject> +@required +- (void)enableWithErrorCallback:(void(^)(NSString *error))errorCallback successCallback:(void(^)())successCallback; +@end + + + + +### End File: TestProtocol.h + +### Begin File: TestProtocolInternal.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import "TestProtocolJSONObjectPrivate.h" +#import <JavaScriptCore/AugmentableInspectorController.h> +#import <JavaScriptCore/InspectorValues.h> + + + + +### End File: TestProtocolInternal.h + +### Begin File: TestProtocolTypeConversions.h +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocol.h" +#import <WebInspector/RWIProtocolArrayConversions.h> + +namespace Inspector { + +template<typename ObjCEnumType> +std::optional<ObjCEnumType> fromProtocolString(const String& value); + +inline String toProtocolString(TestProtocolPlatform value) +{ + switch(value) { + case TestProtocolPlatformAll: + return ASCIILiteral("all"); + case TestProtocolPlatformGeneric: + return ASCIILiteral("generic"); + case TestProtocolPlatformIOS: + return ASCIILiteral("ios"); + case TestProtocolPlatformMacOS: + return ASCIILiteral("macos"); + } +} + +template<> +inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value) +{ + if (value == "all") + return TestProtocolPlatformAll; + if (value == "generic") + return TestProtocolPlatformGeneric; + if (value == "ios") + return TestProtocolPlatformIOS; + if (value == "macos") + return TestProtocolPlatformMacOS; + return std::nullopt; +} + +} // namespace Inspector + +### End File: TestProtocolTypeConversions.h + +### Begin File: TestProtocolTypeConversions.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolTypeConversions.h" + +#import "TestProtocol.h" +#import "TestProtocolTypeParser.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> + +using namespace Inspector; + + + + + + +### End File: TestProtocolTypeConversions.mm + +### Begin File: TestProtocolTypes.mm +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * Copyright (C) 2013-2016 Apple Inc. All rights reserved. + * Copyright (C) 2014 University of Washington. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from worker-supported-domains.json +// by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py + +#import "TestProtocolInternal.h" + +#import "TestProtocolTypeConversions.h" +#import <WebInspector/RWIProtocolJSONObjectPrivate.h> +#import <JavaScriptCore/InspectorValues.h> +#import <wtf/Assertions.h> + +using namespace Inspector; + + +### End File: TestProtocolTypes.mm diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-command-with-invalid-platform.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-command-with-invalid-platform.json new file mode 100644 index 000000000..a180cae9b --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-command-with-invalid-platform.json @@ -0,0 +1,16 @@ +{ + "domain": "Overlay", + "commands": [ + { + "name": "processPoints", + "platform": "invalid", + "parameters": [ + { "name": "point1", "type": "number" }, + { "name": "point2", "type": "number" } + ], + "returns": [ + { "name": "result", "type": "string" } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-domain-availability.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-domain-availability.json new file mode 100644 index 000000000..36ee2c600 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-domain-availability.json @@ -0,0 +1,9 @@ +{ + "domain": "WebOnly", + "availability": "webb", + "commands": [ + { + "name": "enable" + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-command-call-parameter-names.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-command-call-parameter-names.json new file mode 100644 index 000000000..bab76ca62 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-command-call-parameter-names.json @@ -0,0 +1,16 @@ +{ + "domain": "Overlay", + "commands": [ + { + "name": "processPoints", + "parameters": [ + { "name": "point", "type": "number" }, + { "name": "point", "type": "number" } + ], + "returns": [ + { "name": "result1", "type": "string" }, + { "name": "result2", "type": "string" } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-command-return-parameter-names.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-command-return-parameter-names.json new file mode 100644 index 000000000..c8bb15c04 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-command-return-parameter-names.json @@ -0,0 +1,16 @@ +{ + "domain": "Overlay", + "commands": [ + { + "name": "processPoints", + "parameters": [ + { "name": "point1", "type": "number" }, + { "name": "point2", "type": "number" } + ], + "returns": [ + { "name": "result", "type": "string" }, + { "name": "result", "type": "string" } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-event-parameter-names.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-event-parameter-names.json new file mode 100644 index 000000000..d3d3b3cc6 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-event-parameter-names.json @@ -0,0 +1,12 @@ +{ + "domain": "Overlay", + "events": [ + { + "name": "processedPoints", + "parameters": [ + { "name": "point", "type": "number" }, + { "name": "point", "type": "number" } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-type-declarations.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-type-declarations.json new file mode 100644 index 000000000..702fc6a32 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-type-declarations.json @@ -0,0 +1,15 @@ +{ + "domain": "Runtime", + "types": [ + { + "id": "RemoteObjectId", + "type": "string", + "description": "Unique object identifier." + }, + { + "id": "RemoteObjectId", + "type": "string", + "description": "Unique object identifier." + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-type-member-names.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-type-member-names.json new file mode 100644 index 000000000..aebacee8b --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-duplicate-type-member-names.json @@ -0,0 +1,15 @@ +[ +{ + "domain": "OverlayTypes", + "types": [ + { + "id": "Point", + "type": "object", + "properties": [ + { "name": "x", "type": "integer" }, + { "name": "x", "type": "integer" } + ] + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-enum-with-no-values.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-enum-with-no-values.json new file mode 100644 index 000000000..232a7c324 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-enum-with-no-values.json @@ -0,0 +1,10 @@ +{ + "domain": "Database", + "types": [ + { + "id": "PrimaryColors", + "type": "string", + "enum": [] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-number-typed-optional-parameter-flag.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-number-typed-optional-parameter-flag.json new file mode 100644 index 000000000..7308db992 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-number-typed-optional-parameter-flag.json @@ -0,0 +1,18 @@ +{ + "domain": "Database", + "types": [ + { + "id": "DatabaseId", + "type": "string", + "description": "Unique identifier of Database object." + } + ], + "events": [ + { + "name": "didExecuteOptionalParameters", + "parameters": [ + { "name": "columnNames", "type": "string", "optional": 0 } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-number-typed-optional-type-member.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-number-typed-optional-type-member.json new file mode 100644 index 000000000..afea555ec --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-number-typed-optional-type-member.json @@ -0,0 +1,16 @@ +[ +{ + "domain": "Database", + "types": [ + { + "id": "Error", + "type": "object", + "description": "Database error.", + "properties": [ + { "name": "message", "type": "string", "description": "Error message." }, + { "name": "code", "type": "integer", "description": "Error code.", "optional": 0 } + ] + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-string-typed-optional-parameter-flag.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-string-typed-optional-parameter-flag.json new file mode 100644 index 000000000..4012c79b6 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-string-typed-optional-parameter-flag.json @@ -0,0 +1,18 @@ +{ + "domain": "Database", + "types": [ + { + "id": "DatabaseId", + "type": "string", + "description": "Unique identifier of Database object." + } + ], + "events": [ + { + "name": "didExecuteOptionalParameters", + "parameters": [ + { "name": "columnNames", "type": "string", "optional": "true" } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-string-typed-optional-type-member.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-string-typed-optional-type-member.json new file mode 100644 index 000000000..ca3ef28a8 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-string-typed-optional-type-member.json @@ -0,0 +1,16 @@ +[ +{ + "domain": "Database", + "types": [ + { + "id": "Error", + "type": "object", + "description": "Database error.", + "properties": [ + { "name": "message", "type": "string", "description": "Error message." }, + { "name": "code", "type": "integer", "description": "Error code.", "optional": "false" } + ] + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-declaration-using-type-reference.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-declaration-using-type-reference.json new file mode 100644 index 000000000..19b7590cc --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-declaration-using-type-reference.json @@ -0,0 +1,13 @@ +[ +{ + "domain": "Runtime", + "types": [ + { + "id": "RemoteObjectId", + "type": "object", + "$ref": "SomeType", + "description": "Unique object identifier." + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-reference-as-primitive-type.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-reference-as-primitive-type.json new file mode 100644 index 000000000..8c83bbfce --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-reference-as-primitive-type.json @@ -0,0 +1,18 @@ +{ + "domain": "Database", + "types": [ + { + "id": "DatabaseId", + "type": "string", + "description": "Unique identifier of Database object." + } + ], + "events": [ + { + "name": "didExecuteOptionalParameters", + "parameters": [ + { "name": "columnNames", "type": "DatabaseId" } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-with-invalid-platform.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-with-invalid-platform.json new file mode 100644 index 000000000..a9fd2e995 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-with-invalid-platform.json @@ -0,0 +1,11 @@ +{ + "domain": "Runtime", + "types": [ + { + "id": "RemoteObjectId", + "type": "string", + "platform": "invalid", + "description": "Unique object identifier." + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-with-lowercase-name.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-with-lowercase-name.json new file mode 100644 index 000000000..531901e4a --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-type-with-lowercase-name.json @@ -0,0 +1,10 @@ +{ + "domain": "Database", + "types": [ + { + "id": "databaseId", + "type": "integer", + "description": "Unique identifier of Database object." + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-unknown-type-reference-in-type-declaration.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-unknown-type-reference-in-type-declaration.json new file mode 100644 index 000000000..d6887a274 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-unknown-type-reference-in-type-declaration.json @@ -0,0 +1,12 @@ +[ +{ + "domain": "Runtime", + "types": [ + { + "id": "RemoteObjectId", + "type": "dragon", + "description": "Unique object identifier." + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-unknown-type-reference-in-type-member.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-unknown-type-reference-in-type-member.json new file mode 100644 index 000000000..b817db504 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/fail-on-unknown-type-reference-in-type-member.json @@ -0,0 +1,15 @@ +[ +{ + "domain": "Fantasy", + "types": [ + { + "id": "DragonEgg", + "type": "object", + "description": "A dragon egg.", + "properties": [ + { "name": "color", "$ref": "Color" } + ] + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/generate-domains-with-feature-guards.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/generate-domains-with-feature-guards.json new file mode 100644 index 000000000..67cf8e582 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/generate-domains-with-feature-guards.json @@ -0,0 +1,36 @@ +[ +{ + "domain": "Network1", + "featureGuard": "PLATFORM(WEB_COMMANDS)", + "commands": [ + { + "name": "loadResource", + "description": "Loads a resource in the context of a frame on the inspected page without cross origin checks." + } + ] +}, +{ + "domain": "Network2", + "featureGuard": "PLATFORM(WEB_TYPES)", + "types": [ + { + "id": "NetworkError", + "type": "object", + "properties": [ + { "name": "message", "type": "string", "description": "Error message." }, + { "name": "code", "type": "integer", "description": "Error code." } + ] + } + ] +}, +{ + "domain": "Network3", + "featureGuard": "PLATFORM(WEB_EVENTS)", + "events": [ + { + "name": "resourceLoaded", + "description": "A resource was loaded." + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/same-type-id-different-domain.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/same-type-id-different-domain.json new file mode 100644 index 000000000..3bf4dff5c --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/same-type-id-different-domain.json @@ -0,0 +1,22 @@ +[ +{ + "domain": "Runtime", + "types": [ + { + "id": "RemoteObjectId", + "type": "string", + "description": "Unique object identifier." + } + ] +}, +{ + "domain": "Runtime2", + "types": [ + { + "id": "RemoteObjectId", + "type": "string", + "description": "Unique object identifier." + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/shadowed-optional-type-setters.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/shadowed-optional-type-setters.json new file mode 100644 index 000000000..20a0c1552 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/shadowed-optional-type-setters.json @@ -0,0 +1,31 @@ +{ + "domain": "Runtime", + "types": [ + { + "id": "KeyPath", + "type": "object", + "description": "Key path.", + "properties": [ + { + "name": "type", + "type": "string", + "enum": ["null", "string", "array"], + "description": "Key path type." + }, + { + "name": "string", + "type": "string", + "optional": true, + "description": "String value." + }, + { + "name": "array", + "type": "array", + "optional": true, + "items": { "type": "string" }, + "description": "Array value." + } + ] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-aliased-primitive-type.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-aliased-primitive-type.json new file mode 100644 index 000000000..cbc9d5394 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-aliased-primitive-type.json @@ -0,0 +1,10 @@ +{ + "domain": "Runtime", + "types": [ + { + "id": "RemoteObjectId", + "type": "integer", + "description": "Unique object identifier." + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-array-type.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-array-type.json new file mode 100644 index 000000000..cfb08bd94 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-array-type.json @@ -0,0 +1,50 @@ +[ +{ + "domain": "Debugger", + "types": [ + { + "id": "BreakpointId", + "type": "integer" + }, + { + "id": "Reason", + "type": "string", + "enum": ["Died", "Fainted", "Hungry"] + } + ] +}, +{ + "domain": "Runtime", + "types": [ + { + "id": "ObjectId", + "type": "integer" + }, + { + "id": "LuckyNumbers", + "type": "array", + "items": { "type": "integer" } + }, + { + "id": "BabyNames", + "type": "array", + "items": { "type": "string" } + }, + { + "id": "NewObjects", + "type": "array", + "items": { "$ref": "ObjectId" } + }, + { + "id": "OldObjects", + "type": "array", + "items": { "$ref": "Debugger.BreakpointId" } + }, + { + "id": "StopReasons", + "type": "array", + "items": { "$ref": "Debugger.Reason" } + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-enum-type.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-enum-type.json new file mode 100644 index 000000000..9f0aee9c9 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-enum-type.json @@ -0,0 +1,15 @@ +{ + "domain": "Runtime", + "types": [ + { + "id": "FarmAnimals", + "type": "string", + "enum": ["Pigs", "Cows", "Cats", "Hens"] + }, + { + "id": "TwoLeggedAnimals", + "type": "string", + "enum": ["Ducks", "Hens", "Crows", "Flamingos"] + } + ] +} diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-object-type.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-object-type.json new file mode 100644 index 000000000..178309197 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/type-declaration-object-type.json @@ -0,0 +1,83 @@ +[ +{ + "domain": "Database", + "description": "Test type builder generation of various object types.", + "types": [ + { + "id": "Error", + "type": "object", + "description": "Database error.", + "properties": [ + { "name": "message", "type": "string", "description": "Error message." }, + { "name": "code", "type": "integer", "description": "Error code." } + ] + }, + { + "id": "ErrorList", + "type": "array", + "items": { "$ref": "Error" } + }, + { + "id": "OptionalParameterBundle", + "type": "object", + "properties": [ + { "name": "columnNames", "type": "array", "optional": true, "items": { "type": "string" } }, + { "name": "notes", "type": "string", "optional": true }, + { "name": "timestamp", "type": "number", "optional": true }, + { "name": "values", "type": "object", "optional": true }, + { "name": "payload", "type": "any", "optional": true }, + { "name": "error", "$ref": "Error", "optional": true }, + { "name": "errorList", "$ref": "ErrorList", "optional": true } + ] + }, + { + "id": "ParameterBundle", + "type": "object", + "properties": [ + { "name": "columnNames", "type": "array", "items": { "type": "string" } }, + { "name": "notes", "type": "string" }, + { "name": "timestamp", "type": "number" }, + { "name": "values", "type": "object" }, + { "name": "payload", "type": "any" }, + { "name": "error", "$ref": "Error" }, + { "name": "errorList", "$ref": "ErrorList" } + ] + }, + { + "id": "ObjectWithPropertyNameConflicts", + "description": "Conflicted names may cause generated getters/setters to clash with built-in InspectorObject methods.", + "type": "object", + "properties": [ + { "name": "integer", "type": "string" }, + { "name": "array", "type": "string" }, + { "name": "string", "type": "string" }, + { "name": "value", "type": "string" }, + { "name": "object", "type": "string" } + ] + }, + { + "id": "DummyObject", + "description": "An open object that doesn't have any predefined fields.", + "type": "object" + } + ] +}, +{ + "domain": "Test", + "description": "Test the generation of special behaviors that only apply to specific classes.", + "types": [ + { + "id": "ParameterBundle", + "type": "object", + "properties": [ + { "name": "columnNames", "type": "array", "items": { "type": "string" } }, + { "name": "notes", "type": "string" }, + { "name": "timestamp", "type": "number" }, + { "name": "values", "type": "object" }, + { "name": "payload", "type": "any" }, + { "name": "error", "$ref": "Database.Error" } + ] + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/type-requiring-runtime-casts.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/type-requiring-runtime-casts.json new file mode 100644 index 000000000..83d94be89 --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/type-requiring-runtime-casts.json @@ -0,0 +1,51 @@ +[ +{ + "domain": "Test", + "types": [ + { + "id": "TypeNeedingCast", + "type": "object", + "description": "A dummy type that requires runtime casts, and forces non-primitive referenced types to also emit runtime cast helpers.", + "properties": [ + { "name": "string", "type": "string", "description": "String member." }, + { "name": "number", "type": "integer", "description": "Number member." }, + { "name": "animals", "$ref": "CastedAnimals", "description": "Enum member." }, + { "name": "id", "$ref": "CastedObjectId", "description": "Aliased member." }, + { "name": "tree", "$ref": "RecursiveObject1", "description": "Recursive object member." } + ] + }, + { + "id": "CastedObjectId", + "type": "integer" + }, + { + "id": "UncastedObjectId", + "type": "integer" + }, + { + "id": "UncastedAnimals", + "type": "string", + "enum": ["Pigs", "Cows", "Cats", "Hens"] + }, + { + "id": "CastedAnimals", + "type": "string", + "enum": ["Ducks", "Hens", "Crows", "Flamingos"] + }, + { + "id": "RecursiveObject1", + "type": "object", + "properties": [ + { "name": "obj", "$ref": "RecursiveObject2", "optional": true } + ] + }, + { + "id": "RecursiveObject2", + "type": "object", + "properties": [ + { "name": "obj", "$ref": "RecursiveObject1", "optional": true } + ] + } + ] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/tests/generic/worker-supported-domains.json b/Source/JavaScriptCore/inspector/scripts/tests/generic/worker-supported-domains.json new file mode 100644 index 000000000..5e5889afc --- /dev/null +++ b/Source/JavaScriptCore/inspector/scripts/tests/generic/worker-supported-domains.json @@ -0,0 +1,11 @@ +[ +{ + "domain": "DomainA", + "workerSupported": true, + "commands": [{"name": "enable"}] +}, +{ + "domain": "DomainB", + "commands": [{"name": "enable"}] +} +] diff --git a/Source/JavaScriptCore/inspector/scripts/xxd.pl b/Source/JavaScriptCore/inspector/scripts/xxd.pl deleted file mode 100644 index 5ee08a52d..000000000 --- a/Source/JavaScriptCore/inspector/scripts/xxd.pl +++ /dev/null @@ -1,45 +0,0 @@ -#! /usr/bin/perl - -# Copyright (C) 2010-2011 Google Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# # Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# # Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# # Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -$varname = shift; -$fname = shift; -$output = shift; - -open($input, '<', $fname) or die "Can't open file for read: $fname $!"; -$/ = undef; -$text = <$input>; -close($input); - -$text = join(', ', map('0x' . unpack("H*", $_), split(undef, $text))); - -open($output, '>', $output) or die "Can't open file for write: $output $!"; -print $output "const unsigned char $varname\[\] = {\n$text\n};\n"; -close($output); |