Files
harbour-core/src/rtl/valtoexp.prg
Przemysław Czerpak 3f78fa0b6e 2014-08-01 02:04 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* extras/gtwvw/gtwvwd.c
    ! fixed typo in WVW_SETICON() - thanks to Ash

  * src/rdd/dbcmd53.c
    ! typo in comment

  * src/rtl/dateshb.c
    % use hb_retclen() instead of hb_retc() when size is well known.

  * src/rtl/valtoexp.prg
    % use hb_defaultValue()

  * src/vm/estack.c
    * minor cleanup

  * src/vm/fm.c
    * modified a little bit HB_MEMINFO structure to force strict alignment
    + added debug code covered by HB_FM_FORCE_REALLOC macro which forces
      allocateing new block in each hb_xrealloc() call
    ! protect realloc() in HB_FM_STATISTIC by mutex, it fixes issue #77.

  * src/rtl/hbproces.c
    % unlock HVM waiting for process in OS2 builds
    ! build array of argument passed to process in hb_processRun() in
      parent process not forked one. It fixes possible deadlock in forked
      process because memory is allocated to create arguments array and
      in MT program memory managers may use mutexes internally which can
      be cloned to forked process in locked state.
      It fixes seldom and random HBMK2 freezing during compilation
      with -jobs=<n> parameter.

  * utils/hbmk2/hbmk2.prg
    ! fixed race condition in concurrent C compiler execution (-jobs=<n>)
      with script file

  * src/debug/dbgentry.c
    ! fixed crash when wrong expression is used as tracepoint
    ! fixed expression analyzer to correctly recognized extended strings e"..."
    * formatting

  * src/debug/dbgbrwsr.prg
  * src/debug/dbghelp.prg
  * src/debug/dbgtarr.prg
  * src/debug/dbgthsh.prg
  * src/debug/dbgtinp.prg
  * src/debug/dbgtmenu.prg
  * src/debug/dbgtobj.prg
  * src/debug/dbgtwin.prg
  * src/debug/dbgwa.prg
  * src/debug/debugger.prg
    * added calls to ::NotSupported() method for some still missing
      functionality
    ! do not use SetColor() but directly pass colors to used objects
      and functions
    ! do not use SetPos() and Row()/Col() for core functionality - it was
      source of few minor bugs
    % enable cursor only in input objects and disable it just after
    % eliminated code to save and restore cursor position and shape
    ! fixed initial positioning in help window
    + implemented HiLite() and DeHiLite() methods in HBDbBrowser() class
    ! fixed positioning when end of source data is reached in browser
    % eliminated some redundant or completely useless code and comments
    % use some fully functional HBDbBrowser() features instead of manual
      encoding similar functionality
    ! validate watchpoint and tracepoint expressions
    % use SWITCH statements
    ! fixed expression presentation (added __dbgValToExp() and __dbgValToStr())
    ! fixed input for new expressions
    ! fixed browser scrolling in object inspector
    ! fixed inkey() processing inside debugger (ALT+D and ALT+C)
    ! fixed browsers highliting in WA inspector
    ! fixed hardcoded limit for 512 workareas in WA inspector
    ! fixed initial WA positioning in WA inspector
    * resized WA  inspector window
    * many other minor fixes and improvements
2014-08-01 02:04:07 +02:00

209 lines
6.5 KiB
Plaintext

