| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright 2014 Google Inc. | 3 # Copyright 2014 Google Inc. |
| 4 # | 4 # |
| 5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
| 6 # found in the LICENSE file. | 6 # found in the LICENSE file. |
| 7 | 7 |
| 8 import collections | 8 import collections |
| 9 import types | 9 import types |
| 10 | 10 |
| 11 # The goal of this class is to store a set of unique items in the order in |
| 12 # which they are inserted. This is important for the final makefile, where |
| 13 # we want to make sure the image decoders are in a particular order. See |
| 14 # images.gyp for more information. |
| 11 class OrderedSet(object): | 15 class OrderedSet(object): |
| 12 """ | 16 """ |
| 13 Ordered set of unique items that supports addition and removal. | 17 Ordered set of unique items that supports addition and removal. |
| 14 """ | 18 """ |
| 15 | 19 |
| 16 def __init__(self): | 20 def __init__(self): |
| 17 self.__li = [] | 21 self.__li = [] |
| 18 | 22 |
| 19 def add(self, item): | 23 def add(self, item): |
| 20 """ | 24 """ |
| (...skipping 29 matching lines...) Expand all Loading... |
| 50 Number of items in the set. | 54 Number of items in the set. |
| 51 """ | 55 """ |
| 52 return len(self.__li) | 56 return len(self.__li) |
| 53 | 57 |
| 54 def __getitem__(self, index): | 58 def __getitem__(self, index): |
| 55 """ | 59 """ |
| 56 Return item at index. | 60 Return item at index. |
| 57 """ | 61 """ |
| 58 return self.__li[index] | 62 return self.__li[index] |
| 59 | 63 |
| 64 def reset(self): |
| 65 """ |
| 66 Reset to empty. |
| 67 """ |
| 68 self.__li = [] |
| 69 |
| 60 VAR_NAMES = ['LOCAL_CFLAGS', | 70 VAR_NAMES = ['LOCAL_CFLAGS', |
| 61 'LOCAL_CPPFLAGS', | 71 'LOCAL_CPPFLAGS', |
| 62 'LOCAL_SRC_FILES', | 72 'LOCAL_SRC_FILES', |
| 63 'LOCAL_SHARED_LIBRARIES', | 73 'LOCAL_SHARED_LIBRARIES', |
| 64 'LOCAL_STATIC_LIBRARIES', | 74 'LOCAL_STATIC_LIBRARIES', |
| 65 'LOCAL_C_INCLUDES', | 75 'LOCAL_C_INCLUDES', |
| 66 'LOCAL_EXPORT_C_INCLUDE_DIRS', | 76 'LOCAL_EXPORT_C_INCLUDE_DIRS', |
| 77 'DEFINES', |
| 67 'KNOWN_TARGETS'] | 78 'KNOWN_TARGETS'] |
| 68 | 79 |
| 69 class VarsDict(collections.namedtuple('VarsDict', VAR_NAMES)): | 80 class VarsDict(collections.namedtuple('VarsDict', VAR_NAMES)): |
| 70 """ | 81 """ |
| 71 Custom class for storing the arguments to Android.mk variables. Can be | 82 Custom class for storing the arguments to Android.mk variables. Can be |
| 72 treated as a dictionary with fixed keys. | 83 treated as a dictionary with fixed keys. |
| 73 """ | 84 """ |
| 74 | 85 |
| 75 __slots__ = () | 86 __slots__ = () |
| 76 | 87 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 for var_dict in other_var_dicts: | 135 for var_dict in other_var_dicts: |
| 125 if not item in var_dict[key]: | 136 if not item in var_dict[key]: |
| 126 in_all_lists = False | 137 in_all_lists = False |
| 127 break | 138 break |
| 128 if in_all_lists: | 139 if in_all_lists: |
| 129 intersection[key].add(item) | 140 intersection[key].add(item) |
| 130 for var_dict in var_dict_list: | 141 for var_dict in var_dict_list: |
| 131 var_dict[key].remove(item) | 142 var_dict[key].remove(item) |
| 132 return intersection | 143 return intersection |
| 133 | 144 |
| OLD | NEW |