2012-11-13 19:00 UTC+0100 Viktor Szakats (harbour syenar.net)

* contrib/hbfimage/fi_wrp.c
  * contrib/hbfimage/tests/fitest.prg
    ! FI_SETOUTPUTMESSAGE(): fixed/implemented error callback.
      In previous version it was not working. Now the function
      accepts both function pointer and codeblock.
    * adapted/fixed error callback setting in test
    + added test for error callback

  * contrib/xhb/hbcompat.ch
    * formatting
This commit is contained in:
Viktor Szakats
2012-11-13 18:00:52 +00:00
parent 9715f1a858
commit 4acc58ca6a
4 changed files with 156 additions and 117 deletions

View File

@@ -16,6 +16,18 @@
The license applies to all entries newer than 2009-04-28.
*/
2012-11-13 19:00 UTC+0100 Viktor Szakats (harbour syenar.net)
* contrib/hbfimage/fi_wrp.c
* contrib/hbfimage/tests/fitest.prg
! FI_SETOUTPUTMESSAGE(): fixed/implemented error callback.
In previous version it was not working. Now the function
accepts both function pointer and codeblock.
* adapted/fixed error callback setting in test
+ added test for error callback
* contrib/xhb/hbcompat.ch
* formatting
2012-11-13 17:59 UTC+0100 Viktor Szakats (harbour syenar.net)
* INSTALL
* minor tweak in hbmk2 examples to better emphasis .hbc files

View File

