Kaydet (Commit) dc1df1b8 authored tarafından Noel Grandin's avatar Noel Grandin

simplify parser

Change-Id: If6b9ed2a0cb373c8bec5d3ff20488f5ee00231ff
üst 380a646b
...@@ -182,10 +182,8 @@ void SvIdlParser::ReadStruct() ...@@ -182,10 +182,8 @@ void SvIdlParser::ReadStruct()
xStruct->SetType( MetaTypeType::Struct ); xStruct->SetType( MetaTypeType::Struct );
xStruct->SetName( ReadIdentifier() ); xStruct->SetName( ReadIdentifier() );
Read( '{' ); Read( '{' );
sal_uInt32 nBeginPos = 0; // can not happen with Tell while( true )
while( nBeginPos != rInStm.Tell() )
{ {
nBeginPos = rInStm.Tell();
tools::SvRef<SvMetaAttribute> xAttr( new SvMetaAttribute() ); tools::SvRef<SvMetaAttribute> xAttr( new SvMetaAttribute() );
xAttr->aType = ReadKnownType(); xAttr->aType = ReadKnownType();
xAttr->SetName(ReadIdentifier()); xAttr->SetName(ReadIdentifier());
...@@ -293,25 +291,20 @@ void SvIdlParser::ReadInterfaceOrShell( SvMetaModule& rModule, MetaTypeType aMet ...@@ -293,25 +291,20 @@ void SvIdlParser::ReadInterfaceOrShell( SvMetaModule& rModule, MetaTypeType aMet
void SvIdlParser::ReadInterfaceOrShellEntry(SvMetaClass& rClass) void SvIdlParser::ReadInterfaceOrShellEntry(SvMetaClass& rClass)
{ {
sal_uInt32 nTokPos = rInStm.Tell(); if( ReadIf( SvHash_import() ) )
SvToken& rTok = rInStm.GetToken_Next();
if( rTok.Is( SvHash_import() ) )
{ {
SvMetaClass * pClass = ReadKnownClass(); SvMetaClass * pClass = ReadKnownClass();
SvClassElement aEle(pClass); SvClassElement aEle(pClass);
rTok = rInStm.GetToken(); SvToken& rTok = rInStm.GetToken();
if( rTok.IsString() ) if( rTok.IsString() )
{ {
aEle.SetPrefix( rTok.GetString() ); aEle.SetPrefix( rTok.GetString() );
rInStm.GetToken_Next(); rInStm.GetToken_Next();
} }
rClass.aClassElementList.push_back( aEle ); rClass.aClassElementList.push_back( aEle );
return;
} }
else else
{ {
rInStm.Seek( nTokPos );
SvMetaType * pType = rBase.ReadKnownType( rInStm ); SvMetaType * pType = rBase.ReadKnownType( rInStm );
tools::SvRef<SvMetaAttribute> xAttr; tools::SvRef<SvMetaAttribute> xAttr;
bool bOk = false; bool bOk = false;
...@@ -335,10 +328,8 @@ void SvIdlParser::ReadInterfaceOrShellEntry(SvMetaClass& rClass) ...@@ -335,10 +328,8 @@ void SvIdlParser::ReadInterfaceOrShellEntry(SvMetaClass& rClass)
if( !xAttr->GetSlotId().IsSet() ) if( !xAttr->GetSlotId().IsSet() )
xAttr->SetSlotId( SvIdentifier(rBase.GetUniqueId()) ); xAttr->SetSlotId( SvIdentifier(rBase.GetUniqueId()) );
rClass.aAttrList.push_back( xAttr ); rClass.aAttrList.push_back( xAttr );
return;
} }
} }
rInStm.Seek( nTokPos );
} }
bool SvIdlParser::ReadInterfaceOrShellSlot(SvMetaSlot& rSlot) bool SvIdlParser::ReadInterfaceOrShellSlot(SvMetaSlot& rSlot)
...@@ -402,20 +393,22 @@ void SvIdlParser::ReadInterfaceOrShellMethodOrAttribute( SvMetaAttribute& rAttr ...@@ -402,20 +393,22 @@ void SvIdlParser::ReadInterfaceOrShellMethodOrAttribute( SvMetaAttribute& rAttr
tools::SvRef<SvMetaType> xT(new SvMetaType() ); tools::SvRef<SvMetaType> xT(new SvMetaType() );
xT->SetRef(rAttr.GetType() ); xT->SetRef(rAttr.GetType() );
rAttr.aType = xT; rAttr.aType = xT;
sal_uInt32 nBeginPos = 0; // can not happen with Tell rAttr.aType->SetType( MetaTypeType::Method );
while( nBeginPos != rInStm.Tell() ) if (!ReadIf(')'))
{ {
nBeginPos = rInStm.Tell(); while (true)
tools::SvRef<SvMetaAttribute> xAttr( new SvMetaAttribute() );
if( xAttr->ReadSvIdl( rBase, rInStm ) )
{ {
if( xAttr->Test( rInStm ) ) tools::SvRef<SvMetaAttribute> xAttr( new SvMetaAttribute() );
rAttr.aType->GetAttrList().push_back( xAttr ); if( !xAttr->ReadSvIdl( rBase, rInStm ) )
throw SvParseException(rInStm, "ReadSvIdl in method argument parsing failed");
if( !xAttr->Test( rInStm ) )
throw SvParseException(rInStm, "test in method argument parsing failed");
rAttr.aType->GetAttrList().push_back( xAttr );
if (!ReadIfDelimiter())
break;
} }
ReadIfDelimiter(); Read(')');
} }
Read( ')' );
rAttr.aType->SetType( MetaTypeType::Method );
} }
SvMetaClass * SvIdlParser::ReadKnownClass() SvMetaClass * SvIdlParser::ReadKnownClass()
...@@ -433,9 +426,7 @@ SvMetaType * SvIdlParser::ReadKnownType() ...@@ -433,9 +426,7 @@ SvMetaType * SvIdlParser::ReadKnownType()
for( const auto& aType : rBase.GetTypeList() ) for( const auto& aType : rBase.GetTypeList() )
{ {
if( aType->GetName() == aName ) if( aType->GetName() == aName )
{
return aType; return aType;
}
} }
throw SvParseException( rInStm, "wrong typedef: "); throw SvParseException( rInStm, "wrong typedef: ");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment