Skip to content

Commit

Permalink
Fix some warning on function class declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
e-marchand committed Aug 30, 2024
1 parent 463d6ac commit ae2c4b5
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 100 deletions.
11 changes: 4 additions & 7 deletions Project/Sources/Classes/DataSource.4dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Class constructor
Class constructor($url : Text)

This:C1470.handler:="mobileapp"
This:C1470.method:=HTTP GET method:K71:1
Expand All @@ -7,11 +7,10 @@ Class constructor

This:C1470.path:=""

var $1 : Text

If (Count parameters:C259>=1)

This:C1470.setURL($1)
This:C1470.setURL($url)

Else

Expand All @@ -20,13 +19,11 @@ Class constructor
End if

// === === === === === === === === === === === === === === === === === === === === ===
Function setURL

var $1 : Text
Function setURL($url : Text)

If (Count parameters:C259>=1)

This:C1470.url:=$1
This:C1470.url:=$url

// Add missing / if necessary
If (Not:C34(Match regex:C1019("/$"; This:C1470.url; 1)))
Expand Down
68 changes: 25 additions & 43 deletions Project/Sources/Classes/DevTestData.4dm
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@


Class constructor
var $1 : Object
Class constructor($ds : Object)
If (Count parameters:C259>0)
This:C1470.ds:=$1
This:C1470.ds:=$ds
Else
This:C1470.ds:=ds:C1482
End if
Expand Down Expand Up @@ -122,10 +121,7 @@ $entity[$key]:=$related*/
End for each


Function unattach
var $entitiesByDataClass; $1 : Object
$entitiesByDataClass:=$1

Function unattach($entitiesByDataClass : Object)
var $entities : Variant // Collection or Selection -> iterable of object
$entities:=$entitiesByDataClass[OB Keys:C1719($entitiesByDataClass)[0]]

Expand Down Expand Up @@ -155,10 +151,8 @@ Function unattach

End for each

Function newEntity
var $0; $entities : Collection
var $1; $classStore : Object
$classStore:=$1
Function newEntity($classStore : Object)->$entities : Collection

$entities:=New collection:C1472()

var $max; $maxStr; $i; $j : Integer
Expand Down Expand Up @@ -211,13 +205,11 @@ Function newEntity
ASSERT:C1129($status.success; "Failed to save an entity:"+JSON Stringify:C1217($status))
$entities.push($entity)
End for
$0:=$entities

Function stat
Function stat()->$stat : Object
var $dataClassName : Text
var $entity : 4D:C1709.Entity

var $0; $stat : Object
$stat:=New object:C1471()

var $all : Object
Expand All @@ -231,16 +223,11 @@ Function stat

End for each

$0:=$stat

Function statRelation
var $1; $dataClass : 4D:C1709.DataClass //
var $2; $entities : Object //selection
$dataClass:=$1
$entities:=$2
Function statRelation($dataClass : 4D:C1709.DataClass; $entities : Object)->$result : Object
var $entity : 4D:C1709.Entity
var $0 : Object
$0:=New object:C1471()

$result:=New object:C1471()

var $key : Text
For each ($key; $dataClass)
Expand All @@ -249,11 +236,11 @@ Function statRelation
// reverve stat?

