Get a global function by name. @param name The name of the function. @param allowMissing Whether allow missing function or raise an error. @return The function to be returned, None if function is missing.
(String name, boolean allowMissing)
| 51 | * @return The function to be returned, None if function is missing. |
| 52 | */ |
| 53 | private static Function getGlobalFunc(String name, boolean allowMissing) { |
| 54 | Base.RefLong handle = new Base.RefLong(); |
| 55 | Base.checkCall(Base._LIB.tvmFFIFunctionGetGlobal(name, handle)); |
| 56 | if (handle.value != 0) { |
| 57 | return new Function(handle.value); |
| 58 | } else { |
| 59 | if (allowMissing) { |
| 60 | return null; |
| 61 | } else { |
| 62 | throw new IllegalArgumentException("Cannot find global function " + name); |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | Function(long handle) { |
| 68 | super(handle, TypeIndex.kTVMFFIFunction); |
no test coverage detected