summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-07-06 23:10:38 +0200
committerStephan Bergmann <sbergman@redhat.com>2015-07-07 07:48:12 +0200
commite294fa9283071cb2816b6d8c759ed76ee552410e (patch)
tree10fc4d353de9409d769e74675536b8be4acf7c03
parentaf1be90e528ceeca70ee8f266fc6f6d8682b2c0d (diff)
Replace GetAppData(SHL_IDL) with an rtl::Static
Change-Id: Ia7a75c4686734aa811006858343666d2edfde8a1
-rw-r--r--idl/inc/globals.hxx9
-rw-r--r--idl/source/cmptools/lex.cxx4
-rw-r--r--idl/source/prj/command.cxx13
-rw-r--r--idl/source/prj/database.cxx2
-rw-r--r--idl/source/prj/globals.cxx21
-rw-r--r--idl/source/prj/svidl.cxx1
-rw-r--r--include/tools/shl.hxx2
7 files changed, 23 insertions, 29 deletions
diff --git a/idl/inc/globals.hxx b/idl/inc/globals.hxx
index 3569d975018f..014aac7cdbc9 100644
--- a/idl/inc/globals.hxx
+++ b/idl/inc/globals.hxx
@@ -125,13 +125,12 @@ public:
~IdlDll();
};
-IdlDll * GetIdlApp();
-#define IDLAPP GetIdlApp()
+IdlDll & GetIdlApp();
#define SV_GLOBAL_HASH_ACCESS( Name ) \
- if( !IDLAPP->pGlobalNames ) \
- IDLAPP->pGlobalNames = new SvGlobalHashNames(); \
- return IDLAPP->pGlobalNames->MM_##Name;
+ if( !GetIdlApp().pGlobalNames ) \
+ GetIdlApp().pGlobalNames = new SvGlobalHashNames(); \
+ return GetIdlApp().pGlobalNames->MM_##Name;
#define HASH_INLINE( Name ) \
inline SvStringHashEntry * SvHash_##Name() { SV_GLOBAL_HASH_ACCESS( Name ) }
diff --git a/idl/source/cmptools/lex.cxx b/idl/source/cmptools/lex.cxx
index ef606941af2d..571f4c133322 100644
--- a/idl/source/cmptools/lex.cxx
+++ b/idl/source/cmptools/lex.cxx
@@ -342,8 +342,8 @@ bool SvTokenStream::MakeToken( SvToken & rToken )
else
{
sal_uInt32 nHashId;
- if( IDLAPP->pHashTable->Test( aStr, &nHashId ) )
- rToken.SetHash( IDLAPP->pHashTable->Get( nHashId ) );
+ if( GetIdlApp().pHashTable->Test( aStr, &nHashId ) )
+ rToken.SetHash( GetIdlApp().pHashTable->Get( nHashId ) );
else
{
rToken.nType = SVTOKEN_IDENTIFIER;
diff --git a/idl/source/prj/command.cxx b/idl/source/prj/command.cxx
index 39c1bc45450d..44dd4918e479 100644
--- a/idl/source/prj/command.cxx
+++ b/idl/source/prj/command.cxx
@@ -116,15 +116,10 @@ char CommandLineSyntax[] =
void Init()
{
- if( !IDLAPP->pHashTable )
- IDLAPP->pHashTable = new SvStringHashTable( 2801 );
- if( !IDLAPP->pGlobalNames )
- IDLAPP->pGlobalNames = new SvGlobalHashNames();
-}
-
-void DeInit()
-{
- delete IDLAPP;
+ if( !GetIdlApp().pHashTable )
+ GetIdlApp().pHashTable = new SvStringHashTable( 2801 );
+ if( !GetIdlApp().pGlobalNames )
+ GetIdlApp().pGlobalNames = new SvGlobalHashNames();
}
bool ReadIdl( SvIdlWorkingBase * pDataBase, const SvCommand & rCommand )
diff --git a/idl/source/prj/database.cxx b/idl/source/prj/database.cxx
index 865332f7b0d8..0aba11745589 100644
--- a/idl/source/prj/database.cxx
+++ b/idl/source/prj/database.cxx
@@ -531,7 +531,7 @@ void SvIdlDataBase::WriteError( SvTokenStream & rInStm )
}
if( pTok && pTok->IsIdentifier() )
{
- OString aN = IDLAPP->pHashTable->GetNearString( pTok->GetString() );
+ OString aN = GetIdlApp().pHashTable->GetNearString( pTok->GetString() );
if( !aN.isEmpty() )
fprintf( stderr, "%s versus %s\n", pTok->GetString().getStr(), aN.getStr() );
}
diff --git a/idl/source/prj/globals.cxx b/idl/source/prj/globals.cxx
index 38b2d167edb4..b36b84511cdf 100644
--- a/idl/source/prj/globals.cxx
+++ b/idl/source/prj/globals.cxx
@@ -17,19 +17,20 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-
-#include <tools/shl.hxx>
+#include <sal/config.h>
#include <globals.hxx>
#include <database.hxx>
-IdlDll * GetIdlApp()
+namespace {
+
+struct TheIdlDll: public rtl::Static<IdlDll, TheIdlDll> {};
+
+}
+
+IdlDll & GetIdlApp()
{
- if( !(*reinterpret_cast<IdlDll**>(GetAppData(SHL_IDL))) )
- {
- (*reinterpret_cast<IdlDll**>(GetAppData(SHL_IDL))) = new IdlDll();
- }
- return (*reinterpret_cast<IdlDll**>(GetAppData(SHL_IDL)));
+ return TheIdlDll::get();
}
IdlDll::IdlDll()
@@ -47,8 +48,8 @@ IdlDll::~IdlDll()
inline SvStringHashEntry * INS( const OString& rName )
{
sal_uInt32 nIdx;
- IDLAPP->pHashTable->Insert( rName, &nIdx );
- return IDLAPP->pHashTable->Get( nIdx );
+ GetIdlApp().pHashTable->Insert( rName, &nIdx );
+ return GetIdlApp().pHashTable->Get( nIdx );
}
#define A_ENTRY( Name ) , MM_##Name( INS( #Name ) )
diff --git a/idl/source/prj/svidl.cxx b/idl/source/prj/svidl.cxx
index ee1bb85bb162..676dd6f6b89d 100644
--- a/idl/source/prj/svidl.cxx
+++ b/idl/source/prj/svidl.cxx
@@ -211,7 +211,6 @@ int main ( int argc, char ** argv)
}
delete pDataBase;
- DeInit();
if( nExit != 0 )
fprintf( stderr, "svidl terminated with errors\n" );
return nExit;
diff --git a/include/tools/shl.hxx b/include/tools/shl.hxx
index e4bce5508c54..c310c55c6141 100644
--- a/include/tools/shl.hxx
+++ b/include/tools/shl.hxx
@@ -43,7 +43,7 @@
//16 (SHL_SFC) removed
//17 (SHL_SFX) removed
//18 (SHL_SO2) removed
-#define SHL_IDL 19
+//19 (SHL_IDL) removed
//20 (SHL_IDE) removed
//21 (SHL_EDIT) removed
//22 (SHL_VCED) removed