//------------------------------------------------------------------------------ static void HB_EXPORT hb_itemPushList( ULONG ulRefMask, ULONG ulPCount, PHB_ITEM** pItems ) { PHB_ITEM itmRef; ULONG ulParam; if( ulPCount ) { itmRef = hb_itemNew( NULL ); // initialize the reference item itmRef->type = HB_IT_BYREF; itmRef->item.asRefer.offset = -1; itmRef->item.asRefer.BasePtr.itemsbasePtr = pItems; for( ulParam = 0; ulParam < ulPCount; ulParam++ ) { if( ulRefMask & ( 1L << ulParam ) ) { // when item is passed by reference then we have to put // the reference on the stack instead of the item itself itmRef->item.asRefer.value = ulParam+1; hb_vmPush( itmRef ); } else { hb_vmPush( (*pItems)[ulParam] ); } } hb_itemRelease( itmRef ); } }
static void sax_cb( mxml_node_t * node, mxml_sax_event_t event, void * data ) { HB_CBS_VAR * pCbs = ( HB_CBS_VAR * ) hb_stackTestTSD( &s_cbs_var ); if( node != NULL && pCbs != NULL ) { PHB_ITEM pCallback = pCbs->sax_cb; if( pCallback && hb_vmRequestReenter() ) { HB_USHORT uPCount = 2; hb_vmPushEvalSym(); hb_vmPush( pCallback ); mxml_node_push( node, 0 ); hb_vmPushInteger( ( int ) ( event + 1 ) ); if( data != NULL ) { hb_vmPush( ( PHB_ITEM ) data ); uPCount++; } hb_vmSend( uPCount ); hb_vmRequestRestore(); } } }
/* undocumented Clipper _cEval1() */ void hb_evalBlock1( PHB_ITEM pCodeBlock, PHB_ITEM pParam ) { hb_vmPushEvalSym(); hb_vmPush( pCodeBlock ); hb_vmPush( pParam ); hb_vmSend( 1 ); }
/* undocumented Clipper _cEval1() */ void hb_evalBlock1( PHB_ITEM pCodeBlock, PHB_ITEM pParam ) { hb_vmPushSymbol( &hb_symEval ); hb_vmPush( pCodeBlock ); hb_vmPush( pParam ); hb_vmSend( 1 ); }
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 hbqt_SlotsExecQAudioBuffer( PHB_ITEM * codeBlock, void ** arguments, QStringList pList ) { Q_UNUSED( pList ); PHB_ITEM p0 = hbqt_bindGetHbObject( NULL, new QAudioBuffer( ( *reinterpret_cast< QAudioBuffer( * ) >( arguments[ 1 ] ) ) ), "HB_QAUDIOBUFFER", hbqt_del_QAudioBuffer, HBQT_BIT_OWNER ); if( p0 ) { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); hb_vmPush( p0 ); hb_vmSend( 1 ); hb_itemRelease( p0 ); } }
static void hbqt_SlotsExecQVideoFrame( PHB_ITEM * codeBlock, void ** arguments, QStringList pList ) { Q_UNUSED( pList ); PHB_ITEM p0 = hbqt_bindGetHbObject( NULL, new QVideoFrame( ( *reinterpret_cast< QVideoFrame( * ) >( arguments[ 1 ] ) ) ), "HB_QVIDEOFRAME", hbqt_del_QVideoFrame, HBQT_BIT_OWNER ); if( p0 ) { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); hb_vmPush( p0 ); hb_vmSend( 1 ); hb_itemRelease( p0 ); } }
static HB_BOOL s_fileConfigure( PHB_FILE pFile, int iIndex, PHB_ITEM pValue ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFile->pFuncs; s_pushMethod( pIO, IOUSR_CONFIGURE ); hb_vmPush( pFile->pFileItm ); hb_vmPushInteger( iIndex ); if( pValue != NULL ) hb_vmPush( pValue ); hb_vmDo( pValue != NULL ? 3 : 2 ); return hb_parl( -1 ); }
static void hbqt_SlotsExecQMediaContent( PHB_ITEM * codeBlock, void ** arguments, QStringList pList ) { Q_UNUSED( pList ); PHB_ITEM p0 = hbqt_bindGetHbObject( NULL, new QMediaContent( ( *reinterpret_cast< QMediaContent( * ) >( arguments[ 1 ] ) ) ), "HB_QMEDIACONTENT", hbqt_del_QMediaContent, HBQT_BIT_OWNER ); if( p0 ) { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); hb_vmPush( p0 ); hb_vmSend( 1 ); hb_itemRelease( p0 ); } }
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; }
static mxml_type_t type_cb( mxml_node_t * node ) { HB_CBS_VAR * pCbs = ( HB_CBS_VAR * ) hb_stackTestTSD( &s_cbs_var ); if( pCbs != NULL ) { PHB_ITEM pCallback = pCbs->type_cb; if( pCallback && hb_vmRequestReenter() ) { int iResult; hb_vmPushEvalSym(); hb_vmPush( pCallback ); mxml_node_push( node, 0 ); hb_vmSend( 1 ); iResult = hb_parnidef( -1, MXML_TEXT ); hb_vmRequestRestore(); return ( mxml_type_t ) iResult; } } return MXML_TEXT; }
static char * custom_save_cb( mxml_node_t * node ) { HB_CUSTOM_CBS_VAR * pCCbs = ( HB_CUSTOM_CBS_VAR * ) hb_stackTestTSD( &s_custom_cbs_var ); if( node != NULL && pCCbs != NULL ) { PHB_ITEM pCallback = pCCbs->save_cb; if( pCallback && hb_vmRequestReenter() ) { char * pszResult; const char * pszText; void * hText; hb_vmPushEvalSym(); hb_vmPush( pCallback ); mxml_node_push( node, 0 ); hb_vmSend( 1 ); pszText = hb_parstr_utf8( -1, &hText, NULL ); pszResult = pszText ? strdup( pszText ) : NULL; hb_strfree( hText ); hb_vmRequestRestore(); return pszResult; } } return NULL; }
static int custom_load_cb( mxml_node_t * node, const char * data ) { HB_CUSTOM_CBS_VAR * pCCbs = ( HB_CUSTOM_CBS_VAR * ) hb_stackTestTSD( &s_custom_cbs_var ); if( node != NULL && pCCbs != NULL && data != NULL ) { PHB_ITEM pCallback = pCCbs->load_cb; if( pCallback && hb_vmRequestReenter() ) { int iResult; hb_vmPushEvalSym(); hb_vmPush( pCallback ); mxml_node_push( node, 0 ); hb_itemPutC( hb_stackAllocItem(), data ); hb_vmSend( 2 ); iResult = hb_parnidef( -1, 1 ); hb_vmRequestRestore(); return iResult; } } return 1; }
static const char * save_cb( mxml_node_t * node, int where ) { HB_CBS_VAR * pCbs = ( HB_CBS_VAR * ) hb_stackTestTSD( &s_cbs_var ); if( node != NULL && pCbs != NULL ) { PHB_ITEM pCallback = pCbs->save_cb; if( pCbs->hText ) { hb_strfree( pCbs->hText ); pCbs->hText = NULL; } if( pCallback && hb_vmRequestReenter() ) { const char * pszResult; hb_vmPushEvalSym(); hb_vmPush( pCallback ); mxml_node_push( node, 0 ); hb_vmPushInteger( where ); hb_vmSend( 2 ); pszResult = hb_itemGetStrUTF8( hb_param( -1, HB_IT_ANY ), &pCbs->hText, NULL ); hb_vmRequestRestore(); return pszResult; } } return NULL; }
LRESULT CALLBACK ControlWindowProcedure( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { PHB_ITEM pBlock = ( PHB_ITEM ) GetProp( hwnd, TEXT( "BLOCKCALLBACK" ) ); long lRet; if( pBlock ) { if( hb_itemType( pBlock ) == HB_IT_POINTER ) { hb_vmPushSymbol( hb_dynsymSymbol( ( ( PHB_SYMB ) pBlock )->pDynSym ) ); hb_vmPushNil(); } else { hb_vmPushEvalSym(); hb_vmPush( pBlock ); } hb_vmPushNumInt( ( HB_PTRUINT ) hwnd ); hb_vmPushInteger( msg ); hb_vmPushNumInt( ( HB_PTRUINT ) wParam ); hb_vmPushNumInt( ( HB_PTRUINT ) lParam ); hb_vmDo( 4 ); lRet = ( long ) hb_parnint( -1 ); return lRet; } return DefWindowProc( hwnd, msg, wParam, lParam ); }
static int hb_ssl_pem_password_cb( char * buf, int size, int rwflag, void * userdata ) { int retsize = 0; if( size > 0 && userdata && hb_vmRequestReenter() ) { hb_vmPushEvalSym(); hb_vmPush( ( PHB_ITEM ) userdata ); hb_vmPushLogical( rwflag ); hb_vmSend( 1 ); buf[ 0 ] = '\0'; retsize = ( int ) hb_parclen( -1 ); if( retsize > 0 ) { if( retsize > size ) retsize = size; memcpy( buf, hb_parc( -1 ), retsize ); } hb_vmRequestRestore(); } return retsize; }
static HB_SIZE s_fileReadAt( PHB_FILE pFile, void * buffer, HB_SIZE nSize, HB_FOFFSET nOffset ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFile->pFuncs; HB_SIZE nResult; int iOffset; iOffset = ( int ) ( hb_stackTopOffset() - hb_stackBaseOffset() ); memset( buffer, 0, nSize ); hb_vmPushString( ( const char * ) buffer, nSize ); s_pushMethod( pIO, IOUSR_READAT ); hb_vmPush( pFile->pFileItm ); hb_xvmPushLocalByRef( ( HB_SHORT ) iOffset ); hb_vmPushSize( nSize ); hb_vmPushNumInt( ( HB_MAXINT ) nOffset ); hb_vmDo( 4 ); nResult = hb_parns( -1 ); if( nResult > 0 ) { nSize = hb_itemGetCLen( hb_stackItemFromBase( iOffset ) ); if( nResult > nSize ) nResult = nSize; memcpy( buffer, hb_itemGetCPtr( hb_stackItemFromBase( iOffset ) ), nSize ); } hb_stackPop(); return nResult; }
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 PHB_FILE s_fileOpen( PHB_FILE_FUNCS pFuncs, const char * pszName, const char * pszDefExt, HB_USHORT uiExFlags, const char * pPaths, PHB_ITEM pError ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFuncs; PHB_FILE pFile = NULL; PHB_ITEM pFileItm; s_pushMethod( pIO, IOUSR_OPEN ); hb_vmPushString( pszName, strlen( pszName ) ); if( pszDefExt ) hb_vmPushString( pszDefExt, strlen( pszDefExt ) ); else hb_vmPushNil(); hb_vmPushInteger( uiExFlags ); if( pPaths ) hb_vmPushString( pPaths, strlen( pPaths ) ); else hb_vmPushNil(); if( pError ) hb_vmPush( pError ); else hb_vmPushNil(); hb_vmDo( 5 ); pFileItm = hb_stackReturnItem(); if( ! HB_IS_NIL( pFileItm ) ) pFile = s_fileNew( pIO, hb_itemNew( pFileItm ) ); return pFile; }
/* Control handler function */ static VOID WINAPI hbwin_SvcControlHandler( DWORD fdwControl ) { if( s_pHarbourControlFunc ) { if( hb_vmRequestReenterExt() ) { hb_vmPushEvalSym(); hb_vmPush( s_pHarbourControlFunc ); hb_vmPushNumInt( ( HB_MAXINT ) fdwControl ); hb_vmSend( 1 ); hb_vmRequestRestore(); } else HB_TRACE( HB_TR_DEBUG, ( "HVM stack not available" ) ); return; } switch( fdwControl ) { case SERVICE_CONTROL_STOP: s_ServiceStatus.dwWin32ExitCode = 0; s_ServiceStatus.dwCurrentState = SERVICE_STOPPED; break; case SERVICE_CONTROL_SHUTDOWN: s_ServiceStatus.dwWin32ExitCode = 0; s_ServiceStatus.dwCurrentState = SERVICE_STOPPED; break; default: return; } SetServiceStatus( s_hStatus, &s_ServiceStatus ); /* Report current status */ }
static void s_fileCommit( PHB_FILE pFile ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFile->pFuncs; s_pushMethod( pIO, IOUSR_COMMIT ); hb_vmPush( pFile->pFileItm ); hb_vmDo( 1 ); }
static void s_fileClose( PHB_FILE pFile ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFile->pFuncs; s_pushMethod( pIO, IOUSR_CLOSE ); hb_vmPush( pFile->pFileItm ); hb_vmDo( 1 ); }
static void s_fileFlush( PHB_FILE pFile, HB_BOOL fDirty ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFile->pFuncs; s_pushMethod( pIO, IOUSR_FLUSH ); hb_vmPush( pFile->pFileItm ); hb_vmPushLogical( fDirty ); hb_vmDo( 2 ); }
PHB_ITEM hb_evalLaunch( PHB_EVALINFO pEvalInfo ) { HB_THREAD_STUB PHB_ITEM pResult = NULL; HB_TRACE( HB_TR_DEBUG, ( "hb_evalLaunch(%p)", pEvalInfo ) ); if( pEvalInfo ) { register USHORT uiParam = 1; if( HB_IS_STRING( pEvalInfo->pItems[ 0 ] ) ) { const char * ptr = pEvalInfo->pItems[ 0 ]->item.asString.value; hb_vmPushSymbol( hb_dynsymFindName( ptr )->pSymbol ); hb_vmPushNil(); while( uiParam <= pEvalInfo->paramCount ) hb_vmPush( pEvalInfo->pItems[ uiParam++ ] ); hb_vmDo( pEvalInfo->paramCount ); pResult = hb_itemNew( NULL ); hb_itemForwardValue( pResult, &( HB_VM_STACK.Return ) ); } else if( HB_IS_BLOCK( pEvalInfo->pItems[ 0 ] ) ) { hb_vmPushSymbol( &hb_symEval ); hb_vmPush( pEvalInfo->pItems[ 0 ] ); while( uiParam <= pEvalInfo->paramCount ) hb_vmPush( pEvalInfo->pItems[ uiParam++ ] ); hb_vmSend( pEvalInfo->paramCount ); pResult = hb_itemNew( NULL ); hb_itemForwardValue( pResult, &( HB_VM_STACK.Return ) ); } } return pResult; }
static HB_FHANDLE s_fileHandle( PHB_FILE pFile ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFile->pFuncs; s_pushMethod( pIO, IOUSR_HANDLE ); hb_vmPush( pFile->pFileItm ); hb_vmDo( 1 ); return ( HB_FHANDLE ) hb_parns( -1 ); }
/* same functionality but with a NULL terminated list of parameters */ void hb_evalBlock( PHB_ITEM pCodeBlock, ... ) { va_list args; UINT uiParams = 0; PHB_ITEM pParam; hb_vmPushSymbol( &hb_symEval ); hb_vmPush( pCodeBlock ); va_start( args, pCodeBlock ); while( ( pParam = va_arg( args, PHB_ITEM ) ) != NULL ) { hb_vmPush( pParam ); ++uiParams; } va_end( args ); hb_vmSend( ( USHORT ) uiParams ); }
static HB_BOOL s_fileEof( PHB_FILE pFile ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFile->pFuncs; s_pushMethod( pIO, IOUSR_EOF ); hb_vmPush( pFile->pFileItm ); hb_vmDo( 1 ); return hb_parl( -1 ); }
static HB_FOFFSET s_fileSize( PHB_FILE pFile ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFile->pFuncs; s_pushMethod( pIO, IOUSR_SIZE ); hb_vmPush( pFile->pFileItm ); hb_vmDo( 1 ); return ( HB_FOFFSET ) hb_parnint( -1 ); }
/* same functionality but with a NULL terminated list of parameters */ void hb_evalBlock( PHB_ITEM pCodeBlock, ... ) { va_list args; HB_USHORT uiParams = 0; PHB_ITEM pParam; hb_vmPushEvalSym(); hb_vmPush( pCodeBlock ); va_start( args, pCodeBlock ); while( ( pParam = va_arg( args, PHB_ITEM ) ) != NULL ) { hb_vmPush( pParam ); uiParams++; } va_end( args ); hb_vmSend( uiParams ); }
static VOID WINAPI hbwin_SvcMainFunction( DWORD dwArgc, LPTSTR * lpszArgv ) { s_ServiceStatus.dwServiceType = SERVICE_WIN32; s_ServiceStatus.dwCurrentState = SERVICE_START_PENDING; s_ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; s_ServiceStatus.dwWin32ExitCode = 0; s_ServiceStatus.dwServiceSpecificExitCode = 0; s_ServiceStatus.dwCheckPoint = 0; s_ServiceStatus.dwWaitHint = 0; s_hStatus = RegisterServiceCtrlHandler( s_lpServiceName, ( LPHANDLER_FUNCTION ) hbwin_SvcControlHandler ); if( s_hStatus != ( SERVICE_STATUS_HANDLE ) 0 ) { if( s_pHarbourEntryFunc != NULL ) { if( hb_vmRequestReenterExt() ) { DWORD i; int iArgCount = 0; if( ! s_pHarbourControlFunc ) { /* We report the running status to SCM. */ s_ServiceStatus.dwCurrentState = SERVICE_RUNNING; SetServiceStatus( s_hStatus, &s_ServiceStatus ); } hb_vmPushEvalSym(); hb_vmPush( s_pHarbourEntryFunc ); for( i = 1; i < dwArgc; ++i ) { PHB_ITEM pItem = hb_stackAllocItem(); HB_ITEMPUTSTR( pItem, lpszArgv[ i ] ); if( hb_cmdargIsInternal( hb_itemGetCPtr( pItem ), NULL ) ) hb_stackPop(); else ++iArgCount; } hb_vmSend( ( HB_USHORT ) iArgCount ); hb_vmRequestRestore(); } else HB_TRACE( HB_TR_DEBUG, ( "HVM stack not available" ) ); } else HB_TRACE( HB_TR_DEBUG, ( "Harbour service entry function not found" ) ); } else HB_TRACE( HB_TR_DEBUG, ( "Error registering service" ) ); }