Skip to content

Commit

Permalink
bf beautifier
Browse files Browse the repository at this point in the history
  • Loading branch information
vdelachaux committed Oct 16, 2023
1 parent 283f40a commit 6a4bb49
Show file tree
Hide file tree
Showing 11 changed files with 179 additions and 87 deletions.
Binary file modified Build/4DPop Macros.4dbase.zip
Binary file not shown.
Binary file modified Build/Components/4DPop Macros.4dbase/4DPop Macros.4DZ
Binary file not shown.
4 changes: 2 additions & 2 deletions Build/Components/4DPop Macros.4dbase/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<key>CFBundleName</key>
<string>4DPop Macros</string>
<key>CFBundleVersion</key>
<string>275</string>
<string>277</string>
<key>NSHumanReadableCopyright</key>
<string>©vdl 2009-2023</string>
<key>CFBundleGetInfoString</key>
<string>20R4</string>
<key>CFBundleLongVersionString</key>
<string>20R4 (274)</string>
<string>20R4 (276)</string>
<key>CFBundleShortVersionString</key>
<string>20R4</string>
<key>CFBundleDisplayName</key>
Expand Down
Binary file modified Build/Components/4DPop Macros.4dbase/Libraries/lib4d-arm64.dylib
Binary file not shown.
Binary file modified Build/Components/4DPop Macros.4dbase/Resources/InfoPlist.strings
Binary file not shown.
4 changes: 2 additions & 2 deletions Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<key>CFBundleName</key>
<string>4DPop Macros</string>
<key>CFBundleVersion</key>
<string>275</string>
<string>277</string>
<key>NSHumanReadableCopyright</key>
<string>©vdl 2009-2023</string>
<key>CFBundleGetInfoString</key>
<string>20R4</string>
<key>CFBundleLongVersionString</key>
<string>20R4 (274)</string>
<string>20R4 (276)</string>
<key>CFBundleShortVersionString</key>
<string>20R4</string>
<key>CFBundleDisplayName</key>
Expand Down
141 changes: 62 additions & 79 deletions Project/Sources/Classes/beautifier.4dm

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions Project/Sources/Classes/macro.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,12 @@ Function _paste($text : Text; $useSelection : Boolean)

SET MACRO PARAMETER:C998($target; $text)

If (Structure file:C489=Structure file:C489(*))

return

End if

// Force tokenisation
var $name : Text
var $i; $mode; $origin; $state; $time; $UID : Integer
Expand Down
101 changes: 101 additions & 0 deletions Project/Sources/Methods/classDiagram.4dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
//%attributes = {}
var $key; $code; $name : Text
var $i; $j : Integer
var $attribute; $classes; $class : Object
var $c : Collection
var $regex : cs:C1710.regex

ARRAY TEXT:C222($methods; 0)

METHOD GET PATHS:C1163(Path class:K72:19; $methods; *)

$regex:=cs:C1710.regex.new()
$classes:=New object:C1471

For ($i; 1; Size of array:C274($methods); 1)

$name:=Delete string:C232($methods{$i}; 1; 8)

If ($name#"@Entity") && ($name#"DataStore")

METHOD GET CODE:C1190($methods{$i}; $code; *)

$class:=New object:C1471

If ($regex.setPattern("(?m-si)Class extends\\s([[:alpha:]][[:alnum:]]*)").setTarget($code).match())

$class.extend:=$regex.matches[1].data

End if

$c:=$regex.setPattern("(?m-si)(?!.*[gs]et)Function ([[:alpha:]][^[:blank:]($]*)(?:\\(.*\\))(?:[^$]*)").extract(1)

If ($c.length>0)

$class.functions:=$c

End if

// Public attributes (not starting with an underscore)
$c:=$regex.setPattern("(?mi-s)This\\.(?!_)([^[:blank:]\\.]*):").extract(1)

If ($c.length>0)

$class.attributes:=New collection:C1472

For ($j; 0; $c.length-1; 1)

If ($class.attributes.query("name = :1"; $c[$j]).pop()=Null:C1517)

$attribute:=New object:C1471(\
"name"; $c[$j])

//If ($regex.setPattern("(?mi-s)This\\."+$attribute.name+"\\.").match())
//$attribute.type:="Object"
//End if

$class.attributes.push($attribute)

End if
End for
End if

// Computed attributes
$c:=$regex.setPattern("(?mi-s)Function\\sget\\s([[:alpha:]][^[:blank:]($]*)\\(\\)\\s:\\s([[:alpha:]]*)").extract("1 2")

If ($c.length>0)

$class.attributes:=$class.attributes || New collection:C1472

For ($j; 0; $c.length-1; 2)

$attribute:=New object:C1471(\
"name"; $c[$j]; \
"type"; $c[$j+1]; \
"computed"; True:C214; \
"writable"; $regex.setPattern("(?mi-s)Function set "+$c[$j]).match())

$class.attributes.push($attribute)

End for
End if

$classes[$name]:=$class

End if
End for

For each ($key; $classes)

$class:=$classes[$key]

If ($class.extend#Null:C1517)

$classes[$class.extend].childs:=$classes[$class.extend].childs || New object:C1471
$classes[$class.extend].childs[$key]:=$class

//OB REMOVE($class; "extend")

End if
End for each

10 changes: 6 additions & 4 deletions Project/Sources/folders.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
"COMPILER_TESTS",
"createSymbolicLink",
"macro",
"Method120",
"Method121",
"Method122",
"Method123"
"Method2",
"Method3",
"Method4",
"Method5",
"Method6",
"Method7"
]
},
"#️⃣ API": {},
Expand Down
Binary file modified Resources/InfoPlist.strings
Binary file not shown.

0 comments on commit 6a4bb49

Please sign in to comment.