(
func: ctypes.FTVMFFIWasmSafeCallType
)
| 2011 | } |
| 2012 | |
| 2013 | private createPackedFuncFromSafeCallType( |
| 2014 | func: ctypes.FTVMFFIWasmSafeCallType |
| 2015 | ): PackedFunc { |
| 2016 | let findex = this.env.packedCFuncTable.length; |
| 2017 | if (this.env.packedCFuncTableFreeId.length != 0) { |
| 2018 | findex = this.env.packedCFuncTableFreeId.pop() as number; |
| 2019 | } else { |
| 2020 | this.env.packedCFuncTable.push(undefined); |
| 2021 | } |
| 2022 | this.env.packedCFuncTable[findex] = func; |
| 2023 | |
| 2024 | const stack = this.lib.getOrAllocCallStack(); |
| 2025 | const outOffset = stack.allocPtrArray(1); |
| 2026 | const outPtr = stack.ptrFromOffset(outOffset); |
| 2027 | this.lib.checkCall( |
| 2028 | (this.exports |
| 2029 | .TVMFFIWasmFunctionCreate as ctypes.FTVMFFIWasmFunctionCreate)( |
| 2030 | findex, |
| 2031 | outPtr |
| 2032 | ) |
| 2033 | ); |
| 2034 | const ret = this.makePackedFunc(this.memory.loadPointer(outPtr)); |
| 2035 | this.lib.recycleCallStack(stack); |
| 2036 | return ret; |
| 2037 | } |
| 2038 | |
| 2039 | /** |
| 2040 | * Set packed function arguments into the location indicated by argsValue and argsCode. |
no test coverage detected