コード例 #1
0
    def load(self, s: AbstractIO):
        self.clear()

        curblock = self

        left = s.get_uint()

        level = 0
        stack = list()

        while level > -1:
            if left > 0:
                type = s.get_byte()
                name = s.get_widestr()

                if type == ElementKind.PARAM:
                    curblock.add(name, s.get_widestr())
                    left -= 1

                elif type == ElementKind.BLOCK:
                    stack.append((curblock, left))

                    prevblock = curblock
                    curblock = CacheData()
                    prevblock.add(name, curblock)

                    left = s.get_uint()
                    level += 1
                    continue

            else:
                if level > 0:
                    curblock, left = stack.pop()
                    left -= 1
                level -= 1
コード例 #2
0
    def load(self, s: AbstractIO, *, new_format: bool = False):
        self.clear()

        curblock = self
        curblock.sorted = s.get_bool()

        left = s.get_uint()

        level = 0
        stack = list()

        while level > -1:
            if left > 0:
                if new_format and curblock.sorted:
                    s.get(8)

                type = s.get_byte()
                name = s.get_widestr()

                if type == ElementKind.PARAM:
                    curblock.add(name, s.get_widestr())
                    left -= 1

                elif type == ElementKind.BLOCK:
                    stack.append((curblock, left))

                    prevblock = curblock
                    curblock = BlockPar()
                    prevblock.add(name, curblock)

                    curblock.sorted = s.get_bool()
                    left = s.get_uint()
                    level += 1
                    continue

            else:
                if level > 0:
                    curblock, left = stack.pop()
                    left -= 1
                level -= 1