teal: Use new integer support in Teal 0.13.0
authorKim Alvefur <zash@zash.se>
Thu, 18 Mar 2021 23:16:41 +0100
changeset 11463 86904555bffc
parent 11462 0e00fa518688
child 11464 a8b4e04bc044
teal: Use new integer support in Teal 0.13.0
teal-src/util/crand.d.tl
teal-src/util/datamapper.tl
teal-src/util/datetime.d.tl
teal-src/util/encodings.d.tl
teal-src/util/error.d.tl
teal-src/util/hashes.d.tl
teal-src/util/id.d.tl
teal-src/util/jsonschema.tl
teal-src/util/poll.d.tl
teal-src/util/pposix.d.tl
teal-src/util/random.d.tl
teal-src/util/stanza.d.tl
teal-src/util/table.d.tl
teal-src/util/uuid.d.tl
--- a/teal-src/util/crand.d.tl	Thu Mar 18 13:07:10 2021 +0100
+++ b/teal-src/util/crand.d.tl	Thu Mar 18 23:16:41 2021 +0100
@@ -1,5 +1,5 @@
 local record lib
-	bytes : function (n : number) : string
+	bytes : function (n : integer) : string
 	enum sourceid "OpenSSL" "arc4random()" "Linux" end
 	_source : sourceid
 end
--- a/teal-src/util/datamapper.tl	Thu Mar 18 13:07:10 2021 +0100
+++ b/teal-src/util/datamapper.tl	Thu Mar 18 23:16:41 2021 +0100
@@ -17,6 +17,7 @@
 -- TODO arrays
 -- TODO pointers
 -- TODO cleanup / refactor
+-- TODO s/number/integer/ once we have appropriate math.type() compat
 --
 
 local st = require "util.stanza";
@@ -246,7 +247,7 @@
 						out.attr[attr] = v
 					elseif proptype == "number" and v is number then
 						out.attr[attr] = string.format("%g", v)
-					elseif proptype == "integer" and v is number then
+					elseif proptype == "integer" and v is number then -- TODO is integer
 						out.attr[attr] = string.format("%d", v)
 					elseif proptype == "boolean" then
 						out.attr[attr] = v and "1" or "0"
@@ -266,7 +267,7 @@
 						propattr[single_attribute] = v
 					elseif proptype == "number" and v is number then
 						propattr[single_attribute] = string.format("%g", v)
-					elseif proptype == "integer" and v is number then
+					elseif proptype == "integer" and v is number then -- TODO is integer
 						propattr[single_attribute] = string.format("%d", v)
 					elseif proptype == "boolean" and v is boolean then
 						propattr[single_attribute] = v and "1" or "0"
@@ -288,7 +289,7 @@
 						out:text_tag(name, v, propattr)
 					elseif proptype == "number" and v is number then
 						out:text_tag(name, string.format("%g", v), propattr)
-					elseif proptype == "integer" and v is number then
+					elseif proptype == "integer" and v is number then -- TODO is integer
 						out:text_tag(name, string.format("%d", v), propattr)
 					elseif proptype == "boolean" and v is boolean then
 						out:text_tag(name, v and "1" or "0", propattr)
--- a/teal-src/util/datetime.d.tl	Thu Mar 18 13:07:10 2021 +0100
+++ b/teal-src/util/datetime.d.tl	Thu Mar 18 23:16:41 2021 +0100
@@ -1,11 +1,11 @@
 -- TODO s/number/integer/ once Teal gets support for that
 
 local record lib
-	date     : function (t : number) : string
-	datetime : function (t : number) : string
-	time     : function (t : number) : string
-	legacy   : function (t : number) : string
-	parse    : function (t : string) : number
+	date     : function (t : integer) : string
+	datetime : function (t : integer) : string
+	time     : function (t : integer) : string
+	legacy   : function (t : integer) : string
+	parse    : function (t : string) : integer
 end
 
 return lib
--- a/teal-src/util/encodings.d.tl	Thu Mar 18 13:07:10 2021 +0100
+++ b/teal-src/util/encodings.d.tl	Thu Mar 18 23:16:41 2021 +0100
@@ -16,7 +16,7 @@
 	end
 	record utf8
 		valid : function (s : string) : boolean
