diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2000-09-18 15:33:13 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2000-09-18 15:33:13 +0000 |
commit | ee27dd72550ce8815e06e337d3682d5b8d9d7b11 (patch) | |
tree | c785600f8cc75cd1191fc9966bee9cb0742bb780 /idl/source/cmptools | |
parent | c25ec0608a167bcf1d891043f02273761c351701 (diff) |
initial import
Diffstat (limited to 'idl/source/cmptools')
-rw-r--r-- | idl/source/cmptools/char.cxx | 247 | ||||
-rw-r--r-- | idl/source/cmptools/hash.cxx | 367 | ||||
-rw-r--r-- | idl/source/cmptools/lex.cxx | 677 | ||||
-rw-r--r-- | idl/source/cmptools/makefile.mk | 99 |
4 files changed, 1390 insertions, 0 deletions
diff --git a/idl/source/cmptools/char.cxx b/idl/source/cmptools/char.cxx new file mode 100644 index 000000000000..4b0ca177a508 --- /dev/null +++ b/idl/source/cmptools/char.cxx @@ -0,0 +1,247 @@ +/************************************************************************* + * + * $RCSfile: char.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +/****************** I N C L U D E S **************************************/ +#include <ctype.h> +#include <string.h> + +#ifndef _TABLE_HXX //autogen +#include <tools/table.hxx> +#endif + +#include <char.hxx> +#pragma hdrstop + +/****************** D A T E N ********************************************/ +static unsigned char EqualTab[ 256 ] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, +100, 101, 102, 103, 104, 105, 106, 107, 108, 109, +110, 111, 112, 113, 114, 115, 116, 117, 118, 119, +120, 121, 122, 123, 124, 125, 126, 127, 128, 129, +130, 131, 132, 133, 134, 135, 136, 137, 138, 139, +140, 141, 142, 143, 144, 145, 146, 147, 148, 149, +150, 151, 152, 153, 154, 155, 156, 157, 158, 159, +160, 161, 162, 163, 164, 165, 166, 167, 168, 169, +170, 171, 172, 173, 174, 175, 176, 177, 178, 179, +180, 181, 182, 183, 184, 185, 186, 187, 188, 189, +190, 191, 192, 193, 194, 195, 196, 197, 198, 199, +200, 201, 202, 203, 204, 205, 206, 207, 208, 209, +210, 211, 212, 213, 214, 215, 216, 217, 218, 219, +220, 221, 222, 223, 224, 225, 226, 227, 228, 229, +230, 231, 232, 233, 234, 235, 236, 237, 238, 239, +240, 241, 242, 243, 244, 245, 246, 247, 248, 249, +250, 251, 252, 253, 254, 255 }; + + +/************************************************************************* +|* +|* RscChar::GetTable() +|* +|* Beschreibung +|* Ersterstellung MM 08.08.91 +|* Letzte Aenderung MM 08.08.91 +|* +*************************************************************************/ +Table * pCharTable = NULL; +unsigned char * pChange = EqualTab; +char * SvChar::GetTable( CharSet nSource , CharSet nDest ) +{ + if( nSource == nDest ) + return (char *)EqualTab; + + if( !pCharTable ) + pCharTable = new Table(); + + BYTE * pSet; + pSet = (BYTE *)pCharTable->Get( (ULONG)nSource << 16 + (ULONG)nDest ); + + if( !pSet ) + { + pSet = new BYTE[ 256 ]; + memcpy( pSet, EqualTab, sizeof( EqualTab ) ); + for( USHORT i = 128; i < 256; i++ ) + { + char c = ByteString::Convert( pSet[i], nSource, nDest ); + if( c ) + pSet[ i ] = (BYTE)c; + } + pCharTable->Insert( (ULONG)nSource << 16 + (ULONG)nDest, pSet ); + } + + return (char *)pSet; +}; + + +/************************************************************************* +|* +|* RscChar::MakeChar() +|* +|* Beschreibung Der ByteString wird nach C-Konvention umgesetzt +|* Ersterstellung MM 20.03.91 +|* Letzte Aenderung MM 20.03.91 +|* +*************************************************************************/ +BOOL SvChar::MakeChar( char * pChar, char ** ppStr ) +{ + char c; + BOOL bDoInc = TRUE; // Noch einmal erhoehen + + if( **ppStr == '\\' ) + { + ++*ppStr; + switch( **ppStr ) + { + case 'a': + c = '\a'; + break; + case 'b': + c = '\b'; + break; + case 'f': + c = '\f'; + break; + case 'n': + c = '\n'; + break; + case 'r': + c = '\r'; + break; + case 't': + c = '\t'; + break; + case 'v': + c = '\v'; + break; + case '\\': + c = '\\'; + break; + case '?': + c = '\?'; + break; + case '\'': + c = '\''; + break; + case '\"': + c = '\"'; + break; + default: + { + if( '0' <= **ppStr && '7' >= **ppStr ) + { + bDoInc = FALSE; + + USHORT nChar = 0; + USHORT i = 0; + while( '0' <= **ppStr && '7' >= **ppStr && i != 3 ) + { + nChar = nChar * 8 + (BYTE)**ppStr - (BYTE)'0'; + ++*ppStr; + i++; + } + if( nChar > 255 ) + // Wert zu gross, oder kein 3 Ziffern + return( FALSE ); + c = (char)nChar; + } + else if( 'x' == **ppStr ) + { + bDoInc = FALSE; + + USHORT nChar = 0; + USHORT i = 0; + ++*ppStr; + while( isxdigit( **ppStr ) && i != 2 ) + { + if( isdigit( **ppStr ) ) + nChar = nChar * 16 + (BYTE)**ppStr - (BYTE)'0'; + else if( isupper( **ppStr ) ) + nChar = nChar * 16 + (BYTE)**ppStr - (BYTE)'A' +10; + else + nChar = nChar * 16 + (BYTE)**ppStr - (BYTE)'a' +10; + ++*ppStr; + i++; + } + c = (char)nChar; + } + else + c = **ppStr; + //c = pChange [ (unsigned char)**ppStr ]; + }; + } + } + else + c = **ppStr; + //c = pChange [ (unsigned char)**ppStr ]; + + if( **ppStr && bDoInc ) ++*ppStr; + *pChar = c; + return( TRUE ); +}; + diff --git a/idl/source/cmptools/hash.cxx b/idl/source/cmptools/hash.cxx new file mode 100644 index 000000000000..2f14e1b01d99 --- /dev/null +++ b/idl/source/cmptools/hash.cxx @@ -0,0 +1,367 @@ +/************************************************************************* + * + * $RCSfile: hash.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +/****************** I N C L U D E S **************************************/ +// C and C++ Includes. +#include <stdlib.h> +#include <stdio.h> +#include <ctype.h> + +// Programmabhngige Includes. +#include <hash.hxx> + +#ifndef _TOOLS_DEBUG_HXX //autogen +#include <tools/debug.hxx> +#endif + +#pragma hdrstop + +/****************** C O D E **********************************************/ +/************************************************************************* +|* +|* SvStringHashEntry::~SvStringHashEntry() +|* +|* Beschreibung +|* +*************************************************************************/ +SvStringHashEntry::~SvStringHashEntry() { }; + +/************************************************************************* +|* +|* SvHashTable::SvHashTable() +|* +|* Beschreibung +|* +*************************************************************************/ +SvHashTable::SvHashTable( ULONG nMaxEntries ) +{ + nMax = nMaxEntries; // set max entries + nFill = 0; // no entries + lTry = 0; + lAsk = 0; +} + +/************************************************************************* +|* +|* SvHashTable::~SvHashTable() +|* +|* Beschreibung +|* +*************************************************************************/ +SvHashTable::~SvHashTable() +{ +#ifdef DOS_NIE + printf( "Maximum: %ld, Fllung: %ld\n", (ULONG)nMax, (ULONG)nFill ); + printf( "Anfragen: %ld, Versuche: %ld", (ULONG)lAsk, (ULONG)lTry ); + if( lTry != 0 ) + printf( ", V/E = %ld\n", lTry / lAsk ); +#endif +} + +/************************************************************************* +|* +|* SvHashTable::Test_Insert() +|* +|* Beschreibung +|* +*************************************************************************/ +BOOL SvHashTable::Test_Insert( const void * pElement, BOOL bInsert, + UINT32 * pInsertPos ) +{ + UINT32 nHash; + UINT32 nIndex; + UINT32 nLoop; + + lAsk++; + lTry++; + + nHash = HashFunc( pElement ); + nIndex = nHash % nMax; + +// const char* s = ((ByteString*) pElement)->GetStr(); +// fprintf(stderr,"### Hash: %lu , Name: %s\n",nIndex,s ); + + nLoop = 0; // divide to range + while( (nMax != nLoop) && IsEntry( nIndex ) ) + { // is place occupied + if( COMPARE_EQUAL == Compare( pElement, nIndex ) ) + { + if( pInsertPos ) + *pInsertPos = nIndex; // place of Element + return TRUE; + } + nLoop++; + lTry++; + nIndex = (USHORT)(nIndex + nHash + 7) % nMax; + } + + if( bInsert ) + { + DBG_ASSERT( nMax != nLoop, "Hash table full" ) + if( nMax != nLoop ) + { + nFill++; + *pInsertPos = nIndex; // return free place + return TRUE; + } + } + return( FALSE ); +} + +/************************************************************************/ +/************************************************************************* +|* +|* SvStringHashTable::SvStringHashTable() +|* +|* Beschreibung +|* +*************************************************************************/ +SvStringHashTable::SvStringHashTable( UINT32 nMaxEntries ) + : SvHashTable( nMaxEntries ) +{ +#ifdef WIN + DBG_ASSERT( (UINT32)nMaxEntries * sizeof( SvStringHashEntry ) <= 0xFF00, + "Hash table size cannot exeed 64k byte" ) +#endif + pEntries = new SvStringHashEntry[ nMaxEntries ]; + + // RefCount auf eins setzen + SvStringHashEntry * pPos, *pEnd; + pPos = pEntries; + pEnd = pEntries + nMaxEntries; + while( pPos != pEnd ) + { + pPos->AddRef(); + pPos++; + } +} + +/************************************************************************* +|* +|* ~SvStringHashTable::SvStringHashTable() +|* +|* Beschreibung +|* +*************************************************************************/ +SvStringHashTable::~SvStringHashTable() +{ + // RefCount auf eins setzen + SvStringHashEntry * pPos, *pEnd; + pPos = pEntries; + pEnd = pEntries + GetMax(); +#ifdef DBG_UTIL + while( pPos != pEnd ) + { + DBG_ASSERT( pPos->GetRefCount() == 1, "Reference count != 1" ) + pPos++; + } +#endif + +#ifdef MPW + // der MPW-Compiler ruft sonst keine Dtoren! + for ( USHORT n = 0; n < GetMax(); ++n ) + (pEntries+n)->SvStringHashEntry::~SvStringHashEntry(); + delete (void*) pEntries; +#else + delete [] pEntries; +#endif +} + +/************************************************************************* +|* +|* SvStringHashTable::HashFunc() +|* +|* Beschreibung +|* +*************************************************************************/ +UINT32 SvStringHashTable::HashFunc( const void * pElement ) const +{ + UINT32 nHash = 0; // hash value + const char * pStr = ((const ByteString * )pElement)->GetBuffer(); + + int nShift = 0; + while( *pStr ) + { + if( isupper( *pStr ) ) + nHash ^= UINT32(*pStr - 'A' + 26) << nShift; + else + nHash ^= UINT32(*pStr - 'a') << nShift; + if( nShift == 28 ) + nShift = 0; + else + nShift += 4; + pStr++; + } + return( nHash ); +} + +/************************************************************************* +|* +|* SvStringHashTable::GetNearString() +|* +|* Beschreibung +|* +*************************************************************************/ +ByteString SvStringHashTable::GetNearString( const ByteString & rName ) const +{ + for( UINT32 i = 0; i < GetMax(); i++ ) + { + SvStringHashEntry * pE = Get( i ); + if( pE ) + { + if( pE->GetName().EqualsIgnoreCaseAscii( rName ) && !pE->GetName().Equals( rName ) ) + return pE->GetName(); + } + } + return ByteString(); +} + +/************************************************************************* +|* +|* SvStringHashTable::IsEntry() +|* +|* Beschreibung +|* +*************************************************************************/ +BOOL SvStringHashTable::IsEntry( UINT32 nIndex ) const +{ + if( nIndex >= GetMax() ) + return FALSE; + return pEntries[ nIndex ].HasId(); +} + +/************************************************************************* +|* +|* SvStringHashTable::Insert() +|* +|* Beschreibung +|* +*************************************************************************/ +BOOL SvStringHashTable::Insert( const ByteString & rName, UINT32 * pIndex ) +{ + UINT32 nIndex; + + if( !pIndex ) pIndex = &nIndex; + + if( !SvHashTable::Test_Insert( &rName, TRUE, pIndex ) ) + return FALSE; + + if( !IsEntry( *pIndex ) ) + pEntries[ *pIndex ] = SvStringHashEntry( rName, *pIndex ); + return TRUE; +} + +/************************************************************************* +|* +|* SvStringHashTable::Test() +|* +|* Beschreibung +|* +*************************************************************************/ +BOOL SvStringHashTable::Test( const ByteString & rName, UINT32 * pPos ) const +{ + return ((SvStringHashTable *)this)->SvHashTable:: + Test_Insert( &rName, FALSE, pPos ); +} + +/************************************************************************* +|* +|* SvStringHashTable::Get() +|* +|* Beschreibung +|* +*************************************************************************/ +SvStringHashEntry * SvStringHashTable::Get( UINT32 nIndex ) const +{ + if( IsEntry( nIndex ) ) + return pEntries + nIndex; + return( NULL ); +} + +/************************************************************************* +|* +|* SvStringHashTable::Get() +|* +|* Beschreibung +|* +*************************************************************************/ +StringCompare SvStringHashTable::Compare( const void * pElement, + UINT32 nIndex ) const +{ + return ((const ByteString *)pElement)->CompareTo( pEntries[ nIndex ].GetName() ); +} + +/************************************************************************* +|* +|* SvStringHashTable::FillHashList() +|* +|* Beschreibung +|* +*************************************************************************/ +void SvStringHashTable::FillHashList( SvStringHashList * pList ) const +{ + for( UINT32 n = 0; n < GetMax(); n++ ) + { + if( IsEntry( n ) ) + pList->Insert( Get( n ), LIST_APPEND ); + } + // Hash Reihenfolge, jetzt sortieren +} diff --git a/idl/source/cmptools/lex.cxx b/idl/source/cmptools/lex.cxx new file mode 100644 index 000000000000..3162eafbb3c5 --- /dev/null +++ b/idl/source/cmptools/lex.cxx @@ -0,0 +1,677 @@ +/************************************************************************* + * + * $RCSfile: lex.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#include <ctype.h> +#include <stdio.h> + +#include <char.hxx> +#include <hash.hxx> +#include <lex.hxx> +#include <globals.hxx> + +#ifndef _BIGINT_HXX //autogen +#include <tools/bigint.hxx> +#endif + +#pragma hdrstop + +/****************** SvToken **********************************************/ +/************************************************************************* +|* +|* SvToken::Print() +|* +|* Beschreibung +|* +*************************************************************************/ +ByteString SvToken::GetTokenAsString() const +{ + ByteString aStr; + switch( nType ) + { + case SVTOKEN_EMPTY: + break; + case SVTOKEN_COMMENT: + aStr = aString; + break; + case SVTOKEN_INTEGER: + aStr = nLong; + break; + case SVTOKEN_STRING: + aStr = aString; + break; + case SVTOKEN_BOOL: + aStr = bBool ? "TRUE" : "FALSE"; + break; + case SVTOKEN_IDENTIFIER: + aStr = aString; + break; + case SVTOKEN_CHAR: + aStr = cChar; + break; + case SVTOKEN_RTTIBASE: + aStr = "RTTIBASE";//(ULONG)pComplexObj; + break; + case SVTOKEN_EOF: + break; + } + + return aStr; +} + +/************************************************************************* +|* +|* SvToken::Print() +|* +|* Beschreibung +|* +*************************************************************************/ +ByteString SvToken::Print() const +{ + ByteString aStr; + aStr += "Line = "; + aStr += nLine; + aStr += ", Column = "; + aStr += nColumn; + aStr += ", "; + switch( nType ) + { + case SVTOKEN_EMPTY: + aStr += "Empty"; + break; + case SVTOKEN_COMMENT: + aStr += "Comment = "; + break; + case SVTOKEN_INTEGER: + aStr += "Integer = "; + break; + case SVTOKEN_STRING: + aStr += "ByteString = "; + break; + case SVTOKEN_BOOL: + aStr += "Bool = "; + break; + case SVTOKEN_IDENTIFIER: + aStr += "Identifier = "; + break; + case SVTOKEN_CHAR: + aStr += "char = "; + break; + case SVTOKEN_RTTIBASE: + aStr += "SvRttiBase = "; + break; + case SVTOKEN_EOF: + aStr += "end of file"; + break; + } + aStr += GetTokenAsString(); + + return aStr; +} + +/************************************************************************* +|* +|* SvToken::SvToken() +|* +|* Beschreibung +|* +*************************************************************************/ +SvToken::SvToken( const SvToken & rObj ) +{ + nLine = rObj.nLine; + nColumn = rObj.nColumn; + nType = rObj.nType; + aString = rObj.aString; +/* + if( SVTOKEN_RTTIBASE = nType ) + { + pComplexObj = rObj.pComplexObj; + pComplexObj->AddRef(); + } + else +*/ + nLong = rObj.nLong; +} + +/************************************************************************* +|* +|* SvToken::operator = () +|* +|* Beschreibung +|* +*************************************************************************/ +SvToken & SvToken::operator = ( const SvToken & rObj ) +{ + if( this != &rObj ) + { +/* + if( SVTOKEN_RTTIBASE = nType ) + pComplexObj->ReleaseRef(); +*/ + nLine = rObj.nLine; + nColumn = rObj.nColumn; + nType = rObj.nType; + aString = rObj.aString; +/* + if( SVTOKEN_RTTIBASE = nType ) + { + pComplexObj = rObj.pComplexObj; + pComplexObj->AddRef(); + } + else +*/ + nLong = rObj.nLong; + } + return *this; +} + +/****************** SvTokenStream ****************************************/ +/************************************************************************* +|* SvTokenStream::InitCtor() +|* +|* Beschreibung +*************************************************************************/ +void SvTokenStream::InitCtor() +{ +#ifdef DOS + SetCharSet( CHARSET_ANSI ); +#else + SetCharSet( gsl_getSystemTextEncoding() ); +#endif + aStrTrue = "TRUE"; + aStrFalse = "FALSE"; + nLine = nColumn = 0; + nBufPos = 0; + nTabSize = 4; + pCurToken = NULL; + nMaxPos = 0; + c = GetNextChar(); + FillTokenList(); +} + +/************************************************************************* +|* SvTokenStream::SvTokenStream() +|* +|* Beschreibung +*************************************************************************/ +SvTokenStream::SvTokenStream( const String & rFileName ) + : aFileName( rFileName ) + , pInStream( new SvFileStream( rFileName, STREAM_STD_READ | STREAM_NOCREATE ) ) + , rInStream( *pInStream ) + , aTokList( 0x8000, 0x8000 ) +{ + InitCtor(); +} + +/************************************************************************* +|* SvTokenStream::SvTokenStream() +|* +|* Beschreibung +*************************************************************************/ +SvTokenStream::SvTokenStream( SvStream & rStream, const String & rFileName ) + : aFileName( rFileName ) + , pInStream( NULL ) + , rInStream( rStream ) + , aTokList( 0x8000, 0x8000 ) +{ + InitCtor(); +} + +/************************************************************************* +|* SvTokenStream::~SvTokenStream() +|* +|* Beschreibung +*************************************************************************/ +SvTokenStream::~SvTokenStream() +{ + delete pInStream; + SvToken * pTok = aTokList.Last(); + while( pTok ) + { + delete pTok; + pTok = aTokList.Prev(); + } +} + +/************************************************************************* +|* SvTokenStream::GetHexValue() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvTokenStream::GetHexValue( const ByteString & rStr, BigInt * pValue ) +{ + short nLog = 16; + + *pValue = 0; + char * pStr = (char *)rStr.GetBuffer(); + while( isxdigit( *pStr ) ) + { + if( isdigit( *pStr ) ) + *pValue = *pValue * BigInt( nLog ) + BigInt(*pStr - '0'); + else + *pValue = *pValue * BigInt( nLog ) + BigInt(toupper( *pStr ) - 'A' + 10 ); + pStr++; + } + return '\0' == *pStr; +} + + +/************************************************************************* +|* SvTokenStream::FillTokenList() +|* +|* Beschreibung +*************************************************************************/ +void SvTokenStream::FillTokenList() +{ + SvToken * pToken = new SvToken(); + aTokList.Insert( pToken, LIST_APPEND ); + do + { + if( !MakeToken( *pToken ) ) + { + SvToken * p = aTokList.Prev(); + *pToken = SvToken(); + if( p ) + { + pToken->SetLine( p->GetLine() ); + pToken->SetColumn( p->GetColumn() ); + } + break; + } + else if( pToken->IsComment() ) + *pToken = SvToken(); + else if( pToken->IsEof() ) + break; + else + { + pToken = new SvToken(); + aTokList.Insert( pToken, LIST_APPEND ); + } + } + while( !pToken->IsEof() ); + pCurToken = aTokList.First(); +} + +/************************************************************************* +|* SvTokenStream::Skip() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvTokenStream::Skip( char cStart, char cEnd, UINT32 * pBegin ) +{ + SvToken * pTok = GetToken_Next(); + while( !pTok->IsEof() + && (!pTok->IsChar() || cStart != pTok->GetChar()) ) + pTok = GetToken_Next(); + + if( pBegin ) + *pBegin = Tell() -1; + UINT32 nContextCount = 1; + + while( !pTok->IsEof() && nContextCount != 0 ) + { + pTok = GetToken_Next(); + if( pTok->IsChar() ) + { + if( cEnd == pTok->GetChar() ) + nContextCount--; + if( cStart == pTok->GetChar() ) + nContextCount++; + } + } + pTok = GetToken(); + if( cEnd == '}' && pTok->IsChar() && pTok->GetChar() == ';' ) + // siehe aerger rsc, }; ausgemerzt + pTok = GetToken_Next(); + return nContextCount == 0; +} + +/************************************************************************* +|* SvTokenStream::Replace() +|* +|* Beschreibung +|* Invariante Range immer gueltig +*************************************************************************/ +void SvTokenStream::Replace( const Range & rRange, SvToken * pNewTok ) +{ + // Robuster SeekCursor + ULONG nSeekPos = aTokList.GetCurPos(); + if( nSeekPos >= (ULONG)rRange.Min() ) + if( nSeekPos <= (ULONG)rRange.Max() ) + nSeekPos = rRange.Min(); + else + nSeekPos -= rRange.Len(); + + long nLen = rRange.Len(); + aTokList.Seek( (ULONG)rRange.Min() ); + while( nLen-- ) + delete aTokList.Remove(); + + Seek( nSeekPos ); +} + +/************************************************************************* +|* SvTokenStrem::SetCharSet() +|* +|* Beschreibung +*************************************************************************/ +void SvTokenStream::SetCharSet( CharSet nSet ) +{ + nCharSet = nSet; + +#ifdef DOS + pCharTab = SvChar::GetTable( nSet, CHARSET_ANSI ); +#else + pCharTab = SvChar::GetTable( nSet, gsl_getSystemTextEncoding() ); +#endif +} + +/************************************************************************* +|* SvTokeStream::GetNextChar() +|* +|* Beschreibung +*************************************************************************/ +int SvTokenStream::GetNextChar() +{ + int nChar; + if( (int)aBufStr.Len() < nBufPos ) + { + if( rInStream.ReadLine( aBufStr ) ) + { + nLine++; + nColumn = 0; + nBufPos = 0; + } + else + { + aBufStr.Erase(); + nColumn = 0; + nBufPos = 0; + return '\0'; + } + } + nChar = aBufStr.GetChar( (USHORT)nBufPos++ ); + nColumn += nChar == '\t' ? nTabSize : 1; + return nChar; +} + +/************************************************************************* +|* SvTokenStrem::GetNumber() +|* +|* Beschreibung +*************************************************************************/ +ULONG SvTokenStream::GetNumber() +{ + ULONG l = 0; + short nLog = 10; + + if( '0' == c ) + { + c = GetFastNextChar(); + if( 'x' == c ) + { + nLog = 16; + c = GetFastNextChar(); + } + }; + + if( nLog == 16 ) + { + while( isxdigit( c ) ) + { + if( isdigit( c ) ) + l = l * nLog + (c - '0'); + else + l = l * nLog + (toupper( c ) - 'A' + 10 ); + c = GetFastNextChar(); + } + } + else + { + while( isdigit( c ) || 'x' == c ) + { + l = l * nLog + (c - '0'); + c = GetFastNextChar(); + } + } + + return( l ); +} + +/************************************************************************* +|* SvTokenStream::MakeToken() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvTokenStream::MakeToken( SvToken & rToken ) +{ + int c1; + USHORT i; + + do + { + if( 0 == c ) + c = GetNextChar(); + // Leerzeichen ueberlesen + while( isspace( c ) || 26 == c ) + { + c = GetFastNextChar(); + nColumn += c == '\t' ? nTabSize : 1; + } + } + while( 0 == c && !IsEof() && ( SVSTREAM_OK == rInStream.GetError() ) ); + + ULONG nLastLine = nLine; + ULONG nLastColumn = nColumn; + // Kommentar + if( '/' == c ) + { + // Zeit Optimierung, keine Kommentare + //ByteString aComment( (char)c ); + c1 = c; + c = GetFastNextChar(); + if( '/' == c ) + { + while( '\0' != c ) + { + //aComment += (char)c; + c = GetFastNextChar(); + } + c = GetNextChar(); + rToken.nType = SVTOKEN_COMMENT; + //rToken.aString = aComment; + } + else if( '*' == c ) + { + //aComment += (char)c; + c = GetFastNextChar(); + do + { + //aComment += (char)c; + while( '*' != c ) + { + if( '\0' == c ) + { + c = GetNextChar(); + if( IsEof() ) + return FALSE; + } + else + c = GetFastNextChar(); + //aComment += (char)c; + } + c = GetFastNextChar(); + } + while( '/' != c && !IsEof() && ( SVSTREAM_OK == rInStream.GetError() ) ); + if( IsEof() || ( SVSTREAM_OK != rInStream.GetError() ) ) + return FALSE; + //aComment += (char)c; + c = GetNextChar(); + rToken.nType = SVTOKEN_COMMENT; + //rToken.aString = aComment; + CalcColumn(); + } + else + { + rToken.nType = SVTOKEN_CHAR; + rToken.cChar = (char)c1; + } + } + else if( c == '"' ) + { + ByteString aStr; + i = 0; + BOOL bDone = FALSE; + while( !bDone && !IsEof() && c ) + { + c = GetFastNextChar(); + if( '\0' == c ) + { + // Strings auch "uber das Zeilenende hinauslesen + aStr += '\n'; + c = GetNextChar(); + if( IsEof() ) + return FALSE; + } + if( c == '"' ) + { + c = GetFastNextChar(); + if( c == '"' ) + { + aStr += '"'; + aStr += '"'; + } + else + bDone = TRUE; + } + else if( c == '\\' ) + { + aStr += '\\'; + c = GetFastNextChar(); + if( c ) + aStr += (char)c; + } + else + aStr += (char)c; + } + if( IsEof() || ( SVSTREAM_OK != rInStream.GetError() ) ) + return FALSE; + char * pStr = (char *)aStr.GetBuffer(); + while( *pStr ) + { + *pStr = pCharTab[ (unsigned char)*pStr ]; + pStr++; + }; + rToken.nType = SVTOKEN_STRING; + rToken.aString = aStr; + } + else if( isdigit( c ) ) + { + rToken.nType = SVTOKEN_INTEGER; + rToken.nLong = GetNumber(); + + } + else if( isalpha (c) || (c == '_') ) + { + ByteString aStr; + + while( isalnum( c ) || c == '_' ) + { + aStr += (char)c; + c = GetFastNextChar(); + } + if( aStr.EqualsIgnoreCaseAscii( aStrTrue ) ) + { + rToken.nType = SVTOKEN_BOOL; + rToken.bBool = TRUE; + } + else if( aStr.EqualsIgnoreCaseAscii( aStrFalse ) ) + { + rToken.nType = SVTOKEN_BOOL; + rToken.bBool = FALSE; + } + else + { + UINT32 nHashId; + if( IDLAPP->pHashTable->Test( aStr, &nHashId ) ) + rToken.SetHash( IDLAPP->pHashTable->Get( nHashId ) ); + else + { + rToken.nType = SVTOKEN_IDENTIFIER; + rToken.aString = aStr; + } + } + } + else if( IsEof() ) + { + rToken.nType = SVTOKEN_EOF; + } + else + { + rToken.nType = SVTOKEN_CHAR; + rToken.cChar = (char)c; + c = GetFastNextChar(); + } + rToken.SetLine( nLastLine ); + rToken.SetColumn( nLastColumn ); + return rInStream.GetError() == SVSTREAM_OK; +} + diff --git a/idl/source/cmptools/makefile.mk b/idl/source/cmptools/makefile.mk new file mode 100644 index 000000000000..9a718c175dae --- /dev/null +++ b/idl/source/cmptools/makefile.mk @@ -0,0 +1,99 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. + +PRJPCH= + +PROJECTPCH4DLL=TRUE +PROJECTPCH=idlpch +PROJECTPCHSOURCE=$(PRJ)$/util$/idlpch + +PRJNAME=SVIDL +TARGET=cmptools + +# --- Settings ----------------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +.IF "$(COM)"=="WTC" +CFLAGS+=-od +.ENDIF + +CDEFS+=-DIDL_COMPILER +# --- Files -------------------------------------------------------------- + +CXXFILES= char.cxx \ + lex.cxx \ + hash.cxx \ + $(PROJECTPCHSOURCE).cxx + +OBJFILES= $(OBJ)$/lex.obj \ + $(OBJ)$/char.obj \ + $(OBJ)$/hash.obj + +# --- Targets ------------------------------------------------------------ + +.INCLUDE : target.mk + |