Skip to content

Commit

Permalink
2024-08-17 17:37 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
Browse files Browse the repository at this point in the history
  * contrib/xhb/xhberror.c
    % cleaned code] to overload ERRORNEW() with XHB_ERRORNEW()

  * src/rtl/fscopy.c
    % removed unnecessary code

  * src/rtl/vfile.c
    ! fixed typo in comment

  * src/vm/dynsym.c
    + allow to use symbol items as parameter in functions:
      hb_IsFunction(), __dynsGetIndex(), __dynsIsFun()
  • Loading branch information
druzus committed Aug 17, 2024
1 parent 96c050b commit 368508e
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 37 deletions.
14 changes: 14 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@
Entries may not always be in chronological/commit order.
See license at the end of file. */

2024-08-17 17:37 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* contrib/xhb/xhberror.c
% cleaned code] to overload ERRORNEW() with XHB_ERRORNEW()

* src/rtl/fscopy.c
% removed unnecessary code

* src/rtl/vfile.c
! fixed typo in comment

* src/vm/dynsym.c
+ allow to use symbol items as parameter in functions:
hb_IsFunction(), __dynsGetIndex(), __dynsIsFun()

2024-07-22 13:37 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* contrib/xhb/xhberror.c
! fixed very bad bug introduced in this modification:
Expand Down
10 changes: 7 additions & 3 deletions contrib/xhb/xhberror.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ static HB_SIZE s_nErrProcLine = 0;
static HB_SIZE s_nErrProcModule = 0;
static HB_SIZE s_nErrCallStack = 0;

static HB_SYMB s_symErrorNew = { "XHB_ERRORNEW", { HB_FS_PUBLIC | HB_FS_LOCAL }, { HB_FUNCNAME( XHB_ERRORNEW ) }, NULL };
static HB_SYMB s_symXhbErrorNew = { "XHB_ERRORNEW", { HB_FS_PUBLIC | HB_FS_LOCAL }, { HB_FUNCNAME( XHB_ERRORNEW ) }, NULL };
#ifdef XHB_ERROR_OVERLOAD_ERRORNEW
static HB_SYMB s_symErrorNew = { "ERRORNEW" , { HB_FS_PUBLIC | HB_FS_LOCAL }, { HB_FUNCNAME( XHB_ERRORNEW ) }, NULL };
#endif

static void s_xhbErrorResize( PHB_ITEM pError )
{
Expand Down Expand Up @@ -342,7 +345,8 @@ static void xhb_errRedefineClass( void * cargo )
PHB_DYNS pDynSym = hb_dynsymFind( "ERRORNEW" );
if( pDynSym )
{
pDynSym->pSymbol->value.pFunPtr = s_symErrorNew.value.pFunPtr;
s_symErrorNew.pDynSym = pDynSym;
pDynSym->pSymbol = &s_symErrorNew;
hb_vmSetDynFunc( pDynSym );
}
}
Expand All @@ -353,7 +357,7 @@ static void xhb_errRedefineClass( void * cargo )
}

HB_CALL_ON_STARTUP_BEGIN( _xhb_error_init_ )
hb_dynsymNew( &s_symErrorNew );
hb_dynsymNew( &s_symXhbErrorNew );
hb_vmAtInit( xhb_errRedefineClass, NULL );
HB_CALL_ON_STARTUP_END( _xhb_error_init_ )

Expand Down
5 changes: 0 additions & 5 deletions src/rtl/fscopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,6 @@ HB_FUNC( HB_FCOPY )
fResult = hb_fsCopy( pszSource, pszDest );
errCode = hb_fsError();
}
else
{
hb_fsSetFError( 2 /* file not found */ );
hb_retni( F_ERROR );
}
hb_fsSetFError( errCode );
hb_retni( fResult ? 0 : F_ERROR );
}
2 changes: 1 addition & 1 deletion src/rtl/vfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ HB_FUNC( HB_VFCOPYFILE )
hb_retni( iResult );
}

