interface
| 1389 | |
| 1390 | // interface |
| 1391 | int asCModule::BindImportedFunction(asUINT index, asIScriptFunction *func) |
| 1392 | { |
| 1393 | // First unbind the old function |
| 1394 | int r = UnbindImportedFunction(index); |
| 1395 | if( r < 0 ) return r; |
| 1396 | |
| 1397 | // Must verify that the interfaces are equal |
| 1398 | asCScriptFunction *dst = GetImportedFunction(index); |
| 1399 | if( dst == 0 ) return asNO_FUNCTION; |
| 1400 | |
| 1401 | if( func == 0 ) |
| 1402 | return asINVALID_ARG; |
| 1403 | |
| 1404 | // Only script functions and registered functions can be bound |
| 1405 | // Class methods, delegates, other imported functions are not allowed |
| 1406 | if (func->GetFuncType() != asFUNC_SCRIPT && func->GetFuncType() != asFUNC_SYSTEM) |
| 1407 | return asNOT_SUPPORTED; |
| 1408 | |
| 1409 | asCScriptFunction *src = m_engine->GetScriptFunction(func->GetId()); |
| 1410 | if( src == 0 ) |
| 1411 | return asNO_FUNCTION; |
| 1412 | |
| 1413 | // Verify function signature |
| 1414 | if (!dst->IsSignatureExceptNameEqual(src)) |
| 1415 | return asINVALID_INTERFACE; |
| 1416 | |
| 1417 | m_bindInformations[index]->boundFunctionId = src->GetId(); |
| 1418 | src->AddRefInternal(); |
| 1419 | |
| 1420 | return asSUCCESS; |
| 1421 | } |
| 1422 | |
| 1423 | // interface |
| 1424 | int asCModule::UnbindImportedFunction(asUINT index) |