// interface int asCModule::BindImportedFunction(int index, int sourceId) { // First unbind the old function int r = UnbindImportedFunction(index); if( r < 0 ) return r; // Must verify that the interfaces are equal asCScriptFunction *dst = GetImportedFunction(index); if( dst == 0 ) return asNO_FUNCTION; asCScriptFunction *src = engine->GetScriptFunction(sourceId); if( src == 0 ) return asNO_FUNCTION; // Verify return type if( dst->returnType != src->returnType ) return asINVALID_INTERFACE; if( dst->parameterTypes.GetLength() != src->parameterTypes.GetLength() ) return asINVALID_INTERFACE; for( size_t n = 0; n < dst->parameterTypes.GetLength(); ++n ) { if( dst->parameterTypes[n] != src->parameterTypes[n] ) return asINVALID_INTERFACE; } bindInformations[index]->boundFunctionId = sourceId; engine->scriptFunctions[sourceId]->AddRef(); return asSUCCESS; }
// interface int asCModule::UnbindAllImportedFunctions() { int c = GetImportedFunctionCount(); for( int n = 0; n < c; ++n ) UnbindImportedFunction(n); return asSUCCESS; }
// interface int asCModule::BindImportedFunction(int index, int sourceId) { // First unbind the old function int r = UnbindImportedFunction(index); if( r < 0 ) return r; // Must verify that the interfaces are equal asCModule *srcModule = engine->GetModuleFromFuncId(sourceId); if( srcModule == 0 ) return asNO_MODULE; asCScriptFunction *dst = GetImportedFunction(index); if( dst == 0 ) return asNO_FUNCTION; asCScriptFunction *src = engine->GetScriptFunction(sourceId); if( src == 0 ) return asNO_FUNCTION; // Verify return type if( dst->returnType != src->returnType ) return asINVALID_INTERFACE; if( dst->parameterTypes.GetLength() != src->parameterTypes.GetLength() ) return asINVALID_INTERFACE; for( size_t n = 0; n < dst->parameterTypes.GetLength(); ++n ) { if( dst->parameterTypes[n] != src->parameterTypes[n] ) return asINVALID_INTERFACE; } // Add reference to new module srcModule->AddModuleRef(); bindInformations[index].importedFunction = sourceId; return asSUCCESS; }