From b44121bb821e52a2663a878012b2ed826a874f76 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 21 Jun 1999 03:53:39 +0000 Subject: [PATCH] *** empty log message *** --- harbour/ChangeLog | 16 +++++ harbour/doc/header.txt | 74 ++++++++++++++++++++ harbour/include/ctoharb.h | 1 + harbour/include/error.api | 36 +++++----- harbour/include/errorapi.h | 122 +++++++++++++++++++++++---------- harbour/include/hberrors.h | 10 +-- harbour/include/hbsetup.h | 2 +- harbour/source/rtl/errorapi.c | 123 +++++++++++++++++++++++++++++++--- 8 files changed, 317 insertions(+), 67 deletions(-) create mode 100644 harbour/doc/header.txt diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 37fcb67c13..9f1c291ac6 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,19 @@ +19990621-04:04 CET Victor Szel + * include/errorapi.h - Some additions, note + the copyright message at the beginning, as the + final text gets done, we should put similar header + to each file. + ! include/hbsetup.h - USE_GTAPI was mistakenly + left defined. + + include/errorapi.h + include/error.api + source/rtl/errorapi.c + The rest of the ERROR API functions + implemented. +. hb_errorRT_BASE() implemented. + + doc/header.txt - added as a function header + template. + 19990621-01:30 CET Victor Szel * whatsnew.txt moved to doc/ directory. * doc/hrb.faq renamed to hrb_faq.txt diff --git a/harbour/doc/header.txt b/harbour/doc/header.txt new file mode 100644 index 0000000000..1d0cc88024 --- /dev/null +++ b/harbour/doc/header.txt @@ -0,0 +1,74 @@ + +/* $DOC$ + * $FUNCNAME$ + * + * $CATEGORY$ + * + * $ONELINER$ + * + * $SYNTAX$ + * + * $ARGUMENTS$ + * + * $RETURNS$ + * + * $DESCRIPTION$ + * + * $EXAMPLES$ + * + * $TESTS$ + * + * $STATUS$ + * + * $COMPLIANCE$ + * + * $SEEALSO$ + * + * $END$ + */ + +Example: + +/* $DOC$ + * $FUNCNAME$ + * IsLeapYr() + * $CATEGORY$ + * Dates + * $ONELINER$ + * Test if a date falls in a leap year. + * $SYNTAX$ + * IsLeapYr( [] ) --> lIsLeap + * $ARGUMENTS$ + * is an optional date. If not supplied is defaults to the + * value returned from date(). + * $RETURNS$ + * TRUE if falls in a leap year, FALSE if not. + * $DESCRIPTION$ + * IsLeapYr() can be used to check if a given year is a leap year. + * $EXAMPLES$ + * // Check if it's a leap year. + * + * If IsLeapYr() + * ? "One extra day before you get paid this Feb!!" + * Else + * ? "A normal year" + * EndIf + * $TESTS$ + * valtype( IsLeapYr( date() ) ) == "L" + * valtype( IsLeapYr( ctod( "" ) ) ) == "L" + * valtype( IsLeapYr() ) == "L" + * IsLeapYr( SToD( "20000101" ) ) + * !IsLeapYr( SToD( "19000101" ) ) + * IsLeapYr( SToD( "19841231" ) ) + * !IsLeapYr() + * $STATUS$ + * C + * $COMPLIANCE$ + * IsLeapYr() works exactly like CA-Clipper's IsLeapYr(), if your + * CA-Clipper doesn't have such a function you're probably in a + * different universe from the author of this function. + * $SEEALSO$ + * Date() IsWeekend() IsHarbourFinished() IsApocalypse() + * $END$ + */ + diff --git a/harbour/include/ctoharb.h b/harbour/include/ctoharb.h index ea5b96e595..98e49f8388 100644 --- a/harbour/include/ctoharb.h +++ b/harbour/include/ctoharb.h @@ -17,6 +17,7 @@ void PushInteger( int iNumber ); void PushLong( long lNumber ); void PushDouble( double dNumber, WORD wDec ); void PushString( char * szText, WORD wLength ); /* pushes a string on to the stack */ +void PushLogical( int iTrueFalse ); /* pushes a logical value onto the stack */ void PushSymbol( PSYMBOL ); void Do( WORD wParams ); /* invokes the virtual machine */ void Function( WORD wParams ); /* invokes the virtual machine */ diff --git a/harbour/include/error.api b/harbour/include/error.api index c9b21a940f..4af7931de6 100644 --- a/harbour/include/error.api +++ b/harbour/include/error.api @@ -16,21 +16,27 @@ #include "errorapi.h" #define _errNew hb_errNew -#define _errGetDescription hb_errGetDescription -#define _errPutDescription hb_errPutDescription -#define _errGetFileName hb_errGetFileName -#define _errPutFileNaem hb_errPutFileName -#define _errGetGenCode hb_errGetGenCode -#define _errPutGenCode hb_errPutGenCode -#define _errGetOperation hb_errGetOperation -#define _errPutOperation hb_errPutOperation -#define _errGetOsCode hb_errGetOsCode -#define _errPutOsCode hb_errPutOsCode -#define _errPutSeverity hb_errPutSeverity -#define _errPutSubCode hb_errPutSubCode -#define _errPutSubSystem hb_errPutSubSystem -#define _errPutTries hb_errPutTries #define _errLaunch hb_errLaunch #define _errRelease hb_errRelease -#endif +#define _errGetSeverity hb_errGetSeverity +#define _errPutSeverity hb_errPutSeverity +#define _errGetGenCode hb_errGetGenCode +#define _errPutGenCode hb_errPutGenCode +#define _errGetOsCode hb_errGetOsCode +#define _errPutOsCode hb_errPutOsCode +#define _errGetFlags hb_errGetFlags +#define _errPutFlags hb_errPutFlags +#define _errGetTries hb_errGetTries +#define _errPutTries hb_errPutTries +#define _errGetSubCode hb_errGetSubCode +#define _errPutSubCode hb_errPutSubCode +#define _errGetSubSystem hb_errGetSubSystem +#define _errPutSubSystem hb_errPutSubSystem +#define _errGetDescription hb_errGetDescription +#define _errPutDescription hb_errPutDescription +#define _errGetOperation hb_errGetOperation +#define _errPutOperation hb_errPutOperation +#define _errGetFileName hb_errGetFileName +#define _errPutFileNaem hb_errPutFileName + diff --git a/harbour/include/errorapi.h b/harbour/include/errorapi.h index 074c3811ae..2e2cbb99b3 100644 --- a/harbour/include/errorapi.h +++ b/harbour/include/errorapi.h @@ -1,54 +1,102 @@ -/* - * $Id$ - */ +/* $Id$ + + Harbour Project source code + + This file contains the Harbour internal error handling definitions + + Copyright (C) 1999 ? + www - http://www.harbour-project.org + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + V 1.0 1999-04-25 - Initial posting. +*/ #ifndef ERRORAPI_H_ #define ERRORAPI_H_ -/* - * + - * Harbour project - * - * 99.04.25 initial posting. - * compatible - *- - */ - #include #include "error.ch" +/* Error codes (returned from hb_errLaunch()) */ -/* - * error flag definations - */ +#define E_BREAK 0xFFFF +#define E_RETRY 1 +#define E_DEFAULT 0 -#define EF_CANRETRY 1 -#define EF_CANDEFAULT 4 +/* Error flags */ -/* - * error codes (returned from _errLaunch()) - */ +#define EF_NONE 0 +#define EF_CANRETRY 1 +#define EF_CANSUBSTITUTE 2 +#define EF_CANDEFAULT 4 -#define E_BREAK 0xFFFF -#define E_RETRY 1 -#define E_DEFAULT 0 +/* oError:Severity */ + +/* ... defined in extend.ch */ + +/* oError:SubSystem (commonly used) */ + +#define HB_ERR_SS_BASE "BASE" +#define HB_ERR_SS_TERMINAL "TERM" +#define HB_ERR_SS_DBCMD "DBCMD" + +/* oError:GenCode */ + +/* ... defined in extend.ch */ + +/* Internal error numbers */ + +#define HB_ERR_IE_NOT_ENOUGH_MEM 1024 +#define HB_ERR_IE_ERR_RECOV_FAIL 1025 +#define HB_ERR_IE_UNREC_ERROR 1026 +#define HB_ERR_IE_GENERIC 1027 + +/* Standard API */ PHB_ITEM hb_errNew( void ); -char * hb_errGetDescription( PHB_ITEM pError ); -PHB_ITEM hb_errPutDescription( PHB_ITEM pError, char * szDescription ); -char * hb_errGetFileName( PHB_ITEM pError ); -PHB_ITEM hb_errPutFileName( PHB_ITEM pError, char * szFileName ); -USHORT hb_errGetGenCode( PHB_ITEM pError ); -PHB_ITEM hb_errPutGenCode( PHB_ITEM pError, USHORT uiGenCode ); -char * hb_errGetOperation( PHB_ITEM pError ); -PHB_ITEM hb_errPutOperation( PHB_ITEM pError, char * szOperation ); -USHORT hb_errGetOsCode( PHB_ITEM pError ); -PHB_ITEM hb_errPutOsCode( PHB_ITEM pError, USHORT uiOsCode ); -PHB_ITEM hb_errPutSeverity( PHB_ITEM pError, USHORT uiSeverity ); -PHB_ITEM hb_errPutSubCode( PHB_ITEM pError, USHORT uiSubCode ); -PHB_ITEM hb_errPutSubSystem( PHB_ITEM pError, char * szSubSystem ); -PHB_ITEM hb_errPutTries( PHB_ITEM pError, USHORT uiTries ); WORD hb_errLaunch( PHB_ITEM pError ); void hb_errRelease( PHB_ITEM pError ); +USHORT hb_errGetSeverity( PHB_ITEM pError ); +PHB_ITEM hb_errPutSeverity( PHB_ITEM pError, USHORT uiSeverity ); +USHORT hb_errGetGenCode( PHB_ITEM pError ); +PHB_ITEM hb_errPutGenCode( PHB_ITEM pError, USHORT uiGenCode ); +USHORT hb_errGetOsCode( PHB_ITEM pError ); +PHB_ITEM hb_errPutOsCode( PHB_ITEM pError, USHORT uiOsCode ); +USHORT hb_errGetFlags( PHB_ITEM pError ); +PHB_ITEM hb_errPutFlags( PHB_ITEM pError, USHORT uiFlags ); +USHORT hb_errGetTries( PHB_ITEM pError ); +PHB_ITEM hb_errPutTries( PHB_ITEM pError, USHORT uiTries ); +USHORT hb_errGetSubCode( PHB_ITEM pError ); +PHB_ITEM hb_errPutSubCode( PHB_ITEM pError, USHORT uiSubCode ); +char * hb_errGetSubSystem( PHB_ITEM pError ); +PHB_ITEM hb_errPutSubSystem( PHB_ITEM pError, char * szSubSystem ); +char * hb_errGetDescription( PHB_ITEM pError ); +PHB_ITEM hb_errPutDescription( PHB_ITEM pError, char * szDescription ); +char * hb_errGetOperation( PHB_ITEM pError ); +PHB_ITEM hb_errPutOperation( PHB_ITEM pError, char * szOperation ); +char * hb_errGetFileName( PHB_ITEM pError ); +PHB_ITEM hb_errPutFileName( PHB_ITEM pError, char * szFileName ); + +/* Error launchers */ + +void hb_errorRT_BASE( ULONG ulGenCode, ULONG ulSubCode, char* szDescription, char* szOperation ); +/* TODO: Enable this: +void hb_errorInternal( ULONG ulCode ); +*/ + #endif /* ERRORAPI_H_ */ + diff --git a/harbour/include/hberrors.h b/harbour/include/hberrors.h index 6ad792b9cf..331557dfa4 100644 --- a/harbour/include/hberrors.h +++ b/harbour/include/hberrors.h @@ -30,11 +30,11 @@ #define ERR_SYNTAX2 20 #define ERR_INCOMPLETE_STMT 21 -#define WARN_AMBIGUOUS_VAR 1 -#define WARN_VAR_NOT_USED 2 -#define WARN_BLOCKVAR_NOT_USED 3 -#define WARN_ASSIGN_TYPE 4 -#define WARN_ASSIGN_SUSPECTED 5 +#define WARN_AMBIGUOUS_VAR 1 +#define WARN_VAR_NOT_USED 2 +#define WARN_BLOCKVAR_NOT_USED 3 +#define WARN_ASSIGN_TYPE 4 +#define WARN_ASSIGN_SUSPECTED 5 void GenError( int, char*, char * ); /* generic parsing error management function */ void GenWarning( int, char*, char * ); /* generic parsing warning management function */ diff --git a/harbour/include/hbsetup.h b/harbour/include/hbsetup.h index 7aeeed3568..66ed127d70 100644 --- a/harbour/include/hbsetup.h +++ b/harbour/include/hbsetup.h @@ -37,7 +37,7 @@ * * By default it is disabled (symbol is not defined) */ -#define USE_GTAPI +/*#define USE_GTAPI*/ /* Operating system specific definitions */ diff --git a/harbour/source/rtl/errorapi.c b/harbour/source/rtl/errorapi.c index ff4dc34756..6b02dac03e 100644 --- a/harbour/source/rtl/errorapi.c +++ b/harbour/source/rtl/errorapi.c @@ -7,9 +7,6 @@ #include #include -/* error codes ( returned from hb_errLaunch() ) */ - - extern HB_ITEM errorBlock; extern STACK stack; extern SYMBOL symEval; @@ -27,6 +24,21 @@ PHB_ITEM hb_errNew( void ) return pReturn; } +WORD hb_errLaunch( PHB_ITEM pError ) +{ + PushSymbol( &symEval ); + Push( &errorBlock ); + Push( pError ); + Do( 1 ); + + return stack.Return.value.iNumber; /* TODO: hb_parnl( -1 ) */ +} + +void hb_errRelease( PHB_ITEM pError ) +{ + hb_itemRelease( pError ); +} + char * hb_errGetDescription( PHB_ITEM pError ) { PushSymbol( GetDynSym( "DESCRIPTION" )->pSymbol ); @@ -113,6 +125,14 @@ PHB_ITEM hb_errPutOsCode( PHB_ITEM pError, USHORT uiOsCode ) return pError; } +USHORT hb_errGetSeverity( PHB_ITEM pError ) +{ + PushSymbol( GetDynSym( "SEVERITY" )->pSymbol ); + Push( pError ); + Do( 0 ); + return stack.Return.value.iNumber; +} + PHB_ITEM hb_errPutSeverity( PHB_ITEM pError, USHORT uiSeverity ) { PushSymbol( GetDynSym( "_SEVERITY" )->pSymbol ); @@ -122,6 +142,14 @@ PHB_ITEM hb_errPutSeverity( PHB_ITEM pError, USHORT uiSeverity ) return pError; } +USHORT hb_errGetSubCode( PHB_ITEM pError ) +{ + PushSymbol( GetDynSym( "SUBCODE" )->pSymbol ); + Push( pError ); + Do( 0 ); + return stack.Return.value.iNumber; +} + PHB_ITEM hb_errPutSubCode( PHB_ITEM pError, USHORT uiSubCode ) { PushSymbol( GetDynSym( "_SUBCODE" )->pSymbol ); @@ -131,6 +159,14 @@ PHB_ITEM hb_errPutSubCode( PHB_ITEM pError, USHORT uiSubCode ) return pError; } +char * hb_errGetSubSystem( PHB_ITEM pError ) +{ + PushSymbol( GetDynSym( "SUBSYSTEM" )->pSymbol ); + Push( pError ); + Do( 0 ); + return stack.Return.value.szText; +} + PHB_ITEM hb_errPutSubSystem( PHB_ITEM pError, char * szSubSystem ) { PushSymbol( GetDynSym( "_SUBSYSTEM" )->pSymbol ); @@ -140,6 +176,14 @@ PHB_ITEM hb_errPutSubSystem( PHB_ITEM pError, char * szSubSystem ) return pError; } +USHORT hb_errGetTries( PHB_ITEM pError ) +{ + PushSymbol( GetDynSym( "TRIES" )->pSymbol ); + Push( pError ); + Do( 0 ); + return stack.Return.value.iNumber; +} + PHB_ITEM hb_errPutTries( PHB_ITEM pError, USHORT uiTries ) { PushSymbol( GetDynSym( "_TRIES" )->pSymbol ); @@ -149,18 +193,79 @@ PHB_ITEM hb_errPutTries( PHB_ITEM pError, USHORT uiTries ) return pError; } -WORD hb_errLaunch( PHB_ITEM pError ) +USHORT hb_errGetFlags( PHB_ITEM pError ) { - PushSymbol( &symEval ); - Push( &errorBlock ); + USHORT uiFlags = EF_NONE; + + /* ; */ + + PushSymbol( GetDynSym( "CANRETRY" )->pSymbol ); Push( pError ); + Do( 0 ); + + if (stack.Return.value.iLogical) uiFlags |= EF_CANRETRY; + + /* ; */ + + PushSymbol( GetDynSym( "CANSUBSTITUTE" )->pSymbol ); + Push( pError ); + Do( 0 ); + + if (stack.Return.value.iLogical) uiFlags |= EF_CANSUBSTITUTE; + + /* ; */ + + PushSymbol( GetDynSym( "CANDEFAULT" )->pSymbol ); + Push( pError ); + Do( 0 ); + + if (stack.Return.value.iLogical) uiFlags |= EF_CANDEFAULT; + + /* ; */ + + return uiFlags; +} + +PHB_ITEM hb_errPutFlags( PHB_ITEM pError, USHORT uiFlags ) +{ + PushSymbol( GetDynSym( "_CANRETRY" )->pSymbol ); + Push( pError ); + PushLogical( uiFlags & EF_CANRETRY ); Do( 1 ); - return stack.Return.value.iNumber; /* TODO: hb_parnl( -1 ) */ + /* ; */ + + PushSymbol( GetDynSym( "_CANSUBSTITUTE" )->pSymbol ); + Push( pError ); + PushLogical( uiFlags & EF_CANSUBSTITUTE ); + Do( 1 ); + + /* ; */ + + PushSymbol( GetDynSym( "_CANDEFAULT" )->pSymbol ); + Push( pError ); + PushLogical( uiFlags & EF_CANDEFAULT ); + Do( 1 ); + + /* ; */ + + return pError; } -void hb_errRelease( PHB_ITEM pError ) +/* Wrappers for hb_errLaunch() */ + +void hb_errorRT_BASE( ULONG ulGenCode, ULONG ulSubCode, char* szDescription, char* szOperation ) { - hb_itemRelease( pError ); + PHB_ITEM pError = hb_errNew(); + + hb_errPutSeverity( pError, ES_ERROR ); + hb_errPutSubSystem( pError, HB_ERR_SS_BASE ); + hb_errPutGenCode( pError, ulGenCode ); + hb_errPutSubCode( pError, ulSubCode ); + hb_errPutDescription( pError, szDescription ); + hb_errPutOperation( pError, szOperation ); + hb_errLaunch( pError ); + + hb_errRelease( pError ); }