def initializationexpr(self, decoration=''): T = self.getTYPE() yield '{' if needs_gcheader(self.db.gctransformer, T): lines = generic_initializationexpr(self.db, self.gc_init, 'gcheader', '%sgcheader' % (decoration, )) for line in lines: yield line if T._hints.get('nolength', False): length = '' else: length = '%d, ' % len(self.obj.items) if T.OF is Void or len(self.obj.items) == 0: yield '\t%s' % length.rstrip(', ') yield '}' elif T.OF == Char: if len(self.obj.items) and self.obj.items[0] is None: s = ''.join( [self.obj.getitem(i) for i in range(len(self.obj.items))]) else: s = ''.join(self.obj.items) array_constant = c_char_array_constant(s) if array_constant.startswith('{') and barebonearray(T): assert array_constant.endswith('}') array_constant = array_constant[1:-1].strip() yield '\t%s%s' % (length, array_constant) yield '}' else: barebone = barebonearray(T) if not barebone: yield '\t%s{' % length for j in range(len(self.obj.items)): value = self.obj.items[j] basename = self.name if basename.endswith('.b'): basename = basename[:-2] + '.a' lines = generic_initializationexpr( self.db, value, '%s.items[%d]' % (basename, j), '%s%d' % (decoration, j)) for line in lines: yield '\t' + line if not barebone: yield '} }' else: yield '}'
def initializationexpr(self, decoration=''): T = self.getTYPE() yield '{' if needs_gcheader(T): gc_init = self.db.gcpolicy.array_gcheader_initdata(self) lines = generic_initializationexpr(self.db, gc_init, 'gcheader', '%sgcheader' % (decoration, )) for line in lines: yield line if T._hints.get('nolength', False): length = '' else: length = '%d, ' % len(self.obj.items) if T.OF is Void or len(self.obj.items) == 0: yield '\t%s' % length.rstrip(', ') yield '}' elif T.OF == Char: if len(self.obj.items) and self.obj.items[0] is None: s = ''.join( [self.obj.getitem(i) for i in range(len(self.obj.items))]) else: s = ''.join(self.obj.items) array_constant = c_char_array_constant(s) if array_constant.startswith('{') and barebonearray(T): assert array_constant.endswith('}') array_constant = array_constant[1:-1].strip() yield '\t%s%s' % (length, array_constant) yield '}' else: barebone = barebonearray(T) if not barebone: yield '\t%s{' % length for j in range(len(self.obj.items)): value = self.obj.items[j] basename = self.name if basename.endswith('.b'): basename = basename[:-2] + '.a' lines = generic_initializationexpr( self.db, value, '%s.items[%d]' % (basename, j), '%s%d' % (decoration, j)) for line in lines: yield '\t' + line if not barebone: yield '} }' else: yield '}'
def initializationexpr(self, decoration=""): T = self.getTYPE() yield "{" if needs_gcheader(T): gc_init = self.db.gcpolicy.array_gcheader_initdata(self) lines = generic_initializationexpr(self.db, gc_init, "gcheader", "%sgcheader" % (decoration,)) for line in lines: yield line if T._hints.get("nolength", False): length = "" else: length = "%d, " % len(self.obj.items) if T.OF is Void or len(self.obj.items) == 0: yield "\t%s" % length.rstrip(", ") yield "}" elif T.OF == Char: if len(self.obj.items) and self.obj.items[0] is None: s = "".join([self.obj.getitem(i) for i in range(len(self.obj.items))]) else: s = "".join(self.obj.items) array_constant = c_char_array_constant(s) if array_constant.startswith("{") and barebonearray(T): assert array_constant.endswith("}") array_constant = array_constant[1:-1].strip() yield "\t%s%s" % (length, array_constant) yield "}" else: barebone = barebonearray(T) if not barebone: yield "\t%s{" % length for j in range(len(self.obj.items)): value = self.obj.items[j] basename = self.name if basename.endswith(".b"): basename = basename[:-2] + ".a" lines = generic_initializationexpr( self.db, value, "%s.items[%d]" % (basename, j), "%s%d" % (decoration, j) ) for line in lines: yield "\t" + line if not barebone: yield "} }" else: yield "}"