1 # Copyright (c) 2013 Google Inc. All rights reserved.
2 # Copyright (c) 2013 Apple Inc. All Rights Reserved.
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following disclaimer
12 # in the documentation and/or other materials provided with the
14 # * Neither the name of Google Inc. nor the names of its
15 # contributors may be used to endorse or promote products derived from
16 # this software without specific prior written permission.
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 # This file contains string resources for CodeGeneratorInspector.
31 # Its syntax is a Python syntax subset, suitable for manual parsing.
33 frontend_domain_class
= (
34 """class ${exportMacro} ${domainClassName} {
36 ${domainClassName}(InspectorFrontendChannel* inspectorFrontendChannel) : m_inspectorFrontendChannel(inspectorFrontendChannel) { }
37 ${frontendDomainMethodDeclarations}private:
38 InspectorFrontendChannel* m_inspectorFrontendChannel;
43 backend_dispatcher_constructor
= (
44 """PassRefPtr<${dispatcherName}> ${dispatcherName}::create(InspectorBackendDispatcher* backendDispatcher, ${agentName}* agent)
46 return adoptRef(new ${dispatcherName}(backendDispatcher, agent));
49 ${dispatcherName}::${dispatcherName}(InspectorBackendDispatcher* backendDispatcher, ${agentName}* agent)
50 : InspectorSupplementalBackendDispatcher(backendDispatcher)
53 m_backendDispatcher->registerDispatcherForDomain(ASCIILiteral("${domainName}"), this);
57 backend_dispatcher_dispatch_method_simple
= (
58 """void ${dispatcherName}::dispatch(long callId, const String& method, PassRefPtr<InspectorObject> message)
60 Ref<${dispatcherName}> protect(*this);
64 m_backendDispatcher->reportProtocolError(&callId, InspectorBackendDispatcher::MethodNotFound, String("'") + "${domainName}" + '.' + method + "' was not found");
68 backend_dispatcher_dispatch_method
= (
69 """void ${dispatcherName}::dispatch(long callId, const String& method, PassRefPtr<InspectorObject> message)
71 Ref<${dispatcherName}> protect(*this);
73 typedef void (${dispatcherName}::*CallHandler)(long callId, const Inspector::InspectorObject& message);
74 typedef HashMap<String, CallHandler> DispatchMap;
75 DEPRECATED_DEFINE_STATIC_LOCAL(DispatchMap, dispatchMap, ());
76 if (dispatchMap.isEmpty()) {
77 static const struct MethodTable {
83 size_t length = WTF_ARRAY_LENGTH(commands);
84 for (size_t i = 0; i < length; ++i)
85 dispatchMap.add(commands[i].name, commands[i].handler);
88 HashMap<String, CallHandler>::iterator it = dispatchMap.find(method);
89 if (it == dispatchMap.end()) {
90 m_backendDispatcher->reportProtocolError(&callId, InspectorBackendDispatcher::MethodNotFound, String("'") + "${domainName}" + '.' + method + "' was not found");
94 ((*this).*it->value)(callId, *message.get());
99 """void ${dispatcherName}::${methodName}(long callId, const InspectorObject&${requestMessageObject})
101 ${methodInParametersHandling}${methodDispatchHandling}${methodOutParametersHandling}${methodEndingHandling}
105 frontend_method
= ("""void Inspector${domainName}FrontendDispatcher::${eventName}(${parameters})
107 RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
108 jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("${domainName}.${eventName}"));
110 m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
115 """${handlerName}::${callbackName}::${callbackName}(PassRefPtr<InspectorBackendDispatcher> backendDispatcher, int id) : Inspector::InspectorBackendDispatcher::CallbackBase(backendDispatcher, id) { }
117 void ${handlerName}::${callbackName}::sendSuccess(${parameters})
119 RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
120 ${code} sendIfActive(jsonMessage, ErrorString());
125 """#ifndef Inspector${outputFileNamePrefix}FrontendDispatchers_h
126 #define Inspector${outputFileNamePrefix}FrontendDispatchers_h
128 #include "Inspector${outputFileNamePrefix}TypeBuilders.h"
129 #include <inspector/InspectorFrontendChannel.h>
130 #include <inspector/InspectorValues.h>
131 #include <wtf/PassRefPtr.h>
132 #include <wtf/text/WTFString.h>
134 namespace Inspector {
136 #if ENABLE(INSPECTOR)
140 #endif // ENABLE(INSPECTOR)
142 } // namespace Inspector
144 #endif // !defined(Inspector${outputFileNamePrefix}FrontendDispatchers_h)
148 """#ifndef Inspector${outputFileNamePrefix}BackendDispatchers_h
149 #define Inspector${outputFileNamePrefix}BackendDispatchers_h
151 #if ENABLE(INSPECTOR)
153 #include "Inspector${outputFileNamePrefix}TypeBuilders.h"
154 #include <inspector/InspectorBackendDispatcher.h>
155 #include <wtf/PassRefPtr.h>
156 #include <wtf/text/WTFString.h>
158 namespace Inspector {
160 typedef String ErrorString;
164 ${dispatcherInterfaces}
165 } // namespace Inspector
167 #endif // ENABLE(INSPECTOR)
169 #endif // !defined(Inspector${outputFileNamePrefix}BackendDispatchers_h)
176 #if ENABLE(INSPECTOR)
178 #include "Inspector${outputFileNamePrefix}BackendDispatchers.h"
180 #include <inspector/InspectorFrontendChannel.h>
181 #include <inspector/InspectorValues.h>
182 #include <wtf/text/CString.h>
183 #include <wtf/text/WTFString.h>
185 namespace Inspector {
187 ${handlerImplementations}
190 } // namespace Inspector
192 #endif // ENABLE(INSPECTOR)
200 #if ENABLE(INSPECTOR)
202 #include "Inspector${outputFileNamePrefix}FrontendDispatchers.h"
204 #include <wtf/text/CString.h>
205 #include <wtf/text/WTFString.h>
207 namespace Inspector {
211 } // namespace Inspector
213 #endif // ENABLE(INSPECTOR)
218 #ifndef Inspector${outputFileNamePrefix}TypeBuilders_h
219 #define Inspector${outputFileNamePrefix}TypeBuilders_h
221 #if ENABLE(INSPECTOR)
223 #include <inspector/InspectorTypeBuilder.h>
224 ${typeBuilderDependencies}
225 #include <wtf/Assertions.h>
226 #include <wtf/PassRefPtr.h>
228 namespace Inspector {
230 namespace TypeBuilder {
234 ${exportMacro} String get${outputFileNamePrefix}EnumConstantValue(int code);
237 } // namespace TypeBuilder
239 } // namespace Inspector
241 #endif // ENABLE(INSPECTOR)
243 #endif // !defined(Inspector${outputFileNamePrefix}TypeBuilders_h)
251 #include "Inspector${outputFileNamePrefix}TypeBuilders.h"
253 #if ENABLE(INSPECTOR)
255 #include <wtf/text/CString.h>
257 namespace Inspector {
259 namespace TypeBuilder {
261 static const char* const enum_constant_values[] = {
262 ${enumConstantValues}};
264 String get${outputFileNamePrefix}EnumConstantValue(int code) {
265 return enum_constant_values[code];
268 } // namespace TypeBuilder
272 #if ${validatorIfdefName}
276 #endif // ${validatorIfdefName}
278 } // namespace Inspector
280 #endif // ENABLE(INSPECTOR)
286 ${domainInitializers}
289 param_container_access_code
= """
290 RefPtr<InspectorObject> paramsContainer = message.getObject("params");
291 InspectorObject* paramsContainerPtr = paramsContainer.get();
292 InspectorArray* protocolErrorsPtr = protocolErrors.get();
295 class_binding_builder_part_1
= (
296 """ AllFieldsSet = %s
302 RefPtr<Inspector::InspectorObject> m_result;
304 template<int STEP> Builder<STATE | STEP>& castState()
306 return *reinterpret_cast<Builder<STATE | STEP>*>(this);
309 Builder(PassRefPtr</*%s*/Inspector::InspectorObject> ptr)
311 COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state);
318 class_binding_builder_part_2
= ("""
319 Builder<STATE | %s>& set%s(%s value)
321 COMPILE_ASSERT(!(STATE & %s), property_%s_already_set);
322 m_result->set%s(ASCIILiteral("%s"), %s);
323 return castState<%s>();
327 class_binding_builder_part_3
= ("""
328 operator RefPtr<%s>& ()
330 COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready);
331 COMPILE_ASSERT(sizeof(%s) == sizeof(Inspector::InspectorObject), cannot_cast);
332 return *reinterpret_cast<RefPtr<%s>*>(&m_result);
335 PassRefPtr<%s> release()
337 return RefPtr<%s>(*this).release();
343 class_binding_builder_part_4
= (
344 """ static Builder<NoFieldsSet> create()
346 return Builder<NoFieldsSet>(Inspector::InspectorObject::create());