@@ -7,6 +7,7 @@
* FreeImage graphic library low level (client api) interface code.
*
* Copyright 2005 Francesco Saverio Giudice <info@fsgiudice.com>
* Copyright 2012 Viktor Szakats (harbour syenar.net)
* www - http://www.xharbour.org http://harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
@@ -55,6 +56,7 @@
#include "hbapi.h"
#include "hbapiitm.h"
#include "hbapierr.h"
#include "hbstack.h"
#include "hbvm.h"
#if defined( HB_OS_WIN )
@@ -69,6 +71,33 @@
#define hb_fi_retl( x ) hb_retl( x ? HB_TRUE : HB_FALSE )
#define hb_fi_parl( x ) ( hb_parl( x ) ? TRUE : FALSE )
/* Error callback */
typedef struct
{
PHB_ITEM pErrorCallback;
} HB_FI_ERROR;
static void hb_fi_error_init( void * cargo )
{
HB_FI_ERROR * pError = ( HB_FI_ERROR * ) cargo;
pError->pErrorCallback = NULL;
}
static void hb_fi_error_release( void * cargo )
{
HB_FI_ERROR * pError = ( HB_FI_ERROR * ) cargo;
if( pError->pErrorCallback )
hb_itemRelease( pError->pErrorCallback );
}
static HB_TSD_NEW( s_fi_error,
sizeof( HB_FI_ERROR ),
hb_fi_error_init,
hb_fi_error_release );
/* HB_FIBITMAP API */
typedef struct
@@ -189,9 +218,6 @@ static void hb_FIMULTIBITMAP_ret( FIMULTIBITMAP * bitmap )
/* ************************* WRAPPED FUNCTIONS ****************************** */
/* static for error handler (see below FI_SETOUTPUTMESSAGE ) */
static void * s_pErrorHandler = NULL;
/* Init / Error routines */
/* --------------------- */
@@ -224,45 +250,45 @@ HB_FUNC( FI_GETCOPYRIGHTMESSAGE )
/* DLL_API void DLL_CALLCONV FreeImage_OutputMessageProc(int fif, const char *fmt, ...); */
/* typedef void (*FreeImage_OutputMessageFunction)(FREE_IMAGE_FORMAT fif, const char *msg); */
/* DLL_API void DLL_CALLCONV FreeImage_SetOutputMessage(FreeImage_OutputMessageFunction omf); */
/* implementation: void FreeImage_SetOutputMessage( pFunctionPointer ) */
/**
@param fif Format / Plugin responsible for the error
@param message Error message
*/
static void FreeImageErrorHandler( FREE_IMAGE_FORMAT fif, const char * message )
{
if( s_pErrorHandler )
HB_FI_ERROR * pError = ( HB_FI_ERROR * ) hb_stackGetTSD( &s_fi_error );
if( pError )
{
if( hb_vmRequestReenter() )
PHB_ITEM pErrorCallback = pError->pErrorCallback;
if( pErrorCallback && hb_vmRequestReenter() )
{
const char * format = FreeImage_GetFormatFromFIF( fif );
/* launch error function at prg level */
hb_vmPushSymbol( ( PHB_SYMB ) s_pErrorHandler );
hb_vmPushNil();
hb_vmPushEvalSym();
hb_vmPush( pErrorCallback );
hb_vmPushString( format, strlen( format ) );
hb_vmPushString( message, strlen( message ) );
hb_vmDo( 2 );
hb_vmSend( 2 );
hb_vmRequestRestore();
}
else
hb_errRT_BASE_SubstR( EG_ARG, 0, NULL, "FreeImageErrorHandler", HB_ERR_ARGS_BASEPARAMS );
}
}
/* DLL_API void DLL_CALLCONV FreeImage_SetOutputMessage(FreeImage_OutputMessageFunction omf); */
/* implementation: void FreeImage_SetOutputMessage( pFunctionPointer ) */
HB_FUNC( FI_SETOUTPUTMESSAGE )
{
s_pErrorHandler = NULL;
FreeImage_SetOutputMessage( FreeImageErrorHandler );
if( HB_ISBLOCK( 1 ) || HB_ISSYMBOL( 1 ) )
{
HB_FI_ERROR * pError = ( HB_FI_ERROR * ) hb_stackGetTSD( &s_fi_error );
if( HB_ISPOINTER( 1 ) )
/* Set the pointer */
s_pErrorHandler = hb_parptr( 1 );
else if( ! HB_ISNIL( 1 ) )
if( pError->pErrorCallback )
hb_itemRelease( pError->pErrorCallback );
pError->pErrorCallback = hb_itemNew( hb_param( 1, HB_IT_BLOCK | HB_IT_SYMBOL ) );
FreeImage_SetOutputMessage( FreeImageErrorHandler );
}
else
hb_errRT_BASE_SubstR( EG_ARG, 0, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}

View File

@@ -13,6 +13,7 @@
#include "freeimag.ch"
#include "fileio.ch"
#include "simpleio.ch"
#define IMAGES_IN ""
#define IMAGES_OUT "imgs_out" + hb_ps()
@@ -47,15 +48,15 @@ PROCEDURE Main()
//
? "Set Error Message:", fi_SetOutputMessage( fi_Error() )
#if 0
? "Set Error Message:", fi_SetOutputMessage( NIL )
#endif
? "Version :", fi_GetVersion()
? "Copyright :", fi_GetCopyrightMessage()
? "File type :", fi_GetFileType( IMAGES_IN + "sample1.jpg" )
? "Set Error Message (symbol):", fi_SetOutputMessage( @fi_Error() )
im := fi_Load( FIF_JPEG, IMAGES_IN + "nothere.jpg", JPEG_DEFAULT )
? "Set Error Message (block):", fi_SetOutputMessage( {| cFormat, cMessage | fi_Error( cFormat, cMessage ) } )
im := fi_Load( FIF_JPEG, IMAGES_IN + "nothere.jpg", JPEG_DEFAULT )
? "Load JPEG directly from file"
im := fi_Load( FIF_JPEG, IMAGES_IN + "sample1.jpg", JPEG_DEFAULT )
@@ -208,9 +209,9 @@ PROCEDURE Main()
PROCEDURE fi_Error( cFormat, cMessage )
? "ERROR!..."
? "Format : ", cFormat
? "Message : ", cMessage
? "ERROR!.."
? "Format : ", cFormat
? "Message: ", cMessage
RETURN

View File

@@ -64,81 +64,81 @@
#define __PLATFORM__LINUX
#endif
#xtranslate hb_ScrMaxRow() => gtInfo( HB_GTI_SCREENHEIGHT )
#xtranslate hb_ScrMaxCol() => gtInfo( HB_GTI_SCREENWIDTH )
#xtranslate MaxRow( .T. ) => gtInfo( HB_GTI_SCREENHEIGHT )
#xtranslate MaxCol( .T. ) => gtInfo( HB_GTI_SCREENWIDTH )
#xtranslate hb_keyNext( [<x>] ) => NextKey( <x> )
#xtranslate hb_gtInfo( HB_GTI_INKEYREAD [, <x>] ) => SetInkeyBeforeBlock( [<x>] ) <-x->
#xtranslate hb_gtInfo( HB_GTI_INKEYFILTER [, <x>] ) => SetInkeyAfterBlock( [<x>] ) <-x->
#xtranslate hb_osNewLine() => hb_eol()
#xtranslate hb_osPathSeparator() => hb_ps()
#xtranslate hb_ScrMaxRow() => gtInfo( HB_GTI_SCREENHEIGHT )
#xtranslate hb_ScrMaxCol() => gtInfo( HB_GTI_SCREENWIDTH )
#xtranslate MaxRow( .T. ) => gtInfo( HB_GTI_SCREENHEIGHT )
#xtranslate MaxCol( .T. ) => gtInfo( HB_GTI_SCREENWIDTH )
#xtranslate hb_keyNext( [<x>] ) => NextKey( <x> )
#xtranslate hb_dbPack() => __dbPack()
#xtranslate hb_dbZap() => __dbZap()
#xtranslate hb_dbDrop( [<x,...>] ) => dbDrop( <x> )
#xtranslate hb_dbExists( [<x,...>] ) => dbExists( <x> )
#xtranslate hb_FieldLen( [<x>] ) => FieldLen( <x> )
#xtranslate hb_FieldDec( [<x>] ) => FieldDec( <x> )
#xtranslate hb_FieldType( [<x>] ) => FieldType( <x> )
#xtranslate hb_osNewLine() => hb_eol()
#xtranslate hb_osPathSeparator() => hb_ps()
#xtranslate hb_gtInfo( HB_GTI_INKEYREAD [, <x>] ) => SetInkeyBeforeBlock( [<x>] ) <-x->
#xtranslate hb_gtInfo( HB_GTI_INKEYFILTER [, <x>] ) => SetInkeyAfterBlock( [<x>] ) <-x->
#xtranslate hb_dbPack() => __dbPack()
#xtranslate hb_dbZap() => __dbZap()
#xtranslate hb_dbDrop( [<x,...>] ) => dbDrop( <x> )
#xtranslate hb_dbExists( [<x,...>] ) => dbExists( <x> )
#xtranslate hb_FieldLen( [<x>] ) => FieldLen( <x> )
#xtranslate hb_FieldDec( [<x>] ) => FieldDec( <x> )
#xtranslate hb_FieldType( [<x>] ) => FieldType( <x> )
#xtranslate hb_processOpen( [<x,...>] ) => hb_OpenProcess( <x> )
#xtranslate hb_processClose( [<x,...>] ) => hb_CloseProcess( <x> )
#xtranslate hb_processOpen( [<x,...>] ) => hb_OpenProcess( <x> )
#xtranslate hb_processClose( [<x,...>] ) => hb_CloseProcess( <x> )
#xtranslate hb_IsRegex( [<x>] ) => hb_IsRegexString( <x> )
#xtranslate hb_MethodName( [<x,...>] ) => MethodName( <x> )
#xtranslate hb_libLoad( [<x,...>] ) => LibLoad( <x> )
#xtranslate hb_libFree( [<x,...>] ) => LibFree( <x> )
#xtranslate hb_Adler32( [<x,...>] ) => hb_Checksum( <x> )
#xtranslate hb_keySetLast( [<x,...>] ) => hb_SetLastKey( <x> )
#xtranslate hb_CStr( [<x,...>] ) => CStr( <x> )
#xtranslate hb_ValToExp( [<x,...>] ) => ValToPrgExp( <x> )
#xtranslate hb_rddInfo( [<x,...>] ) => rddInfo( <x> )
#xtranslate hb_idleSleep( [<x,...>] ) => SecondsSleep( <x> )
#xtranslate hb_UserName() => NetName( 1 )
#xtranslate hb_FSize( <x> ) => FileSize( <x> )
#xtranslate hb_WildMatch( [<x,...>] ) => WildMatch( <x> )
#xtranslate hb_bitTest( [<x,...>] ) => hb_bitIsSet( <x> )
#xtranslate hb_Deserialize( <x> ) => hb_DeserialNext( <x> )
#xtranslate hb_IsRegex( [<x>] ) => hb_IsRegexString( <x> )
#xtranslate hb_MethodName( [<x,...>] ) => MethodName( <x> )
#xtranslate hb_libLoad( [<x,...>] ) => LibLoad( <x> )
#xtranslate hb_libFree( [<x,...>] ) => LibFree( <x> )
#xtranslate hb_Adler32( [<x,...>] ) => hb_Checksum( <x> )
#xtranslate hb_keySetLast( [<x,...>] ) => hb_SetLastKey( <x> )
#xtranslate hb_CStr( [<x,...>] ) => CStr( <x> )
#xtranslate hb_ValToExp( [<x,...>] ) => ValToPrgExp( <x> )
#xtranslate hb_rddInfo( [<x,...>] ) => rddInfo( <x> )
#xtranslate hb_idleSleep( [<x,...>] ) => SecondsSleep( <x> )
#xtranslate hb_UserName() => NetName( 1 )
#xtranslate hb_FSize( <x> ) => FileSize( <x> )
#xtranslate hb_WildMatch( [<x,...>] ) => WildMatch( <x> )
#xtranslate hb_bitTest( [<x,...>] ) => hb_bitIsSet( <x> )
#xtranslate hb_Deserialize( <x> ) => hb_DeserialNext( <x> )
#xtranslate hb_HexToNum( [<c,...>] ) => HexToNum( <c> )
#xtranslate hb_NumToHex( [<n,...>] ) => NumToHex( <n> )
#xtranslate hb_HexToStr( [<c,...>] ) => HexToStr( <c> )
#xtranslate hb_StrToHex( [<c,...>] ) => StrToHex( <c> )
#xtranslate hb_HexToNum( [<c,...>] ) => HexToNum( <c> )
#xtranslate hb_NumToHex( [<n,...>] ) => NumToHex( <n> )
#xtranslate hb_HexToStr( [<c,...>] ) => HexToStr( <c> )
#xtranslate hb_StrToHex( [<c,...>] ) => StrToHex( <c> )
#xtranslate hb_AScan( [<x,...>] ) => AScan( <x> )
#xtranslate hb_RAScan( [<x,...>] ) => RAScan( <x> )
#xtranslate hb_AIns( [<x,...>] ) => AIns( <x> )
#xtranslate hb_ADel( [<x,...>] ) => ADel( <x> )
#xtranslate hb_At( [<x,...>] ) => At( <x> )
#xtranslate hb_AScan( [<x,...>] ) => AScan( <x> )
#xtranslate hb_RAScan( [<x,...>] ) => RAScan( <x> )
#xtranslate hb_AIns( [<x,...>] ) => AIns( <x> )
#xtranslate hb_ADel( [<x,...>] ) => ADel( <x> )
#xtranslate hb_At( [<x,...>] ) => At( <x> )
#xtranslate hb_DateTime( [<x,...>] ) => DateTime( <x> )
#xtranslate hb_Hour( [<x>] ) => Hour( <x> )
#xtranslate hb_Minute( [<x>] ) => Minute( <x> )
#xtranslate hb_TToS( [<x>] ) => TToS( <x> )
#xtranslate hb_SToT( [<x>] ) => SToT( <x> )
#xtranslate hb_TToC( [<x,...>] ) => TToC( <x> )
#xtranslate hb_CToT( [<x,...>] ) => CToT( <x> )
#xtranslate hb_DateTime( [<x,...>] ) => DateTime( <x> )
#xtranslate hb_Hour( [<x>] ) => Hour( <x> )
#xtranslate hb_Minute( [<x>] ) => Minute( <x> )
#xtranslate hb_TToS( [<x>] ) => TToS( <x> )
#xtranslate hb_SToT( [<x>] ) => SToT( <x> )
#xtranslate hb_TToC( [<x,...>] ) => TToC( <x> )
#xtranslate hb_CToT( [<x,...>] ) => CToT( <x> )
#xtranslate hb_GetEnv( [<x,...>] ) => GetEnv( <x> )
#xtranslate hb_SetKey( [<x,...>] ) => SetKey( <x> )
#xtranslate hb_GetEnv( [<x,...>] ) => GetEnv( <x> )
#xtranslate hb_SetKey( [<x,...>] ) => SetKey( <x> )
#xtranslate hb_i18n_gettext( <x> ) => i18n( <x> )
#xtranslate hb_i18n_gettext( <x> ) => i18n( <x> )
#xtranslate hb_cdpSelect( [<x,...>] ) => hb_SetCodepage( <x> )
#xtranslate hb_cdpSelect( [<x,...>] ) => hb_SetCodepage( <x> )
#xtranslate hb_argv( [<x,...>] ) => hb_CmdArgArgV( <x> )
#xtranslate hb_argv( [<x,...>] ) => hb_CmdArgArgV( <x> )
#xtranslate hb_iniSetComment( [<x,...>] ) => hb_SetIniComment( <x> )
#xtranslate hb_iniRead( [<x,...>] ) => hb_ReadIni( <x> )
#xtranslate hb_iniWrite( [<x,...>] ) => hb_WriteIni( <x> )
#xtranslate hb_iniSetComment( [<x,...>] ) => hb_SetIniComment( <x> )
#xtranslate hb_iniRead( [<x,...>] ) => hb_ReadIni( <x> )
#xtranslate hb_iniWrite( [<x,...>] ) => hb_WriteIni( <x> )
#xtranslate hb_DisableWaitLocks( [<x>] ) => DisableWaitLocks( <x> )
#xtranslate hb_DisableWaitLocks( [<x>] ) => DisableWaitLocks( <x> )
#xtranslate hb_gtLock() => hbConsoleLock()
#xtranslate hb_gtUnLock() => hbConsoleUnLock()
#xtranslate hb_gtLock() => hbConsoleLock()
#xtranslate hb_gtUnLock() => hbConsoleUnLock()
/* MT functions */
#xtranslate hb_mtvm() => hb_MultiThread()
@@ -171,31 +171,31 @@
hb_MutexTimeOutLock( <x>, <n> ) ) )
/* Hash item functions */
#xtranslate hb_Hash( [<x,...>] ) => Hash( <x> )
#xtranslate hb_HHasKey( [<x,...>] ) => HHasKey( <x> )
#xtranslate hb_HPos( [<x,...>] ) => HGetPos( <x> )
#xtranslate hb_HGet( [<x,...>] ) => HGet( <x> )
#xtranslate hb_HSet( [<x,...>] ) => HSet( <x> )
#xtranslate hb_HDel( [<x,...>] ) => HDel( <x> )
#xtranslate hb_HKeyAt( [<x,...>] ) => HGetKeyAt( <x> )
#xtranslate hb_HValueAt( [<x,...>] ) => HGetValueAt( <x> )
#xtranslate hb_HValueAt( [<x,...>] ) => HSetValueAt( <x> )
#xtranslate hb_HPairAt( [<x,...>] ) => HGetPairAt( <x> )
#xtranslate hb_HDelAt( [<x,...>] ) => HDelAt( <x> )
#xtranslate hb_HKeys( [<x,...>] ) => HGetKeys( <x> )
#xtranslate hb_HValues( [<x,...>] ) => HGetValues( <x> )
#xtranslate hb_HFill( [<x,...>] ) => HFill( <x> )
#xtranslate hb_HClone( [<x,...>] ) => HClone( <x> )
#xtranslate hb_HCopy( [<x,...>] ) => HCopy( <x> )
#xtranslate hb_HMerge( [<x,...>] ) => HMerge( <x> )
#xtranslate hb_HEval( [<x,...>] ) => HEval( <x> )
#xtranslate hb_HScan( [<x,...>] ) => HScan( <x> )
#xtranslate hb_HSetCaseMatch( [<x,...>] ) => HSetCaseMatch( <x> )
#xtranslate hb_HCaseMatch( [<x,...>] ) => HGetCaseMatch( <x> )
#xtranslate hb_HSetAutoAdd( [<x,...>] ) => HSetAutoAdd( <x> )
#xtranslate hb_HAutoAdd( [<x,...>] ) => HGetAutoAdd( <x> )
#xtranslate hb_HAllocate( [<x,...>] ) => HAllocate( <x> )
#xtranslate hb_HDefault( [<x,...>] ) => HDefault( <x> )
#xtranslate hb_Hash( [<x,...>] ) => Hash( <x> )
#xtranslate hb_HHasKey( [<x,...>] ) => HHasKey( <x> )
#xtranslate hb_HPos( [<x,...>] ) => HGetPos( <x> )
#xtranslate hb_HGet( [<x,...>] ) => HGet( <x> )
#xtranslate hb_HSet( [<x,...>] ) => HSet( <x> )
#xtranslate hb_HDel( [<x,...>] ) => HDel( <x> )
#xtranslate hb_HKeyAt( [<x,...>] ) => HGetKeyAt( <x> )
#xtranslate hb_HValueAt( [<x,...>] ) => HGetValueAt( <x> )
#xtranslate hb_HValueAt( [<x,...>] ) => HSetValueAt( <x> )
#xtranslate hb_HPairAt( [<x,...>] ) => HGetPairAt( <x> )
#xtranslate hb_HDelAt( [<x,...>] ) => HDelAt( <x> )
#xtranslate hb_HKeys( [<x,...>] ) => HGetKeys( <x> )
#xtranslate hb_HValues( [<x,...>] ) => HGetValues( <x> )
#xtranslate hb_HFill( [<x,...>] ) => HFill( <x> )
#xtranslate hb_HClone( [<x,...>] ) => HClone( <x> )
#xtranslate hb_HCopy( [<x,...>] ) => HCopy( <x> )
#xtranslate hb_HMerge( [<x,...>] ) => HMerge( <x> )
#xtranslate hb_HEval( [<x,...>] ) => HEval( <x> )
#xtranslate hb_HScan( [<x,...>] ) => HScan( <x> )
#xtranslate hb_HSetCaseMatch( [<x,...>] ) => HSetCaseMatch( <x> )
#xtranslate hb_HCaseMatch( [<x,...>] ) => HGetCaseMatch( <x> )
#xtranslate hb_HSetAutoAdd( [<x,...>] ) => HSetAutoAdd( <x> )
#xtranslate hb_HAutoAdd( [<x,...>] ) => HGetAutoAdd( <x> )
#xtranslate hb_HAllocate( [<x,...>] ) => HAllocate( <x> )
#xtranslate hb_HDefault( [<x,...>] ) => HDefault( <x> )
/* Inet functions */
#xtranslate hb_inetInit( [<x,...>] ) => inetInit( <x> )