Skip to content

Commit

Permalink
enhance declaration for variadic & declaration with affectation
Browse files Browse the repository at this point in the history
  • Loading branch information
vdelachaux committed Oct 18, 2023
1 parent a2a4a9f commit 9ae4191
Show file tree
Hide file tree
Showing 18 changed files with 282 additions and 263 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>277</string>
<string>278</string>
<key>NSHumanReadableCopyright</key>
<string>©vdl 2009-2023</string>
<key>CFBundleGetInfoString</key>
<string>20R4</string>
<key>CFBundleLongVersionString</key>
<string>20R4 (276)</string>
<string>20R4 (277)</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>277</string>
<string>278</string>
<key>NSHumanReadableCopyright</key>
<string>©vdl 2009-2023</string>
<key>CFBundleGetInfoString</key>
<string>20R4</string>
<key>CFBundleLongVersionString</key>
<string>20R4 (276)</string>
<string>20R4 (277)</string>
<key>CFBundleShortVersionString</key>
<string>20R4</string>
<key>CFBundleDisplayName</key>
Expand Down
4 changes: 1 addition & 3 deletions Project/Sources/Classes/button.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ Some specificity for button widgets
Class extends widget
/*═══════════════════*/

Class constructor

C_VARIANT:C1683($1)
Class constructor( ... )

Super:C1705($1)

Check failure on line 13 in Project/Sources/Classes/button.4dm

View workflow job for this annotation

GitHub Actions / Build

The parameter $1 has not been explicitly declared in the typing methods (Compiler...).

Expand Down
396 changes: 216 additions & 180 deletions Project/Sources/Classes/declaration.4dm

Large diffs are not rendered by default.

72 changes: 36 additions & 36 deletions Project/Sources/Classes/group.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,51 @@ or a comma separated list of object names
in this case, all named objects are initialized with widget class
——————————————————————————*/
Class constructor
Class constructor($members; ... : Object)

C_VARIANT:C1683($1)
C_OBJECT:C1216(${2})
//C_VARIANT($1)
//C_OBJECT(${2})

C_LONGINT:C283($i)
C_TEXT:C284($t)

If (Asserted:C1132(Count parameters:C259>0;"Missing parameter"))
If (Asserted:C1132(Count parameters:C259>0; "Missing parameter"))

Case of

//___________________________
//___________________________
: (Value type:C1509($1)=Is collection:K8:32)

This:C1470.members:=$1

//___________________________
//___________________________
: (Value type:C1509($1)=Is object:K8:27) // 1 to n objects

This:C1470.members:=New collection:C1472

For ($i;1;Count parameters:C259;1)
For ($i; 1; Count parameters:C259; 1)

This:C1470.members.push(${$i})

Check failure on line 39 in Project/Sources/Classes/group.4dm

View workflow job for this annotation

GitHub Actions / Build

The parameter ${$} has not been explicitly declared in the typing methods (Compiler...).

End for

//___________________________
//___________________________
: (Value type:C1509($1)=Is text:K8:3) // Comma separated list of object names

This:C1470.members:=New collection:C1472

For each ($t;Split string:C1554($1;","))
For each ($t; Split string:C1554($1; ","))

This:C1470.members.push(cs:C1710.widget.new($t)) // Widget by default

End for each

//___________________________
//___________________________
Else

ASSERT:C1129(False:C215;"Bad parameter type")
ASSERT:C1129(False:C215; "Bad parameter type")

//___________________________
//___________________________
End case
End if

Expand All @@ -77,22 +77,22 @@ Function include

Case of

//______________________________________________________
//______________________________________________________
: (Value type:C1509($1)=Is object:K8:27)

