Changeset 262424 in webkit


Ignore:
Timestamp:
Jun 2, 2020, 9:10:54 AM (5 years ago)
Author:
[email protected]
Message:

Make generated C++ code use modern C++
https://bugs.webkit.org/show_bug.cgi?id=190714

Patch by Rob Buis <[email protected]> on 2020-06-02
Reviewed by Sam Weinig.

Source/JavaScriptCore:

Update inspector protocol generator and rebaseline the tests.

  • inspector/scripts/codegen/cpp_generator_templates.py:
  • inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
  • inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
  • inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
  • inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
  • inspector/scripts/tests/expected/enum-values.json-result:
  • inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
  • inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
  • inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
  • inspector/scripts/tests/expected/type-declaration-array-type.json-result:
  • inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
  • inspector/scripts/tests/expected/type-declaration-object-type.json-result:
  • inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
  • yarr/generateYarrUnicodePropertyTables.py:

Source/WebCore:

Replace typedef usage by alias-declaration.

No new tests. No change in behavior.

  • css/makeprop.pl:
  • dom/make_names.pl:

(printHeaderHead):
(printInit):
(printTypeHelpersHeaderFile):
(printFactoryCppFile):
(printFactoryHeaderFile):
(printWrapperFactoryCppFile):
(printWrapperFactoryHeaderFile):

Source/WebKit:

Replace typedef usage by alias-declaration.

  • Scripts/webkit/messages.py:
