diff options
Diffstat (limited to 'idl/inc')
-rw-r--r-- | idl/inc/basobj.hxx | 128 | ||||
-rw-r--r-- | idl/inc/bastype.hxx | 76 | ||||
-rw-r--r-- | idl/inc/command.hxx | 47 | ||||
-rw-r--r-- | idl/inc/database.hxx | 141 | ||||
-rw-r--r-- | idl/inc/globals.hxx | 128 | ||||
-rw-r--r-- | idl/inc/hash.hxx | 61 | ||||
-rw-r--r-- | idl/inc/lex.hxx | 217 | ||||
-rw-r--r-- | idl/inc/module.hxx | 37 | ||||
-rw-r--r-- | idl/inc/object.hxx | 90 | ||||
-rw-r--r-- | idl/inc/parser.hxx | 72 | ||||
-rw-r--r-- | idl/inc/slot.hxx | 134 | ||||
-rw-r--r-- | idl/inc/types.hxx | 118 |
12 files changed, 1249 insertions, 0 deletions
diff --git a/idl/inc/basobj.hxx b/idl/inc/basobj.hxx new file mode 100644 index 000000000..2bdd8e622 --- /dev/null +++ b/idl/inc/basobj.hxx @@ -0,0 +1,128 @@ +/* -*- 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_BASOBJ_HXX +#define INCLUDED_IDL_INC_BASOBJ_HXX + +#include <tools/ref.hxx> +#include "bastype.hxx" +#include <vector> + +class SvTokenStream; +class SvIdlDataBase; + +template<typename T> +class SvRefMemberList : private std::vector<T> +{ +private: + typedef typename std::vector<T> base_t; + +public: + using base_t::size; + using base_t::front; + using base_t::back; + using base_t::operator[]; + using base_t::begin; + using base_t::end; + using typename base_t::iterator; + using typename base_t::const_iterator; + using base_t::rbegin; + using base_t::rend; + using typename base_t::reverse_iterator; + using base_t::empty; + + ~SvRefMemberList() { clear(); } + void clear() + { + for( typename base_t::const_iterator it = base_t::begin(); it != base_t::end(); ++it ) + { + T p = *it; + if( p ) + p->ReleaseRef(); + } + base_t::clear(); + } + + void push_back( T p ) + { + base_t::push_back( p ); + p->AddFirstRef(); + } + + void insert( typename base_t::iterator it, T p ) + { + base_t::insert( it, p ); + p->AddFirstRef(); + } + + void pop_back() + { + T p = base_t::back(); + base_t::pop_back(); + if( p ) + p->ReleaseRef(); + } +}; + +class SvMetaObject : public SvRefBase +{ + OString aName; + +protected: + bool ReadNameSvIdl( SvTokenStream & rInStm ); + void DoReadContextSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void ReadContextSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ); +public: + SvMetaObject(); + + static void WriteTab( SvStream & rOutStm, sal_uInt16 nTab ); + static void Back2Delimiter( SvStream & ); + static void WriteStars( SvStream & ); + + void SetName( const OString& rName ); + virtual const OString & GetName() const { return aName; } + + virtual bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); +}; + +class SvMetaReference : public SvMetaObject +{ + tools::SvRef<SvMetaReference> aRef; +public: + SvMetaReference(); + + const OString & GetName() const override + { + return ( !aRef.is() + || !SvMetaObject::GetName().isEmpty() ) + ? SvMetaObject::GetName() + : aRef->GetName(); + } + + SvMetaReference * GetRef() const { return aRef.get(); } + void SetRef( SvMetaReference * pRef ) + { aRef = pRef; } +}; + +#endif // INCLUDED_IDL_INC_BASOBJ_HXX + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/bastype.hxx b/idl/inc/bastype.hxx new file mode 100644 index 000000000..7494b35a8 --- /dev/null +++ b/idl/inc/bastype.hxx @@ -0,0 +1,76 @@ +/* -*- 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_BASTYPE_HXX +#define INCLUDED_IDL_INC_BASTYPE_HXX + + +#include <sal/types.h> +#include <rtl/string.hxx> + +class SvStringHashEntry; +class SvIdlDataBase; +class SvStream; +class SvTokenStream; + +class SvBOOL +{ + bool bVal:1, + bSet:1; +public: + SvBOOL() { bSet = bVal = false; } + SvBOOL( bool b ) : bVal( b ), bSet( false) {} + SvBOOL & operator = ( bool n ) { bVal = n; bSet = true; return *this; } + + operator bool() const { return bVal; } + bool IsSet() const { return bSet; } + + bool ReadSvIdl( SvStringHashEntry const * pName, SvTokenStream & rInStm ); +}; + + +class SvIdentifier +{ + OString m_aStr; + sal_uInt32 nValue; +public: + SvIdentifier() : nValue( 0 ) {}; + SvIdentifier(sal_uInt32 n) : nValue( n ) {}; + + void setString(const OString& rStr) { m_aStr = rStr; } + const OString& getString() const { return m_aStr; } + + void ReadSvIdl( SvStringHashEntry const * pName, SvTokenStream & rInStm ); + bool IsSet() const + { + return !m_aStr.isEmpty() || nValue != 0; + } + sal_uInt32 GetValue() const { return nValue; } + void SetValue( sal_uInt32 bVal ) { nValue = bVal; } + + void ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); +}; + + +bool ReadStringSvIdl( SvStringHashEntry const * pName, SvTokenStream & rInStm, OString& aString ); + + +#endif // INCLUDED_IDL_INC_BASTYPE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/command.hxx b/idl/inc/command.hxx new file mode 100644 index 000000000..ea5e0f446 --- /dev/null +++ b/idl/inc/command.hxx @@ -0,0 +1,47 @@ +/* -*- 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_COMMAND_HXX +#define INCLUDED_IDL_INC_COMMAND_HXX + +#include <rtl/ustring.hxx> +#include <vector> + +class SvCommand +{ +public: + std::vector<OUString> aInFileList; + OUString aSlotMapFile; + OUString aPath; + OUString aTargetFile; + OUString aExportFile; + OUString m_DepFile; + sal_uInt32 nVerbosity; + + SvCommand( int argc, char ** argv ); + ~SvCommand(); +}; + +void Init(); +class SvIdlWorkingBase; +bool ReadIdl( SvIdlWorkingBase * pDataBase, const SvCommand & rCommand ); + +#endif // INCLUDED_IDL_INC_COMMAND_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/database.hxx b/idl/inc/database.hxx new file mode 100644 index 000000000..dcdf93593 --- /dev/null +++ b/idl/inc/database.hxx @@ -0,0 +1,141 @@ +/* -*- 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_DATABASE_HXX +#define INCLUDED_IDL_INC_DATABASE_HXX + +#include "module.hxx" +#include "hash.hxx" +#include "lex.hxx" +#include <rtl/string.hxx> + +#include <rtl/ustring.hxx> +#include <set> +#include <string_view> +#include <exception> + +class SvCommand; + +class SvIdlError +{ + OString aText; +public: + sal_uInt32 nLine, nColumn; + + SvIdlError() : nLine(0), nColumn(0) {} + SvIdlError( sal_uInt32 nL, sal_uInt32 nC ) + : nLine(nL), nColumn(nC) {} + + const OString& GetText() const { return aText; } + void SetText( const OString& rT ) { aText = rT; } + bool IsError() const { return nLine != 0; } +}; + +class SvParseException final : public std::exception +{ +public: + SvIdlError aError; + SvParseException( SvTokenStream const & rInStm, const OString& rError ); + SvParseException( const OString& rError, SvToken const & rTok ); +}; + + + +class SvIdlDataBase +{ + bool bExport; + OUString aExportFile; + sal_uInt32 nUniqueId; + sal_uInt32 nVerbosity; + std::vector<OUString> aIdFileList; + std::unique_ptr<SvStringHashTable> pIdTable; + + SvRefMemberList<SvMetaType *> aTypeList; + SvRefMemberList<SvMetaClass *> aClassList; + SvRefMemberList<SvMetaModule *> aModuleList; + SvRefMemberList<SvMetaSlot *> aSlotList; + SvRefMemberList<SvMetaObject *> aContextStack; + +protected: + ::std::set< OUString > m_DepFiles; + OUString aPath; + SvIdlError aError; + void WriteReset() + { + aUsedTypes.clear(); + } +public: + OUString sSlotMapFile; + + explicit SvIdlDataBase( const SvCommand& rCmd ); + ~SvIdlDataBase(); + + SvRefMemberList<SvMetaType *>& GetTypeList(); + SvRefMemberList<SvMetaClass *>& GetClassList() { return aClassList; } + SvRefMemberList<SvMetaModule *>& GetModuleList() { return aModuleList; } + + // list of used types while writing + SvRefMemberList<SvMetaType *> aUsedTypes; + + void StartNewFile( std::u16string_view rName ); + void SetExportFile( const OUString& rName ) + { aExportFile = rName; } + void AppendSlot( SvMetaSlot *pSlot ); + const SvIdlError & GetError() const { return aError; } + void SetError( const SvIdlError & r ) + { aError = r; } + + const OUString & GetPath() const { return aPath; } + void SetPath(const OUString &s) { aPath = s; } + SvRefMemberList<SvMetaObject *>& GetStack() { return aContextStack; } + + void Write(const OString& rText) const; + void WriteError( SvTokenStream & rInStm ); + void SetError( const OString& rError, SvToken const & rTok ); + void SetAndWriteError( SvTokenStream & rInStm, const OString& rError ); + void Push( SvMetaObject * pObj ); + sal_uInt32 GetUniqueId() { return ++nUniqueId; } + bool FindId( const OString& rIdName, sal_uInt32 * pVal ); + void InsertId( const OString& rIdName, sal_uInt32 nVal ); + bool ReadIdFile( std::string_view rFileName ); + + SvMetaType * FindType( std::string_view rName ); + static SvMetaType * FindType( const SvMetaType *, SvRefMemberList<SvMetaType *>& ); + + SvMetaType * ReadKnownType( SvTokenStream & rInStm ); + SvMetaAttribute * ReadKnownAttr( SvTokenStream & rInStm, + SvMetaType * pType ); + SvMetaAttribute * FindKnownAttr( const SvIdentifier& ); + SvMetaClass * ReadKnownClass( SvTokenStream & rInStm ); + SvMetaClass * FindKnownClass( std::string_view aName ); + void AddDepFile(OUString const& rFileName); + void WriteDepFile(SvFileStream & rStream, std::u16string_view rTarget); +}; + +class SvIdlWorkingBase : public SvIdlDataBase +{ +public: + explicit SvIdlWorkingBase( const SvCommand& rCmd ); + + bool WriteSfx( SvStream & ); +}; + +#endif // INCLUDED_IDL_INC_DATABASE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/globals.hxx b/idl/inc/globals.hxx new file mode 100644 index 000000000..0739d8757 --- /dev/null +++ b/idl/inc/globals.hxx @@ -0,0 +1,128 @@ +/* -*- 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_GLOBALS_HXX +#define INCLUDED_IDL_INC_GLOBALS_HXX + +#include "hash.hxx" +#include <memory> + +struct SvGlobalHashNames +{ + SvStringHashEntry* MM_module; + SvStringHashEntry* MM_interface; + SvStringHashEntry* MM_shell; + SvStringHashEntry* MM_Toggle; + SvStringHashEntry* MM_AutoUpdate; + SvStringHashEntry* MM_Asynchron; + SvStringHashEntry* MM_RecordPerSet; + SvStringHashEntry* MM_RecordPerItem; + SvStringHashEntry* MM_NoRecord; + SvStringHashEntry* MM_RecordAbsolute; + SvStringHashEntry* MM_enum; + SvStringHashEntry* MM_UINT16; + SvStringHashEntry* MM_INT16; + SvStringHashEntry* MM_UINT32; + SvStringHashEntry* MM_INT32; + SvStringHashEntry* MM_BOOL; + SvStringHashEntry* MM_BYTE; + SvStringHashEntry* MM_float; + SvStringHashEntry* MM_double; + SvStringHashEntry* MM_item; + SvStringHashEntry* MM_import; + SvStringHashEntry* MM_SlotIdFile; + SvStringHashEntry* MM_include; + SvStringHashEntry* MM_ExecMethod; + SvStringHashEntry* MM_StateMethod; + SvStringHashEntry* MM_GroupId; + SvStringHashEntry* MM_define; + SvStringHashEntry* MM_MenuConfig; + SvStringHashEntry* MM_ToolBoxConfig; + SvStringHashEntry* MM_AccelConfig; + SvStringHashEntry* MM_FastCall; + SvStringHashEntry* MM_SbxObject; + SvStringHashEntry* MM_Container; + SvStringHashEntry* MM_ReadOnlyDoc; + SvStringHashEntry* MM_struct; + SvStringHashEntry* MM_DisableFlags; + + SvGlobalHashNames(); +}; + +class IdlDll +{ +public: + std::unique_ptr<SvStringHashTable> pHashTable; + std::unique_ptr<SvGlobalHashNames> pGlobalNames; + + IdlDll(); + ~IdlDll(); +}; + +IdlDll & GetIdlApp(); + +#define HASH_INLINE( Name ) \ +inline SvStringHashEntry * SvHash_##Name() \ +{ \ + if( !GetIdlApp().pGlobalNames ) \ + GetIdlApp().pGlobalNames.reset( new SvGlobalHashNames() ); \ + return GetIdlApp().pGlobalNames->MM_##Name; \ +} + +HASH_INLINE(module) +HASH_INLINE(interface) +HASH_INLINE(shell) +HASH_INLINE(Toggle) +HASH_INLINE(AutoUpdate) +HASH_INLINE(Asynchron) +HASH_INLINE(RecordPerItem) +HASH_INLINE(RecordPerSet) +HASH_INLINE(NoRecord) +HASH_INLINE(RecordAbsolute) +HASH_INLINE(enum) +HASH_INLINE(UINT16) +HASH_INLINE(INT16) +HASH_INLINE(UINT32) +HASH_INLINE(INT32) +HASH_INLINE(BOOL) +HASH_INLINE(BYTE) +HASH_INLINE(item) +HASH_INLINE(import) +HASH_INLINE(SlotIdFile) +HASH_INLINE(include) +HASH_INLINE(ExecMethod) +HASH_INLINE(StateMethod) +HASH_INLINE(GroupId) +HASH_INLINE(float) +HASH_INLINE(double) +HASH_INLINE(define) +HASH_INLINE(MenuConfig) +HASH_INLINE(ToolBoxConfig) +HASH_INLINE(AccelConfig) +HASH_INLINE(FastCall) +HASH_INLINE(SbxObject) +HASH_INLINE(Container) +HASH_INLINE(ReadOnlyDoc) +HASH_INLINE(struct) +HASH_INLINE(DisableFlags) + + +#endif // INCLUDED_IDL_INC_GLOBALS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/hash.hxx b/idl/inc/hash.hxx new file mode 100644 index 000000000..6bc904133 --- /dev/null +++ b/idl/inc/hash.hxx @@ -0,0 +1,61 @@ +/* -*- 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_HASH_HXX +#define INCLUDED_IDL_INC_HASH_HXX + +#include <rtl/string.hxx> +#include <tools/solar.h> +#include <unordered_map> +#include <memory> +#include <utility> + +class SvStringHashEntry +{ + OString aName; + sal_uLong nValue; +public: + SvStringHashEntry( OString aName_ ) + : aName(std::move(aName_)) + , nValue(0) + { + } + + const OString& GetName() const { return aName; } + + void SetValue( sal_uLong n ) { nValue = n; } + sal_uLong GetValue() const { return nValue; } +}; + +class SvStringHashTable +{ + std::unordered_map<sal_uInt32, std::unique_ptr<SvStringHashEntry>> maInt2EntryMap; + std::unordered_map<OString, sal_uInt32> maString2IntMap; + sal_uInt32 mnNextId = 0; + +public: + SvStringHashEntry * Insert( OString const & rElement, sal_uInt32 * pInsertPos ); + bool Test( OString const & rElement, sal_uInt32 * pInsertPos ); + SvStringHashEntry * Get( sal_uInt32 nInsertPos ) const; + OString GetNearString( std::string_view rName ) const; +}; + +#endif // INCLUDED_IDL_INC_HASH_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/lex.hxx b/idl/inc/lex.hxx new file mode 100644 index 000000000..b7aa9336d --- /dev/null +++ b/idl/inc/lex.hxx @@ -0,0 +1,217 @@ +/* -*- 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 <sal/types.h> +#include "hash.hxx" +#include <tools/stream.hxx> +#include <vector> +#include <memory> + +enum class SVTOKENTYPE { Empty, Comment, + Integer, String, + Bool, Identifier, + Char, + EndOfFile, HashId }; + +class SvToken +{ +friend class SvTokenStream; + sal_uInt64 nLine, nColumn; + SVTOKENTYPE nType; + OString aString; + union + { + sal_uInt64 nLong; + bool bBool; + char cChar; + SvStringHashEntry * pHash; + }; +public: + SvToken(); + SvToken( const SvToken & rObj ) = delete; + + SvToken & operator = ( const SvToken & rObj ); + + OString GetTokenAsString() const; + + void SetLine( sal_uInt64 nLineP ) { nLine = nLineP; } + sal_uInt64 GetLine() const { return nLine; } + + void SetColumn( sal_uInt64 nColumnP ) { nColumn = nColumnP; } + sal_uInt64 GetColumn() const { return nColumn; } + + bool IsComment() const { return nType == SVTOKENTYPE::Comment; } + bool IsInteger() const { return nType == SVTOKENTYPE::Integer; } + bool IsString() const { return nType == SVTOKENTYPE::String; } + bool IsBool() const { return nType == SVTOKENTYPE::Bool; } + bool IsIdentifierHash() const + { return nType == SVTOKENTYPE::HashId; } + bool IsIdentifier() const + { + return nType == SVTOKENTYPE::Identifier + || nType == SVTOKENTYPE::HashId; + } + bool IsChar() const { return nType == SVTOKENTYPE::Char; } + bool IsEof() const { return nType == SVTOKENTYPE::EndOfFile; } + + const OString& GetString() const + { + return IsIdentifierHash() + ? pHash->GetName() + : aString; + } + sal_uInt64 GetNumber() const { return nLong; } + bool GetBool() const { return bBool; } + char GetChar() const { return cChar; } + + void SetHash( SvStringHashEntry * pHashP ) + { pHash = pHashP; nType = SVTOKENTYPE::HashId; } + bool Is( SvStringHashEntry const * pEntry ) const + { return IsIdentifierHash() && pHash == pEntry; } +}; + +inline SvToken::SvToken() + : nLine(0) + , nColumn(0) + , nType( SVTOKENTYPE::Empty ) +{ +} + +class SvTokenStream +{ + sal_uInt64 nLine, nColumn; + sal_Int32 nBufPos; + char c; // next character + static const sal_uInt16 nTabSize = 4; // length of tabulator + OString aStrTrue; + OString aStrFalse; + sal_uInt32 nMaxPos; + + std::unique_ptr<SvFileStream> pInStream; + OUString aFileName; + std::vector<std::unique_ptr<SvToken> > aTokList; + std::vector<std::unique_ptr<SvToken> >::iterator pCurToken; + + OString aBufStr; + + void InitCtor(); + + char GetNextChar(); + char GetFastNextChar() + { + return (nBufPos < aBufStr.getLength()) + ? aBufStr[nBufPos++] + : '\0'; + } + + void FillTokenList(); + sal_uInt64 GetNumber(); + bool MakeToken( SvToken & ); + bool IsEof() const { return pInStream->eof(); } + void SetMax() + { + sal_uInt32 n = Tell(); + if( n > nMaxPos ) + nMaxPos = n; + } + void CalcColumn() + { + // if end of line spare calculation + if( 0 != c ) + { + sal_Int32 n = 0; + nColumn = 0; + while( n < nBufPos ) + nColumn += aBufStr[n++] == '\t' ? nTabSize : 1; + } + } +public: + SvTokenStream( const OUString & rFileName ); + ~SvTokenStream(); + + const OUString & GetFileName() const { return aFileName; } + SvStream & GetStream() { return *pInStream; } + + SvToken& GetToken_PrevAll() + { + std::vector<std::unique_ptr<SvToken> >::iterator pRetToken = pCurToken; + + // current iterator always valid + if(pCurToken != aTokList.begin()) + --pCurToken; + + return *(*pRetToken); + } + + SvToken& GetToken_Next() + { + std::vector<std::unique_ptr<SvToken> >::iterator pRetToken = pCurToken++; + + if (pCurToken == aTokList.end()) + pCurToken = pRetToken; + + SetMax(); + + return *(*pRetToken); + } + + SvToken& GetToken() const { return *(*pCurToken); } + + bool ReadIf( char cChar ) + { + if( GetToken().IsChar() && cChar == GetToken().GetChar() ) + { + GetToken_Next(); + return true; + } + else + return false; + } + + void ReadIfDelimiter() + { + if( GetToken().IsChar() + && (';' == GetToken().GetChar() + || ',' == GetToken().GetChar()) ) + { + GetToken_Next(); + } + } + + sal_uInt32 Tell() const { return pCurToken-aTokList.begin(); } + + void Seek( sal_uInt32 nPos ) + { + pCurToken = aTokList.begin() + nPos; + SetMax(); + } + + void SeekToMax() + { + pCurToken = aTokList.begin()+nMaxPos; + } +}; + + +#endif // INCLUDED_IDL_INC_LEX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/module.hxx b/idl/inc/module.hxx new file mode 100644 index 000000000..08c14cc9c --- /dev/null +++ b/idl/inc/module.hxx @@ -0,0 +1,37 @@ +/* -*- 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_MODULE_HXX +#define INCLUDED_IDL_INC_MODULE_HXX + +#include "object.hxx" + +class SvMetaModule final : public SvMetaObject +{ +public: + SvRefMemberList<SvMetaClass *> aClassList; + + SvMetaModule(); + + void WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ); +}; + +#endif // INCLUDED_IDL_INC_MODULE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/object.hxx b/idl/inc/object.hxx new file mode 100644 index 000000000..8d16ca563 --- /dev/null +++ b/idl/inc/object.hxx @@ -0,0 +1,90 @@ +/* -*- 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_OBJECT_HXX +#define INCLUDED_IDL_INC_OBJECT_HXX + +#include "types.hxx" + +#include <tools/solar.h> + +#include <vector> + +class SvMetaClass; +typedef ::std::vector< SvMetaClass* > SvMetaClassList; + +class SvClassElement +{ + OString aPrefix; + tools::SvRef<SvMetaClass> xClass; +public: + SvClassElement(); + SvClassElement(SvMetaClass* pClass) { xClass = pClass; } + + void SetPrefix( const OString& rPrefix ) + { aPrefix = rPrefix; } + const OString& GetPrefix() const + { return aPrefix; } + + void SetClass( SvMetaClass * pClass ) + { xClass = pClass; } + SvMetaClass * GetClass() const + { return xClass.get(); } +}; + + +class SvMetaClass : public SvMetaType +{ +public: + tools::SvRef<SvMetaClass> aSuperClass; + std::vector<SvClassElement> aClassElementList; + SvRefMemberList<SvMetaAttribute *> aAttrList; + bool TestAttribute( SvIdlDataBase & rBase, SvTokenStream & rInStm, + SvMetaAttribute & rAttr ) const; +private: + + static void WriteSlotStubs( std::string_view rShellName, + SvSlotElementList & rSlotList, + std::vector<OString> & rList, + SvStream & rOutStm ); + static sal_uInt16 WriteSlotParamArray( SvIdlDataBase & rBase, + SvSlotElementList & rSlotList, + SvStream & rOutStm ); + static sal_uInt16 WriteSlots( std::string_view rShellName, + SvSlotElementList & rSlotList, + SvIdlDataBase & rBase, + SvStream & rOutStm ); + + void InsertSlots( SvSlotElementList& rList, std::vector<sal_uLong>& rSuperList, + SvMetaClassList & rClassList, + const OString& rPrefix, SvIdlDataBase& rBase ); + +public: + SvMetaClass(); + virtual void ReadContextSvIdl( SvIdlDataBase &, + SvTokenStream & rInStm ) override; + + void FillClasses( SvMetaClassList & rList ); + + virtual void WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ) override; +}; + +#endif // INCLUDED_IDL_INC_OBJECT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/parser.hxx b/idl/inc/parser.hxx new file mode 100644 index 000000000..ae9db7105 --- /dev/null +++ b/idl/inc/parser.hxx @@ -0,0 +1,72 @@ +/* -*- 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_PARSER_HXX +#define INCLUDED_IDL_INC_PARSER_HXX + +#include <rtl/ustring.hxx> +#include "types.hxx" + +class SvTokenStream; +class SvIdlDataBase; +class SvMetaModule; +class SvMetaTypeEnum; +class SvStringHashEntry; +class SvMetaType; +class SvMetaClass; +class SvBOOL; + +class SvIdlParser +{ + SvIdlDataBase& rBase; + SvTokenStream & rInStm; +public: + SvIdlParser( SvIdlDataBase& rBase_, SvTokenStream & rInStrm_) : rBase(rBase_), rInStm(rInStrm_) {} + void ReadSvIdl( const OUString & rPath ); + void ReadModuleHeader(SvMetaModule& rModule); + void ReadModuleBody(SvMetaModule& rModule); + void ReadModuleElement( SvMetaModule& rModule ); + void ReadInclude( SvMetaModule& rModule ); + void ReadInterfaceOrShell( SvMetaModule& rModule, MetaTypeType aMetaTypeType ); + void ReadInterfaceOrShellEntry( SvMetaClass& rClass ); + 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 const * pName); + void ReadIfIdAttribute( SvIdentifier& rIdentifier, SvStringHashEntry const * pName ); + bool ReadIf(char cChar); + void ReadDelimiter(); + bool ReadIfDelimiter(); + OString ReadIdentifier(); + OString ReadString(); + void Read(SvStringHashEntry const *); + bool ReadIf(SvStringHashEntry const *); +}; + +#endif // INCLUDED_IDL_INC_PARSER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/slot.hxx b/idl/inc/slot.hxx new file mode 100644 index 000000000..f8ba61d98 --- /dev/null +++ b/idl/inc/slot.hxx @@ -0,0 +1,134 @@ +/* -*- 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_SLOT_HXX +#define INCLUDED_IDL_INC_SLOT_HXX + +#include "types.hxx" + +#include <tools/solar.h> + +class SvMetaSlot : public SvMetaAttribute +{ +public: + SvIdentifier aGroupId; + SvIdentifier aExecMethod; + SvIdentifier aStateMethod; + + SvBOOL aToggle; + SvBOOL aAutoUpdate; + + SvBOOL aAsynchron; + + SvBOOL aRecordPerItem;// exclusive + SvBOOL aRecordPerSet; + SvBOOL aNoRecord; + SvBOOL aRecordAbsolute; + + SvBOOL aMenuConfig; + SvBOOL aToolBoxConfig; + SvBOOL aAccelConfig; + SvBOOL aFastCall; + SvBOOL aContainer; + OString aDisableFlags; + SvMetaSlot* pNextSlot; + sal_uLong nListPos; + SvBOOL aReadOnlyDoc; + + void WriteSlot( std::string_view rShellName, + sal_uInt16 nCount, std::string_view rSlotId, + SvSlotElementList &rList, + size_t nStart, + SvIdlDataBase & rBase, SvStream & rOutStm ); + + bool IsVariable() const; + bool IsMethod() const; + + void SetRecordPerItem( bool bSet ) + { + aRecordPerItem = bSet; + if( bSet ) + aRecordPerSet = aNoRecord = false; + } + void SetRecordPerSet( bool bSet ) + { + aRecordPerSet = bSet; + if( bSet ) + aRecordPerItem = aNoRecord = false; + } + void SetNoRecord( bool bSet ) + { + aNoRecord = bSet; + if( bSet ) + aRecordPerItem = aRecordPerSet = false; + } + +public: + SvMetaSlot(); + SvMetaSlot( SvMetaType * pType ); + + const OString& GetGroupId() const; + const OString& GetExecMethod() const; + const OString& GetStateMethod() const; + const OString& GetDisableFlags() const; + bool GetToggle() const; + bool GetAutoUpdate() const; + + bool GetAsynchron() const; + + bool GetRecordPerItem() const; + bool GetRecordPerSet() const; + bool GetNoRecord() const; + bool GetRecordAbsolute() const; + + bool GetMenuConfig() const; + bool GetToolBoxConfig() const; + bool GetAccelConfig() const; + bool GetFastCall() const; + bool GetContainer() const; + bool GetReadOnlyDoc() const; + + sal_uLong GetListPos() const + { return nListPos; } + void SetListPos(sal_uLong n) + { nListPos = n; } + void ResetSlotPointer() + { pNextSlot = nullptr; } + + virtual bool Test( SvTokenStream & rInStm ) override; + virtual void ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) override; + virtual bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ) override; + virtual void Insert( SvSlotElementList& ) override; + void WriteSlotStubs( std::string_view rShellName, + std::vector<OString> & rList, + SvStream & rOutStm ) const; + sal_uInt16 WriteSlotMap( std::string_view rShellName, + sal_uInt16 nCount, + SvSlotElementList&, + size_t nStart, + SvIdlDataBase & rBase, + SvStream & rOutStm ); + sal_uInt16 WriteSlotParamArray( SvIdlDataBase & rBase, + SvStream & rOutStm ) const; +}; + +#endif // INCLUDED_IDL_INC_SLOT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/types.hxx b/idl/inc/types.hxx new file mode 100644 index 000000000..badab618e --- /dev/null +++ b/idl/inc/types.hxx @@ -0,0 +1,118 @@ +/* -*- 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_TYPES_HXX +#define INCLUDED_IDL_INC_TYPES_HXX + +#include <rtl/strbuf.hxx> +#include <tools/ref.hxx> +#include "basobj.hxx" + +class SvMetaType; +class SvMetaSlot; +typedef SvRefMemberList< SvMetaSlot* > SvSlotElementList; + +class SvMetaAttribute : public SvMetaReference +{ +public: + tools::SvRef<SvMetaType> aType; + SvIdentifier aSlotId; + SvMetaAttribute(); + SvMetaAttribute( SvMetaType * ); + + void SetSlotId( const SvIdentifier & rId ) + { aSlotId = rId; } + const SvIdentifier& GetSlotId() const; + SvMetaType * GetType() const; + + virtual bool Test( SvTokenStream & rInStm ); + virtual bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ) override; + size_t MakeSfx( OStringBuffer& rAtrrArray ) const; + virtual void Insert( SvSlotElementList& ); +}; + +enum MetaTypeType { Method, Struct, Base, Enum, Interface, Shell }; + +class SvMetaType : public SvMetaReference +{ + SvRefMemberList<SvMetaAttribute *> aAttrList; + MetaTypeType nType; + bool bIsItem; + + void WriteSfxItem( std::string_view rItemName, SvIdlDataBase const & rBase, + SvStream & rOutStm ); +protected: + bool ReadHeaderSvIdl( SvTokenStream & rInStm ); +public: + SvMetaType(); + SvMetaType( const OString& rTypeName ); + + virtual ~SvMetaType() override; + + virtual void ReadContextSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ) override; + + SvRefMemberList<SvMetaAttribute *>& + GetAttrList() { return aAttrList; } + size_t GetAttrCount() const { return aAttrList.size(); } + + void SetType( MetaTypeType nT ); + MetaTypeType GetMetaTypeType() const { return nType; } + SvMetaType * GetBaseType() const; + SvMetaType * GetReturnType() const; + void SetItem(bool b) { bIsItem = b; } + bool IsItem() const { return bIsItem; } + + virtual bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ) override; + + size_t MakeSfx( OStringBuffer& rAtrrArray ); + virtual void WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ); + bool ReadMethodArgs( SvIdlDataBase & rBase, + SvTokenStream & rInStm ); +}; + +class SvMetaTypeString final : public SvMetaType +{ +public: + SvMetaTypeString(); +}; + +class SvMetaEnumValue final : public SvMetaObject +{ +public: + SvMetaEnumValue(); +}; + +class SvMetaTypeEnum final : public SvMetaType +{ +public: + SvRefMemberList<SvMetaEnumValue *> aEnumValueList; + OString aPrefix; + SvMetaTypeEnum(); +}; + +class SvMetaTypevoid final : public SvMetaType +{ +public: + SvMetaTypevoid(); +}; + + +#endif // INCLUDED_IDL_INC_TYPES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |