| 1 | #include "stdafx.h"
|
|---|
| 2 |
|
|---|
| 3 | Interface::Interface( const CClass *pInterfaceClass, const Types &actualTypeParameters )
|
|---|
| 4 | : DynamicMethodsPrototype()
|
|---|
| 5 | , pInterfaceClass( pInterfaceClass )
|
|---|
| 6 | , vtblOffset( -1 )
|
|---|
| 7 | , actualTypeParameters( actualTypeParameters )
|
|---|
| 8 | {
|
|---|
| 9 | //メソッドをコピー
|
|---|
| 10 | BOOST_FOREACH( const CMethod *pBaseMethod, pInterfaceClass->GetDynamicMethods() )
|
|---|
| 11 | {
|
|---|
| 12 | CMethod *pMethod = new DynamicMethod( *pBaseMethod );
|
|---|
| 13 |
|
|---|
| 14 | // アクセシビリティ
|
|---|
| 15 | if(pBaseMethod->GetAccessibility() == Prototype::Private){
|
|---|
| 16 | pMethod->SetAccessibility( Prototype::None );
|
|---|
| 17 | }
|
|---|
| 18 | else{
|
|---|
| 19 | pMethod->SetAccessibility( pBaseMethod->GetAccessibility() );
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | //pobj_Inherits
|
|---|
| 23 | // ※継承元のClassIndexをセット(入れ子継承を考慮する)
|
|---|
| 24 | if(pBaseMethod->GetInheritsClassPtr()==0){
|
|---|
| 25 | pMethod->SetInheritsClassPtr( pInterfaceClass );
|
|---|
| 26 | }
|
|---|
| 27 | else{
|
|---|
| 28 | pMethod->SetInheritsClassPtr( pBaseMethod->GetInheritsClassPtr() );
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | AddDynamicMethods( pMethod );
|
|---|
| 32 | }
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | bool Interface::Equals( const Interface *pInterface ) const
|
|---|
| 36 | {
|
|---|
| 37 | // ポインタが等しいかどうかを見てみる
|
|---|
| 38 | if( this == pInterface )
|
|---|
| 39 | {
|
|---|
| 40 | return true;
|
|---|
| 41 | }
|
|---|
| 42 | else if( this->pInterfaceClass->IsNeedResolve() || pInterface->pInterfaceClass->IsNeedResolve() )
|
|---|
| 43 | {
|
|---|
| 44 | // 依存関係解決前の状態であれば、パスが等しいかどうかを見てみる
|
|---|
| 45 | if( this-pInterfaceClass->IsDuplication( pInterface->pInterfaceClass ) )
|
|---|
| 46 | {
|
|---|
| 47 | return true;
|
|---|
| 48 | }
|
|---|
| 49 | }
|
|---|
| 50 | return false;
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | std::string Interface::GetFullNameWithActualGenericTypeParameters() const
|
|---|
| 54 | {
|
|---|
| 55 | std::string interfaceName = this->GetClass().GetFullName();
|
|---|
| 56 | if( actualTypeParameters.size() )
|
|---|
| 57 | {
|
|---|
| 58 | std::string actualGenericTypesName;
|
|---|
| 59 | BOOST_FOREACH( const Type &typeParameter, actualTypeParameters )
|
|---|
| 60 | {
|
|---|
| 61 | if( actualGenericTypesName.size() )
|
|---|
| 62 | {
|
|---|
| 63 | actualGenericTypesName += ",";
|
|---|
| 64 | }
|
|---|
| 65 | actualGenericTypesName += typeParameter.ToString();
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | interfaceName += "<" + actualGenericTypesName + ">";
|
|---|
| 69 | }
|
|---|
| 70 | return interfaceName;
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | bool Interface::Resolve( const ObjectModule &resolver, ResolveErrors &resolveErrors )
|
|---|
| 74 | {
|
|---|
| 75 | // 動的メソッド
|
|---|
| 76 | BOOST_FOREACH( CMethod *pMethod, GetDynamicMethods() )
|
|---|
| 77 | {
|
|---|
| 78 | pMethod->Resolve( resolver, resolveErrors );
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | // クラス
|
|---|
| 82 | if( this->pInterfaceClass )
|
|---|
| 83 | {
|
|---|
| 84 | if( this->pInterfaceClass->IsNeedResolve() )
|
|---|
| 85 | {
|
|---|
| 86 | const CClass *pTempClass = resolver.meta.GetClasses().FindLike( this->pInterfaceClass );
|
|---|
| 87 | if( pTempClass )
|
|---|
| 88 | {
|
|---|
| 89 | this->pInterfaceClass = pTempClass;
|
|---|
| 90 | }
|
|---|
| 91 | else
|
|---|
| 92 | {
|
|---|
| 93 | resolveErrors.Add( ResolveError( this->pInterfaceClass->GetRelationalObjectModuleIndex(), this->pInterfaceClass->GetFullName() ) );
|
|---|
| 94 | }
|
|---|
| 95 | }
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | BOOST_FOREACH( Type &actualTypeParameter, actualTypeParameters )
|
|---|
| 99 | {
|
|---|
| 100 | actualTypeParameter.Resolve( resolver, resolveErrors );
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | return true;
|
|---|
| 104 | }
|
|---|