From a5f9f1e74888a2f18141aece6f941e6ca51475f4 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Fri, 11 Feb 2011 23:43:07 +0000 Subject: [PATCH] 2011-02-11 15:38 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbqt/qtcore/hbqt_init.cpp * contrib/hbqt/qtgui/hbqt_init.cpp * contrib/hbqt/qtnetwork/hbqt_init.cpp ! Fixed: to return GC Collectible pointers instead of raw ones. TODO: add 3 more classes which are required to handle Qt events. These methods will not work until then. --- harbour/ChangeLog | 8 +++ harbour/contrib/hbqt/qtcore/hbqt_init.cpp | 62 +++++++++++++++++++- harbour/contrib/hbqt/qtgui/hbqt_init.cpp | 38 ++++++++++++ harbour/contrib/hbqt/qtnetwork/hbqt_init.cpp | 35 +++++++++++ 4 files changed, 142 insertions(+), 1 deletion(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 90d7241057..e277927e83 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,14 @@ The license applies to all entries newer than 2009-04-28. */ +2011-02-11 15:38 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbqt/qtcore/hbqt_init.cpp + * contrib/hbqt/qtgui/hbqt_init.cpp + * contrib/hbqt/qtnetwork/hbqt_init.cpp + ! Fixed: to return GC Collectible pointers instead of raw ones. + TODO: add 3 more classes which are required to handle + Qt events. These methods will not work until then. + 2011-02-11 15:36 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbqt/qtgui/qth/QBitmap.qth * contrib/hbqt/qtgui/qth/QColor.qth diff --git a/harbour/contrib/hbqt/qtcore/hbqt_init.cpp b/harbour/contrib/hbqt/qtcore/hbqt_init.cpp index ce833f4ff1..a046dc0453 100644 --- a/harbour/contrib/hbqt/qtcore/hbqt_init.cpp +++ b/harbour/contrib/hbqt/qtcore/hbqt_init.cpp @@ -73,11 +73,22 @@ #include #include -//#define _RET_GC_PTR_ +#define _RET_GC_PTR_ #ifdef _RET_GC_PTR_ HB_EXTERN_BEGIN extern void * hbqt_gcAllocate_QTime( void * pObj, bool bNew ); +extern void * hbqt_gcAllocate_QSize( void * pObj, bool bNew ); +extern void * hbqt_gcAllocate_QSizeF( void * pObj, bool bNew ); +extern void * hbqt_gcAllocate_QPoint( void * pObj, bool bNew ); +extern void * hbqt_gcAllocate_QRect( void * pObj, bool bNew ); +extern void * hbqt_gcAllocate_QRectF( void * pObj, bool bNew ); +extern void * hbqt_gcAllocate_QUrl( void * pObj, bool bNew ); +extern void * hbqt_gcAllocate_QDate( void * pObj, bool bNew ); +extern void * hbqt_gcAllocate_QDateTime( void * pObj, bool bNew ); +extern void * hbqt_gcAllocate_QTime( void * pObj, bool bNew ); +extern void * hbqt_gcAllocate_QModelIndex( void * pObj, bool bNew ); +extern void * hbqt_gcAllocate_QStringList( void * pObj, bool bNew ); HB_EXTERN_END #endif @@ -176,7 +187,11 @@ static void hbqt_SlotsExecModel( PHB_ITEM * codeBlock, void ** arguments ) { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); +#ifdef _RET_GC_PTR_ + hb_vmPushPointerGC( hbqt_gcAllocate_QModelIndex( new QModelIndex( ( *reinterpret_cast< QModelIndex( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ +#else hb_vmPushPointer( new QModelIndex( ( *reinterpret_cast< QModelIndex( * ) >( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ +#endif hb_vmSend( 1 ); } @@ -184,8 +199,13 @@ static void hbqt_SlotsExecModelModel( PHB_ITEM * codeBlock, void ** arguments ) { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); +#ifdef _RET_GC_PTR_ + hb_vmPushPointerGC( hbqt_gcAllocate_QModelIndex( new QModelIndex( ( *reinterpret_cast< QModelIndex( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ + hb_vmPushPointerGC( hbqt_gcAllocate_QModelIndex( new QModelIndex( ( *reinterpret_cast< QModelIndex( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ +#else hb_vmPushPointer( new QModelIndex( ( *reinterpret_cast< QModelIndex( * ) >( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ hb_vmPushPointer( new QModelIndex( ( *reinterpret_cast< QModelIndex( * ) >( arguments[ 2 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ +#endif hb_vmSend( 2 ); } @@ -193,7 +213,11 @@ static void hbqt_SlotsExecStringList( PHB_ITEM * codeBlock, void ** arguments ) { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); +#ifdef _RET_GC_PTR_ + hb_vmPushPointerGC( hbqt_gcAllocate_QStringList( new QStringList( ( *reinterpret_cast< QStringList( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ +#else hb_vmPushPointer( new QStringList( ( *reinterpret_cast( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ +#endif hb_vmSend( 1 ); } @@ -201,7 +225,11 @@ static void hbqt_SlotsExecQPoint( PHB_ITEM * codeBlock, void ** arguments ) { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); +#ifdef _RET_GC_PTR_ + hb_vmPushPointerGC( hbqt_gcAllocate_QPoint( new QPoint( ( *reinterpret_cast< QPoint( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ +#else hb_vmPushPointer( new QPoint( ( *reinterpret_cast< QPoint( * )>( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ +#endif hb_vmSend( 1 ); } @@ -209,7 +237,11 @@ static void hbqt_SlotsExecQUrl( PHB_ITEM * codeBlock, void ** arguments ) { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); +#ifdef _RET_GC_PTR_ + hb_vmPushPointerGC( hbqt_gcAllocate_QUrl( new QUrl( ( *reinterpret_cast< QUrl( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ +#else hb_vmPushPointer( new QUrl( ( *reinterpret_cast< QUrl( * )>( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ +#endif hb_vmSend( 1 ); } @@ -217,7 +249,11 @@ static void hbqt_SlotsExecQDate( PHB_ITEM * codeBlock, void ** arguments ) { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); +#ifdef _RET_GC_PTR_ + hb_vmPushPointerGC( hbqt_gcAllocate_QDate( new QDate( ( *reinterpret_cast< QDate( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ +#else hb_vmPushPointer( new QDate( ( *reinterpret_cast< QDate( * ) >( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ +#endif hb_vmSend( 1 ); } @@ -225,7 +261,11 @@ static void hbqt_SlotsExecQDateTime( PHB_ITEM * codeBlock, void ** arguments ) { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); +#ifdef _RET_GC_PTR_ + hb_vmPushPointerGC( hbqt_gcAllocate_QDateTime( new QDateTime( ( *reinterpret_cast< QDateTime( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ +#else hb_vmPushPointer( new QDateTime( ( *reinterpret_cast< QDateTime( * ) >( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ +#endif hb_vmSend( 1 ); } @@ -245,7 +285,11 @@ static void hbqt_SlotsExecQRectF( PHB_ITEM * codeBlock, void ** arguments ) { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); +#ifdef _RET_GC_PTR_ + hb_vmPushPointerGC( hbqt_gcAllocate_QRectF( new QRectF( ( *reinterpret_cast< QRectF( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ +#else hb_vmPushPointer( new QRectF( ( *reinterpret_cast< QRectF( * )>( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ +#endif hb_vmSend( 1 ); } @@ -253,7 +297,11 @@ static void hbqt_SlotsExecQRectInt( PHB_ITEM * codeBlock, void ** arguments ) { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); +#ifdef _RET_GC_PTR_ + hb_vmPushPointerGC( hbqt_gcAllocate_QRect( new QRect( ( *reinterpret_cast< QRect( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ +#else hb_vmPushPointer( new QRect( ( *reinterpret_cast< QRect( * )>( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ +#endif hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 2 ] ) ); hb_vmSend( 2 ); } @@ -262,7 +310,11 @@ static void hbqt_SlotsExecQRect( PHB_ITEM * codeBlock, void ** arguments ) { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); +#ifdef _RET_GC_PTR_ + hb_vmPushPointerGC( hbqt_gcAllocate_QRect( new QRect( ( *reinterpret_cast< QRect( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ +#else hb_vmPushPointer( new QRect( ( *reinterpret_cast< QRect( * )>( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ +#endif hb_vmSend( 1 ); } @@ -270,7 +322,11 @@ static void hbqt_SlotsExecQSizeF( PHB_ITEM * codeBlock, void ** arguments ) { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); +#ifdef _RET_GC_PTR_ + hb_vmPushPointerGC( hbqt_gcAllocate_QSizeF( new QSizeF( ( *reinterpret_cast< QSizeF( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ +#else hb_vmPushPointer( new QSizeF( ( *reinterpret_cast< QSizeF( * )>( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ +#endif hb_vmSend( 1 ); } @@ -278,7 +334,11 @@ static void hbqt_SlotsExecModelIndexIntInt( PHB_ITEM * codeBlock, void ** argume { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); +#ifdef _RET_GC_PTR_ + hb_vmPushPointerGC( hbqt_gcAllocate_QModelIndex( new QModelIndex( ( *reinterpret_cast< QModelIndex( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ +#else hb_vmPushPointer( new QModelIndex( ( *reinterpret_cast< QModelIndex( * ) >( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ +#endif hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 2 ] ) ); hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 3 ] ) ); hb_vmSend( 3 ); diff --git a/harbour/contrib/hbqt/qtgui/hbqt_init.cpp b/harbour/contrib/hbqt/qtgui/hbqt_init.cpp index fa22d7f662..6cf1efd341 100644 --- a/harbour/contrib/hbqt/qtgui/hbqt_init.cpp +++ b/harbour/contrib/hbqt/qtgui/hbqt_init.cpp @@ -71,13 +71,30 @@ #include #include +#define _RET_GC_PTR_ + +#ifdef _RET_GC_PTR_ +HB_EXTERN_BEGIN +extern void * hbqt_gcAllocate_QColor( void * pObj, bool bNew ); +extern void * hbqt_gcAllocate_QItemSelection( void * pObj, bool bNew ); +extern void * hbqt_gcAllocate_QTextCharFormat( void * pObj, bool bNew ); +extern void * hbqt_gcAllocate_QFont( void * pObj, bool bNew ); +extern void * hbqt_gcAllocate_QTextCursor( void * pObj, bool bNew ); +extern void * hbqt_gcAllocate_QTextBlock( void * pObj, bool bNew ); +HB_EXTERN_END +#endif + /*----------------------------------------------------------------------*/ static void hbqt_SlotsExecQColor( PHB_ITEM * codeBlock, void ** arguments ) { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); +#ifdef _RET_GC_PTR_ + hb_vmPushPointerGC( hbqt_gcAllocate_QColor( new QColor( ( *reinterpret_cast< QColor( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ +#else hb_vmPushPointer( new QColor( ( *reinterpret_cast< QColor( * )>( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ +#endif hb_vmSend( 1 ); } @@ -85,8 +102,13 @@ static void hbqt_SlotsExecItemSelItemSel( PHB_ITEM * codeBlock, void ** argument { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); +#ifdef _RET_GC_PTR_ + hb_vmPushPointerGC( hbqt_gcAllocate_QItemSelection( new QItemSelection( ( *reinterpret_cast< QItemSelection( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ + hb_vmPushPointerGC( hbqt_gcAllocate_QItemSelection( new QItemSelection( ( *reinterpret_cast< QItemSelection( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ +#else hb_vmPushPointer( new QItemSelection( ( *reinterpret_cast< QItemSelection( * )>( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ hb_vmPushPointer( new QItemSelection( ( *reinterpret_cast< QItemSelection( * )>( arguments[ 2 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ +#endif hb_vmSend( 2 ); } @@ -94,7 +116,11 @@ static void hbqt_SlotsExecQTextCharFormat( PHB_ITEM * codeBlock, void ** argumen { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); +#ifdef _RET_GC_PTR_ + hb_vmPushPointerGC( hbqt_gcAllocate_QTextCharFormat( new QTextCharFormat( ( *reinterpret_cast< QTextCharFormat( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ +#else hb_vmPushPointer( new QTextCharFormat( ( *reinterpret_cast( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ +#endif hb_vmSend( 1 ); } @@ -102,7 +128,11 @@ static void hbqt_SlotsExecQFont( PHB_ITEM * codeBlock, void ** arguments ) { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); +#ifdef _RET_GC_PTR_ + hb_vmPushPointerGC( hbqt_gcAllocate_QFont( new QFont( ( *reinterpret_cast< QFont( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ +#else hb_vmPushPointer( new QFont( ( *reinterpret_cast< QFont( * )>( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ +#endif hb_vmSend( 1 ); } @@ -110,7 +140,11 @@ static void hbqt_SlotsExecQTextCursor( PHB_ITEM * codeBlock, void ** arguments ) { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); +#ifdef _RET_GC_PTR_ + hb_vmPushPointerGC( hbqt_gcAllocate_QTextCursor( new QTextCursor( ( *reinterpret_cast< QTextCursor( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ +#else hb_vmPushPointer( new QTextCursor( ( *reinterpret_cast< QTextCursor( * )>( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ +#endif hb_vmSend( 1 ); } @@ -118,7 +152,11 @@ static void hbqt_SlotsExecQTextBlock( PHB_ITEM * codeBlock, void ** arguments ) { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); +#ifdef _RET_GC_PTR_ + hb_vmPushPointerGC( hbqt_gcAllocate_QTextBlock( new QTextBlock( ( *reinterpret_cast< QTextBlock( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ +#else hb_vmPushPointer( new QTextBlock( ( *reinterpret_cast< QTextBlock( * )>( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ +#endif hb_vmSend( 1 ); } diff --git a/harbour/contrib/hbqt/qtnetwork/hbqt_init.cpp b/harbour/contrib/hbqt/qtnetwork/hbqt_init.cpp index 5dff1fa1c8..0f609ecda3 100644 --- a/harbour/contrib/hbqt/qtnetwork/hbqt_init.cpp +++ b/harbour/contrib/hbqt/qtnetwork/hbqt_init.cpp @@ -66,13 +66,30 @@ #include #include +#define _RET_GC_PTR_ + +#ifdef _RET_GC_PTR_ +HB_EXTERN_BEGIN +extern void * hbqt_gcAllocate_QHttpResponseHeader( void * pObj, bool bNew ); +extern void * hbqt_gcAllocate_QNetworkRequest( void * pObj, bool bNew ); +#if 0 // Classes not initiated yet! +extern void * hbqt_gcAllocate_QNetworkProxy( void * pObj, bool bNew ); +extern void * hbqt_gcAllocate_QUrlInfo( void * pObj, bool bNew ); +#endif +HB_EXTERN_END +#endif + /*----------------------------------------------------------------------*/ static void hbqt_SlotsExecQHttpResponseHeader( PHB_ITEM * codeBlock, void ** arguments ) { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); +#ifdef _RET_GC_PTR_ + hb_vmPushPointerGC( hbqt_gcAllocate_QHttpResponseHeader( new QHttpResponseHeader( ( *reinterpret_cast< QHttpResponseHeader( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ +#else hb_vmPushPointer( new QHttpResponseHeader( ( *reinterpret_cast< QHttpResponseHeader( * )>( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ +#endif hb_vmSend( 1 ); } @@ -80,6 +97,13 @@ static void hbqt_SlotsExecQNetworkProxyPointer( PHB_ITEM * codeBlock, void ** ar { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); +#if 0 +#ifdef _RET_GC_PTR_ + hb_vmPushPointerGC( hbqt_gcAllocate_QNetworkProxy( new QNetworkProxy( ( *reinterpret_cast< QNetworkProxy( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ +#else + hb_vmPushPointer( new QNetworkProxy( ( *reinterpret_cast< QNetworkProxy( * )>( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ +#endif +#endif hb_vmPushPointer( new QNetworkProxy( ( *reinterpret_cast< QNetworkProxy( * )>( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ hb_vmPushPointer( *reinterpret_cast< void*( * )>( arguments[ 2 ] ) ); /* TOFIX: Pass .prg level object to callback */ hb_vmSend( 2 ); @@ -89,7 +113,11 @@ static void hbqt_SlotsExecQNetworkRequest( PHB_ITEM * codeBlock, void ** argumen { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); +#ifdef _RET_GC_PTR_ + hb_vmPushPointerGC( hbqt_gcAllocate_QNetworkRequest( new QNetworkRequest( ( *reinterpret_cast< QNetworkRequest( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ +#else hb_vmPushPointer( new QNetworkRequest( ( *reinterpret_cast< QNetworkRequest( * )>( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ +#endif hb_vmSend( 1 ); } @@ -97,6 +125,13 @@ static void hbqt_SlotsExecQUrlInfo( PHB_ITEM * codeBlock, void ** arguments ) { hb_vmPushEvalSym(); hb_vmPush( codeBlock ); +#if 0 +#ifdef _RET_GC_PTR_ + hb_vmPushPointerGC( hbqt_gcAllocate_QUrlInfo( new QUrlInfo( ( *reinterpret_cast< QUrlInfo( * ) >( arguments[ 1 ] ) ) ), true ) ); /* TOFIX: Pass .prg level object to callback */ +#else + hb_vmPushPointer( new QUrlInfo( ( *reinterpret_cast< QUrlInfo( * )>( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ +#endif +#endif hb_vmPushPointer( new QUrlInfo( ( *reinterpret_cast< QUrlInfo( * )>( arguments[ 1 ] ) ) ) ); /* TOFIX: Pass .prg level object to callback */ hb_vmSend( 1 ); }