From 2df124bece7aa6418e66a53141c65ede910b2505 Mon Sep 17 00:00:00 2001 From: "David G. Holm" Date: Sat, 8 May 1999 01:14:50 +0000 Subject: [PATCH] See ChangeLog entry 19990507-20:15 EDT David G. Holm --- harbour/ChangeLog | 7 +++++++ harbour/source/compiler/harbour.l | 10 +++++++--- harbour/source/compiler/harbour.y | 26 ++++++++++++++++++++++++-- harbour/source/rtl/classes.c | 2 +- 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 9647faab45..3d91de61c3 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,10 @@ +19990507-20:15 EDT David G. Holm + * source/compiler/harbour.l + * source/compiler/harbour.y + * source/rtl/classes.c + - Modified all three for C and C++ compatibility. + - Tested with Borland C++ 3.1 in both C and C++ modes. + 19990508-00:18 Eddie Runia * source/rtl/classes.c: oSend( , , added. diff --git a/harbour/source/compiler/harbour.l b/harbour/source/compiler/harbour.l index 7231147335..d36fcabc88 100644 --- a/harbour/source/compiler/harbour.l +++ b/harbour/source/compiler/harbour.l @@ -17,7 +17,11 @@ void yyerror( char * ); void yyunput( int, char * ); #undef yywrap /* to implement our own yywrap() funtion to handle EOFs */ +#ifdef __cplusplus +extern "C" int yywrap( void ); +#else int yywrap( void ); +#endif #undef YY_INPUT /* to implement our own YY_INPUT function to manage PRGs without \n at the end */ extern FILE * yyin; /* currently yacc parsed file */ int yy_lex_input( char *, int ); @@ -337,7 +341,7 @@ Separator {SpaceTab}|{Comment}|{LineCont} PDEFINE LastDef( PDEFINE pDef ) { while( pDef->pNext ) - pDef = pDef->pNext; + pDef = (PDEFINE) pDef->pNext; return pDef; } @@ -363,7 +367,7 @@ void DefineKey( char * szKey ) PDEFINE pLast = LastDef( pDefs ); if( pLast->pKeys ) - LastDef( pLast->pKeys )->pNext = pDef; + LastDef( (PDEFINE) pLast->pKeys )->pNext = pDef; else pLast->pKeys = pDef; @@ -384,7 +388,7 @@ PDEFINE FindDef( char * szText ) else { if( pDef->pNext ) - pDef = pDef->pNext; + pDef = (PDEFINE) pDef->pNext; else return 0; } diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index 1afd81c22a..27af0ca371 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -139,12 +139,22 @@ char *MakeFilename( char *, FILENAME *); /* joins a path, a name an an extensio void yyerror( char * ); /* parsing error management function */ int yylex( void ); /* main lex token function, called by yyparse() */ int yyparse( void ); /* main yacc parsing function */ +#ifdef __cplusplus +extern "C" int yywrap( void ); +#else int yywrap( void ); /* manages the EOF of current processed file */ +#endif void AddDefine( char * szDefine, char * szValue ); /* add a new Lex define from the command line */ void * yy_create_buffer( FILE *, int ); /* yacc functions to manage multiple files */ +#ifdef __cplusplus +typedef struct yy_buffer_state *YY_BUFFER_STATE; +void yy_switch_to_buffer( YY_BUFFER_STATE ); /* yacc functions to manage multiple files */ +void yy_delete_buffer( YY_BUFFER_STATE ); /* yacc functions to manage multiple files */ +#else void yy_switch_to_buffer( void * ); /* yacc functions to manage multiple files */ void yy_delete_buffer( void * ); /* yacc functions to manage multiple files */ +#endif void __yy_memcpy( char * from, char * to, int count ); /* Bison prototype */ /* production related functions */ @@ -965,7 +975,7 @@ void close_on_exit( void ) { printf( "\nClosing file: %s\n", pFile->szFileName ); fclose( pFile->handle ); - pFile = pFile->pPrev; + pFile = (PFILE) pFile->pPrev; } } @@ -1496,7 +1506,11 @@ int Include( char * szFileName ) pFile->pPrev = files.pLast; files.pLast = pFile; } - yy_switch_to_buffer( pFile->pBuffer = yy_create_buffer( yyin, 8192 * 2 ) ); +#ifdef __cplusplus + yy_switch_to_buffer( (YY_BUFFER_STATE) (pFile->pBuffer = yy_create_buffer( yyin, 8192 * 2 ) ) ); +#else + yy_switch_to_buffer( (pFile->pBuffer = yy_create_buffer( yyin, 8192 * 2 ) ) ); +#endif files.iFiles++; return 1; } @@ -1514,11 +1528,19 @@ int yywrap( void ) /* handles the EOF of the currently processed file */ files.pLast = ( PFILE ) ( ( PFILE ) files.pLast )->pPrev; iLine = files.pLast->iLine; printf( "\nparsing file %s\n", files.pLast->szFileName ); +#ifdef __cplusplus + yy_delete_buffer( (YY_BUFFER_STATE) ( ( PFILE ) pLast )->pBuffer ); +#else yy_delete_buffer( ( ( PFILE ) pLast )->pBuffer ); +#endif free( pLast ); files.iFiles--; yyin = files.pLast->handle; +#ifdef __cplusplus + yy_switch_to_buffer( (YY_BUFFER_STATE) files.pLast->pBuffer ); +#else yy_switch_to_buffer( files.pLast->pBuffer ); +#endif return 0; /* we close the currently include file and continue */ } } diff --git a/harbour/source/rtl/classes.c b/harbour/source/rtl/classes.c index 2413e6ae25..4f7ff0dc32 100644 --- a/harbour/source/rtl/classes.c +++ b/harbour/source/rtl/classes.c @@ -275,7 +275,7 @@ static HARBOUR ClassSel() /* Create a transfer array */ for( wAt = 0; wAt < wLimit ; wAt++ ) { - pMessage = pClass->pMethods[ wAt ].pMessage; + pMessage = (PDYNSYM) pClass->pMethods[ wAt ].pMessage; if( pMessage ) /* Hash Entry used ? */ { pItem = _itemNew( NULL ); /* Add to array */