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:
~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 ) }
......
......@@ -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;
......
......@@ -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 )
......
......@@ -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() );
}
......
......@@ -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 ) )
......
......@@ -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;
......
......@@ -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
......
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