Changeset 159308 in webkit


Ignore:
Timestamp:
Nov 14, 2013 1:30:48 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

Web Inspector: Simply generated domain dispatch methods for domains with few commands
https://bugs.webkit.org/show_bug.cgi?id=124374

Patch by Joseph Pecoraro <Joseph Pecoraro> on 2013-11-14
Reviewed by Timothy Hatcher.

  • inspector/CodeGeneratorInspector.py:

(Generator.go):
(Generator.process_command):

  • inspector/CodeGeneratorInspectorStrings.py:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r159307 r159308  
     12013-11-14  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Simply generated domain dispatch methods for domains with few commands
     4        https://bugs.webkit.org/show_bug.cgi?id=124374
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        * inspector/CodeGeneratorInspector.py:
     9        (Generator.go):
     10        (Generator.process_command):
     11        * inspector/CodeGeneratorInspectorStrings.py:
     12
    1132013-11-14  Bear Travis  <betravis@adobe.com>
    214
  • trunk/Source/WebCore/inspector/CodeGeneratorInspector.py

    r159289 r159308  
    22# Copyright (c) 2011 Google Inc. All rights reserved.
    33# Copyright (c) 2012 Intel Corporation. All rights reserved.
     4# Copyright (c) 2013 Apple Inc. All Rights Reserved.
    45#
    56# Redistribution and use in source and binary forms, with or without
     
    17321733    backend_dispatcher_constructor = string.Template(CodeGeneratorInspectorStrings.backend_dispatcher_constructor)
    17331734    backend_dispatcher_dispatch_method = string.Template(CodeGeneratorInspectorStrings.backend_dispatcher_dispatch_method)
     1735    backend_dispatcher_dispatch_method_simple = string.Template(CodeGeneratorInspectorStrings.backend_dispatcher_dispatch_method_simple)
    17341736    backend_method = string.Template(CodeGeneratorInspectorStrings.backend_method)
    17351737    frontend_method = string.Template(CodeGeneratorInspectorStrings.frontend_method)
     
    19071909            backend_method_count = len(Generator.backend_method_implementation_list)
    19081910
     1911            dispatcher_if_chain = []
    19091912            dispatcher_commands_list = []
    19101913            if "commands" in json_domain:
    19111914                for json_command in json_domain["commands"]:
    1912                     Generator.process_command(json_command, domain_name, agent_interface_name, dispatcher_name, dispatcher_commands_list)
     1915                    Generator.process_command(json_command, domain_name, agent_interface_name, dispatcher_name, dispatcher_if_chain, dispatcher_commands_list)
    19131916
    19141917            Generator.backend_handler_interface_list.append("protected:\n")
     
    19261929                agentName=agent_interface_name))
    19271930
    1928             Generator.backend_method_implementation_list.insert(backend_method_count + 1, Templates.backend_dispatcher_dispatch_method.substitute(None,
    1929                 domainName=domain_name,
    1930                 dispatcherName=dispatcher_name,
    1931                 dispatcherCommands="\n".join(dispatcher_commands_list)))
     1931            if "commands" in json_domain and len(json_domain["commands"]) <= 5:
     1932                Generator.backend_method_implementation_list.insert(backend_method_count + 1, Templates.backend_dispatcher_dispatch_method_simple.substitute(None,
     1933                    domainName=domain_name,
     1934                    dispatcherName=dispatcher_name,
     1935                    ifChain="\n".join(dispatcher_if_chain)))
     1936            else:
     1937                Generator.backend_method_implementation_list.insert(backend_method_count + 1, Templates.backend_dispatcher_dispatch_method.substitute(None,
     1938                    domainName=domain_name,
     1939                    dispatcherName=dispatcher_name,
     1940                    dispatcherCommands="\n".join(dispatcher_commands_list)))
    19321941
    19331942            if domain_guard:
     
    19851994
    19861995    @staticmethod
    1987     def process_command(json_command, domain_name, agent_interface_name, dispatcher_name, dispatcher_commands_list):
     1996    def process_command(json_command, domain_name, agent_interface_name, dispatcher_name, dispatcher_if_chain, dispatcher_commands_list):
    19881997        json_command_name = json_command["name"]
    19891998
     
    19962005        Generator.backend_handler_interface_list.append("    virtual void %s(ErrorString*" % json_command_name)
    19972006
     2007        if not dispatcher_if_chain:
     2008            dispatcher_if_chain.append("    if (method == \"%s\")" % json_command_name)
     2009        else:
     2010            dispatcher_if_chain.append("    else if (method == \"%s\")" % json_command_name)
     2011        dispatcher_if_chain.append("        %s(callId, *message.get());" % json_command_name)
    19982012        dispatcher_commands_list.append("            { \"%s\",  &%s::%s }," % (json_command_name, dispatcher_name, json_command_name))
    19992013
  • trunk/Source/WebCore/inspector/CodeGeneratorInspectorStrings.py

    r159289 r159308  
    11# Copyright (c) 2013 Google Inc. All rights reserved.
     2# Copyright (c) 2013 Apple Inc. All Rights Reserved.
    23#
    34# Redistribution and use in source and binary forms, with or without
     
    5455""")
    5556
     57backend_dispatcher_dispatch_method_simple = (
     58"""void ${dispatcherName}::dispatch(long callId, const String& method, PassRefPtr<InspectorObject> message)
     59{
     60    Ref<${dispatcherName}> protect(*this);
     61
     62${ifChain}
     63    else
     64        m_backendDispatcher->reportProtocolError(&callId, InspectorBackendDispatcher::MethodNotFound, String("'") + "${domainName}" + '.' + method + "' was not found");
     65}
     66""")
     67
    5668backend_dispatcher_dispatch_method = (
    5769"""void ${dispatcherName}::dispatch(long callId, const String& method, PassRefPtr<InspectorObject> message)
Note: See TracChangeset for help on using the changeset viewer.