Changeset 118652 in webkit
- Timestamp:
- May 28, 2012, 1:03:24 AM (14 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
-
ChangeLog (modified) (1 diff)
-
inspector/CodeGeneratorInspector.py (modified) (7 diffs)
-
inspector/InspectorAgent.cpp (modified) (5 diffs)
-
inspector/InspectorApplicationCacheAgent.cpp (modified) (2 diffs)
-
inspector/InspectorDOMAgent.cpp (modified) (1 diff)
-
inspector/InspectorMemoryAgent.cpp (modified) (2 diffs)
-
inspector/PageRuntimeAgent.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r118651 r118652 1 2012-05-28 Peter Rybin <peter.rybin@gmail.com> 2 3 Web Inspector: CodeGeneratorInspector.py: protect typed API from C++ implicit float to int cast 4 https://bugs.webkit.org/show_bug.cgi?id=87183 5 6 Reviewed by Yury Semikhatsky. 7 8 An intermediate C++ class is introduced that uses C++ template technique to control actual type 9 of its constructor argument. 10 All input parameters of type "int" now have type ExactlyInt. 11 All usage sites are fixed accordingly. 12 13 * inspector/CodeGeneratorInspector.py: 14 (TypeModel.RefPtrBased): 15 (TypeModel.Enum): 16 (TypeModel.ValueType): 17 (TypeModel.ValueType.get_opt_output_type_): 18 (TypeModel.ValueType.ValueOptional.get_command_return_pass_model): 19 (TypeModel.ExactlyInt): 20 (TypeModel.ExactlyInt.__init__): 21 (TypeModel.ExactlyInt.get_input_param_type_text): 22 (TypeModel.ExactlyInt.get_opt_output_type_): 23 (TypeModel.init_class): 24 (ExactlyInt): 25 * inspector/InspectorAgent.cpp: 26 (WebCore::InspectorAgent::enable): 27 (WebCore::InspectorAgent::didCreateWorker): 28 (WebCore::InspectorAgent::didDestroyWorker): 29 (WebCore::InspectorAgent::evaluateForTestInFrontend): 30 * inspector/InspectorApplicationCacheAgent.cpp: 31 (WebCore::InspectorApplicationCacheAgent::updateApplicationCacheStatus): 32 (WebCore::InspectorApplicationCacheAgent::getFramesWithManifests): 33 * inspector/InspectorDOMAgent.cpp: 34 (WebCore::InspectorDOMAgent::buildObjectForNode): 35 * inspector/InspectorMemoryAgent.cpp: 36 (WebCore::jsHeapInfo): 37 (WebCore::InspectorMemoryAgent::getProcessMemoryDistribution): 38 * inspector/PageRuntimeAgent.cpp: 39 (WebCore::PageRuntimeAgent::notifyContextCreated): 40 1 41 2012-05-28 Kentaro Hara <haraken@chromium.org> 2 42 -
trunk/Source/WebCore/inspector/CodeGeneratorInspector.py
r116744 r118652 623 623 624 624 class TypeModel: 625 class RefPtrBased :625 class RefPtrBased(object): 626 626 def __init__(self, class_name): 627 627 self.class_name = class_name … … 647 647 return "%s" 648 648 649 class Enum :649 class Enum(object): 650 650 def __init__(self, base_type_name): 651 651 self.type_name = base_type_name + "::Enum" … … 680 680 return "%s" 681 681 682 class ValueType :682 class ValueType(object): 683 683 def __init__(self, type_name, is_heavy): 684 684 self.type_name = type_name … … 697 697 return self.type_name 698 698 699 def get_opt_output_type_(self): 700 return self.type_name 701 699 702 @staticmethod 700 703 def get_event_setter_expression_pattern(): … … 709 712 710 713 def get_command_return_pass_model(self): 711 return CommandReturnPassModel.OptOutput(self.base. type_name)714 return CommandReturnPassModel.OptOutput(self.base.get_opt_output_type_()) 712 715 713 716 def get_input_param_type_text(self): … … 718 721 return "*%s" 719 722 723 class ExactlyInt(ValueType): 724 def __init__(self): 725 TypeModel.ValueType.__init__(self, "int", False) 726 727 def get_input_param_type_text(self): 728 return "TypeBuilder::ExactlyInt" 729 730 def get_opt_output_type_(self): 731 return "TypeBuilder::ExactlyInt" 732 720 733 @classmethod 721 734 def init_class(cls): 722 735 cls.Bool = cls.ValueType("bool", False) 723 cls.Int = cls. ValueType("int", False)736 cls.Int = cls.ExactlyInt() 724 737 cls.Number = cls.ValueType("double", False) 725 cls.String = cls.ValueType("String", True )738 cls.String = cls.ValueType("String", True,) 726 739 cls.Object = cls.RefPtrBased("InspectorObject") 727 740 cls.Array = cls.RefPtrBased("InspectorArray") … … 2225 2238 2226 2239 2240 // A small transient wrapper around int type, that can be used as a funciton parameter type 2241 // cleverly disallowing C++ implicit casts from float or double. 2242 class ExactlyInt { 2243 public: 2244 template<typename T> 2245 ExactlyInt(T t) : m_value(cast_to_int<T>(t)) {} 2246 2247 ExactlyInt() {} 2248 2249 operator int() { return m_value; } 2250 private: 2251 int m_value; 2252 2253 template<typename T> 2254 static int cast_to_int(T t) { return T::default_case_cast_is_not_supported(); } 2255 }; 2256 2257 template<> 2258 inline int ExactlyInt::cast_to_int<int>(int i) { return i; } 2259 2260 template<> 2261 inline int ExactlyInt::cast_to_int<unsigned int>(unsigned int i) { return i; } 2262 2263 2227 2264 // This class provides "Traits" type for the input type T. It is programmed using C++ template specialization 2228 2265 // technique. By default it simply takes "ItemTraits" type from T, but it doesn't work with the base types. -
trunk/Source/WebCore/inspector/InspectorAgent.cpp
r116740 r118652 127 127 for (WorkersMap::iterator it = m_workers.begin(); it != workersEnd; ++it) { 128 128 InspectorWorkerResource* worker = it->second.get(); 129 m_frontend->inspector()->didCreateWorker( worker->id(), worker->url(), worker->isSharedWorker());129 m_frontend->inspector()->didCreateWorker(static_cast<int>(worker->id()), worker->url(), worker->isSharedWorker()); 130 130 } 131 131 #endif … … 135 135 136 136 for (Vector<pair<long, String> >::iterator it = m_pendingEvaluateTestCommands.begin(); m_frontend && it != m_pendingEvaluateTestCommands.end(); ++it) 137 m_frontend->inspector()->evaluateForTestInFrontend( (*it).first, (*it).second);137 m_frontend->inspector()->evaluateForTestInFrontend(static_cast<int>((*it).first), (*it).second); 138 138 m_pendingEvaluateTestCommands.clear(); 139 139 } … … 164 164 #if ENABLE(JAVASCRIPT_DEBUGGER) 165 165 if (m_inspectedPage && m_frontend && m_state->getBoolean(InspectorAgentState::inspectorAgentEnabled)) 166 m_frontend->inspector()->didCreateWorker( id, url, isSharedWorker);166 m_frontend->inspector()->didCreateWorker(static_cast<int>(id), url, isSharedWorker); 167 167 #endif 168 168 } … … 178 178 #if ENABLE(JAVASCRIPT_DEBUGGER) 179 179 if (m_inspectedPage && m_frontend && m_state->getBoolean(InspectorAgentState::inspectorAgentEnabled)) 180 m_frontend->inspector()->didDestroyWorker( id);180 m_frontend->inspector()->didDestroyWorker(static_cast<int>(id)); 181 181 #endif 182 182 m_workers.remove(workerResource); … … 187 187 { 188 188 if (m_state->getBoolean(InspectorAgentState::inspectorAgentEnabled)) 189 m_frontend->inspector()->evaluateForTestInFrontend( callId, script);189 m_frontend->inspector()->evaluateForTestInFrontend(static_cast<int>(callId), script); 190 190 else 191 191 m_pendingEvaluateTestCommands.append(pair<long, String>(callId, script)); -
trunk/Source/WebCore/inspector/InspectorApplicationCacheAgent.cpp
r115965 r118652 96 96 97 97 String manifestURL = info.m_manifest.string(); 98 m_frontend->applicationCacheStatusUpdated(m_pageAgent->frameId(frame), manifestURL, stat us);98 m_frontend->applicationCacheStatusUpdated(m_pageAgent->frameId(frame), manifestURL, static_cast<int>(status)); 99 99 } 100 100 … … 122 122 .setFrameId(m_pageAgent->frameId(frame)) 123 123 .setManifestURL(manifestURL) 124 .setStatus( host->status());124 .setStatus(static_cast<int>(host->status())); 125 125 result->addItem(value); 126 126 } -
trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp
r117323 r118652 1220 1220 RefPtr<TypeBuilder::DOM::Node> value = TypeBuilder::DOM::Node::create() 1221 1221 .setNodeId(id) 1222 .setNodeType( node->nodeType())1222 .setNodeType(static_cast<int>(node->nodeType())) 1223 1223 .setNodeName(nodeName) 1224 1224 .setLocalName(localName) -
trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp
r118368 r118652 326 326 327 327 RefPtr<WebCore::TypeBuilder::Memory::MemoryBlock> totalJsHeap = WebCore::TypeBuilder::Memory::MemoryBlock::create().setName(MemoryBlockName::totalJsHeap); 328 totalJsHeap->setSize( totalJSHeapSize);328 totalJsHeap->setSize(static_cast<int>(totalJSHeapSize)); 329 329 330 330 RefPtr<TypeBuilder::Array<WebCore::TypeBuilder::Memory::MemoryBlock> > children = TypeBuilder::Array<WebCore::TypeBuilder::Memory::MemoryBlock>::create(); 331 331 RefPtr<WebCore::TypeBuilder::Memory::MemoryBlock> usedJsHeap = WebCore::TypeBuilder::Memory::MemoryBlock::create().setName(MemoryBlockName::usedJsHeap); 332 usedJsHeap->setSize( usedJSHeapSize);332 usedJsHeap->setSize(static_cast<int>(usedJSHeapSize)); 333 333 children->addItem(usedJsHeap); 334 334 … … 345 345 #endif 346 346 processMemory = WebCore::TypeBuilder::Memory::MemoryBlock::create().setName(MemoryBlockName::processPrivateMemory); 347 processMemory->setSize( privateBytes);347 processMemory->setSize(static_cast<int>(privateBytes)); 348 348 349 349 RefPtr<TypeBuilder::Array<WebCore::TypeBuilder::Memory::MemoryBlock> > children = TypeBuilder::Array<WebCore::TypeBuilder::Memory::MemoryBlock>::create(); -
trunk/Source/WebCore/inspector/PageRuntimeAgent.cpp
r116744 r118652 155 155 String name = securityOrigin ? securityOrigin->toString() : ""; 156 156 m_frontend->isolatedContextCreated(ExecutionContextDescription::create() 157 .setId( executionContextId)157 .setId(static_cast<int>(executionContextId)) 158 158 .setIsPageContext(isPageContext) 159 159 .setName(name)
Note:
See TracChangeset
for help on using the changeset viewer.