/* hb_vfCopyFile( <cFileSrc>, <cFileDst>, [<nBufSize>], [<lTimePreserve>=.t.], [<bCallBack>] ) --> <nResult> */
/* hb_vfCopyFileEx( <cFileSrc>, <cFileDst>, [<nBufSize>], [<lTimePreserve>=.t.], [<bCallBack>] ) --> <nResult> */
HB_FUNC( HB_VFCOPYFILEEX )
{
const char * pszSource = hb_parc( 1 ),
Expand Down
61 changes: 33 additions & 28 deletions src/vm/dynsym.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,26 @@ static PHB_DYNS hb_dynsymGetByIndex( HB_LONG lIndex )
return pDynSym;
}

static PHB_DYNS hb_dynsymByItem( PHB_ITEM pItem )
{
PHB_DYNS pDynSym = NULL;

if( pItem )
{
if( HB_IS_STRING( pItem ) )
pDynSym = hb_dynsymFindName( pItem->item.asString.value );
else if( HB_IS_SYMBOL( pItem ) )
{
pDynSym = pItem->item.asSymbol.value->pDynSym;
if( pDynSym == NULL )
pDynSym = hb_dynsymFind( pItem->item.asSymbol.value->szName );
}
else if( HB_IS_NUMERIC( pItem ) )
pDynSym = hb_dynsymGetByIndex( hb_itemGetNL( pItem ) );
}
return pDynSym;
}

HB_LONG hb_dynsymCount( void )
{
HB_TRACE( HB_TR_DEBUG, ( "hb_dynsymCount()" ) );
Expand Down Expand Up @@ -668,53 +688,38 @@ HB_FUNC( __DYNSGETNAME ) /* Get name of symbol: cSymbol = __dynsymGetName( dsInd
hb_retc( pDynSym ? pDynSym->pSymbol->szName : NULL );
}

HB_FUNC( __DYNSGETINDEX ) /* Gimme index number of symbol: dsIndex = __dynsymGetIndex( cSymbol ) */
HB_FUNC( __DYNSGETINDEX ) /* Gimme index number of symbol: dsIndex = __dynsymGetIndex( cSymbol | sSymbol ) */
{
HB_STACK_TLS_PRELOAD
HB_SYMCNT uiPos = 0;
const char * szName = hb_parc( 1 );
PHB_DYNS pDynSym = hb_dynsymByItem( hb_param( 1, HB_IT_STRING | HB_IT_SYMBOL ) );

if( szName )
if( pDynSym )
{
PHB_DYNS pDynSym = hb_dynsymFindName( szName );
if( pDynSym )
{
HB_DYNSYM_LOCK();
if( hb_dynsymPos( pDynSym->pSymbol->szName, &uiPos ) )
++uiPos;
else
uiPos = 0;
HB_DYNSYM_UNLOCK();
}
HB_DYNSYM_LOCK();
if( hb_dynsymPos( pDynSym->pSymbol->szName, &uiPos ) )
++uiPos;
else
uiPos = 0;
HB_DYNSYM_UNLOCK();
}

hb_retnint( uiPos );
}

HB_FUNC( HB_ISFUNCTION ) /* returns .T. if a symbol has a function/procedure pointer,
given its name */
given its symbol or name */
{
HB_STACK_TLS_PRELOAD
const char * szProc = hb_parc( 1 );
HB_BOOL fResult = HB_FALSE;
PHB_DYNS pDynSym = hb_dynsymByItem( hb_param( 1, HB_IT_STRING | HB_IT_SYMBOL ) );

if( szProc )
{
PHB_DYNS pDynSym = hb_dynsymFindName( szProc );
if( pDynSym )
fResult = hb_dynsymIsFunction( pDynSym );
}

hb_retl( fResult );
hb_retl( pDynSym && hb_dynsymIsFunction( pDynSym ) );
}

HB_FUNC( __DYNSISFUN ) /* returns .T. if a symbol has a function/procedure pointer,
given its symbol index or name */
{
HB_STACK_TLS_PRELOAD
const char * szName = hb_parc( 1 );
PHB_DYNS pDynSym = szName ? hb_dynsymFindName( szName ) :
hb_dynsymGetByIndex( hb_parnl( 1 ) );
PHB_DYNS pDynSym = hb_dynsymByItem( hb_param( 1, HB_IT_STRING | HB_IT_SYMBOL | HB_IT_NUMERIC ) );

hb_retl( pDynSym && hb_dynsymIsFunction( pDynSym ) );
}
Expand Down

0 comments on commit 368508e

Please sign in to comment.