Changeset 212116 in webkit


Ignore:
Timestamp:
Feb 10, 2017 9:29:36 AM (7 years ago)
Author:
BJ Burg
Message:

[Cocoa] Web Inspector: generate an NS_ENUM containing platforms supported by the protocol code generator
https://bugs.webkit.org/show_bug.cgi?id=168019
<rdar://problem/28718990>

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

It's useful to have an symbolic value (not a string) for each of the supported platform values.
Generate this once per protocol for the Objective-C bindings. Covered by existing tests.

  • inspector/scripts/codegen/generate_objc_header.py:

(ObjCHeaderGenerator.generate_output):
(ObjCHeaderGenerator._generate_enum_for_platforms):
Create an NS_ENUM for Platform values in Platforms.

  • inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py:

(ObjCProtocolTypeConversionsHeaderGenerator.generate_output):
(ObjCProtocolTypeConversionsHeaderGenerator._generate_enum_conversion_for_platforms):
Add type conversion/parsing methods for the newly added enum.

  • inspector/scripts/codegen/generator.py:

(Generator.stylized_name_for_enum_value):
(Generator.stylized_name_for_enum_value.replaceCallback):
Support arbitrary special-cased substrings in enums, not just all-caps. Add 'IOS' and 'MacOS'.

  • inspector/scripts/codegen/models.py:

(Platforms):
Use lower-case string values for platform names, to avoid guesswork.

(Platforms.metaclass):
(Platforms.metaclass.iter):
Make it possible to iterate over Platform instances of Platforms.

  • inspector/scripts/tests/all/expected/definitions-with-mac-platform.json-result:
  • inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result:
  • inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result:
  • inspector/scripts/tests/generic/expected/definitions-with-mac-platform.json-result:
  • inspector/scripts/tests/generic/expected/domain-availability.json-result:
  • inspector/scripts/tests/generic/expected/domains-with-varying-command-sizes.json-result:
  • inspector/scripts/tests/generic/expected/enum-values.json-result:
  • inspector/scripts/tests/generic/expected/events-with-optional-parameters.json-result:
  • inspector/scripts/tests/generic/expected/generate-domains-with-feature-guards.json-result:
  • inspector/scripts/tests/generic/expected/same-type-id-different-domain.json-result:
  • inspector/scripts/tests/generic/expected/shadowed-optional-type-setters.json-result:
  • inspector/scripts/tests/generic/expected/type-declaration-aliased-primitive-type.json-result:
  • inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result:
  • inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result:
  • inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result:
  • inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result:
  • inspector/scripts/tests/generic/expected/worker-supported-domains.json-result:
  • inspector/scripts/tests/ios/expected/definitions-with-mac-platform.json-result:
  • inspector/scripts/tests/mac/expected/definitions-with-mac-platform.json-result:

Rebaseline results.

Source/WebKit2:

  • UIProcess/Automation/Automation.json: Fix the platform values to be lowercase.
