Commit Graph

10 Commits

Author SHA1 Message Date
Oleksandr Redko
938cb6e9d8
pkg,service: remove unnecessary convertions (#3564) 2023-11-14 16:36:55 +01:00
Andrei Matei
ae67a45a1c
starbind: fix Starlark slice unmarshaling (#3454)
The unmarshaling code for slices wasn't actually setting the
destination. This patch fixes it.
2023-08-07 12:11:05 -07:00
gocurr
b5c9edccff
pkg/terminal: use reflect.Value.IsValid to check a zero Value (#3450)
I searched the source code of Go, and found no usages of
"== (reflect.Value{})" and "!= (reflect.Value{})". I think
it's more idiomatic to use "IsValid" to check a zero Value.
2023-08-01 08:35:59 -07:00
Andrei Matei
7603e46f75
starbind: fix use of ptr variables in starlark (#3386) 2023-05-31 10:29:36 -07:00
Vitaliy Filippov
efb119d969
terminal: Fix printing boolean values in Starlark scripts (#3314) 2023-03-29 09:40:58 -07:00
Alessandro Arzilli
29eae8f617
*: clean up staticcheck problems (#2723)
Fix problems that can be fixed, ignore the ones that don't make sense
2021-09-28 12:07:42 -07:00
Derek Parker
ad2563f008 pkg/terminal: Remove unused slice and append 2020-03-20 09:16:17 +01:00
Derek Parker
ad75f78c4e
*: Fix go vet complaints (#1935)
* *: Fix go vet struct complaints

* *: Fix struct vet issue on linux

* *: Ignore proc/native in go vet check

We have to do some unsafe pointer manipulation that will never make go
vet happy within the proc/native package. Ignore it for runs of go vet.
2020-03-18 09:25:32 -07:00
Alun Evans
36d688bf14 pkg/terminal: Fix starlark map iteration for maps > 64 entries (#1699)
* Fix starlark map iteration for maps > 64 entries

* Fix TestMapEvaluation
2019-10-07 09:35:58 -07:00
Alessandro Arzilli
ed35dce7a3 terminal: adds embedded scripting language (#1466)
If the argument of 'source' ends in '.star' it will be interpreted as a
starlark script.
If the argument of 'source' is '-' an interactive starlark repl will be
started.

For documentation on how the starlark execution environment works see
Documentation/cli/starlark.md.

The starlark API is autogenerated from the JSON-RPC API by
script/gen-starlark-bindings.go.
In general for each JSON-RPC API a single global starlark function is
created.
When one of those functions is called (through a starlark script) the
arguments are converted to go structs using reflection. See
unmarshalStarlarkValue in pkg/terminal/starbind/conv.go.
If there are no type conversion errors the JSON-RPC call is executed.
The return value of the JSON-RPC call is converted back into a starlark
value by interfaceToStarlarkValue (same file):

* primitive types (such as integers, floats or strings) are converted
  by creating the corresponding starlark value.
* compound types (such as structs and slices) are converted by wrapping
  their reflect.Value object into a type that implements the relevant
  starlark interfaces.
* api.Variables are treated specially so that their Value field can be
  of the proper type instead of always being a string.

Implements #1415, #1443
2019-07-02 10:55:27 -07:00