From 072b90b2be58bf9217cbdac5f1fc7164ea13f6d1 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 25 Jun 2012 10:11:12 +0000 Subject: [PATCH] 2012-06-25 12:09 UTC+0200 Viktor Szakats (harbour syenar.net) * contrib/xhb/decode.prg * contrib/xhb/dumpvar.prg * contrib/xhb/hbcompat.ch * contrib/xhb/regexrpl.prg % using HB_IS*() functions. * formatting --- harbour/ChangeLog | 22 ++++++++++++------- harbour/contrib/xhb/decode.prg | 18 ++++++++-------- harbour/contrib/xhb/dumpvar.prg | 2 +- harbour/contrib/xhb/hbcompat.ch | 36 ++++++++++++++++---------------- harbour/contrib/xhb/regexrpl.prg | 13 ++++-------- 5 files changed, 47 insertions(+), 44 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index cc0b15bb3e..49ff78b15e 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,14 @@ The license applies to all entries newer than 2009-04-28. */ +2012-06-25 12:09 UTC+0200 Viktor Szakats (harbour syenar.net) + * contrib/xhb/decode.prg + * contrib/xhb/dumpvar.prg + * contrib/xhb/hbcompat.ch + * contrib/xhb/regexrpl.prg + % using HB_IS*() functions. + * formatting + 2012-06-23 10:53 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbqt/hbmk2_qt.hb ! Fixed: to handle QList implementation. @@ -33,20 +41,20 @@ 2012-06-22 15:09 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbqt/hbmk2_qt.hb - ! Optimized to not add code for constructors which do not + ! Optimized to not add code for constructors which do not have Qt objects. Results can be viewed in QLibraryInfo.cpp. 2012-06-22 12:47 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbqt/hbmk2_qt.hb * contrib/hbqt/qtcore/hbqt.h * contrib/hbqt/qtcore/hbqt_init.cpp - - Removed: a hack introduced some months back where + - Removed: a hack introduced some months back where C++ static items were held in a list them released - at exit of an application. This was double work and + at exit of an application. This was double work and now is not needed at all. * contrib/hbqt/qtcore/hbqt_bind.cpp - - Reverted: last fix where was compared against + - Reverted: last fix where was compared against a numeric, which, BTW was a stupid implementation. A pointer casted to a numeric is always true. @@ -55,8 +63,8 @@ It was breaking such code: oWnd:connect( QEvent_Close, {|| QApplication():quit() } ) QApplication():exec() - the reason was any code executed after - QApplication():quit() was rendered unexcutable because + the reason was any code executed after + QApplication():quit() was rendered unexcutable because appln was forced to stop execution. * contrib/hbqt/qtcore/hbqt_hbqevents.cpp @@ -65,7 +73,7 @@ * contrib/hbqt/qtcore/qth/QLibraryInfo.qth * contrib/hbqt/qtgui/qth/QDesktopServices.qth - + Reworked: constructors. + + Reworked: constructors. Previous implementation was wrong. Applied Francesco's thought and it worked, thanks. diff --git a/harbour/contrib/xhb/decode.prg b/harbour/contrib/xhb/decode.prg index f91d403a7a..8c5f6b5d1e 100644 --- a/harbour/contrib/xhb/decode.prg +++ b/harbour/contrib/xhb/decode.prg @@ -119,18 +119,18 @@ FUNCTION HB_Decode(...) // Ok because I have no other value than default, I will check if it is a complex value // like an array or an hash, so I can get it to decode values IF xDefault != NIL .AND. ; - ( ValType( xDefault ) == "A" .OR. ; - ValType( xDefault ) == "H" ) + ( HB_ISARRAY( xDefault ) .OR. ; + HB_ISHASH( xDefault ) ) // If it is an array I will restart this function creating a linear call - IF ValType( xDefault ) == "A" .AND. Len( xDefault ) > 0 + IF HB_ISARRAY( xDefault ) .AND. Len( xDefault ) > 0 // I can have a linear array like { 1, "A", 2, "B", 3, "C" } // or an array of array couples like { { 1, "A" }, { 2, "B" }, { 3, "C" } } // first element tell me what type is // couples of values - IF ValType( xDefault[ 1 ] ) == "A" + IF HB_ISARRAY( xDefault[ 1 ] ) //// If i have an array as default, this contains couples of key / value //// so I have to convert in a linear array @@ -139,7 +139,7 @@ FUNCTION HB_Decode(...) // Check if array has a default value, this will be last value and has a value // different from an array - IF !( ValType( xDefault[ nLen ] ) == "A" ) + IF ! HB_ISARRAY( xDefault[ nLen ] ) aParams := Array( ( nLen - 1 ) * 2 ) @@ -172,7 +172,7 @@ FUNCTION HB_Decode(...) // If it is an hash, translate it in an array - ELSEIF ValType( xDefault ) == "H" + ELSEIF HB_ISHASH( xDefault ) aParams := Array( Len( xDefault ) * 2 ) @@ -208,7 +208,7 @@ FUNCTION HB_Decode(...) // Check if value exists (valtype of values MUST be same of xVal, // otherwise I will get a runtime error) // TODO: Have I to check also between different valtypes, jumping different ? - nPos := aScan( aValues, {|e| e == xVal } ) + nPos := aScan( aValues, {| e | e == xVal } ) IF nPos == 0 // Not Found, returning default xRet := xDefault // it could be also nil because not present @@ -242,7 +242,7 @@ STATIC FUNCTION EmptyValue( xVal ) xRet := "" EXIT CASE "D" // Date - xRet := CTOD("") + xRet := CTOD( "" ) EXIT CASE "L" // Logical xRet := .F. @@ -257,7 +257,7 @@ STATIC FUNCTION EmptyValue( xVal ) xRet := {} EXIT CASE "H" // hash - xRet := {=>} + xRet := { => } EXIT CASE "U" // undefined xRet := NIL diff --git a/harbour/contrib/xhb/dumpvar.prg b/harbour/contrib/xhb/dumpvar.prg index ad4b5a8143..f86a1691a0 100644 --- a/harbour/contrib/xhb/dumpvar.prg +++ b/harbour/contrib/xhb/dumpvar.prg @@ -242,7 +242,7 @@ STATIC FUNCTION DShowHash( hVar, lRecursive, nIndent, nRecursionLevel, nMaxRecur //TraceLog( "DShowHash: hVar, ValType( hVar ), lRecursive", hVar, ValType( hVar ), ValToPrg( hVar ), lRecursive ) - IF ValType( hVar ) == "H" + IF HB_ISHASH( hVar ) nEolLen := Len( hb_eol() ) cString += Space( nIndent ) + "{" + hb_eol() FOR EACH xVal IN hVar diff --git a/harbour/contrib/xhb/hbcompat.ch b/harbour/contrib/xhb/hbcompat.ch index 759a9c2edf..1dc7dc195e 100644 --- a/harbour/contrib/xhb/hbcompat.ch +++ b/harbour/contrib/xhb/hbcompat.ch @@ -153,20 +153,20 @@ #xtranslate hb_mutexNotify() => Notify() #xtranslate hb_mutexNotifyAll() => NotifyAll() - #xtranslate hb_mutexSubscribe() => {|mtx, nTimeOut, xSubscribed| ;; + #xtranslate hb_mutexSubscribe() => {| mtx, nTimeOut, xSubscribed | ;; local lSubscribed ;; xSubscribed := Subscribe( mtx, ; - iif( hb_isNumeric( nTimeOut ), nTimeOut * 1000, ), ; + iif( HB_ISNUMERIC( nTimeOut ), nTimeOut * 1000, ), ; @lSubscribed ) ; return lSubscribed ; }:eval( ) - #xtranslate hb_mutexSubscribeNow() => {|mtx, nTimeOut, xSubscribed| ;; + #xtranslate hb_mutexSubscribeNow() => {| mtx, nTimeOut, xSubscribed | ;; local lSubscribed ;; xSubscribed := SubscribeNow( mtx, ; - iif( hb_isNumeric( nTimeOut ), nTimeOut * 1000, ), ; + iif( HB_ISNUMERIC( nTimeOut ), nTimeOut * 1000, ), ; @lSubscribed ) ; return lSubscribed ; }:eval( ) - #xtranslate hb_MutexLock( , ) => iif( !hb_isNumeric( ), hb_MutexLock( ) ; + #xtranslate hb_MutexLock( , ) => iif( ! HB_ISNUMERIC( ), hb_MutexLock( ) ; iif( <= 0, hb_MutexTryLock( ), ; hb_MutexTimeOutLock( , ) ) ) @@ -281,8 +281,8 @@ #xuntranslate NetName( => #xuntranslate MemoWrit( => - #xtranslate NetName() => iif( hb_isNumeric( ) .AND. == 1, hb_UserName(), NetName() ) - #xtranslate MemoWrit(,,) => iif( hb_isLogical() .AND. ! , hb_MemoWrit(,), MemoWrit(,) ) + #xtranslate NetName() => iif( HB_ISNUMERIC( ) .AND. == 1, hb_UserName(), NetName() ) + #xtranslate MemoWrit(,,) => iif( HB_ISLOGICAL( ) .AND. ! , hb_MemoWrit(,), MemoWrit(,) ) #xuntranslate AIns( => #xuntranslate ADel( => @@ -311,7 +311,7 @@ #xcommand FINALLY => ALWAYS /* EXTENDED CODEBLOCKs */ - #xtranslate \<|[]| => {|| + #xtranslate \<|[]| => {| | #xcommand > [<*x*>] => } /* xHarbour operators: IN, HAS, LIKE, >>, <<, |, &, ^^ */ @@ -421,26 +421,26 @@ #xtranslate DestroyMutex( ) => #xtranslate hb_MutexTryLock( ) => hb_mutexLock( , 0 ) #xtranslate hb_MutexTimeOutLock( ) => hb_mutexLock( , 0 ) - #xtranslate hb_MutexTimeOutLock( , ) => hb_mutexLock( , IIF( hb_isNumeric( ), / 1000, 0 ) ) + #xtranslate hb_MutexTimeOutLock( , ) => hb_mutexLock( , iif( HB_ISNUMERIC( ), / 1000, 0 ) ) #xtranslate Notify( ) => hb_mutexNotify( ) #xtranslate NotifyAll( ) => hb_mutexNotifyAll( ) - #xtranslate Subscribe( ) => {|mtx, nTimeOut, lSubscribed| ;; + #xtranslate Subscribe( ) => {| mtx, nTimeOut, lSubscribed | ;; local xSubscribed ;; lSubscribed := hb_mutexSubscribe( mtx, ; - iif( hb_isNumeric( nTimeOut ), nTimeOut / 1000, ), ; + iif( HB_ISNUMERIC( nTimeOut ), nTimeOut / 1000, ), ; @xSubscribed ) ; return xSubscribed ; }:eval( ) - #xtranslate SubscribeNow( ) => {|mtx, nTimeOut, lSubscribed| ;; + #xtranslate SubscribeNow( ) => {| mtx, nTimeOut, lSubscribed | ;; local xSubscribed ;; lSubscribed := hb_mutexSubscribeNow( mtx, ; - iif( hb_isNumeric( nTimeOut ), nTimeOut / 1000, ), ; + iif( HB_ISNUMERIC( nTimeOut ), nTimeOut / 1000, ), ; @xSubscribed ) ; return xSubscribed ; }:eval( ) #xtranslate StartThread( [] ) => hb_threadStart( ) - #xtranslate StartThread( , [, ] ) => iif( valtype( ) == "O" .and. hb_isString( ), ; - hb_threadStart( {|...| ():&()( ... ) } [, ] ), ; + #xtranslate StartThread( , [, ] ) => iif( HB_ISOBJECT( ) .AND. HB_ISSTRING( ), ; + hb_threadStart( {| ... | ():&()( ... ) } [, ] ), ; hb_threadStart( , [, ] ) ) /* not possible to well replicate xHarbour behavior because it's buggy @@ -501,16 +501,16 @@ #xtranslate HAAGETVALUEAT([]) => hb_HVALUEAT() #xtranslate HAADELAT([]) => hb_HDELAT() #xtranslate HAAGETPOS([]) => hb_HPOS() - #xtranslate HAAGETREALPOS(,) => iif( hb_isNumeric( ) .AND. >= 1 .AND. ; + #xtranslate HAAGETREALPOS(,) => iif( HB_ISNUMERIC( ) .AND. >= 1 .AND. ; int( ) <= len( ), int( ), 0 ) - #xtranslate HGETVAAPOS() => {|h| ;; + #xtranslate HGETVAAPOS() => {| h | ;; local a := array( len( h ), v ;; for each v in a ;; v := v:__enumIndex() ;; next ;; return a ; }:eval( ) #xtranslate HGETAACOMPATIBILITY() => hb_HKEEPORDER() - #xtranslate HSETAACOMPATIBILITY([]) => {|h| ;; + #xtranslate HSETAACOMPATIBILITY([]) => {| h | ;; hb_HKEEPORDER( h ) ;; return .T. ; }:eval( ) diff --git a/harbour/contrib/xhb/regexrpl.prg b/harbour/contrib/xhb/regexrpl.prg index a40567cf50..f590ab11bf 100644 --- a/harbour/contrib/xhb/regexrpl.prg +++ b/harbour/contrib/xhb/regexrpl.prg @@ -49,8 +49,6 @@ * */ -//--------------------------------------------------------------// - #define MATCH_STRING 1 #define MATCH_START 2 #define MATCH_END 3 @@ -61,16 +59,15 @@ FUNCTION hb_RegexReplace( cRegex, cString, cReplace, lCaseSensitive, lNewLine, n LOCAL cReturn LOCAL nOffSet := 0 LOCAL cSearch, nStart, nLenSearch, nLenReplace - //LOCAL nEnd aMatches := HB_RegExAll( cRegEx, cString, lCaseSensitive, lNewLine, nMaxMatches, nGetMatch, .F. ) cReturn := cString IF ! Empty( aMatches ) FOR EACH aMatch IN aMatches - IF ValType( aMatch ) == "A" .AND. Len( aMatch ) == 1 .AND. ; - ValType( aMatch[1] ) == "A" - aMatch := aMatch[1] + IF HB_ISARRAY( aMatch ) .AND. Len( aMatch ) == 1 .AND. ; + HB_ISARRAY( aMatch[ 1 ] ) + aMatch := aMatch[ 1 ] ENDIF IF Len( aMatch ) == 3 // if regex matches I must have an array of 3 elements cSearch := aMatch[ MATCH_STRING ] @@ -84,6 +81,4 @@ FUNCTION hb_RegexReplace( cRegex, cString, cReplace, lCaseSensitive, lNewLine, n ENDIF -RETURN cReturn - -//--------------------------------------------------------------// + RETURN cReturn