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