Kaydet (Commit) e294fa92 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Replace GetAppData(SHL_IDL) with an rtl::Static

Change-Id: Ia7a75c4686734aa811006858343666d2edfde8a1
üst af1be90e
...@@ -125,13 +125,12 @@ public: ...@@ -125,13 +125,12 @@ public:
~IdlDll(); ~IdlDll();
}; };
IdlDll * GetIdlApp(); IdlDll & GetIdlApp();
#define IDLAPP GetIdlApp()
#define SV_GLOBAL_HASH_ACCESS( Name ) \ #define SV_GLOBAL_HASH_ACCESS( Name ) \
if( !IDLAPP->pGlobalNames ) \ if( !GetIdlApp().pGlobalNames ) \
IDLAPP->pGlobalNames = new SvGlobalHashNames(); \ GetIdlApp().pGlobalNames = new SvGlobalHashNames(); \
return IDLAPP->pGlobalNames->MM_##Name; return GetIdlApp().pGlobalNames->MM_##Name;
#define HASH_INLINE( Name ) \ #define HASH_INLINE( Name ) \
inline SvStringHashEntry * SvHash_##Name() { SV_GLOBAL_HASH_ACCESS( Name ) } inline SvStringHashEntry * SvHash_##Name() { SV_GLOBAL_HASH_ACCESS( Name ) }
......
...@@ -342,8 +342,8 @@ bool SvTokenStream::MakeToken( SvToken & rToken ) ...@@ -342,8 +342,8 @@ bool SvTokenStream::MakeToken( SvToken & rToken )
else else
{ {
sal_uInt32 nHashId; sal_uInt32 nHashId;
if( IDLAPP->pHashTable->Test( aStr, &nHashId ) ) if( GetIdlApp().pHashTable->Test( aStr, &nHashId ) )
rToken.SetHash( IDLAPP->pHashTable->Get( nHashId ) ); rToken.SetHash( GetIdlApp().pHashTable->Get( nHashId ) );
else else
{ {
rToken.nType = SVTOKEN_IDENTIFIER; rToken.nType = SVTOKEN_IDENTIFIER;
......
...@@ -116,15 +116,10 @@ char CommandLineSyntax[] = ...@@ -116,15 +116,10 @@ char CommandLineSyntax[] =
void Init() void Init()
{ {
if( !IDLAPP->pHashTable ) if( !GetIdlApp().pHashTable )
IDLAPP->pHashTable = new SvStringHashTable( 2801 ); GetIdlApp().pHashTable = new SvStringHashTable( 2801 );
if( !IDLAPP->pGlobalNames ) if( !GetIdlApp().pGlobalNames )
IDLAPP->pGlobalNames = new SvGlobalHashNames(); GetIdlApp().pGlobalNames = new SvGlobalHashNames();
}
void DeInit()
{
delete IDLAPP;
} }
bool ReadIdl( SvIdlWorkingBase * pDataBase, const SvCommand & rCommand ) bool ReadIdl( SvIdlWorkingBase * pDataBase, const SvCommand & rCommand )
......
...@@ -531,7 +531,7 @@ void SvIdlDataBase::WriteError( SvTokenStream & rInStm ) ...@@ -531,7 +531,7 @@ void SvIdlDataBase::WriteError( SvTokenStream & rInStm )
} }
if( pTok && pTok->IsIdentifier() ) if( pTok && pTok->IsIdentifier() )
{ {
OString aN = IDLAPP->pHashTable->GetNearString( pTok->GetString() ); OString aN = GetIdlApp().pHashTable->GetNearString( pTok->GetString() );
if( !aN.isEmpty() ) if( !aN.isEmpty() )
fprintf( stderr, "%s versus %s\n", pTok->GetString().getStr(), aN.getStr() ); fprintf( stderr, "%s versus %s\n", pTok->GetString().getStr(), aN.getStr() );
} }
......
...@@ -17,19 +17,20 @@ ...@@ -17,19 +17,20 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <sal/config.h>
#include <tools/shl.hxx>
#include <globals.hxx> #include <globals.hxx>
#include <database.hxx> #include <database.hxx>
IdlDll * GetIdlApp() namespace {
struct TheIdlDll: public rtl::Static<IdlDll, TheIdlDll> {};
}
IdlDll & GetIdlApp()
{ {
if( !(*reinterpret_cast<IdlDll**>(GetAppData(SHL_IDL))) ) return TheIdlDll::get();
{
(*reinterpret_cast<IdlDll**>(GetAppData(SHL_IDL))) = new IdlDll();
}
return (*reinterpret_cast<IdlDll**>(GetAppData(SHL_IDL)));
} }
IdlDll::IdlDll() IdlDll::IdlDll()
...@@ -47,8 +48,8 @@ IdlDll::~IdlDll() ...@@ -47,8 +48,8 @@ IdlDll::~IdlDll()
inline SvStringHashEntry * INS( const OString& rName ) inline SvStringHashEntry * INS( const OString& rName )
{ {
sal_uInt32 nIdx; sal_uInt32 nIdx;
IDLAPP->pHashTable->Insert( rName, &nIdx ); GetIdlApp().pHashTable->Insert( rName, &nIdx );
return IDLAPP->pHashTable->Get( nIdx ); return GetIdlApp().pHashTable->Get( nIdx );
} }
#define A_ENTRY( Name ) , MM_##Name( INS( #Name ) ) #define A_ENTRY( Name ) , MM_##Name( INS( #Name ) )
......
...@@ -211,7 +211,6 @@ int main ( int argc, char ** argv) ...@@ -211,7 +211,6 @@ int main ( int argc, char ** argv)
} }
delete pDataBase; delete pDataBase;
DeInit();
if( nExit != 0 ) if( nExit != 0 )
fprintf( stderr, "svidl terminated with errors\n" ); fprintf( stderr, "svidl terminated with errors\n" );
return nExit; return nExit;
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
//16 (SHL_SFC) removed //16 (SHL_SFC) removed
//17 (SHL_SFX) removed //17 (SHL_SFX) removed
//18 (SHL_SO2) removed //18 (SHL_SO2) removed
#define SHL_IDL 19 //19 (SHL_IDL) removed
//20 (SHL_IDE) removed //20 (SHL_IDE) removed
//21 (SHL_EDIT) removed //21 (SHL_EDIT) removed
//22 (SHL_VCED) removed //22 (SHL_VCED) removed
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment