addPolicyAxis static method
Implementation
static Uint8List addPolicyAxis(Policy currentPolicy, PolicyAxis axis) {
// FFI INPUT parameters
final currentPolicyPointer = currentPolicy.toBytes().allocateInt8Pointer();
final axisPointer = axis.toString().toNativeUtf8();
// FFI OUTPUT parameters
const arbitraryLargeSize = 8192;
final outputPolicyPointer = calloc<Int8>(arbitraryLargeSize);
final outputPolicyLength = calloc<Int32>(1);
outputPolicyLength.value = arbitraryLargeSize;
try {
final result = library.h_add_policy_axis(
outputPolicyPointer.cast<Int8>(),
outputPolicyLength,
currentPolicyPointer,
currentPolicy.toBytes().length,
axisPointer.cast<Int8>(),
);
if (result != 0) {
throw Exception("Call to `h_add_policy_axis` fail. ${getLastError()}");
}
return Uint8List.fromList(
outputPolicyPointer.asTypedList(outputPolicyLength.value));
} finally {
calloc.free(outputPolicyPointer);
calloc.free(outputPolicyLength);
calloc.free(currentPolicyPointer);
calloc.free(axisPointer);
}
}