Typing the untyped values in an array of Any, commenting stuff
This commit is contained in:
@@ -14,31 +14,48 @@ AnyArguments :: (values: []Any)
|
||||
* Released under GPLv3.
|
||||
*/
|
||||
IntegerToString :: (value: S64, result: *U8, base: S64): *U8
|
||||
// check that the base if valid
|
||||
if (base < 2) || (base > 36)
|
||||
*result = 0 // '
|
||||
return result
|
||||
|
||||
ptr := result
|
||||
ptr1 := result
|
||||
tmp_char: U8
|
||||
tmp_value: S64
|
||||
|
||||
for value != 0
|
||||
tmp_value = value
|
||||
value /= base
|
||||
*ptr++ = "zyxwvutsrqponmlkjihgfedcba9876543210123456789abcdefghijklmnopqrstuvwxyz"[35 + (tmp_value - value * base)]
|
||||
|
||||
// Apply negative sign
|
||||
if tmp_value < 0
|
||||
*ptr++ = '-'
|
||||
*ptr-- = 0
|
||||
for ptr1 < ptr
|
||||
tmp_char = *ptr
|
||||
*ptr-- = *ptr1
|
||||
*ptr1++ = tmp_char
|
||||
// check that the base if valid
|
||||
if (base < 2) || (base > 36)
|
||||
*result = 0 // '
|
||||
return result
|
||||
|
||||
ptr := result
|
||||
ptr1 := result
|
||||
tmp_char: U8
|
||||
tmp_value: S64
|
||||
|
||||
for value != 0
|
||||
tmp_value = value
|
||||
value /= base
|
||||
*ptr++ = "zyxwvutsrqponmlkjihgfedcba9876543210123456789abcdefghijklmnopqrstuvwxyz"[35 + (tmp_value - value * base)]
|
||||
|
||||
// Apply negative sign
|
||||
if tmp_value < 0
|
||||
*ptr++ = '-'
|
||||
*ptr-- = 0
|
||||
for ptr1 < ptr
|
||||
tmp_char = *ptr
|
||||
*ptr-- = *ptr1
|
||||
*ptr1++ = tmp_char
|
||||
return result
|
||||
|
||||
|
||||
|
||||
StringToDouble :: (s: String): F64
|
||||
sign: F64 = 1.0
|
||||
i := 0
|
||||
|
||||
if s[i] == '-'
|
||||
sign = -1
|
||||
i += 1
|
||||
elif s[i] == '+'
|
||||
i += 1
|
||||
|
||||
for , i < Len(s), i+= 1
|
||||
pass // BACKUP
|
||||
|
||||
return 0
|
||||
|
||||
FormatString :: (buffer: *U8, buffer_len: U64, string: String, args: ..)
|
||||
|
||||
// @todo(krzosa): Add consideration of buffer SIZE! Add some function to handle this OutStr or something
|
||||
@@ -78,6 +95,6 @@ main :: (): int
|
||||
Assert(*(values[1].data->*S64) == 20)
|
||||
|
||||
buf: [128]U8
|
||||
FormatString(&buf[0], Len(buf), "Test % %", {32->S64, 156->S64})
|
||||
FormatString(&buf[0], Len(buf), "Test % %", {32, 156})
|
||||
|
||||
return 0
|
||||
Reference in New Issue
Block a user