The name of the dynamic library to be imported.
The imported function signature. Specifies the return type and parameter types the C-function takes. Must exactly match how it was exported in the dynamic library or the engine may crash.
OptionalsymbolName: stringThe symbol to call on the imported library. This symbol must be exported in the library (see DLL export) and must be compatible with the C-ABI.
The return type of the function, according to its signature.
This decorator will override the implementation of the function with another that calls the imported library function.
If the library was not found or the specified symbol was not exported on the given library, the implementation will call the original implementation of this function.
Library import support the following C types to be proxied seamlessly between JavaScript and the native calling convention:
Number.Number.Boolean on JavaScript.const char* on C and seamlessly translated to/from a JavaScript String.void* on C and as a IntPtr on JavaScript.The function signature must be in the form of returnType([arguments, ...]) where either returnTypeorarguments` are one of the supported data type specified above.
class PlatformFile {
@importLibrary("c", "fopen", "ptr(string,string)")
public static fopen(path: string, mode: string): IntPtr {}
@importLibrary("c", "fgetc", "int32(ptr)")
public static fgetc(handle: IntPtr): number {}
@importLibrary("c", "fclose", "int32(ptr)")
public static fclose(handle: IntPtr): number {}
}
const handle: BigInt = PlatformFile.fopen("/my/path", "r");
const bytes: number[] = [
PlatformFile.fgetc(handle),
PlatformFile.fgetc(handle),
PlatformFile.fgetc(handle),
PlatformFile.fgetc(handle)
];
PlatformFile.fclose(handle);
Declares that the function is an external imported library.