OLD | NEW |
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 """Uncapitalizes first letter or initial acronym (used in method names). | 105 """Uncapitalizes first letter or initial acronym (used in method names). |
106 | 106 |
107 E.g., 'SetURL' becomes 'setURL', but 'URLFoo' becomes 'urlFoo'. | 107 E.g., 'SetURL' becomes 'setURL', but 'URLFoo' becomes 'urlFoo'. |
108 """ | 108 """ |
109 for acronym in ACRONYMS: | 109 for acronym in ACRONYMS: |
110 if name.startswith(acronym): | 110 if name.startswith(acronym): |
111 return name.replace(acronym, acronym.lower()) | 111 return name.replace(acronym, acronym.lower()) |
112 return name[0].lower() + name[1:] | 112 return name[0].lower() + name[1:] |
113 | 113 |
114 | 114 |
| 115 def unique_by(dict_list, key): |
| 116 """Returns elements from a list of dictionaries with unique values for the n
amed key.""" |
| 117 keys_seen = set() |
| 118 filtered_list = [] |
| 119 for item in dict_list: |
| 120 if item.get(key) not in keys_seen: |
| 121 filtered_list.append(item) |
| 122 keys_seen.add(item.get(key)) |
| 123 return filtered_list |
| 124 |
| 125 |
115 ################################################################################ | 126 ################################################################################ |
116 # C++ | 127 # C++ |
117 ################################################################################ | 128 ################################################################################ |
118 | 129 |
119 def scoped_name(interface, definition, base_name): | 130 def scoped_name(interface, definition, base_name): |
120 if 'ImplementedInPrivateScript' in definition.extended_attributes: | 131 if 'ImplementedInPrivateScript' in definition.extended_attributes: |
121 return '%s::PrivateScript::%s' % (v8_class_name(interface), base_name) | 132 return '%s::PrivateScript::%s' % (v8_class_name(interface), base_name) |
122 # partial interfaces are implemented as separate classes, with their members | 133 # partial interfaces are implemented as separate classes, with their members |
123 # implemented as static member functions | 134 # implemented as static member functions |
124 partial_interface_implemented_as = definition.extended_attributes.get('Parti
alInterfaceImplementedAs') | 135 partial_interface_implemented_as = definition.extended_attributes.get('Parti
alInterfaceImplementedAs') |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 except StopIteration: | 612 except StopIteration: |
602 return None | 613 return None |
603 | 614 |
604 | 615 |
605 IdlInterface.indexed_property_getter = property(indexed_property_getter) | 616 IdlInterface.indexed_property_getter = property(indexed_property_getter) |
606 IdlInterface.indexed_property_setter = property(indexed_property_setter) | 617 IdlInterface.indexed_property_setter = property(indexed_property_setter) |
607 IdlInterface.indexed_property_deleter = property(indexed_property_deleter) | 618 IdlInterface.indexed_property_deleter = property(indexed_property_deleter) |
608 IdlInterface.named_property_getter = property(named_property_getter) | 619 IdlInterface.named_property_getter = property(named_property_getter) |
609 IdlInterface.named_property_setter = property(named_property_setter) | 620 IdlInterface.named_property_setter = property(named_property_setter) |
610 IdlInterface.named_property_deleter = property(named_property_deleter) | 621 IdlInterface.named_property_deleter = property(named_property_deleter) |
OLD | NEW |