* harbour/include/hbthread.h
* harbour/source/vm/thread.c
+ added hb_atomic_set(), hb_atomic_get(), hb_atomic_inc() and
hb_atomic_dec() functions which operates on HB_COUNTER or smaller
type if it's necessary for some platforms which can be access/assign
increment/decrement in MT safe atom operations.
hb_atomic_dec() returns true if counter is 0 after decrementation
* harbour/include/hbatomic.h
! fixed compilation in Linux and OpenWatcom
* harbour/include/hbapiitm.h
* harbour/source/rtl/itemseri.c
+ make hb_itemSerialize() and hb_itemDeserialize() public functions
! fixed serialization items with internal item references
* harbour/source/vm/hvm.c
* release memvars after closing RDDs
* harbour/source/debug/dbgentry.c
! fixed buffer overflow reported by Rodrigo
* harbour/source/vm/macro.c
* harbour/source/compiler/hbmain.c
* formatting
* harbour/include/hbexprb.c
! fixed wrongly recognized functions with HB_I18N_ prefix as
HB_I18N_GETTEXT()
* harbour/include/hbapi.h
* harbour/include/hbstack.h
* harbour/include/hbthread.h
* harbour/source/vm/estack.c
* harbour/source/vm/thread.c
* harbour/source/vm/hvm.c
+ added support for I18N in HVM.
Each thread can have it's own i18n set.
When new thread is created then it inherits i18n set from parent
thread and both uses the same set (please remember about it if you
will want to make some direct modifications on active i18n set
internals).
When thread change active i18n set then it effects only this thread
and new threads which will be create later. It does not change i18n
in other existing threads.
+ added functions to set/get pointer to active i18n set in HVM
void * hb_vmI18N( void )
void hb_vmSetI18N( void * )
* harbour/include/hbapi.h
* harbour/source/rtl/hbi18n.c
+ added i18n module. Now only for internal Harbour usage without support
for optional switching to alternative implementations.
I'll add such functionality later when I will work on native gettext
support.
The following public .prg functions has been added:
HB_I18N_GETTEXT[_STRICT]( <cMsgID> [, <cContext> ] )
-> <cTranslatedMsgID> | <cMsgID>
HB_I18N_NGETTEXT[_STRICT]( <nValue>, <cMsgID> | <acMsgID> ;
[, <cContext> ] )
-> <cTranslatedMsgID> | <cMsgID> | <acMsgID>[ <nIndex> ]
This is minimal support necessary for .prg code which has to exists
in each i18n module working with Harbour.
The following functions had been added as public C API:
PHB_ITEM hb_i18n_gettext( PHB_ITEM pMsgID, PHB_ITEM pContext )
PHB_ITEM hb_i18n_ngettext( PHB_ITEM pNum,
PHB_ITEM pMsgID, PHB_ITEM pContext )
The following functions had been added as private HVM C API:
void hb_i18n_init( void )
void hb_i18n_exit( void )
void hb_i18n_release( void * cargo )
void * hb_i18n_alloc( void * cargo )
They have to be supported by alternative i18n modules
The following functions has been added to manage Harbour i18n
translations sets:
HB_I18N_CREATE()
-> <pI18N>
Creates new empty I18N translation set
HB_I18N_CODEPAGE( [<pI18N>,] [<cNewCP>], [<lBase>], [<lTranslate>] )
-> <cOldCP>
Gets or sets Harbour codepage used by translation set
<pI18N> - I18N translation set,
if it's not given then currently active I18N set is used
<cNewCP> - new CP ID. Must be linked with application
<lBase> - when it's .T. then get/set base massages CP instead of
translated massages CP
<lTranslate> - if it's .T. then translate base (<lBase>==.T.) or
final messages in I18N set from previous CP to
given one. Base messages translation in synced
with context ID translation.
HB_I18N_PLURALFORM( [<pI18N>,] [<cNewForm>|<bNewForm>], [<lBase>] )
-> <cOldForm>|<bOldForm>
Gets or sets plural form used for final or base messages
<pI18N> - I18N translation set,
if it's not given then currently active I18N set is used
<cNewForm> - language ID of plural form, f.e.: "EN", "PL", "LT".
Now only three above are supported. Please add rules
for other languages to source/rtl/hbi18n.c.
<bNewForm> - codeblock used to calculate plural form indexes.
can be used instead of character representation but
it's not storred in serialized I18N set
<lBase> - when it's .T. then get/set base massages plural form
instead of translated massages one.
HB_I18N_DESCRIPTION( [<pI18N>,] [<cNewDescription>] )
-> <cOldDescription>
Gets or sets translation set description. After serialization
up to 32 bytes is stored in header which can be easy used to
determinate type of translation file.
<pI18N> - I18N translation set,
if it's not given then currently active I18N set is used
<cNewDescription> - new description
HB_I18N_ADDTEXT( <pI18N>, <cMsgID>, <cTrans> | <acTrans> [, <cContext> ] )
-> NIL
Adds new message with translation to i18n translation set
<pI18N> - I18N translation set
<cMsgID> - original message
<cTrans> - translated message
<acTrans> - array with translated messages used for plural forms
<cContext> - message context
HB_I18N_SET( [ <pI18N> | NIL ] )
-> <lActive>
Sets given I18N translation set as default one used by
HB_I18N_[N]GETTEXT[_STRICT]() functions or remove translation
set for calling thread when passed parameter is NIL
<pI18N> - I18N translation set
Returns logical value which is .T. when i18n set is active
HB_I18N_SAVETABLE( [<pI18N>] )
-> <cTable>
Returns I18N translation as string item which can be stored
in file or database
<pI18N> - I18N translation set, if it's not given then currently
active I18N set is used
HB_I18N_RESTORETABLE( <cTable> )
-> <pI18N> | NIL
Restores I18N translation set from strin item.
<cTable> - I18N translation set in string representation
On success it returns new <pI18N> set otherwise NIL if <cTable>
is not valid item created by HB_I18N_SAVETABLE() or it's corrupted.
HB_I18N_HEADERSIZE()
-> <nHeaderSize>
Returns size of header used by i18n serialized version
HB_I18N_CHEK( <cTable> | <cHeader> [, @<cDescription> ] )
-> <lValid>
<cTable> - i18n translation set serialized by HB_I18N_SAVETABLE
<cHeader> - header of i18n translation set
( LEFT( <cTable>, HB_I18N_HEADERSIZE() )
<cDescription> - optional parameter passed by reference where
will be sored i18n translation set description
extracted from valid header
Returns logical value indicating if given table or header is
valid serialized by HB_I18N_SAVETABLE() data. It does not
decode the table though it validates size and control sums.
These functions are optional and some future alternative implementations
may not support all of them and/or may provide some other functions.
+ added unofficial .prg function __I18N_HASHTABLE() which allows to
access hash table used by i18n translation set or create new translation
set with given hash table. It's helper functions for developers which
will work on Harbour i18n tools and should not be used by Harbour users.
Unlike original gettext Harbour allows to use language with many
plural forms as base one. In such case programmer should activate
at application startup default i18n translation set with base plural
form valid for base application language, f.e. by:
pI18N := hb_i18n_create()
hb_i18n_pluralForm( pI18N, <cLangID> | <bForm>, .t. )
hb_i18n_set( pI18N )
.prg code example:
#xtranslate _( <x,...> ) => hb_i18n_gettext_strict( <x> )
#xtranslate _N( <x,...> ) => hb_i18n_ngettext_strict( <x> )
proc main()
local pI18N, i
pI18N := hb_i18n_create()
hb_i18n_pluralForm( pI18N, "PL", .t. )
hb_i18n_set( pI18N )
for i := 0 to 30
? i, _N( i, {"grosz", "grosze", "groszy"} )
if i > 0 .and. i % 10 == 0
wait
endif
next
return
In .pot files created during compilation by Harbour with -j option
for above code we have the following entries for message with plural
forms:
msgid "grosz"
msgid_plural "grosze"
msgid_plural2 "groszy"
msgstr[0] ""
The msgid_plural2 (and others if language has more plural forms)
is Harbour extension which is not gettext compatible.
The above implementation is base version but should be fully functional.
Now we will need functions to safe/read i18n files and tools to mange
.pot files: merge them, edit translations, create final binary i18n
translation sets. Because we are using gettext compatible .pot files
then for some of such jobs we can use original gettext tools but we
need at least function which will create translation set from one or
more .pot files.
We should also agree some default localization(s) for files containing
translated data, their name convention and environment variable(s)
to set default language. It's not strictly necessary and each user
can have his own implementation but it would help in adding new
translations by final users to any Harbour application which will
respect them. We can use LANG envvar to extract preferred language
and use the same path as executed application looking for files
<appname>-<lang>.hil files though it may create some problems for
OSes which support only 8.3 file names so we can also define that
HB_I18N envvar has higher priority and points to expected translation
file.
* harbour/include/hbextern.ch
- removed old __i18n_*() functions
+ added current i18n functions
467 lines
20 KiB
C
467 lines
20 KiB
C
/*
|
|
* $Id$
|
|
*/
|
|
|
|
/*
|
|
* Harbour Project source code:
|
|
* The eval stack
|
|
*
|
|
* Copyright 1999 Antonio Linares <alinares@fivetech.com>
|
|
* www - http://www.harbour-project.org
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
* any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this software; see the file COPYING. If not, write to
|
|
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
|
*
|
|
* As a special exception, the Harbour Project gives permission for
|
|
* additional uses of the text contained in its release of Harbour.
|
|
*
|
|
* The exception is that, if you link the Harbour libraries with other
|
|
* files to produce an executable, this does not by itself cause the
|
|
* resulting executable to be covered by the GNU General Public License.
|
|
* Your use of that executable is in no way restricted on account of
|
|
* linking the Harbour library code into it.
|
|
*
|
|
* This exception does not however invalidate any other reasons why
|
|
* the executable file might be covered by the GNU General Public License.
|
|
*
|
|
* This exception applies only to the code released by the Harbour
|
|
* Project under the name Harbour. If you copy code from other
|
|
* Harbour Project or Free Software Foundation releases into a copy of
|
|
* Harbour, as the General Public License permits, the exception does
|
|
* not apply to the code that you add in this way. To avoid misleading
|
|
* anyone as to the status of such modified files, you must delete
|
|
* this exception notice from them.
|
|
*
|
|
* If you write modifications of your own for Harbour, it is your choice
|
|
* whether to permit this exception to apply to your modifications.
|
|
* If you do not wish that, delete this exception notice.
|
|
*
|
|
*/
|
|
|
|
/* TOFIX: There are several things in this file which are not part of the
|
|
standard Harbour API, in other words these things are not
|
|
guaranteed to remain unchanged. To avoid confusion these should be
|
|
moved to somewhere else (like hbrtl.h). [vszakats] */
|
|
|
|
#ifndef HB_STACK_H_
|
|
#define HB_STACK_H_
|
|
|
|
#include "hbvmpub.h"
|
|
|
|
HB_EXTERN_BEGIN
|
|
|
|
#if defined( HB_MT_VM )
|
|
# include "hbthread.h"
|
|
# if !defined( HB_USE_TLS ) && !defined( HB_OS_OS2 ) && 0
|
|
# undef HB_STACK_MACROS
|
|
# endif
|
|
#endif
|
|
|
|
/* thread specific data */
|
|
typedef void (*PHB_TSD_FUNC)(void *);
|
|
typedef struct
|
|
{
|
|
int iHandle;
|
|
int iSize;
|
|
PHB_TSD_FUNC pInitFunc;
|
|
PHB_TSD_FUNC pCleanFunc;
|
|
}
|
|
HB_TSD, * PHB_TSD;
|
|
#define HB_TSD_NEW(name,size,init,clean) \
|
|
HB_TSD name = { 0, size, init, clean }
|
|
#define HB_TSD_INIT(name,size,init,clean) do { \
|
|
(name)->iHandle = 0; \
|
|
(name)->iSize = (size); \
|
|
(name)->pInitFunc = (init); \
|
|
(name)->pCleanFunc = (clean); \
|
|
} while( 0 )
|
|
|
|
typedef struct
|
|
{
|
|
USHORT uiFError;
|
|
USHORT uiErrorLast;
|
|
USHORT uiOsErrorLast;
|
|
}
|
|
HB_IOERRORS, * PHB_IOERRORS;
|
|
|
|
typedef struct
|
|
{
|
|
const char * szDefaultRDD; /* default RDD */
|
|
BOOL fNetError; /* current NETERR() flag */
|
|
|
|
void ** waList; /* Allocated WorkAreas */
|
|
USHORT uiWaMax; /* Number of allocated WA */
|
|
USHORT uiWaSpace; /* Number of allocated WA */
|
|
|
|
USHORT * waNums; /* Allocated WorkAreas */
|
|
USHORT uiWaNumMax; /* Number of allocated WA */
|
|
|
|
USHORT uiCurrArea; /* Current WokrArea number */
|
|
void * pCurrArea; /* Current WorkArea pointer */
|
|
}
|
|
HB_STACKRDD, * PHB_STACKRDD;
|
|
|
|
#ifdef _HB_API_INTERNAL_
|
|
|
|
#include "hbset.h"
|
|
|
|
typedef struct
|
|
{
|
|
PHB_TSD pTSD;
|
|
void * value;
|
|
}
|
|
HB_TSD_HOLDER, * PHB_TSD_HOLDER;
|
|
|
|
typedef struct
|
|
{
|
|
PHB_DYNS pDynSym;
|
|
PHB_ITEM pPrevMemvar;
|
|
}
|
|
HB_PRIVATE_ITEM, * PHB_PRIVATE_ITEM;
|
|
|
|
typedef struct
|
|
{
|
|
PHB_PRIVATE_ITEM stack;
|
|
ULONG size;
|
|
ULONG count;
|
|
ULONG base;
|
|
}
|
|
HB_PRIVATE_STACK, * PHB_PRIVATE_STACK;
|
|
|
|
#if defined( HB_MT_VM )
|
|
typedef struct
|
|
{
|
|
void * pMemvar; /* memvar pointer ( publics & privates ) */
|
|
USHORT uiArea; /* Workarea number */
|
|
}
|
|
HB_DYN_HANDLES, * PHB_DYN_HANDLES;
|
|
#endif
|
|
|
|
/* stack managed by the virtual machine */
|
|
typedef struct
|
|
{
|
|
PHB_ITEM * pItems; /* pointer to the stack items */
|
|
PHB_ITEM * pPos; /* pointer to the latest used item */
|
|
PHB_ITEM * pEnd; /* pointer to the end of stack items */
|
|
LONG wItems; /* total items that may be holded on the stack */
|
|
HB_ITEM Return; /* latest returned value */
|
|
PHB_ITEM * pBase; /* stack frame position for the current function call */
|
|
LONG lStatics; /* statics base for the current function call */
|
|
LONG lWithObject; /* stack offset to base current WITH OBJECT item */
|
|
LONG lRecoverBase; /* current SEQUENCE envelope offset or 0 if no SEQUENCE is active */
|
|
USHORT uiActionRequest;/* request for some action - stop processing of opcodes */
|
|
USHORT uiQuitState; /* HVM is quiting */
|
|
HB_STACK_STATE state; /* first (default) stack state frame */
|
|
HB_STACKRDD rdd; /* RDD related data */
|
|
char szDate[ 9 ]; /* last returned date from _pards() yyyymmdd format */
|
|
void * pCDP; /* current codepage module */
|
|
void * pLang; /* current language module */
|
|
void * pI18N; /* current I18N module */
|
|
void * hGT; /* current GT module */
|
|
int iTSD; /* number of allocated TSD holders */
|
|
PHB_TSD_HOLDER pTSD; /* thread specific data holder */
|
|
HB_PRIVATE_STACK privates; /* private variables stack */
|
|
HB_SET_STRUCT set;
|
|
int iKeyPoll; /* counter for GT/keyboard polling */
|
|
BOOL fDebugRequest; /* request debugger activation */
|
|
void * pDebugInfo; /* internal debugger structure */
|
|
#if defined( HB_MT_VM )
|
|
int iUnlocked; /* counter for nested hb_vmUnlock() calls */
|
|
PHB_DYN_HANDLES pDynH; /* dynamic symbol handles */
|
|
int iDynH; /* number of dynamic symbol handles */
|
|
void * pStackLst; /* this stack entry in stack linked list */
|
|
HB_IOERRORS IOErrors; /* MT safe buffer for IO errors */
|
|
BYTE * byDirBuffer; /* MT safe buffer for hb_fsCurDir() results */
|
|
#endif
|
|
} HB_STACK, * PHB_STACK;
|
|
|
|
#if defined( HB_STACK_MACROS )
|
|
# if defined( HB_MT_VM )
|
|
# if defined( HB_USE_TLS )
|
|
# if defined( __BORLANDC__ )
|
|
extern PHB_STACK HB_TLS_ATTR hb_stack_ptr;
|
|
# else
|
|
extern HB_TLS_ATTR PHB_STACK hb_stack_ptr;
|
|
# endif
|
|
# else
|
|
extern HB_TLS_KEY hb_stack_key;
|
|
# if defined( __BORLANDC__ ) && defined( HB_STACK_PRELOAD )
|
|
static __inline void* hb_stack_ptr_from_tls( void )
|
|
{
|
|
/* mov ecx,hb_stack_key */
|
|
_ECX = hb_stack_key;
|
|
/* mov eax,dword ptr fs:[00000018h] */
|
|
__emit__( 0x64, 0xA1, 0x18, 0x00, 0x00, 0x00 );
|
|
/* mov eax,[eax+ecx*4+00000E10h] */
|
|
__emit__( 0x8B, 0x84, 0x88, 0x10, 0x0E, 0x00, 0x00 );
|
|
/* ret (if function is not inlined) */
|
|
return (void*) _EAX;
|
|
}
|
|
# elif defined( __MINGW32__ )
|
|
static __inline__ __attribute__ ((pure, malloc)) void * hb_stack_ptr_from_tls( void )
|
|
{
|
|
void * p;
|
|
__asm__ (
|
|
"movl %%fs:(0x18), %0\n\t"
|
|
"movl 0x0e10(%0,%1,4), %0\n\t"
|
|
:"=a" (p)
|
|
:"c" (hb_stack_key)
|
|
);
|
|
return p;
|
|
}
|
|
# define hb_stack_ptr ( ( PHB_STACK ) hb_stack_ptr_from_tls() )
|
|
# endif
|
|
# if !defined( hb_stack_ptr )
|
|
# define hb_stack_ptr ( ( PHB_STACK ) hb_tls_get( hb_stack_key ) )
|
|
# endif
|
|
# endif
|
|
# if defined( HB_STACK_PRELOAD ) && !defined( HB_USE_TLS )
|
|
# if defined( __BORLANDC__ ) || defined( __MINGW32__ )
|
|
# define HB_STACK_TLS_PRELOAD PHB_STACK _hb_stack_ptr_ = ( PHB_STACK ) hb_stack_ptr_from_tls();
|
|
# undef hb_stack_ptr
|
|
# else
|
|
# define HB_STACK_TLS_PRELOAD PHB_STACK _hb_stack_ptr_ = hb_stack_ptr;
|
|
# endif
|
|
# define hb_stack ( * _hb_stack_ptr_ )
|
|
# else
|
|
# define hb_stack ( * hb_stack_ptr )
|
|
# endif
|
|
# else
|
|
extern HB_STACK hb_stack;
|
|
# endif
|
|
#endif
|
|
#if !defined( HB_STACK_TLS_PRELOAD ) && defined( HB_STACK_PRELOAD )
|
|
# define HB_STACK_TLS_PRELOAD
|
|
# undef HB_STACK_PRELOAD
|
|
#endif
|
|
|
|
#endif /* _HB_API_INTERNAL_ */
|
|
|
|
HB_EXPORT extern HB_ITEM_PTR hb_stackItemFromTop( int nFromTop );
|
|
extern HB_ITEM_PTR hb_stackItemFromBase( int nFromBase );
|
|
extern LONG hb_stackTopOffset( void );
|
|
extern LONG hb_stackBaseOffset( void );
|
|
extern LONG hb_stackTotalItems( void );
|
|
extern HB_ITEM_PTR hb_stackBaseItem( void );
|
|
extern HB_ITEM_PTR hb_stackItem( LONG iItemPos );
|
|
extern HB_ITEM_PTR hb_stackSelfItem( void ); /* returns Self object at C function level */
|
|
extern HB_ITEM_PTR hb_stackReturnItem( void ); /* returns RETURN Item from stack */
|
|
extern char * hb_stackDateBuffer( void );
|
|
extern void * hb_stackId( void );
|
|
|
|
HB_EXPORT extern void hb_stackPop( void ); /* pops an item from the stack */
|
|
extern void hb_stackDec( void ); /* pops an item from the stack without clearing it's contents */
|
|
extern void hb_stackPush( void ); /* pushes an item on to the stack */
|
|
extern HB_ITEM_PTR hb_stackAllocItem( void ); /* allocates new item on the top of stack, returns pointer to it */
|
|
extern void hb_stackPushReturn( void );
|
|
extern void hb_stackPopReturn( void );
|
|
extern void hb_stackRemove( LONG lUntilPos );
|
|
|
|
/* stack management functions */
|
|
extern int hb_stackCallDepth( void );
|
|
extern LONG hb_stackBaseProcOffset( int iLevel );
|
|
extern void hb_stackBaseProcInfo( char * szProcName, USHORT * puiProcLine ); /* get current .prg function name and line number */
|
|
extern void hb_stackDispLocal( void ); /* show the types of the items on the stack for debugging purposes */
|
|
extern void hb_stackDispCall( void );
|
|
extern void hb_stackFree( void ); /* releases all memory used by the stack */
|
|
extern void hb_stackInit( void ); /* initializes the stack */
|
|
extern void hb_stackIncrease( void ); /* increase the stack size */
|
|
|
|
/* thread specific data */
|
|
extern void * hb_stackGetTSD( PHB_TSD pTSD );
|
|
extern void * hb_stackTestTSD( PHB_TSD pTSD );
|
|
extern void hb_stackReleaseTSD( PHB_TSD pTSD );
|
|
|
|
extern BYTE * hb_stackDirBuffer( void );
|
|
extern PHB_IOERRORS hb_stackIOErrors( void );
|
|
extern void * hb_stackGetGT( void );
|
|
extern void hb_stackSetGT( void * );
|
|
extern PHB_STACKRDD hb_stackRDD( void );
|
|
|
|
extern void ** hb_stackDebugInfo( void );
|
|
|
|
#ifdef _HB_API_INTERNAL_
|
|
extern void hb_stackDecrease( ULONG ulItems );
|
|
extern HB_ITEM_PTR hb_stackNewFrame( PHB_STACK_STATE pFrame, USHORT uiParams );
|
|
extern void hb_stackOldFrame( PHB_STACK_STATE pFrame );
|
|
extern void hb_stackClearMevarsBase( void );
|
|
|
|
extern HB_ITEM_PTR hb_stackLocalVariable( int *piFromBase );
|
|
extern PHB_ITEM ** hb_stackItemBasePtr( void );
|
|
|
|
extern LONG hb_stackGetRecoverBase( void );
|
|
extern void hb_stackSetRecoverBase( LONG lBase );
|
|
extern USHORT hb_stackGetActionRequest( void );
|
|
extern void hb_stackSetActionRequest( USHORT uiAction );
|
|
|
|
extern void hb_stackSetStaticsBase( LONG lBase );
|
|
extern LONG hb_stackGetStaticsBase( void );
|
|
|
|
extern PHB_ITEM hb_stackWithObjectItem( void );
|
|
extern LONG hb_stackWithObjectOffset( void );
|
|
extern void hb_stackWithObjectSetOffset( LONG );
|
|
|
|
extern int * hb_stackKeyPolls( void );
|
|
extern BOOL * hb_stackDebugRequest( void );
|
|
|
|
extern void hb_stackDestroyTSD( void );
|
|
|
|
extern PHB_PRIVATE_STACK hb_stackGetPrivateStack( void );
|
|
extern void * hb_stackGetCDP( void );
|
|
extern void hb_stackSetCDP( void * );
|
|
extern void * hb_stackGetLang( void );
|
|
extern void hb_stackSetLang( void * );
|
|
extern void * hb_stackGetI18N( void );
|
|
extern void hb_stackSetI18N( void * );
|
|
|
|
extern void hb_stackIsStackRef( void *, PHB_TSD_FUNC );
|
|
|
|
#if defined( HB_MT_VM )
|
|
extern void * hb_stackList( void );
|
|
extern void hb_stackListSet( void * pStackLst );
|
|
extern void hb_stackIdSetActionRequest( void * pStackID, USHORT uiAction );
|
|
extern PHB_DYN_HANDLES hb_stackGetDynHandle( PHB_DYNS pDynSym );
|
|
extern BOOL hb_stackQuitState( void );
|
|
extern void hb_stackSetQuitState( USHORT uiState );
|
|
extern int hb_stackUnlock( void );
|
|
extern int hb_stackLock( void );
|
|
#endif
|
|
|
|
#endif /* _HB_API_INTERNAL_ */
|
|
|
|
#if defined( _HB_API_INTERNAL_ ) || defined( _HB_SET_INTERNAL_ )
|
|
extern PHB_SET_STRUCT hb_stackSetStruct( void );
|
|
#endif
|
|
|
|
|
|
#if defined( HB_STACK_MACROS )
|
|
|
|
#define hb_stackItemFromTop( n ) ( * ( hb_stack.pPos + ( int ) (n) ) )
|
|
#define hb_stackItemFromBase( n ) ( * ( hb_stack.pBase + ( int ) (n) + 1 ) )
|
|
#define hb_stackTopOffset( ) ( hb_stack.pPos - hb_stack.pItems )
|
|
#define hb_stackBaseOffset( ) ( hb_stack.pBase - hb_stack.pItems + 1 )
|
|
#define hb_stackTotalItems( ) ( hb_stack.wItems )
|
|
#define hb_stackBaseItem( ) ( * hb_stack.pBase )
|
|
#define hb_stackSelfItem( ) ( * ( hb_stack.pBase + 1 ) )
|
|
#define hb_stackItem( iItemPos ) ( * ( hb_stack.pItems + ( iItemPos ) ) )
|
|
#define hb_stackReturnItem( ) ( &hb_stack.Return )
|
|
#define hb_stackDateBuffer( ) ( hb_stack.szDate )
|
|
#define hb_stackItemBasePtr( ) ( &hb_stack.pItems )
|
|
#define hb_stackGetStaticsBase( ) ( hb_stack.lStatics )
|
|
#define hb_stackSetStaticsBase( n ) do { hb_stack.lStatics = ( n ); } while ( 0 )
|
|
#define hb_stackGetRecoverBase( ) ( hb_stack.lRecoverBase )
|
|
#define hb_stackSetRecoverBase( n ) do { hb_stack.lRecoverBase = ( n ); } while( 0 )
|
|
#define hb_stackGetActionRequest( ) ( hb_stack.uiActionRequest )
|
|
#define hb_stackSetActionRequest( n ) do { hb_stack.uiActionRequest = ( n ); } while( 0 )
|
|
#define hb_stackWithObjectItem( ) ( hb_stack.lWithObject ? * ( hb_stack.pItems + hb_stack.lWithObject ) : NULL )
|
|
#define hb_stackWithObjectOffset( ) ( hb_stack.lWithObject )
|
|
#define hb_stackWithObjectSetOffset( n ) do { hb_stack.lWithObject = ( n ); } while( 0 )
|
|
#define hb_stackGetCDP( ) ( hb_stack.pCDP )
|
|
#define hb_stackSetCDP( p ) do { hb_stack.pCDP = ( p ); } while ( 0 )
|
|
#define hb_stackGetLang( ) ( hb_stack.pLang )
|
|
#define hb_stackSetLang( p ) do { hb_stack.pLang = ( p ); } while ( 0 )
|
|
#define hb_stackGetI18N( ) ( hb_stack.pI18N )
|
|
#define hb_stackSetI18N( p ) do { hb_stack.pI18N = ( p ); } while ( 0 )
|
|
|
|
#define hb_stackId( ) ( ( void * ) &hb_stack )
|
|
#if defined( HB_MT_VM )
|
|
# define hb_stackList( ) ( hb_stack.pStackLst )
|
|
# define hb_stackListSet( p ) do { hb_stack.pStackLst = ( p ); } while ( 0 )
|
|
# define hb_stackQuitState( ) ( hb_stack.uiQuitState != 0 )
|
|
# define hb_stackSetQuitState( n ) do { hb_stack.uiQuitState = ( n ); } while( 0 )
|
|
# define hb_stackUnlock() ( ++hb_stack.iUnlocked )
|
|
# define hb_stackLock() ( --hb_stack.iUnlocked )
|
|
#endif
|
|
|
|
#define hb_stackAllocItem( ) ( ( ++hb_stack.pPos == hb_stack.pEnd ? \
|
|
hb_stackIncrease() : (void) 0 ), \
|
|
* ( hb_stack.pPos - 1 ) )
|
|
|
|
#ifdef HB_STACK_SAFEMACROS
|
|
|
|
#define hb_stackDecrease( n ) do { \
|
|
if( ( hb_stack.pPos -= (n) ) <= hb_stack.pBase ) \
|
|
hb_errInternal( HB_EI_STACKUFLOW, NULL, NULL, NULL ); \
|
|
} while ( 0 )
|
|
|
|
#define hb_stackDec( ) do { \
|
|
if( --hb_stack.pPos <= hb_stack.pBase ) \
|
|
hb_errInternal( HB_EI_STACKUFLOW, NULL, NULL, NULL ); \
|
|
} while ( 0 )
|
|
|
|
#define hb_stackPop( ) do { \
|
|
if( --hb_stack.pPos <= hb_stack.pBase ) \
|
|
hb_errInternal( HB_EI_STACKUFLOW, NULL, NULL, NULL ); \
|
|
if( HB_IS_COMPLEX( * hb_stack.pPos ) ) \
|
|
hb_itemClear( * hb_stack.pPos ); \
|
|
} while ( 0 )
|
|
|
|
#define hb_stackPopReturn( ) do { \
|
|
if( HB_IS_COMPLEX( &hb_stack.Return ) ) \
|
|
hb_itemClear( &hb_stack.Return ); \
|
|
if( --hb_stack.pPos <= hb_stack.pBase ) \
|
|
hb_errInternal( HB_EI_STACKUFLOW, NULL, NULL, NULL ); \
|
|
hb_itemRawMove( &hb_stack.Return, * hb_stack.pPos ); \
|
|
} while ( 0 )
|
|
|
|
#else
|
|
|
|
#define hb_stackDecrease( n ) do { hb_stack.pPos -= (n); } while ( 0 )
|
|
#define hb_stackDec( ) do { --hb_stack.pPos; } while ( 0 )
|
|
#define hb_stackPop( ) do { --hb_stack.pPos; \
|
|
if( HB_IS_COMPLEX( * hb_stack.pPos ) ) \
|
|
hb_itemClear( * hb_stack.pPos ); \
|
|
} while ( 0 )
|
|
#define hb_stackPopReturn( ) do { \
|
|
if( HB_IS_COMPLEX( &hb_stack.Return ) ) \
|
|
hb_itemClear( &hb_stack.Return ); \
|
|
--hb_stack.pPos; \
|
|
hb_itemRawMove( &hb_stack.Return, * hb_stack.pPos ); \
|
|
} while ( 0 )
|
|
|
|
#endif
|
|
|
|
#define hb_stackPush( ) do { \
|
|
if( ++hb_stack.pPos == hb_stack.pEnd ) \
|
|
hb_stackIncrease(); \
|
|
} while ( 0 )
|
|
|
|
#define hb_stackPushReturn( ) do { \
|
|
hb_itemRawMove( * hb_stack.pPos, &hb_stack.Return ); \
|
|
if( ++hb_stack.pPos == hb_stack.pEnd ) \
|
|
hb_stackIncrease(); \
|
|
} while ( 0 )
|
|
|
|
#define hb_stackLocalVariable( p ) ( ( ( ( *hb_stack.pBase )->item.asSymbol.paramcnt > \
|
|
( * hb_stack.pBase )->item.asSymbol.paramdeclcnt ) && \
|
|
( * (p) ) > ( * hb_stack.pBase )->item.asSymbol.paramdeclcnt ) ? \
|
|
( * ( hb_stack.pBase + ( int ) ( * (p) += \
|
|
( * hb_stack.pBase )->item.asSymbol.paramcnt - \
|
|
( * hb_stack.pBase )->item.asSymbol.paramdeclcnt ) + 1 ) ) : \
|
|
( * ( hb_stack.pBase + ( int ) ( * (p) ) + 1 ) ) )
|
|
|
|
#define hb_stackGetPrivateStack( ) ( &hb_stack.privates )
|
|
#define hb_stackSetStruct( ) ( &hb_stack.set )
|
|
#define hb_stackKeyPolls( ) ( &hb_stack.iKeyPoll )
|
|
#define hb_stackDebugRequest( ) ( &hb_stack.fDebugRequest )
|
|
#define hb_stackDebugInfo( ) ( &hb_stack.pDebugInfo )
|
|
|
|
#endif
|
|
|
|
|
|
HB_EXTERN_END
|
|
|
|
#endif /* HB_STACK_H_ */
|