/*
* Harbour Project source code:
* hb_ValToExp(), hb_CStr()
*
* Copyright 2007 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
* www - http://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, 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 software; see the file COPYING.txt. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
FUNCTION hb_CStr( xVal )
LOCAL v := ValType( xVal )
SWITCH v
CASE "C"
CASE "M" ; RETURN xVal
CASE "N" ; RETURN Str( xVal )
CASE "D" ; RETURN iif( Empty( xVal ), "0d00000000", "0d" + DToS( xVal ) )
CASE "T" ; RETURN 't"' + hb_TSToStr( xVal, .T. ) + '"'
CASE "L" ; RETURN iif( xVal, ".T.", ".F." )
CASE "S" ; RETURN "@" + xVal:name + "()"
CASE "B" ; RETURN "{|| ... }"
CASE "O" ; RETURN "{ " + xVal:className() + " Object }"
CASE "A" ; RETURN "{ Array of " + hb_ntos( Len( xVal ) ) + " Items }"
CASE "H" ; RETURN "{ Hash of " + hb_ntos( Len( xVal ) ) + " Items }"
CASE "P" ; RETURN "<pointer>"
OTHERWISE
IF xVal == NIL
RETURN "NIL"
ENDIF
ENDSWITCH
RETURN "???:" + v
FUNCTION hb_ValToExp( xVal, lRaw )
RETURN s_valToExp( xVal, hb_defaultValue( lRaw, .F. ) )
STATIC FUNCTION s_valToExp( xVal, lRaw, cInd, hRefs, cRefs, cObjs )
LOCAL cVal, cKey, cClass
LOCAL tmp
LOCAL v := ValType( xVal )
SWITCH v
CASE "C"
CASE "M" ; RETURN hb_StrToExp( xVal )
CASE "N" ; RETURN hb_ntos( xVal )
CASE "D" ; RETURN iif( Empty( xVal ), "0d00000000", "0d" + DToS( xVal ) )
CASE "T" ; RETURN 't"' + hb_TSToStr( xVal, .T. ) + '"'
CASE "L" ; RETURN iif( xVal, ".T.", ".F." )
CASE "S" ; RETURN "@" + xVal:name + "()"
CASE "O"
cClass := xVal:className()
CASE "A"
CASE "H"
tmp := __vmItemID( xVal )
IF cInd == NIL
cInd := cRefs := ""
hRefs := { tmp => cInd }
ELSEIF tmp $ hRefs
IF !( cRefs == "" )
cRefs += ","
ENDIF
cRefs += "{{" + cInd + "}," + hRefs[ tmp ] + "}"
RETURN "NIL"
ELSE
hRefs[ tmp ] := "{" + cInd + "}"
cInd += ","
ENDIF
IF v == "H"
IF Empty( xVal )
cVal := "{=>}"
ELSE
cVal := "{"
FOR EACH tmp IN xVal
cKey := s_valToExp( tmp:__enumKey(), lRaw )
cVal += iif( tmp:__enumIsFirst(), "", ", " ) + ;
cKey + "=>" + ;
s_valToExp( tmp, lRaw, cInd + cKey, hRefs, @cRefs, @cObjs )
NEXT
cVal += "}"
ENDIF
ELSE
cVal := "{"
IF ! lRaw .AND. v == "O"
FOR EACH tmp IN __objGetIVars( xVal )
cVal += iif( tmp:__enumIsFirst(), '{"', ', {"' ) + ;
tmp[ 1 ] + '", ' + ;
s_valToExp( tmp[ 2 ], lRaw, ;
cInd + hb_ntos( tmp:__enumIndex() ) + ",2", ;
hRefs, @cRefs, @cObjs ) + "}"
NEXT
ELSE
FOR EACH tmp IN xVal
cVal += iif( tmp:__enumIsFirst(), "", ", " ) + ;
s_valToExp( tmp, lRaw, cInd + hb_ntos( tmp:__enumIndex() ), hRefs, @cRefs, @cObjs )
NEXT
ENDIF
cVal += "}"
ENDIF
IF v == "O"
IF cObjs == NIL
cObjs := ""
ELSE
cObjs += ","
ENDIF
cObjs += '{"' + cClass + '",'
IF ! cInd == ""
cObjs += "{" + hb_StrShrink( cInd ) + "}"
ENDIF
cObjs += "}"
ENDIF
IF cInd == ""
IF ! Empty( cRefs )
cVal := "__itemSetRef( " + cVal + ", {" + cRefs + "} )"
ENDIF
IF ! Empty( cObjs )
cVal := iif( lRaw, "__itemSetObjRaw( ", ;
"__itemSetObj( " ) + cVal + ", {" + cObjs + "} )"
ENDIF
ENDIF
EXIT
CASE "P" ; RETURN "<pointer>"
CASE "B" ; RETURN "{|| ... }"
OTHERWISE
IF xVal == NIL
cVal := "NIL"
ELSE
cVal := "???:" + v
ENDIF
ENDSWITCH
RETURN cVal
FUNCTION __itemSetRef( xVal, aRefs )
LOCAL aRef
FOR EACH aRef in aRefs
xVal[ hb_ArrayToParams( aRef[ 1 ] ) ] := ;
iif( aRef[ 2 ] == NIL, xVal, xVal[ hb_ArrayToParams( aRef[ 2 ] ) ] )
NEXT
RETURN xVal
FUNCTION __itemSetObj( xVal, aObjs )
LOCAL aRef
FOR EACH aRef in aObjs
__objRestoreIVars( iif( aRef[ 2 ] == NIL, xVal, ;
xVal[ hb_ArrayToParams( aRef[ 2 ] ) ] ), aRef[ 1 ] )
NEXT
RETURN xVal
FUNCTION __itemSetObjRaw( xVal, aObjs )
LOCAL aRef
FOR EACH aRef in aObjs
__objSetClass( iif( aRef[ 2 ] == NIL, xVal, ;
xVal[ hb_ArrayToParams( aRef[ 2 ] ) ] ), aRef[ 1 ] )
NEXT
RETURN xVal