const Complex = Struct({
real: FFIType.double,
imag: FFIType.double,
});
const LibFFT = dlopen(LIB_NAME_FFT, {
complex_new: { args: [FFIType.double, FFIType.double], returns: Complex },
complex_add: { args: [Complex, Complex], returns: Complex },
complex_sub: { args: [Complex, Complex], returns: Complex },
complex_mul: { args: [Complex, Complex], returns: Complex },
fft: { args: [FFIType.ptr, FFIType.int32], returns: FFIType.void }
});
let a = Complex.create({ real: 4, imag: 1 });
let b = Complex.create({ real: 3, imag: 3 });
LibFFT.symbols.complex_mul.async(a, b)
.then((mulPtr) => {
let mulVal = Complex.fromPtr(mulPtr);
console.log('complex_mul', mulVal.real, mulVal.imag);
})
.finally(() => {
LibFFT.close();
});
console.log('LibFFT.symbols.complex_mul.async');