From 924db6f7ed8cc6587a4e95098da83307917a881c Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 11 Jun 2012 13:32:11 +0000 Subject: [PATCH] 2012-06-11 15:31 UTC+0200 Viktor Szakats (harbour syenar.net) * include/harbour.hbx * src/vm/dynsym.c + added HB_ISFUNCTION( ) -> uses Przemek's code from hbfship/ISFUNCTION() with minor adaptation for VM. Use it instead of __DYNSISFUN() and TYPE( ) == "UI". * include/harbour.hbx * formatted HB_IS*() functions used for type checking * contrib/hbfship/isfunc.c % converted ISFUNCTION() to wrapper for HB_ISFUNCTION() * contrib/hbide/ideplugins.prg * contrib/hbrun/hbrun.prg * contrib/hbxpp/xppop.prg * contrib/xhb/xhbcomp.prg * contrib/xhb/xhberr.prg * examples/hbdoc/hbdoc.prg % Using HB_ISFUNCTION() instead of __DYNSISFUN() and TYPE( ) == "UI" --- harbour/ChangeLog | 22 ++++++++++++++++ harbour/contrib/hbfship/isfunc.c | 14 +++------- harbour/contrib/hbide/ideplugins.prg | 2 +- harbour/contrib/hbrun/hbrun.prg | 2 +- harbour/contrib/hbxpp/xppop.prg | 2 +- harbour/contrib/xhb/xhbcomp.prg | 2 +- harbour/contrib/xhb/xhberr.prg | 16 ++++++------ harbour/examples/hbdoc/hbdoc.prg | 2 +- harbour/include/harbour.hbx | 39 ++++++++++++++-------------- harbour/src/vm/dynsym.c | 21 +++++++++++++-- 10 files changed, 77 insertions(+), 45 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 82df559dbd..1a3f7737db 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,28 @@ The license applies to all entries newer than 2009-04-28. */ +2012-06-11 15:31 UTC+0200 Viktor Szakats (harbour syenar.net) + * include/harbour.hbx + * src/vm/dynsym.c + + added HB_ISFUNCTION( ) -> + uses Przemek's code from hbfship/ISFUNCTION() with minor + adaptation for VM. + Use it instead of __DYNSISFUN() and TYPE( ) == "UI". + + * include/harbour.hbx + * formatted HB_IS*() functions used for type checking + + * contrib/hbfship/isfunc.c + % converted ISFUNCTION() to wrapper for HB_ISFUNCTION() + + * contrib/hbide/ideplugins.prg + * contrib/hbrun/hbrun.prg + * contrib/hbxpp/xppop.prg + * contrib/xhb/xhbcomp.prg + * contrib/xhb/xhberr.prg + * examples/hbdoc/hbdoc.prg + % Using HB_ISFUNCTION() instead of __DYNSISFUN() and TYPE( ) == "UI" + 2012-06-11 14:14 UTC+0200 Viktor Szakats (harbour syenar.net) * bin/hbcommit.hb + To configure your own name and e-mail address used diff --git a/harbour/contrib/hbfship/isfunc.c b/harbour/contrib/hbfship/isfunc.c index 9fbac952f1..7ca325d79c 100644 --- a/harbour/contrib/hbfship/isfunc.c +++ b/harbour/contrib/hbfship/isfunc.c @@ -55,17 +55,9 @@ #include "hbapi.h" +HB_FUNC_EXTERN( HB_ISFUNCTION ); + HB_FUNC( ISFUNCTION ) { - const char * szProc = hb_parc( 1 ); - HB_BOOL fResult = HB_FALSE; - - if( szProc ) - { - PHB_DYNS pDynSym = hb_dynsymFindName( szProc ); - if( pDynSym ) - fResult = hb_dynsymIsFunction( pDynSym ); - } - - hb_retl( fResult ); + HB_FUNC_EXEC( HB_ISFUNCTION ); } diff --git a/harbour/contrib/hbide/ideplugins.prg b/harbour/contrib/hbide/ideplugins.prg index 9f57ea1e17..7afedb1253 100644 --- a/harbour/contrib/hbide/ideplugins.prg +++ b/harbour/contrib/hbide/ideplugins.prg @@ -309,7 +309,7 @@ FUNCTION hbide_loadPersistentScripts() FUNCTION hbide_execScriptFunction( cFunc, ... ) - IF type( "script_" + cFunc + "()" ) == "UI" + IF hb_IsFunction( "script_" + cFunc ) RETURN eval( &( "{|...| " + "script_" + cFunc + "( ... )" + "}" ), ... ) ENDIF diff --git a/harbour/contrib/hbrun/hbrun.prg b/harbour/contrib/hbrun/hbrun.prg index 70503dc0e4..b6c35db523 100644 --- a/harbour/contrib/hbrun/hbrun.prg +++ b/harbour/contrib/hbrun/hbrun.prg @@ -275,7 +275,7 @@ STATIC PROCEDURE hbrun_extensionlist_init( aDynamic ) STATIC s_lInit := .F. IF ! s_lInit - IF Type( "__hbrun_extensions_static_init()" ) == "UI" + IF hb_IsFunction( "__hbrun_extensions_static_init" ) Do( "__hbrun_extensions_static_init" ) ENDIF __hbrun_extensions_dynamic_init( aDynamic ) diff --git a/harbour/contrib/hbxpp/xppop.prg b/harbour/contrib/hbxpp/xppop.prg index 8451040697..0d6f2451e9 100644 --- a/harbour/contrib/hbxpp/xppop.prg +++ b/harbour/contrib/hbxpp/xppop.prg @@ -58,7 +58,7 @@ ANNOUNCE XPP_OP_OVERLOAD * It should not be used in user code. [druzus] */ #xcommand OPTIONAL INHERIT => ; - IF Type( <"className">+"()" ) == "UI" ;; + IF hb_IsFunction( <"className"> ) ;; AAdd( oClass:asSuper, @__() ) ;; ENDIF diff --git a/harbour/contrib/xhb/xhbcomp.prg b/harbour/contrib/xhb/xhbcomp.prg index 725c266de5..1e0b0418d6 100644 --- a/harbour/contrib/xhb/xhbcomp.prg +++ b/harbour/contrib/xhb/xhbcomp.prg @@ -60,7 +60,7 @@ ANNOUNCE XHB_LIB * It should not be used in user code. [druzus] */ #xcommand OPTIONAL INHERIT => ; - IF Type( <"className">+"()" ) == "UI" ;; + IF hb_IsFunction( <"className"> ) ;; AAdd( oClass:asSuper, @__() ) ;; ENDIF diff --git a/harbour/contrib/xhb/xhberr.prg b/harbour/contrib/xhb/xhberr.prg index f40bd5e78c..052606164a 100644 --- a/harbour/contrib/xhb/xhberr.prg +++ b/harbour/contrib/xhb/xhberr.prg @@ -358,7 +358,7 @@ STATIC FUNCTION LogError( oerr ) FWriteLine( nHandle, "Multi Threading....: " + If( hb_mtvm(),"YES","NO" ) ) FWriteLine( nHandle, "VM Optimization....: " + strvalue( Hb_VmMode() ) ) - IF __dynsIsFun( "Select" ) + IF hb_IsFunction( "Select" ) FWriteLine( nHandle, "" ) FWriteLine( nHandle, "Current Area ......:" + strvalue( &("Select()") ) ) ENDIF @@ -476,25 +476,25 @@ STATIC FUNCTION LogError( oerr ) FWriteLine( nHandle, "" ) HB_WAEval( {|| - IF __dynsIsFun( "Select" ) + IF hb_IsFunction( "Select" ) FWriteLine( nHandle, "Work Area No ......: " + strvalue( &("Select()") ) ) ENDIF - IF __dynsIsFun( "Alias" ) + IF hb_IsFunction( "Alias" ) FWriteLine( nHandle, "Alias .............: " + &("Alias()") ) ENDIF - IF __dynsIsFun( "RecNo" ) + IF hb_IsFunction( "RecNo" ) FWriteLine( nHandle, "Current Recno .....: " + strvalue( &("RecNo()") ) ) ENDIF - IF __dynsIsFun( "DbFilter" ) + IF hb_IsFunction( "DbFilter" ) FWriteLine( nHandle, "Current Filter ....: " + &("DbFilter()") ) ENDIF - IF __dynsIsFun( "DbRelation" ) + IF hb_IsFunction( "DbRelation" ) FWriteLine( nHandle, "Relation Exp. .....: " + &("DbRelation()") ) ENDIF - IF __dynsIsFun( "IndexOrd" ) + IF hb_IsFunction( "IndexOrd" ) FWriteLine( nHandle, "Index Order .......: " + strvalue( &("IndexOrd(0)") ) ) ENDIF - IF __dynsIsFun( "IndexKey" ) + IF hb_IsFunction( "IndexKey" ) FWriteLine( nHandle, "Active Key ........: " + strvalue( &("IndexKey(0)") ) ) ENDIF FWriteLine( nHandle, "" ) diff --git a/harbour/examples/hbdoc/hbdoc.prg b/harbour/examples/hbdoc/hbdoc.prg index 96ede63297..43849af158 100644 --- a/harbour/examples/hbdoc/hbdoc.prg +++ b/harbour/examples/hbdoc/hbdoc.prg @@ -146,7 +146,7 @@ PROCEDURE Main( ... ) FOR idx := Len( p_hsSwitches[ "format-list" ] ) TO 1 STEP -1 IF p_hsSwitches[ "format-list" ][ idx ] == "all" - ELSEIF Type( "Generate" + p_hsSwitches[ "format-list" ][ idx ] + "()" ) != "UI" + ELSEIF hb_IsFunction( "Generate" + p_hsSwitches[ "format-list" ][ idx ] ) ASize( ADel( p_hsSwitches[ "format-list" ], idx), Len( p_hsSwitches[ "format-list" ] ) - 1 ) ENDIF NEXT diff --git a/harbour/include/harbour.hbx b/harbour/include/harbour.hbx index b42bc47ba6..f82b82ca4e 100644 --- a/harbour/include/harbour.hbx +++ b/harbour/include/harbour.hbx @@ -607,25 +607,26 @@ DYNAMIC hb_iniReadStr DYNAMIC hb_iniSetComment DYNAMIC hb_iniWrite DYNAMIC hb_iniWriteStr -DYNAMIC hb_isArray -DYNAMIC hb_isBlock -DYNAMIC hb_isChar -DYNAMIC hb_isDate -DYNAMIC hb_isDateTime -DYNAMIC hb_isHash -DYNAMIC hb_isHashKey -DYNAMIC hb_isLogical -DYNAMIC hb_isMemo -DYNAMIC hb_isNil -DYNAMIC hb_isNull -DYNAMIC hb_isNumeric -DYNAMIC hb_isObject -DYNAMIC hb_isPointer -DYNAMIC hb_isPrinter -DYNAMIC hb_isRegex -DYNAMIC hb_isString -DYNAMIC hb_isSymbol -DYNAMIC hb_isTimeStamp +DYNAMIC HB_ISARRAY +DYNAMIC HB_ISBLOCK +DYNAMIC HB_ISCHAR +DYNAMIC HB_ISDATE +DYNAMIC HB_ISDATETIME +DYNAMIC hb_IsFunction +DYNAMIC HB_ISHASH +DYNAMIC HB_ISHASHKEY +DYNAMIC HB_ISLOGICAL +DYNAMIC HB_ISMEMO +DYNAMIC HB_ISNIL +DYNAMIC HB_ISNULL +DYNAMIC HB_ISNUMERIC +DYNAMIC HB_ISOBJECT +DYNAMIC HB_ISPOINTER +DYNAMIC hb_IsPrinter +DYNAMIC hb_IsRegex +DYNAMIC HB_ISSTRING +DYNAMIC HB_ISSYMBOL +DYNAMIC HB_ISTIMESTAMP DYNAMIC hb_jsonDecode DYNAMIC hb_jsonEncode DYNAMIC hb_keyChar diff --git a/harbour/src/vm/dynsym.c b/harbour/src/vm/dynsym.c index 9facaacb76..96c8040a31 100644 --- a/harbour/src/vm/dynsym.c +++ b/harbour/src/vm/dynsym.c @@ -695,8 +695,25 @@ HB_FUNC( __DYNSGETINDEX ) /* Gimme index number of symbol: dsIndex = __dynsymGet hb_retnint( uiPos ); } -HB_FUNC( __DYNSISFUN ) /* returns .t. if a symbol has a function/procedure pointer, - given its symbol index */ +HB_FUNC( HB_ISFUNCTION ) /* returns .T. if a symbol has a function/procedure pointer, + given its name */ +{ + HB_STACK_TLS_PRELOAD + const char * szProc = hb_parc( 1 ); + HB_BOOL fResult = HB_FALSE; + + if( szProc ) + { + PHB_DYNS pDynSym = hb_dynsymFindName( szProc ); + if( pDynSym ) + fResult = hb_dynsymIsFunction( pDynSym ); + } + + hb_retl( fResult ); +} + +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 );