$0:=(This:C1470.members.indexOf($1)#-1)

//______________________________________________________
//______________________________________________________
: (Value type:C1509($1)=Is text:K8:3)

$0:=(This:C1470.members.query("name=:1";$1).pop()#Null:C1517)
$0:=(This:C1470.members.query("name=:1"; $1).pop()#Null:C1517)

//______________________________________________________
//______________________________________________________
Else

ASSERT:C1129(False:C215;"Unmanaged parameter type")
ASSERT:C1129(False:C215; "Unmanaged parameter type")

//______________________________________________________
//______________________________________________________
End case

/*════════════════════════════════════════════
Expand All @@ -110,13 +110,13 @@ The optional object type parameter allow to specify:
════════════════════════════════════════════*/
Function distributeHorizontally

C_OBJECT:C1216($1;$o;$e)
C_OBJECT:C1216($1; $o; $e)

$e:=New object:C1471(\
"start";0;\
"spacing";0;\
"minWidth";0;\
"maxWidth";0)
"start"; 0; \
"spacing"; 0; \
"minWidth"; 0; \
"maxWidth"; 0)

If (Count parameters:C259>=1)

Expand All @@ -133,7 +133,7 @@ Function distributeHorizontally
End if
End if

For each ($o;This:C1470.members)
For each ($o; This:C1470.members)

If (Count parameters:C259>=1)

Expand All @@ -151,25 +151,25 @@ Function distributeHorizontally

End if

// Calculate the cumulative shift
// Calculate the cumulative shift
If ($e.spacing=0)

Case of

//_______________________________
//_______________________________
: ($o.type=Object type push button:K79:16)

$e.start:=$o.coordinates.right+Choose:C955(Is macOS:C1572;20;20)
$e.start:=$o.coordinates.right+Choose:C955(Is macOS:C1572; 20; 20)

//_______________________________
//_______________________________
: (False:C215)

//_______________________________
//_______________________________
Else

$e.start:=$o.coordinates.right

//_______________________________
//_______________________________
End case

Else
Expand All @@ -190,15 +190,15 @@ Function show

If (Count parameters:C259>=1)

For each ($o;This:C1470.members)
For each ($o; This:C1470.members)

$o.show($1)

End for each

Else

For each ($o;This:C1470.members)
For each ($o; This:C1470.members)

$o.show()

Expand All @@ -210,7 +210,7 @@ Function hide

C_OBJECT:C1216($o)

For each ($o;This:C1470.members)
For each ($o; This:C1470.members)

$o.hide()

Expand All @@ -227,15 +227,15 @@ Function enable

If (Count parameters:C259>=1)

For each ($o;This:C1470.members)
For each ($o; This:C1470.members)

$o.enable($1)

End for each

Else

For each ($o;This:C1470.members)
For each ($o; This:C1470.members)

$o.enable()

Expand All @@ -247,7 +247,7 @@ Function disable

C_OBJECT:C1216($o)

For each ($o;This:C1470.members)
For each ($o; This:C1470.members)

$o.disable()

Expand Down
2 changes: 1 addition & 1 deletion Project/Sources/Classes/macro.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Function PasteColor()
/// Compiler Directives for local variables
Function Declarations()

DECLARATION
_o_DECLARATION

// === === === === === === === === === === === === === === === === === === === === === === === === === ===
Function Beautifier()
Expand Down
19 changes: 8 additions & 11 deletions Project/Sources/Classes/widget.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ I prefer to call them widgets to make the difference with language objects
Class extends static
/*═══════════════════*/

Class constructor
var $1 : Text
var $2 : Text
Class constructor($name : Text; $datasource : Text)

var $p : Pointer

Super:C1705($1)
Super:C1705($name)

$p:=OBJECT Get pointer:C1124(Object named:K67:5; This:C1470.name)
This:C1470.assignable:=Not:C34(Is nil pointer:C315($p))
Expand All @@ -34,8 +32,8 @@ Class constructor

If (Count parameters:C259>=2)

This:C1470.dataSource:=$2
This:C1470.value:=Formula from string:C1601($2).call()
This:C1470.dataSource:=$datasource
This:C1470.value:=Formula from string:C1601($datasource).call()

End if
End if
Expand All @@ -47,9 +45,9 @@ Class constructor
This:C1470.events:=New collection:C1472
ARRAY TO COLLECTION:C1563(This:C1470.events; $_)

Function addEvents
Function addEvents( ... : Integer)

Check failure on line 48 in Project/Sources/Classes/widget.4dm

View workflow job for this annotation

GitHub Actions / Build

Function 'widget.addEvents' declaration syntax error

var ${1}; $i : Integer
var $i : Integer

For ($i; 1; Count parameters:C259; 1)

Expand All @@ -62,10 +60,9 @@ Function addEvents
//OBJECT SET EVENTS(*; This.name; $_; Enable events others unchanged)

/*══════════════════════════*/
Function getEnterable
var $0 : Boolean
Function getEnterable : Boolean

$0:=OBJECT Get enterable:C1067(*; This:C1470.name)
return OBJECT Get enterable:C1067(*; This:C1470.name)

/*══════════════════════════
.enterable()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
_o_Preferences("Get_Value"; "ignoreDeclarations"; OBJECT Get pointer:C1124(Object named:K67:5; "ignoreDirectives"))
_o_Preferences("Get_Value"; "numberOfVariablePerLine"; OBJECT Get pointer:C1124(Object named:K67:5; "variableNumber"))
DECLARATION("Get_Syntax_Preferences")
_o_DECLARATION("Get_Syntax_Preferences")
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ OPTIONS_SET(\
_o_Preferences("Set_Value"; "ignoreDeclarations"; OBJECT Get pointer:C1124(Object named:K67:5; "ignoreDirectives"))
_o_Preferences("Set_Value"; "numberOfVariablePerLine"; OBJECT Get pointer:C1124(Object named:K67:5; "variableNumber"))

DECLARATION("Set_Syntax_Preferences"; -><>tLon_Declaration_Types; -><>tTxt_Patterns)
DECLARATION("Get_Syntax_Preferences")
_o_DECLARATION("Set_Syntax_Preferences"; -><>tLon_Declaration_Types; -><>tTxt_Patterns)
_o_DECLARATION("Get_Syntax_Preferences")

(OBJECT Get pointer:C1124(Object named:K67:5; "spinner"))->:=1
OBJECT SET VISIBLE:C603(*; "spinner"; True:C214)
Expand Down
12 changes: 3 additions & 9 deletions Project/Sources/Methods/4DPop_MACROS.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,15 @@
// 4DPop Macros v 3.0
// ----------------------------------------------------
// Description
// Entry point of all 4DPop's macros
// Entry point of all macros
// ----------------------------------------------------
// Modified by Vincent de Lachaux (12/05/10)
// v12
// ----------------------------------------------------
// Declarations
#DECLARE($action : Text; $text : Text; $title : Text)

var ${4} : Pointer
#DECLARE($action : Text; $text : Text; $title : Text; ... : Pointer)

Check failure on line 10 in Project/Sources/Methods/4DPop_MACROS.4dm

View workflow job for this annotation

GitHub Actions / Build

Syntax error

Check failure on line 10 in Project/Sources/Methods/4DPop_MACROS.4dm

View workflow job for this annotation

GitHub Actions / Build

Syntax error in the parameters declaration.

If (False:C215)
C_TEXT:C284(4DPop_MACROS; $1)
C_TEXT:C284(4DPop_MACROS; $2)
C_TEXT:C284(4DPop_MACROS; $3)
C_POINTER:C301(4DPop_MACROS; $4)
C_POINTER:C301(4DPop_MACROS; ${4})
End if

var $t : Text
Expand Down
4 changes: 2 additions & 2 deletions Project/Sources/Methods/Compiler_.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ If (False:C215)
End if

If (False:C215)
C_TEXT:C284(DECLARATION; $1)
C_POINTER:C301(DECLARATION; ${2})
C_TEXT:C284(_o_DECLARATION; $1)
C_POINTER:C301(_o_DECLARATION; ${2})
End if

If (False:C215)
Expand Down
Loading

0 comments on commit 9ae4191

Please sign in to comment.