if (args.length - argstart < 2)
Py.TypeError("illegal argument type for built-in operation");
if (!(args[argstart] instanceof PyArray)) {
throw Py.TypeError("pack_into takes an array arg"); // as well as a buffer, what else?
}
PyArray buffer = (PyArray)args[argstart];
int offset = args[argstart + 1].asInt();
ByteStream res = pack(format, f, size, argstart + 2, args);
if (res.pos > buffer.__len__()) {
throw StructError("pack_into requires a buffer of at least " + res.pos + " bytes, got " + buffer.__len__());
}
for (int i = 0; i < res.pos; i++, offset++) {
char val = res.data[i];
buffer.set(offset, val);
}
}