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