#-----------------------------------------------------------------------------* # # @file gtl_functions.galgas # # @section desc File description # # built in functions of GTL. # # @section copyright Copyright # # Goil OIL compiler, part of Trampoline RTOS # # Trampoline is copyright (c) CNRS, University of Nantes, # Ecole Centrale de Nantes # Trampoline is protected by the French intellectual property law. # # This software is distributed under the GNU Public Licence V2. # Check the LICENSE file in the root directory of Trampoline # # $Date$ # $Rev$ # $Author$ # $URL$ # #-----------------------------------------------------------------------------* #-----------------------------------------------------------------------------* # For compatibility purpose with previous version : returns "true" or "false" # string according to the bool argument. #-----------------------------------------------------------------------------* func trueFalse ?let @bool inBool ->@string result { if inBool then result = "true" else result = "false" end } #-----------------------------------------------------------------------------* # For compatibility purpose with previous version : returns "True" or "False" # string according to the bool argument. #-----------------------------------------------------------------------------* func TrueFalse ?let @bool inBool ->@string result { if inBool then result = "True" else result = "False" end } #-----------------------------------------------------------------------------* # For compatibility purpose with previous version : returns "YES" or "NO" # string according to the bool argument. #-----------------------------------------------------------------------------* func yesNo ?let @bool inBool ->@string result { if inBool then result = "YES" else result = "NO" end } #-----------------------------------------------------------------------------* # For compatibility purpose with previous version : returns "TRUE" or "FALSE" # string according to the bool argument. #-----------------------------------------------------------------------------* func TRUEFALSE ?let @bool inBool ->@string result { if inBool then result = "TRUE" else result = "FALSE" end } #-----------------------------------------------------------------------------* # returns a list with inSize elements. Each element is unconstructed #-----------------------------------------------------------------------------* func listOfSize ?@bigint inSize -> @list result { result = .emptyList loop ([inSize uint]) while inSize > 0 do result += !@gtlUnconstructed.new { !.here !emptylstring() } inSize-- end } #-----------------------------------------------------------------------------* # Returns the version string. #-----------------------------------------------------------------------------* func version -> @string result { result = @application.projectVersionString } #-----------------------------------------------------------------------------* # Returns the major version as int. #-----------------------------------------------------------------------------* func majorVersion -> @bigint result { let @string version = @application.projectVersionString let @stringlist versionComponents = [version componentsSeparatedByString !"."] if [versionComponents length] > 0 then result = [[[versionComponents mValueAtIndex !0] decimalUnsignedNumber] bigint] else result = 0 end } #-----------------------------------------------------------------------------* # Returns the minor version as int. #-----------------------------------------------------------------------------* func minorVersion -> @bigint result { let @string version = @application.projectVersionString let @stringlist versionComponents = [version componentsSeparatedByString !"."] if [versionComponents length] > 1 then result = [[[versionComponents mValueAtIndex !1] decimalUnsignedNumber] bigint] else result = 0 end } #-----------------------------------------------------------------------------* # Returns the revision as int. #-----------------------------------------------------------------------------* func revision -> @bigint result { let @string version = @application.projectVersionString let @stringlist versionComponents = [version componentsSeparatedByString !"."] if [versionComponents length] > 2 then result = [[[versionComponents mValueAtIndex !2] decimalUnsignedNumber] bigint] else result = 0 end } #-----------------------------------------------------------------------------* # Returns the current directory. #-----------------------------------------------------------------------------* func currentDir -> @string result { result = @string.stringWithCurrentDirectory } #-----------------------------------------------------------------------------* # Returns the home directory. #-----------------------------------------------------------------------------* func homeDir -> @string result { result = @string.homeDirectory } #-----------------------------------------------------------------------------* # Returns the current date and time as GMT #-----------------------------------------------------------------------------* func currentDateTime -> @string result { result = @string.stringWithCurrentDateTime } #-----------------------------------------------------------------------------* # Returns the max 8 bits unsigned integer #-----------------------------------------------------------------------------* func max8bitsUnsignedInt -> @bigint result { result = 255 } #-----------------------------------------------------------------------------* # Returns the max 8 bits signed integer #-----------------------------------------------------------------------------* func max8bitsSignedInt -> @bigint result { result = 127 } #-----------------------------------------------------------------------------* # Returns the min 8 bits signed integer #-----------------------------------------------------------------------------* func min8bitsSignedInt -> @bigint result { result = -128 } #-----------------------------------------------------------------------------* # Returns the max 16 bits unsigned integer #-----------------------------------------------------------------------------* func max16bitsUnsignedInt -> @bigint result { result = 65535 } #-----------------------------------------------------------------------------* # Returns the max 16 bits signed integer #-----------------------------------------------------------------------------* func max16bitsSignedInt -> @bigint result { result = 32767 } #-----------------------------------------------------------------------------* # Returns the min 16 bits signed integer #-----------------------------------------------------------------------------* func min16bitsSignedInt -> @bigint result { result = -32768 } #-----------------------------------------------------------------------------* # Returns the max 32 bits unsigned integer #-----------------------------------------------------------------------------* func max32bitsUnsignedInt -> @bigint result { result = [@uint.max bigint] } #-----------------------------------------------------------------------------* # Returns the max 32 bits signed integer #-----------------------------------------------------------------------------* func max32bitsSignedInt -> @bigint result { result = [@sint.max bigint] } #-----------------------------------------------------------------------------* # Returns the min 32 bits signed integer #-----------------------------------------------------------------------------* func min32bitsSignedInt -> @bigint result { result = [@sint.min bigint] } #-----------------------------------------------------------------------------* # Returns the max 32 bits unsigned integer #-----------------------------------------------------------------------------* func max64bitsUnsignedInt -> @bigint result { result = [@uint64.max bigint] } #-----------------------------------------------------------------------------* # Returns the max 32 bits signed integer #-----------------------------------------------------------------------------* func max64bitsSignedInt -> @bigint result { result = [@sint64.max bigint] } #-----------------------------------------------------------------------------* # Returns the min 32 bits signed integer #-----------------------------------------------------------------------------* func min64bitsSignedInt -> @bigint result { result = [@sint64.min bigint] } #-----------------------------------------------------------------------------* # Returns an approximation of pi #-----------------------------------------------------------------------------* func pi -> @double result { result = @double.pi }