diff options
author | Noel Grandin <noel@peralex.com> | 2016-02-15 14:22:36 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2016-02-15 15:47:30 +0200 |
commit | f7520bbc80b571a15adca5279cc7fc5e8965e53c (patch) | |
tree | ab18692f88820aa9d69b2543c9f9656dcc32c236 /idl/source | |
parent | ac432839329866659e339b582d31a1980c035c2e (diff) |
move interface/shell parsing to SvIdlParser
Change-Id: I95cce21c6c9beb5637dd4f4a769f455eaacbec2b
Diffstat (limited to 'idl/source')
-rw-r--r-- | idl/source/objects/object.cxx | 28 | ||||
-rw-r--r-- | idl/source/prj/parser.cxx | 79 |
2 files changed, 53 insertions, 54 deletions
diff --git a/idl/source/objects/object.cxx b/idl/source/objects/object.cxx index c5c3589acdea..711ca195f915 100644 --- a/idl/source/objects/object.cxx +++ b/idl/source/objects/object.cxx @@ -99,34 +99,6 @@ void SvMetaClass::ReadContextSvIdl( SvIdlDataBase & rBase, rInStm.Seek( nTokPos ); } -bool SvMetaClass::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm ) -{ - sal_uLong nTokPos = rInStm.Tell(); - if( SvMetaType::ReadHeaderSvIdl( rBase, rInStm ) && - (GetMetaTypeType() == MetaTypeType::Interface || GetMetaTypeType() == MetaTypeType::Shell) ) - { - bool bOk = true; - if( rInStm.ReadIf( ':' ) ) - { - aSuperClass = rBase.ReadKnownClass( rInStm ); - bOk = aSuperClass.Is(); - if( !bOk ) - { - throw SvParseException( rInStm, "unknown super class" ); - } - } - if( bOk ) - { - rBase.Write(OString('.')); - bOk = SvMetaObject::ReadSvIdl( rBase, rInStm ); - } - if( bOk ) - return bOk; - } - rInStm.Seek( nTokPos ); - return false; -} - bool SvMetaClass::TestAttribute( SvIdlDataBase & rBase, SvTokenStream & rInStm, SvMetaAttribute & rAttr ) const { diff --git a/idl/source/prj/parser.cxx b/idl/source/prj/parser.cxx index f2bc458e4b24..cdd80dfecbff 100644 --- a/idl/source/prj/parser.cxx +++ b/idl/source/prj/parser.cxx @@ -118,16 +118,13 @@ bool SvIdlParser::ReadModuleBody(SvMetaModule& rModule) void SvIdlParser::ReadModuleElement( SvMetaModule& rModule ) { - if( rInStm.GetToken().Is( SvHash_interface() ) - || rInStm.GetToken().Is( SvHash_shell() ) ) + if( rInStm.GetToken().Is( SvHash_interface() ) ) { - tools::SvRef<SvMetaClass> aClass( new SvMetaClass() ); - if( aClass->ReadSvIdl( rBase, rInStm ) ) - { - rModule.aClassList.push_back( aClass ); - // announce globally - rBase.GetClassList().push_back( aClass ); - } + ReadInterfaceOrShell(rModule, MetaTypeType::Interface); + } + else if( rInStm.GetToken().Is( SvHash_shell() ) ) + { + ReadInterfaceOrShell(rModule, MetaTypeType::Shell); } else if( rInStm.GetToken().Is( SvHash_enum() ) ) { @@ -254,20 +251,6 @@ void SvIdlParser::ReadItem() rBase.GetTypeList().push_back( xItem ); } -SvMetaType * SvIdlParser::ReadKnownType() -{ - OString aName = ReadIdentifier(); - for( const auto& aType : rBase.GetTypeList() ) - { - if( aType->GetName().equals(aName) ) - { - return aType; - } - } - throw SvParseException( rInStm, "wrong typedef: "); -} - - void SvIdlParser::ReadEnum() { rInStm.GetToken_Next(); @@ -316,14 +299,52 @@ void SvIdlParser::ReadEnumValue( SvMetaTypeEnum& rEnum ) rEnum.aEnumValueList.push_back( aEnumVal ); } +void SvIdlParser::ReadInterfaceOrShell( SvMetaModule& rModule, MetaTypeType aMetaTypeType ) +{ + tools::SvRef<SvMetaClass> aClass( new SvMetaClass() ); + rInStm.GetToken_Next(); -void SvIdlParser::ReadChar(char cChar) + aClass->SetType( aMetaTypeType ); + + aClass->SetName( ReadIdentifier() ); + + if( rInStm.ReadIf( ':' ) ) + { + aClass->aSuperClass = rBase.ReadKnownClass( rInStm ); + if( !aClass->aSuperClass.Is() ) + throw SvParseException( rInStm, "unknown super class" ); + } + if( rInStm.ReadIf( '{' ) ) + { + sal_uInt32 nBeginPos = 0; // can not happen with Tell + while( nBeginPos != rInStm.Tell() ) + { + nBeginPos = rInStm.Tell(); + aClass->ReadContextSvIdl( rBase, rInStm ); + rInStm.ReadIfDelimiter(); + } + ReadChar( '}' ); + } + rModule.aClassList.push_back( aClass ); + // announce globally + rBase.GetClassList().push_back( aClass ); +} + +SvMetaType * SvIdlParser::ReadKnownType() { - if( !rInStm.ReadIf( cChar ) ) - throw SvParseException(rInStm, "expected char '" + OString(cChar) + "'"); + OString aName = ReadIdentifier(); + for( const auto& aType : rBase.GetTypeList() ) + { + if( aType->GetName().equals(aName) ) + { + return aType; + } + } + throw SvParseException( rInStm, "wrong typedef: "); } + void SvIdlParser::ReadDelimiter() { if( !rInStm.ReadIfDelimiter() ) @@ -346,6 +367,12 @@ OString SvIdlParser::ReadString() return rTok.GetString(); } +void SvIdlParser::ReadChar(char cChar) +{ + if( !rInStm.ReadIf( cChar ) ) + throw SvParseException(rInStm, "expected char '" + OString(cChar) + "'"); +} + void SvIdlParser::ReadToken(SvStringHashEntry* entry) { if( !rInStm.GetToken().Is(entry) ) |