[206] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
[558] | 3 | DynamicMethod::OverrideResult::EnumType DynamicMethod::Override( const UserProc *pUserProc, Prototype::Accessibility accessibility, bool isOverrideModifier )
|
---|
[351] | 4 | {
|
---|
[558] | 5 | bool isAbstractBefore = this->IsAbstract();
|
---|
[351] | 6 |
|
---|
| 7 | //メンバ関数を上書き
|
---|
| 8 | this->SetUserProcPtr( pUserProc );
|
---|
| 9 | this->SetAbstractMark( false );
|
---|
| 10 |
|
---|
[558] | 11 | if( this->IsVirtual() )
|
---|
[351] | 12 | {
|
---|
[558] | 13 | if( !isAbstractBefore && isOverrideModifier == false )
|
---|
| 14 | {
|
---|
| 15 | return OverrideResult::NotUseOverrideModifier;
|
---|
| 16 | }
|
---|
[351] | 17 | }
|
---|
[558] | 18 | else
|
---|
[351] | 19 | {
|
---|
[558] | 20 | return OverrideResult::NotVirtual;
|
---|
[351] | 21 | }
|
---|
| 22 |
|
---|
[558] | 23 | if( this->GetAccessibility() != accessibility )
|
---|
| 24 | {
|
---|
| 25 | return OverrideResult::DifferentAccesibility;
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | return OverrideResult::Successful;
|
---|
[351] | 29 | }
|
---|
| 30 |
|
---|
| 31 |
|
---|
| 32 | StaticMethod::StaticMethod( const StaticMethod &staticMethod )
|
---|
| 33 | {
|
---|
| 34 | // 静的メソッドがコピーコンストラトされることは想定しない
|
---|
[559] | 35 | throw;
|
---|
[351] | 36 | }
|
---|
| 37 |
|
---|
[206] | 38 | Methods::Methods()
|
---|
| 39 | {
|
---|
| 40 | }
|
---|
[351] | 41 |
|
---|
| 42 | // コピーコンストラクタ
|
---|
| 43 | Methods::Methods( const Methods &methods )
|
---|
| 44 | {
|
---|
| 45 | BOOST_FOREACH( CMethod *pMethod, methods )
|
---|
| 46 | {
|
---|
| 47 | this->push_back( new DynamicMethod( dynamic_cast<DynamicMethod &>(*pMethod) ) );
|
---|
| 48 | }
|
---|
| 49 | }
|
---|
| 50 |
|
---|
[206] | 51 | Methods::~Methods()
|
---|
| 52 | {
|
---|
| 53 | Methods &methods = *this;
|
---|
[351] | 54 | BOOST_FOREACH( CMethod *pMethod, methods )
|
---|
| 55 | {
|
---|
[206] | 56 | delete pMethod;
|
---|
| 57 | }
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | void Methods::Add( UserProc *pUserProc,Prototype::Accessibility accessibility, bool isConst, bool isAbstract, bool isVirtual ){
|
---|
| 61 | CMethod *pMethod = new DynamicMethod( pUserProc, accessibility, isAbstract, isVirtual, isConst );
|
---|
| 62 | this->push_back( pMethod );
|
---|
| 63 | pUserProc->SetMethod( pMethod );
|
---|
| 64 | }
|
---|
| 65 | void Methods::AddStatic(UserProc *pUserProc, Prototype::Accessibility accessibility ){
|
---|
| 66 | CMethod *pMethod = new StaticMethod( pUserProc, accessibility );
|
---|
| 67 | this->push_back( pMethod );
|
---|
| 68 | pUserProc->SetMethod( pMethod );
|
---|
| 69 | }
|
---|
| 70 |
|
---|
[558] | 71 | DynamicMethod *Methods::FindForOverride( const Types &actualTypeParametersForThisMethods, const UserProc *pUserProc )
|
---|
[346] | 72 | {
|
---|
| 73 | //メソッドのオーバーライド
|
---|
| 74 | Methods &methods = *this;
|
---|
| 75 | BOOST_FOREACH( CMethod *pMethod, methods )
|
---|
| 76 | {
|
---|
[382] | 77 | if( !pMethod->IsNotUse() && pMethod->GetUserProc().IsEqualForOverride( actualTypeParametersForThisMethods, pUserProc ) )
|
---|
[346] | 78 | {
|
---|
[558] | 79 | return dynamic_cast<DynamicMethod *>(pMethod);
|
---|
[346] | 80 | }
|
---|
| 81 | }
|
---|
[351] | 82 | return NULL;
|
---|
[346] | 83 | }
|
---|
| 84 |
|
---|
[206] | 85 | const CMethod *Methods::GetMethodPtr( const UserProc *pUserProc ) const
|
---|
| 86 | {
|
---|
| 87 | const Methods &methods = *this;
|
---|
| 88 | for( int i=(int)methods.size()-1; i>=0; i-- ){
|
---|
| 89 | if( pUserProc == &methods[i]->GetUserProc() ){
|
---|
| 90 | return methods[i];
|
---|
| 91 | }
|
---|
| 92 | }
|
---|
| 93 | return NULL;
|
---|
| 94 | }
|
---|
| 95 | bool Methods::IsExist( const char *name ) const
|
---|
| 96 | {
|
---|
| 97 | const Methods &methods = *this;
|
---|
| 98 | BOOST_FOREACH( const CMethod *pMethod, methods ){
|
---|
| 99 | if( pMethod->GetUserProc().GetName() == name ) return true;
|
---|
| 100 | }
|
---|
| 101 | return false;
|
---|
| 102 | }
|
---|
[523] | 103 | void Methods::Enum( const char *methodName, std::vector<const UserProc *> &subs ) const
|
---|
[206] | 104 | {
|
---|
| 105 | //オブジェクトのメンバ関数の場合
|
---|
| 106 | //※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う
|
---|
| 107 | const Methods &methods = *this;
|
---|
| 108 | for( int i=(int)methods.size()-1; i>=0; i-- ){
|
---|
[352] | 109 | if( methods[i]->GetUserProc().GetName() == methodName && methods[i]->IsNotUse() == false ){
|
---|
[206] | 110 | subs.push_back( &methods[i]->GetUserProc() );
|
---|
| 111 | }
|
---|
| 112 | }
|
---|
| 113 | }
|
---|
[523] | 114 | void Methods::Enum( BYTE idOperatorCalc, std::vector<const UserProc *> &subs ) const
|
---|
[206] | 115 | {
|
---|
| 116 | //オブジェクトのメンバ関数の場合
|
---|
| 117 | //※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う
|
---|
| 118 | const Methods &methods = *this;
|
---|
| 119 | for( int i=(int)methods.size()-1; i>=0; i-- ){
|
---|
| 120 | const UserProc &userProc = methods[i]->GetUserProc();
|
---|
| 121 | const char *temp = userProc.GetName().c_str();
|
---|
| 122 | if(temp[0]==1&&temp[1]==ESC_OPERATOR){
|
---|
| 123 | if((BYTE)temp[2]==idOperatorCalc){
|
---|
| 124 | subs.push_back( &userProc );
|
---|
| 125 | }
|
---|
| 126 | }
|
---|
| 127 | }
|
---|
| 128 | }
|
---|
[347] | 129 |
|
---|
| 130 | int Methods::GetVtblNum() const
|
---|
| 131 | {
|
---|
| 132 | int count = 0;
|
---|
| 133 | const Methods &methods = *this;
|
---|
| 134 | BOOST_FOREACH( const CMethod *pMethod, methods )
|
---|
| 135 | {
|
---|
| 136 | if( pMethod->IsVirtual() )
|
---|
| 137 | {
|
---|
| 138 | count++;
|
---|
| 139 | }
|
---|
| 140 | }
|
---|
| 141 | return count;
|
---|
| 142 | }
|
---|