| 316 | template <typename FuncT, FuncT fn, template <typename FuncTT, FuncTT fnt> class SimNodeT = SimNode_ExtFuncCall, typename QQ = defaultTempFn> |
| 317 | #endif |
| 318 | inline auto makeExtern ( const ModuleLibrary & lib, const char * name, |
| 319 | const char * cppName = nullptr, QQ && tempFn = QQ() ) { |
| 320 | #if DAS_SLOW_CALL_INTEROP |
| 321 | using SimNodeType = SimNodeT<FuncT>; |
| 322 | auto fnX = new ExternalFn<FuncT, SimNodeType, FuncT>(fn, name, lib, cppName); |
| 323 | #else |
| 324 | using SimNodeType = SimNodeT<FuncT, fn>; |
| 325 | auto fnX = new ExternalFn<FuncT, fn, SimNodeType, FuncT>(name, lib, cppName); |
| 326 | #endif |
| 327 | |
| 328 | tempFn(fnX); |
| 329 | |
| 330 | if (!SimNodeType::IS_CMRES) { |
| 331 | if (fnX->result->isRefType() && !fnX->result->ref) { |
| 332 | DAS_FATAL_ERROR( |
| 333 | "addExtern(%s)::failed\n" |
| 334 | " this function should be bound with addExtern<DAS_BIND_FUNC(%s), SimNode_ExtFuncCallAndCopyOrMove>\n" |
| 335 | " likely cast<> is implemented for the return type, and it should not\n", |
| 336 | fnX->name.c_str(), fnX->name.c_str()); |
| 337 | } |
| 338 | } |
| 339 | #if VERIFY_JIT_ARGUMENTS |
| 340 | VerifyFn<FuncT, fn>::verify(fnX); |
| 341 | #endif |
| 342 | return fnX; |
| 343 | } |
| 344 | |
| 345 | #if DAS_SLOW_CALL_INTEROP |
| 346 | template <typename FuncArgT, typename FuncT, FuncT fn, template <typename FuncTT> class SimNodeT = SimNode_ExtFuncCall> |