Hi Viktor,

you changed __EXPORT__ macro to HB_DYNLIB.
I know that it was name space problem but new name is not the best
choice. This macro was used to make functions public (exported)
for any other modules. I do not have to build harbour*dll to use it.
F.e. I want to use static Harbour libraries compiled with with this
macro because I want to make all public functions inside exported
so they can be accessed by any other shared libraries loaded by
my or 3-rd party code.
Can we chose it to sth what will have EXPORT in the name?
Or maybe better we should make symbol exporting by default so
it will be possible to use PCODE DLLs with standard static builds
and add HB_NO_EXPORT macro?

I'd like to add to Windows builds small library with the code
below. It allows to make DLL from compiled PCODE modules and then
load it to HVM by HB_LIBLOAD().

Looks that now people have lot of problems with creating valid PCODE
DLLs and produce final binaries with more or less critical errors.

best regards,
Przemek



#include <windows.h>
#include "hbtypes.h"

#define HB_DLL_NAME  "harbour.dll"
#if defined( __BORLANDC__ )
#define HB_DLL_NAME2 "harbour-b32.dll"
#elif defined( _MSC_VER )
#define HB_DLL_NAME2 "harbour-vc.dll"
#endif

HB_EXTERN_BEGIN

static FARPROC s_hb_getProcAddress( LPCSTR szProcName )
{
   static HMODULE s_hModule = NULL;
   FARPROC pProcAddr = NULL;

   if( s_hModule == NULL )
   {
      s_hModule = GetModuleHandle( NULL );
      if( s_hModule == NULL )
         s_hModule = GetModuleHandle( HB_DLL_NAME );
#ifdef HB_DLL_NAME2
      if( s_hModule == NULL )
         s_hModule = GetModuleHandle( HB_DLL_NAME2 );
#endif
   }
   if( s_hModule )
   {
      pProcAddr = GetProcAddress( s_hModule, szProcName );
      if( pProcAddr == NULL && szProcName[ 0 ] == '_' )
         pProcAddr = GetProcAddress( s_hModule, szProcName + 1 );
   }

   return pProcAddr;
}

static void s_errorMessage( void )
{
   /* TODO: display error message, hb_errInternal() is not accessible here */
}

static void s_vmExecuteError( const BYTE * pCode, PHB_SYMB pSymbols )
{
   HB_SYMBOL_UNUSED( pCode );
   HB_SYMBOL_UNUSED( pSymbols );

   s_errorMessage();
}

static VM_DLL_EXECUTE s_vmExecute = &s_vmExecuteError;

/* module symbols initialization with extended information */
PHB_SYMB hb_vmProcessSymbolsEx( PHB_SYMB pSymbols, USHORT uiSymbols,
                                const char * szModuleName,
                                ULONG ulID, USHORT uiPcodeVer )
{
   static VM_PROCESS_SYMBOLS_EX s_vmProcessSymbols = NULL;

   if( !s_vmProcessSymbols )
      s_vmProcessSymbols = ( VM_PROCESS_SYMBOLS_EX )
                           s_hb_getProcAddress( "_hb_vmProcessDynLibSymbols" );

   if( s_vmExecute == &s_vmExecuteError )
   {
      VM_DLL_EXECUTE pVmExecute = ( VM_DLL_EXECUTE )
                                  s_hb_getProcAddress( "_hb_vmExecute" );
      if( pVmExecute )
         s_vmExecute = pVmExecute;
   }

   if( s_vmProcessSymbols && s_vmExecute != &s_vmExecuteError )
      return ( s_vmProcessSymbols )
                  ( pSymbols, uiSymbols, szModuleName, ulID, uiPcodeVer );

   s_errorMessage();
   return pSymbols;
}

/* execute PCODE function */
void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols )
{
   ( s_vmExecute )( pCode, pSymbols );
}

HB_EXTERN_END
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to