2012-11-06 21:18 UTC+0100 Viktor Szakats (harbour syenar.net)
* contrib/hbct/hbct.hbx
* minor cleanup
+ contrib/hbformat/hbfuncs.prg
* contrib/hbformat/hbfmtcls.prg
* contrib/hbformat/hbformat.hbp
* contrib/hbformat/hbformat.hbx
* moved function name loading functions to
separate file
+ proper cased function names will now be loaded
from .hbr files and /contrib and /addons
folder structures automatically.
This commit is contained in:
@@ -16,6 +16,20 @@
|
||||
The license applies to all entries newer than 2009-04-28.
|
||||
*/
|
||||
|
||||
2012-11-06 21:18 UTC+0100 Viktor Szakats (harbour syenar.net)
|
||||
* contrib/hbct/hbct.hbx
|
||||
* minor cleanup
|
||||
|
||||
+ contrib/hbformat/hbfuncs.prg
|
||||
* contrib/hbformat/hbfmtcls.prg
|
||||
* contrib/hbformat/hbformat.hbp
|
||||
* contrib/hbformat/hbformat.hbx
|
||||
* moved function name loading functions to
|
||||
separate file
|
||||
+ proper cased function names will now be loaded
|
||||
from .hbr files and /contrib and /addons
|
||||
folder structures automatically.
|
||||
|
||||
2012-11-06 20:08 UTC+0100 Viktor Szakats (harbour syenar.net)
|
||||
* utils/hbmk2/hbmk2.prg
|
||||
+ hbmk2 will now read *.hbr for function/lib pairs
|
||||
|
||||
@@ -143,17 +143,17 @@ DYNAMIC CSetCurs
|
||||
DYNAMIC CSetKey
|
||||
DYNAMIC CSetRef
|
||||
DYNAMIC CSetSafety
|
||||
DYNAMIC CTCExit
|
||||
DYNAMIC CTCInit
|
||||
DYNAMIC CTExit
|
||||
DYNAMIC CTInit
|
||||
DYNAMIC ctcexit
|
||||
DYNAMIC ctcinit
|
||||
DYNAMIC ctexit
|
||||
DYNAMIC ctinit
|
||||
DYNAMIC CToBit
|
||||
DYNAMIC CToDoW
|
||||
DYNAMIC CToF
|
||||
DYNAMIC CToMonth
|
||||
DYNAMIC CToN
|
||||
DYNAMIC CTWInit
|
||||
DYNAMIC CTWLastKey
|
||||
DYNAMIC ctwinit
|
||||
DYNAMIC ctwLastKey
|
||||
DYNAMIC CurrentGet
|
||||
DYNAMIC DaysInMonth
|
||||
DYNAMIC DaysToMonth
|
||||
|
||||
@@ -86,7 +86,6 @@ CREATE CLASS HBFORMATCODE
|
||||
|
||||
VAR nEol INIT 0 // Eol: -1 - no change, 0 - OS default, 1 - DOS, 2 - UNIX
|
||||
VAR lFCaseLow INIT .F. // If true, convert file name to lower case
|
||||
VAR lNoTabs INIT .T. // If true, converts all tabs to spaces
|
||||
VAR lIndent INIT .T. // If true, indent code
|
||||
VAR lCase INIT .T. // If true, make case conversion
|
||||
VAR lSpaces INIT .T. // If true, reformat spaces
|
||||
@@ -110,8 +109,8 @@ CREATE CLASS HBFORMATCODE
|
||||
VAR nLineRet INIT 1 // -1 - no change, 1 - insert empty line before return, 2 - remove it
|
||||
VAR nLineVar INIT 1 // -1 - no change, 1 - insert empty line before variables declaration, 2 - remove it
|
||||
VAR nLineCode INIT 1 // -1 - no change, 1 - insert empty line before code in function, 2 - remove it
|
||||
VAR nBr4Comma INIT 1 // Max level of nesting in brackets, while space is added after a comma
|
||||
VAR nBr4Brac INIT 2 // Max level of nesting in brackets, while space is added after/before a bracket
|
||||
VAR nBr4Comma INIT 8 // Max level of nesting in brackets, while space is added after a comma
|
||||
VAR nBr4Brac INIT 8 // Max level of nesting in brackets, while space is added after/before a bracket
|
||||
VAR cHBXList INIT ""
|
||||
|
||||
VAR cExtSave INIT "" // Extension for a formatted file ( "" - replace original )
|
||||
@@ -148,7 +147,7 @@ ENDCLASS
|
||||
|
||||
METHOD New( aParams, cIniName ) CLASS HBFORMATCODE
|
||||
|
||||
LOCAL cParam, cHBX
|
||||
LOCAL cParam
|
||||
|
||||
::nErr := 0
|
||||
|
||||
@@ -172,19 +171,19 @@ METHOD New( aParams, cIniName ) CLASS HBFORMATCODE
|
||||
IF !( Right( ::cCommands, 1 ) == "," )
|
||||
::cCommands += ","
|
||||
ENDIF
|
||||
::cCommands += "IF,ELSEIF,ELSE,ENDIF,END,DO,WHILE,ENDDO,WITH,CASE,OTHERWISE,ENDCASE,BEGIN," +;
|
||||
"FUNCTION,PROCEDURE,RETURN,CLASS,ENDCLASS,METHOD,DATA,LOCAL,PRIVATE,PUBLIC,STATIC,FIELD,MEMVAR,PARAMETERS,DECLARE," +;
|
||||
"ACCEPT,APPEND,AVERAGE,CLEAR,CLOSE,COMMIT,CONTINUE,COPY,COUNT,CREATE,DEFAULT," +;
|
||||
"DELETE,DISPLAY,EJECT,ERASE,EXIT,FOR,GO,GOTO,INDEX,INPUT,JOIN,KEYBOARD,LABEL,LIST,LOCATE," +;
|
||||
"LOOP,MENU,NEXT,PACK,PRINT,QUIT,READ,RECALL,REINDEX,RELEASE,RENAME,REQUEST,REPLACE,RESTORE," +;
|
||||
"RUN,SAVE,SEEK,SELECT,SET,SKIP,SORT,STORE,SUM,TEXT,TOTAL,UNLOCK,USE,WAIT,ZAP,"
|
||||
::cCommands += "IF,ELSE,ELSEIF,END,ENDIF,DO,WHILE,ENDDO,WITH,CASE,OTHERWISE,ENDCASE,BEGIN,ANNOUNCE,REQUEST,THREAD,DYNAMIC,EXTERNAL," + ;
|
||||
"FUNCTION,PROCEDURE,RETURN,CLASS,ENDCLASS,METHOD,DATA,LOCAL,PRIVATE,PUBLIC,STATIC,FIELD,MEMVAR,PARAMETERS,DECLARE," + ;
|
||||
"ACCEPT,APPEND,AVERAGE,CLEAR,CLOSE,COMMIT,CONTINUE,COPY,COUNT,CREATE,DEFAULT," + ;
|
||||
"DELETE,DISPLAY,EJECT,ERASE,EXIT,FOR,GO,GOTO,INDEX,INIT,INPUT,JOIN,KEYBOARD,LABEL,LIST,LOCATE," + ;
|
||||
"LOOP,MENU,NEXT,PACK,PRINT,QUIT,READ,RECALL,REINDEX,RELEASE,RENAME,REQUEST,REPLACE,RESTORE," + ;
|
||||
"RUN,SAVE,SEEK,SELECT,SET,SKIP,SORT,STORE,SUM,TEXT,TOTAL,UNLOCK,USE,VAR,WAIT,ZAP,"
|
||||
|
||||
IF !( Right( ::cClauses, 1 ) == "," )
|
||||
::cClauses += ","
|
||||
ENDIF
|
||||
::cClauses += "ADDITIVE,ALIAS,ALL,BLANK,BOTTOM,BOX,COLOR,DATE,DELETED,EACH,EXTENDED,EXCLUSIVE,FROM,GET," +;
|
||||
"RANGE,READONLY,REST,SAY,SCREEN,ALTERNATE,BELL,CENTURY,CONFIRM,CONSOLE,CURSOR,DECIMALS,DELIMITERS,DEVICE,EPOCH,ESCAPE," +;
|
||||
"EXACT,EXCLUSIVE,FILTER,FIXED,FORMAT,INTENSITY,KEY,LIKE,MARGIN,MESSAGE,NEW,OFF,ON,ORDER,PATH,PICTURE,PRINTER,PROMPT," +;
|
||||
::cClauses += "ADDITIVE,ALIAS,ALL,BLANK,BOTTOM,BOX,COLOR,DATE,DELETED,EACH,EXTENDED,EXCLUSIVE,FROM,GET," + ;
|
||||
"RANGE,READONLY,REST,SAY,SCREEN,ALTERNATE,BELL,CENTURY,CONFIRM,CONSOLE,CURSOR,DECIMALS,DELIMITERS,DEVICE,EPOCH,ESCAPE," + ;
|
||||
"EXACT,EXCLUSIVE,FILTER,FIXED,FORMAT,INHERIT,INTENSITY,KEY,LIKE,MARGIN,MESSAGE,NEW,NIL,OFF,ON,ORDER,PATH,PICTURE,PRINTER,PROMPT," + ;
|
||||
"PROTECTED,RELATION,SCOREBOARD,SEQUENCE,SOFTSEEK,STEP,STRUCTURE,TYPEAHEAD,UNIQUE,WRAP,TAG,TO,TOP,VALID,WHEN,"
|
||||
|
||||
IF !( Right( ::cFunctions, 1 ) == "," )
|
||||
@@ -192,10 +191,7 @@ METHOD New( aParams, cIniName ) CLASS HBFORMATCODE
|
||||
ENDIF
|
||||
IF !( ",STR," $ Upper( ::cFunctions ) )
|
||||
::cFunctions += "iif,ISNIL,ISARRAY,ISBLOCK,ISCHARACTER,ISDATE,ISLOGICAL,ISMEMO,ISNUMBER,ISOBJECT,Main"
|
||||
HBXToFuncList( @::cFunctions, __harbour_hbx() )
|
||||
FOR EACH cHBX IN hb_ATokens( ::cHBXList )
|
||||
HBXToFuncList( @::cFunctions, hb_MemoRead( hb_PathJoin( hb_DirBase(), cHBX ) ) )
|
||||
NEXT
|
||||
__hbformat_BuildListOfFunctions( @::cFunctions, ::cHBXList )
|
||||
ENDIF
|
||||
|
||||
IF ::nEol == 2
|
||||
@@ -205,27 +201,9 @@ METHOD New( aParams, cIniName ) CLASS HBFORMATCODE
|
||||
ELSEIF ::nEol == 0
|
||||
::cEol := hb_eol()
|
||||
ENDIF
|
||||
IF ::lIndent
|
||||
::lNoTabs := .T.
|
||||
ENDIF
|
||||
|
||||
RETURN Self
|
||||
|
||||
STATIC PROCEDURE HBXToFuncList( /* @ */ cFuncList, cHBX )
|
||||
LOCAL cLine
|
||||
|
||||
FOR EACH cLine IN hb_ATokens( StrTran( cHBX, Chr( 13 ) ), Chr( 10 ) )
|
||||
IF Left( cLine, Len( "DYNAMIC " ) ) == "DYNAMIC "
|
||||
cFuncList += "," + SubStr( cLine, Len( "DYNAMIC " ) + 1 )
|
||||
ENDIF
|
||||
NEXT
|
||||
|
||||
RETURN
|
||||
|
||||
STATIC FUNCTION __harbour_hbx()
|
||||
|
||||
#pragma __streaminclude "harbour.hbx" | RETURN %s
|
||||
|
||||
METHOD Reformat( aFile ) CLASS HBFORMATCODE
|
||||
|
||||
LOCAL i, iDelta := 0, nLen := Len( aFile ), cToken1, cToken2, nLenToken, nPos
|
||||
@@ -257,7 +235,7 @@ METHOD Reformat( aFile ) CLASS HBFORMATCODE
|
||||
LOOP
|
||||
ENDIF
|
||||
IF lComment
|
||||
IF ( nPos := FindNotQuoted( "*/", aFile[ i ] ) ) != 0
|
||||
IF ( nPos := hb_At( "*/", aFile[ i ] ) ) != 0
|
||||
lComment := .F.
|
||||
IF ! Empty( cToken1 := SubStr( aFile[ i ], nPos + 2 ) )
|
||||
aFile[ i ] := Left( aFile[ i ], nPos + 1 )
|
||||
@@ -295,19 +273,22 @@ METHOD Reformat( aFile ) CLASS HBFORMATCODE
|
||||
cLineAll := Left( cLineAll, nPos - 1 ) + "//" + SubStr( cLineAll, nPos + 2 )
|
||||
ENDIF
|
||||
ENDIF
|
||||
IF nPosComment > 0
|
||||
nPos := nPosComment + iif( SubStr( cLineAll, nPosComment, 1) == "*", 1, 2 )
|
||||
if SubStr( cLineAll, nPos, 1 ) != " "
|
||||
cLineAll := Left( cLineAll, nPos - 1) + " " + SubStr( cLineAll, nPos )
|
||||
endif
|
||||
endif
|
||||
IF ( nPos := FindNotQuoted( "/*", cLineAll ) ) != 0 .AND. ( nPosComment == 0 .OR. nPosComment > nPos )
|
||||
nPosComment := nPos
|
||||
IF ( nPos := FindNotQuoted( "*/", cLineAll, nPos + 2 ) ) != 0
|
||||
IF ! Empty( cToken1 := SubStr( cLineAll, nPos + 2 ) )
|
||||
cLineAll := Left( cLineAll, nPos + 1 )
|
||||
nLen := rf_AINS( aFile, i + 1, cToken1 )
|
||||
iDelta++
|
||||
ENDIF
|
||||
ELSE
|
||||
IF hb_At( "*/", cLineAll, nPos + 2 ) == 0
|
||||
lComment := .T.
|
||||
ENDIF
|
||||
ENDIF
|
||||
IF ! lPragmaDump .AND. ::lIndent .AND. ( ! lComment .OR. nPosComment > 1 )
|
||||
if nPosComment == 1 .AND. nDeep == 0 .and. nState == RF_STATE_RET
|
||||
nState := 0
|
||||
endif
|
||||
IF ! lPragmaDump .AND. ::lIndent .AND. ! lComment
|
||||
aFile[ i ] := cLineAll
|
||||
IF ! lContinue
|
||||
nPosSep := 1
|
||||
@@ -337,10 +318,12 @@ METHOD Reformat( aFile ) CLASS HBFORMATCODE
|
||||
ENDIF
|
||||
cToken2 := Lower( hb_tokenGet( cLine, 2 ) )
|
||||
IF Left( cToken1, 1 ) == "#"
|
||||
ELSEIF nLenToken >= 4 .AND. ( ( LEFTEQUAL( "static", cToken1 ) .AND. ;
|
||||
( LEFTEQUAL( "function", cToken2 ) .OR. LEFTEQUAL( "procedure", cToken2 ) ) ) .OR. ;
|
||||
LEFTEQUAL( "function", cToken1 ) .OR. LEFTEQUAL( "procedure", cToken1 ) ;
|
||||
.OR. ( "method" == cToken1 .AND. ! lClass ) .OR. ;
|
||||
ELSEIF nLenToken >= 4 .AND. ( ;
|
||||
( LEFTEQUAL( "static", cToken1 ) .AND. ( LEFTEQUAL( "function", cToken2 ) .OR. LEFTEQUAL( "procedure", cToken2 ) ) ) .OR. ;
|
||||
( Len( cToken2 ) >= 4 .AND. LEFTEQUAL( "procedure", cToken2 ) .AND. ( "init" == cToken1 .OR. "exit" == cToken1 ) ) .OR. ;
|
||||
LEFTEQUAL( "function", cToken1 ) .OR. ;
|
||||
LEFTEQUAL( "procedure", cToken1 ) .OR. ;
|
||||
( "method" == cToken1 .AND. ! lClass ) .OR. ;
|
||||
( "class" == cToken1 .AND. ! lClass ) .OR. ;
|
||||
( "create" == cToken1 .AND. "class" == cToken2 .AND. ! lClass ) )
|
||||
IF nDeep == 0
|
||||
@@ -354,6 +337,13 @@ METHOD Reformat( aFile ) CLASS HBFORMATCODE
|
||||
::cLineErr := cLine
|
||||
RETURN .F.
|
||||
ENDIF
|
||||
ELSEIF nLenToken >= 4 .AND. ( ;
|
||||
LEFTEQUAL( "request", cToken1 ) .OR. ;
|
||||
LEFTEQUAL( "announce", cToken1 ) .OR. ;
|
||||
LEFTEQUAL( "dynamic", cToken1 ) .OR. ;
|
||||
LEFTEQUAL( "external", cToken1 ) .OR. ;
|
||||
LEFTEQUAL( "thread", cToken1 ) )
|
||||
nState := 0
|
||||
ELSEIF nLenToken >= 4 .AND. ( ;
|
||||
LEFTEQUAL( "local", cToken1 ) .OR. ;
|
||||
LEFTEQUAL( "private", cToken1 ) .OR. ;
|
||||
@@ -372,7 +362,7 @@ METHOD Reformat( aFile ) CLASS HBFORMATCODE
|
||||
nState := RF_STATE_RET
|
||||
ENDIF
|
||||
ELSE
|
||||
IF !( cToken1 == "request" )
|
||||
IF nState > 0
|
||||
nState := RF_STATE_CODE
|
||||
ENDIF
|
||||
IF ( nContrState := Ascan( ::aContr, ;
|
||||
@@ -415,15 +405,11 @@ METHOD Reformat( aFile ) CLASS HBFORMATCODE
|
||||
IF Left( cLine, 1 ) == "#" .AND. ! ::lIndDrt
|
||||
nIndent := 0
|
||||
ENDIF
|
||||
IF Left( cLine, 2 ) == "//" .AND. nDeep == 0
|
||||
nIndent := 0
|
||||
ENDIF
|
||||
cLineAll := Space( nIndent ) + ::FormatLine( cLine )
|
||||
|
||||
IF i > 1 .AND. ( ( nState == RF_STATE_RET .AND. ::nLineRet > 0 ) .OR. ;
|
||||
( nState == RF_STATE_FUNC .AND. ::nLineFnc > 0 ) .OR. ;
|
||||
( nState == RF_STATE_VAR .AND. nStatePrev != nState .AND. ::nLineVar > 0 ) .OR. ;
|
||||
( nState == RF_STATE_CODE .AND. nStatePrev != nState .AND. ::nLineCode > 0 ) )
|
||||
IF i > 1 .AND. ( ( nState == RF_STATE_RET .AND. ::nLineRet > 0 .AND. nStatePrev != RF_STATE_FUNC ) .OR. ;
|
||||
( nState == RF_STATE_FUNC .AND. ::nLineFnc > 0 .AND. nStatePrev > 0 ) .OR. ;
|
||||
( nState == RF_STATE_VAR .AND. nStatePrev != nState .AND. ::nLineVar > 0 ) .OR. ;
|
||||
( nState == RF_STATE_CODE .AND. nStatePrev != nState .AND. ::nLineCode > 0 ) )
|
||||
nPos := i - 1
|
||||
IF ( nState == RF_STATE_RET .AND. ::nLineRet == 1 ) .OR. ;
|
||||
( nState == RF_STATE_FUNC .AND. ::nLineFnc == 1 ) .OR. ;
|
||||
@@ -447,8 +433,11 @@ METHOD Reformat( aFile ) CLASS HBFORMATCODE
|
||||
ELSE
|
||||
cLineAll += ::FormatLine( cLine )
|
||||
ENDIF
|
||||
IF lClass .AND. nState == RF_STATE_RET
|
||||
lClass := .F.
|
||||
IF nState == RF_STATE_RET
|
||||
IF lClass
|
||||
lClass := .F.
|
||||
endif
|
||||
nState := 0
|
||||
ENDIF
|
||||
IF nPosSep == 0 .OR. nPosSep == Len( aFile[ i ] )
|
||||
EXIT
|
||||
@@ -550,8 +539,16 @@ METHOD FormatLine( cLine, lContinued ) CLASS HBFORMATCODE
|
||||
cSymb := c
|
||||
nState := FL_STATE_QUOTED
|
||||
ELSEIF c == "["
|
||||
nState := FL_STATE_SQBR
|
||||
ELSEIF c == "/" .AND. ( ( c := SubStr( cLine, i + 1, 1 ) ) == "/" .OR. c == "*" )
|
||||
IF nState == FL_STATE_STRING .OR. nState == FL_STATE_ANY
|
||||
IF nEnd == nBegin
|
||||
nEnd := i
|
||||
ENDIF
|
||||
::ConvertCmd( @cLine, nBegin, nEnd )
|
||||
nA := i
|
||||
ELSE
|
||||
nState := FL_STATE_SQBR
|
||||
ENDIF
|
||||
ELSEIF c == "/" .AND. ( SubStr( cLine, i + 1, 1 ) $ "*/" )
|
||||
IF nState == FL_STATE_STRING
|
||||
IF nEnd == nBegin
|
||||
nEnd := i
|
||||
@@ -566,6 +563,16 @@ METHOD FormatLine( cLine, lContinued ) CLASS HBFORMATCODE
|
||||
i++
|
||||
ENDDO
|
||||
i--
|
||||
IF ( SubStr( cLine, i + 1, 1 ) == "," .AND. ! SubStr( cLine, nEnd - 1, 1 ) $ "(," ) .OR. ;
|
||||
"*" + SubStr( cLine, nEnd - 1, 1 ) + SubStr( cLine, i + 1, 1 ) + "*" $ "*{}*()*][*{|*||*" .OR. ;
|
||||
SubStr( cLine, i + 1, 2 ) == "->" .OR. ;
|
||||
SubStr( cLine, nEnd - 2, 2 ) == "->" .OR. ;
|
||||
( nState == FL_STATE_STRING .AND. ( SubStr( cLine, i + 1, 1 ) == "[" .OR. "*" + SubStr( cLine, i + 1, 3 ) + "*" $ "*-- *++ *" ) ) .OR. ;
|
||||
( nState != FL_STATE_STRING .AND. "*" + SubStr( cLine, nEnd - 3, 3 ) + "*" $ "* --* ++*" )
|
||||
cLine := Left( cLine, nEnd - 1 ) + SubStr( cLine, i + 1 )
|
||||
nLen := Len( cLine )
|
||||
i := nEnd
|
||||
ENDIF
|
||||
ELSEIF c == "(" .OR. c == "{"
|
||||
aBrackets[ iif( c == "(", 1, 2 ) ]++
|
||||
IF nState == FL_STATE_STRING
|
||||
@@ -577,7 +584,7 @@ METHOD FormatLine( cLine, lContinued ) CLASS HBFORMATCODE
|
||||
ENDIF
|
||||
ENDIF
|
||||
IF ::lSpaces .AND. aBrackets[ iif( c == "(", 1, 2 ) ] <= ::nBr4Brac .AND. ;
|
||||
i < nLen .AND. !( SubStr( cLine, i + 1, 1 ) $ iif( c == "(", " )", " |} " ) )
|
||||
i < nLen .AND. !( SubStr( cLine, i + 1, 1 ) $ iif( c == "(", " )", " |}" ) )
|
||||
nA := i
|
||||
ENDIF
|
||||
nState := FL_STATE_ANY
|
||||
@@ -619,9 +626,24 @@ METHOD FormatLine( cLine, lContinued ) CLASS HBFORMATCODE
|
||||
IF SubStr( cLine, i + 1, 1 ) $ cOperators
|
||||
i++
|
||||
ENDIF
|
||||
IF c == "-" // .AND. SubStr( cLine, i + 1, 1 ) $ "1234567890"
|
||||
IF nState == FL_STATE_STRING
|
||||
IF ::ConvertCmd( @cLine, nBegin, nEnd )
|
||||
nState := FL_STATE_ANY
|
||||
ELSE
|
||||
nA := i
|
||||
nState := FL_STATE_OP
|
||||
ENDIF
|
||||
ELSEIF nState == FL_STATE_OP
|
||||
nState := FL_STATE_ANY
|
||||
ENDIF
|
||||
ELSE
|
||||
nA := i
|
||||
nState := FL_STATE_OP
|
||||
ENDIF
|
||||
ELSEIF c == "|" .AND. SubStr( cLine, i + 1, 1 ) != "|"
|
||||
nA := i
|
||||
nState := FL_STATE_OP
|
||||
ELSEIF c == ")" .OR. c == "}"
|
||||
ELSEIF c == ")" .OR. c == "}" .OR. c == "]"
|
||||
IF ::lSpaces .AND. aBrackets[ iif( c == "(", 1, 2 ) ] <= ::nBr4Brac .AND. ;
|
||||
i > 1 .AND. !( SubStr( cLine, i - 1, 1 ) $ " ({" )
|
||||
nB := i
|
||||
@@ -635,7 +657,7 @@ METHOD FormatLine( cLine, lContinued ) CLASS HBFORMATCODE
|
||||
lFirst := .F.
|
||||
ENDIF
|
||||
IF !( "|" + SubStr( cLine, nB, 2 ) + "|" $ "|--|++|->|" )
|
||||
IF nA != 0 .AND. ::lSpaces .AND. nA < nLen .AND. !( SubStr( cLine, nA + 1, 1 ) == " " )
|
||||
IF nA != 0 .AND. ::lSpaces .AND. nA < nLen .AND. !( SubStr( cLine, nA + 1, 1 ) $ " ," )
|
||||
cLine := Left( cLine, nA ) + " " + SubStr( cLine, nA + 1 )
|
||||
nLen++
|
||||
i++
|
||||
|
||||
@@ -12,3 +12,4 @@
|
||||
hbformat.hbx
|
||||
|
||||
hbfmtcls.prg
|
||||
hbfuncs.prg
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#endif
|
||||
|
||||
DYNAMIC HBFormatCode
|
||||
DYNAMIC __HBFORMAT_BUILDLISTOFFUNCTIONS
|
||||
|
||||
#if defined( __HBEXTREQ__ ) .OR. defined( __HBEXTERN__HBFORMAT__REQUEST )
|
||||
#uncommand DYNAMIC <fncs,...> => EXTERNAL <fncs>
|
||||
|
||||
117
harbour/contrib/hbformat/hbfuncs.prg
Normal file
117
harbour/contrib/hbformat/hbfuncs.prg
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Processing .hbx files for function lists
|
||||
*
|
||||
* Copyright 2012 Viktor Szakats (harbour syenar.net)
|
||||
* www - http://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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "directry.ch"
|
||||
|
||||
PROCEDURE __hbformat_BuildListOfFunctions( /* @ */ cFunctions, cHBXList )
|
||||
|
||||
LOCAL aFile
|
||||
LOCAL cName
|
||||
LOCAL lAnyHBR
|
||||
|
||||
/* from built-in core .hbx file */
|
||||
HBXToFuncList( @cFunctions, __harbour_hbx() )
|
||||
|
||||
/* from .hbr container files */
|
||||
lAnyHBR := .F.
|
||||
FOR EACH aFile IN Directory( hb_DirBase() + "*.hbr" )
|
||||
lAnyHBR := .T.
|
||||
FOR EACH cName IN hb_Deserialize( hb_ZUncompress( hb_MemoRead( hb_DirBase() + aFile[ F_NAME ] ) ) )
|
||||
cFunctions += "," + cName
|
||||
NEXT
|
||||
NEXT
|
||||
|
||||
/* from standalone .hbx files in some known locations */
|
||||
IF ! lAnyHBR
|
||||
WalkDir( hb_DirBase() + ".." + hb_ps() + "contrib", @cFunctions )
|
||||
ENDIF
|
||||
WalkDir( hb_DirBase() + ".." + hb_ps() + "addons", @cFunctions )
|
||||
|
||||
/* from specified list of .hbx files */
|
||||
|
||||
FOR EACH cName IN hb_ATokens( cHBXList )
|
||||
HBXToFuncList( @cFunctions, hb_MemoRead( hb_PathJoin( hb_DirBase(), cName ) ) )
|
||||
NEXT
|
||||
|
||||
RETURN
|
||||
|
||||
STATIC PROCEDURE WalkDir( cDir, /* @ */ cFunctions )
|
||||
|
||||
LOCAL aFile
|
||||
|
||||
cDir := hb_DirSepAdd( cDir )
|
||||
|
||||
FOR EACH aFile IN Directory( cDir + hb_osFileMask(), "D" )
|
||||
IF aFile[ F_NAME ] == "." .OR. aFile[ F_NAME ] == ".."
|
||||
ELSEIF "D" $ aFile[ F_ATTR ]
|
||||
WalkDir( cDir + aFile[ F_NAME ] + hb_ps(), @cFunctions )
|
||||
ELSEIF hb_FNameExt( aFile[ F_NAME ] ) == ".hbx"
|
||||
HBXToFuncList( @cFunctions, hb_MemoRead( cDir + aFile[ F_NAME ] ) )
|
||||
ENDIF
|
||||
NEXT
|
||||
|
||||
RETURN
|
||||
|
||||
STATIC PROCEDURE HBXToFuncList( /* @ */ cFunctions, cHBX )
|
||||
LOCAL cLine
|
||||
|
||||
FOR EACH cLine IN hb_ATokens( StrTran( cHBX, Chr( 13 ) ), Chr( 10 ) )
|
||||
IF Left( cLine, Len( "DYNAMIC " ) ) == "DYNAMIC "
|
||||
cFunctions += "," + SubStr( cLine, Len( "DYNAMIC " ) + 1 )
|
||||
ENDIF
|
||||
NEXT
|
||||
|
||||
RETURN
|
||||
|
||||
STATIC FUNCTION __harbour_hbx()
|
||||
|
||||
#pragma __streaminclude "harbour.hbx" | RETURN %s
|
||||
Reference in New Issue
Block a user