/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #ifndef INCLUDED_IDL_INC_LEX_HXX #define INCLUDED_IDL_INC_LEX_HXX #include #include #include #include enum SVTOKEN_ENUM { SVTOKEN_EMPTY, SVTOKEN_COMMENT, SVTOKEN_INTEGER, SVTOKEN_STRING, SVTOKEN_BOOL, SVTOKEN_IDENTIFIER, SVTOKEN_CHAR, SVTOKEN_RTTIBASE, SVTOKEN_EOF, SVTOKEN_HASHID }; class SvToken { friend class SvTokenStream; sal_uLong nLine, nColumn; SVTOKEN_ENUM nType; OString aString; union { sal_uLong nLong; bool bBool; char cChar; SvStringHashEntry * pHash; }; public: SvToken(); SvToken( const SvToken & rObj ); SvToken( sal_uLong n ); SvToken( SVTOKEN_ENUM nTypeP, bool b ); SvToken( char c ); SvToken( SVTOKEN_ENUM nTypeP, const OString& rStr ); SvToken( SVTOKEN_ENUM nTypeP ); SvToken & operator = ( const SvToken & rObj ); OString GetTokenAsString() const; void SetLine( sal_uLong nLineP ) { nLine = nLineP; } sal_uLong GetLine() const { return nLine; } void SetColumn( sal_uLong nColumnP ) { nColumn = nColumnP; } sal_uLong GetColumn() const { return nColumn; } bool IsEmpty() const { return nType == SVTOKEN_EMPTY; } bool IsComment() const { return nType == SVTOKEN_COMMENT; } bool IsInteger() const { return nType == SVTOKEN_INTEGER; } bool IsString() const { return nType == SVTOKEN_STRING; } bool IsBool() const { return nType == SVTOKEN_BOOL; } bool IsIdentifierHash() const { return nType == SVTOKEN_HASHID; } bool IsIdentifier() const { return nType == SVTOKEN_IDENTIFIER || nType == SVTOKEN_HASHID; } bool IsChar() const { return nType == SVTOKEN_CHAR; } bool IsEof() const { return nType == SVTOKEN_EOF; } const OString& GetString() const { return IsIdentifierHash() ? pHash->GetName() : aString; } sal_uLong GetNumber() const { return nLong; } bool GetBool() const { return bBool; } char GetChar() const { return cChar; } void SetHash( SvStringHashEntry * pHashP ) { pHash = pHashP; nType = SVTOKEN_HASHID; } bool HasHash() const { return nType == SVTOKEN_HASHID; } bool Is( SvStringHashEntry * pEntry ) const { return IsIdentifierHash() && pHash == pEntry; } }; inline SvToken::SvToken() : nLine(0) , nColumn(0) , nType( SVTOKEN_EMPTY ) { } inline SvToken::SvToken( sal_uLong n ) : nType( SVTOKEN_INTEGER ), nLong( n ) {} inline SvToken::SvToken( SVTOKEN_ENUM nTypeP, bool b ) : nType( nTypeP ), bBool( b ) {} inline SvToken::SvToken( char c ) : nType( SVTOKEN_CHAR ), cChar( c ) {} inline SvToken::SvToken( SVTOKEN_ENUM nTypeP, const OString& rStr ) : nType( nTypeP ), aString( rStr ) {} inline SvToken::SvToken( SVTOKEN_ENUM nTypeP ) : nType( nTypeP ) {} class SvTokenStream { sal_uLong nLine, nColumn; int nBufPos; int c; // next character sal_uInt16 nTabSize; // length of tabulator OString aStrTrue; OString aStrFalse; sal_uLong nMaxPos; SvFileStream * pInStream; SvStream & rInStream; OUString aFileName; boost::ptr_vector aTokList; boost::ptr_vector::iterator pCurToken; OString aBufStr; void InitCtor(); int GetNextChar(); int GetFastNextChar() { return (nBufPos < aBufStr.getLength()) ? aBufStr[nBufPos++] : '\0'; } void FillTokenList(); sal_uLong GetNumber(); bool MakeToken( SvToken & ); bool IsEof() const { return rInStream.IsEof(); } void SetMax() { sal_uLong n = Tell(); if( n > nMaxPos ) nMaxPos = n; } void CalcColumn() { // if end of line spare calculation if( 0 != c ) { sal_uInt16 n = 0; nColumn = 0; while( n < nBufPos ) nColumn += aBufStr[n++] == '\t' ? nTabSize : 1; } } public: SvTokenStream( const OUString & rFileName ); SvTokenStream( SvStream & rInStream, const OUString & rFileName ); ~SvTokenStream(); const OUString & GetFileName() const { return aFileName; } SvStream & GetStream() { return rInStream; } SvToken* GetToken_PrevAll() { boost::ptr_vector::iterator pRetToken = pCurToken; // current iterator always valid if(pCurToken != aTokList.begin()) --pCurToken; return &(*pRetToken); } SvToken* GetToken_NextAll() { boost::ptr_vector::iterator pRetToken = pCurToken++; if (pCurToken == aTokList.end()) pCurToken = pRetToken; SetMax(); return &(*pRetToken); } SvToken* GetToken_Next() { // comments get removed initially return GetToken_NextAll(); } SvToken& GetToken() const { return *pCurToken; } bool Read( char cChar ) { if( pCurToken->IsChar() && cChar == pCurToken->GetChar() ) { GetToken_Next(); return true; } else return false; } void ReadDelemiter() { if( pCurToken->IsChar() && (';' == pCurToken->GetChar() || ',' == pCurToken->GetChar()) ) { GetToken_Next(); } } sal_uInt32 Tell() const { return pCurToken-aTokList.begin(); } void Seek( sal_uInt32 nPos ) { pCurToken = aTokList.begin() + nPos; SetMax(); } void SeekEnd() { pCurToken = aTokList.begin()+nMaxPos; } }; #endif // INCLUDED_IDL_INC_LEX_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2015-02-07loplugin:deletedspecialStephan Bergmann
Change-Id: I035d584af8a802d08dd4e50070b4d290210e20b6
2015-01-26followup code removal after changing virtual methods to non-virtualNoel Grandin
This cleanups up indentation and removes dead classes. This is a followup patch to commit 272b1dd55797aacf511fb4342b0054e3697243f6 "new loplugin: change virtual methods to non-virtual" Change-Id: I1c2139589cf8cb23bb9808defe22c51039d38de1
2015-01-26new loplugin: change virtual methods to non-virtualNoel Grandin
Where we can prove that the virtual method is never overriden. In the case of pure-virtual methods, we remove the method entirely. Sometimes this leads to entire methods and fields being eliminated. Change-Id: I138ef81c95f115dbd8c023a83cfc7e9d5d6d14ae
2015-01-20Some more loplugin:cstylecast: xmlhelpStephan Bergmann
Change-Id: I1aa45f669711a90cce52bafd839bd84eb711436a
2015-01-08brute-force find-and-remove of unused #define constants.Noel Grandin
Change-Id: I7223530ae37297a76654cd00cc1fedb56dbe3adb
2015-01-02boost::unordered_map->std::unordered_mapCaolán McNamara
you can get debug stl this way Change-Id: Ia70a3e7c7c452390e8bee34975d296c9318e4a19
2014-12-18xmlhelp: Use appropriate OUString functions on string constantsStephan Bergmann
Change-Id: I8642ec147cb0dca32dce7ec7f3efec93bcb99cb4
2014-12-18comphelper: Use appropriate OUString functions on string constantsStephan Bergmann
Change-Id: Id1d5c3cf2f76dbb33606cec1c0f17d4a1f282247
2014-12-15xmlhelp: Use appropriate OUString functions on string constantsStephan Bergmann
Change-Id: I28f68ff0c43366b3877244ba272acf967f141e54
2014-12-04images: Tango is the most complete theme.Jan Holesovsky
Change-Id: I211d21b09223dfacac18e879993b0f0943b94741
2014-11-18cppuhelper: clean up public headers with include-what-you-useMichael Stahl
Change-Id: I41ba46831f24b2960a1fe982b74a2b623e682e0b
2014-11-17sal: clean up public headers with include-what-you-useMichael Stahl
Sadly cannot forward declare "struct {...} TimeValue;". rtl/(u)?string.hxx still include sal/log.hxx but removing osl/diagnose.h was painful enough for now... Change-Id: Id41e17f3870c4f24c53ce7b11f2c40a3d14d1f05
2014-11-14fdo#86023 - O[U]String needs a 'clear' methodBrij Mohan Lal Srivastava
Added clear() method to OString and OUString class, Updated appropriate call-sites. Change-Id: I0ba97fa6dc7af3e31b605953089a4e8e9c3e61ac Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
2014-11-12Fix common typos. No automatic tools. Handmade…Andrea Gelmini
Change-Id: I1ab4e23b0539f8d39974787f226e57a21f96e959 Reviewed-on: https://gerrit.libreoffice.org/12164 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
2014-11-05fdo#38835 strip out OUString globalsNoel Grandin
they are largely unnecessary these days, since our OUString infrastructure gained optimised handling for static char constants. Change-Id: I07f73484f82d0582252cb4324d4107c998432c37
2014-10-20loplugin: cstylecastNoel Grandin
Change-Id: Ia3055b00c20a885dfa0584f864f0e91ccad1e9c9
2014-10-15More -Werror,-Wunused-private-fieldStephan Bergmann
...detected with a modified trunk Clang with > Index: lib/Sema/SemaDeclCXX.cpp > =================================================================== > --- lib/Sema/SemaDeclCXX.cpp (revision 219190) > +++ lib/Sema/SemaDeclCXX.cpp (working copy) > @@ -1917,9 +1917,10 @@ > const Type *T = FD.getType()->getBaseElementTypeUnsafe(); > // FIXME: Destruction of ObjC lifetime types has side-effects. > if (const CXXRecordDecl *RD = T->getAsCXXRecordDecl()) > - return !RD->isCompleteDefinition() || > - !RD->hasTrivialDefaultConstructor() || > - !RD->hasTrivialDestructor(); > + return !RD->hasAttr<WarnUnusedAttr>() && > + (!RD->isCompleteDefinition() || > + !RD->hasTrivialDefaultConstructor() || > + !RD->hasTrivialDestructor()); > return false; > } > > @@ -3517,9 +3518,11 @@ > bool addFieldInitializer(CXXCtorInitializer *Init) { > AllToInit.push_back(Init); > > +#if 0 > // Check whether this initializer makes the field "used". > if (Init->getInit()->HasSideEffects(S.Context)) > S.UnusedPrivateFields.remove(Init->getAnyMember()); > +#endif > > return false; > } to warn about members of SAL_WARN_UNUSED-annotated class types, and warn about initializations with side effects (cf. <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-October/039602.html> "-Wunused-private-field distracted by side effects"). Change-Id: I3f3181c4eb8180ca28e1fa3dffc9dbe1002c6628
2014-09-18fdo#83512 Make use of OUStringHash and OStringHashDaniel Sikeler
Change-Id: I33cafe68c798e3d54943ea1790fa4e73f85e525d Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
2014-09-11(Rudimentary) C++11 support is a hard requirement nowStephan Bergmann
Change-Id: I43ed776d52336b822aa6152f0f2a29e39303bb75
2014-08-11Resolves: fdo#82025 use strlen instead of stored length byteCaolán McNamara
Change-Id: I58cf2391d7bf2480cd12d2b1b4cf73f346f4f95f
2014-06-09loplugin: inlinesimplememberfunctionsNoel Grandin
Change-Id: I42119f656ca528286fb25d2d36c0af54b7d04a6b
2014-06-04compareToAscii -> equalsAsciiNoel Grandin
convert places using compareToAscii that should be using equalsAscii Change-Id: I97b4da7f6e867c3967b2f65b70d6886f83b4a4e5
2014-06-02fdo#68849: Add header guards to all include filesJens Carl
added header guards for directories basebmp/, chart2/, cppuhelper/, include/test/, io/test/, sax/test, shell/, writerfilter/, and xmlhelp/ Change-Id: I0e29a9b75c26d71f58aa98986b52f6d3b46015a6 Reviewed-on: https://gerrit.libreoffice.org/9615 Reviewed-by: Thomas Arnhold <thomas@arnhold.org> Tested-by: Thomas Arnhold <thomas@arnhold.org>
2014-05-29fdo#68849: Add header guards to all include filesJens Carl
Added header guards to files in directories xml*/* Change-Id: Ia5dfb9ab494bfbfae7537f2d54ff11331dc8c922 Reviewed-on: https://gerrit.libreoffice.org/9539 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2014-05-27use namespace css instead of com::sunThomas Arnhold
Change-Id: I47582b072bb939cf270a76e430a9f7908b5c1d93
2014-05-24cppcheck: redundantAssignmentThomas Arnhold
Change-Id: I6fcece7f7a77060bfa3cd3d40db3fa4f253cf261
2014-05-23remove boilerplate in UNO Exception constructor callsNoel Grandin
Now that we have default values for Exception constructor params, remove lots of boilerplate code. Change-Id: I620bd641eecfed38e6123873b3b94aaf47922e74
2014-05-13Prefer cppu::UnoType<T>::get() to ::getCppuType((T*)0) part11Julien Nabet
Change-Id: Ibe0a1006aba2b6cbd87c0bd6ca3acbf9ba7b0fbe
2014-05-10Prefer cppu::UnoType<T>::get() to ::getCppuType((T*)0) part9Julien Nabet
Change-Id: I82ed4a4868cb22566706ca0f4b1321e0d45016cf
2014-05-05simplify ternary conditions "xxx ? yyy : false"Noel Grandin
Look for code like: xxx ? yyy : false; Which can be simplified to: xxx && yyy Change-Id: Ia33c0e452aa28af3f0658a5382895aaad0246b4d
2014-05-02xmlhelp: sal_Bool->boolNoel Grandin
Change-Id: I0aa1b7023b5100fb855a8a839e44036988d8bc2e
2014-04-19fixincludeguards.sh: some smaller dirsThomas Arnhold
Change-Id: Ic25bd678dc299627299b22145efd7bebcf2b39d0
2014-04-15Remove unused codeStephan Bergmann
Change-Id: Ia624a624271b1143c96cd189cc9e4dab4c5ae302
2014-04-14typo: misformed -> malformedThomas Arnhold