Location:
trunk/Source
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r262412 r262424  
     12020-06-02  Rob Buis  <[email protected]>
     2
     3        Make generated C++ code use modern C++
     4        https://bugs.webkit.org/show_bug.cgi?id=190714
     5
     6        Reviewed by Sam Weinig.
     7
     8        Update inspector protocol generator and rebaseline the tests.
     9
     10        * inspector/scripts/codegen/cpp_generator_templates.py:
     11        * inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
     12        * inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
     13        * inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
     14        * inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
     15        * inspector/scripts/tests/expected/enum-values.json-result:
     16        * inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
     17        * inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
     18        * inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
     19        * inspector/scripts/tests/expected/type-declaration-array-type.json-result:
     20        * inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
     21        * inspector/scripts/tests/expected/type-declaration-object-type.json-result:
     22        * inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
     23        * yarr/generateYarrUnicodePropertyTables.py:
     24
    1252020-06-02  Paulo Matos  <[email protected]>
    226
  • trunk/Source/JavaScriptCore/inspector/scripts/codegen/cpp_generator_templates.py

    r262203 r262424  
    140140    message->getObject("params"_s, parameters);
    141141
    142     typedef void (${domainName}BackendDispatcher::*CallHandler)(long requestId, RefPtr<JSON::Object>&& message);
    143     typedef HashMap<String, CallHandler> DispatchMap;
     142    using CallHandler = void (${domainName}BackendDispatcher::*)(long requestId, RefPtr<JSON::Object>&& message);
     143    using DispatchMap = HashMap<String, CallHandler>;
    144144    static NeverDestroyed<DispatchMap> dispatchMap;
    145145    if (dispatchMap.get().isEmpty()) {
  • trunk/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_header.py

    r262243 r262424  
    170170            if len(declaration.description) > 0:
    171171                typedef_lines.append('/* %s */' % declaration.description)
    172             typedef_lines.append('typedef %s %s;' % (primitive_name, declaration.type_name))
     172            typedef_lines.append('using %s = %s;' % (declaration.type_name, primitive_name))
    173173            sections.append(self.wrap_with_guard_for_condition(declaration.condition, '\n'.join(typedef_lines)))
    174174
     
    178178            if len(declaration.description) > 0:
    179179                typedef_lines.append('/* %s */' % declaration.description)
    180             typedef_lines.append('typedef JSON::ArrayOf<%s> %s;' % (element_type, declaration.type_name))
     180            typedef_lines.append('using %s = JSON::ArrayOf<%s>;' % (declaration.type_name, element_type))
    181181            sections.append(self.wrap_with_guard_for_condition(declaration.condition, '\n'.join(typedef_lines)))
    182182
     
    487487                enum_lines.append('template<>')
    488488                enum_lines.append('struct DefaultHash<Inspector::Protocol::%s::%s> {' % (domain.domain_name, enum_type.raw_name()))
    489                 enum_lines.append('    typedef IntHash<Inspector::Protocol::%s::%s> Hash;' % (domain.domain_name, enum_type.raw_name()))
     489                enum_lines.append('    using Hash = IntHash<Inspector::Protocol::%s::%s>;' % (domain.domain_name, enum_type.raw_name()))
    490490                enum_lines.append('};')
    491491                domain_lines.append(self.wrap_with_guard_for_condition(enum_type.declaration().condition, '\n'.join(enum_lines)))
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/expected/commands-with-async-attribute.json-result

    r262203 r262424  
    619619namespace Database {
    620620/* Unique identifier of Database object. */
    621 typedef int DatabaseId;
    622 typedef JSON::ArrayOf<Inspector::Protocol::Database::PrimaryColors> ColorList;
     621using DatabaseId = int;
     622using ColorList = JSON::ArrayOf<Inspector::Protocol::Database::PrimaryColors>;
    623623} // Database
    624624// End of typedefs.
     
    735735template<>
    736736struct DefaultHash<Inspector::Protocol::Database::PrimaryColors> {
    737     typedef IntHash<Inspector::Protocol::Database::PrimaryColors> Hash;
     737    using Hash = IntHash<Inspector::Protocol::Database::PrimaryColors>;
    738738};
    739739
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result

    r262203 r262424  
    530530namespace Database {
    531531/* Unique identifier of Database object. */
    532 typedef int DatabaseId;
    533 typedef JSON::ArrayOf<Inspector::Protocol::Database::PrimaryColors> ColorList;
     532using DatabaseId = int;
     533using ColorList = JSON::ArrayOf<Inspector::Protocol::Database::PrimaryColors>;
    534534} // Database
    535535// End of typedefs.
     
    646646template<>
    647647struct DefaultHash<Inspector::Protocol::Database::PrimaryColors> {
    648     typedef IntHash<Inspector::Protocol::Database::PrimaryColors> Hash;
     648    using Hash = IntHash<Inspector::Protocol::Database::PrimaryColors>;
    649649};
    650650
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result

    r262203 r262424  
    338338    message->getObject("params"_s, parameters);
    339339
    340     typedef void (Network3BackendDispatcher::*CallHandler)(long requestId, RefPtr<JSON::Object>&& message);
    341     typedef HashMap<String, CallHandler> DispatchMap;
     340    using CallHandler = void (Network3BackendDispatcher::*)(long requestId, RefPtr<JSON::Object>&& message);
     341    using DispatchMap = HashMap<String, CallHandler>;
    342342    static NeverDestroyed<DispatchMap> dispatchMap;
    343343    if (dispatchMap.get().isEmpty()) {
     
    638638namespace Network2 {
    639639/* Unique loader identifier. */
    640 typedef String LoaderId;
     640using LoaderId = String;
    641641} // Network2
    642642// End of typedefs.
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/expected/enum-values.json-result

    r262203 r262424  
    494494template<>
    495495struct DefaultHash<Inspector::Protocol::TypeDomain::TypeDomainEnum> {
    496     typedef IntHash<Inspector::Protocol::TypeDomain::TypeDomainEnum> Hash;
     496    using Hash = IntHash<Inspector::Protocol::TypeDomain::TypeDomainEnum>;
    497497};
    498498
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/expected/events-with-optional-parameters.json-result

    r262203 r262424  
    383383namespace Database {
    384384/* Unique identifier of Database object. */
    385 typedef String DatabaseId;
    386 typedef String PrimaryColors;
    387 typedef JSON::ArrayOf<String> ColorList;
     385using DatabaseId = String;
     386using PrimaryColors = String;
     387using ColorList = JSON::ArrayOf<String>;
    388388} // Database
    389389// End of typedefs.
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/expected/same-type-id-different-domain.json-result

    r262203 r262424  
    314314namespace Runtime {
    315315/* Unique object identifier. */
    316 typedef String RemoteObjectId;
     316using RemoteObjectId = String;
    317317} // Runtime
    318318
    319319namespace Runtime2 {
    320320/* Unique object identifier. */
    321 typedef String RemoteObjectId;
     321using RemoteObjectId = String;
    322322} // Runtime2
    323323// End of typedefs.
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result

    r262203 r262424  
    314314namespace Runtime {
    315315/* Unique object identifier. */
    316 typedef int RemoteObjectId;
     316using RemoteObjectId = int;
    317317} // Runtime
    318318// End of typedefs.
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/expected/type-declaration-array-type.json-result

    r262203 r262424  
    323323// Typedefs.
    324324namespace Debugger {
    325 typedef int BreakpointId;
     325using BreakpointId = int;
    326326} // Debugger
    327327
    328328namespace Runtime {
    329 typedef int ObjectId;
    330 typedef JSON::ArrayOf<int> LuckyNumbers;
    331 typedef JSON::ArrayOf<String> BabyNames;
    332 typedef JSON::ArrayOf<int> NewObjects;
    333 typedef JSON::ArrayOf<int> OldObjects;
    334 typedef JSON::ArrayOf<Inspector::Protocol::Debugger::Reason> StopReasons;
     329using ObjectId = int;
     330using LuckyNumbers = JSON::ArrayOf<int>;
     331using BabyNames = JSON::ArrayOf<String>;
     332using NewObjects = JSON::ArrayOf<int>;
     333using OldObjects = JSON::ArrayOf<int>;
     334using StopReasons = JSON::ArrayOf<Inspector::Protocol::Debugger::Reason>;
    335335} // Runtime
    336336// End of typedefs.
     
    381381template<>
    382382struct DefaultHash<Inspector::Protocol::Debugger::Reason> {
    383     typedef IntHash<Inspector::Protocol::Debugger::Reason> Hash;
     383    using Hash = IntHash<Inspector::Protocol::Debugger::Reason>;
    384384};
    385385
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/expected/type-declaration-enum-type.json-result

    r262203 r262424  
    380380template<>
    381381struct DefaultHash<Inspector::Protocol::Runtime::FarmAnimals> {
    382     typedef IntHash<Inspector::Protocol::Runtime::FarmAnimals> Hash;
     382    using Hash = IntHash<Inspector::Protocol::Runtime::FarmAnimals>;
    383383};
    384384template<>
    385385struct DefaultHash<Inspector::Protocol::Runtime::TwoLeggedAnimals> {
    386     typedef IntHash<Inspector::Protocol::Runtime::TwoLeggedAnimals> Hash;
     386    using Hash = IntHash<Inspector::Protocol::Runtime::TwoLeggedAnimals>;
    387387};
    388388
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/expected/type-declaration-object-type.json-result

    r262203 r262424  
    334334// Typedefs.
    335335namespace Database {
    336 typedef JSON::ArrayOf<Inspector::Protocol::Database::Error> ErrorList;
     336using ErrorList = JSON::ArrayOf<Inspector::Protocol::Database::Error>;
    337337} // Database
    338338// End of typedefs.
     
    910910template<>
    911911struct DefaultHash<Inspector::Protocol::Database::MouseButton> {
    912     typedef IntHash<Inspector::Protocol::Database::MouseButton> Hash;
     912    using Hash = IntHash<Inspector::Protocol::Database::MouseButton>;
    913913};
    914914
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result

    r262203 r262424  
    328328// Typedefs.
    329329namespace Test {
    330 typedef int CastedObjectId;
    331 typedef int UncastedObjectId;
     330using CastedObjectId = int;
     331using UncastedObjectId = int;
    332332} // Test
    333333// End of typedefs.
     
    597597template<>
    598598struct DefaultHash<Inspector::Protocol::Test::UncastedAnimals> {
    599     typedef IntHash<Inspector::Protocol::Test::UncastedAnimals> Hash;
     599    using Hash = IntHash<Inspector::Protocol::Test::UncastedAnimals>;
    600600};
    601601template<>
    602602struct DefaultHash<Inspector::Protocol::Test::CastedAnimals> {
    603     typedef IntHash<Inspector::Protocol::Test::CastedAnimals> Hash;
     603    using Hash = IntHash<Inspector::Protocol::Test::CastedAnimals>;
    604604};
    605605
  • trunk/Source/JavaScriptCore/yarr/generateYarrUnicodePropertyTables.py

    r248846 r262424  
    552552            propertyData.dump(file, propertyData != cls.allPropertyData[-1])
    553553
    554         file.write("typedef std::unique_ptr<CharacterClass> (*CreateCharacterClass)();\n")
     554        file.write("using CreateCharacterClass = std::unique_ptr<CharacterClass> (*)();\n")
    555555        file.write("static CreateCharacterClass createFunctions[{}] = {{\n   ".format(len(cls.allPropertyData)))
    556556        functionsOnThisLine = 0
  • trunk/Source/WebCore/ChangeLog

    r262421 r262424  
     12020-06-02  Rob Buis  <[email protected]>
     2
     3        Make generated C++ code use modern C++
     4        https://bugs.webkit.org/show_bug.cgi?id=190714
     5
     6        Reviewed by Sam Weinig.
     7
     8        Replace typedef usage by alias-declaration.
     9
     10        No new tests. No change in behavior.
     11
     12        * css/makeprop.pl:
     13        * dom/make_names.pl:
     14        (printHeaderHead):
     15        (printInit):
     16        (printTypeHelpersHeaderFile):
     17        (printFactoryCppFile):
     18        (printFactoryHeaderFile):
     19        (printWrapperFactoryCppFile):
     20        (printWrapperFactoryHeaderFile):
     21
    1222020-06-02  Tetsuharu Ohzeki  <[email protected]>
    223
  • trunk/Source/WebCore/css/makeprop.pl

    r260491 r262424  
    619619
    620620namespace WTF {
    621 template<> struct DefaultHash<WebCore::CSSPropertyID> { typedef IntHash<unsigned> Hash; };
     621template<> struct DefaultHash<WebCore::CSSPropertyID> { using Hash = IntHash<unsigned>; };
    622622template<> struct HashTraits<WebCore::CSSPropertyID> : GenericHashTraits<WebCore::CSSPropertyID> {
    623623    static const bool emptyValueIsZero = true;
  • trunk/Source/WebCore/dom/make_names.pl

    r261013 r262424  
    543543
    544544    print F<<END
    545 #ifndef ${prefix}_${namespace}Names_h
    546 
    547 #define ${prefix}_${namespace}Names_h
     545#pragma once
    548546
    549547$includes
     
    584582        print F "\nWEBCORE_EXPORT void init();\n\n";
    585583        print F "} }\n\n";
    586         print F "#endif\n\n";
    587584        return;
    588585    }
     
    696693    printLicenseHeader($F);
    697694
    698     print F "#ifndef ".$parameters{namespace}."ElementTypeHelpers_h\n";
    699     print F "#define ".$parameters{namespace}."ElementTypeHelpers_h\n\n";
     695    print F "#pragma once\n\n";
    700696    print F "#include \"".$parameters{namespace}."Names.h\"\n\n";
    701697
    702698    printTypeHelpers($F, \%allTags);
    703 
    704     print F "#endif\n";
    705699
    706700    close F;
     
    968962namespace WebCore {
    969963
    970 typedef Ref<$parameters{namespace}Element> (*$parameters{namespace}ConstructorFunction)(const QualifiedName&, Document&$formElementArgumentForDeclaration, bool createdByParser);
     964using $parameters{namespace}ConstructorFunction = Ref<$parameters{namespace}Element> (*)(const QualifiedName&, Document&$formElementArgumentForDeclaration, bool createdByParser);
    971965
    972966END
     
    10881082
    10891083    print F<<END
    1090 #ifndef $parameters{namespace}ElementFactory_h
    1091 #define $parameters{namespace}ElementFactory_h
     1084#pragma once
    10921085
    10931086#include <wtf/Forward.h>
     
    11261119
    11271120}
    1128 
    1129 #endif // $parameters{namespace}ElementFactory_h
    11301121
    11311122END
     
    12481239namespace WebCore {
    12491240
    1250 typedef JSDOMObject* (*Create$parameters{namespace}ElementWrapperFunction)(JSDOMGlobalObject*, Ref<$parameters{namespace}Element>&&);
     1241using Create$parameters{namespace}ElementWrapperFunction = JSDOMObject* (*)(JSDOMGlobalObject*, Ref<$parameters{namespace}Element>&&);
    12511242
    12521243END
     
    13391330    printLicenseHeader($F);
    13401331
    1341     print F "#ifndef JS$parameters{namespace}ElementWrapperFactory_h\n";
    1342     print F "#define JS$parameters{namespace}ElementWrapperFactory_h\n\n";
    1343 
    1344     print F "#if $parameters{guardFactoryWith}\n" if $parameters{guardFactoryWith};
     1332    print F "#pragma once\n\n";
    13451333
    13461334    print F <<END
     
    13601348    ;
    13611349
    1362     print F "#endif // $parameters{guardFactoryWith}\n\n" if $parameters{guardFactoryWith};
    1363 
    1364     print F "#endif // JS$parameters{namespace}ElementWrapperFactory_h\n";
    1365 
    13661350    close F;
    13671351}
  • trunk/Source/WebKit/ChangeLog

    r262415 r262424  
     12020-06-02  Rob Buis  <[email protected]>
     2
     3        Make generated C++ code use modern C++
     4        https://bugs.webkit.org/show_bug.cgi?id=190714
     5
     6        Reviewed by Sam Weinig.
     7
     8        Replace typedef usage by alias-declaration.
     9
     10        * Scripts/webkit/messages.py:
     11
    1122020-06-02  Carlos Garcia Campos  <[email protected]>
    213
  • trunk/Source/WebKit/Scripts/webkit/messages.py

    r262075 r262424  
    141141    result.append('class %s {\n' % message.name)
    142142    result.append('public:\n')
    143     result.append('    typedef %s Arguments;\n' % arguments_type(message))
     143    result.append('    using Arguments = %s;\n' % arguments_type(message))
    144144    result.append('\n')
    145145    result.append('    static IPC::MessageName name() { return IPC::MessageName::%s_%s; }\n' % (receiver.name, message.name))
Note: See TracChangeset for help on using the changeset viewer.