[DEVELOPMENT ENVIRONMENT]
* BUG: Function signatures now support the new syntax that allows to put braces around arguments to let the compiler ignore them. git-svn-id: svn://localhost/gambas/trunk@5126 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
28c9d6d59b
commit
8059e72f19
1 changed files with 83 additions and 62 deletions
|
@ -230,20 +230,73 @@ End
|
|||
|
||||
Private Sub MakeSignature(sSign As String) As String
|
||||
|
||||
Dim aSym As String[]
|
||||
Dim iInd As Integer
|
||||
Dim aWait As New String[]
|
||||
Dim bOptional As Boolean
|
||||
Dim sSym As String
|
||||
Dim sType As String
|
||||
Dim sDefault As String
|
||||
Dim bByRef As Boolean
|
||||
Dim iPos, iPos2 As Integer
|
||||
Dim sResult As String
|
||||
|
||||
Highlight.Analyze(sSign)
|
||||
sSign = ""
|
||||
aSym = Highlight.Symbols
|
||||
|
||||
For iInd = 0 To Highlight.Symbols.Max
|
||||
Do
|
||||
|
||||
sSym = Highlight.Symbols[iInd]
|
||||
If iInd > aSym.Max Then Break
|
||||
|
||||
sSym = aSym[iInd]
|
||||
|
||||
If sSym = "..." Then
|
||||
sResult &= "."
|
||||
Break
|
||||
Endif
|
||||
|
||||
If UCase(sSym) = "OPTIONAL" Then
|
||||
If Not bOptional Then
|
||||
sResult &= "["
|
||||
bOptional = True
|
||||
Endif
|
||||
Inc iInd
|
||||
sSym = aSym[iInd]
|
||||
Endif
|
||||
|
||||
bByRef = False
|
||||
If UCase(sSym) = "BYREF" Then
|
||||
bByRef = True
|
||||
Inc iInd
|
||||
sSym = aSym[iInd]
|
||||
Endif
|
||||
|
||||
If sSym = "(" And If aSym[iInd + 2] = ")" Then
|
||||
sSym = aSym[iInd + 1]
|
||||
iInd += 2
|
||||
Endif
|
||||
|
||||
If bByRef Then sSym = "&" & sSym
|
||||
|
||||
Inc iInd
|
||||
If aSym[iInd] <> "AS" Then Break
|
||||
|
||||
Inc iInd
|
||||
sType = aSym[iInd]
|
||||
If $cNameType.Exist(sType) Then
|
||||
sType = $cNameType[sType]
|
||||
Else
|
||||
sType = UCase(Left(sType)) & Mid$(sType, 2) & ";"
|
||||
Endif
|
||||
sResult &= "(" & sSym & ")" & sType
|
||||
|
||||
If bOptional And If iInd < aSym.Max Then
|
||||
If aSym[iInd + 1] = "=" Then
|
||||
iInd += 2
|
||||
sDefault = ""
|
||||
iPos = Highlight.Positions[iInd]
|
||||
While iInd < aSym.Max
|
||||
sSym = aSym[iInd]
|
||||
If sSym = "(" Then
|
||||
aWait.Push(")")
|
||||
Else If sSym = "[" Then
|
||||
|
@ -253,62 +306,30 @@ Private Sub MakeSignature(sSign As String) As String
|
|||
aWait.Pop
|
||||
Endif
|
||||
Else
|
||||
|
||||
If iInd > 0 And If sSym <> "," Then Continue
|
||||
|
||||
If iInd Then
|
||||
Inc iInd
|
||||
sSym = Highlight.Symbols[iInd]
|
||||
Endif
|
||||
|
||||
If sSym = "..." Then
|
||||
sSign &= "."
|
||||
If sSym = ")" Or If sSym = "," Then
|
||||
iPos2 = Highlight.Positions[iInd]
|
||||
sDefault = Trim(Mid$(sSign, iPos + 1, iPos2 - iPos))
|
||||
Dec iInd
|
||||
Break
|
||||
Endif
|
||||
|
||||
If UCase(sSym) = "OPTIONAL" Then
|
||||
If Not bOptional Then
|
||||
sSign &= "["
|
||||
bOptional = True
|
||||
Endif
|
||||
Inc iInd
|
||||
sSym = Highlight.Symbols[iInd]
|
||||
Wend
|
||||
sResult &= "=" & sDefault & "\t"
|
||||
Endif
|
||||
Endif
|
||||
|
||||
If UCase(sSym) = "BYREF" Then
|
||||
Inc iInd
|
||||
sSym = "&" & Highlight.Symbols[iInd]
|
||||
Endif
|
||||
If iInd > aSym.Max Then Break
|
||||
sSym = aSym[iInd]
|
||||
If sSym <> "," Then Break
|
||||
Inc iInd
|
||||
|
||||
iInd += 2
|
||||
sType = Highlight.Symbols[iInd]
|
||||
If $cNameType.Exist(sType) Then
|
||||
sType = $cNameType[sType]
|
||||
Else
|
||||
sType = UCase(Left(sType)) & Mid$(sType, 2) & ";"
|
||||
Endif
|
||||
sSign &= "(" & sSym & ")" & sType
|
||||
Loop
|
||||
|
||||
If bOptional And If iInd < Highlight.Symbols.Max Then
|
||||
If Highlight.Symbols[iInd + 1] = "=" Then
|
||||
iInd += 2
|
||||
sDefault = Highlight.Symbols[iInd]
|
||||
If Highlight.Types[iInd] = Highlight.Keyword Then
|
||||
If Not Settings["/Editor/KeywordsUseUpperCase"] Then
|
||||
Mid$(sDefault, 2) = LCase(Mid$(sDefault, 2))
|
||||
Endif
|
||||
Endif
|
||||
sSign &= "=" & sDefault & "\t"
|
||||
Endif
|
||||
Endif
|
||||
If bOptional Then sResult &= "]"
|
||||
|
||||
Endif
|
||||
|
||||
Next
|
||||
|
||||
If bOptional Then sSign &= "]"
|
||||
|
||||
Return sSign
|
||||
Return sResult
|
||||
|
||||
Catch
|
||||
|
||||
|
@ -567,7 +588,7 @@ Public Function GetDescription(Optional bBalise As Boolean) As String
|
|||
Endif
|
||||
|
||||
If InStr(":mx", LCase(Kind)) Then
|
||||
sSign = GetSignature(False )
|
||||
sSign = GetSignature(False)
|
||||
If sSign Then
|
||||
sDesc &= sSign
|
||||
Else
|
||||
|
@ -941,7 +962,7 @@ Public Function GetHelpHTML() As String
|
|||
|
||||
'If Me.IsStatic() Then sHTML &= "<font color=\"blue\">STATIC </font>"
|
||||
|
||||
sSyntax &= Me.GetDescription(False )
|
||||
sSyntax &= Me.GetDescription(False)
|
||||
sSyntax = Replace(Replace(sSyntax, "</b>", ""), "<b>", "")
|
||||
|
||||
Highlight.Analyze(sSyntax)
|
||||
|
|
Loading…
Reference in a new issue