diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2024-09-02 17:48:36 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-10-21 13:30:51 -0300 |
| commit | aa3199def734b492059fcaccdebd3cde85cb8547 (patch) | |
| tree | 21cf0c7cde073b56f4ddbf7c846441f519b97982 /src | |
| parent | 7aac852ddead017c90c775991801e2f7dadc84e0 (diff) | |
| download | luarocks-aa3199def734b492059fcaccdebd3cde85cb8547.tar.gz luarocks-aa3199def734b492059fcaccdebd3cde85cb8547.tar.bz2 luarocks-aa3199def734b492059fcaccdebd3cde85cb8547.zip | |
Teal: make schedule_function generic
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/util.lua | 6 | ||||
| -rw-r--r-- | src/luarocks/util.tl | 10 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index 7035f305..0ea480be 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
| @@ -56,8 +56,8 @@ local scheduled_functions = {} | |||
| 56 | 56 | ||
| 57 | 57 | ||
| 58 | 58 | ||
| 59 | function util.schedule_function(f, ...) | 59 | function util.schedule_function(f, x) |
| 60 | local item = { fn = f, args = _tl_table_pack(...) } | 60 | local item = { fn = f, arg = x } |
| 61 | table.insert(scheduled_functions, item) | 61 | table.insert(scheduled_functions, item) |
| 62 | return item | 62 | return item |
| 63 | end | 63 | end |
| @@ -87,7 +87,7 @@ function util.run_scheduled_functions() | |||
| 87 | end | 87 | end |
| 88 | for i = #scheduled_functions, 1, -1 do | 88 | for i = #scheduled_functions, 1, -1 do |
| 89 | local item = scheduled_functions[i] | 89 | local item = scheduled_functions[i] |
| 90 | item.fn(_tl_table_unpack(item.args, 1, item.args.n)) | 90 | item.fn(item.arg) |
| 91 | end | 91 | end |
| 92 | end | 92 | end |
| 93 | 93 | ||
diff --git a/src/luarocks/util.tl b/src/luarocks/util.tl index 823ee1db..80d39b16 100644 --- a/src/luarocks/util.tl +++ b/src/luarocks/util.tl | |||
| @@ -24,8 +24,8 @@ local record util | |||
| 24 | matchquote: function(string): string | 24 | matchquote: function(string): string |
| 25 | 25 | ||
| 26 | record Fn | 26 | record Fn |
| 27 | fn: function(...: any) | 27 | fn: function(any) |
| 28 | args: table.PackTable<any> | 28 | arg: any |
| 29 | end | 29 | end |
| 30 | end | 30 | end |
| 31 | 31 | ||
| @@ -56,8 +56,8 @@ local scheduled_functions: {Fn} = {} | |||
| 56 | -- @param ... arguments to be passed to function. | 56 | -- @param ... arguments to be passed to function. |
| 57 | -- @return table: A token representing the scheduled execution, | 57 | -- @return table: A token representing the scheduled execution, |
| 58 | -- which can be used to remove the item later from the list. | 58 | -- which can be used to remove the item later from the list. |
| 59 | function util.schedule_function(f: function(...: any), ...:any): Fn | 59 | function util.schedule_function<X>(f: function(X...), x?: X): Fn |
| 60 | local item: Fn = { fn = f, args = table.pack(...) } | 60 | local item: Fn = { fn = f, arg = x } |
| 61 | table.insert(scheduled_functions, item) | 61 | table.insert(scheduled_functions, item) |
| 62 | return item | 62 | return item |
| 63 | end | 63 | end |
| @@ -87,7 +87,7 @@ function util.run_scheduled_functions(): string --! a hack for xpcall | |||
| 87 | end | 87 | end |
| 88 | for i = #scheduled_functions, 1, -1 do | 88 | for i = #scheduled_functions, 1, -1 do |
| 89 | local item = scheduled_functions[i] | 89 | local item = scheduled_functions[i] |
| 90 | item.fn(table.unpack(item.args, 1, item.args.n)) | 90 | item.fn(item.arg) |
| 91 | end | 91 | end |
| 92 | end | 92 | end |
| 93 | 93 | ||
