| 3567 | } |
| 3568 | |
| 3569 | WASMEDGE_CAPI_EXPORT uint32_t WasmEdge_VMGetFunctionList( |
| 3570 | const WasmEdge_VMContext *Cxt, WasmEdge_String *Names, |
| 3571 | const WasmEdge_FunctionTypeContext **FuncTypes, |
| 3572 | const uint32_t Len) noexcept { |
| 3573 | if (Cxt) { |
| 3574 | // Do not use VM::getFunctionList() here because it would allocate the |
| 3575 | // returned function name strings. |
| 3576 | const auto *ModInst = Cxt->VM.getActiveModule(); |
| 3577 | if (ModInst != nullptr) { |
| 3578 | return ModInst->getFuncExports([&](const auto &FuncExp) { |
| 3579 | uint32_t I = 0; |
| 3580 | for (auto It = FuncExp.cbegin(); It != FuncExp.cend() && I < Len; |
| 3581 | It++, I++) { |
| 3582 | const auto *FuncInst = It->second; |
| 3583 | const auto &FuncType = FuncInst->getFuncType(); |
| 3584 | if (Names) { |
| 3585 | Names[I] = WasmEdge_String{ |
| 3586 | /* Length */ static_cast<uint32_t>(It->first.length()), |
| 3587 | /* Buf */ It->first.data()}; |
| 3588 | } |
| 3589 | if (FuncTypes) { |
| 3590 | FuncTypes[I] = toFuncTypeCxt(&FuncType); |
| 3591 | } |
| 3592 | } |
| 3593 | return static_cast<uint32_t>(FuncExp.size()); |
| 3594 | }); |
| 3595 | } |
| 3596 | } |
| 3597 | return 0; |
| 3598 | } |
| 3599 | |
| 3600 | WASMEDGE_CAPI_EXPORT WasmEdge_ModuleInstanceContext * |
| 3601 | WasmEdge_VMGetImportModuleContext( |