Location:
trunk/Source
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r212035 r212116  
     12017-02-10  Brian Burg  <bburg@apple.com>
     2
     3        [Cocoa] Web Inspector: generate an NS_ENUM containing platforms supported by the protocol code generator
     4        https://bugs.webkit.org/show_bug.cgi?id=168019
     5        <rdar://problem/28718990>
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        It's useful to have an symbolic value (not a string) for each of the supported platform values.
     10        Generate this once per protocol for the Objective-C bindings. Covered by existing tests.
     11
     12        * inspector/scripts/codegen/generate_objc_header.py:
     13        (ObjCHeaderGenerator.generate_output):
     14        (ObjCHeaderGenerator._generate_enum_for_platforms):
     15        Create an NS_ENUM for Platform values in Platforms.
     16
     17        * inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py:
     18        (ObjCProtocolTypeConversionsHeaderGenerator.generate_output):
     19        (ObjCProtocolTypeConversionsHeaderGenerator._generate_enum_conversion_for_platforms):
     20        Add type conversion/parsing methods for the newly added enum.
     21
     22        * inspector/scripts/codegen/generator.py:
     23        (Generator.stylized_name_for_enum_value):
     24        (Generator.stylized_name_for_enum_value.replaceCallback):
     25        Support arbitrary special-cased substrings in enums, not just all-caps. Add 'IOS' and 'MacOS'.
     26
     27        * inspector/scripts/codegen/models.py:
     28        (Platforms):
     29        Use lower-case string values for platform names, to avoid guesswork.
     30
     31        (Platforms.__metaclass__):
     32        (Platforms.__metaclass__.__iter__):
     33        Make it possible to iterate over Platform instances of Platforms.
     34
     35        * inspector/scripts/tests/all/expected/definitions-with-mac-platform.json-result:
     36        * inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result:
     37        * inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result:
     38        * inspector/scripts/tests/generic/expected/definitions-with-mac-platform.json-result:
     39        * inspector/scripts/tests/generic/expected/domain-availability.json-result:
     40        * inspector/scripts/tests/generic/expected/domains-with-varying-command-sizes.json-result:
     41        * inspector/scripts/tests/generic/expected/enum-values.json-result:
     42        * inspector/scripts/tests/generic/expected/events-with-optional-parameters.json-result:
     43        * inspector/scripts/tests/generic/expected/generate-domains-with-feature-guards.json-result:
     44        * inspector/scripts/tests/generic/expected/same-type-id-different-domain.json-result:
     45        * inspector/scripts/tests/generic/expected/shadowed-optional-type-setters.json-result:
     46        * inspector/scripts/tests/generic/expected/type-declaration-aliased-primitive-type.json-result:
     47        * inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result:
     48        * inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result:
     49        * inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result:
     50        * inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result:
     51        * inspector/scripts/tests/generic/expected/worker-supported-domains.json-result:
     52        * inspector/scripts/tests/ios/expected/definitions-with-mac-platform.json-result:
     53        * inspector/scripts/tests/mac/expected/definitions-with-mac-platform.json-result:
     54        Rebaseline results.
     55
    1562017-02-09  Filip Pizlo  <fpizlo@apple.com>
    257
  • trunk/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_header.py

    r210309 r212116  
    3131
    3232from generator import Generator, ucfirst
    33 from models import ObjectType, EnumType
     33from models import ObjectType, EnumType, Platforms
    3434from objc_generator import ObjCGenerator, join_type_and_name
    3535from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates
     
    7474        sections.append(Template(ObjCTemplates.HeaderPrelude).substitute(None, **header_args))
    7575        sections.append('\n'.join(filter(None, map(self._generate_forward_declarations, type_domains))))
     76        sections.append(self._generate_enum_for_platforms())
    7677        sections.append('\n'.join(filter(None, map(self._generate_enums, type_domains))))
    7778        sections.append('\n'.join(filter(None, map(self._generate_types, type_domains))))
     
    135136        return '\n'.join(lines)
    136137
     138    def _generate_enum_for_platforms(self):
     139        objc_enum_name = '%sPlatform' % self.objc_prefix()
     140        enum_values = [platform.name for platform in Platforms]
     141        return self._generate_enum(objc_enum_name, enum_values)
     142
    137143    def _generate_anonymous_enum_for_declaration(self, domain, declaration):
    138144        objc_enum_name = self.objc_enum_name_for_anonymous_enum_declaration(declaration)
  • trunk/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py

    r210309 r212116  
    3131
    3232from generator import Generator
    33 from models import EnumType, Frameworks
     33from models import EnumType, Frameworks, Platforms
    3434from objc_generator import ObjCGenerator
    3535from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates
     
    7070        sections.append(Template(ObjCTemplates.TypeConversionsHeaderPrelude).substitute(None, **header_args))
    7171        sections.append(Template(ObjCTemplates.TypeConversionsHeaderStandard).substitute(None))
     72        sections.append(self._generate_enum_conversion_for_platforms())
    7273        sections.extend(map(self._generate_enum_conversion_functions, domains))
    7374        sections.append(Template(ObjCTemplates.TypeConversionsHeaderPostlude).substitute(None, **header_args))
     
    107108
    108109        return '\n'.join(lines)
     110
     111    def _generate_enum_conversion_for_platforms(self):
     112        objc_enum_name = '%sPlatform' % self.objc_prefix()
     113        enum_values = [platform.name for platform in Platforms]
     114        lines = []
     115        lines.append(self._generate_enum_objc_to_protocol_string(objc_enum_name, enum_values))
     116        lines.append(self._generate_enum_from_protocol_string(objc_enum_name, enum_values))
     117        return '\n\n'.join(lines)
    109118
    110119    def _generate_anonymous_enum_conversion_for_declaration(self, domain, declaration):
  • trunk/Source/JavaScriptCore/inspector/scripts/codegen/generator.py

    r210309 r212116  
    3939    return str[:1].upper() + str[1:]
    4040
    41 _ALWAYS_UPPERCASED_ENUM_VALUE_SUBSTRINGS = set(['API', 'CSS', 'DOM', 'HTML', 'JIT', 'XHR', 'XML'])
     41_ALWAYS_SPECIALCASED_ENUM_VALUE_SUBSTRINGS = set(['API', 'CSS', 'DOM', 'HTML', 'JIT', 'XHR', 'XML', 'IOS', 'MacOS'])
     42_ALWAYS_SPECIALCASED_ENUM_VALUE_LOOKUP_TABLE = dict([(s.upper(), s) for s in _ALWAYS_SPECIALCASED_ENUM_VALUE_SUBSTRINGS])
    4243
    4344# These objects are built manually by creating and setting InspectorValues.
     
    239240    @staticmethod
    240241    def stylized_name_for_enum_value(enum_value):
    241         regex = '(%s)' % "|".join(_ALWAYS_UPPERCASED_ENUM_VALUE_SUBSTRINGS)
     242        regex = '(%s)' % "|".join(_ALWAYS_SPECIALCASED_ENUM_VALUE_SUBSTRINGS)
    242243
    243244        def replaceCallback(match):
    244             return match.group(1).upper()
     245            return _ALWAYS_SPECIALCASED_ENUM_VALUE_LOOKUP_TABLE[match.group(1).upper()]
    245246
    246247        # Split on hyphen, introduce camelcase, and force uppercasing of acronyms.
  • trunk/Source/JavaScriptCore/inspector/scripts/codegen/models.py

    r211075 r212116  
    133133
    134134class Platforms:
    135     All = Platform("All")
     135    All = Platform("all")
    136136    Generic = Platform("generic")
    137     iOS = Platform("iOS")
    138     macOS = Platform("macOS")
    139 
     137    iOS = Platform("ios")
     138    macOS = Platform("macos")
     139
     140    # Allow iteration over all platforms. See <http://stackoverflow.com/questions/5434400/>.
     141    class __metaclass__(type):
     142        def __iter__(self):
     143            for attr in dir(Platforms):
     144                if not attr.startswith("__"):
     145                    yield getattr(Platforms, attr)
    140146
    141147class TypeReference:
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/all/expected/definitions-with-mac-platform.json-result

    r210852 r212116  
    895895@class TestProtocolNetworkError;
    896896
     897typedef NS_ENUM(NSInteger, TestProtocolPlatform) {
     898    TestProtocolPlatformAll,
     899    TestProtocolPlatformGeneric,
     900    TestProtocolPlatformIOS,
     901    TestProtocolPlatformMacOS,
     902};
     903
    897904
    898905
     
    10021009ObjCEnumType fromProtocolString(const String& value);
    10031010
     1011inline String toProtocolString(TestProtocolPlatform value)
     1012{
     1013    switch(value) {
     1014    case TestProtocolPlatformAll:
     1015        return ASCIILiteral("all");
     1016    case TestProtocolPlatformGeneric:
     1017        return ASCIILiteral("generic");
     1018    case TestProtocolPlatformIOS:
     1019        return ASCIILiteral("ios");
     1020    case TestProtocolPlatformMacOS:
     1021        return ASCIILiteral("macos");
     1022    }
     1023}
     1024
     1025template<>
     1026inline TestProtocolPlatform fromProtocolString(const String& value)
     1027{
     1028    if (value == "all")
     1029        return TestProtocolPlatformAll;
     1030    if (value == "generic")
     1031        return TestProtocolPlatformGeneric;
     1032    if (value == "ios")
     1033        return TestProtocolPlatformIOS;
     1034    if (value == "macos")
     1035        return TestProtocolPlatformMacOS;
     1036    ASSERT_NOT_REACHED();
     1037    return TestProtocolPlatformAll;
     1038}
     1039
    10041040
    10051041
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result

    r210852 r212116  
    12831283@class TestProtocolDatabaseError;
    12841284
     1285typedef NS_ENUM(NSInteger, TestProtocolPlatform) {
     1286    TestProtocolPlatformAll,
     1287    TestProtocolPlatformGeneric,
     1288    TestProtocolPlatformIOS,
     1289    TestProtocolPlatformMacOS,
     1290};
     1291
    12851292
    12861293typedef NS_ENUM(NSInteger, TestProtocolDatabasePrimaryColors) {
     
    14211428ObjCEnumType fromProtocolString(const String& value);
    14221429
     1430inline String toProtocolString(TestProtocolPlatform value)
     1431{
     1432    switch(value) {
     1433    case TestProtocolPlatformAll:
     1434        return ASCIILiteral("all");
     1435    case TestProtocolPlatformGeneric:
     1436        return ASCIILiteral("generic");
     1437    case TestProtocolPlatformIOS:
     1438        return ASCIILiteral("ios");
     1439    case TestProtocolPlatformMacOS:
     1440        return ASCIILiteral("macos");
     1441    }
     1442}
     1443
     1444template<>
     1445inline TestProtocolPlatform fromProtocolString(const String& value)
     1446{
     1447    if (value == "all")
     1448        return TestProtocolPlatformAll;
     1449    if (value == "generic")
     1450        return TestProtocolPlatformGeneric;
     1451    if (value == "ios")
     1452        return TestProtocolPlatformIOS;
     1453    if (value == "macos")
     1454        return TestProtocolPlatformMacOS;
     1455    ASSERT_NOT_REACHED();
     1456    return TestProtocolPlatformAll;
     1457}
     1458
    14231459
    14241460inline String toProtocolString(TestProtocolDatabasePrimaryColors value)
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result

    r210852 r212116  
    11401140@class TestProtocolDatabaseError;
    11411141
     1142typedef NS_ENUM(NSInteger, TestProtocolPlatform) {
     1143    TestProtocolPlatformAll,
     1144    TestProtocolPlatformGeneric,
     1145    TestProtocolPlatformIOS,
     1146    TestProtocolPlatformMacOS,
     1147};
     1148
    11421149
    11431150typedef NS_ENUM(NSInteger, TestProtocolDatabasePrimaryColors) {
     
    12751282template<typename ObjCEnumType>
    12761283ObjCEnumType fromProtocolString(const String& value);
     1284
     1285inline String toProtocolString(TestProtocolPlatform value)
     1286{
     1287    switch(value) {
     1288    case TestProtocolPlatformAll:
     1289        return ASCIILiteral("all");
     1290    case TestProtocolPlatformGeneric:
     1291        return ASCIILiteral("generic");
     1292    case TestProtocolPlatformIOS:
     1293        return ASCIILiteral("ios");
     1294    case TestProtocolPlatformMacOS:
     1295        return ASCIILiteral("macos");
     1296    }
     1297}
     1298
     1299template<>
     1300inline TestProtocolPlatform fromProtocolString(const String& value)
     1301{
     1302    if (value == "all")
     1303        return TestProtocolPlatformAll;
     1304    if (value == "generic")
     1305        return TestProtocolPlatformGeneric;
     1306    if (value == "ios")
     1307        return TestProtocolPlatformIOS;
     1308    if (value == "macos")
     1309        return TestProtocolPlatformMacOS;
     1310    ASSERT_NOT_REACHED();
     1311    return TestProtocolPlatformAll;
     1312}
    12771313
    12781314
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/definitions-with-mac-platform.json-result

    r210852 r212116  
    647647
    648648
     649typedef NS_ENUM(NSInteger, TestProtocolPlatform) {
     650    TestProtocolPlatformAll,
     651    TestProtocolPlatformGeneric,
     652    TestProtocolPlatformIOS,
     653    TestProtocolPlatformMacOS,
     654};
     655
    649656
    650657
     
    738745ObjCEnumType fromProtocolString(const String& value);
    739746
     747inline String toProtocolString(TestProtocolPlatform value)
     748{
     749    switch(value) {
     750    case TestProtocolPlatformAll:
     751        return ASCIILiteral("all");
     752    case TestProtocolPlatformGeneric:
     753        return ASCIILiteral("generic");
     754    case TestProtocolPlatformIOS:
     755        return ASCIILiteral("ios");
     756    case TestProtocolPlatformMacOS:
     757        return ASCIILiteral("macos");
     758    }
     759}
     760
     761template<>
     762inline TestProtocolPlatform fromProtocolString(const String& value)
     763{
     764    if (value == "all")
     765        return TestProtocolPlatformAll;
     766    if (value == "generic")
     767        return TestProtocolPlatformGeneric;
     768    if (value == "ios")
     769        return TestProtocolPlatformIOS;
     770    if (value == "macos")
     771        return TestProtocolPlatformMacOS;
     772    ASSERT_NOT_REACHED();
     773    return TestProtocolPlatformAll;
     774}
     775
    740776} // namespace Inspector
    741777
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/domain-availability.json-result

    r211075 r212116  
    893893
    894894
     895typedef NS_ENUM(NSInteger, TestProtocolPlatform) {
     896    TestProtocolPlatformAll,
     897    TestProtocolPlatformGeneric,
     898    TestProtocolPlatformIOS,
     899    TestProtocolPlatformMacOS,
     900};
     901
    895902
    896903
     
    992999ObjCEnumType fromProtocolString(const String& value);
    9931000
     1001inline String toProtocolString(TestProtocolPlatform value)
     1002{
     1003    switch(value) {
     1004    case TestProtocolPlatformAll:
     1005        return ASCIILiteral("all");
     1006    case TestProtocolPlatformGeneric:
     1007        return ASCIILiteral("generic");
     1008    case TestProtocolPlatformIOS:
     1009        return ASCIILiteral("ios");
     1010    case TestProtocolPlatformMacOS:
     1011        return ASCIILiteral("macos");
     1012    }
     1013}
     1014
     1015template<>
     1016inline TestProtocolPlatform fromProtocolString(const String& value)
     1017{
     1018    if (value == "all")
     1019        return TestProtocolPlatformAll;
     1020    if (value == "generic")
     1021        return TestProtocolPlatformGeneric;
     1022    if (value == "ios")
     1023        return TestProtocolPlatformIOS;
     1024    if (value == "macos")
     1025        return TestProtocolPlatformMacOS;
     1026    ASSERT_NOT_REACHED();
     1027    return TestProtocolPlatformAll;
     1028}
     1029
    9941030} // namespace Inspector
    9951031
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/domains-with-varying-command-sizes.json-result

    r210852 r212116  
    11501150
    11511151
     1152typedef NS_ENUM(NSInteger, TestProtocolPlatform) {
     1153    TestProtocolPlatformAll,
     1154    TestProtocolPlatformGeneric,
     1155    TestProtocolPlatformIOS,
     1156    TestProtocolPlatformMacOS,
     1157};
     1158
    11521159
    11531160
     
    12551262ObjCEnumType fromProtocolString(const String& value);
    12561263
     1264inline String toProtocolString(TestProtocolPlatform value)
     1265{
     1266    switch(value) {
     1267    case TestProtocolPlatformAll:
     1268        return ASCIILiteral("all");
     1269    case TestProtocolPlatformGeneric:
     1270        return ASCIILiteral("generic");
     1271    case TestProtocolPlatformIOS:
     1272        return ASCIILiteral("ios");
     1273    case TestProtocolPlatformMacOS:
     1274        return ASCIILiteral("macos");
     1275    }
     1276}
     1277
     1278template<>
     1279inline TestProtocolPlatform fromProtocolString(const String& value)
     1280{
     1281    if (value == "all")
     1282        return TestProtocolPlatformAll;
     1283    if (value == "generic")
     1284        return TestProtocolPlatformGeneric;
     1285    if (value == "ios")
     1286        return TestProtocolPlatformIOS;
     1287    if (value == "macos")
     1288        return TestProtocolPlatformMacOS;
     1289    ASSERT_NOT_REACHED();
     1290    return TestProtocolPlatformAll;
     1291}
     1292
    12571293
    12581294
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/enum-values.json-result

    r210852 r212116  
    930930
    931931
     932typedef NS_ENUM(NSInteger, TestProtocolPlatform) {
     933    TestProtocolPlatformAll,
     934    TestProtocolPlatformGeneric,
     935    TestProtocolPlatformIOS,
     936    TestProtocolPlatformMacOS,
     937};
     938
    932939
    933940typedef NS_ENUM(NSInteger, TestProtocolTypeDomainEnum) {
     
    10341041template<typename ObjCEnumType>
    10351042ObjCEnumType fromProtocolString(const String& value);
     1043
     1044inline String toProtocolString(TestProtocolPlatform value)
     1045{
     1046    switch(value) {
     1047    case TestProtocolPlatformAll:
     1048        return ASCIILiteral("all");
     1049    case TestProtocolPlatformGeneric:
     1050        return ASCIILiteral("generic");
     1051    case TestProtocolPlatformIOS:
     1052        return ASCIILiteral("ios");
     1053    case TestProtocolPlatformMacOS:
     1054        return ASCIILiteral("macos");
     1055    }
     1056}
     1057
     1058template<>
     1059inline TestProtocolPlatform fromProtocolString(const String& value)
     1060{
     1061    if (value == "all")
     1062        return TestProtocolPlatformAll;
     1063    if (value == "generic")
     1064        return TestProtocolPlatformGeneric;
     1065    if (value == "ios")
     1066        return TestProtocolPlatformIOS;
     1067    if (value == "macos")
     1068        return TestProtocolPlatformMacOS;
     1069    ASSERT_NOT_REACHED();
     1070    return TestProtocolPlatformAll;
     1071}
    10361072
    10371073
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/events-with-optional-parameters.json-result

    r210852 r212116  
    883883@class TestProtocolDatabaseError;
    884884
     885typedef NS_ENUM(NSInteger, TestProtocolPlatform) {
     886    TestProtocolPlatformAll,
     887    TestProtocolPlatformGeneric,
     888    TestProtocolPlatformIOS,
     889    TestProtocolPlatformMacOS,
     890};
     891
    885892
    886893
     
    988995ObjCEnumType fromProtocolString(const String& value);
    989996
     997inline String toProtocolString(TestProtocolPlatform value)
     998{
     999    switch(value) {
     1000    case TestProtocolPlatformAll:
     1001        return ASCIILiteral("all");
     1002    case TestProtocolPlatformGeneric:
     1003        return ASCIILiteral("generic");
     1004    case TestProtocolPlatformIOS:
     1005        return ASCIILiteral("ios");
     1006    case TestProtocolPlatformMacOS:
     1007        return ASCIILiteral("macos");
     1008    }
     1009}
     1010
     1011template<>
     1012inline TestProtocolPlatform fromProtocolString(const String& value)
     1013{
     1014    if (value == "all")
     1015        return TestProtocolPlatformAll;
     1016    if (value == "generic")
     1017        return TestProtocolPlatformGeneric;
     1018    if (value == "ios")
     1019        return TestProtocolPlatformIOS;
     1020    if (value == "macos")
     1021        return TestProtocolPlatformMacOS;
     1022    ASSERT_NOT_REACHED();
     1023    return TestProtocolPlatformAll;
     1024}
     1025
    9901026
    9911027
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/generate-domains-with-feature-guards.json-result

    r210852 r212116  
    922922@class TestProtocolNetwork2NetworkError;
    923923
     924typedef NS_ENUM(NSInteger, TestProtocolPlatform) {
     925    TestProtocolPlatformAll,
     926    TestProtocolPlatformGeneric,
     927    TestProtocolPlatformIOS,
     928    TestProtocolPlatformMacOS,
     929};
     930
    924931
    925932
     
    10291036ObjCEnumType fromProtocolString(const String& value);
    10301037
     1038inline String toProtocolString(TestProtocolPlatform value)
     1039{
     1040    switch(value) {
     1041    case TestProtocolPlatformAll:
     1042        return ASCIILiteral("all");
     1043    case TestProtocolPlatformGeneric:
     1044        return ASCIILiteral("generic");
     1045    case TestProtocolPlatformIOS:
     1046        return ASCIILiteral("ios");
     1047    case TestProtocolPlatformMacOS:
     1048        return ASCIILiteral("macos");
     1049    }
     1050}
     1051
     1052template<>
     1053inline TestProtocolPlatform fromProtocolString(const String& value)
     1054{
     1055    if (value == "all")
     1056        return TestProtocolPlatformAll;
     1057    if (value == "generic")
     1058        return TestProtocolPlatformGeneric;
     1059    if (value == "ios")
     1060        return TestProtocolPlatformIOS;
     1061    if (value == "macos")
     1062        return TestProtocolPlatformMacOS;
     1063    ASSERT_NOT_REACHED();
     1064    return TestProtocolPlatformAll;
     1065}
     1066
    10311067
    10321068
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/same-type-id-different-domain.json-result

    r210852 r212116  
    657657
    658658
     659typedef NS_ENUM(NSInteger, TestProtocolPlatform) {
     660    TestProtocolPlatformAll,
     661    TestProtocolPlatformGeneric,
     662    TestProtocolPlatformIOS,
     663    TestProtocolPlatformMacOS,
     664};
     665
    659666
    660667
     
    747754template<typename ObjCEnumType>
    748755ObjCEnumType fromProtocolString(const String& value);
     756
     757inline String toProtocolString(TestProtocolPlatform value)
     758{
     759    switch(value) {
     760    case TestProtocolPlatformAll:
     761        return ASCIILiteral("all");
     762    case TestProtocolPlatformGeneric:
     763        return ASCIILiteral("generic");
     764    case TestProtocolPlatformIOS:
     765        return ASCIILiteral("ios");
     766    case TestProtocolPlatformMacOS:
     767        return ASCIILiteral("macos");
     768    }
     769}
     770
     771template<>
     772inline TestProtocolPlatform fromProtocolString(const String& value)
     773{
     774    if (value == "all")
     775        return TestProtocolPlatformAll;
     776    if (value == "generic")
     777        return TestProtocolPlatformGeneric;
     778    if (value == "ios")
     779        return TestProtocolPlatformIOS;
     780    if (value == "macos")
     781        return TestProtocolPlatformMacOS;
     782    ASSERT_NOT_REACHED();
     783    return TestProtocolPlatformAll;
     784}
    749785
    750786
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/shadowed-optional-type-setters.json-result

    r210852 r212116  
    780780@class TestProtocolRuntimeKeyPath;
    781781
     782typedef NS_ENUM(NSInteger, TestProtocolPlatform) {
     783    TestProtocolPlatformAll,
     784    TestProtocolPlatformGeneric,
     785    TestProtocolPlatformIOS,
     786    TestProtocolPlatformMacOS,
     787};
     788
    782789
    783790typedef NS_ENUM(NSInteger, TestProtocolRuntimeKeyPathType) {
     
    885892ObjCEnumType fromProtocolString(const String& value);
    886893
     894inline String toProtocolString(TestProtocolPlatform value)
     895{
     896    switch(value) {
     897    case TestProtocolPlatformAll:
     898        return ASCIILiteral("all");
     899    case TestProtocolPlatformGeneric:
     900        return ASCIILiteral("generic");
     901    case TestProtocolPlatformIOS:
     902        return ASCIILiteral("ios");
     903    case TestProtocolPlatformMacOS:
     904        return ASCIILiteral("macos");
     905    }
     906}
     907
     908template<>
     909inline TestProtocolPlatform fromProtocolString(const String& value)
     910{
     911    if (value == "all")
     912        return TestProtocolPlatformAll;
     913    if (value == "generic")
     914        return TestProtocolPlatformGeneric;
     915    if (value == "ios")
     916        return TestProtocolPlatformIOS;
     917    if (value == "macos")
     918        return TestProtocolPlatformMacOS;
     919    ASSERT_NOT_REACHED();
     920    return TestProtocolPlatformAll;
     921}
     922
    887923
    888924inline String toProtocolString(TestProtocolRuntimeKeyPathType value)
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-aliased-primitive-type.json-result

    r210852 r212116  
    652652
    653653
     654typedef NS_ENUM(NSInteger, TestProtocolPlatform) {
     655    TestProtocolPlatformAll,
     656    TestProtocolPlatformGeneric,
     657    TestProtocolPlatformIOS,
     658    TestProtocolPlatformMacOS,
     659};
     660
    654661
    655662
     
    742749template<typename ObjCEnumType>
    743750ObjCEnumType fromProtocolString(const String& value);
     751
     752inline String toProtocolString(TestProtocolPlatform value)
     753{
     754    switch(value) {
     755    case TestProtocolPlatformAll:
     756        return ASCIILiteral("all");
     757    case TestProtocolPlatformGeneric:
     758        return ASCIILiteral("generic");
     759    case TestProtocolPlatformIOS:
     760        return ASCIILiteral("ios");
     761    case TestProtocolPlatformMacOS:
     762        return ASCIILiteral("macos");
     763    }
     764}
     765
     766template<>
     767inline TestProtocolPlatform fromProtocolString(const String& value)
     768{
     769    if (value == "all")
     770        return TestProtocolPlatformAll;
     771    if (value == "generic")
     772        return TestProtocolPlatformGeneric;
     773    if (value == "ios")
     774        return TestProtocolPlatformIOS;
     775    if (value == "macos")
     776        return TestProtocolPlatformMacOS;
     777    ASSERT_NOT_REACHED();
     778    return TestProtocolPlatformAll;
     779}
    744780
    745781
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result

    r210852 r212116  
    730730
    731731
     732typedef NS_ENUM(NSInteger, TestProtocolPlatform) {
     733    TestProtocolPlatformAll,
     734    TestProtocolPlatformGeneric,
     735    TestProtocolPlatformIOS,
     736    TestProtocolPlatformMacOS,
     737};
     738
    732739
    733740typedef NS_ENUM(NSInteger, TestProtocolDebuggerReason) {
     
    825832template<typename ObjCEnumType>
    826833ObjCEnumType fromProtocolString(const String& value);
     834
     835inline String toProtocolString(TestProtocolPlatform value)
     836{
     837    switch(value) {
     838    case TestProtocolPlatformAll:
     839        return ASCIILiteral("all");
     840    case TestProtocolPlatformGeneric:
     841        return ASCIILiteral("generic");
     842    case TestProtocolPlatformIOS:
     843        return ASCIILiteral("ios");
     844    case TestProtocolPlatformMacOS:
     845        return ASCIILiteral("macos");
     846    }
     847}
     848
     849template<>
     850inline TestProtocolPlatform fromProtocolString(const String& value)
     851{
     852    if (value == "all")
     853        return TestProtocolPlatformAll;
     854    if (value == "generic")
     855        return TestProtocolPlatformGeneric;
     856    if (value == "ios")
     857        return TestProtocolPlatformIOS;
     858    if (value == "macos")
     859        return TestProtocolPlatformMacOS;
     860    ASSERT_NOT_REACHED();
     861    return TestProtocolPlatformAll;
     862}
    827863
    828864
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result

    r210852 r212116  
    750750
    751751
     752typedef NS_ENUM(NSInteger, TestProtocolPlatform) {
     753    TestProtocolPlatformAll,
     754    TestProtocolPlatformGeneric,
     755    TestProtocolPlatformIOS,
     756    TestProtocolPlatformMacOS,
     757};
     758
    752759
    753760typedef NS_ENUM(NSInteger, TestProtocolRuntimeFarmAnimals) {
     
    853860template<typename ObjCEnumType>
    854861ObjCEnumType fromProtocolString(const String& value);
     862
     863inline String toProtocolString(TestProtocolPlatform value)
     864{
     865    switch(value) {
     866    case TestProtocolPlatformAll:
     867        return ASCIILiteral("all");
     868    case TestProtocolPlatformGeneric:
     869        return ASCIILiteral("generic");
     870    case TestProtocolPlatformIOS:
     871        return ASCIILiteral("ios");
     872    case TestProtocolPlatformMacOS:
     873        return ASCIILiteral("macos");
     874    }
     875}
     876
     877template<>
     878inline TestProtocolPlatform fromProtocolString(const String& value)
     879{
     880    if (value == "all")
     881        return TestProtocolPlatformAll;
     882    if (value == "generic")
     883        return TestProtocolPlatformGeneric;
     884    if (value == "ios")
     885        return TestProtocolPlatformIOS;
     886    if (value == "macos")
     887        return TestProtocolPlatformMacOS;
     888    ASSERT_NOT_REACHED();
     889    return TestProtocolPlatformAll;
     890}
    855891
    856892
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result

    r210852 r212116  
    11221122@class TestProtocolTestParameterBundle;
    11231123
     1124typedef NS_ENUM(NSInteger, TestProtocolPlatform) {
     1125    TestProtocolPlatformAll,
     1126    TestProtocolPlatformGeneric,
     1127    TestProtocolPlatformIOS,
     1128    TestProtocolPlatformMacOS,
     1129};
     1130
    11241131
    11251132
     
    12791286ObjCEnumType fromProtocolString(const String& value);
    12801287
     1288inline String toProtocolString(TestProtocolPlatform value)
     1289{
     1290    switch(value) {
     1291    case TestProtocolPlatformAll:
     1292        return ASCIILiteral("all");
     1293    case TestProtocolPlatformGeneric:
     1294        return ASCIILiteral("generic");
     1295    case TestProtocolPlatformIOS:
     1296        return ASCIILiteral("ios");
     1297    case TestProtocolPlatformMacOS:
     1298        return ASCIILiteral("macos");
     1299    }
     1300}
     1301
     1302template<>
     1303inline TestProtocolPlatform fromProtocolString(const String& value)
     1304{
     1305    if (value == "all")
     1306        return TestProtocolPlatformAll;
     1307    if (value == "generic")
     1308        return TestProtocolPlatformGeneric;
     1309    if (value == "ios")
     1310        return TestProtocolPlatformIOS;
     1311    if (value == "macos")
     1312        return TestProtocolPlatformMacOS;
     1313    ASSERT_NOT_REACHED();
     1314    return TestProtocolPlatformAll;
     1315}
     1316
    12811317
    12821318
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result

    r210852 r212116  
    10791079@class TestProtocolTestRecursiveObject2;
    10801080
     1081typedef NS_ENUM(NSInteger, TestProtocolPlatform) {
     1082    TestProtocolPlatformAll,
     1083    TestProtocolPlatformGeneric,
     1084    TestProtocolPlatformIOS,
     1085    TestProtocolPlatformMacOS,
     1086};
     1087
    10811088
    10821089typedef NS_ENUM(NSInteger, TestProtocolTestUncastedAnimals) {
     
    12081215ObjCEnumType fromProtocolString(const String& value);
    12091216
     1217inline String toProtocolString(TestProtocolPlatform value)
     1218{
     1219    switch(value) {
     1220    case TestProtocolPlatformAll:
     1221        return ASCIILiteral("all");
     1222    case TestProtocolPlatformGeneric:
     1223        return ASCIILiteral("generic");
     1224    case TestProtocolPlatformIOS:
     1225        return ASCIILiteral("ios");
     1226    case TestProtocolPlatformMacOS:
     1227        return ASCIILiteral("macos");
     1228    }
     1229}
     1230
     1231template<>
     1232inline TestProtocolPlatform fromProtocolString(const String& value)
     1233{
     1234    if (value == "all")
     1235        return TestProtocolPlatformAll;
     1236    if (value == "generic")
     1237        return TestProtocolPlatformGeneric;
     1238    if (value == "ios")
     1239        return TestProtocolPlatformIOS;
     1240    if (value == "macos")
     1241        return TestProtocolPlatformMacOS;
     1242    ASSERT_NOT_REACHED();
     1243    return TestProtocolPlatformAll;
     1244}
     1245
    12101246
    12111247inline String toProtocolString(TestProtocolTestUncastedAnimals value)
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/worker-supported-domains.json-result

    r211075 r212116  
    894894
    895895
     896typedef NS_ENUM(NSInteger, TestProtocolPlatform) {
     897    TestProtocolPlatformAll,
     898    TestProtocolPlatformGeneric,
     899    TestProtocolPlatformIOS,
     900    TestProtocolPlatformMacOS,
     901};
     902
    896903
    897904
     
    9931000ObjCEnumType fromProtocolString(const String& value);
    9941001
     1002inline String toProtocolString(TestProtocolPlatform value)
     1003{
     1004    switch(value) {
     1005    case TestProtocolPlatformAll:
     1006        return ASCIILiteral("all");
     1007    case TestProtocolPlatformGeneric:
     1008        return ASCIILiteral("generic");
     1009    case TestProtocolPlatformIOS:
     1010        return ASCIILiteral("ios");
     1011    case TestProtocolPlatformMacOS:
     1012        return ASCIILiteral("macos");
     1013    }
     1014}
     1015
     1016template<>
     1017inline TestProtocolPlatform fromProtocolString(const String& value)
     1018{
     1019    if (value == "all")
     1020        return TestProtocolPlatformAll;
     1021    if (value == "generic")
     1022        return TestProtocolPlatformGeneric;
     1023    if (value == "ios")
     1024        return TestProtocolPlatformIOS;
     1025    if (value == "macos")
     1026        return TestProtocolPlatformMacOS;
     1027    ASSERT_NOT_REACHED();
     1028    return TestProtocolPlatformAll;
     1029}
     1030
    9951031} // namespace Inspector
    9961032
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/ios/expected/definitions-with-mac-platform.json-result

    r210852 r212116  
    647647
    648648
     649typedef NS_ENUM(NSInteger, TestProtocolPlatform) {
     650    TestProtocolPlatformAll,
     651    TestProtocolPlatformGeneric,
     652    TestProtocolPlatformIOS,
     653    TestProtocolPlatformMacOS,
     654};
     655
    649656
    650657
     
    738745ObjCEnumType fromProtocolString(const String& value);
    739746
     747inline String toProtocolString(TestProtocolPlatform value)
     748{
     749    switch(value) {
     750    case TestProtocolPlatformAll:
     751        return ASCIILiteral("all");
     752    case TestProtocolPlatformGeneric:
     753        return ASCIILiteral("generic");
     754    case TestProtocolPlatformIOS:
     755        return ASCIILiteral("ios");
     756    case TestProtocolPlatformMacOS:
     757        return ASCIILiteral("macos");
     758    }
     759}
     760
     761template<>
     762inline TestProtocolPlatform fromProtocolString(const String& value)
     763{
     764    if (value == "all")
     765        return TestProtocolPlatformAll;
     766    if (value == "generic")
     767        return TestProtocolPlatformGeneric;
     768    if (value == "ios")
     769        return TestProtocolPlatformIOS;
     770    if (value == "macos")
     771        return TestProtocolPlatformMacOS;
     772    ASSERT_NOT_REACHED();
     773    return TestProtocolPlatformAll;
     774}
     775
    740776} // namespace Inspector
    741777
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/mac/expected/definitions-with-mac-platform.json-result

    r210852 r212116  
    895895@class TestProtocolNetworkError;
    896896
     897typedef NS_ENUM(NSInteger, TestProtocolPlatform) {
     898    TestProtocolPlatformAll,
     899    TestProtocolPlatformGeneric,
     900    TestProtocolPlatformIOS,
     901    TestProtocolPlatformMacOS,
     902};
     903
    897904
    898905
     
    10021009ObjCEnumType fromProtocolString(const String& value);
    10031010
     1011inline String toProtocolString(TestProtocolPlatform value)
     1012{
     1013    switch(value) {
     1014    case TestProtocolPlatformAll:
     1015        return ASCIILiteral("all");
     1016    case TestProtocolPlatformGeneric:
     1017        return ASCIILiteral("generic");
     1018    case TestProtocolPlatformIOS:
     1019        return ASCIILiteral("ios");
     1020    case TestProtocolPlatformMacOS:
     1021        return ASCIILiteral("macos");
     1022    }
     1023}
     1024
     1025template<>
     1026inline TestProtocolPlatform fromProtocolString(const String& value)
     1027{
     1028    if (value == "all")
     1029        return TestProtocolPlatformAll;
     1030    if (value == "generic")
     1031        return TestProtocolPlatformGeneric;
     1032    if (value == "ios")
     1033        return TestProtocolPlatformIOS;
     1034    if (value == "macos")
     1035        return TestProtocolPlatformMacOS;
     1036    ASSERT_NOT_REACHED();
     1037    return TestProtocolPlatformAll;
     1038}
     1039
    10041040
    10051041
  • trunk/Source/WebKit2/ChangeLog

    r212115 r212116  
     12017-02-10  Brian Burg  <bburg@apple.com>
     2
     3        [Cocoa] Web Inspector: generate an NS_ENUM containing platforms supported by the protocol code generator
     4        https://bugs.webkit.org/show_bug.cgi?id=168019
     5        <rdar://problem/28718990>
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        * UIProcess/Automation/Automation.json: Fix the platform values to be lowercase.
     10
    1112017-02-10  Brian Burg  <bburg@apple.com>
    212
  • trunk/Source/WebKit2/UIProcess/Automation/Automation.json

    r210927 r212116  
    249249            "name": "resizeWindowOfBrowsingContext",
    250250            "description": "Resizes the window of the specified browsing context to the specified size.",
    251             "platform": "macOS",
     251            "platform": "macos",
    252252            "parameters": [
    253253                { "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context to be resized." },
     
    258258            "name": "moveWindowOfBrowsingContext",
    259259            "description": "Moves the window of the specified browsing context to the specified position.",
    260             "platform": "macOS",
     260            "platform": "macos",
    261261            "parameters": [
    262262                { "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context to be moved." },
     
    300300            "name": "inspectBrowsingContext",
    301301            "description": "Inspect the specified browsing context using Web Inspector.",
    302             "platform": "macOS",
     302            "platform": "macos",
    303303            "parameters": [
    304304                { "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context that should be inspected." },
Note: See TracChangeset for help on using the changeset viewer.