static void hb_hrbExit( PHRB_BODY pHrbBody ) { if( pHrbBody->fExit ) { if( hb_vmRequestReenter() ) { HB_ULONG ul; pHrbBody->fExit = HB_FALSE; pHrbBody->fInit = HB_TRUE; for( ul = 0; ul < pHrbBody->ulSymbols; ul++ ) { if( ( pHrbBody->pSymRead[ ul ].scope.value & HB_FS_INITEXIT ) == HB_FS_EXIT ) { hb_vmPushSymbol( pHrbBody->pSymRead + ul ); hb_vmPushNil(); hb_vmProc( 0 ); if( hb_vmRequestQuery() != 0 ) break; } } hb_vmRequestRestore(); } } }
static void hb_hrbDo( PHRB_BODY pHrbBody, int iPCount, PHB_ITEM * pParams ) { PHB_ITEM pRetVal = NULL; int i; hb_hrbInit( pHrbBody, iPCount, pParams ); /* May not have a startup symbol, if first symbol was an INIT Symbol (was executed already). */ if( pHrbBody->lSymStart >= 0 && hb_vmRequestQuery() == 0 ) { hb_vmPushSymbol( &pHrbBody->pSymRead[ pHrbBody->lSymStart ] ); hb_vmPushNil(); for( i = 0; i < iPCount; i++ ) hb_vmPush( pParams[ i ] ); hb_vmProc( ( HB_USHORT ) iPCount ); pRetVal = hb_itemNew( NULL ); hb_itemMove( pRetVal, hb_stackReturnItem() ); } if( pRetVal ) hb_itemReturnRelease( pRetVal ); }
static void hb_hrbInitStatic( PHRB_BODY pHrbBody ) { if( ! pHrbBody->fInit && ! pHrbBody->fExit ) { HB_ULONG ul; pHrbBody->fInit = HB_TRUE; /* Initialize static variables first */ for( ul = 0; ul < pHrbBody->ulSymbols; ul++ ) /* Check _INITSTATICS functions */ { if( ( pHrbBody->pSymRead[ ul ].scope.value & HB_FS_INITEXIT ) == HB_FS_INITEXIT ) { /* call (_INITSTATICS) function. This function assigns * literal values to static variables only. There is no need * to pass any parameters to this function because they * cannot be used to initialize static variable. */ /* changed to call VM execution instead of direct function address call * pHrbBody->pSymRead[ ul ].value.pFunPtr(); * [MLombardo] */ hb_vmPushSymbol( &( pHrbBody->pSymRead[ ul ] ) ); hb_vmPushNil(); hb_vmProc( 0 ); } } } }
PHB_ITEM hb_itemDoC( const char * szFunc, HB_ULONG ulPCount, ... ) { PHB_ITEM pResult = NULL; HB_TRACE( HB_TR_DEBUG, ( "hb_itemDoC(%s, %lu, ...)", szFunc, ulPCount ) ); if( szFunc ) { PHB_DYNS pDynSym = hb_dynsymFindName( szFunc ); if( pDynSym ) { if( hb_vmRequestReenter() ) { hb_vmPushSymbol( pDynSym->pSymbol ); hb_vmPushNil(); if( ulPCount ) { HB_ULONG ulParam; va_list va; va_start( va, ulPCount ); for( ulParam = 1; ulParam <= ulPCount; ulParam++ ) hb_vmPush( va_arg( va, PHB_ITEM ) ); va_end( va ); } hb_vmProc( ( HB_USHORT ) ulPCount ); pResult = hb_itemNew( hb_stackReturnItem() ); hb_vmRequestRestore(); } } } return pResult; }
PHB_ITEM hb_evalLaunch( PHB_EVALINFO pEvalInfo ) { PHB_ITEM pResult = NULL; HB_TRACE( HB_TR_DEBUG, ( "hb_evalLaunch(%p)", pEvalInfo ) ); if( pEvalInfo ) { PHB_ITEM pItem = pEvalInfo->pItems[ 0 ]; PHB_SYMB pSymbol = NULL; if( HB_IS_STRING( pItem ) ) { PHB_DYNS pDynSym = hb_dynsymFindName( pItem->item.asString.value ); if( pDynSym ) { pSymbol = pDynSym->pSymbol; pItem = NULL; } } else if( HB_IS_SYMBOL( pItem ) ) { pSymbol = pItem->item.asSymbol.value; pItem = NULL; } else if( HB_IS_BLOCK( pItem ) ) { pSymbol = &hb_symEval; } if( pSymbol ) { HB_USHORT uiParam = 0; hb_vmPushSymbol( pSymbol ); if( pItem ) hb_vmPush( pItem ); else hb_vmPushNil(); while( uiParam < pEvalInfo->paramCount ) hb_vmPush( pEvalInfo->pItems[ ++uiParam ] ); if( pItem ) hb_vmSend( uiParam ); else hb_vmProc( uiParam ); pResult = hb_itemNew( hb_stackReturnItem() ); } } return pResult; }
static void hb_hrbInit( PHRB_BODY pHrbBody, int iPCount, PHB_ITEM * pParams ) { if( pHrbBody->fInit ) { if( hb_vmRequestReenter() ) { HB_ULONG ul; HB_BOOL fRepeat, fClipInit = HB_TRUE; int i; pHrbBody->fInit = HB_FALSE; pHrbBody->fExit = HB_TRUE; do { fRepeat = HB_FALSE; ul = pHrbBody->ulSymbols; while( ul-- ) { /* Check INIT functions */ if( ( pHrbBody->pSymRead[ ul ].scope.value & HB_FS_INITEXIT ) == HB_FS_INIT ) { if( strcmp( pHrbBody->pSymRead[ ul ].szName, "CLIPINIT$" ) ? ! fClipInit : fClipInit ) { hb_vmPushSymbol( pHrbBody->pSymRead + ul ); hb_vmPushNil(); for( i = 0; i < iPCount; i++ ) hb_vmPush( pParams[ i ] ); hb_vmProc( ( HB_USHORT ) iPCount ); if( hb_vmRequestQuery() != 0 ) break; } else if( fClipInit ) fRepeat = HB_TRUE; } } fClipInit = HB_FALSE; } while( fRepeat && hb_vmRequestQuery() == 0 ); hb_vmRequestRestore(); } } }
static HRESULT STDMETHODCALLTYPE classCreateInstance( IClassFactory * lpThis, IUnknown * punkOuter, REFIID riid, void ** ppvObj ) { HRESULT hr; HB_SYMBOL_UNUSED( lpThis ); *ppvObj = NULL; if( punkOuter ) hr = CLASS_E_NOAGGREGATION; else { PHB_ITEM pAction = NULL; HB_BOOL fGuids = HB_FALSE; if( s_pAction ) { if( HB_IS_EVALITEM( s_pAction ) ) { if( hb_vmRequestReenter() ) { hb_vmPushEvalSym(); hb_vmPush( s_pAction ); hb_vmProc( 0 ); pAction = hb_itemNew( hb_stackReturnItem() ); hb_vmRequestRestore(); } } else if( HB_IS_HASH( s_pAction ) ) { if( s_fHashClone ) pAction = hb_itemClone( s_pAction ); else if( ! s_pMsgHash && s_hashWithNumKeys( s_pAction ) ) fGuids = HB_TRUE; } } hr = s_createHbOleObject( riid, ppvObj, pAction, fGuids ); } return hr; }
static void hb_pp_StdRules( PHB_ITEM ppItem ) { static HB_BOOL s_fInit = HB_TRUE; static PHB_DYNS s_pDynSym; if( s_fInit ) { s_pDynSym = hb_dynsymFind( "__PP_STDRULES" ); s_fInit = HB_FALSE; } if( s_pDynSym ) { hb_vmPushDynSym( s_pDynSym ); hb_vmPushNil(); hb_vmPush( ppItem ); hb_vmProc( 1 ); } }
HB_USHORT hbgi_hb_clsNew(const char *szClassName, int nDatas, PHB_ITEM pSuperArray) { if (!s_pDyns__CLSNEW) { hbgihb_init(NULL); } hb_vmPushDynSym(s_pDyns__CLSNEW); hb_vmPushNil(); hb_vmPushString(szClassName, strlen(szClassName)); hb_vmPushNumInt(nDatas); if (!pSuperArray) { hb_vmPushNil(); } else { hb_vmPush(pSuperArray); } hb_vmProc(3); return hb_itemGetNI(hb_stackReturnItem()); }
static void hbgi_hb_clsAddMsgNative(HB_USHORT uiClass, const char *szMessage, HB_USHORT uiType, HB_USHORT uiScope, PHB_ITEM pFuncOrOffset, PHB_ITEM pInit) { PHB_ITEM pInitCopy; HB_BOOL allocated = !pInit; pInitCopy = allocated ? hb_itemNew(NULL) : pInit; if (!s_pDyns__CLSADDMSG) { hbgihb_init(NULL); } hb_vmPushDynSym(s_pDyns__CLSADDMSG); hb_vmPushNil(); hb_vmPushNumInt(uiClass); hb_vmPushString(szMessage, strlen(szMessage)); hb_vmPush(pFuncOrOffset); hb_vmPushNumInt(uiType); hb_vmPush(pInitCopy); hb_vmPushNumInt(uiScope); hb_vmProc(6); if (allocated) { hb_itemRelease(pInitCopy); } }
BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, PVOID pvReserved ) #endif { static HB_BOOL s_fInit = HB_FALSE; BOOL fResult = TRUE; HB_SYMBOL_UNUSED( pvReserved ); switch( dwReason ) { case DLL_PROCESS_ATTACH: s_hInstDll = ( HINSTANCE ) hInstance; s_lLockCount = s_lObjectCount = 0; s_IClassFactoryObj.lpVtbl = ( IClassFactoryVtbl * ) &IClassFactory_Vtbl; DisableThreadLibraryCalls( ( HMODULE ) hInstance ); s_fInit = ! hb_vmIsActive(); if( s_fInit ) hb_vmInit( HB_FALSE ); hb_oleInit(); if( ! s_fServerReady ) { PHB_DYNS pDynSym = hb_dynsymFind( "DLLMAIN" ); if( pDynSym && hb_dynsymIsFunction( pDynSym ) && hb_vmRequestReenter() ) { hb_vmPushDynSym( pDynSym ); hb_vmPushNil(); hb_vmProc( 0 ); hb_vmRequestRestore(); } } fResult = s_fServerReady ? TRUE : FALSE; break; case DLL_PROCESS_DETACH: s_fServerReady = HB_FALSE; if( s_pAction ) { hb_itemRelease( s_pAction ); s_pAction = NULL; } if( s_pMsgHash ) { hb_itemRelease( s_pMsgHash ); s_pMsgHash = NULL; } if( s_fInit ) { hb_vmQuit(); s_fInit = HB_FALSE; } break; } return fResult; }
HB_BOOL hb_execFromArray( PHB_ITEM pParam ) { PHB_ITEM pArray = NULL; PHB_ITEM pSelf = NULL; HB_ULONG ulParamOffset = 0; if( pParam && HB_IS_ARRAY( pParam ) && ! HB_IS_OBJECT( pParam ) ) { pArray = pParam; pParam = hb_arrayGetItemPtr( pArray, 1 ); if( HB_IS_OBJECT( pParam ) ) { pSelf = pParam; pParam = hb_arrayGetItemPtr( pArray, 2 ); ulParamOffset = 2; } else ulParamOffset = 1; } if( pParam ) { PHB_SYMB pExecSym = NULL; if( HB_IS_SYMBOL( pParam ) ) pExecSym = hb_itemGetSymbol( pParam ); else if( HB_IS_STRING( pParam ) ) pExecSym = hb_dynsymGet( hb_itemGetCPtr( pParam ) )->pSymbol; else if( HB_IS_BLOCK( pParam ) && ! pSelf ) { pSelf = pParam; pExecSym = &hb_symEval; } if( pExecSym ) { int iPCount = 0; hb_vmPushSymbol( pExecSym ); if( pSelf ) hb_vmPush( pSelf ); else hb_vmPushNil(); if( pArray ) { pParam = hb_arrayGetItemPtr( pArray, ++ulParamOffset ); while( pParam && iPCount < 255 ) { hb_vmPush( pParam ); ++iPCount; pParam = hb_arrayGetItemPtr( pArray, ++ulParamOffset ); } } if( pSelf ) hb_vmSend( ( HB_USHORT ) iPCount ); else hb_vmProc( ( HB_USHORT ) iPCount ); return HB_TRUE; } } hb_errRT_BASE_SubstR( EG_ARG, 1099, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); return HB_FALSE; }
PHB_ITEM hb_itemDo( PHB_ITEM pItem, HB_ULONG ulPCount, ... ) { PHB_ITEM pResult = NULL; HB_TRACE( HB_TR_DEBUG, ( "hb_itemDo(%p, %lu, ...)", pItem, ulPCount ) ); if( pItem ) { PHB_SYMB pSymbol = NULL; if( HB_IS_STRING( pItem ) ) { PHB_DYNS pDynSym = hb_dynsymFindName( pItem->item.asString.value ); if( pDynSym ) { pSymbol = pDynSym->pSymbol; pItem = NULL; } } else if( HB_IS_SYMBOL( pItem ) ) { pSymbol = pItem->item.asSymbol.value; pItem = NULL; } else if( HB_IS_BLOCK( pItem ) ) { pSymbol = &hb_symEval; } if( pSymbol ) { if( hb_vmRequestReenter() ) { hb_vmPushSymbol( pSymbol ); if( pItem ) hb_vmPush( pItem ); else hb_vmPushNil(); if( ulPCount ) { HB_ULONG ulParam; va_list va; va_start( va, ulPCount ); for( ulParam = 1; ulParam <= ulPCount; ulParam++ ) hb_vmPush( va_arg( va, PHB_ITEM ) ); va_end( va ); } if( pItem ) hb_vmSend( ( HB_USHORT ) ulPCount ); else hb_vmProc( ( HB_USHORT ) ulPCount ); pResult = hb_itemNew( hb_stackReturnItem() ); hb_vmRequestRestore(); } } } return pResult; }