2010-11-05 12:59 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)

* include/hbvm.h
  * src/vm/hvm.c
    + Added hb_vmPushPointerGC().

  * contrib/hbqt/qtcore/hbqt_init.cpp
    + Added experimental (not activated) code example to pass GC collected 
      pointer back from callbacks. This is just intermediate step, as it 
      should return .prg level class, but at least some room for leaks 
      can be avoided this way, plus the pointer type is identifiable.
      Based on code posted to list by Pritpal.
This commit is contained in:
Viktor Szakats
2010-11-05 12:00:28 +00:00
parent 97bc5b9ea3
commit 2fc69d4894
4 changed files with 41 additions and 1 deletions

View File

@@ -16,6 +16,18 @@
The license applies to all entries newer than 2009-04-28.
*/
2010-11-05 12:59 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* include/hbvm.h
* src/vm/hvm.c
+ Added hb_vmPushPointerGC().
* contrib/hbqt/qtcore/hbqt_init.cpp
+ Added experimental (not activated) code example to pass GC collected
pointer back from callbacks. This is just intermediate step, as it
should return .prg level class, but at least some room for leaks
can be avoided this way, plus the pointer type is identifiable.
Based on code posted to list by Pritpal.
2010-11-05 00:58 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* config/cygwin/gcc.mk
* include/hbwmain.c

View File

@@ -73,6 +73,14 @@
#include <QtCore/QModelIndex>
#include <QtCore/QRectF>
//#define _RET_GC_PTR_
#ifdef _RET_GC_PTR_
HB_EXTERN_BEGIN
extern void * hbqt_gcAllocate_QTime( void * pObj, bool bNew );
HB_EXTERN_END
#endif
/*----------------------------------------------------------------------*/
static void hbqt_SlotsExecPointer( PHB_ITEM * codeBlock, void ** arguments )
@@ -225,7 +233,11 @@ static void hbqt_SlotsExecQTime( PHB_ITEM * codeBlock, void ** arguments )
{
hb_vmPushEvalSym();
hb_vmPush( codeBlock );
#ifdef _RET_GC_PTR_
hb_vmPushPointerGC( hbqt_gcAllocate_QTime( new QTime( ( *reinterpret_cast< QTime( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */
#else
hb_vmPushPointer( new QTime( ( *reinterpret_cast< QTime( * ) >( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */
#endif
hb_vmSend( 1 );
}

View File

@@ -166,7 +166,8 @@ extern HB_EXPORT void hb_vmPushTimeStamp( long lJulian, long lMilliSec ); /*
extern HB_EXPORT void hb_vmPushSymbol( PHB_SYMB pSym ); /* pushes a function pointer onto the stack */
extern HB_EXPORT void hb_vmPushDynSym( PHB_DYNS pDynSym ); /* pushes a function/method pointer onto the stack */
extern HB_EXPORT void hb_vmPushEvalSym( void ); /* pushes a codeblock eval symbol onto the stack */
extern HB_EXPORT void hb_vmPushPointer( void * ); /* push an item of HB_IT_POINTER type */
extern HB_EXPORT void hb_vmPushPointer( void * pPointer ); /* push an item of HB_IT_POINTER type */
extern HB_EXPORT void hb_vmPushPointerGC( void * pPointer ); /* push an item of GC HB_IT_POINTER type */
extern HB_EXPORT void hb_vmPushItemRef( PHB_ITEM pItem ); /* push item reference */
#ifdef HB_LEGACY_LEVEL3
extern HB_EXPORT void hb_vmPushState( void ); /* push current VM state on stack */

View File

@@ -6777,6 +6777,21 @@ void hb_vmPushPointer( void * pPointer )
pItem->item.asPointer.single = HB_FALSE;
}
void hb_vmPushPointerGC( void * pPointer )
{
HB_STACK_TLS_PRELOAD
PHB_ITEM pItem = hb_stackAllocItem();
HB_TRACE(HB_TR_DEBUG, ("hb_vmPushPointerGC(%p)", pPointer));
pItem->type = HB_IT_POINTER;
pItem->item.asPointer.value = pPointer;
pItem->item.asPointer.collect = HB_TRUE;
pItem->item.asPointer.single = HB_FALSE;
hb_gcAttach( pPointer );
}
void hb_vmPushString( const char * szText, HB_SIZE nLength )
{
HB_STACK_TLS_PRELOAD