: ($dataClass[$key].kind="relatedEntity")
$0[$key]:=0
$result[$key]:=0
// $0[$key]:=$entities.count($key) // not working with relation? why? not user friendly
For each ($entity; $entities)
If ($entity[$key]#Null:C1517)
$0[$key]:=$0[$key]+1
$result[$key]:=$result[$key]+1
End if
End for each

Expand All @@ -270,9 +257,8 @@ Function notify
This:C1470._callback(This:C1470.stat())
End if

Function _callback
var $1; $stat : Object //stat
$stat:=$1
Function _callback($stat : Object)

C_OBJECT:C1216($dumpFolder)
// here we could launch task, study mobile app etc.., or pass a "callback" function to this class

Expand Down Expand Up @@ -338,16 +324,13 @@ Function _callback
End for each
End if

Function mobileStat
var $0; $1; $dataClass; $2 : Object
$0:=New object:C1471("count"; $2.records.length; "relation"; This:C1470.mobileStatRelation($1; $2.records))
Function mobileStat($dataClass : Object; $res : Object) : Object
return New object:C1471("count"; $res.records.length; "relation"; This:C1470.mobileStatRelation($dataClass; $res.records))


Function mobileStatRelation($dataClass : Object; $col : Collection)->$result : Object

Function mobileStatRelation
var $0; $1; $dataClass : Object
var $2 : Collection
$dataClass:=$1
$0:=New object:C1471()
$result:=New object:C1471()
var $key : Text
For each ($key; $dataClass)
Case of
Expand All @@ -358,11 +341,11 @@ Function mobileStatRelation

var $keyExist : Boolean
$keyExist:=False:C215
$0[$key]:=0
$result[$key]:=0
var $entity : Object
For each ($entity; $2)
For each ($entity; $col)
If ($entity[$key]#Null:C1517)
$0[$key]:=$0[$key]+1
$result[$key]:=$result[$key]+1
End if
//%W-518.7
If (Not:C34(Undefined:C82($entity[$key]))) // null must be defined (we want here a method ob has key
Expand All @@ -371,7 +354,7 @@ Function mobileStatRelation
//%W+518.7
End for each
If (Not:C34($keyExist))
OB REMOVE:C1226($0; $key)
OB REMOVE:C1226($result; $key)
End if
Else
// ignore
Expand All @@ -392,14 +375,13 @@ End while */
End while
// XXX maybe also add a time max, and stop current process if too much time

Function xCallback
var $1 : Object
This:C1470.lastCallbackInfo:=$1
Function xCallback($info : Object)
This:C1470.lastCallbackInfo:=$info
This:C1470.lastCallbackInfo.success:=Bool:C1537(Num:C11(This:C1470.lastCallbackInfo.success))

var $html : Text
$html:="<html><body><h1><font size=\"7\">"
$html:=$html+JSON Stringify:C1217($1)
$html:=$html+JSON Stringify:C1217($info)
$html:=$html+"</h1></font></body></html>"
WEB SEND TEXT:C677($html) // just to have a response from this 4daction (maybe add later progress)

Expand Down
17 changes: 7 additions & 10 deletions Project/Sources/Classes/avd.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -344,34 +344,31 @@ Function isDeviceAvailable($device : Text)->$available : Boolean

//=== === === === === === === === === === === === === === === === === === === === === === === === === ===
//
Function listAvds // List emulators
var $0 : Text // returns complete output
Function listAvds() : Text // List emulators

This:C1470.launch(This:C1470.cmd+" list avd")

If (This:C1470.errorStream#Null:C1517)
$0:=This:C1470.errorStream
return This:C1470.errorStream
Else
$0:=String:C10(This:C1470.outputStream)
return String:C10(This:C1470.outputStream)
End if

//=== === === === === === === === === === === === === === === === === === === === === === === === === ===
//
Function isAvdExisting // Check if avd already exists
var $0 : Boolean
var $1 : Text // avd name
Function isAvdExisting($avdName : Text) : Boolean // Check if avd already exists
var $listOutput; $separator : Text

$listOutput:=This:C1470.listAvds()

$separator:=Choose:C955(Is macOS:C1572; "/"; "\\")

// Searching for "/avd_name.avd" expression
If (Position:C15($separator+$1+".avd\n"; String:C10($listOutput))=0)
If (Position:C15($separator+$avdName+".avd\n"; String:C10($listOutput))=0)
// avd name not found, means it doesn't exists
$0:=False:C215
return False:C215
Else
// avd name found, means it already exists
$0:=True:C214
return True:C214
End if

24 changes: 10 additions & 14 deletions Project/Sources/Classes/debugLog.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@
/*
Called from a preemptive process, this class triggers an error when .stop() is executed.
https:// Project.4d.com/issues/130543
https://project.4d.com/issues/130543
So, temporary disable strat & stop for a preemptive process.
Another solution will be to call a not preemptive worker with a project method
*/
Class constructor
C_OBJECT:C1216($1)
This:C1470.parameters:=$1
Class constructor($parameters : Object)
This:C1470.parameters:=$parameters
This:C1470.restoreParameters:=New object:C1471
If (This:C1470.parameters#Null:C1517)
Expand All @@ -40,37 +38,35 @@ Function start
Function stop
This:C1470._set(This:C1470.restoreParameters)
Function _createRestore
C_OBJECT:C1216($1)
Function _createRestore($parameters : Object)
If (This:C1470.cooperative) // ⚠️ Get database parameter & SET DATABASE PARAMETER are NOT threadSafe
If (Num:C11($1.recording)>0)
If (Num:C11($parameters.recording)>0)
This:C1470.restoreParameters.recording:=Get database parameter:C643(Current process debug log recording:K37:97)
End if
If (Num:C11($1.currentProcess)>0)
If (Num:C11($parameters.currentProcess)>0)
This:C1470.restoreParameters.currentProcess:=Get database parameter:C643(Current process debug log recording:K37:97)
End if
End if
Function _set
C_OBJECT:C1216($1)
ASSERT:C1129($1#Null:C1517)
Function _set($parameters : Object)
ASSERT:C1129($parameters#Null:C1517)
//If (This.cooperative) // ⚠️ Get database parameter & SET DATABASE PARAMETER are NOT threadSafe
If ($1.recording#Null:C1517)
If ($parameters.recording#Null:C1517)
SET DATABASE PARAMETER:C642(Debug log recording:K37:34; This:C1470.parameters.recording)
End if
If ($1.currentProcess#Null:C1517)
If ($parameters.currentProcess#Null:C1517)
SET DATABASE PARAMETER:C642(Current process debug log recording:K37:97; This:C1470.parameters.currentProcess)
Expand Down
38 changes: 17 additions & 21 deletions Project/Sources/Classes/gradlew.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,43 @@ Function stop()
This:C1470.execute("--stop")


Function assembleDebug
var $0 : Object
Function assembleDebug->$result : Object

$0:=New object:C1471(\
$result:=New object:C1471(\
"success"; False:C215; \
"outputStream"; ""; \
"errorStream"; ""; \
"errors"; New collection:C1472)

This:C1470.execute("assembleDebug")

$0.outputStream:=This:C1470.outputStream
$0.errorStream:=This:C1470.errorStream
$result.outputStream:=This:C1470.outputStream
$result.errorStream:=This:C1470.errorStream

If (Position:C15("BUILD FAILED"; This:C1470.errorStream)=0)

$0.success:=True:C214
$result.success:=True:C214

Else

$0.errors.push("Failed to build project with task \"assembleDebug\"")
$0.errors.push(This:C1470.errorStream)
$result.errors.push("Failed to build project with task \"assembleDebug\"")
$result.errors.push(This:C1470.errorStream)

End if

Function createEmbeddedDatabase
var $0 : Object
Function createEmbeddedDatabase()->$result : Object

$0:=New object:C1471(\
$result:=New object:C1471(\
"success"; False:C215; \
"errors"; New collection:C1472)

This:C1470.execute("app:createDataBase")

$0.success:=Not:C34((This:C1470.errorStream#Null:C1517) & (String:C10(This:C1470.errorStream)#""))
$result.success:=Not:C34((This:C1470.errorStream#Null:C1517) & (String:C10(This:C1470.errorStream)#""))

If (Not:C34($0.success))
If (Not:C34($result.success))

$0.errors.push("Failed to create embedded database")
$result.errors.push("Failed to create embedded database")

// Else : all ok
End if
Expand Down Expand Up @@ -92,16 +90,14 @@ Function signingReport()->$result : Object
End if


Function checkAPKExists
var $0 : Object
var $1 : 4D:C1709.File // apk
Function checkAPKExists($apkFile : 4D:C1709.File)->$result : Object

$0:=New object:C1471(\
$result:=New object:C1471(\
"success"; False:C215; \
"errors"; New collection:C1472)

If ($1.exists)
$0.success:=True:C214
If ($apkFile.exists)
$result.success:=True:C214
Else
$0.errors.push("Missing APK file: "+$1.path)
$result.errors.push("Missing APK file: "+$apkFile.path)
End if
Loading

0 comments on commit ae2c4b5

Please sign in to comment.