| 1398 | // >>>>>>>> WasmEdge function type functions >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
| 1399 | |
| 1400 | WASMEDGE_CAPI_EXPORT WasmEdge_FunctionTypeContext *WasmEdge_FunctionTypeCreate( |
| 1401 | const WasmEdge_ValType *ParamList, const uint32_t ParamLen, |
| 1402 | const WasmEdge_ValType *ReturnList, const uint32_t ReturnLen) noexcept { |
| 1403 | try { |
| 1404 | auto *Cxt = new WasmEdge::AST::FunctionType; |
| 1405 | if (ParamLen > 0) { |
| 1406 | Cxt->getParamTypes().resize(ParamLen); |
| 1407 | } |
| 1408 | for (uint32_t I = 0; I < ParamLen; I++) { |
| 1409 | Cxt->getParamTypes()[I] = genValType(ParamList[I]); |
| 1410 | } |
| 1411 | if (ReturnLen > 0) { |
| 1412 | Cxt->getReturnTypes().resize(ReturnLen); |
| 1413 | } |
| 1414 | for (uint32_t I = 0; I < ReturnLen; I++) { |
| 1415 | Cxt->getReturnTypes()[I] = genValType(ReturnList[I]); |
| 1416 | } |
| 1417 | return toFuncTypeCxt(Cxt); |
| 1418 | } catch (...) { |
| 1419 | handleCAPIError(); |
| 1420 | return nullptr; |
| 1421 | } |
| 1422 | } |
| 1423 | |
| 1424 | WASMEDGE_CAPI_EXPORT uint32_t WasmEdge_FunctionTypeGetParametersLength( |
| 1425 | const WasmEdge_FunctionTypeContext *Cxt) noexcept { |