MCPcopy Index your code
hub / github.com/python/cpython / Array

Class Array

Tools/unicode/makeunicodedata.py:1253–1283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1251# stuff to deal with arrays of unsigned integers
1252
1253class Array:
1254
1255 def __init__(self, name, data):
1256 self.name = name
1257 self.data = data
1258
1259 def dump(self, file, trace=0):
1260 # write data to file, as a C array
1261 size = getsize(self.data)
1262 if trace:
1263 print(self.name+":", size*len(self.data), "bytes", file=sys.stderr)
1264 file.write("static const ")
1265 if size == 1:
1266 file.write("unsigned char")
1267 elif size == 2:
1268 file.write("unsigned short")
1269 else:
1270 file.write("unsigned int")
1271 file.write(" " + self.name + "[] = {\n")
1272 if self.data:
1273 s = " "
1274 for item in self.data:
1275 i = str(item) + ", "
1276 if len(s) + len(i) > 78:
1277 file.write(s.rstrip() + "\n")
1278 s = " " + i
1279 else:
1280 s = s + i
1281 if s.strip():
1282 file.write(s.rstrip() + "\n")
1283 file.write("};\n\n")
1284
1285
1286def getsize(data):

Callers 3

makeunicodedataFunction · 0.70
makeunicodetypeFunction · 0.70
makeunicodenameFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…