Created
November 2, 2022 15:59
-
-
Save BetterProgramming/858159cc02d8437185ff51886efcb580 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// allocate create isolate arguments | |
let isolate = UnsafeMutablePointer<OpaquePointer?> | |
.allocate(capacity: 1) | |
let params = UnsafeMutablePointer<graal_create_isolate_params_t> | |
.allocate(capacity: 1) | |
let graal_thread = UnsafeMutablePointer<OpaquePointer?> | |
.allocate(capacity: 1) | |
// create isolate | |
let ret = graal_create_isolate(self.params, self.isolate, graal_thread) | |
if ret != 0 { | |
print("error creating isolate") | |
exit(0) | |
} | |
// native call into Java | |
Java_exposed_c_function_by_graal(graal_thread.pointee) | |
Java_exposed_c_function_by_graal_with_args(graal_thread.pointee, arg1, arg2) | |
// destroy isolate | |
let ret2 = graal_tear_down_isolate(graal_thread.pointee) | |
if ret2 != 0 { | |
print("error tearing down isolate") | |
exit(0) | |
} | |
// deallocate | |
params.deallocate() | |
isolate.deallocate() | |
graal_thread.deallocate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment