| 3079 | } |
| 3080 | |
| 3081 | void asCBuilder::AddInterfaceToClass(sClassDeclaration *decl, asCScriptNode *errNode, asCObjectType *intfType) |
| 3082 | { |
| 3083 | // A shared type may only implement from shared interfaces |
| 3084 | if( decl->typeInfo->IsShared() && !intfType->IsShared() ) |
| 3085 | { |
| 3086 | asCString msg; |
| 3087 | msg.Format(TXT_SHARED_CANNOT_IMPLEMENT_NON_SHARED_s, intfType->name.AddressOf()); |
| 3088 | WriteError(msg, decl->script, errNode); |
| 3089 | return; |
| 3090 | } |
| 3091 | |
| 3092 | if( decl->isExistingShared ) |
| 3093 | { |
| 3094 | // If the class is an existing shared class, then just check if the |
| 3095 | // interface exists in the original declaration too |
| 3096 | if( !decl->typeInfo->Implements(intfType) ) |
| 3097 | { |
| 3098 | asCString str; |
| 3099 | str.Format(TXT_SHARED_s_DOESNT_MATCH_ORIGINAL, decl->typeInfo->GetName()); |
| 3100 | WriteError(str, decl->script, errNode); |
| 3101 | return; |
| 3102 | } |
| 3103 | } |
| 3104 | else |
| 3105 | { |
| 3106 | // If the interface is already in the class then don't add it again |
| 3107 | if( decl->typeInfo->Implements(intfType) ) |
| 3108 | return; |
| 3109 | |
| 3110 | // Add the interface to the class |
| 3111 | CastToObjectType(decl->typeInfo)->interfaces.PushLast(intfType); |
| 3112 | |
| 3113 | // Add the inherited interfaces too |
| 3114 | // For interfaces this will be done outside to handle out-of-order declarations |
| 3115 | if( !CastToObjectType(decl->typeInfo)->IsInterface() ) |
| 3116 | { |
| 3117 | for( asUINT n = 0; n < intfType->interfaces.GetLength(); n++ ) |
| 3118 | AddInterfaceToClass(decl, errNode, intfType->interfaces[n]); |
| 3119 | } |
| 3120 | } |
| 3121 | } |
| 3122 | |
| 3123 | void asCBuilder::CompileInterfaces() |
| 3124 | { |
nothing calls this directly
no test coverage detected