Changeset 95298 in webkit
- Timestamp:
- Sep 16, 2011 9:57:50 AM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r95283 r95298 1 2011-09-15 Adam Roben <aroben@apple.com> 2 3 Split some of the message-generation code into separate modules 4 5 This is in preparation for making these modules scripts usable by other projects. 6 7 Fixes <http://webkit.org/b/68217> Model and parsing functionality for WebKit2's 8 message-generation scripts is trapped inside a much larger module 9 10 Reviewed by Darin Adler. 11 12 * DerivedSources.make: 13 * DerivedSources.pro: 14 * GNUmakefile.am: 15 * WebKit2.xcodeproj/project.pbxproj: 16 * win/WebKit2.vcproj: 17 * win/WebKit2Generated.vcproj: 18 Added new files. 19 20 * Scripts/webkit2/messages.py: Moved some code from here... 21 22 * Scripts/webkit2/model.py: Added. 23 * Scripts/webkit2/parser.py: Added. 24 ...to here. MessageReceiver.parse was split out into a function in the new parser module. 25 26 * Scripts/webkit2/messages_unittest.py: Updated for renames. 27 1 28 2011-09-16 Martin Robinson <mrobinson@igalia.com> 2 29 -
trunk/Source/WebKit2/DerivedSources.make
r94456 r95298 87 87 $(WebKit2)/Scripts/webkit2/__init__.py \ 88 88 $(WebKit2)/Scripts/webkit2/messages.py \ 89 $(WebKit2)/Scripts/webkit2/model.py \ 90 $(WebKit2)/Scripts/webkit2/parser.py \ 89 91 # 90 92 -
trunk/Source/WebKit2/DerivedSources.pro
r94519 r95298 136 136 $$PWD/Scripts/generate-messages-header.py \ 137 137 $$PWD/Scripts/webkit2/__init__.py \ 138 $$PWD/Scripts/webkit2/messages.py 138 $$PWD/Scripts/webkit2/messages.py \ 139 $$PWD/Scripts/webkit2/model.py \ 140 $$PWD/Scripts/webkit2/parser.py 139 141 140 142 message_header_generator.commands = $${PYTHON} $${SRC_ROOT_DIR}/Source/WebKit2/Scripts/generate-messages-header.py ${QMAKE_FILE_IN} > ${QMAKE_FILE_OUT} -
trunk/Source/WebKit2/GNUmakefile.am
r95283 r95298 950 950 $(WebKit2)/Scripts/generate-messages-header.py \ 951 951 $(WebKit2)/Scripts/webkit2/__init__.py \ 952 $(WebKit2)/Scripts/webkit2/messages.py 952 $(WebKit2)/Scripts/webkit2/messages.py \ 953 $(WebKit2)/Scripts/webkit2/model.py \ 954 $(WebKit2)/Scripts/webkit2/parser.py 953 955 954 956 # Message header generation -
trunk/Source/WebKit2/Scripts/webkit2/messages.py
r95195 r95298 1 # Copyright (C) 2010 Apple Inc. All rights reserved.1 # Copyright (C) 2010, 2011 Apple Inc. All rights reserved. 2 2 # 3 3 # Redistribution and use in source and binary forms, with or without … … 22 22 23 23 import collections 24 import itertools25 24 import re 25 26 import parser 26 27 27 28 … … 54 55 55 56 """ 56 57 class MessageReceiver(object):58 def __init__(self, name, messages, condition):59 self.name = name60 self.messages = messages61 self.condition = condition62 63 def iterparameters(self):64 return itertools.chain((parameter for message in self.messages for parameter in message.parameters),65 (reply_parameter for message in self.messages if message.reply_parameters for reply_parameter in message.reply_parameters))66 67 @classmethod68 def parse(cls, file):69 destination = None70 messages = []71 condition = None72 master_condition = None73 for line in file:74 match = re.search(r'messages -> ([A-Za-z_0-9]+) {', line)75 if match:76 if condition:77 master_condition = condition78 condition = None79 destination = match.group(1)80 continue81 if line.startswith('#'):82 if line.startswith('#if '):83 condition = line.rstrip()[4:]84 elif line.startswith('#endif'):85 condition = None86 continue87 match = re.search(r'([A-Za-z_0-9]+)\((.*?)\)(?:(?:\s+->\s+)\((.*?)\))?(?:\s+(.*))?', line)88 if match:89 name, parameters_string, reply_parameters_string, attributes_string = match.groups()90 if parameters_string:91 parameters = parse_parameter_string(parameters_string)92 for parameter in parameters:93 parameter.condition = condition94 else:95 parameters = []96 97 if attributes_string:98 attributes = frozenset(attributes_string.split())99 else:100 attributes = None101 102 if reply_parameters_string:103 reply_parameters = parse_parameter_string(reply_parameters_string)104 for reply_parameter in reply_parameters:105 reply_parameter.condition = condition106 elif reply_parameters_string == '':107 reply_parameters = []108 else:109 reply_parameters = None110 111 messages.append(Message(name, parameters, reply_parameters, attributes, condition))112 return MessageReceiver(destination, messages, master_condition)113 114 115 class Message(object):116 def __init__(self, name, parameters, reply_parameters, attributes, condition):117 self.name = name118 self.parameters = parameters119 self.reply_parameters = reply_parameters120 self.attributes = frozenset(attributes or [])121 self.condition = condition122 123 def id(self):124 return '%sID' % self.name125 126 def has_attribute(self, attribute):127 return attribute in self.attributes128 129 130 class Parameter(object):131 def __init__(self, type, name, condition=None):132 self.type = type133 self.name = name134 self.condition = condition135 136 137 def parse_parameter_string(parameter_string):138 return [Parameter(*type_and_name.rsplit(' ', 1)) for type_and_name in parameter_string.split(', ')]139 57 140 58 … … 345 263 346 264 def generate_messages_header(file): 347 receiver = MessageReceiver.parse(file)265 receiver = parser.parse(file) 348 266 header_guard = messages_header_filename(receiver).replace('.', '_') 349 267 … … 483 401 484 402 def generate_message_handler(file): 485 receiver = MessageReceiver.parse(file)403 receiver = parser.parse(file) 486 404 headers = { 487 405 '"%s"' % messages_header_filename(receiver): [None], -
trunk/Source/WebKit2/Scripts/webkit2/messages_unittest.py
r89140 r95298 25 25 26 26 import messages 27 import parser 27 28 28 29 _messages_file_contents = """# Copyright (C) 2010 Apple Inc. All rights reserved. … … 240 241 class MessagesTest(unittest.TestCase): 241 242 def setUp(self): 242 self.receiver = messages.MessageReceiver.parse(StringIO(_messages_file_contents))243 self.receiver = parser.parse(StringIO(_messages_file_contents)) 243 244 244 245 -
trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
r94456 r95298 1748 1748 C0CE73391247F70E00BC0EC4 /* __init__.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = __init__.py; sourceTree = "<group>"; }; 1749 1749 C0CE734612480B7D00BC0EC4 /* messages.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = messages.py; sourceTree = "<group>"; }; 1750 C0D04E8313EC74940041EFD6 /* model.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = model.py; sourceTree = "<group>"; }; 1751 C0D04E8413EC74940041EFD6 /* parser.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = parser.py; sourceTree = "<group>"; }; 1750 1752 C0E3AA441209E2BA00A49D01 /* Module.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Module.h; sourceTree = "<group>"; }; 1751 1753 C0E3AA451209E2BA00A49D01 /* Module.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Module.cpp; sourceTree = "<group>"; }; … … 3386 3388 C0CE734612480B7D00BC0EC4 /* messages.py */, 3387 3389 C08FDE87124A851C007645BD /* messages_unittest.py */, 3390 C0D04E8313EC74940041EFD6 /* model.py */, 3391 C0D04E8413EC74940041EFD6 /* parser.py */, 3388 3392 ); 3389 3393 path = webkit2; -
trunk/Source/WebKit2/win/WebKit2.vcproj
r94115 r95298 4238 4238 > 4239 4239 </File> 4240 <File 4241 RelativePath="..\Scripts\webkit2\model.py" 4242 > 4243 </File> 4244 <File 4245 RelativePath="..\Scripts\webkit2\parser.py" 4246 > 4247 </File> 4240 4248 </Filter> 4241 4249 </Filter> -
trunk/Source/WebKit2/win/WebKit2Generated.vcproj
r82477 r95298 100 100 > 101 101 </File> 102 <File 103 RelativePath="..\Scripts\webkit2\model.py" 104 > 105 </File> 106 <File 107 RelativePath="..\Scripts\webkit2\parser.py" 108 > 109 </File> 102 110 </Filter> 103 111 </Filter>
Note: See TracChangeset
for help on using the changeset viewer.