Changeset a35b458 in mainline for tools/xstruct.py


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/xstruct.py

    r3061bc1 ra35b458  
    7272        def size(self):
    7373                return struct.calcsize(self._format_)
    74        
     74
    7575        def pack(self):
    7676                args = []
     
    9090                                args.append(value)
    9191                return struct.pack(self._format_, *args)
    92        
     92
    9393        def unpack(self, data):
    9494                values = struct.unpack(self._format_, data)
     
    100100def create(definition):
    101101        "Create structure object"
    102        
     102
    103103        tokens = definition.split(None)
    104        
     104
    105105        # Initial byte order tag
    106106        format = {
     
    111111        inst = Struct()
    112112        args = []
    113        
     113
    114114        # Member tags
    115115        comment = False
     
    120120                                comment = False
    121121                        continue
    122                
     122
    123123                if (token == "/*"):
    124124                        comment = True
    125125                        continue
    126                
     126
    127127                if (variable != None):
    128128                        subtokens = token.split("[")
    129                        
     129
    130130                        length = None
    131131                        if (len(subtokens) > 1):
    132132                                length = int(subtokens[1].split("]")[0])
    133133                                format += "%d" % length
    134                        
     134
    135135                        format += variable
    136                        
     136
    137137                        inst.__dict__[subtokens[0]] = None
    138138                        args.append((subtokens[0], variable, length))
    139                        
     139
    140140                        variable = None
    141141                        continue
    142                
     142
    143143                if (token[0:8] == "padding["):
    144144                        size = token[8:].split("]")[0]
    145145                        format += "%dx" % int(size)
    146146                        continue
    147                
     147
    148148                variable = {
    149149                        "char":     lambda: "s",
     
    152152                        "uint32_t": lambda: "L",
    153153                        "uint64_t": lambda: "Q",
    154                        
     154
    155155                        "int8_t":   lambda: "b",
    156156                        "int16_t":  lambda: "h",
     
    158158                        "int64_t":  lambda: "q"
    159159                }[token]()
    160        
     160
    161161        inst.__dict__['_format_'] = format
    162162        inst.__dict__['_args_'] = args
Note: See TracChangeset for help on using the changeset viewer.