summaryrefslogtreecommitdiff
path: root/idl
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2016-03-11 14:05:30 +0200
committerNoel Grandin <noel@peralex.com>2016-06-22 09:27:15 +0200
commit3e53c6ba9313dae334c0b4db78c911fa960a9fe2 (patch)
tree6680afe56b8c5f0cf7a36049e176c2f1001b374f /idl
parent5a39ad3b259a20fa1c78e34ca9146dcec7fe90b0 (diff)
move the attribute parsing code to SvParser
and simplify considerably Change-Id: I2a4af15e77904b62abc81dad78a2990e2eab05f0
Diffstat (limited to 'idl')
-rw-r--r--idl/inc/parser.hxx6
-rw-r--r--idl/inc/slot.hxx2
-rw-r--r--idl/source/objects/bastype.cxx19
-rw-r--r--idl/source/prj/parser.cxx143
4 files changed, 151 insertions, 19 deletions
diff --git a/idl/inc/parser.hxx b/idl/inc/parser.hxx
index d4d6abb440a3..cc2696b1e7c7 100644
--- a/idl/inc/parser.hxx
+++ b/idl/inc/parser.hxx
@@ -30,6 +30,7 @@ class SvMetaTypeEnum;
class SvStringHashEntry;
class SvMetaType;
class SvMetaClass;
+class SvBOOL;
class SvIdlParser
{
@@ -44,16 +45,19 @@ public:
void ReadInclude( SvMetaModule& rModule );
void ReadInterfaceOrShell( SvMetaModule& rModule, MetaTypeType aMetaTypeType );
void ReadInterfaceOrShellEntry( SvMetaClass& rClass );
- bool ReadInterfaceOrShellSlot( SvMetaSlot& rSlot );
+ bool ReadSlot( SvMetaSlot& rSlot );
void ReadInterfaceOrShellMethod( SvMetaAttribute& rAttr );
void ReadItem();
void ReadStruct();
void ReadEnum();
void ReadEnumValue( SvMetaTypeEnum& rEnum );
void ReadSlotId(SvIdentifier& rSlotId);
+ void ReadSlotAttribute( SvMetaSlot& rSlot );
SvMetaClass* ReadKnownClass();
SvMetaType* ReadKnownType();
void Read(char cChar);
+ bool ReadIfBoolAttribute( SvBOOL&, SvStringHashEntry* pName);
+ bool ReadIfIdAttribute( SvIdentifier& rIdentifier, SvStringHashEntry* pName );
bool ReadIf(char cChar);
void ReadDelimiter();
bool ReadIfDelimiter();
diff --git a/idl/inc/slot.hxx b/idl/inc/slot.hxx
index 93f127dd2a7a..bb807844447f 100644
--- a/idl/inc/slot.hxx
+++ b/idl/inc/slot.hxx
@@ -25,6 +25,7 @@
class SvMetaSlot : public SvMetaAttribute
{
+public:
tools::SvRef<SvMetaType> aSlotType;
tools::SvRef<SvMetaSlot> aMethod;
SvIdentifier aGroupId;
@@ -69,7 +70,6 @@ class SvMetaSlot : public SvMetaAttribute
bool IsVariable() const;
bool IsMethod() const;
-protected:
void SetToggle( bool bSet ) { aToggle = bSet; }
void SetAutoUpdate( bool bSet ) { aAutoUpdate = bSet; }
void SetAsynchron( bool bSet ) { aAsynchron = bSet; }
diff --git a/idl/source/objects/bastype.cxx b/idl/source/objects/bastype.cxx
index 08c59f9a808c..adff4d5e726d 100644
--- a/idl/source/objects/bastype.cxx
+++ b/idl/source/objects/bastype.cxx
@@ -35,24 +35,17 @@ bool SvBOOL::ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm )
if( rTok.Is( pName ) )
{
- bool bOk = true;
- bool bBracket = rInStm.ReadIf( '(' );
- if( bBracket || rInStm.ReadIf( '=' ) )
+ if( rInStm.ReadIf( '=' ) )
{
rTok = rInStm.GetToken();
- if( rTok.IsBool() )
- {
- *this = rTok.GetBool();
-
- rInStm.GetToken_Next();
- }
- if( bOk && bBracket )
- bOk = rInStm.ReadIf( ')' );
+ if( !rTok.IsBool() )
+ throw SvParseException(rInStm, "xxx");
+ *this = rTok.GetBool();
+ rInStm.GetToken_Next();
}
else
*this = true; //default action set to TRUE
- if( bOk )
- return true;
+ return true;
}
rInStm.Seek( nTokPos );
return false;
diff --git a/idl/source/prj/parser.cxx b/idl/source/prj/parser.cxx
index 1438becbfe1a..849bf4c8c1ee 100644
--- a/idl/source/prj/parser.cxx
+++ b/idl/source/prj/parser.cxx
@@ -114,7 +114,7 @@ void SvIdlParser::ReadModuleElement( SvMetaModule& rModule )
{
tools::SvRef<SvMetaSlot> xSlot( new SvMetaSlot() );
- if( xSlot->ReadSvIdl( rBase, rInStm ) )
+ if (ReadSlot(*xSlot))
{
if( xSlot->Test( rInStm ) )
{
@@ -311,7 +311,7 @@ void SvIdlParser::ReadInterfaceOrShellEntry(SvMetaClass& rClass)
if( !pType || pType->IsItem() )
{
xAttr = new SvMetaSlot( pType );
- bOk = ReadInterfaceOrShellSlot(static_cast<SvMetaSlot&>(*xAttr));
+ bOk = ReadSlot(static_cast<SvMetaSlot&>(*xAttr));
}
else
{
@@ -332,7 +332,7 @@ void SvIdlParser::ReadInterfaceOrShellEntry(SvMetaClass& rClass)
}
}
-bool SvIdlParser::ReadInterfaceOrShellSlot(SvMetaSlot& rSlot)
+bool SvIdlParser::ReadSlot(SvMetaSlot& rSlot)
{
sal_uInt32 nTokPos = rInStm.Tell();
bool bOk = true;
@@ -351,7 +351,7 @@ bool SvIdlParser::ReadInterfaceOrShellSlot(SvMetaSlot& rSlot)
while( nBeginPos != rInStm.Tell() )
{
nBeginPos = rInStm.Tell();
- rSlot.ReadAttributesSvIdl( rBase, rInStm );
+ ReadSlotAttribute(rSlot);
ReadIfDelimiter();
}
Read( ']' );
@@ -379,6 +379,98 @@ bool SvIdlParser::ReadInterfaceOrShellSlot(SvMetaSlot& rSlot)
return bOk;
}
+void SvIdlParser::ReadSlotAttribute( SvMetaSlot& rSlot )
+{
+ bool bOk = false;
+ bOk |= ReadIfBoolAttribute(rSlot.aPseudoSlots, SvHash_PseudoSlots() );
+ bOk |= ReadIfIdAttribute(rSlot.aGroupId, SvHash_GroupId() );
+ bOk |= ReadIfIdAttribute(rSlot.aExecMethod, SvHash_ExecMethod() );
+ bOk |= ReadIfIdAttribute(rSlot.aStateMethod, SvHash_StateMethod() );
+ bOk |= ReadStringSvIdl( SvHash_DisableFlags(), rInStm, rSlot.aDisableFlags );
+ bOk |= ReadIfBoolAttribute(rSlot.aReadOnlyDoc, SvHash_ReadOnlyDoc() );
+ bOk |= ReadIfBoolAttribute(rSlot.aExport, SvHash_Export() );
+
+ bOk |= ReadIfBoolAttribute(rSlot.aToggle, SvHash_Toggle() );
+ bOk |= ReadIfBoolAttribute(rSlot.aAutoUpdate, SvHash_AutoUpdate() );
+ bOk |= ReadIfBoolAttribute(rSlot.aAsynchron, SvHash_Asynchron() );
+ bOk |= ReadIfBoolAttribute(rSlot.aRecordAbsolute, SvHash_RecordAbsolute() );
+
+ if( ReadIfBoolAttribute(rSlot.aRecordPerItem, SvHash_RecordPerItem()) )
+ {
+ if (rSlot.aRecordPerSet.IsSet() || rSlot.aNoRecord.IsSet())
+ throw SvParseException(rInStm, "conflicting attributes");
+ rSlot.SetRecordPerItem( rSlot.aRecordPerItem );
+ bOk = true;
+ }
+ if( ReadIfBoolAttribute(rSlot.aRecordPerSet, SvHash_RecordPerSet() ) )
+ {
+ if (rSlot.aRecordPerItem.IsSet() || rSlot.aNoRecord.IsSet())
+ throw SvParseException(rInStm, "conflicting attributes");
+ rSlot.SetRecordPerSet( rSlot.aRecordPerSet );
+ bOk = true;
+ }
+ if( ReadIfBoolAttribute(rSlot.aNoRecord, SvHash_NoRecord() ) )
+ {
+ if (rSlot.aRecordPerItem.IsSet() || rSlot.aRecordPerSet.IsSet())
+ throw SvParseException(rInStm, "conflicting attributes");
+ rSlot.SetNoRecord( rSlot.aNoRecord );
+ bOk = true;
+ }
+
+ bOk |= ReadIfIdAttribute(rSlot.aPseudoPrefix, SvHash_PseudoPrefix() );
+ bOk |= ReadIfBoolAttribute(rSlot.aMenuConfig, SvHash_MenuConfig() );
+ bOk |= ReadIfBoolAttribute(rSlot.aToolBoxConfig, SvHash_ToolBoxConfig() );
+ bOk |= ReadIfBoolAttribute(rSlot.aAccelConfig, SvHash_AccelConfig() );
+
+ bOk |= ReadIfBoolAttribute(rSlot.aFastCall, SvHash_FastCall() );
+ bOk |= ReadIfBoolAttribute(rSlot.aContainer, SvHash_Container() );
+ bOk |= ReadIfBoolAttribute(rSlot.aImageRotation, SvHash_ImageRotation() );
+ bOk |= ReadIfBoolAttribute(rSlot.aImageReflection, SvHash_ImageReflection() );
+
+ if( bOk )
+ return;
+
+ if( !rSlot.aSlotType.Is() )
+ {
+ sal_uInt32 nTokPos = rInStm.Tell();
+ SvToken& rTok = rInStm.GetToken_Next();
+ if( rTok.Is( SvHash_SlotType() ) )
+ {
+ if( rInStm.ReadIf( '=' ) )
+ {
+ rSlot.aSlotType = rBase.ReadKnownType( rInStm );
+ if( !rSlot.aSlotType.Is() )
+ throw SvParseException( rInStm, "SlotType with unknown item type" );
+ if( !rSlot.aSlotType->IsItem() )
+ throw SvParseException( rInStm, "the SlotType is not a item" );
+ return;
+ }
+ }
+ rInStm.Seek( nTokPos );
+
+ }
+ if( !rSlot.aMethod.Is() )
+ {
+ SvToken& rTok = rInStm.GetToken();
+ if( rTok.IsIdentifier() )
+ {
+ rSlot.aMethod = new SvMetaSlot();
+ sal_uInt32 nTokPos = rInStm.Tell();
+ if( rSlot.aMethod->ReadSvIdl( rBase, rInStm ) )
+ {
+ if( rSlot.aMethod->IsMethod() )
+ {
+ rSlot.aMethod->SetSlotId( rSlot.GetSlotId() );
+ if( rSlot.aMethod->Test( rInStm ) )
+ return;
+ }
+ rInStm.Seek( nTokPos );
+ }
+ rSlot.aMethod.Clear();
+ }
+ }
+}
+
void SvIdlParser::ReadInterfaceOrShellMethod( SvMetaAttribute& rAttr )
{
rAttr.SetName( ReadIdentifier() );
@@ -435,6 +527,49 @@ SvMetaType * SvIdlParser::ReadKnownType()
throw SvParseException( rInStm, "wrong typedef: ");
}
+bool SvIdlParser::ReadIfBoolAttribute( SvBOOL& rBool, SvStringHashEntry * pName )
+{
+ sal_uInt32 nTokPos = rInStm.Tell();
+ SvToken& rTok = rInStm.GetToken_Next();
+
+ if( rTok.Is( pName ) )
+ {
+ if( rInStm.ReadIf( '=' ) )
+ {
+ rTok = rInStm.GetToken();
+ if( !rTok.IsBool() )
+ throw SvParseException(rInStm, "xxx");
+ rBool = rTok.GetBool();
+ rInStm.GetToken_Next();
+ }
+ else
+ rBool = true; //default action set to TRUE
+ return true;
+ }
+ rInStm.Seek( nTokPos );
+ return false;
+}
+
+bool SvIdlParser::ReadIfIdAttribute( SvIdentifier& rIdentifier, SvStringHashEntry * pName )
+{
+ sal_uInt32 nTokPos = rInStm.Tell();
+ SvToken& rTok = rInStm.GetToken_Next();
+
+ if( rTok.Is( pName ) )
+ {
+ if( rInStm.ReadIf( '=' ) )
+ {
+ rTok = rInStm.GetToken();
+ if( !rTok.IsIdentifier() )
+ throw SvParseException(rInStm, "expected identifier");
+ rIdentifier.setString(rTok.GetString());
+ rInStm.GetToken_Next();
+ }
+ return true;
+ }
+ rInStm.Seek( nTokPos );
+ return false;
+}
void SvIdlParser::ReadDelimiter()
{