Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(623)

Side by Side Diff: Source/core/inspector/CodeGeneratorInspectorStrings.py

Issue 326013005: DevTools: minor improvements of CodeGenerator code. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2013 Google Inc. All rights reserved. 1 # Copyright (c) 2013 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 backend_method = ( 46 backend_method = (
47 """void InspectorBackendDispatcherImpl::${domainName}_$methodName(long callId, J SONObject*$requestMessageObject, JSONArray* protocolErrors) 47 """void InspectorBackendDispatcherImpl::${domainName}_$methodName(long callId, J SONObject*$requestMessageObject, JSONArray* protocolErrors)
48 { 48 {
49 if (!$agentField) 49 if (!$agentField)
50 protocolErrors->pushString("${domainName} handler is not available."); 50 protocolErrors->pushString("${domainName} handler is not available.");
51 $methodCode 51 $methodCode
52 if (protocolErrors->length()) { 52 if (protocolErrors->length()) {
53 reportProtocolError(&callId, InvalidParams, String::format(InvalidParams FormatString, commandName($commandNameIndex)), protocolErrors); 53 reportProtocolError(&callId, InvalidParams, String::format(InvalidParams FormatString, commandName($commandNameIndex)), protocolErrors);
54 return; 54 return;
55 } 55 }
56 ErrorString error; 56 $agentCallParamsDeclaration
57 $agentField->$methodName(&error$agentCallParams); 57 $agentField->$methodName($agentCallParams);
58 $responseCook 58 $responseCook
59 sendResponse(callId, $sendResponseCallParams); 59 sendResponse(callId, $sendResponseCallParams);
60 } 60 }
61 """) 61 """)
62 62
63 frontend_method = ("""void InspectorFrontend::$domainName::$eventName($parameter s) 63 frontend_method = ("""void InspectorFrontend::$domainName::$eventName($parameter s)
64 { 64 {
65 RefPtr<JSONObject> jsonMessage = JSONObject::create(); 65 RefPtr<JSONObject> jsonMessage = JSONObject::create();
66 jsonMessage->setString("method", "$domainName.$eventName"); 66 jsonMessage->setString("method", "$domainName.$eventName");
67 $code if (m_inspectorFrontendChannel) 67 $code if (m_inspectorFrontendChannel)
68 m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage.release()) ; 68 m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage.release()) ;
69 } 69 }
70 """) 70 """)
71 71
72 callback_main_methods = ( 72 callback_main_methods = (
73 """InspectorBackendDispatcher::$agentName::$callbackName::$callbackName(PassRefP tr<InspectorBackendDispatcherImpl> backendImpl, int id) : CallbackBase(backendIm pl, id) {} 73 """InspectorBackendDispatcher::$agentName::$callbackName::$callbackName(PassRefP tr<InspectorBackendDispatcherImpl> backendImpl, int id) : CallbackBase(backendIm pl, id) {}
74 74
75 void InspectorBackendDispatcher::$agentName::$callbackName::sendSuccess($paramet ers) 75 void InspectorBackendDispatcher::$agentName::$callbackName::sendSuccess($paramet ers)
76 { 76 {
77 RefPtr<JSONObject> jsonMessage = JSONObject::create(); 77 RefPtr<JSONObject> jsonMessage = JSONObject::create();
78 $code sendIfActive(jsonMessage, ErrorString(), PassRefPtr<JSONValue>()); 78 $code sendIfActive(jsonMessage, ErrorString(), PassRefPtr<JSONValue>());
aandrey 2014/06/10 14:50:41 jsonMessage.release()
79 } 79 }
80 """) 80 """)
81 81
82 callback_failure_method = ( 82 callback_failure_method = (
83 """void InspectorBackendDispatcher::$agentName::$callbackName::sendFailure(const ErrorString& error, $parameter) 83 """void InspectorBackendDispatcher::$agentName::$callbackName::sendFailure(const ErrorString& error, $parameter)
84 { 84 {
85 ASSERT(error.length()); 85 ASSERT(error.length());
86 RefPtr<JSONValue> errorDataValue; 86 RefPtr<JSONValue> errorDataValue;
87 if (error) { 87 if (error) {
88 errorDataValue = $argument; 88 errorDataValue = $argument;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 258
259 static int getInt(JSONObject* object, const char* name, bool* valueFound, JS ONArray* protocolErrors); 259 static int getInt(JSONObject* object, const char* name, bool* valueFound, JS ONArray* protocolErrors);
260 static double getDouble(JSONObject* object, const char* name, bool* valueFou nd, JSONArray* protocolErrors); 260 static double getDouble(JSONObject* object, const char* name, bool* valueFou nd, JSONArray* protocolErrors);
261 static String getString(JSONObject* object, const char* name, bool* valueFou nd, JSONArray* protocolErrors); 261 static String getString(JSONObject* object, const char* name, bool* valueFou nd, JSONArray* protocolErrors);
262 static bool getBoolean(JSONObject* object, const char* name, bool* valueFoun d, JSONArray* protocolErrors); 262 static bool getBoolean(JSONObject* object, const char* name, bool* valueFoun d, JSONArray* protocolErrors);
263 static PassRefPtr<JSONObject> getObject(JSONObject* object, const char* name , bool* valueFound, JSONArray* protocolErrors); 263 static PassRefPtr<JSONObject> getObject(JSONObject* object, const char* name , bool* valueFound, JSONArray* protocolErrors);
264 static PassRefPtr<JSONArray> getArray(JSONObject* object, const char* name, bool* valueFound, JSONArray* protocolErrors); 264 static PassRefPtr<JSONArray> getArray(JSONObject* object, const char* name, bool* valueFound, JSONArray* protocolErrors);
265 265
266 void sendResponse(long callId, ErrorString invocationError, PassRefPtr<JSONO bject> result) 266 void sendResponse(long callId, ErrorString invocationError, PassRefPtr<JSONO bject> result)
267 { 267 {
268 sendResponse(callId, invocationError, RefPtr<JSONValue>(), result); 268 sendResponse(callId, invocationError, RefPtr<JSONValue>(), result);
aandrey 2014/06/10 14:50:41 RefPtr -> PassRefPtr
269 } 269 }
270 void sendResponse(long callId, ErrorString invocationError) 270 void sendResponse(long callId, ErrorString invocationError)
271 { 271 {
272 sendResponse(callId, invocationError, RefPtr<JSONValue>(), JSONObject::c reate()); 272 sendResponse(callId, invocationError, RefPtr<JSONValue>(), JSONObject::c reate());
aandrey 2014/06/10 14:50:41 ditto
273 } 273 }
274 static const char InvalidParamsFormatString[]; 274 static const char InvalidParamsFormatString[];
275 }; 275 };
276 276
277 const char InspectorBackendDispatcherImpl::InvalidParamsFormatString[] = "Some a rguments of method '%s' can't be processed"; 277 const char InspectorBackendDispatcherImpl::InvalidParamsFormatString[] = "Some a rguments of method '%s' can't be processed";
278 278
279 $methods 279 $methods
280 280
281 PassRefPtr<InspectorBackendDispatcher> InspectorBackendDispatcher::create(Inspec torFrontendChannel* inspectorFrontendChannel) 281 PassRefPtr<InspectorBackendDispatcher> InspectorBackendDispatcher::create(Inspec torFrontendChannel* inspectorFrontendChannel)
282 { 282 {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 ASSERT(code >=0); 378 ASSERT(code >=0);
379 ASSERT((unsigned)code < s_commonErrors.size()); 379 ASSERT((unsigned)code < s_commonErrors.size());
380 ASSERT(s_commonErrors[code]); 380 ASSERT(s_commonErrors[code]);
381 RefPtr<JSONObject> error = JSONObject::create(); 381 RefPtr<JSONObject> error = JSONObject::create();
382 error->setNumber("code", s_commonErrors[code]); 382 error->setNumber("code", s_commonErrors[code]);
383 error->setString("message", errorMessage); 383 error->setString("message", errorMessage);
384 ASSERT(error); 384 ASSERT(error);
385 if (data) 385 if (data)
386 error->setValue("data", data); 386 error->setValue("data", data);
387 RefPtr<JSONObject> message = JSONObject::create(); 387 RefPtr<JSONObject> message = JSONObject::create();
388 message->setObject("error", error); 388 message->setObject("error", error);
aandrey 2014/06/10 14:50:41 error.release()
389 if (callId) 389 if (callId)
390 message->setNumber("id", *callId); 390 message->setNumber("id", *callId);
391 else 391 else
392 message->setValue("id", JSONValue::null()); 392 message->setValue("id", JSONValue::null());
393 if (m_inspectorFrontendChannel) 393 if (m_inspectorFrontendChannel)
394 m_inspectorFrontendChannel->sendMessageToFrontend(message.release()); 394 m_inspectorFrontendChannel->sendMessageToFrontend(message.release());
395 } 395 }
396 396
397 template<typename R, typename V, typename V0> 397 template<typename R, typename V, typename V0>
398 R InspectorBackendDispatcherImpl::getPropertyValueImpl(JSONObject* object, const char* name, bool* valueFound, JSONArray* protocolErrors, V0 initial_value, bool (*as_method)(JSONValue*, V*), const char* type_name) 398 R InspectorBackendDispatcherImpl::getPropertyValueImpl(JSONObject* object, const char* name, bool* valueFound, JSONArray* protocolErrors, V0 initial_value, bool (*as_method)(JSONValue*, V*), const char* type_name)
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 }; 946 };
947 947
948 """) 948 """)
949 949
950 class_binding_builder_part_4 = ( 950 class_binding_builder_part_4 = (
951 """ static Builder<NoFieldsSet> create() 951 """ static Builder<NoFieldsSet> create()
952 { 952 {
953 return Builder<NoFieldsSet>(JSONObject::create()); 953 return Builder<NoFieldsSet>(JSONObject::create());
954 } 954 }
955 """) 955 """)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698