From b762c675fe78a438e2bfde97e319027a0f9d538c Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Sun, 6 May 2012 02:49:42 +0000 Subject: [PATCH] 2012-05-05 19:44 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbqt/hbmk2_qt.hbs ! Fixed: to take use of the hbqt_par_isDerivedFrom() completely. This renders parameter checking with Class TYPE constants redundant which can be removed alltogether. This also facilitates usage of subclassing a Qt class. ; TODO: impliment siblings checking inside hbqt_par_isDerivedFrom(). HBQPlainTextEdit() is a sibling of QPlainTextEdit(). --- harbour/ChangeLog | 10 ++++++++++ harbour/contrib/hbqt/hbmk2_qt.hbs | 26 +++++++++++++++++--------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index d32ca627a0..609ddc3942 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,16 @@ The license applies to all entries newer than 2009-04-28. */ +2012-05-05 19:44 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbqt/hbmk2_qt.hbs + ! Fixed: to take use of the hbqt_par_isDerivedFrom() completely. + This renders parameter checking with Class TYPE constants + redundant which can be removed alltogether. This also + facilitates usage of subclassing a Qt class. + + ; TODO: impliment siblings checking inside hbqt_par_isDerivedFrom(). + HBQPlainTextEdit() is a sibling of QPlainTextEdit(). + 2012-05-05 15:51 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbqt/qtnetwork/qth/QNetworkProxy.qth + Fixed: constructors now respect new str API. diff --git a/harbour/contrib/hbqt/hbmk2_qt.hbs b/harbour/contrib/hbqt/hbmk2_qt.hbs index 7fca404f3b..e496935a9b 100644 --- a/harbour/contrib/hbqt/hbmk2_qt.hbs +++ b/harbour/contrib/hbqt/hbmk2_qt.hbs @@ -2183,7 +2183,7 @@ METHOD HbQtSource:getMethodBody( oMtd, cMtdName, aMethods ) a_ := b_[ 2 ] FOR EACH oMtd IN a_ IF oMtd:nArgs > 0 - AAdd( txt_, " " + iif( oMtd:__enumIndex() == 1, "if", "else if" ) + "( " + __TY_TYPEScpp( oMtd,nArgs ) + " )" ) + AAdd( txt_, " " + iif( oMtd:__enumIndex() == 1, "if", "else if" ) + "( " + __TY_TYPEScpp( oMtd, nArgs, .f. ) + " )" ) AAdd( txt_, " {" ) ENDIF // @@ -2223,7 +2223,7 @@ METHOD HbQtSource:getMethodBody( oMtd, cMtdName, aMethods ) nTySame := 0 AEval( a_, {| o | iif( __TY( o,nArgs ) == cCrc, nTySame++, NIL ) } ) lInIf := oMtd:nArgQCast > 0 .AND. oMtd:nArgQCast <= nArgs .AND. nTySame > 1 - AAdd( txt_, " " + iif( lFirst, "if( ", "else if( " ) + __TY_TYPEScpp( oMtd, nArgs ) + " )" ) + AAdd( txt_, " " + iif( lFirst, "if( ", "else if( " ) + __TY_TYPEScpp( oMtd, nArgs, nTySame > 1 ) + " )" ) AAdd( txt_, " {" ) ENDIF ENDIF @@ -2310,7 +2310,7 @@ STATIC FUNCTION hbqtgen_prgRetNormalize( cPrgRet ) /*----------------------------------------------------------------------*/ -STATIC FUNCTION hbqtgen_paramCheckStrCpp( cType, nArg, cCast ) +STATIC FUNCTION hbqtgen_paramCheckStrCpp( cType, nArg, cCast, lObj ) HB_SYMBOL_UNUSED( cCast ) @@ -2320,9 +2320,17 @@ STATIC FUNCTION hbqtgen_paramCheckStrCpp( cType, nArg, cCast ) CASE "P" //TODO RETURN "HB_ISPOINTER( " + hb_ntos( nArg ) + " )" CASE "O" - RETURN "hbqt_par_isDerivedFrom( " + hb_ntos( nArg ) + ', "' + upper( cCast ) +'" )' + IF lObj + RETURN "HB_ISOBJECT( " + hb_ntos( nArg ) + " )" + ELSE + RETURN "hbqt_par_isDerivedFrom( " + hb_ntos( nArg ) + ', "' + upper( cCast ) +'" )' + ENDIF CASE "CO" - RETURN "( hbqt_par_isDerivedFrom( " + hb_ntos( nArg ) + ', "' + upper( cCast ) + '" )' + " || HB_ISCHAR( " + hb_ntos( nArg ) + " ) )" + IF lObj + RETURN "( HB_ISOBJECT( " + hb_ntos( nArg ) + " )" + " || HB_ISCHAR( " + hb_ntos( nArg ) + " ) )" + ELSE + RETURN "( hbqt_par_isDerivedFrom( " + hb_ntos( nArg ) + ', "' + upper( cCast ) + '" )' + " || HB_ISCHAR( " + hb_ntos( nArg ) + " ) )" + ENDIF CASE "N*" RETURN "HB_ISBYREF( " + hb_ntos( nArg ) + " )" CASE "N" @@ -2338,10 +2346,10 @@ STATIC FUNCTION hbqtgen_paramCheckStrCpp( cType, nArg, cCast ) RETURN "" /*----------------------------------------------------------------------*/ -STATIC FUNCTION __TY_TYPEScpp( oM, nArgs ) +STATIC FUNCTION __TY_TYPEScpp( oM, nArgs, lObj ) LOCAL i, s := "" FOR i := 1 TO nArgs - s += hbqtgen_paramCheckStrCpp( oM:hArgs[ i ]:cTypeHB, i, oM:hArgs[ i ]:cCast ) + " && " + s += hbqtgen_paramCheckStrCpp( oM:hArgs[ i ]:cTypeHB, i, oM:hArgs[ i ]:cCast, lObj ) + " && " NEXT IF " && " $ s s := Left( s, Len( s ) - 4 ) @@ -3206,7 +3214,7 @@ STATIC FUNCTION hbqtgen_BuildCopyrightText() AAdd( txt_, "/* WARNING: Automatically generated source file. DO NOT EDIT! */" ) AAdd( txt_, "" ) AAdd( txt_, "/* Harbour QT wrapper" ) - AAdd( txt_, " Copyright 2009-2011 Pritpal Bedi " ) + AAdd( txt_, " Copyright 2009-2012 Pritpal Bedi " ) AAdd( txt_, " www - http://harbour-project.org */" ) AAdd( txt_, "" ) AAdd( txt_, '#include "hbqt.h"' ) @@ -3266,7 +3274,7 @@ STATIC FUNCTION __TY_Method( oMtd, nArgs ) cRet := "" FOR EACH nArg IN aIdx - cRet += "hbqt_isObjectType( " + hb_ntos( nArg ) + ", " + "HBQT_TYPE_" + oMtd:hArgs[ nArg ]:cCast + " )" + " && " + cRet += "hbqt_par_isDerivedFrom( " + hb_ntos( nArg ) + ', "' + upper( oMtd:hArgs[ nArg ]:cCast ) + '" )' + " && " NEXT cRet := SubStr( cRet, 1, Len( cRet ) - 4 )