Skip to content

Commit

Permalink
some modernisation of the code
Browse files Browse the repository at this point in the history
  • Loading branch information
vdelachaux committed May 31, 2024
1 parent faf9bff commit ec74d91
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 105 deletions.
Binary file modified Build/4DPop-Macros.dmg
Binary file not shown.
Binary file modified Build/4DPop-Macros.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>285</string>
<string>286</string>
<key>NSHumanReadableCopyright</key>
<string>©vdl 2009-2024</string>
<key>CFBundleGetInfoString</key>
<string>20R6</string>
<key>CFBundleLongVersionString</key>
<string>20R6 (284)</string>
<string>20R6 (285)</string>
<key>CFBundleShortVersionString</key>
<string>20R6</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>285</string>
<string>286</string>
<key>NSHumanReadableCopyright</key>
<string>©vdl 2009-2024</string>
<key>CFBundleGetInfoString</key>
<string>20R6</string>
<key>CFBundleLongVersionString</key>
<string>20R6 (284)</string>
<string>20R6 (285)</string>
<key>CFBundleShortVersionString</key>
<string>20R6</string>
<key>CFBundleDisplayName</key>
Expand Down
20 changes: 10 additions & 10 deletions Project/Sources/Classes/declaration.4dm
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
Class extends macro

property lines; locales; parameters; classes; types : Collection
property lines : Collection:=[]
property locales : Collection:=[]
property parameters : Collection:=[]
property classes : Collection:=[]
property types : Collection:=[]

//ACI0104313
//property $notforArray : Collection
//property $inCommentBlock: Boolean

property settings : Object
property localeNumber; parameterNumber : Integer

property localeNumber : Integer:=0
property parameterNumber : Integer:=0

property _patterns : Object

Expand All @@ -30,12 +36,6 @@ Class constructor

End if

This:C1470.lines:=[]
This:C1470.locales:=[]
This:C1470.parameters:=[]
This:C1470.classes:=[]
This:C1470.types:=[]

This:C1470.$notforArray:=["collection"; "variant"]

// Flags
Expand Down Expand Up @@ -1496,8 +1496,6 @@ Function loadGramSyntax()

var $t : Text
var $first; $i; $return : Integer
var $patterns : Object
var $file : 4D:C1709.File

This:C1470.gramSyntax:=New object:C1471(\
String:C10(Is object:K8:27); []; \
Expand All @@ -1520,12 +1518,14 @@ Function loadGramSyntax()
String:C10(Is time:K8:8)+"_1"; []; \
String:C10(Is BLOB:K8:12)+"_1"; [])

var $file : 4D:C1709.File
$file:=Is macOS:C1572\
? Folder:C1567(Application file:C491; fk platform path:K87:2).file("Contents/Resources/gram.4dsyntax")\
: File:C1566(Application file:C491; fk platform path:K87:2).parent.file("Resources/gram.4dsyntax")

If ($file.exists)

var $patterns : Object
$patterns:={\
affectation: "(?m-is)\\%:=(?:(?:#)(?=$|\\(|(?:\\s*"+kCommentMark+")|(?:\\s*/\\*))"; \
affectationSuite: "|(?:#)(?=$|\\(|(?:\\s*"+kCommentMark+")|(?:\\s*/\\*))"; \
Expand Down
49 changes: 22 additions & 27 deletions Project/Sources/Classes/macro.4dm
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
property title; name; objectName; method; highlighted; decimalSeparator : Text
property class; form; trigger; projectMethod; objectMethod; withSelection : Boolean
property lineTexts : Collection
property title : Text:=Get window title:C450(Frontmost window:C447)
property name : Text:=""
property objectName : Text:=""
property method : Text:=""
property highlighted : Text:=""

property class : Boolean:=False:C215
property form : Boolean:=False:C215
property trigger : Boolean:=False:C215
property projectMethod : Boolean:=False:C215
property objectMethod : Boolean:=False:C215
property withSelection : Boolean:=False:C215

property lineTexts : Collection:=[]
property decimalSeparator : Text
property _controlFlow : Object
property rgx : cs:C1710.regex
property rgx : cs:C1710.regex:=cs:C1710.regex.new()

Class constructor()

Expand All @@ -12,20 +24,10 @@ Class constructor()
ARRAY LONGINT:C221($len; 0)
ARRAY LONGINT:C221($pos; 0)

This:C1470.title:=Get window title:C450(Frontmost window:C447)

// Identify the name & the type of the current method
This:C1470.name:=""
This:C1470.objectName:=""
This:C1470.projectMethod:=False:C215
This:C1470.objectMethod:=False:C215
This:C1470.class:=False:C215
This:C1470.form:=False:C215
This:C1470.trigger:=False:C215

If (Match regex:C1019("(?m-si)^([^:]*\\s*:\\s)([[:ascii:]]*)(\\.[[:ascii:]]*)?(?:\\s*\\*)?$"; This:C1470.title; 1; $pos; $len))

$ƒ:=Formula from string:C1601(Parse formula:C1576("_localized string:C1578($1)"))
$ƒ:=Formula from string:C1601(Parse formula:C1576("Get localized string:C1578($1)"))
$t:=Substring:C12(This:C1470.title; $pos{1}; $len{1})
This:C1470.projectMethod:=($t=$ƒ.call(Null:C1517; "common_method"))
This:C1470.objectMethod:=($t=$ƒ.call(Null:C1517; "common_objectMethod"))
Expand All @@ -47,10 +49,6 @@ Class constructor()

End if

This:C1470.method:=""
This:C1470.highlighted:=""
This:C1470.withSelection:=False:C215

If (This:C1470.form)

// #TO_DO 🚧
Expand All @@ -68,13 +66,9 @@ Class constructor()

End if

This:C1470.lineTexts:=[]

GET SYSTEM FORMAT:C994(Decimal separator:K60:1; $t)
This:C1470.decimalSeparator:=$t

This:C1470.rgx:=cs:C1710.regex.new()

// <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <==
Function get macroCall() : Boolean

Expand Down Expand Up @@ -258,7 +252,8 @@ Function ConvertToCallWithToken()

End if

If (This:C1470.highlighted="\"@") & (This:C1470.highlighted="@\"")
If (This:C1470.highlighted="\"@")\
&& (This:C1470.highlighted="@\"")

SET MACRO PARAMETER:C998(Highlighted method text:K5:18; "Formula:C1597("+Replace string:C233(This:C1470.highlighted; "\""; "")+").source")
POST KEY:C465(3)
Expand Down Expand Up @@ -453,7 +448,7 @@ Function _comment() : Text
If ($c.length=1)

var v1; v2; v3; v4 : Variant
Formula from string:C1601(":C1810(v1; v2; v3; v4)").call()
Formula from string:C1601("4D:C1810(v1; v2; v3; v4)").call()

If ($c[0]=Split string:C1554(This:C1470.method; "\r")[v3])

Expand Down Expand Up @@ -489,11 +484,11 @@ Function _paste($text : Text; $useSelection : Boolean)

If (Count parameters:C259>=2)

$target:=Choose:C955($useSelection; Highlighted method text:K5:18; Full method text:K5:17)
$target:=$useSelection ? Highlighted method text:K5:18 : Full method text:K5:17

Else

$target:=Choose:C955(This:C1470.withSelection; Highlighted method text:K5:18; Full method text:K5:17)
$target:=This:C1470.withSelection ? Highlighted method text:K5:18 : Full method text:K5:17

End if

Expand Down
Loading

0 comments on commit ec74d91

Please sign in to comment.