[206] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
| 3 | #include <Class.h>
|
---|
| 4 |
|
---|
| 5 |
|
---|
| 6 | Methods::Methods()
|
---|
| 7 | {
|
---|
| 8 | }
|
---|
| 9 | Methods::~Methods()
|
---|
| 10 | {
|
---|
| 11 | Methods &methods = *this;
|
---|
| 12 | BOOST_FOREACH( CMethod *pMethod, methods ){
|
---|
| 13 | delete pMethod;
|
---|
| 14 | }
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | void Methods::Add( UserProc *pUserProc,Prototype::Accessibility accessibility, bool isConst, bool isAbstract, bool isVirtual ){
|
---|
| 18 | CMethod *pMethod = new DynamicMethod( pUserProc, accessibility, isAbstract, isVirtual, isConst );
|
---|
| 19 | this->push_back( pMethod );
|
---|
| 20 | pUserProc->SetMethod( pMethod );
|
---|
| 21 | }
|
---|
| 22 | void Methods::AddStatic(UserProc *pUserProc, Prototype::Accessibility accessibility ){
|
---|
| 23 | CMethod *pMethod = new StaticMethod( pUserProc, accessibility );
|
---|
| 24 | this->push_back( pMethod );
|
---|
| 25 | pUserProc->SetMethod( pMethod );
|
---|
| 26 | }
|
---|
| 27 |
|
---|
[346] | 28 | bool Methods::Override( UserProc *pUserProc, Prototype::Accessibility accessibility )
|
---|
| 29 | {
|
---|
| 30 | //メソッドのオーバーライド
|
---|
| 31 | Methods &methods = *this;
|
---|
| 32 | BOOST_FOREACH( CMethod *pMethod, methods )
|
---|
| 33 | {
|
---|
| 34 | if( pMethod->GetUserProc().GetName() == pUserProc->GetName() )
|
---|
| 35 | {
|
---|
| 36 | if( pMethod->GetUserProc().Params().Equals( pUserProc->Params() )
|
---|
| 37 | && pMethod->GetUserProc().ReturnType().Equals( pUserProc->ReturnType() ) )
|
---|
| 38 | {
|
---|
| 39 | //メンバ関数を上書き
|
---|
| 40 | pMethod->SetUserProcPtr( pUserProc );
|
---|
| 41 | pMethod->Override();
|
---|
| 42 |
|
---|
| 43 | if( !pMethod->IsVirtual() )
|
---|
| 44 | {
|
---|
| 45 | // オーバーライドミス
|
---|
| 46 | SetError(136,NULL,cp);
|
---|
| 47 | }
|
---|
| 48 | if(pMethod->GetAccessibility() != accessibility )
|
---|
| 49 | {
|
---|
| 50 | SetError(128,NULL,cp);
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | pUserProc->SetMethod( pMethod );
|
---|
| 54 | return true;
|
---|
| 55 | }
|
---|
| 56 | }
|
---|
| 57 | }
|
---|
| 58 | return false;
|
---|
| 59 | }
|
---|
| 60 |
|
---|
[206] | 61 | const CMethod *Methods::GetMethodPtr( const UserProc *pUserProc ) const
|
---|
| 62 | {
|
---|
| 63 | const Methods &methods = *this;
|
---|
| 64 | for( int i=(int)methods.size()-1; i>=0; i-- ){
|
---|
| 65 | if( pUserProc == &methods[i]->GetUserProc() ){
|
---|
| 66 | return methods[i];
|
---|
| 67 | }
|
---|
| 68 | }
|
---|
| 69 | return NULL;
|
---|
| 70 | }
|
---|
| 71 | bool Methods::IsExist( const char *name ) const
|
---|
| 72 | {
|
---|
| 73 | const Methods &methods = *this;
|
---|
| 74 | BOOST_FOREACH( const CMethod *pMethod, methods ){
|
---|
| 75 | if( pMethod->GetUserProc().GetName() == name ) return true;
|
---|
| 76 | }
|
---|
| 77 | return false;
|
---|
| 78 | }
|
---|
| 79 | void Methods::Enum( const char *methodName, vector<const UserProc *> &subs ) const
|
---|
| 80 | {
|
---|
| 81 | //オブジェクトのメンバ関数の場合
|
---|
| 82 | //※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う
|
---|
| 83 | const Methods &methods = *this;
|
---|
| 84 | for( int i=(int)methods.size()-1; i>=0; i-- ){
|
---|
| 85 | if( methods[i]->GetUserProc().GetName() == methodName ){
|
---|
| 86 | subs.push_back( &methods[i]->GetUserProc() );
|
---|
| 87 | }
|
---|
| 88 | }
|
---|
| 89 | }
|
---|
| 90 | void Methods::Enum( BYTE idOperatorCalc, vector<const UserProc *> &subs ) const
|
---|
| 91 | {
|
---|
| 92 | //オブジェクトのメンバ関数の場合
|
---|
| 93 | //※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う
|
---|
| 94 | const Methods &methods = *this;
|
---|
| 95 | for( int i=(int)methods.size()-1; i>=0; i-- ){
|
---|
| 96 | const UserProc &userProc = methods[i]->GetUserProc();
|
---|
| 97 | const char *temp = userProc.GetName().c_str();
|
---|
| 98 | if(temp[0]==1&&temp[1]==ESC_OPERATOR){
|
---|
| 99 | if((BYTE)temp[2]==idOperatorCalc){
|
---|
| 100 | subs.push_back( &userProc );
|
---|
| 101 | }
|
---|
| 102 | }
|
---|
| 103 | }
|
---|
| 104 | }
|
---|