-		length : function (s : string) : number
+		length : function (s : string) : integer
 	end
 	record confusable
 		skeleteon : function (s : string) : string
--- a/teal-src/util/error.d.tl	Thu Mar 18 13:07:10 2021 +0100
+++ b/teal-src/util/error.d.tl	Thu Mar 18 23:16:41 2021 +0100
@@ -35,14 +35,14 @@
 	type : error_type
 	condition : error_condition
 	text : string
-	code : number
+	code : integer
 end
 
 local record error
 	type : error_type
 	condition : error_condition
 	text : string
-	code : number
+	code : integer
 	context : { any : any }
 	source : string
 end
--- a/teal-src/util/hashes.d.tl	Thu Mar 18 13:07:10 2021 +0100
+++ b/teal-src/util/hashes.d.tl	Thu Mar 18 23:16:41 2021 +0100
@@ -1,6 +1,6 @@
 local type hash = function (msg : string, hex : boolean) : string
 local type hmac = function (key : string, msg : string, hex : boolean) : string
-local type kdf = function (pass : string, salt : string, i : number) : string
+local type kdf = function (pass : string, salt : string, i : integer) : string
 
 local record lib
 	sha1 : hash
--- a/teal-src/util/id.d.tl	Thu Mar 18 13:07:10 2021 +0100
+++ b/teal-src/util/id.d.tl	Thu Mar 18 23:16:41 2021 +0100
@@ -2,7 +2,7 @@
 	short : function () : string
 	medium : function () : string
 	long : function () : string
-	custom : function (number) : function () : string
+	custom : function (integer) : function () : string
 
 end
 return lib
--- a/teal-src/util/jsonschema.tl	Thu Mar 18 13:07:10 2021 +0100
+++ b/teal-src/util/jsonschema.tl	Thu Mar 18 23:16:41 2021 +0100
@@ -40,8 +40,8 @@
 	exclusiveMinimum : number
 
 	-- strings
-	maxLength : number
-	minLength : number
+	maxLength : integer
+	minLength : integer
 	pattern : string
 	format : string
 
@@ -49,16 +49,16 @@
 	prefixItems : { schema_t }
 	items : schema_t
 	contains : schema_t
-	maxItems : number
-	minItems : number
+	maxItems : integer
+	minItems : integer
 	uniqueItems : boolean
-	maxContains : number
-	minContains : number
+	maxContains : integer
+	minContains : integer
 
 	-- objects
 	properties : { string : schema_t | type_e }
-	maxProperties : number
-	minProperties : number
+	maxProperties : integer
+	minProperties : integer
 	required : { string }
 	dependentRequired : { string : { string } }
 	additionalProperties: schema_t
--- a/teal-src/util/poll.d.tl	Thu Mar 18 13:07:10 2021 +0100
+++ b/teal-src/util/poll.d.tl	Thu Mar 18 23:16:41 2021 +0100
@@ -3,22 +3,22 @@
 		"timeout"
 		"signal"
 	end
-	add : function (state, number, boolean, boolean) : boolean
-	add : function (state, number, boolean, boolean) : nil, string, number
-	set : function (state, number, boolean, boolean) : boolean
-	set : function (state, number, boolean, boolean) : nil, string, number
-	del : function (state, number) : boolean
-	del : function (state, number) : nil, string, number
-	wait : function (state, number) : number, boolean, boolean
-	wait : function (state, number) : nil, string, number
-	wait : function (state, number) : nil, waiterr
-	getfd : function (state) : number
+	add : function (state, integer, boolean, boolean) : boolean
+	add : function (state, integer, boolean, boolean) : nil, string, integer
+	set : function (state, integer, boolean, boolean) : boolean
+	set : function (state, integer, boolean, boolean) : nil, string, integer
+	del : function (state, integer) : boolean
+	del : function (state, integer) : nil, string, integer
+	wait : function (state, integer) : integer, boolean, boolean
+	wait : function (state, integer) : nil, string, integer
+	wait : function (state, integer) : nil, waiterr
+	getfd : function (state) : integer
 end
 
 local record lib
 	new : function () : state
-	ENOENT : number
-	EEXIST : number
+	ENOENT : integer
+	EEXIST : integer
 end
 
 return lib
