diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/replay/scripts | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/replay/scripts')
54 files changed, 3759 insertions, 0 deletions
diff --git a/Source/JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py b/Source/JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py new file mode 100755 index 000000000..0441ed567 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py @@ -0,0 +1,1070 @@ +#!/usr/bin/env python +# Copyright (c) 2014 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. +# +# 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 re +import sys +import string +from string import Template +import optparse +import logging +from CodeGeneratorReplayInputsTemplates import Templates + +try: + import json +except ImportError: + import simplejson as json + +# Configuration values are first looked up in the framework configuration, +# and then in the global configuration if there is no framework-specific value. +GLOBAL_CONFIG = { + "baseFilename": "ReplayInputs", + "guardCondition": "ENABLE(WEB_REPLAY)", + "traitsFrameworkName": "JavaScriptCore", + + # These are formatted as ([allowed_frameworks], (framework, header_path)). + # The generator can figure out how to format the includes. + "headerIncludes": [ + (["WebCore"], + ("WebCore", "replay/EventLoopInput.h") + ), + (["JavaScriptCore", "WebCore"], + ("JavaScriptCore", "replay/EncodedValue.h") + ), + (["JavaScriptCore"], + ("JavaScriptCore", "replay/NondeterministicInput.h") + ), + (["JavaScriptCore", "WebCore"], + ("WTF", "wtf/TypeCasts.h") + ), + (["WebCore"], + ("WTF", "wtf/text/WTFString.h") + ), + + # Testing fixtures. + (["Test"], + ("WebCore", "platform/ExternalNamespaceHeaderIncludeDummy.h") + ), + (["Test"], + ("Test", "platform/InternalNamespaceHeaderIncludeDummy.h") + ) + ], + + "implIncludes": [ + (["WebCore"], + ("WebCore", "replay/SerializationMethods.h") + ), + (["WebCore", "JavaScriptCore"], + ("JavaScriptCore", "inspector/InspectorValues.h") + ), + (["WebCore", "JavaScriptCore"], + ("WTF", "wtf/NeverDestroyed.h") + ), + + # Testing fixtures. + (["Test"], + ("WebCore", "platform/ExternalNamespaceImplIncludeDummy.h") + ), + (["Test"], + ("Test", "platform/InternalNamespaceImplIncludeDummy.h") + ) + ], +} + +FRAMEWORK_CONFIG_MAP = { + "Global": { + "prefix": "", + "namespace": "" + }, + + "WTF": { + "prefix": "WTF", + "namespace": "WTF", + }, + "JavaScriptCore": { + "prefix": "JS", + "namespace": "JSC", + "exportMacro": "JS_EXPORT_PRIVATE", + }, + "WebCore": { + "prefix": "Web", + "namespace": "WebCore", + "exportMacro": "WEBCORE_EXPORT" + }, + # Used for bindings tests. + "Test": { + "prefix": "Test", + "namespace": "Test", + "exportMacro": "TEST_EXPORT_MACRO" + } +} + +# These settings are specific to an input queue. +QUEUE_CONFIG_MAP = { + "SCRIPT_MEMOIZED": { + "enumValue": "ScriptMemoizedData", + "baseClass": "NondeterministicInput<%s>", + }, + "LOADER_MEMOIZED": { + "enumValue": "LoaderMemoizedData", + "baseClass": "NondeterministicInput<%s>", + }, + "EVENT_LOOP": { + "enumValue": "EventLoopInput", + "baseClass": "EventLoopInput<%s>", + }, +} + +# Use a global logger, which normally only logs errors. +# It can be configured to log debug messages from the CLI. +logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.ERROR) +log = logging.getLogger('global') + + +# Model classes, which transliterate JSON input. +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 == "WTF": + return Frameworks.WTF + + if frameworkString == "JavaScriptCore": + return Frameworks.JavaScriptCore + + if frameworkString == "WebCore": + return Frameworks.WebCore + + if frameworkString == "Test": + return Frameworks.Test + + raise ParseException("Unknown framework: " + frameworkString) + + +class Frameworks: + Global = Framework("Global") + WTF = Framework("WTF") + JavaScriptCore = Framework("JavaScriptCore") + WebCore = Framework("WebCore") + Test = Framework("Test") + + +class InputQueue: + def __init__(self, settings): + self._settings = settings + + def setting(self, key, default=''): + return self._settings.get(key, default) + + @staticmethod + def fromString(queueString): + if queueString == "SCRIPT_MEMOIZED": + return InputQueues.SCRIPT_MEMOIZED + + if queueString == "LOADER_MEMOIZED": + return InputQueues.LOADER_MEMOIZED + + if queueString == "EVENT_LOOP": + return InputQueues.EVENT_LOOP + + raise ParseException("Unknown input queue: " + queueString) + + +class InputQueues: + SCRIPT_MEMOIZED = InputQueue(QUEUE_CONFIG_MAP["SCRIPT_MEMOIZED"]) + LOADER_MEMOIZED = InputQueue(QUEUE_CONFIG_MAP["LOADER_MEMOIZED"]) + EVENT_LOOP = InputQueue(QUEUE_CONFIG_MAP["EVENT_LOOP"]) + + +class Input: + def __init__(self, name, description, framework, queueString, flags, guard=None): + self.name = name + self.description = description + self.framework = framework + self.queue = InputQueue.fromString(queueString) + self._flags = flags + self.guard = guard + self.members = [] # names should be unique, but ordered. + + def setting(self, key, default=''): + if key in self._flags: + return True + + return self.queue.setting(key, default) + + +class InputMember: + def __init__(self, memberName, typeName, flags=[]): + self.memberName = memberName + self.typeName = typeName + self._flags = flags + + def has_flag(self, key, default=''): + return key in self._flags + + +class TypeMode: + def __init__(self, name): + self._name = name + + @staticmethod + def fromString(modeString): + modeString = modeString.upper() + if modeString == 'SCALAR': + return TypeModes.SCALAR + if modeString == 'HEAVY_SCALAR': + return TypeModes.HEAVY_SCALAR + if modeString == 'OWNED': + return TypeModes.OWNED + if modeString == 'SHARED': + return TypeModes.SHARED + if modeString == 'VECTOR': + return TypeModes.VECTOR + + raise ParseException("Unknown type mode: " + modeString) + + +class TypeModes: + # Copy for assignment and for getter + SCALAR = TypeMode("SCALAR") + # Copy for assignment, pass by reference for getter + HEAVY_SCALAR = TypeMode("HEAVY_SCALAR") + # Move for assignment, pass by reference for getter + OWNED = TypeMode("OWNED") + # Copy a RefPtr for assignment and getter + SHARED = TypeMode("SHARED") + # Move operator for assignment, pass by reference for getter + VECTOR = TypeMode("VECTOR") + + +class Type: + def __init__(self, name, mode, framework, header, enclosing_class, values, guard_values_map, underlying_storage, flags, guard=None): + self._name = name + self.mode = mode + self.framework = framework + self.header = header + self.enclosing_class = enclosing_class + self.values = values + self.guard_values_map = guard_values_map + self.underlying_storage = underlying_storage + self._flags = flags + self.guard = guard + + def __eq__(self, other): + return self.type_name() == other.type_name() and self.mode == other.mode + + def __hash__(self): + return self._name.__hash__() + + def has_flag(self, flagString): + return flagString in self._flags + + def is_struct(self): + return self.has_flag("STRUCT") + + def is_enum_declaration(self): + return self.has_flag("ENUM") + + def is_enum_class_declaration(self): + return self.has_flag("ENUM_CLASS") + + def is_option_set(self): + return self.has_flag("OPTION_SET") + + def is_enumerable(self): + return self.is_enum_declaration() or self.is_enum_class_declaration() or self.is_option_set() + + def declaration_kind(self): + if self.is_enum_declaration(): + return "enum" + elif self.is_enum_class_declaration(): + return "enum class" + # If the enumerable is an OptionSet<T>, then T must be forward declared as an enum class. + elif self.is_option_set(): + return "enum class" + elif self.is_struct(): + return "struct" + else: + return "class" + + def qualified_prefix(self): + components = [] + if self.framework != Frameworks.Global: + components.append(self.framework.setting('namespace')) + if self.enclosing_class is not None: + components.append(self.enclosing_class) + components.append("") + return "::".join(components) + + def type_name(self, qualified=False): + if qualified: + return "%s%s" % (self.qualified_prefix(), self._name) + elif self.enclosing_class is not None: + return "%s::%s" % (self.enclosing_class, self._name) + else: + return self._name + + def storage_type(self, qualified=False): + if self.mode == TypeModes.OWNED: + return "std::unique_ptr<%s>" % self.type_name(qualified) + elif self.mode == TypeModes.SHARED: + return "RefPtr<%s>" % self.type_name(qualified) + else: + return self.type_name(qualified) + + def borrow_type(self, qualified=False): + if self.mode == TypeModes.SCALAR: + return self.type_name(qualified) + elif self.mode == TypeModes.SHARED: + return "RefPtr<%s>" % self.type_name(qualified) + else: + return "const %s&" % self.type_name(qualified) + + def argument_type(self, qualified=False): + if self.mode == TypeModes.SHARED: + return "RefPtr<%s>&&" % self.type_name(qualified) + else: + return self.storage_type() + + def encoding_type_argument(self, qualified=False): + return self.type_name(qualified=qualified) + + +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 VectorType(Type): + def __init__(self, element_type): + self._element_type = element_type + self.mode = TypeModes.VECTOR + self.framework = element_type.framework + self.enclosing_class = None + + def has_flag(self): + return False + + def is_struct(self): + return False + + def is_enum_declaration(self): + return False + + def is_enum_class_declaration(self): + return False + + def is_option_set(self): + return False + + def qualified_prefix(self): + return "" + + def type_name(self, qualified=False): + return "Vector<%s>" % self._element_type.storage_type(qualified=qualified) + + def encoding_type_argument(self, qualified=False): + return "Vector<%s>" % self._element_type.type_name(qualified=qualified) + + def argument_type(self, qualified=False): + return self.type_name(qualified=qualified) + "&" + + +class InputsModel: + def __init__(self): + self.inputs = [] + self.types = [] + + # Types have associated frameworks and are in their namespace, but within the specification + # file types are in a flat namespace. Types with the same name are not allowed. + self.types_by_name = {} + self.inputs_by_name = {} + + def enumerable_types(self): + _enumerables = filter(lambda x: x.is_enumerable(), self.types) + return sorted(_enumerables, key=lambda _enumerable: _enumerable.type_name()) + + def get_type_for_member(self, member): + if member.has_flag("VECTOR"): + return VectorType(self.types_by_name.get(member.typeName)) + else: + return self.types_by_name.get(member.typeName) + + def parse_specification(self, json): + if 'types' in json: + if not isinstance(json['types'], dict): + raise ParseException("Malformed specification: types is not a dict of framework->type list") + + for framework_name, type_list in json['types'].iteritems(): + if not isinstance(type_list, list): + raise ParseException("Malformed specification: type list for framework %s is not a list" % framework_name) + + framework = Framework.fromString(framework_name) + for _type in type_list: + self.parse_type_with_framework(_type, framework) + + if 'inputs' in json: + if not isinstance(json['inputs'], dict): + raise ParseException("Malformed specification: inputs is not a dict of framework->input list") + + for framework_name, input_list in json['inputs'].iteritems(): + if not isinstance(input_list, list): + raise ParseException("Malformed specification: input list for framework %s is not a list" % framework_name) + + framework = Framework.fromString(framework_name) + for _input in input_list: + self.parse_input_with_framework(_input, framework) + + def parse_type_with_framework(self, json, framework): + check_for_required_properties(['name', 'mode'], json, 'type') + if framework is not Frameworks.Global: + check_for_required_properties(['header'], json, 'non-global type') + + type_name = json['name'] + type_mode = TypeMode.fromString(json['mode']) + header = json.get('header') + enclosing_class = json.get('enclosing_class') + enumerable_values = json.get('values') + guarded_enumerable_values = json.get('guarded_values', {}) + type_storage = json.get('storage') + type_flags = json.get('flags', []) + guard = json.get('guard', None) + _type = Type(type_name, type_mode, framework, header, enclosing_class, enumerable_values, guarded_enumerable_values, type_storage, type_flags, guard) + if _type.is_enumerable(): + check_for_required_properties(['values'], json, 'enum') + if not isinstance(json['values'], list) or len(_type.values) == 0: + raise ParseException("Malformed specification: enumerable type %s does not supply a list of values" % type_name) + + if _type.is_enum_declaration() and enclosing_class is None and type_storage is None: + raise ParseException("Could not parse enumerable type %s: C-style enum declarations not enclosed by a class must specify their storage type so they can be forward declared." % type_name) + + self.types.append(_type) + + def parse_input_with_framework(self, json, framework): + check_for_required_properties(['name', 'description', 'queue', 'members'], json, 'input') + _input = Input(json['name'], json['description'], framework, json['queue'], json.get('flags', []), json.get('guard')) + if isinstance(json['members'], list): + for member in json['members']: + check_for_required_properties(['name', 'type'], member, 'member') + _input.members.append(InputMember(member['name'], member['type'], member.get('flags', []))) + + self.inputs.append(_input) + + # Types cannot (yet) reference other types, so we can check references in one pass. + def resolve_types(self): + for _type in self.types: + self.typecheck_type(_type) + + for _input in self.inputs: + self.typecheck_input(_input) + + def typecheck_type(self, _type): + log.debug("typecheck type " + _type.type_name()) + + if _type.type_name() in self.types_by_name: + raise TypecheckException("Duplicate type with name: " + _type.type_name()) + + self.types_by_name[_type.type_name()] = _type + + def typecheck_input(self, _input): + log.debug("typecheck input " + _input.name) + + if _input.name in self.inputs_by_name: + raise TypecheckException("Duplicate input with name: " + _input.name) + + seen_members = {} + + for member in _input.members: + if member.memberName in seen_members: + raise TypecheckException("Duplicate input member with name: " + member.memberName) + + self.typecheck_input_member(member, _input) + seen_members[member.memberName] = member + + self.inputs_by_name[_input.name] = _input + + def typecheck_input_member(self, input_member, _input): + log.debug("typecheck member '%s' of '%s'" % (input_member.memberName, _input.name)) + + if not input_member.typeName in self.types_by_name: + raise TypecheckException("Unknown type '%s' referenced by member '%s' of input '%s'" % (input_member.typeName, input_member.memberName, _input.name)) + + +# 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: + 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 wrap_with_guard(contents, condition=None): + if condition is None: + return contents + + return "\n".join([ + "#if %s" % condition, + contents, + "#endif // %s" % condition + ]) + + +class Generator: + def __init__(self, model, target_framework_name, input_filepath, output_prefix): + self._model = model + self.target_framework = Framework.fromString(target_framework_name) + self.traits_framework = Framework.fromString(self.setting('traitsFrameworkName')) + self._input_filepath = input_filepath + self._output_prefix = output_prefix + + def setting(self, key, default=''): + return self.target_framework.setting(key, GLOBAL_CONFIG.get(key, default)) + + def should_generate_item(self, item): + return item.framework is self.target_framework + + # This does not account for any filename mangling performed on behalf of the test harness. + def output_filename(self, extension=None): + components = [] + if len(self._output_prefix) > 0: + components.extend([self._output_prefix, '-']) + + components.extend([self.setting('prefix'), self.setting('baseFilename')]) + + if extension is not None: + components.extend(['.', extension]) + + return "".join(components) + + def write_output_files(self, _dir, force=False): + header_file = IncrementalFileWriter(os.path.join(_dir, self.output_filename('h')), force) + implementation_file = IncrementalFileWriter(os.path.join(_dir, self.output_filename('cpp')), force) + + header_file.write(self.generate_header()) + implementation_file.write(self.generate_implementation()) + + header_file.close() + implementation_file.close() + + def generate_header(self): + enumerable_types_to_generate = filter(self.should_generate_item, self._model.enumerable_types()) + inputs_to_generate = filter(self.should_generate_item, self._model.inputs) + + template_arguments = { + 'licenseBlock': self.generate_license(), + 'filename': self.output_filename(), + 'guardCondition': self.setting('guardCondition'), + 'traitsNamespace': self.traits_framework.setting('namespace'), + 'inputsNamespace': self.target_framework.setting('namespace'), + 'includes': self.generate_includes(defaults=self.setting('headerIncludes')), + 'typeForwardDeclarations': self.generate_type_forward_declarations(), + 'inputForwardDeclarations': "\n".join([wrap_with_guard("class %s;", _input.guard) % _input.name for _input in inputs_to_generate]), + 'inputClassDeclarations': "\n\n".join([self.generate_class_declaration(_input) for _input in inputs_to_generate]), + 'inputTraitDeclarations': "\n\n".join([self.generate_input_trait_declaration(_input) for _input in inputs_to_generate]), + 'inputTypeTraitDeclarations': "\n\n".join([self.generate_input_type_trait_declaration(_input) for _input in inputs_to_generate]), + 'enumerableTypeTraitDeclarations': "\n\n".join([wrap_with_guard(self.generate_enumerable_type_trait_declaration(_type), _type.guard) for _type in enumerable_types_to_generate]), + 'forEachMacro': self.generate_for_each_macro(), + } + + return Template(Templates.HeaderSkeleton).substitute(template_arguments) + + def generate_implementation(self): + enumerable_types_to_generate = filter(self.should_generate_item, self._model.enumerable_types()) + inputs_to_generate = filter(self.should_generate_item, self._model.inputs) + + template_arguments = { + 'licenseBlock': self.generate_license(), + 'filename': self.output_filename(), + 'guardCondition': self.setting('guardCondition'), + 'traitsNamespace': self.traits_framework.setting('namespace'), + 'inputsNamespace': self.target_framework.setting('namespace'), + 'includes': self.generate_includes(defaults=self.setting('implIncludes'), includes_for_types=True), + 'inputClassImplementations': "\n\n".join([self.generate_class_implementation(_input) for _input in inputs_to_generate]), + 'inputTraitImplementations': "\n\n".join([self.generate_input_trait_implementation(_input) for _input in inputs_to_generate]), + 'enumerableTypeTraitImplementations': "\n\n".join([wrap_with_guard(self.generate_enumerable_type_trait_implementation(_type), _type.guard) for _type in enumerable_types_to_generate]), + } + + return Template(Templates.ImplementationSkeleton).substitute(template_arguments) + + def generate_license(self): + return Template(Templates.CopyrightBlock).substitute(None, inputFilename=os.path.basename(self._input_filepath)) + + def generate_includes(self, defaults=[], includes_for_types=False): + lines = set() + + for _type in self._model.types: + # Types in the "global" framework are implicitly declared and available in all namespaces. + if _type.framework is Frameworks.Global: + continue + # For RefCounted types, we reverse when to include the header so that the destructor can be + # used in the header file. + include_for_destructor = _type.mode is TypeModes.SHARED + # Enum declarations within classes cannot be forward declared, so we include + # headers with the relevant class declaration. + include_for_enclosing_class = _type.enclosing_class is not None + # Include headers for types like URL and String which are copied, not owned or shared. + include_for_copyable_member = _type.mode is TypeModes.HEAVY_SCALAR + if (not includes_for_types) ^ (include_for_destructor or include_for_enclosing_class or include_for_copyable_member): + continue + + if self.target_framework != _type.framework: + lines.add("#include <%s>" % _type.header) + else: + lines.add("#include \"%s\"" % os.path.basename(_type.header)) + + for entry in defaults: + (allowed_framework_names, data) = entry + (framework_name, header_path) = data + + if self.target_framework.name not in allowed_framework_names: + continue + if self.target_framework.name != framework_name: + lines.add("#include <%s>" % header_path) + else: + lines.add("#include \"%s\"" % os.path.basename(header_path)) + + return "\n".join(sorted(list(lines))) + + def generate_type_forward_declarations(self): + lines = [] + + decls_by_framework = {} + frameworks = [Framework.fromString(s) for s in FRAMEWORK_CONFIG_MAP.keys() if s != Frameworks.Global.name] + for framework in frameworks: + decls_by_framework[framework] = [] + + for _type in self._model.types: + if _type.framework not in frameworks: + continue + if _type.enclosing_class is not None: + continue + if _type.mode == TypeModes.HEAVY_SCALAR: + continue + if _type.mode == TypeModes.SCALAR and not _type.is_enumerable(): + continue + if _type.is_enum_declaration(): + declaration = "enum %s : %s;" % (_type.type_name(), _type.underlying_storage) + else: + declaration = "%s %s;" % (_type.declaration_kind(), _type.type_name()) + decls_by_framework[_type.framework].append(declaration) + + # Declare all namespaces explicitly, even if it's the main namespace. + for framework in frameworks: + if len(decls_by_framework[framework]) == 0: + continue + + decls_by_framework[framework].sort() + lines.append("namespace %s {" % framework.setting('namespace')) + lines.extend(decls_by_framework[framework]) + lines.append("}") + lines.append("") + + return "\n".join(lines) + + def generate_class_declaration(self, _input): + extra_declarations = [] + if _input.queue == InputQueues.EVENT_LOOP: + extra_declarations.extend([ + "", + " // EventLoopInput API", + " virtual void dispatch(ReplayController&) final;", + ]) + + if _input.setting('CREATE_FROM_PAGE'): + extra_declarations.extend([ + " static std::unique_ptr<%s> createFromPage(const Page&);" % _input.name + ]) + + member_getters = [self.generate_input_member_getter(_member) for _member in _input.members] + + member_declarations = [self.generate_input_member_declaration(_member) for _member in _input.members] + if len(member_declarations) > 0: + member_declarations.insert(0, "private:") + + template_arguments = { + 'inputConstructor': self.generate_input_constructor_declaration(_input), + 'inputDestructor': self.generate_input_destructor_declaration(_input), + 'inputName': _input.name, + 'inputQueue': _input.setting('enumValue'), + 'baseClass': _input.setting('baseClass') % _input.name, + 'extraDeclarations': "\n".join(extra_declarations), + 'memberGetters': "\n".join(member_getters), + 'memberDeclarations': "\n".join(member_declarations), + } + + return wrap_with_guard(Template(Templates.InputClassDeclaration).substitute(template_arguments), _input.guard) + + def generate_input_constructor_declaration(self, _input): + formals_list = self.generate_constructor_formals_list(_input) + terms = [] + if self.setting('exportMacro'): + terms.append(self.setting('exportMacro')) + terms.append("%s(%s)" % (_input.name, formals_list)) + return " %s;" % " ".join(terms) + + def generate_input_destructor_declaration(self, _input): + return " virtual ~%s();" % _input.name + + def generate_input_member_getter(self, _member): + member_type = self._model.get_type_for_member(_member) + return " %s %s() const { return %s; }" % (member_type.borrow_type(), _member.memberName, self.generate_member_borrow_expression(_member)) + + def generate_input_member_declaration(self, _member): + member_type = self._model.get_type_for_member(_member) + return " %s m_%s;" % (member_type.storage_type(), _member.memberName) + + def generate_input_member_tuples(self, _input): + return [(_member, self._model.get_type_for_member(_member)) for _member in _input.members] + + def qualified_input_name(self, _input, forceQualified=False): + if forceQualified or self.target_framework != self.traits_framework: + return "%s::%s" % (self.target_framework.setting('namespace'), _input.name) + else: + return _input.name + + def generate_input_trait_declaration(self, _input): + decl_type = ['struct'] + if len(self.setting('exportMacro')) > 0: + decl_type.append(self.setting('exportMacro')) + + template_arguments = { + 'structOrClass': " ".join(decl_type), + 'queueType': _input.queue.setting('enumValue'), + 'qualifiedInputName': self.qualified_input_name(_input), + } + + return wrap_with_guard(Template(Templates.InputTraitsDeclaration).substitute(template_arguments), _input.guard) + + def generate_input_type_trait_declaration(self, _input): + template_arguments = { + 'qualifiedInputName': self.qualified_input_name(_input, forceQualified=True), + } + + return wrap_with_guard(Template(Templates.InputTypeTraitsDeclaration).substitute(template_arguments), _input.guard) + + def generate_enumerable_type_trait_declaration(self, _type): + decl_type = ['struct'] + if len(self.setting('exportMacro')) > 0: + decl_type.append(self.setting('exportMacro')) + + should_qualify_type = _type.framework != self.traits_framework + decoded_type = _type.type_name(qualified=should_qualify_type) + if _type.is_option_set(): + decoded_type = "OptionSet<%s>" % decoded_type + + template_arguments = { + 'encodingTypeArgument': _type.encoding_type_argument(qualified=should_qualify_type), + 'enumerableType': decoded_type, + 'structOrClass': " ".join(decl_type) + } + return Template(Templates.EnumerableTypeTraitDeclaration).substitute(template_arguments) + + def generate_for_each_macro(self): + inputs_to_generate = filter(self.should_generate_item, self._model.inputs) + + macro_name = "%s_REPLAY_INPUT_NAMES_FOR_EACH" % self.setting('prefix').upper() + lines = [] + lines.append("#define %s(macro) \\" % macro_name) + lines.extend([" macro(%s) \\" % _input.name for _input in inputs_to_generate]) + lines.append(" \\") + lines.append("// end of %s" % macro_name) + return "\n".join(lines) + + def generate_class_implementation(self, _input): + template_arguments = { + 'inputName': _input.name, + 'inputsNamespace': self.target_framework.setting('namespace'), + 'initializerList': self.generate_constructor_initializer_list(_input), + 'constructorFormalsList': self.generate_constructor_formals_list(_input), + } + + return wrap_with_guard(Template(Templates.InputClassImplementation).substitute(template_arguments), _input.guard) + + def generate_enumerable_type_trait_implementation(self, _type): + should_qualify_type = _type.framework != self.traits_framework + prefix_components = [] + if should_qualify_type: + prefix_components.append(_type.framework.setting('namespace')) + if _type.is_enum_declaration() and _type.enclosing_class is not None: + prefix_components.append(_type.enclosing_class) + elif _type.is_enum_class_declaration() or _type.is_option_set(): + prefix_components.append(_type.type_name(qualified=False)) + prefix_components.append("") + enumerable_type_prefix = "::".join(prefix_components) + encodeLines = [] + + if _type.is_enum_declaration(): + encode_template = Templates.EnumTypeEncodeCase + decode_template = Templates.EnumTypeDecodeCase + enumerable_type_trait_template = Templates.EnumTypeTraitImplementation + elif _type.is_enum_class_declaration(): + encode_template = Templates.EnumClassTypeEncodeCase + decode_template = Templates.EnumClassTypeDecodeCase + enumerable_type_trait_template = Templates.EnumClassTypeTraitImplementation + else: # Thus, _type.is_option_set(). + encode_template = Templates.OptionSetTypeEncodeCase + decode_template = Templates.OptionSetTypeDecodeCase + enumerable_type_trait_template = Templates.OptionSetTypeTraitImplementation + + # Generate body for encode. + for _value in _type.values: + template_arguments = { + 'enumStringValue': _value, + 'qualifiedEnumValue': "%s%s" % (enumerable_type_prefix, _value), + } + encodeLines.append(Template(encode_template).substitute(template_arguments)) + + for guard, guard_values in _type.guard_values_map.iteritems(): + guardedLines = [] + for guard_value in guard_values: + template_arguments = { + 'enumStringValue': guard_value, + 'qualifiedEnumValue': "%s%s" % (enumerable_type_prefix, guard_value), + } + guardedLines.append(Template(encode_template).substitute(template_arguments)) + encodeLines.append(wrap_with_guard("\n".join(guardedLines), guard)) + + # Generate body for decode. + decodeLines = [] + for i, _value in enumerate(_type.values): + + template_arguments = { + 'branchKeyword': "else if" if i > 0 else "if", + 'enumStringValue': _value, + 'qualifiedEnumValue': "%s%s" % (enumerable_type_prefix, _value), + 'qualifiedEnumName': _type.type_name(qualified=should_qualify_type) + } + decodeLines.append(Template(decode_template).substitute(template_arguments)) + + for guard, guard_values in _type.guard_values_map.iteritems(): + guardedLines = [] + for i, guard_value in enumerate(guard_values): + template_arguments = { + 'branchKeyword': "else if" if i > 0 else "if", + 'enumStringValue': guard_value, + 'qualifiedEnumValue': "%s%s" % (enumerable_type_prefix, guard_value), + 'qualifiedEnumName': _type.type_name(qualified=should_qualify_type) + } + guardedLines.append(Template(decode_template).substitute(template_arguments)) + decodeLines.append(wrap_with_guard("\n".join(guardedLines), guard)) + + enumerable_type = _type.type_name(qualified=should_qualify_type) + if _type.is_option_set(): + enumerable_type = "OptionSet<%s>" % enumerable_type + + template_arguments = { + 'encodingTypeArgument': _type.encoding_type_argument(qualified=should_qualify_type), + 'enumerableType': enumerable_type, + 'encodeCases': "\n".join(encodeLines), + 'decodeCases': "\n".join(decodeLines) + } + + return Template(enumerable_type_trait_template).substitute(template_arguments) + + def generate_input_trait_implementation(self, _input): + template_arguments = { + 'inputsNamespace': self.target_framework.setting('namespace'), + 'inputNameStringLiteral': '"%s"' % _input.name, + 'qualifiedInputName': self.qualified_input_name(_input), + 'constructorArguments': self.generate_constructor_arguments_list(_input), + 'constructorFormalsList': self.generate_constructor_formals_list(_input), + 'encodeSteps': self.generate_input_encode_implementation(_input), + 'decodeSteps': self.generate_input_decode_implementation(_input), + } + return wrap_with_guard(Template(Templates.InputTraitsImplementation).substitute(template_arguments), _input.guard) + + def generate_input_encode_implementation(self, _input): + steps = [] + for (_member, _type) in self.generate_input_member_tuples(_input): + should_qualify_type = _type.framework != self.traits_framework + put_method = "put<%s>" % _type.encoding_type_argument(qualified=should_qualify_type) + + steps.extend([ + " encodedValue.%s(ASCIILiteral(\"%s\"), input.%s());" % (put_method, _member.memberName, _member.memberName) + ]) + + if len(steps) == 0: + steps.extend([ + " UNUSED_PARAM(encodedValue);", + " UNUSED_PARAM(input);", + ]) + + return "\n".join(steps) + + def generate_input_decode_implementation(self, _input): + steps = [] + for (_member, _type) in self.generate_input_member_tuples(_input): + should_qualify_type = _type.framework != self.traits_framework + get_method = "get<%s>" % _type.encoding_type_argument(qualified=should_qualify_type) + + lines = [ + " %s %s;" % (_type.storage_type(qualified=should_qualify_type), _member.memberName), + " if (!encodedValue.%s(ASCIILiteral(\"%s\"), %s))" % (get_method, _member.memberName, _member.memberName), + " return false;", + "" + ] + + steps.append("\n".join(lines)) + + if len(steps) == 0: + steps.extend([ + " UNUSED_PARAM(encodedValue);", + ]) + + return "\n".join(steps) + + def generate_constructor_initializer_list(self, _input): + initializers = [] + initializers.append(" : %s()" % (_input.setting('baseClass') % _input.name)) + for _member in _input.members: + initializers.append(" , m_%s(%s)" % (_member.memberName, self.generate_member_move_expression(_member))) + + return "\n".join(initializers) + + def generate_constructor_formals_list(self, _input): + member_tuples = self.generate_input_member_tuples(_input) + return ", ".join(["%s %s" % (_type.argument_type(), _member.memberName) for (_member, _type) in member_tuples]) + + def generate_member_borrow_expression(self, _member): + _type = self._model.get_type_for_member(_member) + expression = "m_%s" % _member.memberName + if _type.mode == TypeModes.OWNED: + expression = "*" + expression + + return expression + + def generate_member_move_expression(self, _member): + _type = self._model.get_type_for_member(_member) + if _type.mode in [TypeModes.OWNED, TypeModes.SHARED]: + return "WTFMove(%s)" % _member.memberName + else: + return _member.memberName + + def generate_constructor_arguments_list(self, _input): + return ", ".join([self.generate_member_move_expression(_member) for _member in _input.members]) + + +def generate_from_specifications(input_filepaths=[], output_prefix="", output_dirpath=None, framework_name=None, force_output=False): + + if not framework_name in FRAMEWORK_CONFIG_MAP: + raise ParseException("Unknown or unsupported framework name supplied: " + framework_name) + + if len(input_filepaths) == 0: + raise ParseException("Must provide at least one specification file, none were provided.") + + def parse_json_from_file(input_filepath): + try: + with open(input_filepath, "r") as input_file: + return json.load(input_file) + except ValueError as e: + raise Exception("Error parsing valid JSON in file: " + input_filepath) + + specifications = map(parse_json_from_file, input_filepaths) + + model = InputsModel() + for spec in specifications: + model.parse_specification(spec) + + model.resolve_types() + generator = Generator(model, framework_name, input_filepaths[0], output_prefix) + + generator.write_output_files(output_dirpath, force_output) + + +if __name__ == '__main__': + allowed_framework_names = FRAMEWORK_CONFIG_MAP.keys() + + cli_parser = optparse.OptionParser(usage="usage: %prog [options] <Inputs.json> [, <MoreInputs.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 these inputs belong to.") # JavaScriptCore, WebCore + 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.") + + options = None + + arg_options, arg_values = cli_parser.parse_args() + + if not arg_options.outputDir: + raise ParseException("Missing output directory") + + if arg_options.debug: + log.setLevel(logging.DEBUG) + + options = { + 'input_filepaths': arg_values, + 'output_dirpath': arg_options.outputDir, + 'output_prefix': os.path.basename(arg_values[0]) if arg_options.test else "", + 'framework_name': arg_options.framework, + 'force_output': arg_options.force + } + + try: + generate_from_specifications(**options) + except (ParseException, TypecheckException) as e: + if arg_options.test: + log.error(e.message) + else: + raise e # Force the build to fail. diff --git a/Source/JavaScriptCore/replay/scripts/CodeGeneratorReplayInputsTemplates.py b/Source/JavaScriptCore/replay/scripts/CodeGeneratorReplayInputsTemplates.py new file mode 100755 index 000000000..953e67f02 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/CodeGeneratorReplayInputsTemplates.py @@ -0,0 +1,265 @@ +#!/usr/bin/env python +# Copyright (c) 2011 Google Inc. All rights reserved. +# Copyright (c) 2012 Intel Corporation. All rights reserved. +# Copyright (c) 2013, 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: +# +# * 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. + + +# Generator templates, which can be filled with string.Template. +# Following are classes that fill the templates from the typechecked model. + +class Templates: + CopyrightBlock = ( + """/* + * Copyright (C) 2014 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 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 + * HOLDER 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. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from ${inputFilename} +// by the script: JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py""") + + HeaderSkeleton = ( + """${licenseBlock} + +#pragma once + +#if ${guardCondition} +${includes} + +${typeForwardDeclarations} + +namespace ${inputsNamespace} { +${inputForwardDeclarations} +} // namespace ${inputsNamespace} + +namespace ${traitsNamespace} { +${inputTraitDeclarations} +${enumerableTypeTraitDeclarations} +} // namespace ${traitsNamespace} + +namespace ${inputsNamespace} { +${inputClassDeclarations} +} // namespace ${inputsNamespace} + +${inputTypeTraitDeclarations} + +${forEachMacro} + +#endif // ${guardCondition} +""") + + InputTraitsDeclaration = ( + """template<> ${structOrClass} InputTraits<${qualifiedInputName}> { + static InputQueue queue() { return InputQueue::${queueType}; } + static const String& type(); + + static void encode(JSC::EncodedValue&, const ${qualifiedInputName}&); + static bool decode(JSC::EncodedValue&, std::unique_ptr<${qualifiedInputName}>&); +};""") + + InputTypeTraitsDeclaration = ( + """SPECIALIZE_TYPE_TRAITS_BEGIN(${qualifiedInputName}) + static bool isType(const NondeterministicInputBase& input) { return input.type() == InputTraits<${qualifiedInputName}>::type(); } +SPECIALIZE_TYPE_TRAITS_END()""") + + EnumerableTypeTraitDeclaration = ( + """template<> ${structOrClass} EncodingTraits<${encodingTypeArgument}> { + typedef ${enumerableType} DecodedType; + + static EncodedValue encodeValue(const ${enumerableType}& value); + static bool decodeValue(EncodedValue&, ${enumerableType}& value); +};""") + + InputClassDeclaration = ( + """class ${inputName} : public ${baseClass} { +public: +${inputConstructor} +${inputDestructor} +${extraDeclarations} +${memberGetters} +${memberDeclarations} +};""") + + ImplementationSkeleton = ( + """${licenseBlock} + +#include "config.h" +#include "${filename}.h" + +#if ${guardCondition} +${includes} + +namespace ${inputsNamespace} { +${inputClassImplementations} +} // namespace ${inputsNamespace} + +namespace ${traitsNamespace} { +${inputTraitImplementations} +${enumerableTypeTraitImplementations} +} // namespace ${traitsNamespace} + +#endif // ${guardCondition} +""") + + InputTraitsImplementation = ( + """const String& InputTraits<${qualifiedInputName}>::type() +{ + static NeverDestroyed<const String> type(ASCIILiteral(${inputNameStringLiteral})); + return type; +} + +void InputTraits<${qualifiedInputName}>::encode(EncodedValue& encodedValue, const ${qualifiedInputName}& input) +{ +${encodeSteps} +} + +bool InputTraits<${qualifiedInputName}>::decode(EncodedValue& encodedValue, std::unique_ptr<${qualifiedInputName}>& input) +{ +${decodeSteps} + input = std::make_unique<${qualifiedInputName}>(${constructorArguments}); + return true; +}""") + + EnumClassTypeTraitImplementation = ( + """EncodedValue EncodingTraits<${encodingTypeArgument}>::encodeValue(const ${enumerableType}& enumValue) +{ + switch (enumValue) { +${encodeCases} + default: ASSERT_NOT_REACHED(); return EncodedValue::createString("Error!"); + } +} + +bool EncodingTraits<${encodingTypeArgument}>::decodeValue(EncodedValue& encodedValue, ${enumerableType}& enumValue) +{ + String enumString = encodedValue.convertTo<String>(); +${decodeCases} + return false; +}""") + + EnumClassTypeEncodeCase = ( + """ case ${qualifiedEnumValue}: return EncodedValue::createString("${enumStringValue}");""") + + EnumClassTypeDecodeCase = ( + """ if (enumString == "${enumStringValue}") { + enumValue = ${qualifiedEnumValue}; + return true; + }""") + + EnumTypeTraitImplementation = ( + """EncodedValue EncodingTraits<${encodingTypeArgument}>::encodeValue(const ${enumerableType}& enumValue) +{ + EncodedValue encodedValue = EncodedValue::createArray(); +${encodeCases} + return encodedValue; +} + +bool EncodingTraits<${encodingTypeArgument}>::decodeValue(EncodedValue& encodedValue, ${enumerableType}& enumValue) +{ + Vector<String> enumStrings; + if (!EncodingTraits<Vector<String>>::decodeValue(encodedValue, enumStrings)) + return false; + + for (const String& enumString : enumStrings) { +${decodeCases} + } + + return true; +}""") + + EnumTypeEncodeCase = ( + """ if (enumValue & ${qualifiedEnumValue}) { + encodedValue.append<String>(ASCIILiteral("${enumStringValue}")); + if (enumValue == ${qualifiedEnumValue}) + return encodedValue; + }""") + + EnumTypeDecodeCase = ( + """ ${branchKeyword} (enumString == "${enumStringValue}") + enumValue = static_cast<${qualifiedEnumName}>(enumValue | ${qualifiedEnumValue});""") + + OptionSetTypeTraitImplementation = ( + """EncodedValue EncodingTraits<${encodingTypeArgument}>::encodeValue(const ${enumerableType}& enumValue) +{ + EncodedValue encodedValue = EncodedValue::createArray(); +${encodeCases} + + return encodedValue; +} + +bool EncodingTraits<${encodingTypeArgument}>::decodeValue(EncodedValue& encodedValue, ${enumerableType}& enumValue) +{ + Vector<String> enumStrings; + if (!EncodingTraits<Vector<String>>::decodeValue(encodedValue, enumStrings)) + return false; + + for (const String& enumString : enumStrings) { +${decodeCases} + } + + return true; +}""") + + OptionSetTypeEncodeCase = ( + """ if (enumValue.contains(${qualifiedEnumValue})) + encodedValue.append<String>(ASCIILiteral("${enumStringValue}"));""") + + OptionSetTypeDecodeCase = ( + """ ${branchKeyword} (enumString == "${enumStringValue}") + enumValue |= ${qualifiedEnumValue};""") + + + InputClassImplementation = ( + """${inputName}::${inputName}(${constructorFormalsList}) +${initializerList} +{ +} + +${inputName}::~${inputName}() +{ +}""") diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-c-style-enum-no-storage.json-error b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-c-style-enum-no-storage.json-error new file mode 100644 index 000000000..9ef00c4aa --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-c-style-enum-no-storage.json-error @@ -0,0 +1 @@ +ERROR: Could not parse enumerable type MouseButton: C-style enum declarations not enclosed by a class must specify their storage type so they can be forward declared. diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-duplicate-enum-type.json-error b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-duplicate-enum-type.json-error new file mode 100644 index 000000000..ef750bf0e --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-duplicate-enum-type.json-error @@ -0,0 +1 @@ +ERROR: Duplicate type with name: PlatformEvent::Type diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-duplicate-input-names.json-error b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-duplicate-input-names.json-error new file mode 100644 index 000000000..d31ec8023 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-duplicate-input-names.json-error @@ -0,0 +1 @@ +ERROR: Duplicate input with name: GetCurrentTime diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-duplicate-type-names.json-error b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-duplicate-type-names.json-error new file mode 100644 index 000000000..d1e4c47bb --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-duplicate-type-names.json-error @@ -0,0 +1 @@ +ERROR: Duplicate type with name: uint64_t diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-enum-type-missing-values.json-error b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-enum-type-missing-values.json-error new file mode 100644 index 000000000..b4a348cf6 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-enum-type-missing-values.json-error @@ -0,0 +1 @@ +ERROR: When parsing enum, required property missing: values diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-missing-input-member-name.json-error b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-missing-input-member-name.json-error new file mode 100644 index 000000000..0bb2869d2 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-missing-input-member-name.json-error @@ -0,0 +1 @@ +ERROR: When parsing member, required property missing: name diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-missing-input-name.json-error b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-missing-input-name.json-error new file mode 100644 index 000000000..b599607a7 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-missing-input-name.json-error @@ -0,0 +1 @@ +ERROR: When parsing input, required property missing: name diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-missing-input-queue.json-error b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-missing-input-queue.json-error new file mode 100644 index 000000000..c7919ab55 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-missing-input-queue.json-error @@ -0,0 +1 @@ +ERROR: When parsing input, required property missing: queue diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-missing-type-mode.json-error b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-missing-type-mode.json-error new file mode 100644 index 000000000..6929f4f8a --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-missing-type-mode.json-error @@ -0,0 +1 @@ +ERROR: When parsing type, required property missing: mode diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-missing-type-name.json-error b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-missing-type-name.json-error new file mode 100644 index 000000000..0aad90019 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-missing-type-name.json-error @@ -0,0 +1 @@ +ERROR: When parsing type, required property missing: name diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-unknown-input-queue.json-error b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-unknown-input-queue.json-error new file mode 100644 index 000000000..acf469b68 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-unknown-input-queue.json-error @@ -0,0 +1 @@ +ERROR: Unknown input queue: SCRIPT_MEOIZED diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-unknown-member-type.json-error b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-unknown-member-type.json-error new file mode 100644 index 000000000..d31e454c6 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-unknown-member-type.json-error @@ -0,0 +1 @@ +ERROR: Unknown type 'double' referenced by member 'randomSeed' of input 'SetRandomSeed' diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-unknown-type-mode.json-error b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-unknown-type-mode.json-error new file mode 100644 index 000000000..952c69ec8 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-unknown-type-mode.json-error @@ -0,0 +1 @@ +ERROR: Unknown type mode: BONKERS diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers-with-guarded-values.json-TestReplayInputs.cpp b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers-with-guarded-values.json-TestReplayInputs.cpp new file mode 100644 index 000000000..d5b15855b --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers-with-guarded-values.json-TestReplayInputs.cpp @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2014 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 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 + * HOLDER 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. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-enum-encoding-helpers-with-guarded-values.json +// by the script: JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py + +#include "config.h" +#include "generate-enum-encoding-helpers-with-guarded-values.json-TestReplayInputs.h" + +#if ENABLE(WEB_REPLAY) +#include "InternalNamespaceImplIncludeDummy.h" +#include <platform/ExternalNamespaceImplIncludeDummy.h> +#include <platform/PlatformMouseEvent.h> + +namespace Test { +SavedMouseButton::SavedMouseButton(MouseButton button) + : NondeterministicInput<SavedMouseButton>() + , m_button(button) +{ +} + +SavedMouseButton::~SavedMouseButton() +{ +} +} // namespace Test + +namespace JSC { +const String& InputTraits<Test::SavedMouseButton>::type() +{ + static NeverDestroyed<const String> type(ASCIILiteral("SavedMouseButton")); + return type; +} + +void InputTraits<Test::SavedMouseButton>::encode(EncodedValue& encodedValue, const Test::SavedMouseButton& input) +{ + encodedValue.put<WebCore::MouseButton>(ASCIILiteral("button"), input.button()); +} + +bool InputTraits<Test::SavedMouseButton>::decode(EncodedValue& encodedValue, std::unique_ptr<Test::SavedMouseButton>& input) +{ + WebCore::MouseButton button; + if (!encodedValue.get<WebCore::MouseButton>(ASCIILiteral("button"), button)) + return false; + + input = std::make_unique<Test::SavedMouseButton>(button); + return true; +} + +} // namespace JSC + +#endif // ENABLE(WEB_REPLAY) diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers-with-guarded-values.json-TestReplayInputs.h b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers-with-guarded-values.json-TestReplayInputs.h new file mode 100644 index 000000000..913fffb50 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers-with-guarded-values.json-TestReplayInputs.h @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2014 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 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 + * HOLDER 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. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-enum-encoding-helpers-with-guarded-values.json +// by the script: JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py + +#pragma once + +#if ENABLE(WEB_REPLAY) +#include "InternalNamespaceHeaderIncludeDummy.h" +#include <platform/ExternalNamespaceHeaderIncludeDummy.h> + +namespace WebCore { +enum MouseButton : unsigned; +} + + +namespace Test { +class SavedMouseButton; +} // namespace Test + +namespace JSC { +template<> struct TEST_EXPORT_MACRO InputTraits<Test::SavedMouseButton> { + static InputQueue queue() { return InputQueue::ScriptMemoizedData; } + static const String& type(); + + static void encode(JSC::EncodedValue&, const Test::SavedMouseButton&); + static bool decode(JSC::EncodedValue&, std::unique_ptr<Test::SavedMouseButton>&); +}; + +} // namespace JSC + +namespace Test { +class SavedMouseButton : public NondeterministicInput<SavedMouseButton> { +public: + TEST_EXPORT_MACRO SavedMouseButton(MouseButton button); + virtual ~SavedMouseButton(); + + MouseButton button() const { return m_button; } +private: + MouseButton m_button; +}; +} // namespace Test + +SPECIALIZE_TYPE_TRAITS_BEGIN(Test::SavedMouseButton) + static bool isType(const NondeterministicInputBase& input) { return input.type() == InputTraits<Test::SavedMouseButton>::type(); } +SPECIALIZE_TYPE_TRAITS_END() + +#define TEST_REPLAY_INPUT_NAMES_FOR_EACH(macro) \ + macro(SavedMouseButton) \ + \ +// end of TEST_REPLAY_INPUT_NAMES_FOR_EACH + +#endif // ENABLE(WEB_REPLAY) diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.cpp b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.cpp new file mode 100644 index 000000000..4ed407ca3 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.cpp @@ -0,0 +1,228 @@ +/* + * Copyright (C) 2014 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 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 + * HOLDER 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. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-enum-encoding-helpers.json +// by the script: JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py + +#include "config.h" +#include "generate-enum-encoding-helpers.json-TestReplayInputs.h" + +#if ENABLE(WEB_REPLAY) +#include "InternalNamespaceImplIncludeDummy.h" +#include "NondeterministicInput.h" +#include "PlatformMouseEvent.h" +#include <platform/ExternalNamespaceImplIncludeDummy.h> + +namespace Test { +SavedMouseButton::SavedMouseButton(MouseButton button) + : NondeterministicInput<SavedMouseButton>() + , m_button(button) +{ +} + +SavedMouseButton::~SavedMouseButton() +{ +} +} // namespace Test + +namespace JSC { +const String& InputTraits<Test::SavedMouseButton>::type() +{ + static NeverDestroyed<const String> type(ASCIILiteral("SavedMouseButton")); + return type; +} + +void InputTraits<Test::SavedMouseButton>::encode(EncodedValue& encodedValue, const Test::SavedMouseButton& input) +{ + encodedValue.put<Test::MouseButton>(ASCIILiteral("button"), input.button()); +} + +bool InputTraits<Test::SavedMouseButton>::decode(EncodedValue& encodedValue, std::unique_ptr<Test::SavedMouseButton>& input) +{ + Test::MouseButton button; + if (!encodedValue.get<Test::MouseButton>(ASCIILiteral("button"), button)) + return false; + + input = std::make_unique<Test::SavedMouseButton>(button); + return true; +} +EncodedValue EncodingTraits<Test::InputQueue>::encodeValue(const Test::InputQueue& enumValue) +{ + switch (enumValue) { + case Test::InputQueue::EventLoopInput: return EncodedValue::createString("EventLoopInput"); + case Test::InputQueue::LoaderMemoizedData: return EncodedValue::createString("LoaderMemoizedData"); + case Test::InputQueue::ScriptMemoizedData: return EncodedValue::createString("ScriptMemoizedData"); + default: ASSERT_NOT_REACHED(); return EncodedValue::createString("Error!"); + } +} + +bool EncodingTraits<Test::InputQueue>::decodeValue(EncodedValue& encodedValue, Test::InputQueue& enumValue) +{ + String enumString = encodedValue.convertTo<String>(); + if (enumString == "EventLoopInput") { + enumValue = Test::InputQueue::EventLoopInput; + return true; + } + if (enumString == "LoaderMemoizedData") { + enumValue = Test::InputQueue::LoaderMemoizedData; + return true; + } + if (enumString == "ScriptMemoizedData") { + enumValue = Test::InputQueue::ScriptMemoizedData; + return true; + } + return false; +} + +EncodedValue EncodingTraits<Test::MouseButton>::encodeValue(const Test::MouseButton& enumValue) +{ + EncodedValue encodedValue = EncodedValue::createArray(); + if (enumValue & Test::NoButton) { + encodedValue.append<String>(ASCIILiteral("NoButton")); + if (enumValue == Test::NoButton) + return encodedValue; + } + if (enumValue & Test::LeftButton) { + encodedValue.append<String>(ASCIILiteral("LeftButton")); + if (enumValue == Test::LeftButton) + return encodedValue; + } + if (enumValue & Test::MiddleButton) { + encodedValue.append<String>(ASCIILiteral("MiddleButton")); + if (enumValue == Test::MiddleButton) + return encodedValue; + } + if (enumValue & Test::RightButton) { + encodedValue.append<String>(ASCIILiteral("RightButton")); + if (enumValue == Test::RightButton) + return encodedValue; + } + return encodedValue; +} + +bool EncodingTraits<Test::MouseButton>::decodeValue(EncodedValue& encodedValue, Test::MouseButton& enumValue) +{ + Vector<String> enumStrings; + if (!EncodingTraits<Vector<String>>::decodeValue(encodedValue, enumStrings)) + return false; + + for (const String& enumString : enumStrings) { + if (enumString == "NoButton") + enumValue = static_cast<Test::MouseButton>(enumValue | Test::NoButton); + else if (enumString == "LeftButton") + enumValue = static_cast<Test::MouseButton>(enumValue | Test::LeftButton); + else if (enumString == "MiddleButton") + enumValue = static_cast<Test::MouseButton>(enumValue | Test::MiddleButton); + else if (enumString == "RightButton") + enumValue = static_cast<Test::MouseButton>(enumValue | Test::RightButton); + } + + return true; +} + +EncodedValue EncodingTraits<Test::PlatformEvent::OtherType>::encodeValue(const OptionSet<Test::PlatformEvent::OtherType>& enumValue) +{ + EncodedValue encodedValue = EncodedValue::createArray(); + if (enumValue.contains(Test::PlatformEvent::OtherType::Mouse)) + encodedValue.append<String>(ASCIILiteral("Mouse")); + if (enumValue.contains(Test::PlatformEvent::OtherType::Key)) + encodedValue.append<String>(ASCIILiteral("Key")); + if (enumValue.contains(Test::PlatformEvent::OtherType::Touch)) + encodedValue.append<String>(ASCIILiteral("Touch")); + if (enumValue.contains(Test::PlatformEvent::OtherType::Wheel)) + encodedValue.append<String>(ASCIILiteral("Wheel")); + + return encodedValue; +} + +bool EncodingTraits<Test::PlatformEvent::OtherType>::decodeValue(EncodedValue& encodedValue, OptionSet<Test::PlatformEvent::OtherType>& enumValue) +{ + Vector<String> enumStrings; + if (!EncodingTraits<Vector<String>>::decodeValue(encodedValue, enumStrings)) + return false; + + for (const String& enumString : enumStrings) { + if (enumString == "Mouse") + enumValue |= Test::PlatformEvent::OtherType::Mouse; + else if (enumString == "Key") + enumValue |= Test::PlatformEvent::OtherType::Key; + else if (enumString == "Touch") + enumValue |= Test::PlatformEvent::OtherType::Touch; + else if (enumString == "Wheel") + enumValue |= Test::PlatformEvent::OtherType::Wheel; + } + + return true; +} + +EncodedValue EncodingTraits<Test::PlatformEvent::Type>::encodeValue(const Test::PlatformEvent::Type& enumValue) +{ + EncodedValue encodedValue = EncodedValue::createArray(); + if (enumValue & Test::PlatformEvent::Mouse) { + encodedValue.append<String>(ASCIILiteral("Mouse")); + if (enumValue == Test::PlatformEvent::Mouse) + return encodedValue; + } + if (enumValue & Test::PlatformEvent::Key) { + encodedValue.append<String>(ASCIILiteral("Key")); + if (enumValue == Test::PlatformEvent::Key) + return encodedValue; + } + if (enumValue & Test::PlatformEvent::Touch) { + encodedValue.append<String>(ASCIILiteral("Touch")); + if (enumValue == Test::PlatformEvent::Touch) + return encodedValue; + } + if (enumValue & Test::PlatformEvent::Wheel) { + encodedValue.append<String>(ASCIILiteral("Wheel")); + if (enumValue == Test::PlatformEvent::Wheel) + return encodedValue; + } + return encodedValue; +} + +bool EncodingTraits<Test::PlatformEvent::Type>::decodeValue(EncodedValue& encodedValue, Test::PlatformEvent::Type& enumValue) +{ + Vector<String> enumStrings; + if (!EncodingTraits<Vector<String>>::decodeValue(encodedValue, enumStrings)) + return false; + + for (const String& enumString : enumStrings) { + if (enumString == "Mouse") + enumValue = static_cast<Test::PlatformEvent::Type>(enumValue | Test::PlatformEvent::Mouse); + else if (enumString == "Key") + enumValue = static_cast<Test::PlatformEvent::Type>(enumValue | Test::PlatformEvent::Key); + else if (enumString == "Touch") + enumValue = static_cast<Test::PlatformEvent::Type>(enumValue | Test::PlatformEvent::Touch); + else if (enumString == "Wheel") + enumValue = static_cast<Test::PlatformEvent::Type>(enumValue | Test::PlatformEvent::Wheel); + } + + return true; +} +} // namespace JSC + +#endif // ENABLE(WEB_REPLAY) diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.h b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.h new file mode 100644 index 000000000..37bd92fef --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.h @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2014 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 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 + * HOLDER 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. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-enum-encoding-helpers.json +// by the script: JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py + +#pragma once + +#if ENABLE(WEB_REPLAY) +#include "InternalNamespaceHeaderIncludeDummy.h" +#include "PlatformEvent.h" +#include <platform/ExternalNamespaceHeaderIncludeDummy.h> + +namespace Test { +enum MouseButton : unsigned; +enum class InputQueue; +} + + +namespace Test { +class SavedMouseButton; +} // namespace Test + +namespace JSC { +template<> struct TEST_EXPORT_MACRO InputTraits<Test::SavedMouseButton> { + static InputQueue queue() { return InputQueue::ScriptMemoizedData; } + static const String& type(); + + static void encode(JSC::EncodedValue&, const Test::SavedMouseButton&); + static bool decode(JSC::EncodedValue&, std::unique_ptr<Test::SavedMouseButton>&); +}; +template<> struct TEST_EXPORT_MACRO EncodingTraits<Test::InputQueue> { + typedef Test::InputQueue DecodedType; + + static EncodedValue encodeValue(const Test::InputQueue& value); + static bool decodeValue(EncodedValue&, Test::InputQueue& value); +}; + +template<> struct TEST_EXPORT_MACRO EncodingTraits<Test::MouseButton> { + typedef Test::MouseButton DecodedType; + + static EncodedValue encodeValue(const Test::MouseButton& value); + static bool decodeValue(EncodedValue&, Test::MouseButton& value); +}; + +template<> struct TEST_EXPORT_MACRO EncodingTraits<Test::PlatformEvent::OtherType> { + typedef OptionSet<Test::PlatformEvent::OtherType> DecodedType; + + static EncodedValue encodeValue(const OptionSet<Test::PlatformEvent::OtherType>& value); + static bool decodeValue(EncodedValue&, OptionSet<Test::PlatformEvent::OtherType>& value); +}; + +template<> struct TEST_EXPORT_MACRO EncodingTraits<Test::PlatformEvent::Type> { + typedef Test::PlatformEvent::Type DecodedType; + + static EncodedValue encodeValue(const Test::PlatformEvent::Type& value); + static bool decodeValue(EncodedValue&, Test::PlatformEvent::Type& value); +}; +} // namespace JSC + +namespace Test { +class SavedMouseButton : public NondeterministicInput<SavedMouseButton> { +public: + TEST_EXPORT_MACRO SavedMouseButton(MouseButton button); + virtual ~SavedMouseButton(); + + MouseButton button() const { return m_button; } +private: + MouseButton m_button; +}; +} // namespace Test + +SPECIALIZE_TYPE_TRAITS_BEGIN(Test::SavedMouseButton) + static bool isType(const NondeterministicInputBase& input) { return input.type() == InputTraits<Test::SavedMouseButton>::type(); } +SPECIALIZE_TYPE_TRAITS_END() + +#define TEST_REPLAY_INPUT_NAMES_FOR_EACH(macro) \ + macro(SavedMouseButton) \ + \ +// end of TEST_REPLAY_INPUT_NAMES_FOR_EACH + +#endif // ENABLE(WEB_REPLAY) diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-with-guard.json-TestReplayInputs.cpp b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-with-guard.json-TestReplayInputs.cpp new file mode 100644 index 000000000..486756e96 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-with-guard.json-TestReplayInputs.cpp @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2014 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 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 + * HOLDER 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. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-enum-with-guard.json +// by the script: JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py + +#include "config.h" +#include "generate-enum-with-guard.json-TestReplayInputs.h" + +#if ENABLE(WEB_REPLAY) +#include "InternalNamespaceImplIncludeDummy.h" +#include "PlatformWheelEvent.h" +#include <platform/ExternalNamespaceImplIncludeDummy.h> +#include <platform/PlatformWheelEvent.h> + +namespace Test { +HandleWheelEvent::HandleWheelEvent(std::unique_ptr<PlatformWheelEvent> platformEvent, PlatformWheelPhase phase) + : EventLoopInput<HandleWheelEvent>() + , m_platformEvent(WTFMove(platformEvent)) + , m_phase(phase) +{ +} + +HandleWheelEvent::~HandleWheelEvent() +{ +} +} // namespace Test + +namespace JSC { +const String& InputTraits<Test::HandleWheelEvent>::type() +{ + static NeverDestroyed<const String> type(ASCIILiteral("HandleWheelEvent")); + return type; +} + +void InputTraits<Test::HandleWheelEvent>::encode(EncodedValue& encodedValue, const Test::HandleWheelEvent& input) +{ + encodedValue.put<WebCore::PlatformWheelEvent>(ASCIILiteral("platformEvent"), input.platformEvent()); + encodedValue.put<Test::PlatformWheelPhase>(ASCIILiteral("phase"), input.phase()); +} + +bool InputTraits<Test::HandleWheelEvent>::decode(EncodedValue& encodedValue, std::unique_ptr<Test::HandleWheelEvent>& input) +{ + std::unique_ptr<WebCore::PlatformWheelEvent> platformEvent; + if (!encodedValue.get<WebCore::PlatformWheelEvent>(ASCIILiteral("platformEvent"), platformEvent)) + return false; + + Test::PlatformWheelPhase phase; + if (!encodedValue.get<Test::PlatformWheelPhase>(ASCIILiteral("phase"), phase)) + return false; + + input = std::make_unique<Test::HandleWheelEvent>(WTFMove(platformEvent), phase); + return true; +} +#if ENABLE(DUMMY_FEATURE) +EncodedValue EncodingTraits<Test::PlatformWheelPhase>::encodeValue(const Test::PlatformWheelPhase& enumValue) +{ + EncodedValue encodedValue = EncodedValue::createArray(); + if (enumValue & Test::PlatformWheelEventPhaseNone) { + encodedValue.append<String>(ASCIILiteral("PlatformWheelEventPhaseNone")); + if (enumValue == Test::PlatformWheelEventPhaseNone) + return encodedValue; + } + return encodedValue; +} + +bool EncodingTraits<Test::PlatformWheelPhase>::decodeValue(EncodedValue& encodedValue, Test::PlatformWheelPhase& enumValue) +{ + Vector<String> enumStrings; + if (!EncodingTraits<Vector<String>>::decodeValue(encodedValue, enumStrings)) + return false; + + for (const String& enumString : enumStrings) { + if (enumString == "PlatformWheelEventPhaseNone") + enumValue = static_cast<Test::PlatformWheelPhase>(enumValue | Test::PlatformWheelEventPhaseNone); + } + + return true; +} +#endif // ENABLE(DUMMY_FEATURE) +} // namespace JSC + +#endif // ENABLE(WEB_REPLAY) diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-with-guard.json-TestReplayInputs.h b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-with-guard.json-TestReplayInputs.h new file mode 100644 index 000000000..adab4b7db --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-with-guard.json-TestReplayInputs.h @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2014 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 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 + * HOLDER 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. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-enum-with-guard.json +// by the script: JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py + +#pragma once + +#if ENABLE(WEB_REPLAY) +#include "InternalNamespaceHeaderIncludeDummy.h" +#include <platform/ExternalNamespaceHeaderIncludeDummy.h> + +namespace Test { +enum PlatformWheelPhase : uint64_t; +} + +namespace WebCore { +class PlatformWheelEvent; +} + + +namespace Test { +class HandleWheelEvent; +} // namespace Test + +namespace JSC { +template<> struct TEST_EXPORT_MACRO InputTraits<Test::HandleWheelEvent> { + static InputQueue queue() { return InputQueue::EventLoopInput; } + static const String& type(); + + static void encode(JSC::EncodedValue&, const Test::HandleWheelEvent&); + static bool decode(JSC::EncodedValue&, std::unique_ptr<Test::HandleWheelEvent>&); +}; +#if ENABLE(DUMMY_FEATURE) +template<> struct TEST_EXPORT_MACRO EncodingTraits<Test::PlatformWheelPhase> { + typedef Test::PlatformWheelPhase DecodedType; + + static EncodedValue encodeValue(const Test::PlatformWheelPhase& value); + static bool decodeValue(EncodedValue&, Test::PlatformWheelPhase& value); +}; +#endif // ENABLE(DUMMY_FEATURE) +} // namespace JSC + +namespace Test { +class HandleWheelEvent : public EventLoopInput<HandleWheelEvent> { +public: + TEST_EXPORT_MACRO HandleWheelEvent(std::unique_ptr<PlatformWheelEvent> platformEvent, PlatformWheelPhase phase); + virtual ~HandleWheelEvent(); + + // EventLoopInput API + virtual void dispatch(ReplayController&) final; + const PlatformWheelEvent& platformEvent() const { return *m_platformEvent; } + PlatformWheelPhase phase() const { return m_phase; } +private: + std::unique_ptr<PlatformWheelEvent> m_platformEvent; + PlatformWheelPhase m_phase; +}; +} // namespace Test + +SPECIALIZE_TYPE_TRAITS_BEGIN(Test::HandleWheelEvent) + static bool isType(const NondeterministicInputBase& input) { return input.type() == InputTraits<Test::HandleWheelEvent>::type(); } +SPECIALIZE_TYPE_TRAITS_END() + +#define TEST_REPLAY_INPUT_NAMES_FOR_EACH(macro) \ + macro(HandleWheelEvent) \ + \ +// end of TEST_REPLAY_INPUT_NAMES_FOR_EACH + +#endif // ENABLE(WEB_REPLAY) diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.cpp b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.cpp new file mode 100644 index 000000000..a19644ffa --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.cpp @@ -0,0 +1,144 @@ +/* + * Copyright (C) 2014 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 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 + * HOLDER 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. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-enums-with-same-base-name.json +// by the script: JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py + +#include "config.h" +#include "generate-enums-with-same-base-name.json-TestReplayInputs.h" + +#if ENABLE(WEB_REPLAY) +#include "InternalNamespaceImplIncludeDummy.h" +#include <platform/ExternalNamespaceImplIncludeDummy.h> + +namespace Test { +FormCombo::FormCombo(PlatformEvent1::Type eventType1, PlatformEvent2::Type eventType2, FormData1::Type formType1, FormData2::Type formType2) + : NondeterministicInput<FormCombo>() + , m_eventType1(eventType1) + , m_eventType2(eventType2) + , m_formType1(formType1) + , m_formType2(formType2) +{ +} + +FormCombo::~FormCombo() +{ +} +} // namespace Test + +namespace JSC { +const String& InputTraits<Test::FormCombo>::type() +{ + static NeverDestroyed<const String> type(ASCIILiteral("FormCombo")); + return type; +} + +void InputTraits<Test::FormCombo>::encode(EncodedValue& encodedValue, const Test::FormCombo& input) +{ + encodedValue.put<PlatformEvent1::Type>(ASCIILiteral("eventType1"), input.eventType1()); + encodedValue.put<PlatformEvent2::Type>(ASCIILiteral("eventType2"), input.eventType2()); + encodedValue.put<Test::FormData1::Type>(ASCIILiteral("formType1"), input.formType1()); + encodedValue.put<Test::FormData2::Type>(ASCIILiteral("formType2"), input.formType2()); +} + +bool InputTraits<Test::FormCombo>::decode(EncodedValue& encodedValue, std::unique_ptr<Test::FormCombo>& input) +{ + PlatformEvent1::Type eventType1; + if (!encodedValue.get<PlatformEvent1::Type>(ASCIILiteral("eventType1"), eventType1)) + return false; + + PlatformEvent2::Type eventType2; + if (!encodedValue.get<PlatformEvent2::Type>(ASCIILiteral("eventType2"), eventType2)) + return false; + + Test::FormData1::Type formType1; + if (!encodedValue.get<Test::FormData1::Type>(ASCIILiteral("formType1"), formType1)) + return false; + + Test::FormData2::Type formType2; + if (!encodedValue.get<Test::FormData2::Type>(ASCIILiteral("formType2"), formType2)) + return false; + + input = std::make_unique<Test::FormCombo>(eventType1, eventType2, formType1, formType2); + return true; +} +EncodedValue EncodingTraits<Test::FormData1::Type>::encodeValue(const Test::FormData1::Type& enumValue) +{ + EncodedValue encodedValue = EncodedValue::createArray(); + if (enumValue & Test::FormData1::Text) { + encodedValue.append<String>(ASCIILiteral("Text")); + if (enumValue == Test::FormData1::Text) + return encodedValue; + } + if (enumValue & Test::FormData1::Blob) { + encodedValue.append<String>(ASCIILiteral("Blob")); + if (enumValue == Test::FormData1::Blob) + return encodedValue; + } + return encodedValue; +} + +bool EncodingTraits<Test::FormData1::Type>::decodeValue(EncodedValue& encodedValue, Test::FormData1::Type& enumValue) +{ + Vector<String> enumStrings; + if (!EncodingTraits<Vector<String>>::decodeValue(encodedValue, enumStrings)) + return false; + + for (const String& enumString : enumStrings) { + if (enumString == "Text") + enumValue = static_cast<Test::FormData1::Type>(enumValue | Test::FormData1::Text); + else if (enumString == "Blob") + enumValue = static_cast<Test::FormData1::Type>(enumValue | Test::FormData1::Blob); + } + + return true; +} + +EncodedValue EncodingTraits<Test::FormData2::Type>::encodeValue(const Test::FormData2::Type& enumValue) +{ + switch (enumValue) { + case Test::FormData2::Type::Text: return EncodedValue::createString("Text"); + case Test::FormData2::Type::Blob: return EncodedValue::createString("Blob"); + default: ASSERT_NOT_REACHED(); return EncodedValue::createString("Error!"); + } +} + +bool EncodingTraits<Test::FormData2::Type>::decodeValue(EncodedValue& encodedValue, Test::FormData2::Type& enumValue) +{ + String enumString = encodedValue.convertTo<String>(); + if (enumString == "Text") { + enumValue = Test::FormData2::Type::Text; + return true; + } + if (enumString == "Blob") { + enumValue = Test::FormData2::Type::Blob; + return true; + } + return false; +} +} // namespace JSC + +#endif // ENABLE(WEB_REPLAY) diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.h b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.h new file mode 100644 index 000000000..86d43be47 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.h @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2014 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 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 + * HOLDER 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. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-enums-with-same-base-name.json +// by the script: JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py + +#pragma once + +#if ENABLE(WEB_REPLAY) +#include "FormData1.h" +#include "FormData2.h" +#include "InternalNamespaceHeaderIncludeDummy.h" +#include <platform/ExternalNamespaceHeaderIncludeDummy.h> +#include <replay/PlatformEvent.h> + + + +namespace Test { +class FormCombo; +} // namespace Test + +namespace JSC { +template<> struct TEST_EXPORT_MACRO InputTraits<Test::FormCombo> { + static InputQueue queue() { return InputQueue::ScriptMemoizedData; } + static const String& type(); + + static void encode(JSC::EncodedValue&, const Test::FormCombo&); + static bool decode(JSC::EncodedValue&, std::unique_ptr<Test::FormCombo>&); +}; +template<> struct TEST_EXPORT_MACRO EncodingTraits<Test::FormData1::Type> { + typedef Test::FormData1::Type DecodedType; + + static EncodedValue encodeValue(const Test::FormData1::Type& value); + static bool decodeValue(EncodedValue&, Test::FormData1::Type& value); +}; + +template<> struct TEST_EXPORT_MACRO EncodingTraits<Test::FormData2::Type> { + typedef Test::FormData2::Type DecodedType; + + static EncodedValue encodeValue(const Test::FormData2::Type& value); + static bool decodeValue(EncodedValue&, Test::FormData2::Type& value); +}; +} // namespace JSC + +namespace Test { +class FormCombo : public NondeterministicInput<FormCombo> { +public: + TEST_EXPORT_MACRO FormCombo(PlatformEvent1::Type eventType1, PlatformEvent2::Type eventType2, FormData1::Type formType1, FormData2::Type formType2); + virtual ~FormCombo(); + + PlatformEvent1::Type eventType1() const { return m_eventType1; } + PlatformEvent2::Type eventType2() const { return m_eventType2; } + FormData1::Type formType1() const { return m_formType1; } + FormData2::Type formType2() const { return m_formType2; } +private: + PlatformEvent1::Type m_eventType1; + PlatformEvent2::Type m_eventType2; + FormData1::Type m_formType1; + FormData2::Type m_formType2; +}; +} // namespace Test + +SPECIALIZE_TYPE_TRAITS_BEGIN(Test::FormCombo) + static bool isType(const NondeterministicInputBase& input) { return input.type() == InputTraits<Test::FormCombo>::type(); } +SPECIALIZE_TYPE_TRAITS_END() + +#define TEST_REPLAY_INPUT_NAMES_FOR_EACH(macro) \ + macro(FormCombo) \ + \ +// end of TEST_REPLAY_INPUT_NAMES_FOR_EACH + +#endif // ENABLE(WEB_REPLAY) diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/generate-event-loop-shape-types.json-error b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-event-loop-shape-types.json-error new file mode 100644 index 000000000..90a4176bf --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-event-loop-shape-types.json-error @@ -0,0 +1 @@ +ERROR: Unknown type mode: MAP diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/generate-input-with-guard.json-TestReplayInputs.cpp b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-input-with-guard.json-TestReplayInputs.cpp new file mode 100644 index 000000000..9cbb7af33 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-input-with-guard.json-TestReplayInputs.cpp @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2014 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 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 + * HOLDER 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. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-input-with-guard.json +// by the script: JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py + +#include "config.h" +#include "generate-input-with-guard.json-TestReplayInputs.h" + +#if ENABLE(WEB_REPLAY) +#include "InternalNamespaceImplIncludeDummy.h" +#include <platform/ExternalNamespaceImplIncludeDummy.h> + +namespace Test { +#if ENABLE(DUMMY_FEATURE) +GetCurrentTime::GetCurrentTime(double currentTime) + : NondeterministicInput<GetCurrentTime>() + , m_currentTime(currentTime) +{ +} + +GetCurrentTime::~GetCurrentTime() +{ +} +#endif // ENABLE(DUMMY_FEATURE) + +SetRandomSeed::SetRandomSeed(uint64_t randomSeed) + : NondeterministicInput<SetRandomSeed>() + , m_randomSeed(randomSeed) +{ +} + +SetRandomSeed::~SetRandomSeed() +{ +} +} // namespace Test + +namespace JSC { +#if ENABLE(DUMMY_FEATURE) +const String& InputTraits<Test::GetCurrentTime>::type() +{ + static NeverDestroyed<const String> type(ASCIILiteral("GetCurrentTime")); + return type; +} + +void InputTraits<Test::GetCurrentTime>::encode(EncodedValue& encodedValue, const Test::GetCurrentTime& input) +{ + encodedValue.put<double>(ASCIILiteral("currentTime"), input.currentTime()); +} + +bool InputTraits<Test::GetCurrentTime>::decode(EncodedValue& encodedValue, std::unique_ptr<Test::GetCurrentTime>& input) +{ + double currentTime; + if (!encodedValue.get<double>(ASCIILiteral("currentTime"), currentTime)) + return false; + + input = std::make_unique<Test::GetCurrentTime>(currentTime); + return true; +} +#endif // ENABLE(DUMMY_FEATURE) + +const String& InputTraits<Test::SetRandomSeed>::type() +{ + static NeverDestroyed<const String> type(ASCIILiteral("SetRandomSeed")); + return type; +} + +void InputTraits<Test::SetRandomSeed>::encode(EncodedValue& encodedValue, const Test::SetRandomSeed& input) +{ + encodedValue.put<uint64_t>(ASCIILiteral("randomSeed"), input.randomSeed()); +} + +bool InputTraits<Test::SetRandomSeed>::decode(EncodedValue& encodedValue, std::unique_ptr<Test::SetRandomSeed>& input) +{ + uint64_t randomSeed; + if (!encodedValue.get<uint64_t>(ASCIILiteral("randomSeed"), randomSeed)) + return false; + + input = std::make_unique<Test::SetRandomSeed>(randomSeed); + return true; +} + +} // namespace JSC + +#endif // ENABLE(WEB_REPLAY) diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/generate-input-with-guard.json-TestReplayInputs.h b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-input-with-guard.json-TestReplayInputs.h new file mode 100644 index 000000000..6d9346ef5 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-input-with-guard.json-TestReplayInputs.h @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2014 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 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 + * HOLDER 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. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-input-with-guard.json +// by the script: JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py + +#pragma once + +#if ENABLE(WEB_REPLAY) +#include "InternalNamespaceHeaderIncludeDummy.h" +#include <platform/ExternalNamespaceHeaderIncludeDummy.h> + + + +namespace Test { +#if ENABLE(DUMMY_FEATURE) +class GetCurrentTime; +#endif // ENABLE(DUMMY_FEATURE) +class SetRandomSeed; +} // namespace Test + +namespace JSC { +#if ENABLE(DUMMY_FEATURE) +template<> struct TEST_EXPORT_MACRO InputTraits<Test::GetCurrentTime> { + static InputQueue queue() { return InputQueue::ScriptMemoizedData; } + static const String& type(); + + static void encode(JSC::EncodedValue&, const Test::GetCurrentTime&); + static bool decode(JSC::EncodedValue&, std::unique_ptr<Test::GetCurrentTime>&); +}; +#endif // ENABLE(DUMMY_FEATURE) + +template<> struct TEST_EXPORT_MACRO InputTraits<Test::SetRandomSeed> { + static InputQueue queue() { return InputQueue::ScriptMemoizedData; } + static const String& type(); + + static void encode(JSC::EncodedValue&, const Test::SetRandomSeed&); + static bool decode(JSC::EncodedValue&, std::unique_ptr<Test::SetRandomSeed>&); +}; + +} // namespace JSC + +namespace Test { +#if ENABLE(DUMMY_FEATURE) +class GetCurrentTime : public NondeterministicInput<GetCurrentTime> { +public: + TEST_EXPORT_MACRO GetCurrentTime(double currentTime); + virtual ~GetCurrentTime(); + + double currentTime() const { return m_currentTime; } +private: + double m_currentTime; +}; +#endif // ENABLE(DUMMY_FEATURE) + +class SetRandomSeed : public NondeterministicInput<SetRandomSeed> { +public: + TEST_EXPORT_MACRO SetRandomSeed(uint64_t randomSeed); + virtual ~SetRandomSeed(); + + uint64_t randomSeed() const { return m_randomSeed; } +private: + uint64_t m_randomSeed; +}; +} // namespace Test + +#if ENABLE(DUMMY_FEATURE) +SPECIALIZE_TYPE_TRAITS_BEGIN(Test::GetCurrentTime) + static bool isType(const NondeterministicInputBase& input) { return input.type() == InputTraits<Test::GetCurrentTime>::type(); } +SPECIALIZE_TYPE_TRAITS_END() +#endif // ENABLE(DUMMY_FEATURE) + +SPECIALIZE_TYPE_TRAITS_BEGIN(Test::SetRandomSeed) + static bool isType(const NondeterministicInputBase& input) { return input.type() == InputTraits<Test::SetRandomSeed>::type(); } +SPECIALIZE_TYPE_TRAITS_END() + +#define TEST_REPLAY_INPUT_NAMES_FOR_EACH(macro) \ + macro(GetCurrentTime) \ + macro(SetRandomSeed) \ + \ +// end of TEST_REPLAY_INPUT_NAMES_FOR_EACH + +#endif // ENABLE(WEB_REPLAY) diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/generate-input-with-vector-members.json-TestReplayInputs.cpp b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-input-with-vector-members.json-TestReplayInputs.cpp new file mode 100644 index 000000000..f2f962a19 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-input-with-vector-members.json-TestReplayInputs.cpp @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2014 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 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 + * HOLDER 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. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-input-with-vector-members.json +// by the script: JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py + +#include "config.h" +#include "generate-input-with-vector-members.json-TestReplayInputs.h" + +#if ENABLE(WEB_REPLAY) +#include "InternalNamespaceImplIncludeDummy.h" +#include <platform/ExternalNamespaceImplIncludeDummy.h> +#include <things/JSThing.h> +#include <things/WebThing.h> + +namespace Test { +ArrayOfThings::ArrayOfThings(Vector<double>& doubles, Vector<JSThing>& jsthings, Vector<WebThing>& webthings) + : NondeterministicInput<ArrayOfThings>() + , m_doubles(doubles) + , m_jsthings(jsthings) + , m_webthings(webthings) +{ +} + +ArrayOfThings::~ArrayOfThings() +{ +} + +SavedHistory::SavedHistory(Vector<RefPtr<HistoryItem>>& entries) + : NondeterministicInput<SavedHistory>() + , m_entries(entries) +{ +} + +SavedHistory::~SavedHistory() +{ +} +} // namespace Test + +namespace JSC { +const String& InputTraits<Test::ArrayOfThings>::type() +{ + static NeverDestroyed<const String> type(ASCIILiteral("ArrayOfThings")); + return type; +} + +void InputTraits<Test::ArrayOfThings>::encode(EncodedValue& encodedValue, const Test::ArrayOfThings& input) +{ + encodedValue.put<Vector<double>>(ASCIILiteral("doubles"), input.doubles()); + encodedValue.put<Vector<JSThing>>(ASCIILiteral("jsthings"), input.jsthings()); + encodedValue.put<Vector<WebCore::WebThing>>(ASCIILiteral("webthings"), input.webthings()); +} + +bool InputTraits<Test::ArrayOfThings>::decode(EncodedValue& encodedValue, std::unique_ptr<Test::ArrayOfThings>& input) +{ + Vector<double> doubles; + if (!encodedValue.get<Vector<double>>(ASCIILiteral("doubles"), doubles)) + return false; + + Vector<JSThing> jsthings; + if (!encodedValue.get<Vector<JSThing>>(ASCIILiteral("jsthings"), jsthings)) + return false; + + Vector<WebCore::WebThing> webthings; + if (!encodedValue.get<Vector<WebCore::WebThing>>(ASCIILiteral("webthings"), webthings)) + return false; + + input = std::make_unique<Test::ArrayOfThings>(doubles, jsthings, webthings); + return true; +} + +const String& InputTraits<Test::SavedHistory>::type() +{ + static NeverDestroyed<const String> type(ASCIILiteral("SavedHistory")); + return type; +} + +void InputTraits<Test::SavedHistory>::encode(EncodedValue& encodedValue, const Test::SavedHistory& input) +{ + encodedValue.put<Vector<WebCore::HistoryItem>>(ASCIILiteral("entries"), input.entries()); +} + +bool InputTraits<Test::SavedHistory>::decode(EncodedValue& encodedValue, std::unique_ptr<Test::SavedHistory>& input) +{ + Vector<RefPtr<WebCore::HistoryItem>> entries; + if (!encodedValue.get<Vector<WebCore::HistoryItem>>(ASCIILiteral("entries"), entries)) + return false; + + input = std::make_unique<Test::SavedHistory>(entries); + return true; +} + +} // namespace JSC + +#endif // ENABLE(WEB_REPLAY) diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/generate-input-with-vector-members.json-TestReplayInputs.h b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-input-with-vector-members.json-TestReplayInputs.h new file mode 100644 index 000000000..9f184faac --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-input-with-vector-members.json-TestReplayInputs.h @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2014 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 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 + * HOLDER 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. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-input-with-vector-members.json +// by the script: JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py + +#pragma once + +#if ENABLE(WEB_REPLAY) +#include "InternalNamespaceHeaderIncludeDummy.h" +#include <history/HistoryItem.h> +#include <platform/ExternalNamespaceHeaderIncludeDummy.h> + +namespace WebCore { +class HistoryItem; +} + + +namespace Test { +class ArrayOfThings; +class SavedHistory; +} // namespace Test + +namespace JSC { +template<> struct TEST_EXPORT_MACRO InputTraits<Test::ArrayOfThings> { + static InputQueue queue() { return InputQueue::ScriptMemoizedData; } + static const String& type(); + + static void encode(JSC::EncodedValue&, const Test::ArrayOfThings&); + static bool decode(JSC::EncodedValue&, std::unique_ptr<Test::ArrayOfThings>&); +}; + +template<> struct TEST_EXPORT_MACRO InputTraits<Test::SavedHistory> { + static InputQueue queue() { return InputQueue::ScriptMemoizedData; } + static const String& type(); + + static void encode(JSC::EncodedValue&, const Test::SavedHistory&); + static bool decode(JSC::EncodedValue&, std::unique_ptr<Test::SavedHistory>&); +}; + +} // namespace JSC + +namespace Test { +class ArrayOfThings : public NondeterministicInput<ArrayOfThings> { +public: + TEST_EXPORT_MACRO ArrayOfThings(Vector<double>& doubles, Vector<JSThing>& jsthings, Vector<WebThing>& webthings); + virtual ~ArrayOfThings(); + + const Vector<double>& doubles() const { return m_doubles; } + const Vector<JSThing>& jsthings() const { return m_jsthings; } + const Vector<WebThing>& webthings() const { return m_webthings; } +private: + Vector<double> m_doubles; + Vector<JSThing> m_jsthings; + Vector<WebThing> m_webthings; +}; + +class SavedHistory : public NondeterministicInput<SavedHistory> { +public: + TEST_EXPORT_MACRO SavedHistory(Vector<RefPtr<HistoryItem>>& entries); + virtual ~SavedHistory(); + + const Vector<RefPtr<HistoryItem>>& entries() const { return m_entries; } +private: + Vector<RefPtr<HistoryItem>> m_entries; +}; +} // namespace Test + +SPECIALIZE_TYPE_TRAITS_BEGIN(Test::ArrayOfThings) + static bool isType(const NondeterministicInputBase& input) { return input.type() == InputTraits<Test::ArrayOfThings>::type(); } +SPECIALIZE_TYPE_TRAITS_END() + +SPECIALIZE_TYPE_TRAITS_BEGIN(Test::SavedHistory) + static bool isType(const NondeterministicInputBase& input) { return input.type() == InputTraits<Test::SavedHistory>::type(); } +SPECIALIZE_TYPE_TRAITS_END() + +#define TEST_REPLAY_INPUT_NAMES_FOR_EACH(macro) \ + macro(ArrayOfThings) \ + macro(SavedHistory) \ + \ +// end of TEST_REPLAY_INPUT_NAMES_FOR_EACH + +#endif // ENABLE(WEB_REPLAY) diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/generate-inputs-with-flags.json-TestReplayInputs.cpp b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-inputs-with-flags.json-TestReplayInputs.cpp new file mode 100644 index 000000000..821f4d0fc --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-inputs-with-flags.json-TestReplayInputs.cpp @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2014 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 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 + * HOLDER 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. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-inputs-with-flags.json +// by the script: JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py + +#include "config.h" +#include "generate-inputs-with-flags.json-TestReplayInputs.h" + +#if ENABLE(WEB_REPLAY) +#include "InternalNamespaceImplIncludeDummy.h" +#include <platform/ExternalNamespaceImplIncludeDummy.h> + +namespace Test { +ScalarInput1::ScalarInput1(ScalarType data) + : NondeterministicInput<ScalarInput1>() + , m_data(data) +{ +} + +ScalarInput1::~ScalarInput1() +{ +} + +ScalarInput2::ScalarInput2(ScalarType data) + : NondeterministicInput<ScalarInput2>() + , m_data(data) +{ +} + +ScalarInput2::~ScalarInput2() +{ +} +} // namespace Test + +namespace JSC { +const String& InputTraits<Test::ScalarInput1>::type() +{ + static NeverDestroyed<const String> type(ASCIILiteral("ScalarInput1")); + return type; +} + +void InputTraits<Test::ScalarInput1>::encode(EncodedValue& encodedValue, const Test::ScalarInput1& input) +{ + encodedValue.put<ScalarType>(ASCIILiteral("data"), input.data()); +} + +bool InputTraits<Test::ScalarInput1>::decode(EncodedValue& encodedValue, std::unique_ptr<Test::ScalarInput1>& input) +{ + ScalarType data; + if (!encodedValue.get<ScalarType>(ASCIILiteral("data"), data)) + return false; + + input = std::make_unique<Test::ScalarInput1>(data); + return true; +} + +const String& InputTraits<Test::ScalarInput2>::type() +{ + static NeverDestroyed<const String> type(ASCIILiteral("ScalarInput2")); + return type; +} + +void InputTraits<Test::ScalarInput2>::encode(EncodedValue& encodedValue, const Test::ScalarInput2& input) +{ + encodedValue.put<ScalarType>(ASCIILiteral("data"), input.data()); +} + +bool InputTraits<Test::ScalarInput2>::decode(EncodedValue& encodedValue, std::unique_ptr<Test::ScalarInput2>& input) +{ + ScalarType data; + if (!encodedValue.get<ScalarType>(ASCIILiteral("data"), data)) + return false; + + input = std::make_unique<Test::ScalarInput2>(data); + return true; +} + +} // namespace JSC + +#endif // ENABLE(WEB_REPLAY) diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/generate-inputs-with-flags.json-TestReplayInputs.h b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-inputs-with-flags.json-TestReplayInputs.h new file mode 100644 index 000000000..761ea900e --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-inputs-with-flags.json-TestReplayInputs.h @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2014 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 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 + * HOLDER 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. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-inputs-with-flags.json +// by the script: JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py + +#pragma once + +#if ENABLE(WEB_REPLAY) +#include "InternalNamespaceHeaderIncludeDummy.h" +#include <platform/ExternalNamespaceHeaderIncludeDummy.h> + + + +namespace Test { +class ScalarInput1; +class ScalarInput2; +} // namespace Test + +namespace JSC { +template<> struct TEST_EXPORT_MACRO InputTraits<Test::ScalarInput1> { + static InputQueue queue() { return InputQueue::ScriptMemoizedData; } + static const String& type(); + + static void encode(JSC::EncodedValue&, const Test::ScalarInput1&); + static bool decode(JSC::EncodedValue&, std::unique_ptr<Test::ScalarInput1>&); +}; + +template<> struct TEST_EXPORT_MACRO InputTraits<Test::ScalarInput2> { + static InputQueue queue() { return InputQueue::ScriptMemoizedData; } + static const String& type(); + + static void encode(JSC::EncodedValue&, const Test::ScalarInput2&); + static bool decode(JSC::EncodedValue&, std::unique_ptr<Test::ScalarInput2>&); +}; + +} // namespace JSC + +namespace Test { +class ScalarInput1 : public NondeterministicInput<ScalarInput1> { +public: + TEST_EXPORT_MACRO ScalarInput1(ScalarType data); + virtual ~ScalarInput1(); + + ScalarType data() const { return m_data; } +private: + ScalarType m_data; +}; + +class ScalarInput2 : public NondeterministicInput<ScalarInput2> { +public: + TEST_EXPORT_MACRO ScalarInput2(ScalarType data); + virtual ~ScalarInput2(); + + ScalarType data() const { return m_data; } +private: + ScalarType m_data; +}; +} // namespace Test + +SPECIALIZE_TYPE_TRAITS_BEGIN(Test::ScalarInput1) + static bool isType(const NondeterministicInputBase& input) { return input.type() == InputTraits<Test::ScalarInput1>::type(); } +SPECIALIZE_TYPE_TRAITS_END() + +SPECIALIZE_TYPE_TRAITS_BEGIN(Test::ScalarInput2) + static bool isType(const NondeterministicInputBase& input) { return input.type() == InputTraits<Test::ScalarInput2>::type(); } +SPECIALIZE_TYPE_TRAITS_END() + +#define TEST_REPLAY_INPUT_NAMES_FOR_EACH(macro) \ + macro(ScalarInput1) \ + macro(ScalarInput2) \ + \ +// end of TEST_REPLAY_INPUT_NAMES_FOR_EACH + +#endif // ENABLE(WEB_REPLAY) diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/generate-memoized-type-modes.json-TestReplayInputs.cpp b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-memoized-type-modes.json-TestReplayInputs.cpp new file mode 100644 index 000000000..b67a9e921 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-memoized-type-modes.json-TestReplayInputs.cpp @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2014 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 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 + * HOLDER 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. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-memoized-type-modes.json +// by the script: JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py + +#include "config.h" +#include "generate-memoized-type-modes.json-TestReplayInputs.h" + +#if ENABLE(WEB_REPLAY) +#include "InternalNamespaceImplIncludeDummy.h" +#include <platform/ExternalNamespaceImplIncludeDummy.h> + +namespace Test { +ScalarInput::ScalarInput(ScalarType data) + : NondeterministicInput<ScalarInput>() + , m_data(data) +{ +} + +ScalarInput::~ScalarInput() +{ +} + +MapInput::MapInput(std::unique_ptr<MapType> data) + : NondeterministicInput<MapInput>() + , m_data(WTFMove(data)) +{ +} + +MapInput::~MapInput() +{ +} +} // namespace Test + +namespace JSC { +const String& InputTraits<Test::ScalarInput>::type() +{ + static NeverDestroyed<const String> type(ASCIILiteral("ScalarInput")); + return type; +} + +void InputTraits<Test::ScalarInput>::encode(EncodedValue& encodedValue, const Test::ScalarInput& input) +{ + encodedValue.put<ScalarType>(ASCIILiteral("data"), input.data()); +} + +bool InputTraits<Test::ScalarInput>::decode(EncodedValue& encodedValue, std::unique_ptr<Test::ScalarInput>& input) +{ + ScalarType data; + if (!encodedValue.get<ScalarType>(ASCIILiteral("data"), data)) + return false; + + input = std::make_unique<Test::ScalarInput>(data); + return true; +} + +const String& InputTraits<Test::MapInput>::type() +{ + static NeverDestroyed<const String> type(ASCIILiteral("MapInput")); + return type; +} + +void InputTraits<Test::MapInput>::encode(EncodedValue& encodedValue, const Test::MapInput& input) +{ + encodedValue.put<MapType>(ASCIILiteral("data"), input.data()); +} + +bool InputTraits<Test::MapInput>::decode(EncodedValue& encodedValue, std::unique_ptr<Test::MapInput>& input) +{ + std::unique_ptr<MapType> data; + if (!encodedValue.get<MapType>(ASCIILiteral("data"), data)) + return false; + + input = std::make_unique<Test::MapInput>(WTFMove(data)); + return true; +} + +} // namespace JSC + +#endif // ENABLE(WEB_REPLAY) diff --git a/Source/JavaScriptCore/replay/scripts/tests/expected/generate-memoized-type-modes.json-TestReplayInputs.h b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-memoized-type-modes.json-TestReplayInputs.h new file mode 100644 index 000000000..ddac7070d --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/expected/generate-memoized-type-modes.json-TestReplayInputs.h @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2014 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 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 + * HOLDER 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. + */ + +// DO NOT EDIT THIS FILE. It is automatically generated from generate-memoized-type-modes.json +// by the script: JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py + +#pragma once + +#if ENABLE(WEB_REPLAY) +#include "InternalNamespaceHeaderIncludeDummy.h" +#include <platform/ExternalNamespaceHeaderIncludeDummy.h> + + + +namespace Test { +class ScalarInput; +class MapInput; +} // namespace Test + +namespace JSC { +template<> struct TEST_EXPORT_MACRO InputTraits<Test::ScalarInput> { + static InputQueue queue() { return InputQueue::ScriptMemoizedData; } + static const String& type(); + + static void encode(JSC::EncodedValue&, const Test::ScalarInput&); + static bool decode(JSC::EncodedValue&, std::unique_ptr<Test::ScalarInput>&); +}; + +template<> struct TEST_EXPORT_MACRO InputTraits<Test::MapInput> { + static InputQueue queue() { return InputQueue::ScriptMemoizedData; } + static const String& type(); + + static void encode(JSC::EncodedValue&, const Test::MapInput&); + static bool decode(JSC::EncodedValue&, std::unique_ptr<Test::MapInput>&); +}; + +} // namespace JSC + +namespace Test { +class ScalarInput : public NondeterministicInput<ScalarInput> { +public: + TEST_EXPORT_MACRO ScalarInput(ScalarType data); + virtual ~ScalarInput(); + + ScalarType data() const { return m_data; } +private: + ScalarType m_data; +}; + +class MapInput : public NondeterministicInput<MapInput> { +public: + TEST_EXPORT_MACRO MapInput(std::unique_ptr<MapType> data); + virtual ~MapInput(); + + const MapType& data() const { return *m_data; } +private: + std::unique_ptr<MapType> m_data; +}; +} // namespace Test + +SPECIALIZE_TYPE_TRAITS_BEGIN(Test::ScalarInput) + static bool isType(const NondeterministicInputBase& input) { return input.type() == InputTraits<Test::ScalarInput>::type(); } +SPECIALIZE_TYPE_TRAITS_END() + +SPECIALIZE_TYPE_TRAITS_BEGIN(Test::MapInput) + static bool isType(const NondeterministicInputBase& input) { return input.type() == InputTraits<Test::MapInput>::type(); } +SPECIALIZE_TYPE_TRAITS_END() + +#define TEST_REPLAY_INPUT_NAMES_FOR_EACH(macro) \ + macro(ScalarInput) \ + macro(MapInput) \ + \ +// end of TEST_REPLAY_INPUT_NAMES_FOR_EACH + +#endif // ENABLE(WEB_REPLAY) diff --git a/Source/JavaScriptCore/replay/scripts/tests/fail-on-c-style-enum-no-storage.json b/Source/JavaScriptCore/replay/scripts/tests/fail-on-c-style-enum-no-storage.json new file mode 100644 index 000000000..31d2c437a --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/fail-on-c-style-enum-no-storage.json @@ -0,0 +1,25 @@ +{ + "types": { + "Test": [ + { + "name": "MouseButton", "mode": "SCALAR", + "flags": ["ENUM"], + "values": ["NoButton", "LeftButton", "MiddleButton", "RightButton"], + "header": "path/to/MouseButton.h" + } + ] + }, + + "inputs": { + "Test": [ + { + "name": "SavedMouseButton", + "description": "Supplies a mouse button enum value.", + "queue": "SCRIPT_MEMOIZED", + "members": [ + { "name": "button", "type": "MouseButton" } + ] + } + ] + } +} diff --git a/Source/JavaScriptCore/replay/scripts/tests/fail-on-duplicate-enum-type.json b/Source/JavaScriptCore/replay/scripts/tests/fail-on-duplicate-enum-type.json new file mode 100644 index 000000000..089e69925 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/fail-on-duplicate-enum-type.json @@ -0,0 +1,35 @@ +{ + "types": { + "JavaScriptCore": [ + { + "name": "Type", "mode": "SCALAR", "storage": "uint64_t", + "enclosing_class": "PlatformEvent", + "flags": ["ENUM"], + "values": ["Mouse", "Keyboard"], + "header": "replay/PlatformEvent.h" + } + ], + "WebCore": [ + { + "name": "Type", "mode": "SCALAR", "storage": "uint64_t", + "enclosing_class": "PlatformEvent", + "flags": ["ENUM"], + "values": ["Mouse", "Keyboard"], + "header": "replay/PlatformEvent.h" + } + ] + }, + + "inputs": { + "Test": [ + { + "name": "FormCombo", + "description": "Combines an event type and form data type.", + "queue": "SCRIPT_MEMOIZED", + "members": [ + { "name": "eventType", "type": "PlatformEvent::Type" } + ] + } + ] + } +} diff --git a/Source/JavaScriptCore/replay/scripts/tests/fail-on-duplicate-input-names.json b/Source/JavaScriptCore/replay/scripts/tests/fail-on-duplicate-input-names.json new file mode 100644 index 000000000..91c84a2ef --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/fail-on-duplicate-input-names.json @@ -0,0 +1,29 @@ +{ + "types": { + "Global": [ + { "name": "double", "mode": "SCALAR" }, + { "name": "uint64_t", "mode": "SCALAR" } + ] + }, + + "inputs": { + "Test": [ + { + "name": "GetCurrentTime", + "description": "Supplies the system time to Date.now() and new Date().", + "queue": "SCRIPT_MEMOIZED", + "members": [ + { "name": "currentTime", "type": "double" } + ] + }, + { + "name": "GetCurrentTime", + "description": "Sets the PRNG seed used by Math.random().", + "queue": "SCRIPT_MEMOIZED", + "members": [ + { "name": "randomSeed", "type": "uint64_t" } + ] + } + ] + } +} diff --git a/Source/JavaScriptCore/replay/scripts/tests/fail-on-duplicate-type-names.json b/Source/JavaScriptCore/replay/scripts/tests/fail-on-duplicate-type-names.json new file mode 100644 index 000000000..fc4b5d9b9 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/fail-on-duplicate-type-names.json @@ -0,0 +1,24 @@ +{ + "types": { + "Global": [ + { "name": "uint64_t", "mode": "SCALAR" }, + { "name": "uint64_t", "mode": "SCALAR" } + ] + }, + + "inputs": { + "Test": [ + { + "name": "SetRandomSeed", + "description": "Sets the PRNG seed used by Math.random().", + "queue": "SCRIPT_MEMOIZED", + "members": [ + { + "name": "randomSeed", + "type": "uint64_t" + } + ] + } + ] + } +} diff --git a/Source/JavaScriptCore/replay/scripts/tests/fail-on-enum-type-missing-values.json b/Source/JavaScriptCore/replay/scripts/tests/fail-on-enum-type-missing-values.json new file mode 100644 index 000000000..5bd20bd51 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/fail-on-enum-type-missing-values.json @@ -0,0 +1,23 @@ +{ + "types": { + "Global": [ + { + "name": "MouseButton", "mode": "SCALAR", + "flags": ["ENUM"] + } + ] + }, + + "inputs": { + "Test": [ + { + "name": "SavedMouseButton", + "description": "Supplies a mouse button enum value.", + "queue": "SCRIPT_MEMOIZED", + "members": [ + { "name": "currentTime", "type": "MouseButton" } + ] + } + ] + } +} diff --git a/Source/JavaScriptCore/replay/scripts/tests/fail-on-missing-input-member-name.json b/Source/JavaScriptCore/replay/scripts/tests/fail-on-missing-input-member-name.json new file mode 100644 index 000000000..b924aafe7 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/fail-on-missing-input-member-name.json @@ -0,0 +1,22 @@ +{ + "types": { + "Global": [ + { "name": "double", "mode": "SCALAR" } + ] + }, + + "inputs": { + "Test": [ + { + "name": "GetCurrentTime", + "description": "Supplies the system time to Date.now() and new Date().", + "queue": "SCRIPT_MEMOIZED", + "members": [ + { + "type": "double" + } + ] + } + ] + } +} diff --git a/Source/JavaScriptCore/replay/scripts/tests/fail-on-missing-input-name.json b/Source/JavaScriptCore/replay/scripts/tests/fail-on-missing-input-name.json new file mode 100644 index 000000000..aa80980d8 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/fail-on-missing-input-name.json @@ -0,0 +1,22 @@ +{ + "types": { + "Global": [ + { "name": "double", "mode": "SCALAR" } + ] + }, + + "inputs": { + "Test": [ + { + "description": "Supplies the system time to Date.now() and new Date().", + "queue": "SCRIPT_MEMOIZED", + "members": [ + { + "name": "currentTime", + "type": "double" + } + ] + } + ] + } +} diff --git a/Source/JavaScriptCore/replay/scripts/tests/fail-on-missing-input-queue.json b/Source/JavaScriptCore/replay/scripts/tests/fail-on-missing-input-queue.json new file mode 100644 index 000000000..8136dfbb3 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/fail-on-missing-input-queue.json @@ -0,0 +1,22 @@ +{ + "types": { + "Global": [ + { "name": "double", "mode": "SCALAR" } + ] + }, + + "inputs": { + "Test": [ + { + "name": "GetCurrentTime", + "description": "Supplies the system time to Date.now() and new Date().", + "members": [ + { + "name": "currentTime", + "type": "double" + } + ] + } + ] + } +} diff --git a/Source/JavaScriptCore/replay/scripts/tests/fail-on-missing-type-mode.json b/Source/JavaScriptCore/replay/scripts/tests/fail-on-missing-type-mode.json new file mode 100644 index 000000000..3ed6d1e45 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/fail-on-missing-type-mode.json @@ -0,0 +1,23 @@ +{ + "types": { + "Global": [ + { "name": "double" } + ] + }, + + "inputs": { + "Test": [ + { + "name": "GetCurrentTime", + "description": "Supplies the system time to Date.now() and new Date().", + "queue": "SCRIPT_MEMOIZED", + "members": [ + { + "name": "currentTime", + "type": "double" + } + ] + } + ] + } +} diff --git a/Source/JavaScriptCore/replay/scripts/tests/fail-on-missing-type-name.json b/Source/JavaScriptCore/replay/scripts/tests/fail-on-missing-type-name.json new file mode 100644 index 000000000..01b1c0872 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/fail-on-missing-type-name.json @@ -0,0 +1,23 @@ +{ + "types": { + "Global": [ + { "mode": "SCALAR" } + ] + }, + + "inputs": { + "Test": [ + { + "name": "GetCurrentTime", + "description": "Supplies the system time to Date.now() and new Date().", + "queue": "SCRIPT_MEMOIZED", + "members": [ + { + "name": "currentTime", + "type": "double" + } + ] + } + ] + } +} diff --git a/Source/JavaScriptCore/replay/scripts/tests/fail-on-unknown-input-queue.json b/Source/JavaScriptCore/replay/scripts/tests/fail-on-unknown-input-queue.json new file mode 100644 index 000000000..cd15f0640 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/fail-on-unknown-input-queue.json @@ -0,0 +1,23 @@ +{ + "types": { + "Global": [ + { "name": "double", "mode": "SCALAR" } + ] + }, + + "inputs": { + "Test": [ + { + "name": "GetCurrentTime", + "description": "Supplies the system time to Date.now() and new Date().", + "queue": "SCRIPT_MEOIZED", + "members": [ + { + "name": "currentTime", + "type": "double" + } + ] + } + ] + } +} diff --git a/Source/JavaScriptCore/replay/scripts/tests/fail-on-unknown-member-type.json b/Source/JavaScriptCore/replay/scripts/tests/fail-on-unknown-member-type.json new file mode 100644 index 000000000..8a2305757 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/fail-on-unknown-member-type.json @@ -0,0 +1,23 @@ +{ + "types": { + "Global": [ + { "name": "uint64_t", "mode": "SCALAR" } + ] + }, + + "inputs": { + "Test": [ + { + "name": "SetRandomSeed", + "description": "Sets the PRNG seed used by Math.random().", + "queue": "SCRIPT_MEMOIZED", + "members": [ + { + "name": "randomSeed", + "type": "double" + } + ] + } + ] + } +} diff --git a/Source/JavaScriptCore/replay/scripts/tests/fail-on-unknown-type-mode.json b/Source/JavaScriptCore/replay/scripts/tests/fail-on-unknown-type-mode.json new file mode 100644 index 000000000..b553befc9 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/fail-on-unknown-type-mode.json @@ -0,0 +1,23 @@ +{ + "types": { + "Global": [ + { "name": "double", "mode": "BONKERS" } + ] + }, + + "inputs": { + "Test": [ + { + "name": "GetCurrentTime", + "description": "Supplies the system time to Date.now() and new Date().", + "queue": "SCRIPT_MEMOIZED", + "members": [ + { + "name": "currentTime", + "type": "double" + } + ] + } + ] + } +} diff --git a/Source/JavaScriptCore/replay/scripts/tests/generate-enum-encoding-helpers-with-guarded-values.json b/Source/JavaScriptCore/replay/scripts/tests/generate-enum-encoding-helpers-with-guarded-values.json new file mode 100644 index 000000000..9b2017d58 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/generate-enum-encoding-helpers-with-guarded-values.json @@ -0,0 +1,29 @@ +{ + "types": { + "WebCore": [ + { + "name": "MouseButton", "mode": "SCALAR", "storage": "unsigned", + "flags": ["ENUM"], + "values": ["NoButton", "LeftButton", "MiddleButton", "RightButton"], + "guarded_values": { + "ENABLE(SIDE_BUTTONS)": ["LeftSideButton", "RightSideButton"], + "PLATFORM(WINDOWS)": ["WindowsButton"] + }, + "header": "platform/PlatformMouseEvent.h" + } + ] + }, + + "inputs": { + "Test": [ + { + "name": "SavedMouseButton", + "description": "Supplies a mouse button enum value.", + "queue": "SCRIPT_MEMOIZED", + "members": [ + { "name": "button", "type": "MouseButton" } + ] + } + ] + } +} diff --git a/Source/JavaScriptCore/replay/scripts/tests/generate-enum-encoding-helpers.json b/Source/JavaScriptCore/replay/scripts/tests/generate-enum-encoding-helpers.json new file mode 100644 index 000000000..73b74edac --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/generate-enum-encoding-helpers.json @@ -0,0 +1,45 @@ +{ + "types": { + "Test": [ + { + "name": "InputQueue", "mode": "SCALAR", + "flags": ["ENUM_CLASS"], + "values": ["EventLoopInput", "LoaderMemoizedData", "ScriptMemoizedData"], + "header": "replay/NondeterministicInput.h" + }, + { + "name": "MouseButton", "mode": "SCALAR", "storage": "unsigned", + "flags": ["ENUM"], + "values": ["NoButton", "LeftButton", "MiddleButton", "RightButton"], + "header": "platform/PlatformMouseEvent.h" + }, + { + "name": "Type", "mode": "SCALAR", + "flags": ["ENUM"], + "enclosing_class": "PlatformEvent", + "values": ["Mouse", "Key", "Touch", "Wheel"], + "header": "platform/PlatformEvent.h" + }, + { + "name": "OtherType", "mode": "SCALAR", + "flags": ["OPTION_SET"], + "enclosing_class": "PlatformEvent", + "values": ["Mouse", "Key", "Touch", "Wheel"], + "header": "platform/PlatformEvent.h" + } + ] + }, + + "inputs": { + "Test": [ + { + "name": "SavedMouseButton", + "description": "Supplies a mouse button enum value.", + "queue": "SCRIPT_MEMOIZED", + "members": [ + { "name": "button", "type": "MouseButton" } + ] + } + ] + } +} diff --git a/Source/JavaScriptCore/replay/scripts/tests/generate-enum-with-guard.json b/Source/JavaScriptCore/replay/scripts/tests/generate-enum-with-guard.json new file mode 100644 index 000000000..20ea35922 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/generate-enum-with-guard.json @@ -0,0 +1,36 @@ +{ + "types": { + "Global": [ + { "name": "uint64_t", "mode": "SCALAR" } + ], + "WebCore": [ + { + "name": "PlatformWheelEvent", "mode": "OWNED", + "header": "platform/PlatformWheelEvent.h" + } + ], + "Test": [ + { + "name": "PlatformWheelPhase", "mode": "SCALAR", "storage": "uint64_t", + "flags": ["ENUM"], + "guard": "ENABLE(DUMMY_FEATURE)", + "values": ["PlatformWheelEventPhaseNone"], + "header": "platform/PlatformWheelEvent.h" + } + ] + }, + + "inputs": { + "Test": [ + { + "name": "HandleWheelEvent", + "description": "", + "queue": "EVENT_LOOP", + "members": [ + { "name": "platformEvent", "type": "PlatformWheelEvent" }, + { "name": "phase", "type": "PlatformWheelPhase" } + ] + } + ] + } +} diff --git a/Source/JavaScriptCore/replay/scripts/tests/generate-enums-with-same-base-name.json b/Source/JavaScriptCore/replay/scripts/tests/generate-enums-with-same-base-name.json new file mode 100644 index 000000000..699439d8a --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/generate-enums-with-same-base-name.json @@ -0,0 +1,52 @@ +{ + "types": { + "JavaScriptCore": [ + { + "name": "Type", "mode": "SCALAR", "storage": "uint64_t", + "enclosing_class": "PlatformEvent1", + "flags": ["ENUM"], + "values": ["Mouse", "Keyboard"], + "header": "replay/PlatformEvent.h" + }, + { + "name": "Type", "mode": "SCALAR", + "enclosing_class": "PlatformEvent2", + "flags": ["ENUM_CLASS"], + "values": ["Mouse", "Keyboard"], + "header": "replay/PlatformEvent.h" + } + ], + "Test": [ + { + "name": "Type", "mode": "SCALAR", "storage": "uint64_t", + "enclosing_class": "FormData1", + "flags": ["ENUM"], + "values": ["Text", "Blob"], + "header": "replay/FormData1.h" + }, + { + "name": "Type", "mode": "SCALAR", + "enclosing_class": "FormData2", + "flags": ["ENUM_CLASS"], + "values": ["Text", "Blob"], + "header": "replay/FormData2.h" + } + ] + }, + + "inputs": { + "Test": [ + { + "name": "FormCombo", + "description": "Combines an event type and form data type.", + "queue": "SCRIPT_MEMOIZED", + "members": [ + { "name": "eventType1", "type": "PlatformEvent1::Type" }, + { "name": "eventType2", "type": "PlatformEvent2::Type" }, + { "name": "formType1", "type": "FormData1::Type" }, + { "name": "formType2", "type": "FormData2::Type" } + ] + } + ] + } +} diff --git a/Source/JavaScriptCore/replay/scripts/tests/generate-event-loop-shape-types.json b/Source/JavaScriptCore/replay/scripts/tests/generate-event-loop-shape-types.json new file mode 100644 index 000000000..93b16bfa5 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/generate-event-loop-shape-types.json @@ -0,0 +1,38 @@ +{ + "types": { + "Global": [ + { "name": "ScalarType", "mode": "SCALAR" }, + { "name": "MapType", "mode": "MAP" }, + { "name": "SharedMapType", "mode": "SHARED_MAP" } + ] + }, + + "inputs": { + "Test": [ + { + "name": "ScalarInput", + "description": "", + "queue": "EVENT_LOOP", + "members": [ + { "name": "data", "type": "ScalarType" } + ] + }, + { + "name": "MapInput", + "description": "", + "queue": "EVENT_LOOP", + "members": [ + { "name": "data", "type": "MapType" } + ] + }, + { + "name": "SharedMapInput", + "description": "", + "queue": "EVENT_LOOP", + "members": [ + { "name": "data", "type": "SharedMapType" } + ] + } + ] + } +} diff --git a/Source/JavaScriptCore/replay/scripts/tests/generate-input-with-guard.json b/Source/JavaScriptCore/replay/scripts/tests/generate-input-with-guard.json new file mode 100644 index 000000000..75cd50473 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/generate-input-with-guard.json @@ -0,0 +1,30 @@ +{ + "types": { + "Global": [ + { "name": "double", "mode": "SCALAR" }, + { "name": "uint64_t", "mode": "SCALAR" } + ] + }, + + "inputs": { + "Test": [ + { + "name": "GetCurrentTime", + "description": "Supplies the system time to Date.now() and new Date().", + "queue": "SCRIPT_MEMOIZED", + "guard": "ENABLE(DUMMY_FEATURE)", + "members": [ + { "name": "currentTime", "type": "double" } + ] + }, + { + "name": "SetRandomSeed", + "description": "Sets the PRNG seed used by Math.random().", + "queue": "SCRIPT_MEMOIZED", + "members": [ + {"name": "randomSeed", "type": "uint64_t" } + ] + } + ] + } +} diff --git a/Source/JavaScriptCore/replay/scripts/tests/generate-input-with-vector-members.json b/Source/JavaScriptCore/replay/scripts/tests/generate-input-with-vector-members.json new file mode 100644 index 000000000..eabd072e1 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/generate-input-with-vector-members.json @@ -0,0 +1,42 @@ +{ + "types": { + "Global": [ + { "name": "double", "mode": "SCALAR" } + ], + + "JavaScriptCore": [ + { "name": "JSThing", "mode": "SCALAR", "header": "things/JSThing.h" } + ], + + "WebCore": [ + { "name": "WebThing", "mode": "SCALAR", "header": "things/WebThing.h" }, + { + "name": "HistoryItem", "mode": "SHARED", + "header": "history/HistoryItem.h" + } + ] + }, + + "inputs": { + "Test": [ + { + "name": "ArrayOfThings", + "description": "Supplies arrays of things.", + "queue": "SCRIPT_MEMOIZED", + "members": [ + { "name": "doubles", "type": "double", "flags": ["VECTOR"] }, + { "name": "jsthings", "type": "JSThing", "flags": ["VECTOR"] }, + { "name": "webthings", "type": "WebThing", "flags": ["VECTOR"] } + ] + }, + { + "name": "SavedHistory", + "description": "Save history items.", + "queue": "SCRIPT_MEMOIZED", + "members": [ + { "name": "entries", "type": "HistoryItem", "flags": ["VECTOR"] } + ] + } + ] + } +} diff --git a/Source/JavaScriptCore/replay/scripts/tests/generate-inputs-with-flags.json b/Source/JavaScriptCore/replay/scripts/tests/generate-inputs-with-flags.json new file mode 100644 index 000000000..3f49cc19e --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/generate-inputs-with-flags.json @@ -0,0 +1,29 @@ +{ + "types": { + "Global": [ + { "name": "ScalarType", "mode": "SCALAR" } + ] + }, + + "inputs": { + "Test": [ + { + "name": "ScalarInput1", + "description": "", + "queue": "SCRIPT_MEMOIZED", + "members": [ + { "name": "data", "type": "ScalarType" } + ] + }, + { + "name": "ScalarInput2", + "description": "", + "queue": "SCRIPT_MEMOIZED", + "flags": ["CREATE_FROM_PAGE"], + "members": [ + { "name": "data", "type": "ScalarType" } + ] + } + ] + } +} diff --git a/Source/JavaScriptCore/replay/scripts/tests/generate-memoized-type-modes.json b/Source/JavaScriptCore/replay/scripts/tests/generate-memoized-type-modes.json new file mode 100644 index 000000000..0d66bd853 --- /dev/null +++ b/Source/JavaScriptCore/replay/scripts/tests/generate-memoized-type-modes.json @@ -0,0 +1,29 @@ +{ + "types": { + "Global": [ + { "name": "ScalarType", "mode": "SCALAR" }, + { "name": "MapType", "mode": "OWNED" } + ] + }, + + "inputs": { + "Test": [ + { + "name": "ScalarInput", + "description": "", + "queue": "SCRIPT_MEMOIZED", + "members": [ + { "name": "data", "type": "ScalarType" } + ] + }, + { + "name": "MapInput", + "description": "", + "queue": "SCRIPT_MEMOIZED", + "members": [ + { "name": "data", "type": "MapType" } + ] + } + ] + } +} |