attach method
Registers this callback and returns its function pointer.
Adds this to registry if not already present, then returns
nativeFunction.
Implementation
MemoryPointer<RFunction<R>> attach() {
final ptr = nativeFunction;
registry.putIfAbsent(ptr.address, () => this as R);
return ptr;
}