--- a/teal-src/util/pposix.d.tl	Thu Mar 18 13:07:10 2021 +0100
+++ b/teal-src/util/pposix.d.tl	Thu Mar 18 23:16:41 2021 +0100
@@ -46,7 +46,7 @@
 		"unlimited"
 	end
 
-	type ulimit_limit = number | ulimit_unlimited
+	type ulimit_limit = integer | ulimit_unlimited
 
 	record utsname
 		sysname         :  string
@@ -58,11 +58,11 @@
 	end
 
 	record memoryinfo
-		allocated       :  number
-		allocated_mmap  :  number
-		used            :  number
-		unused          :  number
-		returnable      :  number
+		allocated       :  integer
+		allocated_mmap  :  integer
+		used            :  integer
+		unused          :  integer
+		returnable      :  integer
 	end
 
 	abort : function ()
@@ -74,13 +74,13 @@
 	syslog_log : function (level : syslog_level, src : string, msg : string)
 	syslog_setminlevel : function (level : syslog_level)
 
-	getpid : function () : number
-	getuid : function () : number
-	getgid : function () : number
+	getpid : function () : integer
+	getuid : function () : integer
+	getgid : function () : integer
 
-	setuid : function (uid : string) : boolean, string -- string|number
-	setgid : function (uid : string) : boolean, string
-	initgroups : function (user : string, gid : number) : boolean, string
+	setuid : function (uid : integer | string) : boolean, string -- string|integer
+	setgid : function (uid : integer | string) : boolean, string
+	initgroups : function (user : string, gid : integer) : boolean, string
 
 	umask : function (umask : string) : string
 
@@ -96,9 +96,9 @@
 
 	meminfo : function () : memoryinfo
 
-	atomic_append : function (f : FILE, s : string) : boolean, string, number
+	atomic_append : function (f : FILE, s : string) : boolean, string, integer
 
-	ENOENT : number
+	ENOENT : integer
 	_NAME : string
 	_VESRION : string
 end
--- a/teal-src/util/random.d.tl	Thu Mar 18 13:07:10 2021 +0100
+++ b/teal-src/util/random.d.tl	Thu Mar 18 23:16:41 2021 +0100
@@ -1,4 +1,4 @@
 local record lib
-	bytes : function (n:number):string
+	bytes : function (n:integer):string
 end
 return lib
--- a/teal-src/util/stanza.d.tl	Thu Mar 18 13:07:10 2021 +0100
+++ b/teal-src/util/stanza.d.tl	Thu Mar 18 23:16:41 2021 +0100
@@ -26,7 +26,7 @@
 		get_child_text : function ( stanza_t, string, string ) : string
 		child_with_name : function ( stanza_t, string, string ) : stanza_t
 		child_with_ns : function ( stanza_t, string, string ) : stanza_t
-		children : function ( stanza_t ) : children_iter, stanza_t, number
+		children : function ( stanza_t ) : children_iter, stanza_t, integer
 		childtags : function ( stanza_t, string, string ) : childtags_iter
 		maptags : function ( stanza_t, maptags_cb ) : stanza_t
 		find : function ( stanza_t, string ) : stanza_t | string
@@ -36,7 +36,7 @@
 		pretty_top_tag : function ( stanza_t ) : string
 
 		get_error : function ( stanza_t ) : string, string, string, stanza_t
-		indent : function ( stanza_t, number, string ) : stanza_t
+		indent : function ( stanza_t, integer, string ) : stanza_t
 	end
 
 	record serialized_stanza_t
--- a/teal-src/util/table.d.tl	Thu Mar 18 13:07:10 2021 +0100
+++ b/teal-src/util/table.d.tl	Thu Mar 18 23:16:41 2021 +0100
@@ -1,5 +1,5 @@
 local record lib
-	create : function (narr:number, nrec:number):table
+	create : function (narr:integer, nrec:integer):table
 	pack : function (...:any):{any}
 end
 return lib
--- a/teal-src/util/uuid.d.tl	Thu Mar 18 13:07:10 2021 +0100
+++ b/teal-src/util/uuid.d.tl	Thu Mar 18 23:16:41 2021 +0100
@@ -1,5 +1,8 @@
 local record lib
-	generate : function (number) : string
+	get_nibbles : (number) : string
+	generate : function () : string
+
+	seed : function (string)
 end
 return lib