Ignore:
Timestamp:
Nov 15, 2007, 3:18:41 AM (16 years ago)
Author:
dai_9181
Message:

COM修飾子に対応。COMインターフェイスを呼び出せるようにした

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abdev/BasicCompiler_Common/src/Class.cpp

    r369 r370  
    116116    return classType == CClass::Interface;
    117117}
     118bool CClass::IsComInterface() const
     119{
     120    return classType == CClass::ComInterface;
     121}
    118122bool CClass::IsEnum() const
    119123{
     
    241245        }
    242246
    243         if( pInheritsClass->IsInterface() ){
    244             // インターフェイスはあとで継承する
    245         }
    246         else if( pInheritsClass->IsClass() ){
     247        if( pInheritsClass->IsClass() ){
    247248            // クラスを継承する
    248249            isInheritsClass = true;
     
    253254        }
    254255        else{
    255             SmoothieException::Throw(135,NULL,nowLine);
     256            SetError(135,pInheritsClass->GetFullName().c_str(),nowLine);
    256257            return false;
    257258        }
     
    268269            return false;
    269270        }
    270     }
    271 
    272     i=0;
    273     while( true ){
    274 
    275         char temporary[VN_SIZE];
    276         for( int i2=0;; i++, i2++ ){
    277             if( inheritNames[i] == '\0' || inheritNames[i] == ',' ){
    278                 temporary[i2] = 0;
    279                 break;
    280             }
    281             temporary[i2] = inheritNames[i];
    282         }
    283 
    284         char className[VN_SIZE];
    285         Jenga::Common::Strings typeParameters;
    286         SplitGenericClassInstance( temporary, className, typeParameters );
    287 
    288         //継承元クラスを取得
    289         const CClass *pInheritsClass = compiler.GetObjectModule().meta.GetClasses().Find(className);
    290         if( !pInheritsClass ){
    291             SmoothieException::Throw(106,className,nowLine);
    292             return false;
    293         }
    294 
    295         if( pInheritsClass->IsInterface() ){
    296             // インターフェイスを継承する
    297             if( !InheritsInterface( *pInheritsClass, nowLine ) ){
    298                 return false;
    299             }
    300         }
    301         else if( pInheritsClass->IsClass() ){
    302             // クラスはさっき継承した
    303         }
    304         else{
    305             SmoothieException::Throw(135,NULL,nowLine);
    306             return false;
    307         }
    308 
    309         if( inheritNames[i] == '\0' ){
    310             break;
    311         }
    312         i++;
    313271    }
    314272
     
    388346    }
    389347
     348    if( this->IsInterface() && inheritsClass.IsComInterface() )
     349    {
     350        // COMインターフェイスを継承した場合はCOMインターフェイスにする
     351        this->SetClassType( CClass::ComInterface );
     352    }
     353
    390354    return true;
    391355}
    392 bool CClass::InheritsInterface( const CClass &inheritsInterface, int nowLine ){
    393 
    394     //ループ継承でないかをチェック
    395     if(pobj_LoopRefCheck->check(inheritsInterface)){
    396         SmoothieException::Throw(123,inheritsInterface.GetName(),nowLine);
    397         return false;
    398     }
    399 
    400     if( !inheritsInterface.IsReady() ){
    401         //継承先が読み取られていないとき
    402         pobj_LoopRefCheck->add(this->GetName().c_str());
    403         compiler.GetObjectModule().meta.GetClasses().GetClass_recur(inheritsInterface.GetName().c_str());
    404         pobj_LoopRefCheck->del(this->GetName().c_str());
    405     }
    406 
    407     //メソッドをコピー
    408     BOOST_FOREACH( const CMethod *pBaseMethod, inheritsInterface.GetDynamicMethods() ){
    409         CMethod *pMethod = new DynamicMethod( *pBaseMethod );
    410 
    411         // アクセシビリティ
    412         if(pBaseMethod->GetAccessibility() == Prototype::Private){
    413             pMethod->SetAccessibility( Prototype::None );
    414         }
    415         else{
    416             pMethod->SetAccessibility( pBaseMethod->GetAccessibility() );
    417         }
    418 
    419         //pobj_Inherits
    420         // ※継承元のClassIndexをセット(入れ子継承を考慮する)
    421         if(pBaseMethod->GetInheritsClassPtr()==0){
    422             pMethod->SetInheritsClassPtr( &inheritsInterface );
    423         }
    424         else{
    425             pMethod->SetInheritsClassPtr( pBaseMethod->GetInheritsClassPtr() );
    426         }
    427 
    428         GetDynamicMethods().push_back( pMethod );
    429     }
    430 
    431     //interfaces.push_back( Interface( &inheritsInterface, vtblNum ) );
    432 
    433     //仮想関数の数
    434     AddVtblNum( inheritsInterface.GetVtblNum() );
    435 
    436     return true;
    437 }
    438356
    439357bool CClass::Implements( const CClass &interfaceClass, int nowLine )
    440358{
    441     if( !interfaceClass.IsInterface() )
     359    if( !interfaceClass.IsInterface() && !interfaceClass.IsComInterface() )
    442360    {
    443361        // インターフェイスではないとき
     
    477395    // キャストメソッドを追加(内部コードは自動生成すること)
    478396    /////////////////////////////////////////////////////////////////
     397    if( interfaceClass.IsInterface() )
    479398    {
    480399        // Function Operator() As ITest
     
    793712    int i2;
    794713
    795     //仮想関数が存在する場合は関数リストへのポインタのサイズを追加
    796     int offset = IsExistVirtualFunctions() ? PTR_SIZE : 0;
     714    //仮想関数が存在する場合はvtbl及びvtblMasterListへのポインタのサイズを追加
     715    int offset = IsExistVirtualFunctions() ? PTR_SIZE*2 : 0;
    797716
    798717    int alignment = 1;
     
    944863    return 0;
    945864}
     865long CClass::GetComVtblOffset() const
     866{
     867    return comVtblOffset;
     868}
    946869long CClass::GetVtblMasterListOffset() const
    947870{
     
    992915
    993916        pInterface->SetVtblOffset( tempVtblOffset );
     917
     918        if( pInterface->GetClass().IsComInterface() )
     919        {
     920            if( this->comVtblOffset )
     921            {
     922                SetError();
     923            }
     924            this->comVtblOffset = tempVtblOffset;
     925        }
    994926    }
    995927
     
    14451377            pobj_c->SetConstructorMemberSubIndex( -1 );
    14461378            pobj_c->SetDestructorMemberSubIndex( -1 );
     1379
     1380            if( memcmp( basbuf+i+1, "__COM", 5 ) == 0 && IsCommandDelimitation( basbuf[i+1+5] ) )
     1381            {
     1382                // COMインターフェイス
     1383                pobj_c->SetClassType( CClass::ComInterface );
     1384
     1385                i += 6;
     1386            }
    14471387
    14481388            if(basbuf[i+1]==1&&basbuf[i+2]==ESC_INHERITS){
Note: See TracChangeset for help on using the changeset viewer.