Changeset 159312 in webkit
- Timestamp:
- Nov 14, 2013 2:20:04 PM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r159309 r159312 1 2013-11-14 Gergo Balogh <geryxyz@inf.u-szeged.hu> 2 3 generate-message-receiver.py can't handle nested #ifs 4 https://bugs.webkit.org/show_bug.cgi?id=121877 5 6 Reviewed by Darin Adler. 7 8 parser.py was modifieded to collect and combine conditions of nested #ifs. 9 messages_unittest.py extended to check these modifications. 10 11 * Scripts/webkit2/messages_unittest.py: 12 (LoadSomething): 13 (std): 14 (AddEvent): 15 (LoadSomethingElse): 16 * Scripts/webkit2/parser.py: 17 (combine_condition): 18 (bracket_if_needed): 19 (parse): 20 1 21 2013-11-14 Dan Bernstein <mitz@apple.com> 2 22 -
trunk/Source/WebKit2/Scripts/webkit2/messages_unittest.py
r159201 r159312 50 50 51 51 #if ENABLE(WEBKIT2) 52 #if NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND 52 53 53 54 messages -> WebPage LegacyReceiver { 54 55 LoadURL(WTF::String url) 55 56 #if ENABLE(TOUCH_EVENTS) 57 LoadSomething(WTF::String url) 58 #if NESTED_MESSAGE_CONDITION || SOME_OTHER_MESSAGE_CONDITION 56 59 TouchEvent(WebKit::WebTouchEvent event) 60 #endif 61 #if NESTED_MESSAGE_CONDITION && SOME_OTHER_MESSAGE_CONDITION 62 AddEvent(WebKit::WebTouchEvent event) 63 #endif 64 LoadSomethingElse(WTF::String url) 57 65 #endif 58 66 DidReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction) … … 93 101 94 102 #endif 103 #endif 95 104 """ 96 105 97 106 _expected_results = { 98 107 'name': 'WebPage', 99 'conditions': (' ENABLE(WEBKIT2)'),108 'conditions': ('(ENABLE(WEBKIT2) && (NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND))'), 100 109 'messages': ( 101 110 { … … 107 116 }, 108 117 { 118 'name': 'LoadSomething', 119 'parameters': ( 120 ('WTF::String', 'url'), 121 ), 122 'conditions': ('ENABLE(TOUCH_EVENTS)'), 123 }, 124 { 109 125 'name': 'TouchEvent', 110 126 'parameters': ( 111 127 ('WebKit::WebTouchEvent', 'event'), 128 ), 129 'conditions': ('(ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION || SOME_OTHER_MESSAGE_CONDITION))'), 130 }, 131 { 132 'name': 'AddEvent', 133 'parameters': ( 134 ('WebKit::WebTouchEvent', 'event'), 135 ), 136 'conditions': ('(ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION && SOME_OTHER_MESSAGE_CONDITION))'), 137 }, 138 { 139 'name': 'LoadSomethingElse', 140 'parameters': ( 141 ('WTF::String', 'url'), 112 142 ), 113 143 'conditions': ('ENABLE(TOUCH_EVENTS)'), … … 311 341 #define WebPageMessages_h 312 342 313 #if ENABLE(WEBKIT2)343 #if (ENABLE(WEBKIT2) && (NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND)) 314 344 315 345 #include "Arguments.h" … … 371 401 372 402 #if ENABLE(TOUCH_EVENTS) 403 class LoadSomething { 404 public: 405 typedef std::tuple<WTF::String> DecodeType; 406 407 static CoreIPC::StringReference receiverName() { return messageReceiverName(); } 408 static CoreIPC::StringReference name() { return CoreIPC::StringReference("LoadSomething"); } 409 static const bool isSync = false; 410 411 explicit LoadSomething(const WTF::String& url) 412 : m_arguments(url) 413 { 414 } 415 416 const std::tuple<const WTF::String&> arguments() const 417 { 418 return m_arguments; 419 } 420 421 private: 422 std::tuple<const WTF::String&> m_arguments; 423 }; 424 #endif 425 426 #if (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION || SOME_OTHER_MESSAGE_CONDITION)) 373 427 class TouchEvent { 374 428 public: … … 391 445 private: 392 446 std::tuple<const WebKit::WebTouchEvent&> m_arguments; 447 }; 448 #endif 449 450 #if (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION && SOME_OTHER_MESSAGE_CONDITION)) 451 class AddEvent { 452 public: 453 typedef std::tuple<WebKit::WebTouchEvent> DecodeType; 454 455 static CoreIPC::StringReference receiverName() { return messageReceiverName(); } 456 static CoreIPC::StringReference name() { return CoreIPC::StringReference("AddEvent"); } 457 static const bool isSync = false; 458 459 explicit AddEvent(const WebKit::WebTouchEvent& event) 460 : m_arguments(event) 461 { 462 } 463 464 const std::tuple<const WebKit::WebTouchEvent&> arguments() const 465 { 466 return m_arguments; 467 } 468 469 private: 470 std::tuple<const WebKit::WebTouchEvent&> m_arguments; 471 }; 472 #endif 473 474 #if ENABLE(TOUCH_EVENTS) 475 class LoadSomethingElse { 476 public: 477 typedef std::tuple<WTF::String> DecodeType; 478 479 static CoreIPC::StringReference receiverName() { return messageReceiverName(); } 480 static CoreIPC::StringReference name() { return CoreIPC::StringReference("LoadSomethingElse"); } 481 static const bool isSync = false; 482 483 explicit LoadSomethingElse(const WTF::String& url) 484 : m_arguments(url) 485 { 486 } 487 488 const std::tuple<const WTF::String&> arguments() const 489 { 490 return m_arguments; 491 } 492 493 private: 494 std::tuple<const WTF::String&> m_arguments; 393 495 }; 394 496 #endif … … 775 877 } // namespace Messages 776 878 777 #endif // ENABLE(WEBKIT2)879 #endif // (ENABLE(WEBKIT2) && (NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND)) 778 880 779 881 #endif // WebPageMessages_h … … 806 908 #include "config.h" 807 909 808 #if ENABLE(WEBKIT2)910 #if (ENABLE(WEBKIT2) && (NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND)) 809 911 810 912 #include "WebPage.h" … … 822 924 #include "Plugin.h" 823 925 #include "WebCoreArgumentCoders.h" 824 #if ENABLE(TOUCH_EVENTS)926 #if (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION && SOME_OTHER_MESSAGE_CONDITION)) || (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION || SOME_OTHER_MESSAGE_CONDITION)) 825 927 #include "WebEvent.h" 826 928 #endif … … 892 994 } 893 995 #if ENABLE(TOUCH_EVENTS) 996 if (decoder.messageName() == Messages::WebPage::LoadSomething::name()) { 997 CoreIPC::handleMessage<Messages::WebPage::LoadSomething>(decoder, this, &WebPage::loadSomething); 998 return; 999 } 1000 #endif 1001 #if (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION || SOME_OTHER_MESSAGE_CONDITION)) 894 1002 if (decoder.messageName() == Messages::WebPage::TouchEvent::name()) { 895 1003 CoreIPC::handleMessage<Messages::WebPage::TouchEvent>(decoder, this, &WebPage::touchEvent); 1004 return; 1005 } 1006 #endif 1007 #if (ENABLE(TOUCH_EVENTS) && (NESTED_MESSAGE_CONDITION && SOME_OTHER_MESSAGE_CONDITION)) 1008 if (decoder.messageName() == Messages::WebPage::AddEvent::name()) { 1009 CoreIPC::handleMessage<Messages::WebPage::AddEvent>(decoder, this, &WebPage::addEvent); 1010 return; 1011 } 1012 #endif 1013 #if ENABLE(TOUCH_EVENTS) 1014 if (decoder.messageName() == Messages::WebPage::LoadSomethingElse::name()) { 1015 CoreIPC::handleMessage<Messages::WebPage::LoadSomethingElse>(decoder, this, &WebPage::loadSomethingElse); 896 1016 return; 897 1017 } … … 979 1099 } // namespace WebKit 980 1100 981 #endif // ENABLE(WEBKIT2)1101 #endif // (ENABLE(WEBKIT2) && (NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND)) 982 1102 """ 983 1103 -
trunk/Source/WebKit2/Scripts/webkit2/parser.py
r157243 r159312 22 22 23 23 import re 24 import sys25 24 26 25 from webkit2 import model 26 27 28 def combine_condition(conditions): 29 if conditions: 30 if len(conditions) == 1: 31 return conditions[0] 32 else: 33 return bracket_if_needed(' && '.join(map(bracket_if_needed, conditions))) 34 else: 35 return None 36 37 38 def bracket_if_needed(condition): 39 if re.match(r'.*(&&|\|\|).*', condition): 40 return '(%s)' % condition 41 else: 42 return condition 27 43 28 44 … … 31 47 destination = None 32 48 messages = [] 33 condition = None49 conditions = [] 34 50 master_condition = None 35 51 for line in file: … … 38 54 receiver_attributes = parse_attributes_string(match.group('attributes')) 39 55 40 if condition :41 master_condition = condition 42 condition = None56 if conditions: 57 master_condition = conditions 58 conditions = [] 43 59 destination = match.group('destination') 44 60 continue 45 61 if line.startswith('#'): 46 62 if line.startswith('#if '): 47 if condition: 48 # FIXME: generate-message-receiver.py can't handle nested ifs 49 # https://bugs.webkit.org/show_bug.cgi?id=121877 50 sys.stderr.write("ERROR: Nested #ifs aren't supported, please fix %s\n" % file.name) 51 sys.exit(1) 52 condition = line.rstrip()[4:] 53 elif line.startswith('#endif'): 54 condition = None 63 conditions.append(line.rstrip()[4:]) 64 elif line.startswith('#endif') and conditions: 65 conditions.pop() 55 66 continue 56 67 match = re.search(r'([A-Za-z_0-9]+)\((.*?)\)(?:(?:\s+->\s+)\((.*?)\))?(?:\s+(.*))?', line) … … 60 71 parameters = parse_parameters_string(parameters_string) 61 72 for parameter in parameters: 62 parameter.condition = co ndition73 parameter.condition = combine_condition(conditions) 63 74 else: 64 75 parameters = [] … … 69 80 reply_parameters = parse_parameters_string(reply_parameters_string) 70 81 for reply_parameter in reply_parameters: 71 reply_parameter.condition = co ndition82 reply_parameter.condition = combine_condition(conditions) 72 83 elif reply_parameters_string == '': 73 84 reply_parameters = [] … … 75 86 reply_parameters = None 76 87 77 messages.append(model.Message(name, parameters, reply_parameters, attributes, co ndition))78 return model.MessageReceiver(destination, receiver_attributes, messages, master_condition)88 messages.append(model.Message(name, parameters, reply_parameters, attributes, combine_condition(conditions))) 89 return model.MessageReceiver(destination, receiver_attributes, messages, combine_condition(master_condition)) 79 90 80 91
Note: See TracChangeset
for help on using the changeset viewer.