diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 35d6e0c525..847dc0076f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,12 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-05-09 20:11 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * contrib/hbide/hbide.prg + * contrib/hbide/ideplugins.prg + % Changed: plugins are loaded on first call instead of + loading all plugins at startup. Now the overhead is negligible. + 2010-05-09 17:21 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + contrib/hbide/plugins + contrib/hbide/plugins/savebackup.hrb diff --git a/harbour/contrib/hbide/hbide.prg b/harbour/contrib/hbide/hbide.prg index 731758e562..09e135690c 100644 --- a/harbour/contrib/hbide/hbide.prg +++ b/harbour/contrib/hbide/hbide.prg @@ -490,7 +490,7 @@ METHOD HbIde:create( aParams ) /* Load tags last tagged projects */ ::oFN:loadTags( ::aINI[ INI_TAGGEDPROJECTS ] ) - hbide_loadPlugins() + /* hbide_loadPlugins() */ DO WHILE .t. ::nEvent := AppEvent( @::mp1, @::mp2, @::oXbp ) diff --git a/harbour/contrib/hbide/ideplugins.prg b/harbour/contrib/hbide/ideplugins.prg index cf844d407e..54e69f8e03 100644 --- a/harbour/contrib/hbide/ideplugins.prg +++ b/harbour/contrib/hbide/ideplugins.prg @@ -73,6 +73,7 @@ /*----------------------------------------------------------------------*/ STATIC s_aPlugins := { { "", NIL } } +STATIC s_aLoaded := { { "", .f. } } /*----------------------------------------------------------------------*/ @@ -99,17 +100,48 @@ FUNCTION hbide_loadPlugins() /*----------------------------------------------------------------------*/ -FUNCTION hbide_execPlugin( cPlugin, oAPI, ... ) - LOCAL n +FUNCTION hbide_loadAPlugin( cPlugin ) + LOCAL cPath, pHrb, bBlock, lLoaded - IF empty( cPlugin ) - RETURN NIL + cPath := hb_dirBase() + hb_osPathSeparator() + "plugins" + hb_osPathSeparator() + cPlugin + ".hrb" + + IF ( lLoaded := hb_fileExists( cPath ) ) + pHrb := hb_hrbLoad( HB_HRB_BIND_OVERLOAD, cPath ) + + IF ! Empty( pHrb ) .AND. ! Empty( hb_hrbGetFunSym( pHrb, cPlugin + "_init" ) ) + bBlock := &( "{|...| " + cPlugin + "_init(...) }" ) + + IF eval( bBlock, "1.0" ) + + IF ! Empty( hb_hrbGetFunSym( pHrb, cPlugin + "_exec" ) ) + aadd( s_aPlugins, { cPlugin, &( "{|...| " + cPlugin + "_exec(...) }" ), pHrb } ) + lLoaded := .t. + + ENDIF + ENDIF + ENDIF ENDIF + aadd( s_aLoaded, { cPlugin, lLoaded } ) + + RETURN lLoaded + +/*----------------------------------------------------------------------*/ + +FUNCTION hbide_execPlugin( cPlugin, oAPI, ... ) + LOCAL n, lLoaded + cPlugin := lower( cPlugin ) - IF ( n := ascan( s_aPlugins, {|e_| e_[ 1 ] == cPlugin } ) ) > 0 - RETURN eval( s_aPlugins[ n, 2 ], oAPI, ... ) + IF ( n := ascan( s_aLoaded, {|e_| e_[ 1 ] == cPlugin } ) ) == 0 + lLoaded := hbide_loadAPlugin( cPlugin ) + ELSE + lLoaded := s_aLoaded[ n,2 ] + ENDIF + IF lLoaded + IF ( n := ascan( s_aPlugins, {|e_| e_[ 1 ] == cPlugin } ) ) > 0 + RETURN eval( s_aPlugins[ n, 2 ], oAPI, ... ) + ENDIF ENDIF RETURN NIL