2014-01-09 19:15 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

* src/rtl/tgetint.prg
    ! allow to accept complex expressions passed as string to __Get()
      function. It fixes the problem I introduced in previous modification.
    ! allow to use __GetA() for hashes

  * src/vm/macro.c
    ! do not ignore additional characters after blank ones looking for
      memvar name. More restrictive behavior is necessary for to fix
      problem with code like: MemVarBlock( "GETLIST [1]" )
This commit is contained in:
Przemysław Czerpak
2014-01-09 19:15:23 +01:00
parent e842b7f788
commit 712b7710bb
3 changed files with 37 additions and 14 deletions

View File

@@ -10,6 +10,17 @@
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
*/
2014-01-09 19:15 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* src/rtl/tgetint.prg
! allow to accept complex expressions passed as string to __Get()
function. It fixes the problem I introduced in previous modification.
! allow to use __GetA() for hashes
* src/vm/macro.c
! do not ignore additional characters after blank ones looking for
memvar name. More restrictive behavior is necessary for to fix
problem with code like: MemVarBlock( "GETLIST [1]" )
2014-01-09 02:01 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* src/vm/itemapi.c
! clear destination item in hb_itemParamStore*() functions if passed

View File

@@ -57,19 +57,22 @@ FUNCTION __Get( bSetGet, cVarName, cPicture, bValid, bWhen )
IF ! HB_ISBLOCK( bSetGet )
IF FieldPos( cVarName ) > 0
bSetGet := FieldWBlock( cVarName, Select() )
ELSE
ELSEIF ( bSetGet := MemVarBlock( cVarName ) ) == NIL
/* If cVarName is not a field name in current workarea then
* CA-Cl*pper always tries to create SET/GET block for memvar.
* Simple loop below with __mvGet() inside is small trick to
* force the same RTE as in CA-Cl*pper so user can create
* memvar dynamically in his custom error handler. [druzus]
* If it cannot (i.e. cVarName is complex expression) then it
* macrocompile simple SET/GET block for it. [druzus]
*/
DO WHILE ( bSetGet := MemVarBlock( cVarName ) ) == NIL
__mvGet( cVarName )
ENDDO
bSetGet := hb_macroBlock( "iif(HB_PValue(1)==NIL," + cVarName + "," + cVarName + ":=hb_PValue(1))" )
ENDIF
ENDIF
/* The Eval() below is executed to force the same RTE as in
* CA-Cl*pper so user can create memvar dynamically in his
* custom error handler. [druzus]
*/
Eval( bSetGet )
oGet := GetNew(,, bSetGet, cVarName, cPicture )
oGet:PreBlock := bWhen
@@ -96,7 +99,7 @@ FUNCTION __GetA( bGetArray, cVarName, cPicture, bValid, bWhen, aIndex )
ENDIF
ENDIF
IF ! HB_ISARRAY( Eval( bGetArray ) )
IF ! ValType( Eval( bGetArray ) ) $ "AH"
RETURN NIL
ENDIF

View File

@@ -920,16 +920,25 @@ static void hb_macroSetGetBlock( PHB_DYNS pVarSym, PHB_ITEM pItem,
HB_FUNC( MEMVARBLOCK )
{
const char * szVarName = hb_parc( 1 );
const char * szName = hb_parc( 1 );
if( szVarName )
if( szName )
{
PHB_DYNS pVarSym = hb_dynsymFindName( szVarName );
char szVarName[ HB_SYMBOL_NAME_LEN + 1 ];
if( pVarSym && hb_dynsymIsMemvar( pVarSym ) )
while( HB_ISSPACE( *szName ) )
++szName;
hb_strncpyUpperTrim( szVarName, szName, sizeof( szVarName ) - 1 );
if( *szVarName )
{
HB_STACK_TLS_PRELOAD
hb_macroSetGetBlock( pVarSym, hb_stackReturnItem(), 0, HB_TRUE );
PHB_DYNS pVarSym = hb_dynsymFind( szVarName );
if( pVarSym && hb_dynsymIsMemvar( pVarSym ) )
{
HB_STACK_TLS_PRELOAD
hb_macroSetGetBlock( pVarSym, hb_stackReturnItem(), 0, HB_TRUE );
}
}
}
}