From 25256841d62b8f9743c23593754e07e685b7783b Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Mon, 6 Apr 2009 16:41:34 +0000 Subject: [PATCH] 2009-04-06 09:36 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * harbour/contrib/hbqt/generator/hbqtgen.prg ! StdOut() used instead of ?. ! More parameter resolved. --- harbour/ChangeLog | 5 ++ harbour/contrib/hbqt/generator/hbqtgen.prg | 85 +++++++++++++++------- 2 files changed, 63 insertions(+), 27 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 4b1852bbd5..a35fb4c1cf 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,11 @@ 2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-04-06 09:36 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * harbour/contrib/hbqt/generator/hbqtgen.prg + ! StdOut() used instead of ?. + ! More parameter resolved. + 2009-04-06 19:35 UTC+0200 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt) * harbour/source/rtl/hbstrfmt.c + added precision support for %s and %d. diff --git a/harbour/contrib/hbqt/generator/hbqtgen.prg b/harbour/contrib/hbqt/generator/hbqtgen.prg index 9fc0190f2f..83530e28d8 100644 --- a/harbour/contrib/hbqt/generator/hbqtgen.prg +++ b/harbour/contrib/hbqt/generator/hbqtgen.prg @@ -68,6 +68,9 @@ FUNCTION Main( ... ) LOCAL aProFiles := {} LOCAL lCompile := .f. + s_NewLine := hb_OsNewLine() + s_PathSep := hb_OsPathSeparator() + DispLogo() IF PCount() == 0 @@ -75,9 +78,6 @@ FUNCTION Main( ... ) RETURN nil ENDIF - s_NewLine := hb_OsNewLine() - s_PathSep := hb_OsPathSeparator() - aParam := hb_AParams() FOR EACH cParam IN aParam @@ -172,7 +172,7 @@ STATIC FUNCTION ManageProject( cProFile, cPathIn, cPathOut, cPathDoc ) cpp_:={} prg_:={} - OutStd( cFile ) + OutStd( cFile + s_NewLine ) cPrj := memoread( cFile ) @@ -184,7 +184,7 @@ STATIC FUNCTION ManageProject( cProFile, cPathIn, cPathOut, cPathDoc ) /* We must have a matching pair */ nn := at( '*/', cPrj ) IF nn == 0 - ? 'Project file has unbalanced comment section...' + OutStd( 'Project file has unbalanced comment section...' + s_NewLine ) RETURN nil ENDIF cPrj := substr( cPrj,1,n-1 ) + substr( cPrj,nn+2 ) @@ -292,7 +292,7 @@ STATIC FUNCTION GenSource( cProFile, cPathIn, cPathOut, cPathDoc ) RETURN nil ENDIF - OutStd( cFile ) + OutStd( cFile + s_NewLine ) /* Prepare to be parsed properly */ cQth := strtran( cQth, s_NewLine , _EOL ) @@ -465,6 +465,7 @@ STATIC FUNCTION ParseProto( cProto, cWidget, txt_, doc_, aEnum, func_ ) LOCAL cPre, cPar, cRet, cFun, cFunRet, cParas, cDocs, cCmd, cPas, s, ss LOCAL cWdg, cCmn, cPrgRet, cHBFunc, cHBIdx, cDocNM LOCAL lConst, lAnd, lStar, lVirt, lSuccess + LOCAL cIntegers := 'int,qint16,qint32,qint64,quint16,quint32,quint64,qlonglong,qulonglong,QRgb,QChar' cParas := '' cDocs := '' @@ -603,12 +604,12 @@ STATIC FUNCTION ParseProto( cProto, cWidget, txt_, doc_, aEnum, func_ ) aA[ PRT_DOC ] := 'x'+ cDocNM /* Values by reference */ - CASE aA[ PRT_CAST ] $ 'int,qint16,qint32,qint64,quint16,quint32,quint64,QRgb' .and. aA[ PRT_L_FAR ] + CASE aA[ PRT_CAST ] $ cIntegers .and. aA[ PRT_L_FAR ] aadd( aPre, { 'int i'+cDocNM+' = 0;', nHBIdx, 'i'+ cDocNM, 'hb_storni' } ) aA[ PRT_BODY ] := '&i'+cDocNM aA[ PRT_DOC ] := '@n'+ cDocNM - CASE aA[ PRT_CAST ] $ 'int,qint16,qint32,qint64,quint16,quint32,quint64,QRgb' + CASE aA[ PRT_CAST ] $ cIntegers s := 'hb_parni( '+ cHBIdx +' )' IF !empty( aA[ PRT_DEFAULT ] ) aA[ PRT_BODY ] := '( HB_ISNIL( '+cHBIdx+' ) ? '+aA[ PRT_DEFAULT ]+' : '+ s + ' )' @@ -647,6 +648,11 @@ STATIC FUNCTION ParseProto( cProto, cWidget, txt_, doc_, aEnum, func_ ) ENDIF aA[ PRT_DOC ] := 'n'+ cDocNM + CASE aA[ PRT_CAST ] == 'bool' .and. aA[ PRT_L_FAR ] + aadd( aPre, { 'bool i'+cDocNM+' = 0;', nHBIdx, 'i'+ cDocNM, 'hb_stornl' } ) + aA[ PRT_BODY ] := '&i'+cDocNM + aA[ PRT_DOC ] := '@l'+ cDocNM + CASE aA[ PRT_CAST ] == 'bool' aA[ PRT_BODY ] := 'hb_parl( '+ cHBIdx +' )' aA[ PRT_DOC ] := 'l'+ cDocNM @@ -667,6 +673,10 @@ STATIC FUNCTION ParseProto( cProto, cWidget, txt_, doc_, aEnum, func_ ) aA[ PRT_BODY ] := 'hbqt_par_WId( '+ cHBIdx +' )' aA[ PRT_DOC ] := 'h'+ cDocNM + CASE aA[ PRT_CAST ] == 'HRGN' + aA[ PRT_BODY ] := 'hbqt_par_HRGN( '+ cHBIdx +' )' + aA[ PRT_DOC ] := 'h'+ cDocNM + CASE aA[ PRT_CAST ] == 'FT_Face' aA[ PRT_BODY ] := 'hbqt_par_FT_Face( '+ cHBIdx +' )' aA[ PRT_DOC ] := 'c'+ cDocNM @@ -744,7 +754,7 @@ STATIC FUNCTION ParseProto( cProto, cWidget, txt_, doc_, aEnum, func_ ) cCmd := cCmn cPrgRet := 'NIL' - CASE aA[ PRT_CAST ] $ 'int,qint16,qint32,qint64,quint16,quint32,quint64,QRgb,char' + CASE aA[ PRT_CAST ] $ cIntegers cCmd := 'hb_retni( '+ cCmn +' )' cPrgRet := 'n'+cDocNM @@ -760,6 +770,10 @@ STATIC FUNCTION ParseProto( cProto, cWidget, txt_, doc_, aEnum, func_ ) cCmd := 'hb_retl( '+ cCmn +' )' cPrgRet := 'l'+cDocNM + CASE aA[ PRT_CAST ] == 'char' + cCmd := 'hb_retni( '+ cCmn +' )' + cPrgRet := 'c'+cDocNM + CASE aA[ PRT_CAST ] == 'QString' cCmd := 'hb_retc( '+ cCmn +'.toLatin1().data()' +' )' cPrgRet := 'c'+cDocNM @@ -776,6 +790,10 @@ STATIC FUNCTION ParseProto( cProto, cWidget, txt_, doc_, aEnum, func_ ) cCmd := 'hb_retptr( ( HWND ) '+ cCmn +' )' cPrgRet := 'h'+cDocNM + CASE aA[ PRT_CAST ] == 'HRGN' + cCmd := 'hb_retptr( ( HRGN ) '+ cCmn +' )' + cPrgRet := 'h'+cDocNM + CASE aA[ PRT_CAST ] == 'FT_Face' cCmd := 'hb_retc( '+ cCmn +' )' cPrgRet := 'c'+cDocNM @@ -827,7 +845,7 @@ STATIC FUNCTION ParseProto( cProto, cWidget, txt_, doc_, aEnum, func_ ) cPrgRet := 'p'+cDocNM ELSE - ? '<<< '+cProto + ' | ' + aA[ PRT_CAST ]+' >>>' + OutStd( '<<< '+cProto + ' | ' + aA[ PRT_CAST ]+' >>>' + s_NewLine ) cCmd := '' cPrgRet := '' @@ -837,7 +855,7 @@ STATIC FUNCTION ParseProto( cProto, cWidget, txt_, doc_, aEnum, func_ ) IF !empty( cCmd ) cCmd := strtran( cCmd, '( )', '()' ) +';' - ? cCmd + OutStd( cCmd + s_NewLine ) ENDIF ENDIF ENDIF @@ -979,30 +997,36 @@ STATIC FUNCTION BuildFooter( txt_ ) /*----------------------------------------------------------------------*/ STATIC FUNCTION DispHelp() + LOCAL cHlp := '' - ? - ? 'SYNTAX:' - ? ' hbqtgen.exe [Options] [[@]] []' - ? - ? 'Options:' - ? ' -O [ e.g. c:\harbour\contrib\hbqt ] [D] Current folder' - ? ' -I [ e.g. c:\harbour\contrib\hbqt\protos ] [D] Current folder' - ? ' -D [ e.g. c:\harbour\contrib\hbqt\doc ] [D] Current folder' - ? ' ' - ? ' -c If QT env is set, attempts to compile resulting .cpp' - ? - inkey( 0 ) + cHlp += '' + s_NewLine + cHlp += 'SYNTAX:' + s_NewLine + cHlp += ' hbqtgen.exe [Options] [[@]] []' + s_NewLine + cHlp += '' + s_NewLine + cHlp += 'Options:' + s_NewLine + cHlp += ' -O [ e.g. c:\harbour\contrib\hbqt ] [D] Current folder' + s_NewLine + cHlp += ' -I [ e.g. c:\harbour\contrib\hbqt\protos ] [D] Current folder' + s_NewLine + cHlp += ' -D [ e.g. c:\harbour\contrib\hbqt\doc ] [D] Current folder' + s_NewLine + cHlp += ' ' + s_NewLine + cHlp += ' -c If QT env is set, attempts to compile resulting .cpp' + s_NewLine + cHlp += '' + s_NewLine + + OutStd( cHlp ) RETURN nil /*----------------------------------------------------------------------*/ STATIC FUNCTION DispLogo() + LOCAL cHlp := '' - OutStd( hb_osNewLine() + "Harbour Source Gennerator for QT " + HBRawVersion() + hb_osNewLine() +; - "Copyright (c) 2009, Pritpal Bedi " + hb_osNewLine() +; - "http://www.harbour-project.org/" + hb_osNewLine() +; - hb_osNewLine() ) + cHlp += '' + s_NewLine + cHlp += "Harbour Source Gennerator for QT " + HBRawVersion() + s_NewLine + cHlp += "Copyright (c) 2009, Pritpal Bedi " + s_NewLine + cHlp += "http://www.harbour-project.org/" + s_NewLine + cHlp += '' + s_NewLine + + OutStd( cHlp ) RETURN nil @@ -1351,6 +1375,12 @@ STATIC FUNCTION Build_HBQT_H( cPathOut ) aadd( txt_, "#define hbqt_par_WId( n ) ( ( HWND* ) hb_parptr( n ) ) " ) aadd( txt_, "#define hbqt_par_HDC( n ) ( ( HDC* ) hb_parptr( n ) ) " ) aadd( txt_, "#define hbqt_par_QBitmap( n ) ( ( QBitmap* ) hb_parptr( n ) ) " ) + aadd( txt_, "#define hbqt_par_QTextStream( n ) ( ( QTextStream* ) hb_parptr( n ) ) " ) + aadd( txt_, "#define hbqt_par_QTextCodec( n ) ( ( QTextCodec* ) hb_parptr( n ) ) " ) + aadd( txt_, "#define hbqt_par_QEventLoop( n ) ( ( QEventLoop* ) hb_parptr( n ) ) " ) + aadd( txt_, "#define hbqt_par_QPaintEvent( n ) ( ( QPaintEvent* ) hb_parptr( n ) ) " ) + aadd( txt_, "#define hbqt_par_QInputEvent( n ) ( ( QInputEvent* ) hb_parptr( n ) ) " ) + aadd( txt_, "#define hbqt_par_HRGN( n ) ( ( HRGN* ) hb_parptr( n ) ) " ) aadd( txt_, " " ) aadd( txt_, "#define hbqt_par_QIcon( n ) ( ( QIcon ) hb_parc( n ) ) " ) aadd( txt_, "#define hbqt_par_QString( n ) ( ( QString ) hb_parc( n ) ) " ) @@ -2357,3 +2387,4 @@ STATIC FUNCTION Build_Demo( cPathOut ) /*----------------------------------------------------------------------*/ +