Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1 | From ea7a3ac6c658164690e0febb55f4467cb9e0bcac Mon Sep 17 00:00:00 2001 |
| 2 | From: Thomas Klausner <wiz@NetBSD.org> |
| 3 | Date: Thu, 19 May 2016 17:30:04 +0200 |
| 4 | Subject: [PATCH 1/2] Make whitespace use consistent. |
| 5 | |
| 6 | At least python-3.5.x complains about this forcefully. |
| 7 | |
| 8 | Signed-off-by: Thomas Klausner <wiz@NetBSD.org> |
| 9 | Signed-off-by: Uli Schlachter <psychon@znc.in> |
| 10 | |
| 11 | Upstream-Status: Backport |
| 12 | |
| 13 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> |
| 14 | --- |
| 15 | xcbgen/align.py | 96 ++++++++++++++++++++++++++++----------------------------- |
| 16 | 1 file changed, 48 insertions(+), 48 deletions(-) |
| 17 | |
| 18 | diff --git a/xcbgen/align.py b/xcbgen/align.py |
| 19 | index 5e31838..d4c12ee 100644 |
| 20 | --- a/xcbgen/align.py |
| 21 | +++ b/xcbgen/align.py |
| 22 | @@ -16,12 +16,12 @@ class Alignment(object): |
| 23 | return self.align == other.align and self.offset == other.offset |
| 24 | |
| 25 | def __str__(self): |
| 26 | - return "(align=%d, offset=%d)" % (self.align, self.offset) |
| 27 | + return "(align=%d, offset=%d)" % (self.align, self.offset) |
| 28 | |
| 29 | @staticmethod |
| 30 | def for_primitive_type(size): |
| 31 | - # compute the required start_alignment based on the size of the type |
| 32 | - if size % 8 == 0: |
| 33 | + # compute the required start_alignment based on the size of the type |
| 34 | + if size % 8 == 0: |
| 35 | # do 8-byte primitives require 8-byte alignment in X11? |
| 36 | return Alignment(8,0) |
| 37 | elif size % 4 == 0: |
| 38 | @@ -33,7 +33,7 @@ class Alignment(object): |
| 39 | |
| 40 | |
| 41 | def align_after_fixed_size(self, size): |
| 42 | - new_offset = (self.offset + size) % self.align |
| 43 | + new_offset = (self.offset + size) % self.align |
| 44 | return Alignment(self.align, new_offset) |
| 45 | |
| 46 | |
| 47 | @@ -41,7 +41,7 @@ class Alignment(object): |
| 48 | ''' |
| 49 | Assuming the given external_align, checks whether |
| 50 | self is fulfilled for all cases. |
| 51 | - Returns True if yes, False otherwise. |
| 52 | + Returns True if yes, False otherwise. |
| 53 | ''' |
| 54 | if self.align == 1 and self.offset == 0: |
| 55 | # alignment 1 with offset 0 is always fulfilled |
| 56 | @@ -55,9 +55,9 @@ class Alignment(object): |
| 57 | # the external align guarantees less alignment -> not guaranteed |
| 58 | return False |
| 59 | |
| 60 | - if external_align.align % self.align != 0: |
| 61 | + if external_align.align % self.align != 0: |
| 62 | # the external align cannot be divided by our align |
| 63 | - # -> not guaranteed |
| 64 | + # -> not guaranteed |
| 65 | # (this can only happen if there are alignments that are not |
| 66 | # a power of 2, which is highly discouraged. But better be |
| 67 | # safe and check for it) |
| 68 | @@ -72,7 +72,7 @@ class Alignment(object): |
| 69 | |
| 70 | def combine_with(self, other): |
| 71 | # returns the alignment that is guaranteed when |
| 72 | - # both, self or other, can happen |
| 73 | + # both, self or other, can happen |
| 74 | new_align = gcd(self.align, other.align) |
| 75 | new_offset_candidate1 = self.offset % new_align |
| 76 | new_offset_candidate2 = other.offset % new_align |
| 77 | @@ -83,8 +83,8 @@ class Alignment(object): |
| 78 | new_align = gcd(new_align, offset_diff) |
| 79 | new_offset_candidate1 = self.offset % new_align |
| 80 | new_offset_candidate2 = other.offset % new_align |
| 81 | - assert new_offset_candidate1 == new_offset_candidate2 |
| 82 | - new_offset = new_offset_candidate1 |
| 83 | + assert new_offset_candidate1 == new_offset_candidate2 |
| 84 | + new_offset = new_offset_candidate1 |
| 85 | # return the result |
| 86 | return Alignment(new_align, new_offset) |
| 87 | |
| 88 | @@ -92,44 +92,44 @@ class Alignment(object): |
| 89 | class AlignmentLog(object): |
| 90 | |
| 91 | def __init__(self): |
| 92 | - self.ok_list = [] |
| 93 | - self.fail_list = [] |
| 94 | - self.verbosity = 1 |
| 95 | + self.ok_list = [] |
| 96 | + self.fail_list = [] |
| 97 | + self.verbosity = 1 |
| 98 | |
| 99 | def __str__(self): |
| 100 | - result = "" |
| 101 | + result = "" |
| 102 | |
| 103 | - # output the OK-list |
| 104 | - for (align_before, field_name, type_obj, callstack, align_after) in self.ok_list: |
| 105 | - stacksize = len(callstack) |
| 106 | + # output the OK-list |
| 107 | + for (align_before, field_name, type_obj, callstack, align_after) in self.ok_list: |
| 108 | + stacksize = len(callstack) |
| 109 | indent = ' ' * stacksize |
| 110 | - if self.ok_callstack_is_relevant(callstack): |
| 111 | + if self.ok_callstack_is_relevant(callstack): |
| 112 | if field_name is None or field_name == "": |
| 113 | - result += (" %sok: %s:\n\t%sbefore: %s, after: %s\n" |
| 114 | - % (indent, str(type_obj), indent, str(align_before), str(align_after))) |
| 115 | - else: |
| 116 | - result += (" %sok: field \"%s\" in %s:\n\t%sbefore: %s, after: %s\n" |
| 117 | - % (indent, str(field_name), str(type_obj), |
| 118 | - indent, str(align_before), str(align_after))) |
| 119 | + result += (" %sok: %s:\n\t%sbefore: %s, after: %s\n" |
| 120 | + % (indent, str(type_obj), indent, str(align_before), str(align_after))) |
| 121 | + else: |
| 122 | + result += (" %sok: field \"%s\" in %s:\n\t%sbefore: %s, after: %s\n" |
| 123 | + % (indent, str(field_name), str(type_obj), |
| 124 | + indent, str(align_before), str(align_after))) |
| 125 | if self.verbosity >= 1: |
| 126 | - result += self.callstack_to_str(indent, callstack) |
| 127 | + result += self.callstack_to_str(indent, callstack) |
| 128 | |
| 129 | - # output the fail-list |
| 130 | - for (align_before, field_name, type_obj, callstack, reason) in self.fail_list: |
| 131 | - stacksize = len(callstack) |
| 132 | + # output the fail-list |
| 133 | + for (align_before, field_name, type_obj, callstack, reason) in self.fail_list: |
| 134 | + stacksize = len(callstack) |
| 135 | indent = ' ' * stacksize |
| 136 | - if field_name is None or field_name == "": |
| 137 | - result += (" %sfail: align %s is incompatible with\n\t%s%s\n\t%sReason: %s\n" |
| 138 | - % (indent, str(align_before), indent, str(type_obj), indent, reason)) |
| 139 | - else: |
| 140 | - result += (" %sfail: align %s is incompatible with\n\t%sfield \"%s\" in %s\n\t%sReason: %s\n" |
| 141 | - % (indent, str(align_before), indent, str(field_name), str(type_obj), indent, reason)) |
| 142 | + if field_name is None or field_name == "": |
| 143 | + result += (" %sfail: align %s is incompatible with\n\t%s%s\n\t%sReason: %s\n" |
| 144 | + % (indent, str(align_before), indent, str(type_obj), indent, reason)) |
| 145 | + else: |
| 146 | + result += (" %sfail: align %s is incompatible with\n\t%sfield \"%s\" in %s\n\t%sReason: %s\n" |
| 147 | + % (indent, str(align_before), indent, str(field_name), str(type_obj), indent, reason)) |
| 148 | |
| 149 | if self.verbosity >= 1: |
| 150 | - result += self.callstack_to_str(indent, callstack) |
| 151 | + result += self.callstack_to_str(indent, callstack) |
| 152 | |
| 153 | |
| 154 | - return result |
| 155 | + return result |
| 156 | |
| 157 | |
| 158 | def callstack_to_str(self, indent, callstack): |
| 159 | @@ -137,41 +137,41 @@ class AlignmentLog(object): |
| 160 | for stack_elem in callstack: |
| 161 | result += "\t %s%s\n" % (indent, str(stack_elem)) |
| 162 | result += "\t%s]\n" % indent |
| 163 | - return result |
| 164 | + return result |
| 165 | |
| 166 | |
| 167 | def ok_callstack_is_relevant(self, ok_callstack): |
| 168 | # determine whether an ok callstack is relevant for logging |
| 169 | - if self.verbosity >= 2: |
| 170 | - return True |
| 171 | + if self.verbosity >= 2: |
| 172 | + return True |
| 173 | |
| 174 | # empty callstacks are always relevant |
| 175 | - if len(ok_callstack) == 0: |
| 176 | + if len(ok_callstack) == 0: |
| 177 | return True |
| 178 | |
| 179 | - # check whether the ok_callstack is a subset or equal to a fail_callstack |
| 180 | + # check whether the ok_callstack is a subset or equal to a fail_callstack |
| 181 | for (align_before, field_name, type_obj, fail_callstack, reason) in self.fail_list: |
| 182 | if len(ok_callstack) <= len(fail_callstack): |
| 183 | zipped = zip(ok_callstack, fail_callstack[:len(ok_callstack)]) |
| 184 | - is_subset = all([i == j for i, j in zipped]) |
| 185 | - if is_subset: |
| 186 | + is_subset = all([i == j for i, j in zipped]) |
| 187 | + if is_subset: |
| 188 | return True |
| 189 | |
| 190 | return False |
| 191 | |
| 192 | |
| 193 | def ok(self, align_before, field_name, type_obj, callstack, align_after): |
| 194 | - self.ok_list.append((align_before, field_name, type_obj, callstack, align_after)) |
| 195 | + self.ok_list.append((align_before, field_name, type_obj, callstack, align_after)) |
| 196 | |
| 197 | def fail(self, align_before, field_name, type_obj, callstack, reason): |
| 198 | - self.fail_list.append((align_before, field_name, type_obj, callstack, reason)) |
| 199 | + self.fail_list.append((align_before, field_name, type_obj, callstack, reason)) |
| 200 | |
| 201 | def append(self, other): |
| 202 | - self.ok_list.extend(other.ok_list) |
| 203 | - self.fail_list.extend(other.fail_list) |
| 204 | + self.ok_list.extend(other.ok_list) |
| 205 | + self.fail_list.extend(other.fail_list) |
| 206 | |
| 207 | def ok_count(self): |
| 208 | - return len(self.ok_list) |
| 209 | + return len(self.ok_list) |
| 210 | |
| 211 | |
| 212 | |
| 213 | -- |
| 214 | 2.9.0 |
| 215 | |