Beispiel #1
0
char * hb_memvarGetStrValuePtr( char * szVarName, HB_SIZE * pnLen )
{
   PHB_DYNS pDynVar;
   char * szValue = NULL;

   HB_TRACE( HB_TR_DEBUG, ( "hb_memvarGetStrValuePtr(%s, %p)", szVarName, pnLen ) );

   pDynVar = hb_memvarFindSymbol( szVarName, *pnLen );

   if( pDynVar )
   {
      /* there is dynamic symbol with the requested name - check if it is
       * a memvar variable
       */
      PHB_ITEM pMemvar = hb_dynsymGetMemvar( pDynVar );

      if( pMemvar )
      {
         /* variable contains some data
          */
         if( HB_IS_BYREF( pMemvar ) )
            pMemvar = hb_itemUnRef( pMemvar );

         if( HB_IS_STRING( pMemvar ) )
         {
            szValue = pMemvar->item.asString.value;
            *pnLen = pMemvar->item.asString.length;
         }
      }
   }

   return szValue;
}
Beispiel #2
0
/* This function checks the scope of passed variable name
 */
int hb_memvarScope( const char * szVarName, HB_SIZE nLength )
{
   PHB_DYNS pDynVar;

   HB_TRACE( HB_TR_DEBUG, ( "hb_memvarScope(%s, %" HB_PFS "u)", szVarName, nLength ) );

   pDynVar = hb_memvarFindSymbol( szVarName, nLength );

   if( pDynVar )
      return hb_memvarScopeGet( pDynVar );
   else
      return HB_MV_NOT_FOUND;
}
Beispiel #3
0
/* This function releases all memory occupied by a memvar variable
 * It also restores the value that was hidden if there is another
 * PRIVATE variable with the same name.
 */
static void hb_memvarRelease( PHB_ITEM pMemvar )
{
   HB_TRACE( HB_TR_DEBUG, ( "hb_memvarRelease(%p)", pMemvar ) );

   if( HB_IS_STRING( pMemvar ) )
   {
      PHB_DYNS pDynSymbol = hb_memvarFindSymbol( pMemvar->item.asString.value,
                                                 pMemvar->item.asString.length );

      if( pDynSymbol && hb_dynsymGetMemvar( pDynSymbol ) )
      {
         HB_STACK_TLS_PRELOAD
         HB_SIZE nBase = hb_stackGetPrivateStack()->count;

         /* Find the variable with a requested name that is currently visible
          * Start from the top of the stack.
          */
         while( nBase > 0 )
         {
            if( pDynSymbol == hb_stackGetPrivateStack()->stack[ --nBase ].pDynSym )
            {
               /* reset current value to NIL - the overriden variables will be
                * visible after exit from current procedure
                */
               pMemvar = hb_dynsymGetMemvar( pDynSymbol );
               if( pMemvar )
                  hb_itemClear( pMemvar );
               return;
            }
         }

         /* No match found for PRIVATEs - it's PUBLIC so let's remove it.
          */
         hb_memvarDetachDynSym( pDynSymbol, NULL );
      }
   }
   else
      hb_errRT_BASE( EG_ARG, 3008, NULL, "RELEASE", HB_ERR_ARGS_BASEPARAMS );
}