summaryrefslogtreecommitdiff
path: root/idl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-12-20 13:30:21 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-12-21 06:09:01 +0100
commit24158311c115c2db6dd05a751f75a5c084e2c0d1 (patch)
treed6e69417f050d4ed5d3bd0fd0c51c53090106ba6 /idl
parent490287a1b22411f4ac32127c93228e06dad4ff22 (diff)
TypedWhichId in svx part 1
and teach the idl compiler how to ignore the TypeWhichId<T1> part of the define Change-Id: I030f54080924d51e9f0ac09b19e14106648024db Reviewed-on: https://gerrit.libreoffice.org/46849 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'idl')
-rw-r--r--idl/source/prj/database.cxx161
1 files changed, 88 insertions, 73 deletions
diff --git a/idl/source/prj/database.cxx b/idl/source/prj/database.cxx
index 46c7b576f5bd..62340e70cb0b 100644
--- a/idl/source/prj/database.cxx
+++ b/idl/source/prj/database.cxx
@@ -146,105 +146,120 @@ bool SvIdlDataBase::ReadIdFile( const OString& rOFileName )
aIdFileList.push_back( rFileName );
AddDepFile( aFullName );
SvTokenStream aTokStm( aFullName );
- if( aTokStm.GetStream().GetError() == ERRCODE_NONE )
- {
- SvToken& rTok = aTokStm.GetToken_Next();
+ if( aTokStm.GetStream().GetError() != ERRCODE_NONE )
+ return false;
+
+ SvToken& rTok = aTokStm.GetToken_Next();
- while( !rTok.IsEof() )
+ while( !rTok.IsEof() )
+ {
+ if( rTok.IsChar() && rTok.GetChar() == '#' )
{
- if( rTok.IsChar() && rTok.GetChar() == '#' )
+ rTok = aTokStm.GetToken_Next();
+ if( rTok.Is( SvHash_define() ) )
{
rTok = aTokStm.GetToken_Next();
- if( rTok.Is( SvHash_define() ) )
+ OString aDefName;
+ if( !rTok.IsIdentifier() )
+ throw SvParseException( "unexpected token after define", rTok );
+ aDefName = rTok.GetString();
+
+ sal_uLong nVal = 0;
+ bool bOk = true;
+ while( bOk )
{
rTok = aTokStm.GetToken_Next();
- OString aDefName;
- if( !rTok.IsIdentifier() )
- throw SvParseException( "unexpected token after define", rTok );
- aDefName = rTok.GetString();
-
- sal_uLong nVal = 0;
- bool bOk = true;
- while( bOk )
+ if (rTok.GetTokenAsString().startsWith("TypedWhichId"))
{
rTok = aTokStm.GetToken_Next();
- if( rTok.IsIdentifier() )
- {
- sal_uLong n;
- if( FindId( rTok.GetString(), &n ) )
- nVal += n;
- else
- bOk = false;
- }
- else if( rTok.IsChar() )
- {
- if( rTok.GetChar() == '-'
- || rTok.GetChar() == '/'
- || rTok.GetChar() == '*'
- || rTok.GetChar() == '&'
- || rTok.GetChar() == '|'
- || rTok.GetChar() == '^'
- || rTok.GetChar() == '~' )
- {
- throw SvParseException( "unknown operator '" + OString(rTok.GetChar()) + "'in define", rTok );
- }
- if( rTok.GetChar() != '+'
- && rTok.GetChar() != '('
- && rTok.GetChar() != ')' )
- // only + is allowed, parentheses are immaterial
- // because + is commutative
- break;
- }
- else if( rTok.IsInteger() )
+ if( !rTok.IsChar() || rTok.GetChar() != '<')
+ throw SvParseException( "expected '<'", rTok );
+ rTok = aTokStm.GetToken_Next();
+ if( !rTok.IsIdentifier() )
+ throw SvParseException( "expected identifier", rTok );
+ rTok = aTokStm.GetToken_Next();
+ if( !rTok.IsChar() || rTok.GetChar() != '>')
+ throw SvParseException( "expected '<'", rTok );
+ rTok = aTokStm.GetToken_Next();
+ }
+ else if( rTok.IsIdentifier() )
+ {
+ sal_uLong n;
+ if( FindId( rTok.GetString(), &n ) )
+ nVal += n;
+ else
+ bOk = false;
+ }
+ else if( rTok.IsChar() )
+ {
+ if( rTok.GetChar() == '-'
+ || rTok.GetChar() == '/'
+ || rTok.GetChar() == '*'
+ || rTok.GetChar() == '&'
+ || rTok.GetChar() == '|'
+ || rTok.GetChar() == '^'
+ || rTok.GetChar() == '~' )
{
- nVal += rTok.GetNumber();
+ throw SvParseException( "unknown operator '" + OString(rTok.GetChar()) + "'in define", rTok );
}
- else
+ if( rTok.GetChar() != '+'
+ && rTok.GetChar() != '('
+ && rTok.GetChar() != ')' )
+ // only + is allowed, parentheses are immaterial
+ // because + is commutative
break;
}
- if( bOk )
+ else if( rTok.IsInteger() )
{
- InsertId( aDefName, nVal );
+ nVal += rTok.GetNumber();
}
+ else
+ break;
+ }
+ if( bOk )
+ {
+ InsertId( aDefName, nVal );
}
- else if( rTok.Is( SvHash_include() ) )
+ }
+ else if( rTok.Is( SvHash_include() ) )
+ {
+ rTok = aTokStm.GetToken_Next();
+ OStringBuffer aNameBuf;
+ if( rTok.IsString() )
+ aNameBuf.append(rTok.GetString());
+ else if( rTok.IsChar() && rTok.GetChar() == '<' )
{
rTok = aTokStm.GetToken_Next();
- OStringBuffer aNameBuf;
- if( rTok.IsString() )
- aNameBuf.append(rTok.GetString());
- else if( rTok.IsChar() && rTok.GetChar() == '<' )
+ while( !rTok.IsEof()
+ && !(rTok.IsChar() && rTok.GetChar() == '>') )
{
+ aNameBuf.append(rTok.GetTokenAsString());
rTok = aTokStm.GetToken_Next();
- while( !rTok.IsEof()
- && !(rTok.IsChar() && rTok.GetChar() == '>') )
- {
- aNameBuf.append(rTok.GetTokenAsString());
- rTok = aTokStm.GetToken_Next();
- }
- if( rTok.IsEof() )
- {
- throw SvParseException("unexpected eof in #include", rTok);
- }
- }
- OString aName(aNameBuf.makeStringAndClear());
- if (aName == "sfx2/groupid.hxx")
- {
- // contains C++ code which we cannot parse
- // we special-case this by defining a macro internally in ....
}
- else if (!ReadIdFile(aName))
+ if( rTok.IsEof() )
{
- throw SvParseException("cannot read file: " + aName, rTok);
+ throw SvParseException("unexpected eof in #include", rTok);
}
}
+ OString aName(aNameBuf.makeStringAndClear());
+ if (aName == "sfx2/groupid.hxx")
+ {
+ // contains C++ code which we cannot parse
+ // we special-case this by defining a macro internally in ....
+ }
+ else if (aName == "svl/typedwhich.hxx")
+ {
+ // contains C++ code which we cannot parse
+ }
+ else if (!ReadIdFile(aName))
+ {
+ throw SvParseException("cannot read file: " + aName, rTok);
+ }
}
- else
- rTok = aTokStm.GetToken_Next();
}
+ else
+ rTok = aTokStm.GetToken_Next();
}
- else
- return false;
return true;
}