mirror of https://github.com/containers/podman.git
Bump github.com/onsi/gomega from 1.11.0 to 1.12.0
Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.11.0 to 1.12.0. - [Release notes](https://github.com/onsi/gomega/releases) - [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/gomega/compare/v1.11.0...v1.12.0) Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
parent
9b9bd9e0e7
commit
3de369fd69
4
go.mod
4
go.mod
|
|
@ -43,7 +43,7 @@ require (
|
||||||
github.com/moby/term v0.0.0-20201216013528-df9cb8a40635
|
github.com/moby/term v0.0.0-20201216013528-df9cb8a40635
|
||||||
github.com/mrunalp/fileutils v0.5.0
|
github.com/mrunalp/fileutils v0.5.0
|
||||||
github.com/onsi/ginkgo v1.16.2
|
github.com/onsi/ginkgo v1.16.2
|
||||||
github.com/onsi/gomega v1.11.0
|
github.com/onsi/gomega v1.12.0
|
||||||
github.com/opencontainers/go-digest v1.0.0
|
github.com/opencontainers/go-digest v1.0.0
|
||||||
github.com/opencontainers/image-spec v1.0.2-0.20190823105129-775207bd45b6
|
github.com/opencontainers/image-spec v1.0.2-0.20190823105129-775207bd45b6
|
||||||
github.com/opencontainers/runc v1.0.0-rc93
|
github.com/opencontainers/runc v1.0.0-rc93
|
||||||
|
|
@ -64,7 +64,7 @@ require (
|
||||||
go.etcd.io/bbolt v1.3.5
|
go.etcd.io/bbolt v1.3.5
|
||||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
|
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
|
||||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a
|
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a
|
||||||
golang.org/x/sys v0.0.0-20210324051608-47abb6519492
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
|
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
|
||||||
k8s.io/api v0.21.0
|
k8s.io/api v0.21.0
|
||||||
k8s.io/apimachinery v0.21.0
|
k8s.io/apimachinery v0.21.0
|
||||||
|
|
|
||||||
20
go.sum
20
go.sum
|
|
@ -376,8 +376,10 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W
|
||||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
|
|
||||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
|
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||||
|
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||||
github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA=
|
github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA=
|
||||||
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||||
|
|
@ -622,8 +624,9 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J
|
||||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||||
github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc=
|
github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc=
|
||||||
github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48=
|
github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48=
|
||||||
github.com/onsi/gomega v1.11.0 h1:+CqWgvj0OZycCaqclBD1pxKHAU+tOkHmQIWvDHq2aug=
|
|
||||||
github.com/onsi/gomega v1.11.0/go.mod h1:azGKhqFUon9Vuj0YmTfLSmx0FUwqXYSTl5re8lQLTUg=
|
github.com/onsi/gomega v1.11.0/go.mod h1:azGKhqFUon9Vuj0YmTfLSmx0FUwqXYSTl5re8lQLTUg=
|
||||||
|
github.com/onsi/gomega v1.12.0 h1:p4oGGk2M2UJc0wWN4lHFvIB71lxsh0T/UiKCCgFADY8=
|
||||||
|
github.com/onsi/gomega v1.12.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY=
|
||||||
github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
||||||
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
||||||
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
||||||
|
|
@ -927,8 +930,9 @@ golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwY
|
||||||
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/net v0.0.0-20210224082022-3d97a244fca7/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210224082022-3d97a244fca7/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw=
|
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
|
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 h1:DzZ89McO9/gWPsQXS/FVKAlG02ZjaQ6AlZRBimEYOd0=
|
||||||
|
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
|
|
@ -1019,8 +1023,9 @@ golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210216224549-f992740a1bac/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210216224549-f992740a1bac/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210324051608-47abb6519492 h1:Paq34FxTluEPvVyayQqMPgHm+vTOrIifmcYxFBx9TLg=
|
|
||||||
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c=
|
||||||
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/term v0.0.0-20201113234701-d7a72108b828/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
golang.org/x/term v0.0.0-20201113234701-d7a72108b828/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
|
@ -1029,8 +1034,9 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc=
|
|
||||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
||||||
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
|
|
@ -1147,8 +1153,10 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
|
||||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
|
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
|
||||||
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
|
|
||||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||||
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
|
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
|
||||||
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
|
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
|
||||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/reflect/protodesc"
|
||||||
"google.golang.org/protobuf/reflect/protoreflect"
|
"google.golang.org/protobuf/reflect/protoreflect"
|
||||||
"google.golang.org/protobuf/reflect/protoregistry"
|
"google.golang.org/protobuf/reflect/protoregistry"
|
||||||
"google.golang.org/protobuf/runtime/protoimpl"
|
"google.golang.org/protobuf/runtime/protoimpl"
|
||||||
|
|
@ -62,14 +63,7 @@ func FileDescriptor(s filePath) fileDescGZIP {
|
||||||
// Find the descriptor in the v2 registry.
|
// Find the descriptor in the v2 registry.
|
||||||
var b []byte
|
var b []byte
|
||||||
if fd, _ := protoregistry.GlobalFiles.FindFileByPath(s); fd != nil {
|
if fd, _ := protoregistry.GlobalFiles.FindFileByPath(s); fd != nil {
|
||||||
if fd, ok := fd.(interface{ ProtoLegacyRawDesc() []byte }); ok {
|
b, _ = Marshal(protodesc.ToFileDescriptorProto(fd))
|
||||||
b = fd.ProtoLegacyRawDesc()
|
|
||||||
} else {
|
|
||||||
// TODO: Use protodesc.ToFileDescriptorProto to construct
|
|
||||||
// a descriptorpb.FileDescriptorProto and marshal it.
|
|
||||||
// However, doing so causes the proto package to have a dependency
|
|
||||||
// on descriptorpb, leading to cyclic dependency issues.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Locally cache the raw descriptor form for the file.
|
// Locally cache the raw descriptor form for the file.
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ const urlPrefix = "type.googleapis.com/"
|
||||||
|
|
||||||
// AnyMessageName returns the message name contained in an anypb.Any message.
|
// AnyMessageName returns the message name contained in an anypb.Any message.
|
||||||
// Most type assertions should use the Is function instead.
|
// Most type assertions should use the Is function instead.
|
||||||
|
//
|
||||||
|
// Deprecated: Call the any.MessageName method instead.
|
||||||
func AnyMessageName(any *anypb.Any) (string, error) {
|
func AnyMessageName(any *anypb.Any) (string, error) {
|
||||||
name, err := anyMessageName(any)
|
name, err := anyMessageName(any)
|
||||||
return string(name), err
|
return string(name), err
|
||||||
|
|
@ -38,6 +40,8 @@ func anyMessageName(any *anypb.Any) (protoreflect.FullName, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalAny marshals the given message m into an anypb.Any message.
|
// MarshalAny marshals the given message m into an anypb.Any message.
|
||||||
|
//
|
||||||
|
// Deprecated: Call the anypb.New function instead.
|
||||||
func MarshalAny(m proto.Message) (*anypb.Any, error) {
|
func MarshalAny(m proto.Message) (*anypb.Any, error) {
|
||||||
switch dm := m.(type) {
|
switch dm := m.(type) {
|
||||||
case DynamicAny:
|
case DynamicAny:
|
||||||
|
|
@ -58,6 +62,9 @@ func MarshalAny(m proto.Message) (*anypb.Any, error) {
|
||||||
// Empty returns a new message of the type specified in an anypb.Any message.
|
// Empty returns a new message of the type specified in an anypb.Any message.
|
||||||
// It returns protoregistry.NotFound if the corresponding message type could not
|
// It returns protoregistry.NotFound if the corresponding message type could not
|
||||||
// be resolved in the global registry.
|
// be resolved in the global registry.
|
||||||
|
//
|
||||||
|
// Deprecated: Use protoregistry.GlobalTypes.FindMessageByName instead
|
||||||
|
// to resolve the message name and create a new instance of it.
|
||||||
func Empty(any *anypb.Any) (proto.Message, error) {
|
func Empty(any *anypb.Any) (proto.Message, error) {
|
||||||
name, err := anyMessageName(any)
|
name, err := anyMessageName(any)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -76,6 +83,8 @@ func Empty(any *anypb.Any) (proto.Message, error) {
|
||||||
//
|
//
|
||||||
// The target message m may be a *DynamicAny message. If the underlying message
|
// The target message m may be a *DynamicAny message. If the underlying message
|
||||||
// type could not be resolved, then this returns protoregistry.NotFound.
|
// type could not be resolved, then this returns protoregistry.NotFound.
|
||||||
|
//
|
||||||
|
// Deprecated: Call the any.UnmarshalTo method instead.
|
||||||
func UnmarshalAny(any *anypb.Any, m proto.Message) error {
|
func UnmarshalAny(any *anypb.Any, m proto.Message) error {
|
||||||
if dm, ok := m.(*DynamicAny); ok {
|
if dm, ok := m.(*DynamicAny); ok {
|
||||||
if dm.Message == nil {
|
if dm.Message == nil {
|
||||||
|
|
@ -100,6 +109,8 @@ func UnmarshalAny(any *anypb.Any, m proto.Message) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is reports whether the Any message contains a message of the specified type.
|
// Is reports whether the Any message contains a message of the specified type.
|
||||||
|
//
|
||||||
|
// Deprecated: Call the any.MessageIs method instead.
|
||||||
func Is(any *anypb.Any, m proto.Message) bool {
|
func Is(any *anypb.Any, m proto.Message) bool {
|
||||||
if any == nil || m == nil {
|
if any == nil || m == nil {
|
||||||
return false
|
return false
|
||||||
|
|
@ -119,6 +130,9 @@ func Is(any *anypb.Any, m proto.Message) bool {
|
||||||
// var x ptypes.DynamicAny
|
// var x ptypes.DynamicAny
|
||||||
// if err := ptypes.UnmarshalAny(a, &x); err != nil { ... }
|
// if err := ptypes.UnmarshalAny(a, &x); err != nil { ... }
|
||||||
// fmt.Printf("unmarshaled message: %v", x.Message)
|
// fmt.Printf("unmarshaled message: %v", x.Message)
|
||||||
|
//
|
||||||
|
// Deprecated: Use the any.UnmarshalNew method instead to unmarshal
|
||||||
|
// the any message contents into a new instance of the underlying message.
|
||||||
type DynamicAny struct{ proto.Message }
|
type DynamicAny struct{ proto.Message }
|
||||||
|
|
||||||
func (m DynamicAny) String() string {
|
func (m DynamicAny) String() string {
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,8 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// Package ptypes provides functionality for interacting with well-known types.
|
// Package ptypes provides functionality for interacting with well-known types.
|
||||||
|
//
|
||||||
|
// Deprecated: Well-known types have specialized functionality directly
|
||||||
|
// injected into the generated packages for each message type.
|
||||||
|
// See the deprecation notice for each function for the suggested alternative.
|
||||||
package ptypes
|
package ptypes
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ const (
|
||||||
|
|
||||||
// Duration converts a durationpb.Duration to a time.Duration.
|
// Duration converts a durationpb.Duration to a time.Duration.
|
||||||
// Duration returns an error if dur is invalid or overflows a time.Duration.
|
// Duration returns an error if dur is invalid or overflows a time.Duration.
|
||||||
|
//
|
||||||
|
// Deprecated: Call the dur.AsDuration and dur.CheckValid methods instead.
|
||||||
func Duration(dur *durationpb.Duration) (time.Duration, error) {
|
func Duration(dur *durationpb.Duration) (time.Duration, error) {
|
||||||
if err := validateDuration(dur); err != nil {
|
if err := validateDuration(dur); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
|
|
@ -39,6 +41,8 @@ func Duration(dur *durationpb.Duration) (time.Duration, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// DurationProto converts a time.Duration to a durationpb.Duration.
|
// DurationProto converts a time.Duration to a durationpb.Duration.
|
||||||
|
//
|
||||||
|
// Deprecated: Call the durationpb.New function instead.
|
||||||
func DurationProto(d time.Duration) *durationpb.Duration {
|
func DurationProto(d time.Duration) *durationpb.Duration {
|
||||||
nanos := d.Nanoseconds()
|
nanos := d.Nanoseconds()
|
||||||
secs := nanos / 1e9
|
secs := nanos / 1e9
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ const (
|
||||||
//
|
//
|
||||||
// A nil Timestamp returns an error. The first return value in that case is
|
// A nil Timestamp returns an error. The first return value in that case is
|
||||||
// undefined.
|
// undefined.
|
||||||
|
//
|
||||||
|
// Deprecated: Call the ts.AsTime and ts.CheckValid methods instead.
|
||||||
func Timestamp(ts *timestamppb.Timestamp) (time.Time, error) {
|
func Timestamp(ts *timestamppb.Timestamp) (time.Time, error) {
|
||||||
// Don't return the zero value on error, because corresponds to a valid
|
// Don't return the zero value on error, because corresponds to a valid
|
||||||
// timestamp. Instead return whatever time.Unix gives us.
|
// timestamp. Instead return whatever time.Unix gives us.
|
||||||
|
|
@ -46,6 +48,8 @@ func Timestamp(ts *timestamppb.Timestamp) (time.Time, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TimestampNow returns a google.protobuf.Timestamp for the current time.
|
// TimestampNow returns a google.protobuf.Timestamp for the current time.
|
||||||
|
//
|
||||||
|
// Deprecated: Call the timestamppb.Now function instead.
|
||||||
func TimestampNow() *timestamppb.Timestamp {
|
func TimestampNow() *timestamppb.Timestamp {
|
||||||
ts, err := TimestampProto(time.Now())
|
ts, err := TimestampProto(time.Now())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -56,6 +60,8 @@ func TimestampNow() *timestamppb.Timestamp {
|
||||||
|
|
||||||
// TimestampProto converts the time.Time to a google.protobuf.Timestamp proto.
|
// TimestampProto converts the time.Time to a google.protobuf.Timestamp proto.
|
||||||
// It returns an error if the resulting Timestamp is invalid.
|
// It returns an error if the resulting Timestamp is invalid.
|
||||||
|
//
|
||||||
|
// Deprecated: Call the timestamppb.New function instead.
|
||||||
func TimestampProto(t time.Time) (*timestamppb.Timestamp, error) {
|
func TimestampProto(t time.Time) (*timestamppb.Timestamp, error) {
|
||||||
ts := ×tamppb.Timestamp{
|
ts := ×tamppb.Timestamp{
|
||||||
Seconds: t.Unix(),
|
Seconds: t.Unix(),
|
||||||
|
|
@ -69,6 +75,9 @@ func TimestampProto(t time.Time) (*timestamppb.Timestamp, error) {
|
||||||
|
|
||||||
// TimestampString returns the RFC 3339 string for valid Timestamps.
|
// TimestampString returns the RFC 3339 string for valid Timestamps.
|
||||||
// For invalid Timestamps, it returns an error message in parentheses.
|
// For invalid Timestamps, it returns an error message in parentheses.
|
||||||
|
//
|
||||||
|
// Deprecated: Call the ts.AsTime method instead,
|
||||||
|
// followed by a call to the Format method on the time.Time value.
|
||||||
func TimestampString(ts *timestamppb.Timestamp) string {
|
func TimestampString(ts *timestamppb.Timestamp) string {
|
||||||
t, err := Timestamp(ts)
|
t, err := Timestamp(ts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,17 @@
|
||||||
|
## 1.12.0
|
||||||
|
|
||||||
|
### Features
|
||||||
|
- Add Satisfy() matcher (#437) [c548f31]
|
||||||
|
- tweak truncation message [3360b8c]
|
||||||
|
- Add format.GomegaStringer (#427) [cc80b6f]
|
||||||
|
- Add Clear() method to gbytes.Buffer [c3c0920]
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
- Fix error message in BeNumericallyMatcher (#432) [09c074a]
|
||||||
|
- Bump github.com/onsi/ginkgo from 1.12.1 to 1.16.2 (#442) [e5f6ea0]
|
||||||
|
- Bump github.com/golang/protobuf from 1.4.3 to 1.5.2 (#431) [adae3bf]
|
||||||
|
- Bump golang.org/x/net (#441) [3275b35]
|
||||||
|
|
||||||
## 1.11.0
|
## 1.11.0
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,10 @@ import (
|
||||||
// Use MaxDepth to set the maximum recursion depth when printing deeply nested objects
|
// Use MaxDepth to set the maximum recursion depth when printing deeply nested objects
|
||||||
var MaxDepth = uint(10)
|
var MaxDepth = uint(10)
|
||||||
|
|
||||||
|
// MaxLength of the string representation of an object.
|
||||||
|
// If MaxLength is set to 0, the Object will not be truncated.
|
||||||
|
var MaxLength = 4000
|
||||||
|
|
||||||
/*
|
/*
|
||||||
By default, all objects (even those that implement fmt.Stringer and fmt.GoStringer) are recursively inspected to generate output.
|
By default, all objects (even those that implement fmt.Stringer and fmt.GoStringer) are recursively inspected to generate output.
|
||||||
|
|
||||||
|
|
@ -53,6 +57,14 @@ var Indent = " "
|
||||||
|
|
||||||
var longFormThreshold = 20
|
var longFormThreshold = 20
|
||||||
|
|
||||||
|
// GomegaStringer allows for custom formating of objects for gomega.
|
||||||
|
type GomegaStringer interface {
|
||||||
|
// GomegaString will be used to custom format an object.
|
||||||
|
// It does not follow UseStringerRepresentation value and will always be called regardless.
|
||||||
|
// It also ignores the MaxLength value.
|
||||||
|
GomegaString() string
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Generates a formatted matcher success/failure message of the form:
|
Generates a formatted matcher success/failure message of the form:
|
||||||
|
|
||||||
|
|
@ -159,6 +171,33 @@ func findFirstMismatch(a, b string) int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const truncateHelpText = `
|
||||||
|
Gomega truncated this representation as it exceeds 'format.MaxLength'.
|
||||||
|
Consider having the object provide a custom 'GomegaStringer' representation
|
||||||
|
or adjust the parameters in Gomega's 'format' package.
|
||||||
|
|
||||||
|
Learn more here: https://onsi.github.io/gomega/#adjusting-output
|
||||||
|
`
|
||||||
|
|
||||||
|
func truncateLongStrings(s string) string {
|
||||||
|
if MaxLength > 0 && len(s) > MaxLength {
|
||||||
|
var sb strings.Builder
|
||||||
|
for i, r := range s {
|
||||||
|
if i < MaxLength {
|
||||||
|
sb.WriteRune(r)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.WriteString("...\n")
|
||||||
|
sb.WriteString(truncateHelpText)
|
||||||
|
|
||||||
|
return sb.String()
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Pretty prints the passed in object at the passed in indentation level.
|
Pretty prints the passed in object at the passed in indentation level.
|
||||||
|
|
||||||
|
|
@ -219,14 +258,21 @@ func formatValue(value reflect.Value, indentation uint) string {
|
||||||
return "nil"
|
return "nil"
|
||||||
}
|
}
|
||||||
|
|
||||||
if UseStringerRepresentation {
|
|
||||||
if value.CanInterface() {
|
if value.CanInterface() {
|
||||||
obj := value.Interface()
|
obj := value.Interface()
|
||||||
|
|
||||||
|
// GomegaStringer will take precedence to other representations and disregards UseStringerRepresentation
|
||||||
|
if x, ok := obj.(GomegaStringer); ok {
|
||||||
|
// do not truncate a user-defined GoMegaString() value
|
||||||
|
return x.GomegaString()
|
||||||
|
}
|
||||||
|
|
||||||
|
if UseStringerRepresentation {
|
||||||
switch x := obj.(type) {
|
switch x := obj.(type) {
|
||||||
case fmt.GoStringer:
|
case fmt.GoStringer:
|
||||||
return x.GoString()
|
return truncateLongStrings(x.GoString())
|
||||||
case fmt.Stringer:
|
case fmt.Stringer:
|
||||||
return x.String()
|
return truncateLongStrings(x.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -257,26 +303,26 @@ func formatValue(value reflect.Value, indentation uint) string {
|
||||||
case reflect.Ptr:
|
case reflect.Ptr:
|
||||||
return formatValue(value.Elem(), indentation)
|
return formatValue(value.Elem(), indentation)
|
||||||
case reflect.Slice:
|
case reflect.Slice:
|
||||||
return formatSlice(value, indentation)
|
return truncateLongStrings(formatSlice(value, indentation))
|
||||||
case reflect.String:
|
case reflect.String:
|
||||||
return formatString(value.String(), indentation)
|
return truncateLongStrings(formatString(value.String(), indentation))
|
||||||
case reflect.Array:
|
case reflect.Array:
|
||||||
return formatSlice(value, indentation)
|
return truncateLongStrings(formatSlice(value, indentation))
|
||||||
case reflect.Map:
|
case reflect.Map:
|
||||||
return formatMap(value, indentation)
|
return truncateLongStrings(formatMap(value, indentation))
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
if value.Type() == timeType && value.CanInterface() {
|
if value.Type() == timeType && value.CanInterface() {
|
||||||
t, _ := value.Interface().(time.Time)
|
t, _ := value.Interface().(time.Time)
|
||||||
return t.Format(time.RFC3339Nano)
|
return t.Format(time.RFC3339Nano)
|
||||||
}
|
}
|
||||||
return formatStruct(value, indentation)
|
return truncateLongStrings(formatStruct(value, indentation))
|
||||||
case reflect.Interface:
|
case reflect.Interface:
|
||||||
return formatInterface(value, indentation)
|
return formatInterface(value, indentation)
|
||||||
default:
|
default:
|
||||||
if value.CanInterface() {
|
if value.CanInterface() {
|
||||||
return fmt.Sprintf("%#v", value.Interface())
|
return truncateLongStrings(fmt.Sprintf("%#v", value.Interface()))
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%#v", value)
|
return truncateLongStrings(fmt.Sprintf("%#v", value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,22 @@ func (b *Buffer) Read(d []byte) (int, error) {
|
||||||
return n, nil
|
return n, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Clear clears out the buffer's contents
|
||||||
|
*/
|
||||||
|
func (b *Buffer) Clear() error {
|
||||||
|
b.lock.Lock()
|
||||||
|
defer b.lock.Unlock()
|
||||||
|
|
||||||
|
if b.closed {
|
||||||
|
return errors.New("attempt to clear closed buffer")
|
||||||
|
}
|
||||||
|
|
||||||
|
b.contents = []byte{}
|
||||||
|
b.readCursor = 0
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Close signifies that the buffer will no longer be written to
|
Close signifies that the buffer will no longer be written to
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ module github.com/onsi/gomega
|
||||||
go 1.14
|
go 1.14
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/golang/protobuf v1.4.3
|
github.com/golang/protobuf v1.5.2
|
||||||
github.com/onsi/ginkgo v1.12.1
|
github.com/onsi/ginkgo v1.16.2
|
||||||
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb
|
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781
|
||||||
gopkg.in/yaml.v2 v2.4.0
|
gopkg.in/yaml.v2 v2.4.0
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,56 +1,93 @@
|
||||||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
|
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||||
|
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||||
|
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||||
github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
|
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
|
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||||
|
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
|
|
||||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||||
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
|
|
||||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||||
|
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||||
|
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
github.com/onsi/ginkgo v1.12.1 h1:mFwc4LvZ0xpSvDZ3E+k8Yte0hLOMxXUlP+yXtJqkYfQ=
|
|
||||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||||
|
github.com/onsi/ginkgo v1.16.2 h1:HFB2fbVIlhIfCfOW81bZFbiC/RvnpXSdhbF2/DJr134=
|
||||||
|
github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E=
|
||||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||||
|
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||||
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb h1:eBmm0M9fYhWpKZLjQUUKka/LtIxf46G4fxeEz5KJr9U=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||||
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
|
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 h1:DzZ89McO9/gWPsQXS/FVKAlG02ZjaQ6AlZRBimEYOd0=
|
||||||
|
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
|
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c=
|
||||||
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
||||||
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||||
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||||
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
|
|
||||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
|
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
|
||||||
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||||
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import (
|
||||||
"github.com/onsi/gomega/types"
|
"github.com/onsi/gomega/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
const GOMEGA_VERSION = "1.11.0"
|
const GOMEGA_VERSION = "1.12.0"
|
||||||
|
|
||||||
const nilFailHandlerPanic = `You are trying to make an assertion, but Gomega's fail handler is nil.
|
const nilFailHandlerPanic = `You are trying to make an assertion, but Gomega's fail handler is nil.
|
||||||
If you're using Ginkgo then you probably forgot to put your assertion in an It().
|
If you're using Ginkgo then you probably forgot to put your assertion in an It().
|
||||||
|
|
|
||||||
|
|
@ -474,3 +474,11 @@ func Not(matcher types.GomegaMatcher) types.GomegaMatcher {
|
||||||
func WithTransform(transform interface{}, matcher types.GomegaMatcher) types.GomegaMatcher {
|
func WithTransform(transform interface{}, matcher types.GomegaMatcher) types.GomegaMatcher {
|
||||||
return matchers.NewWithTransformMatcher(transform, matcher)
|
return matchers.NewWithTransformMatcher(transform, matcher)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Satisfy matches the actual value against the `predicate` function.
|
||||||
|
//The given predicate must be a function of one paramter that returns bool.
|
||||||
|
// var isEven = func(i int) bool { return i%2 == 0 }
|
||||||
|
// Expect(2).To(Satisfy(isEven))
|
||||||
|
func Satisfy(predicate interface{}) types.GomegaMatcher {
|
||||||
|
return matchers.NewSatisfyMatcher(predicate)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ func (matcher *BeNumericallyMatcher) Match(actual interface{}) (success bool, er
|
||||||
return false, fmt.Errorf("Expected a number. Got:\n%s", format.Object(matcher.CompareTo[0], 1))
|
return false, fmt.Errorf("Expected a number. Got:\n%s", format.Object(matcher.CompareTo[0], 1))
|
||||||
}
|
}
|
||||||
if len(matcher.CompareTo) == 2 && !isNumber(matcher.CompareTo[1]) {
|
if len(matcher.CompareTo) == 2 && !isNumber(matcher.CompareTo[1]) {
|
||||||
return false, fmt.Errorf("Expected a number. Got:\n%s", format.Object(matcher.CompareTo[0], 1))
|
return false, fmt.Errorf("Expected a number. Got:\n%s", format.Object(matcher.CompareTo[1], 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
switch matcher.Comparator {
|
switch matcher.Comparator {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
package matchers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
|
||||||
|
"github.com/onsi/gomega/format"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SatisfyMatcher struct {
|
||||||
|
Predicate interface{}
|
||||||
|
|
||||||
|
// cached type
|
||||||
|
predicateArgType reflect.Type
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSatisfyMatcher(predicate interface{}) *SatisfyMatcher {
|
||||||
|
if predicate == nil {
|
||||||
|
panic("predicate cannot be nil")
|
||||||
|
}
|
||||||
|
predicateType := reflect.TypeOf(predicate)
|
||||||
|
if predicateType.Kind() != reflect.Func {
|
||||||
|
panic("predicate must be a function")
|
||||||
|
}
|
||||||
|
if predicateType.NumIn() != 1 {
|
||||||
|
panic("predicate must have 1 argument")
|
||||||
|
}
|
||||||
|
if predicateType.NumOut() != 1 || predicateType.Out(0).Kind() != reflect.Bool {
|
||||||
|
panic("predicate must return bool")
|
||||||
|
}
|
||||||
|
|
||||||
|
return &SatisfyMatcher{
|
||||||
|
Predicate: predicate,
|
||||||
|
predicateArgType: predicateType.In(0),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *SatisfyMatcher) Match(actual interface{}) (success bool, err error) {
|
||||||
|
// prepare a parameter to pass to the predicate
|
||||||
|
var param reflect.Value
|
||||||
|
if actual != nil && reflect.TypeOf(actual).AssignableTo(m.predicateArgType) {
|
||||||
|
// The dynamic type of actual is compatible with the predicate argument.
|
||||||
|
param = reflect.ValueOf(actual)
|
||||||
|
|
||||||
|
} else if actual == nil && m.predicateArgType.Kind() == reflect.Interface {
|
||||||
|
// The dynamic type of actual is unknown, so there's no way to make its
|
||||||
|
// reflect.Value. Create a nil of the predicate argument, which is known.
|
||||||
|
param = reflect.Zero(m.predicateArgType)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return false, fmt.Errorf("predicate expects '%s' but we have '%T'", m.predicateArgType, actual)
|
||||||
|
}
|
||||||
|
|
||||||
|
// call the predicate with `actual`
|
||||||
|
fn := reflect.ValueOf(m.Predicate)
|
||||||
|
result := fn.Call([]reflect.Value{param})
|
||||||
|
return result[0].Bool(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *SatisfyMatcher) FailureMessage(actual interface{}) (message string) {
|
||||||
|
return format.Message(actual, "to satisfy predicate", m.Predicate)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *SatisfyMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
||||||
|
return format.Message(actual, "to not satisfy predicate", m.Predicate)
|
||||||
|
}
|
||||||
|
|
@ -137,11 +137,13 @@ func trimOWS(x string) string {
|
||||||
// contains token amongst its comma-separated tokens, ASCII
|
// contains token amongst its comma-separated tokens, ASCII
|
||||||
// case-insensitively.
|
// case-insensitively.
|
||||||
func headerValueContainsToken(v string, token string) bool {
|
func headerValueContainsToken(v string, token string) bool {
|
||||||
v = trimOWS(v)
|
for comma := strings.IndexByte(v, ','); comma != -1; comma = strings.IndexByte(v, ',') {
|
||||||
if comma := strings.IndexByte(v, ','); comma != -1 {
|
if tokenEqual(trimOWS(v[:comma]), token) {
|
||||||
return tokenEqual(trimOWS(v[:comma]), token) || headerValueContainsToken(v[comma+1:], token)
|
return true
|
||||||
}
|
}
|
||||||
return tokenEqual(v, token)
|
v = v[comma+1:]
|
||||||
|
}
|
||||||
|
return tokenEqual(trimOWS(v), token)
|
||||||
}
|
}
|
||||||
|
|
||||||
// lowerASCII returns the ASCII lowercase version of b.
|
// lowerASCII returns the ASCII lowercase version of b.
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ RUN make
|
||||||
RUN make install
|
RUN make install
|
||||||
|
|
||||||
WORKDIR /root
|
WORKDIR /root
|
||||||
RUN wget http://curl.haxx.se/download/curl-7.45.0.tar.gz
|
RUN wget https://curl.se/download/curl-7.45.0.tar.gz
|
||||||
RUN tar -zxvf curl-7.45.0.tar.gz
|
RUN tar -zxvf curl-7.45.0.tar.gz
|
||||||
WORKDIR /root/curl-7.45.0
|
WORKDIR /root/curl-7.45.0
|
||||||
RUN ./configure --with-ssl --with-nghttp2=/usr/local
|
RUN ./configure --with-ssl --with-nghttp2=/usr/local
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build (linux && 386) || (linux && arm) || (linux && mips) || (linux && mipsle)
|
//go:build (linux && 386) || (linux && arm) || (linux && mips) || (linux && mipsle) || (linux && ppc)
|
||||||
// +build linux,386 linux,arm linux,mips linux,mipsle
|
// +build linux,386 linux,arm linux,mips linux,mipsle linux,ppc
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,196 @@
|
||||||
|
// Copyright 2021 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"runtime"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IoctlRetInt performs an ioctl operation specified by req on a device
|
||||||
|
// associated with opened file descriptor fd, and returns a non-negative
|
||||||
|
// integer that is returned by the ioctl syscall.
|
||||||
|
func IoctlRetInt(fd int, req uint) (int, error) {
|
||||||
|
ret, _, err := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), 0)
|
||||||
|
if err != 0 {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(ret), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlGetUint32(fd int, req uint) (uint32, error) {
|
||||||
|
var value uint32
|
||||||
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlGetRTCTime(fd int) (*RTCTime, error) {
|
||||||
|
var value RTCTime
|
||||||
|
err := ioctl(fd, RTC_RD_TIME, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlSetRTCTime(fd int, value *RTCTime) error {
|
||||||
|
err := ioctl(fd, RTC_SET_TIME, uintptr(unsafe.Pointer(value)))
|
||||||
|
runtime.KeepAlive(value)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlGetRTCWkAlrm(fd int) (*RTCWkAlrm, error) {
|
||||||
|
var value RTCWkAlrm
|
||||||
|
err := ioctl(fd, RTC_WKALM_RD, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlSetRTCWkAlrm(fd int, value *RTCWkAlrm) error {
|
||||||
|
err := ioctl(fd, RTC_WKALM_SET, uintptr(unsafe.Pointer(value)))
|
||||||
|
runtime.KeepAlive(value)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
type ifreqEthtool struct {
|
||||||
|
name [IFNAMSIZ]byte
|
||||||
|
data unsafe.Pointer
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlGetEthtoolDrvinfo fetches ethtool driver information for the network
|
||||||
|
// device specified by ifname.
|
||||||
|
func IoctlGetEthtoolDrvinfo(fd int, ifname string) (*EthtoolDrvinfo, error) {
|
||||||
|
// Leave room for terminating NULL byte.
|
||||||
|
if len(ifname) >= IFNAMSIZ {
|
||||||
|
return nil, EINVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
value := EthtoolDrvinfo{
|
||||||
|
Cmd: ETHTOOL_GDRVINFO,
|
||||||
|
}
|
||||||
|
ifreq := ifreqEthtool{
|
||||||
|
data: unsafe.Pointer(&value),
|
||||||
|
}
|
||||||
|
copy(ifreq.name[:], ifname)
|
||||||
|
err := ioctl(fd, SIOCETHTOOL, uintptr(unsafe.Pointer(&ifreq)))
|
||||||
|
runtime.KeepAlive(ifreq)
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlGetWatchdogInfo fetches information about a watchdog device from the
|
||||||
|
// Linux watchdog API. For more information, see:
|
||||||
|
// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
|
||||||
|
func IoctlGetWatchdogInfo(fd int) (*WatchdogInfo, error) {
|
||||||
|
var value WatchdogInfo
|
||||||
|
err := ioctl(fd, WDIOC_GETSUPPORT, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlWatchdogKeepalive issues a keepalive ioctl to a watchdog device. For
|
||||||
|
// more information, see:
|
||||||
|
// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
|
||||||
|
func IoctlWatchdogKeepalive(fd int) error {
|
||||||
|
return ioctl(fd, WDIOC_KEEPALIVE, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlFileCloneRange performs an FICLONERANGE ioctl operation to clone the
|
||||||
|
// range of data conveyed in value to the file associated with the file
|
||||||
|
// descriptor destFd. See the ioctl_ficlonerange(2) man page for details.
|
||||||
|
func IoctlFileCloneRange(destFd int, value *FileCloneRange) error {
|
||||||
|
err := ioctl(destFd, FICLONERANGE, uintptr(unsafe.Pointer(value)))
|
||||||
|
runtime.KeepAlive(value)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlFileClone performs an FICLONE ioctl operation to clone the entire file
|
||||||
|
// associated with the file description srcFd to the file associated with the
|
||||||
|
// file descriptor destFd. See the ioctl_ficlone(2) man page for details.
|
||||||
|
func IoctlFileClone(destFd, srcFd int) error {
|
||||||
|
return ioctl(destFd, FICLONE, uintptr(srcFd))
|
||||||
|
}
|
||||||
|
|
||||||
|
type FileDedupeRange struct {
|
||||||
|
Src_offset uint64
|
||||||
|
Src_length uint64
|
||||||
|
Reserved1 uint16
|
||||||
|
Reserved2 uint32
|
||||||
|
Info []FileDedupeRangeInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
type FileDedupeRangeInfo struct {
|
||||||
|
Dest_fd int64
|
||||||
|
Dest_offset uint64
|
||||||
|
Bytes_deduped uint64
|
||||||
|
Status int32
|
||||||
|
Reserved uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlFileDedupeRange performs an FIDEDUPERANGE ioctl operation to share the
|
||||||
|
// range of data conveyed in value from the file associated with the file
|
||||||
|
// descriptor srcFd to the value.Info destinations. See the
|
||||||
|
// ioctl_fideduperange(2) man page for details.
|
||||||
|
func IoctlFileDedupeRange(srcFd int, value *FileDedupeRange) error {
|
||||||
|
buf := make([]byte, SizeofRawFileDedupeRange+
|
||||||
|
len(value.Info)*SizeofRawFileDedupeRangeInfo)
|
||||||
|
rawrange := (*RawFileDedupeRange)(unsafe.Pointer(&buf[0]))
|
||||||
|
rawrange.Src_offset = value.Src_offset
|
||||||
|
rawrange.Src_length = value.Src_length
|
||||||
|
rawrange.Dest_count = uint16(len(value.Info))
|
||||||
|
rawrange.Reserved1 = value.Reserved1
|
||||||
|
rawrange.Reserved2 = value.Reserved2
|
||||||
|
|
||||||
|
for i := range value.Info {
|
||||||
|
rawinfo := (*RawFileDedupeRangeInfo)(unsafe.Pointer(
|
||||||
|
uintptr(unsafe.Pointer(&buf[0])) + uintptr(SizeofRawFileDedupeRange) +
|
||||||
|
uintptr(i*SizeofRawFileDedupeRangeInfo)))
|
||||||
|
rawinfo.Dest_fd = value.Info[i].Dest_fd
|
||||||
|
rawinfo.Dest_offset = value.Info[i].Dest_offset
|
||||||
|
rawinfo.Bytes_deduped = value.Info[i].Bytes_deduped
|
||||||
|
rawinfo.Status = value.Info[i].Status
|
||||||
|
rawinfo.Reserved = value.Info[i].Reserved
|
||||||
|
}
|
||||||
|
|
||||||
|
err := ioctl(srcFd, FIDEDUPERANGE, uintptr(unsafe.Pointer(&buf[0])))
|
||||||
|
|
||||||
|
// Output
|
||||||
|
for i := range value.Info {
|
||||||
|
rawinfo := (*RawFileDedupeRangeInfo)(unsafe.Pointer(
|
||||||
|
uintptr(unsafe.Pointer(&buf[0])) + uintptr(SizeofRawFileDedupeRange) +
|
||||||
|
uintptr(i*SizeofRawFileDedupeRangeInfo)))
|
||||||
|
value.Info[i].Dest_fd = rawinfo.Dest_fd
|
||||||
|
value.Info[i].Dest_offset = rawinfo.Dest_offset
|
||||||
|
value.Info[i].Bytes_deduped = rawinfo.Bytes_deduped
|
||||||
|
value.Info[i].Status = rawinfo.Status
|
||||||
|
value.Info[i].Reserved = rawinfo.Reserved
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlHIDGetDesc(fd int, value *HIDRawReportDescriptor) error {
|
||||||
|
err := ioctl(fd, HIDIOCGRDESC, uintptr(unsafe.Pointer(value)))
|
||||||
|
runtime.KeepAlive(value)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlHIDGetRawInfo(fd int) (*HIDRawDevInfo, error) {
|
||||||
|
var value HIDRawDevInfo
|
||||||
|
err := ioctl(fd, HIDIOCGRAWINFO, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlHIDGetRawName(fd int) (string, error) {
|
||||||
|
var value [_HIDIOCGRAWNAME_LEN]byte
|
||||||
|
err := ioctl(fd, _HIDIOCGRAWNAME, uintptr(unsafe.Pointer(&value[0])))
|
||||||
|
return ByteSliceToString(value[:]), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlHIDGetRawPhys(fd int) (string, error) {
|
||||||
|
var value [_HIDIOCGRAWPHYS_LEN]byte
|
||||||
|
err := ioctl(fd, _HIDIOCGRAWPHYS, uintptr(unsafe.Pointer(&value[0])))
|
||||||
|
return ByteSliceToString(value[:]), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlHIDGetRawUniq(fd int) (string, error) {
|
||||||
|
var value [_HIDIOCGRAWUNIQ_LEN]byte
|
||||||
|
err := ioctl(fd, _HIDIOCGRAWUNIQ, uintptr(unsafe.Pointer(&value[0])))
|
||||||
|
return ByteSliceToString(value[:]), err
|
||||||
|
}
|
||||||
|
|
@ -405,10 +405,11 @@ includes_SunOS='
|
||||||
#include <net/if_arp.h>
|
#include <net/if_arp.h>
|
||||||
#include <net/if_types.h>
|
#include <net/if_types.h>
|
||||||
#include <net/route.h>
|
#include <net/route.h>
|
||||||
|
#include <netinet/icmp6.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <termios.h>
|
|
||||||
#include <netinet/ip.h>
|
#include <netinet/ip.h>
|
||||||
#include <netinet/ip_mroute.h>
|
#include <netinet/ip_mroute.h>
|
||||||
|
#include <termios.h>
|
||||||
'
|
'
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -499,10 +500,10 @@ ccflags="$@"
|
||||||
$2 ~ /^LOCK_(SH|EX|NB|UN)$/ ||
|
$2 ~ /^LOCK_(SH|EX|NB|UN)$/ ||
|
||||||
$2 ~ /^LO_(KEY|NAME)_SIZE$/ ||
|
$2 ~ /^LO_(KEY|NAME)_SIZE$/ ||
|
||||||
$2 ~ /^LOOP_(CLR|CTL|GET|SET)_/ ||
|
$2 ~ /^LOOP_(CLR|CTL|GET|SET)_/ ||
|
||||||
$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|MCAST|EVFILT|NOTE|SHUT|PROT|MAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR|LOCAL)_/ ||
|
$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|TCP|MCAST|EVFILT|NOTE|SHUT|PROT|MAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR|LOCAL)_/ ||
|
||||||
$2 ~ /^TP_STATUS_/ ||
|
$2 ~ /^TP_STATUS_/ ||
|
||||||
$2 ~ /^FALLOC_/ ||
|
$2 ~ /^FALLOC_/ ||
|
||||||
$2 ~ /^ICMP(V6)?_FILTER$/ ||
|
$2 ~ /^ICMPV?6?_(FILTER|SEC)/ ||
|
||||||
$2 == "SOMAXCONN" ||
|
$2 == "SOMAXCONN" ||
|
||||||
$2 == "NAME_MAX" ||
|
$2 == "NAME_MAX" ||
|
||||||
$2 == "IFNAMSIZ" ||
|
$2 == "IFNAMSIZ" ||
|
||||||
|
|
|
||||||
|
|
@ -378,6 +378,17 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) {
|
||||||
|
var value IPMreqn
|
||||||
|
vallen := _Socklen(SizeofIPMreqn)
|
||||||
|
errno := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
|
||||||
|
return &value, errno
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) {
|
||||||
|
return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq))
|
||||||
|
}
|
||||||
|
|
||||||
// GetsockoptXucred is a getsockopt wrapper that returns an Xucred struct.
|
// GetsockoptXucred is a getsockopt wrapper that returns an Xucred struct.
|
||||||
// The usual level and opt are SOL_LOCAL and LOCAL_PEERCRED, respectively.
|
// The usual level and opt are SOL_LOCAL and LOCAL_PEERCRED, respectively.
|
||||||
func GetsockoptXucred(fd, level, opt int) (*Xucred, error) {
|
func GetsockoptXucred(fd, level, opt int) (*Xucred, error) {
|
||||||
|
|
|
||||||
|
|
@ -70,167 +70,7 @@ func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
|
||||||
|
|
||||||
// ioctl itself should not be exposed directly, but additional get/set
|
// ioctl itself should not be exposed directly, but additional get/set
|
||||||
// functions for specific types are permissible.
|
// functions for specific types are permissible.
|
||||||
|
// These are defined in ioctl.go and ioctl_linux.go.
|
||||||
// IoctlRetInt performs an ioctl operation specified by req on a device
|
|
||||||
// associated with opened file descriptor fd, and returns a non-negative
|
|
||||||
// integer that is returned by the ioctl syscall.
|
|
||||||
func IoctlRetInt(fd int, req uint) (int, error) {
|
|
||||||
ret, _, err := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), 0)
|
|
||||||
if err != 0 {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
return int(ret), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func IoctlSetRTCTime(fd int, value *RTCTime) error {
|
|
||||||
err := ioctl(fd, RTC_SET_TIME, uintptr(unsafe.Pointer(value)))
|
|
||||||
runtime.KeepAlive(value)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func IoctlSetRTCWkAlrm(fd int, value *RTCWkAlrm) error {
|
|
||||||
err := ioctl(fd, RTC_WKALM_SET, uintptr(unsafe.Pointer(value)))
|
|
||||||
runtime.KeepAlive(value)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func IoctlGetUint32(fd int, req uint) (uint32, error) {
|
|
||||||
var value uint32
|
|
||||||
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
|
||||||
return value, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func IoctlGetRTCTime(fd int) (*RTCTime, error) {
|
|
||||||
var value RTCTime
|
|
||||||
err := ioctl(fd, RTC_RD_TIME, uintptr(unsafe.Pointer(&value)))
|
|
||||||
return &value, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// IoctlGetWatchdogInfo fetches information about a watchdog device from the
|
|
||||||
// Linux watchdog API. For more information, see:
|
|
||||||
// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
|
|
||||||
func IoctlGetWatchdogInfo(fd int) (*WatchdogInfo, error) {
|
|
||||||
var value WatchdogInfo
|
|
||||||
err := ioctl(fd, WDIOC_GETSUPPORT, uintptr(unsafe.Pointer(&value)))
|
|
||||||
return &value, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func IoctlGetRTCWkAlrm(fd int) (*RTCWkAlrm, error) {
|
|
||||||
var value RTCWkAlrm
|
|
||||||
err := ioctl(fd, RTC_WKALM_RD, uintptr(unsafe.Pointer(&value)))
|
|
||||||
return &value, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// IoctlFileCloneRange performs an FICLONERANGE ioctl operation to clone the
|
|
||||||
// range of data conveyed in value to the file associated with the file
|
|
||||||
// descriptor destFd. See the ioctl_ficlonerange(2) man page for details.
|
|
||||||
func IoctlFileCloneRange(destFd int, value *FileCloneRange) error {
|
|
||||||
err := ioctl(destFd, FICLONERANGE, uintptr(unsafe.Pointer(value)))
|
|
||||||
runtime.KeepAlive(value)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// IoctlFileClone performs an FICLONE ioctl operation to clone the entire file
|
|
||||||
// associated with the file description srcFd to the file associated with the
|
|
||||||
// file descriptor destFd. See the ioctl_ficlone(2) man page for details.
|
|
||||||
func IoctlFileClone(destFd, srcFd int) error {
|
|
||||||
return ioctl(destFd, FICLONE, uintptr(srcFd))
|
|
||||||
}
|
|
||||||
|
|
||||||
type FileDedupeRange struct {
|
|
||||||
Src_offset uint64
|
|
||||||
Src_length uint64
|
|
||||||
Reserved1 uint16
|
|
||||||
Reserved2 uint32
|
|
||||||
Info []FileDedupeRangeInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
type FileDedupeRangeInfo struct {
|
|
||||||
Dest_fd int64
|
|
||||||
Dest_offset uint64
|
|
||||||
Bytes_deduped uint64
|
|
||||||
Status int32
|
|
||||||
Reserved uint32
|
|
||||||
}
|
|
||||||
|
|
||||||
// IoctlFileDedupeRange performs an FIDEDUPERANGE ioctl operation to share the
|
|
||||||
// range of data conveyed in value from the file associated with the file
|
|
||||||
// descriptor srcFd to the value.Info destinations. See the
|
|
||||||
// ioctl_fideduperange(2) man page for details.
|
|
||||||
func IoctlFileDedupeRange(srcFd int, value *FileDedupeRange) error {
|
|
||||||
buf := make([]byte, SizeofRawFileDedupeRange+
|
|
||||||
len(value.Info)*SizeofRawFileDedupeRangeInfo)
|
|
||||||
rawrange := (*RawFileDedupeRange)(unsafe.Pointer(&buf[0]))
|
|
||||||
rawrange.Src_offset = value.Src_offset
|
|
||||||
rawrange.Src_length = value.Src_length
|
|
||||||
rawrange.Dest_count = uint16(len(value.Info))
|
|
||||||
rawrange.Reserved1 = value.Reserved1
|
|
||||||
rawrange.Reserved2 = value.Reserved2
|
|
||||||
|
|
||||||
for i := range value.Info {
|
|
||||||
rawinfo := (*RawFileDedupeRangeInfo)(unsafe.Pointer(
|
|
||||||
uintptr(unsafe.Pointer(&buf[0])) + uintptr(SizeofRawFileDedupeRange) +
|
|
||||||
uintptr(i*SizeofRawFileDedupeRangeInfo)))
|
|
||||||
rawinfo.Dest_fd = value.Info[i].Dest_fd
|
|
||||||
rawinfo.Dest_offset = value.Info[i].Dest_offset
|
|
||||||
rawinfo.Bytes_deduped = value.Info[i].Bytes_deduped
|
|
||||||
rawinfo.Status = value.Info[i].Status
|
|
||||||
rawinfo.Reserved = value.Info[i].Reserved
|
|
||||||
}
|
|
||||||
|
|
||||||
err := ioctl(srcFd, FIDEDUPERANGE, uintptr(unsafe.Pointer(&buf[0])))
|
|
||||||
|
|
||||||
// Output
|
|
||||||
for i := range value.Info {
|
|
||||||
rawinfo := (*RawFileDedupeRangeInfo)(unsafe.Pointer(
|
|
||||||
uintptr(unsafe.Pointer(&buf[0])) + uintptr(SizeofRawFileDedupeRange) +
|
|
||||||
uintptr(i*SizeofRawFileDedupeRangeInfo)))
|
|
||||||
value.Info[i].Dest_fd = rawinfo.Dest_fd
|
|
||||||
value.Info[i].Dest_offset = rawinfo.Dest_offset
|
|
||||||
value.Info[i].Bytes_deduped = rawinfo.Bytes_deduped
|
|
||||||
value.Info[i].Status = rawinfo.Status
|
|
||||||
value.Info[i].Reserved = rawinfo.Reserved
|
|
||||||
}
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// IoctlWatchdogKeepalive issues a keepalive ioctl to a watchdog device. For
|
|
||||||
// more information, see:
|
|
||||||
// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
|
|
||||||
func IoctlWatchdogKeepalive(fd int) error {
|
|
||||||
return ioctl(fd, WDIOC_KEEPALIVE, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func IoctlHIDGetDesc(fd int, value *HIDRawReportDescriptor) error {
|
|
||||||
err := ioctl(fd, HIDIOCGRDESC, uintptr(unsafe.Pointer(value)))
|
|
||||||
runtime.KeepAlive(value)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func IoctlHIDGetRawInfo(fd int) (*HIDRawDevInfo, error) {
|
|
||||||
var value HIDRawDevInfo
|
|
||||||
err := ioctl(fd, HIDIOCGRAWINFO, uintptr(unsafe.Pointer(&value)))
|
|
||||||
return &value, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func IoctlHIDGetRawName(fd int) (string, error) {
|
|
||||||
var value [_HIDIOCGRAWNAME_LEN]byte
|
|
||||||
err := ioctl(fd, _HIDIOCGRAWNAME, uintptr(unsafe.Pointer(&value[0])))
|
|
||||||
return ByteSliceToString(value[:]), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func IoctlHIDGetRawPhys(fd int) (string, error) {
|
|
||||||
var value [_HIDIOCGRAWPHYS_LEN]byte
|
|
||||||
err := ioctl(fd, _HIDIOCGRAWPHYS, uintptr(unsafe.Pointer(&value[0])))
|
|
||||||
return ByteSliceToString(value[:]), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func IoctlHIDGetRawUniq(fd int) (string, error) {
|
|
||||||
var value [_HIDIOCGRAWUNIQ_LEN]byte
|
|
||||||
err := ioctl(fd, _HIDIOCGRAWUNIQ, uintptr(unsafe.Pointer(&value[0])))
|
|
||||||
return ByteSliceToString(value[:]), err
|
|
||||||
}
|
|
||||||
|
|
||||||
//sys Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error)
|
//sys Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error)
|
||||||
|
|
||||||
|
|
@ -857,9 +697,11 @@ type SockaddrVM struct {
|
||||||
// CID and Port specify a context ID and port address for a VM socket.
|
// CID and Port specify a context ID and port address for a VM socket.
|
||||||
// Guests have a unique CID, and hosts may have a well-known CID of:
|
// Guests have a unique CID, and hosts may have a well-known CID of:
|
||||||
// - VMADDR_CID_HYPERVISOR: refers to the hypervisor process.
|
// - VMADDR_CID_HYPERVISOR: refers to the hypervisor process.
|
||||||
|
// - VMADDR_CID_LOCAL: refers to local communication (loopback).
|
||||||
// - VMADDR_CID_HOST: refers to other processes on the host.
|
// - VMADDR_CID_HOST: refers to other processes on the host.
|
||||||
CID uint32
|
CID uint32
|
||||||
Port uint32
|
Port uint32
|
||||||
|
Flags uint8
|
||||||
raw RawSockaddrVM
|
raw RawSockaddrVM
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -867,6 +709,7 @@ func (sa *SockaddrVM) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||||
sa.raw.Family = AF_VSOCK
|
sa.raw.Family = AF_VSOCK
|
||||||
sa.raw.Port = sa.Port
|
sa.raw.Port = sa.Port
|
||||||
sa.raw.Cid = sa.CID
|
sa.raw.Cid = sa.CID
|
||||||
|
sa.raw.Flags = sa.Flags
|
||||||
|
|
||||||
return unsafe.Pointer(&sa.raw), SizeofSockaddrVM, nil
|
return unsafe.Pointer(&sa.raw), SizeofSockaddrVM, nil
|
||||||
}
|
}
|
||||||
|
|
@ -1173,6 +1016,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
|
||||||
sa := &SockaddrVM{
|
sa := &SockaddrVM{
|
||||||
CID: pp.Cid,
|
CID: pp.Cid,
|
||||||
Port: pp.Port,
|
Port: pp.Port,
|
||||||
|
Flags: pp.Flags,
|
||||||
}
|
}
|
||||||
return sa, nil
|
return sa, nil
|
||||||
case AF_BLUETOOTH:
|
case AF_BLUETOOTH:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,272 @@
|
||||||
|
// Copyright 2021 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build linux && ppc
|
||||||
|
// +build linux
|
||||||
|
// +build ppc
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
//sys dup2(oldfd int, newfd int) (err error)
|
||||||
|
//sysnb EpollCreate(size int) (fd int, err error)
|
||||||
|
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
|
||||||
|
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||||
|
//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
|
||||||
|
//sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64
|
||||||
|
//sys Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64
|
||||||
|
//sysnb Getegid() (egid int)
|
||||||
|
//sysnb Geteuid() (euid int)
|
||||||
|
//sysnb Getgid() (gid int)
|
||||||
|
//sysnb Getuid() (uid int)
|
||||||
|
//sysnb InotifyInit() (fd int, err error)
|
||||||
|
//sys Ioperm(from int, num int, on int) (err error)
|
||||||
|
//sys Iopl(level int) (err error)
|
||||||
|
//sys Lchown(path string, uid int, gid int) (err error)
|
||||||
|
//sys Listen(s int, n int) (err error)
|
||||||
|
//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
|
||||||
|
//sys Pause() (err error)
|
||||||
|
//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
|
||||||
|
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
|
||||||
|
//sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
|
||||||
|
//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT
|
||||||
|
//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64
|
||||||
|
//sys setfsgid(gid int) (prev int, err error)
|
||||||
|
//sys setfsuid(uid int) (prev int, err error)
|
||||||
|
//sysnb Setregid(rgid int, egid int) (err error)
|
||||||
|
//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
|
||||||
|
//sysnb Setresuid(ruid int, euid int, suid int) (err error)
|
||||||
|
//sysnb Setreuid(ruid int, euid int) (err error)
|
||||||
|
//sys Shutdown(fd int, how int) (err error)
|
||||||
|
//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error)
|
||||||
|
//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
|
||||||
|
//sys Truncate(path string, length int64) (err error) = SYS_TRUNCATE64
|
||||||
|
//sys Ustat(dev int, ubuf *Ustat_t) (err error)
|
||||||
|
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
|
||||||
|
//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
|
||||||
|
//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
|
||||||
|
//sysnb setgroups(n int, list *_Gid_t) (err error)
|
||||||
|
//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
|
||||||
|
//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
|
||||||
|
//sysnb socket(domain int, typ int, proto int) (fd int, err error)
|
||||||
|
//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
|
||||||
|
//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||||
|
//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||||
|
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
|
||||||
|
//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||||
|
//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||||
|
|
||||||
|
//sys futimesat(dirfd int, path string, times *[2]Timeval) (err error)
|
||||||
|
//sysnb Gettimeofday(tv *Timeval) (err error)
|
||||||
|
//sysnb Time(t *Time_t) (tt Time_t, err error)
|
||||||
|
//sys Utime(path string, buf *Utimbuf) (err error)
|
||||||
|
//sys utimes(path string, times *[2]Timeval) (err error)
|
||||||
|
|
||||||
|
func Fadvise(fd int, offset int64, length int64, advice int) (err error) {
|
||||||
|
_, _, e1 := Syscall6(SYS_FADVISE64_64, uintptr(fd), uintptr(advice), uintptr(offset>>32), uintptr(offset), uintptr(length>>32), uintptr(length))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func seek(fd int, offset int64, whence int) (int64, syscall.Errno) {
|
||||||
|
var newoffset int64
|
||||||
|
offsetLow := uint32(offset & 0xffffffff)
|
||||||
|
offsetHigh := uint32((offset >> 32) & 0xffffffff)
|
||||||
|
_, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0)
|
||||||
|
return newoffset, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
|
||||||
|
newoffset, errno := seek(fd, offset, whence)
|
||||||
|
if errno != 0 {
|
||||||
|
return 0, errno
|
||||||
|
}
|
||||||
|
return newoffset, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Fstatfs(fd int, buf *Statfs_t) (err error) {
|
||||||
|
_, _, e := Syscall(SYS_FSTATFS64, uintptr(fd), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
|
||||||
|
if e != 0 {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Statfs(path string, buf *Statfs_t) (err error) {
|
||||||
|
pathp, err := BytePtrFromString(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, _, e := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(pathp)), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
|
||||||
|
if e != 0 {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error)
|
||||||
|
|
||||||
|
func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
|
||||||
|
page := uintptr(offset / 4096)
|
||||||
|
if offset != int64(page)*4096 {
|
||||||
|
return 0, EINVAL
|
||||||
|
}
|
||||||
|
return mmap2(addr, length, prot, flags, fd, page)
|
||||||
|
}
|
||||||
|
|
||||||
|
func setTimespec(sec, nsec int64) Timespec {
|
||||||
|
return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func setTimeval(sec, usec int64) Timeval {
|
||||||
|
return Timeval{Sec: int32(sec), Usec: int32(usec)}
|
||||||
|
}
|
||||||
|
|
||||||
|
type rlimit32 struct {
|
||||||
|
Cur uint32
|
||||||
|
Max uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb getrlimit(resource int, rlim *rlimit32) (err error) = SYS_UGETRLIMIT
|
||||||
|
|
||||||
|
const rlimInf32 = ^uint32(0)
|
||||||
|
const rlimInf64 = ^uint64(0)
|
||||||
|
|
||||||
|
func Getrlimit(resource int, rlim *Rlimit) (err error) {
|
||||||
|
err = prlimit(0, resource, nil, rlim)
|
||||||
|
if err != ENOSYS {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
rl := rlimit32{}
|
||||||
|
err = getrlimit(resource, &rl)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if rl.Cur == rlimInf32 {
|
||||||
|
rlim.Cur = rlimInf64
|
||||||
|
} else {
|
||||||
|
rlim.Cur = uint64(rl.Cur)
|
||||||
|
}
|
||||||
|
|
||||||
|
if rl.Max == rlimInf32 {
|
||||||
|
rlim.Max = rlimInf64
|
||||||
|
} else {
|
||||||
|
rlim.Max = uint64(rl.Max)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT
|
||||||
|
|
||||||
|
func Setrlimit(resource int, rlim *Rlimit) (err error) {
|
||||||
|
err = prlimit(0, resource, rlim, nil)
|
||||||
|
if err != ENOSYS {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
rl := rlimit32{}
|
||||||
|
if rlim.Cur == rlimInf64 {
|
||||||
|
rl.Cur = rlimInf32
|
||||||
|
} else if rlim.Cur < uint64(rlimInf32) {
|
||||||
|
rl.Cur = uint32(rlim.Cur)
|
||||||
|
} else {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
if rlim.Max == rlimInf64 {
|
||||||
|
rl.Max = rlimInf32
|
||||||
|
} else if rlim.Max < uint64(rlimInf32) {
|
||||||
|
rl.Max = uint32(rlim.Max)
|
||||||
|
} else {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
return setrlimit(resource, &rl)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *PtraceRegs) PC() uint32 { return r.Nip }
|
||||||
|
|
||||||
|
func (r *PtraceRegs) SetPC(pc uint32) { r.Nip = pc }
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetIovlen(length int) {
|
||||||
|
msghdr.Iovlen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb pipe(p *[2]_C_int) (err error)
|
||||||
|
|
||||||
|
func Pipe(p []int) (err error) {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
var pp [2]_C_int
|
||||||
|
err = pipe(&pp)
|
||||||
|
p[0] = int(pp[0])
|
||||||
|
p[1] = int(pp[1])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb pipe2(p *[2]_C_int, flags int) (err error)
|
||||||
|
|
||||||
|
func Pipe2(p []int, flags int) (err error) {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
var pp [2]_C_int
|
||||||
|
err = pipe2(&pp, flags)
|
||||||
|
p[0] = int(pp[0])
|
||||||
|
p[1] = int(pp[1])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
|
||||||
|
|
||||||
|
func Poll(fds []PollFd, timeout int) (n int, err error) {
|
||||||
|
if len(fds) == 0 {
|
||||||
|
return poll(nil, 0, timeout)
|
||||||
|
}
|
||||||
|
return poll(&fds[0], len(fds), timeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys syncFileRange2(fd int, flags int, off int64, n int64) (err error) = SYS_SYNC_FILE_RANGE2
|
||||||
|
|
||||||
|
func SyncFileRange(fd int, off int64, n int64, flags int) error {
|
||||||
|
// The sync_file_range and sync_file_range2 syscalls differ only in the
|
||||||
|
// order of their arguments.
|
||||||
|
return syncFileRange2(fd, flags, off, n)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error)
|
||||||
|
|
||||||
|
func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error {
|
||||||
|
cmdlineLen := len(cmdline)
|
||||||
|
if cmdlineLen > 0 {
|
||||||
|
// Account for the additional NULL byte added by
|
||||||
|
// BytePtrFromString in kexecFileLoad. The kexec_file_load
|
||||||
|
// syscall expects a NULL-terminated string.
|
||||||
|
cmdlineLen++
|
||||||
|
}
|
||||||
|
return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
|
||||||
|
}
|
||||||
|
|
@ -1022,6 +1022,15 @@ const (
|
||||||
MAP_RESERVED0100 = 0x100
|
MAP_RESERVED0100 = 0x100
|
||||||
MAP_SHARED = 0x1
|
MAP_SHARED = 0x1
|
||||||
MAP_STACK = 0x400
|
MAP_STACK = 0x400
|
||||||
|
MCAST_BLOCK_SOURCE = 0x54
|
||||||
|
MCAST_EXCLUDE = 0x2
|
||||||
|
MCAST_INCLUDE = 0x1
|
||||||
|
MCAST_JOIN_GROUP = 0x50
|
||||||
|
MCAST_JOIN_SOURCE_GROUP = 0x52
|
||||||
|
MCAST_LEAVE_GROUP = 0x51
|
||||||
|
MCAST_LEAVE_SOURCE_GROUP = 0x53
|
||||||
|
MCAST_UNBLOCK_SOURCE = 0x55
|
||||||
|
MCAST_UNDEFINED = 0x0
|
||||||
MCL_CURRENT = 0x1
|
MCL_CURRENT = 0x1
|
||||||
MCL_FUTURE = 0x2
|
MCL_FUTURE = 0x2
|
||||||
MNT_ACLS = 0x8000000
|
MNT_ACLS = 0x8000000
|
||||||
|
|
|
||||||
|
|
@ -974,6 +974,10 @@ const (
|
||||||
HUGETLBFS_MAGIC = 0x958458f6
|
HUGETLBFS_MAGIC = 0x958458f6
|
||||||
IBSHIFT = 0x10
|
IBSHIFT = 0x10
|
||||||
ICMPV6_FILTER = 0x1
|
ICMPV6_FILTER = 0x1
|
||||||
|
ICMPV6_FILTER_BLOCK = 0x1
|
||||||
|
ICMPV6_FILTER_BLOCKOTHERS = 0x3
|
||||||
|
ICMPV6_FILTER_PASS = 0x2
|
||||||
|
ICMPV6_FILTER_PASSONLY = 0x4
|
||||||
ICMP_FILTER = 0x1
|
ICMP_FILTER = 0x1
|
||||||
ICRNL = 0x100
|
ICRNL = 0x100
|
||||||
IFA_F_DADFAILED = 0x8
|
IFA_F_DADFAILED = 0x8
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,860 @@
|
||||||
|
// mkerrors.sh -Wall -Werror -static -I/tmp/include
|
||||||
|
// Code generated by the command above; see README.md. DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:build ppc && linux
|
||||||
|
// +build ppc,linux
|
||||||
|
|
||||||
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
|
// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/_const.go
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
const (
|
||||||
|
B1000000 = 0x17
|
||||||
|
B115200 = 0x11
|
||||||
|
B1152000 = 0x18
|
||||||
|
B1500000 = 0x19
|
||||||
|
B2000000 = 0x1a
|
||||||
|
B230400 = 0x12
|
||||||
|
B2500000 = 0x1b
|
||||||
|
B3000000 = 0x1c
|
||||||
|
B3500000 = 0x1d
|
||||||
|
B4000000 = 0x1e
|
||||||
|
B460800 = 0x13
|
||||||
|
B500000 = 0x14
|
||||||
|
B57600 = 0x10
|
||||||
|
B576000 = 0x15
|
||||||
|
B921600 = 0x16
|
||||||
|
BLKBSZGET = 0x40041270
|
||||||
|
BLKBSZSET = 0x80041271
|
||||||
|
BLKFLSBUF = 0x20001261
|
||||||
|
BLKFRAGET = 0x20001265
|
||||||
|
BLKFRASET = 0x20001264
|
||||||
|
BLKGETSIZE = 0x20001260
|
||||||
|
BLKGETSIZE64 = 0x40041272
|
||||||
|
BLKPBSZGET = 0x2000127b
|
||||||
|
BLKRAGET = 0x20001263
|
||||||
|
BLKRASET = 0x20001262
|
||||||
|
BLKROGET = 0x2000125e
|
||||||
|
BLKROSET = 0x2000125d
|
||||||
|
BLKRRPART = 0x2000125f
|
||||||
|
BLKSECTGET = 0x20001267
|
||||||
|
BLKSECTSET = 0x20001266
|
||||||
|
BLKSSZGET = 0x20001268
|
||||||
|
BOTHER = 0x1f
|
||||||
|
BS1 = 0x8000
|
||||||
|
BSDLY = 0x8000
|
||||||
|
CBAUD = 0xff
|
||||||
|
CBAUDEX = 0x0
|
||||||
|
CIBAUD = 0xff0000
|
||||||
|
CLOCAL = 0x8000
|
||||||
|
CR1 = 0x1000
|
||||||
|
CR2 = 0x2000
|
||||||
|
CR3 = 0x3000
|
||||||
|
CRDLY = 0x3000
|
||||||
|
CREAD = 0x800
|
||||||
|
CS6 = 0x100
|
||||||
|
CS7 = 0x200
|
||||||
|
CS8 = 0x300
|
||||||
|
CSIZE = 0x300
|
||||||
|
CSTOPB = 0x400
|
||||||
|
ECHOCTL = 0x40
|
||||||
|
ECHOE = 0x2
|
||||||
|
ECHOK = 0x4
|
||||||
|
ECHOKE = 0x1
|
||||||
|
ECHONL = 0x10
|
||||||
|
ECHOPRT = 0x20
|
||||||
|
EFD_CLOEXEC = 0x80000
|
||||||
|
EFD_NONBLOCK = 0x800
|
||||||
|
EPOLL_CLOEXEC = 0x80000
|
||||||
|
EXTPROC = 0x10000000
|
||||||
|
FF1 = 0x4000
|
||||||
|
FFDLY = 0x4000
|
||||||
|
FICLONE = 0x80049409
|
||||||
|
FICLONERANGE = 0x8020940d
|
||||||
|
FLUSHO = 0x800000
|
||||||
|
FS_IOC_ENABLE_VERITY = 0x80806685
|
||||||
|
FS_IOC_GETFLAGS = 0x40046601
|
||||||
|
FS_IOC_GET_ENCRYPTION_NONCE = 0x4010661b
|
||||||
|
FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615
|
||||||
|
FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614
|
||||||
|
FS_IOC_SETFLAGS = 0x80046602
|
||||||
|
FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613
|
||||||
|
F_GETLK = 0xc
|
||||||
|
F_GETLK64 = 0xc
|
||||||
|
F_GETOWN = 0x9
|
||||||
|
F_RDLCK = 0x0
|
||||||
|
F_SETLK = 0xd
|
||||||
|
F_SETLK64 = 0xd
|
||||||
|
F_SETLKW = 0xe
|
||||||
|
F_SETLKW64 = 0xe
|
||||||
|
F_SETOWN = 0x8
|
||||||
|
F_UNLCK = 0x2
|
||||||
|
F_WRLCK = 0x1
|
||||||
|
HIDIOCGRAWINFO = 0x40084803
|
||||||
|
HIDIOCGRDESC = 0x50044802
|
||||||
|
HIDIOCGRDESCSIZE = 0x40044801
|
||||||
|
HUPCL = 0x4000
|
||||||
|
ICANON = 0x100
|
||||||
|
IEXTEN = 0x400
|
||||||
|
IN_CLOEXEC = 0x80000
|
||||||
|
IN_NONBLOCK = 0x800
|
||||||
|
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
|
||||||
|
ISIG = 0x80
|
||||||
|
IUCLC = 0x1000
|
||||||
|
IXOFF = 0x400
|
||||||
|
IXON = 0x200
|
||||||
|
MAP_ANON = 0x20
|
||||||
|
MAP_ANONYMOUS = 0x20
|
||||||
|
MAP_DENYWRITE = 0x800
|
||||||
|
MAP_EXECUTABLE = 0x1000
|
||||||
|
MAP_GROWSDOWN = 0x100
|
||||||
|
MAP_HUGETLB = 0x40000
|
||||||
|
MAP_LOCKED = 0x80
|
||||||
|
MAP_NONBLOCK = 0x10000
|
||||||
|
MAP_NORESERVE = 0x40
|
||||||
|
MAP_POPULATE = 0x8000
|
||||||
|
MAP_STACK = 0x20000
|
||||||
|
MAP_SYNC = 0x80000
|
||||||
|
MCL_CURRENT = 0x2000
|
||||||
|
MCL_FUTURE = 0x4000
|
||||||
|
MCL_ONFAULT = 0x8000
|
||||||
|
NFDBITS = 0x20
|
||||||
|
NL2 = 0x200
|
||||||
|
NL3 = 0x300
|
||||||
|
NLDLY = 0x300
|
||||||
|
NOFLSH = 0x80000000
|
||||||
|
NS_GET_NSTYPE = 0x2000b703
|
||||||
|
NS_GET_OWNER_UID = 0x2000b704
|
||||||
|
NS_GET_PARENT = 0x2000b702
|
||||||
|
NS_GET_USERNS = 0x2000b701
|
||||||
|
OLCUC = 0x4
|
||||||
|
ONLCR = 0x2
|
||||||
|
O_APPEND = 0x400
|
||||||
|
O_ASYNC = 0x2000
|
||||||
|
O_CLOEXEC = 0x80000
|
||||||
|
O_CREAT = 0x40
|
||||||
|
O_DIRECT = 0x20000
|
||||||
|
O_DIRECTORY = 0x4000
|
||||||
|
O_DSYNC = 0x1000
|
||||||
|
O_EXCL = 0x80
|
||||||
|
O_FSYNC = 0x101000
|
||||||
|
O_LARGEFILE = 0x10000
|
||||||
|
O_NDELAY = 0x800
|
||||||
|
O_NOATIME = 0x40000
|
||||||
|
O_NOCTTY = 0x100
|
||||||
|
O_NOFOLLOW = 0x8000
|
||||||
|
O_NONBLOCK = 0x800
|
||||||
|
O_PATH = 0x200000
|
||||||
|
O_RSYNC = 0x101000
|
||||||
|
O_SYNC = 0x101000
|
||||||
|
O_TMPFILE = 0x404000
|
||||||
|
O_TRUNC = 0x200
|
||||||
|
PARENB = 0x1000
|
||||||
|
PARODD = 0x2000
|
||||||
|
PENDIN = 0x20000000
|
||||||
|
PERF_EVENT_IOC_DISABLE = 0x20002401
|
||||||
|
PERF_EVENT_IOC_ENABLE = 0x20002400
|
||||||
|
PERF_EVENT_IOC_ID = 0x40042407
|
||||||
|
PERF_EVENT_IOC_MODIFY_ATTRIBUTES = 0x8004240b
|
||||||
|
PERF_EVENT_IOC_PAUSE_OUTPUT = 0x80042409
|
||||||
|
PERF_EVENT_IOC_PERIOD = 0x80082404
|
||||||
|
PERF_EVENT_IOC_QUERY_BPF = 0xc004240a
|
||||||
|
PERF_EVENT_IOC_REFRESH = 0x20002402
|
||||||
|
PERF_EVENT_IOC_RESET = 0x20002403
|
||||||
|
PERF_EVENT_IOC_SET_BPF = 0x80042408
|
||||||
|
PERF_EVENT_IOC_SET_FILTER = 0x80042406
|
||||||
|
PERF_EVENT_IOC_SET_OUTPUT = 0x20002405
|
||||||
|
PPPIOCATTACH = 0x8004743d
|
||||||
|
PPPIOCATTCHAN = 0x80047438
|
||||||
|
PPPIOCBRIDGECHAN = 0x80047435
|
||||||
|
PPPIOCCONNECT = 0x8004743a
|
||||||
|
PPPIOCDETACH = 0x8004743c
|
||||||
|
PPPIOCDISCONN = 0x20007439
|
||||||
|
PPPIOCGASYNCMAP = 0x40047458
|
||||||
|
PPPIOCGCHAN = 0x40047437
|
||||||
|
PPPIOCGDEBUG = 0x40047441
|
||||||
|
PPPIOCGFLAGS = 0x4004745a
|
||||||
|
PPPIOCGIDLE = 0x4008743f
|
||||||
|
PPPIOCGIDLE32 = 0x4008743f
|
||||||
|
PPPIOCGIDLE64 = 0x4010743f
|
||||||
|
PPPIOCGL2TPSTATS = 0x40487436
|
||||||
|
PPPIOCGMRU = 0x40047453
|
||||||
|
PPPIOCGRASYNCMAP = 0x40047455
|
||||||
|
PPPIOCGUNIT = 0x40047456
|
||||||
|
PPPIOCGXASYNCMAP = 0x40207450
|
||||||
|
PPPIOCSACTIVE = 0x80087446
|
||||||
|
PPPIOCSASYNCMAP = 0x80047457
|
||||||
|
PPPIOCSCOMPRESS = 0x800c744d
|
||||||
|
PPPIOCSDEBUG = 0x80047440
|
||||||
|
PPPIOCSFLAGS = 0x80047459
|
||||||
|
PPPIOCSMAXCID = 0x80047451
|
||||||
|
PPPIOCSMRRU = 0x8004743b
|
||||||
|
PPPIOCSMRU = 0x80047452
|
||||||
|
PPPIOCSNPMODE = 0x8008744b
|
||||||
|
PPPIOCSPASS = 0x80087447
|
||||||
|
PPPIOCSRASYNCMAP = 0x80047454
|
||||||
|
PPPIOCSXASYNCMAP = 0x8020744f
|
||||||
|
PPPIOCUNBRIDGECHAN = 0x20007434
|
||||||
|
PPPIOCXFERUNIT = 0x2000744e
|
||||||
|
PROT_SAO = 0x10
|
||||||
|
PR_SET_PTRACER_ANY = 0xffffffff
|
||||||
|
PTRACE_GETEVRREGS = 0x14
|
||||||
|
PTRACE_GETFPREGS = 0xe
|
||||||
|
PTRACE_GETREGS64 = 0x16
|
||||||
|
PTRACE_GETVRREGS = 0x12
|
||||||
|
PTRACE_GETVSRREGS = 0x1b
|
||||||
|
PTRACE_GET_DEBUGREG = 0x19
|
||||||
|
PTRACE_SETEVRREGS = 0x15
|
||||||
|
PTRACE_SETFPREGS = 0xf
|
||||||
|
PTRACE_SETREGS64 = 0x17
|
||||||
|
PTRACE_SETVRREGS = 0x13
|
||||||
|
PTRACE_SETVSRREGS = 0x1c
|
||||||
|
PTRACE_SET_DEBUGREG = 0x1a
|
||||||
|
PTRACE_SINGLEBLOCK = 0x100
|
||||||
|
PTRACE_SYSEMU = 0x1d
|
||||||
|
PTRACE_SYSEMU_SINGLESTEP = 0x1e
|
||||||
|
PT_CCR = 0x26
|
||||||
|
PT_CTR = 0x23
|
||||||
|
PT_DAR = 0x29
|
||||||
|
PT_DSCR = 0x2c
|
||||||
|
PT_DSISR = 0x2a
|
||||||
|
PT_FPR0 = 0x30
|
||||||
|
PT_FPR31 = 0x6e
|
||||||
|
PT_FPSCR = 0x71
|
||||||
|
PT_LNK = 0x24
|
||||||
|
PT_MQ = 0x27
|
||||||
|
PT_MSR = 0x21
|
||||||
|
PT_NIP = 0x20
|
||||||
|
PT_ORIG_R3 = 0x22
|
||||||
|
PT_R0 = 0x0
|
||||||
|
PT_R1 = 0x1
|
||||||
|
PT_R10 = 0xa
|
||||||
|
PT_R11 = 0xb
|
||||||
|
PT_R12 = 0xc
|
||||||
|
PT_R13 = 0xd
|
||||||
|
PT_R14 = 0xe
|
||||||
|
PT_R15 = 0xf
|
||||||
|
PT_R16 = 0x10
|
||||||
|
PT_R17 = 0x11
|
||||||
|
PT_R18 = 0x12
|
||||||
|
PT_R19 = 0x13
|
||||||
|
PT_R2 = 0x2
|
||||||
|
PT_R20 = 0x14
|
||||||
|
PT_R21 = 0x15
|
||||||
|
PT_R22 = 0x16
|
||||||
|
PT_R23 = 0x17
|
||||||
|
PT_R24 = 0x18
|
||||||
|
PT_R25 = 0x19
|
||||||
|
PT_R26 = 0x1a
|
||||||
|
PT_R27 = 0x1b
|
||||||
|
PT_R28 = 0x1c
|
||||||
|
PT_R29 = 0x1d
|
||||||
|
PT_R3 = 0x3
|
||||||
|
PT_R30 = 0x1e
|
||||||
|
PT_R31 = 0x1f
|
||||||
|
PT_R4 = 0x4
|
||||||
|
PT_R5 = 0x5
|
||||||
|
PT_R6 = 0x6
|
||||||
|
PT_R7 = 0x7
|
||||||
|
PT_R8 = 0x8
|
||||||
|
PT_R9 = 0x9
|
||||||
|
PT_REGS_COUNT = 0x2c
|
||||||
|
PT_RESULT = 0x2b
|
||||||
|
PT_TRAP = 0x28
|
||||||
|
PT_XER = 0x25
|
||||||
|
RLIMIT_AS = 0x9
|
||||||
|
RLIMIT_MEMLOCK = 0x8
|
||||||
|
RLIMIT_NOFILE = 0x7
|
||||||
|
RLIMIT_NPROC = 0x6
|
||||||
|
RLIMIT_RSS = 0x5
|
||||||
|
RNDADDENTROPY = 0x80085203
|
||||||
|
RNDADDTOENTCNT = 0x80045201
|
||||||
|
RNDCLEARPOOL = 0x20005206
|
||||||
|
RNDGETENTCNT = 0x40045200
|
||||||
|
RNDGETPOOL = 0x40085202
|
||||||
|
RNDRESEEDCRNG = 0x20005207
|
||||||
|
RNDZAPENTCNT = 0x20005204
|
||||||
|
RTC_AIE_OFF = 0x20007002
|
||||||
|
RTC_AIE_ON = 0x20007001
|
||||||
|
RTC_ALM_READ = 0x40247008
|
||||||
|
RTC_ALM_SET = 0x80247007
|
||||||
|
RTC_EPOCH_READ = 0x4004700d
|
||||||
|
RTC_EPOCH_SET = 0x8004700e
|
||||||
|
RTC_IRQP_READ = 0x4004700b
|
||||||
|
RTC_IRQP_SET = 0x8004700c
|
||||||
|
RTC_PIE_OFF = 0x20007006
|
||||||
|
RTC_PIE_ON = 0x20007005
|
||||||
|
RTC_PLL_GET = 0x401c7011
|
||||||
|
RTC_PLL_SET = 0x801c7012
|
||||||
|
RTC_RD_TIME = 0x40247009
|
||||||
|
RTC_SET_TIME = 0x8024700a
|
||||||
|
RTC_UIE_OFF = 0x20007004
|
||||||
|
RTC_UIE_ON = 0x20007003
|
||||||
|
RTC_VL_CLR = 0x20007014
|
||||||
|
RTC_VL_READ = 0x40047013
|
||||||
|
RTC_WIE_OFF = 0x20007010
|
||||||
|
RTC_WIE_ON = 0x2000700f
|
||||||
|
RTC_WKALM_RD = 0x40287010
|
||||||
|
RTC_WKALM_SET = 0x8028700f
|
||||||
|
SCM_TIMESTAMPING = 0x25
|
||||||
|
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
||||||
|
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
||||||
|
SCM_TIMESTAMPNS = 0x23
|
||||||
|
SCM_TXTIME = 0x3d
|
||||||
|
SCM_WIFI_STATUS = 0x29
|
||||||
|
SFD_CLOEXEC = 0x80000
|
||||||
|
SFD_NONBLOCK = 0x800
|
||||||
|
SIOCATMARK = 0x8905
|
||||||
|
SIOCGPGRP = 0x8904
|
||||||
|
SIOCGSTAMPNS_NEW = 0x40108907
|
||||||
|
SIOCGSTAMP_NEW = 0x40108906
|
||||||
|
SIOCINQ = 0x4004667f
|
||||||
|
SIOCOUTQ = 0x40047473
|
||||||
|
SIOCSPGRP = 0x8902
|
||||||
|
SOCK_CLOEXEC = 0x80000
|
||||||
|
SOCK_DGRAM = 0x2
|
||||||
|
SOCK_NONBLOCK = 0x800
|
||||||
|
SOCK_STREAM = 0x1
|
||||||
|
SOL_SOCKET = 0x1
|
||||||
|
SO_ACCEPTCONN = 0x1e
|
||||||
|
SO_ATTACH_BPF = 0x32
|
||||||
|
SO_ATTACH_REUSEPORT_CBPF = 0x33
|
||||||
|
SO_ATTACH_REUSEPORT_EBPF = 0x34
|
||||||
|
SO_BINDTODEVICE = 0x19
|
||||||
|
SO_BINDTOIFINDEX = 0x3e
|
||||||
|
SO_BPF_EXTENSIONS = 0x30
|
||||||
|
SO_BROADCAST = 0x6
|
||||||
|
SO_BSDCOMPAT = 0xe
|
||||||
|
SO_BUSY_POLL = 0x2e
|
||||||
|
SO_BUSY_POLL_BUDGET = 0x46
|
||||||
|
SO_CNX_ADVICE = 0x35
|
||||||
|
SO_COOKIE = 0x39
|
||||||
|
SO_DETACH_REUSEPORT_BPF = 0x44
|
||||||
|
SO_DOMAIN = 0x27
|
||||||
|
SO_DONTROUTE = 0x5
|
||||||
|
SO_ERROR = 0x4
|
||||||
|
SO_INCOMING_CPU = 0x31
|
||||||
|
SO_INCOMING_NAPI_ID = 0x38
|
||||||
|
SO_KEEPALIVE = 0x9
|
||||||
|
SO_LINGER = 0xd
|
||||||
|
SO_LOCK_FILTER = 0x2c
|
||||||
|
SO_MARK = 0x24
|
||||||
|
SO_MAX_PACING_RATE = 0x2f
|
||||||
|
SO_MEMINFO = 0x37
|
||||||
|
SO_NOFCS = 0x2b
|
||||||
|
SO_OOBINLINE = 0xa
|
||||||
|
SO_PASSCRED = 0x14
|
||||||
|
SO_PASSSEC = 0x22
|
||||||
|
SO_PEEK_OFF = 0x2a
|
||||||
|
SO_PEERCRED = 0x15
|
||||||
|
SO_PEERGROUPS = 0x3b
|
||||||
|
SO_PEERSEC = 0x1f
|
||||||
|
SO_PREFER_BUSY_POLL = 0x45
|
||||||
|
SO_PROTOCOL = 0x26
|
||||||
|
SO_RCVBUF = 0x8
|
||||||
|
SO_RCVBUFFORCE = 0x21
|
||||||
|
SO_RCVLOWAT = 0x10
|
||||||
|
SO_RCVTIMEO = 0x12
|
||||||
|
SO_RCVTIMEO_NEW = 0x42
|
||||||
|
SO_RCVTIMEO_OLD = 0x12
|
||||||
|
SO_REUSEADDR = 0x2
|
||||||
|
SO_REUSEPORT = 0xf
|
||||||
|
SO_RXQ_OVFL = 0x28
|
||||||
|
SO_SECURITY_AUTHENTICATION = 0x16
|
||||||
|
SO_SECURITY_ENCRYPTION_NETWORK = 0x18
|
||||||
|
SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17
|
||||||
|
SO_SELECT_ERR_QUEUE = 0x2d
|
||||||
|
SO_SNDBUF = 0x7
|
||||||
|
SO_SNDBUFFORCE = 0x20
|
||||||
|
SO_SNDLOWAT = 0x11
|
||||||
|
SO_SNDTIMEO = 0x13
|
||||||
|
SO_SNDTIMEO_NEW = 0x43
|
||||||
|
SO_SNDTIMEO_OLD = 0x13
|
||||||
|
SO_TIMESTAMPING = 0x25
|
||||||
|
SO_TIMESTAMPING_NEW = 0x41
|
||||||
|
SO_TIMESTAMPING_OLD = 0x25
|
||||||
|
SO_TIMESTAMPNS = 0x23
|
||||||
|
SO_TIMESTAMPNS_NEW = 0x40
|
||||||
|
SO_TIMESTAMPNS_OLD = 0x23
|
||||||
|
SO_TIMESTAMP_NEW = 0x3f
|
||||||
|
SO_TXTIME = 0x3d
|
||||||
|
SO_TYPE = 0x3
|
||||||
|
SO_WIFI_STATUS = 0x29
|
||||||
|
SO_ZEROCOPY = 0x3c
|
||||||
|
TAB1 = 0x400
|
||||||
|
TAB2 = 0x800
|
||||||
|
TAB3 = 0xc00
|
||||||
|
TABDLY = 0xc00
|
||||||
|
TCFLSH = 0x2000741f
|
||||||
|
TCGETA = 0x40147417
|
||||||
|
TCGETS = 0x402c7413
|
||||||
|
TCSAFLUSH = 0x2
|
||||||
|
TCSBRK = 0x2000741d
|
||||||
|
TCSBRKP = 0x5425
|
||||||
|
TCSETA = 0x80147418
|
||||||
|
TCSETAF = 0x8014741c
|
||||||
|
TCSETAW = 0x80147419
|
||||||
|
TCSETS = 0x802c7414
|
||||||
|
TCSETSF = 0x802c7416
|
||||||
|
TCSETSW = 0x802c7415
|
||||||
|
TCXONC = 0x2000741e
|
||||||
|
TFD_CLOEXEC = 0x80000
|
||||||
|
TFD_NONBLOCK = 0x800
|
||||||
|
TIOCCBRK = 0x5428
|
||||||
|
TIOCCONS = 0x541d
|
||||||
|
TIOCEXCL = 0x540c
|
||||||
|
TIOCGDEV = 0x40045432
|
||||||
|
TIOCGETC = 0x40067412
|
||||||
|
TIOCGETD = 0x5424
|
||||||
|
TIOCGETP = 0x40067408
|
||||||
|
TIOCGEXCL = 0x40045440
|
||||||
|
TIOCGICOUNT = 0x545d
|
||||||
|
TIOCGISO7816 = 0x40285442
|
||||||
|
TIOCGLCKTRMIOS = 0x5456
|
||||||
|
TIOCGLTC = 0x40067474
|
||||||
|
TIOCGPGRP = 0x40047477
|
||||||
|
TIOCGPKT = 0x40045438
|
||||||
|
TIOCGPTLCK = 0x40045439
|
||||||
|
TIOCGPTN = 0x40045430
|
||||||
|
TIOCGPTPEER = 0x20005441
|
||||||
|
TIOCGRS485 = 0x542e
|
||||||
|
TIOCGSERIAL = 0x541e
|
||||||
|
TIOCGSID = 0x5429
|
||||||
|
TIOCGSOFTCAR = 0x5419
|
||||||
|
TIOCGWINSZ = 0x40087468
|
||||||
|
TIOCINQ = 0x4004667f
|
||||||
|
TIOCLINUX = 0x541c
|
||||||
|
TIOCMBIC = 0x5417
|
||||||
|
TIOCMBIS = 0x5416
|
||||||
|
TIOCMGET = 0x5415
|
||||||
|
TIOCMIWAIT = 0x545c
|
||||||
|
TIOCMSET = 0x5418
|
||||||
|
TIOCM_CAR = 0x40
|
||||||
|
TIOCM_CD = 0x40
|
||||||
|
TIOCM_CTS = 0x20
|
||||||
|
TIOCM_DSR = 0x100
|
||||||
|
TIOCM_LOOP = 0x8000
|
||||||
|
TIOCM_OUT1 = 0x2000
|
||||||
|
TIOCM_OUT2 = 0x4000
|
||||||
|
TIOCM_RI = 0x80
|
||||||
|
TIOCM_RNG = 0x80
|
||||||
|
TIOCM_SR = 0x10
|
||||||
|
TIOCM_ST = 0x8
|
||||||
|
TIOCNOTTY = 0x5422
|
||||||
|
TIOCNXCL = 0x540d
|
||||||
|
TIOCOUTQ = 0x40047473
|
||||||
|
TIOCPKT = 0x5420
|
||||||
|
TIOCSBRK = 0x5427
|
||||||
|
TIOCSCTTY = 0x540e
|
||||||
|
TIOCSERCONFIG = 0x5453
|
||||||
|
TIOCSERGETLSR = 0x5459
|
||||||
|
TIOCSERGETMULTI = 0x545a
|
||||||
|
TIOCSERGSTRUCT = 0x5458
|
||||||
|
TIOCSERGWILD = 0x5454
|
||||||
|
TIOCSERSETMULTI = 0x545b
|
||||||
|
TIOCSERSWILD = 0x5455
|
||||||
|
TIOCSER_TEMT = 0x1
|
||||||
|
TIOCSETC = 0x80067411
|
||||||
|
TIOCSETD = 0x5423
|
||||||
|
TIOCSETN = 0x8006740a
|
||||||
|
TIOCSETP = 0x80067409
|
||||||
|
TIOCSIG = 0x80045436
|
||||||
|
TIOCSISO7816 = 0xc0285443
|
||||||
|
TIOCSLCKTRMIOS = 0x5457
|
||||||
|
TIOCSLTC = 0x80067475
|
||||||
|
TIOCSPGRP = 0x80047476
|
||||||
|
TIOCSPTLCK = 0x80045431
|
||||||
|
TIOCSRS485 = 0x542f
|
||||||
|
TIOCSSERIAL = 0x541f
|
||||||
|
TIOCSSOFTCAR = 0x541a
|
||||||
|
TIOCSTART = 0x2000746e
|
||||||
|
TIOCSTI = 0x5412
|
||||||
|
TIOCSTOP = 0x2000746f
|
||||||
|
TIOCSWINSZ = 0x80087467
|
||||||
|
TIOCVHANGUP = 0x5437
|
||||||
|
TOSTOP = 0x400000
|
||||||
|
TUNATTACHFILTER = 0x800854d5
|
||||||
|
TUNDETACHFILTER = 0x800854d6
|
||||||
|
TUNGETDEVNETNS = 0x200054e3
|
||||||
|
TUNGETFEATURES = 0x400454cf
|
||||||
|
TUNGETFILTER = 0x400854db
|
||||||
|
TUNGETIFF = 0x400454d2
|
||||||
|
TUNGETSNDBUF = 0x400454d3
|
||||||
|
TUNGETVNETBE = 0x400454df
|
||||||
|
TUNGETVNETHDRSZ = 0x400454d7
|
||||||
|
TUNGETVNETLE = 0x400454dd
|
||||||
|
TUNSETCARRIER = 0x800454e2
|
||||||
|
TUNSETDEBUG = 0x800454c9
|
||||||
|
TUNSETFILTEREBPF = 0x400454e1
|
||||||
|
TUNSETGROUP = 0x800454ce
|
||||||
|
TUNSETIFF = 0x800454ca
|
||||||
|
TUNSETIFINDEX = 0x800454da
|
||||||
|
TUNSETLINK = 0x800454cd
|
||||||
|
TUNSETNOCSUM = 0x800454c8
|
||||||
|
TUNSETOFFLOAD = 0x800454d0
|
||||||
|
TUNSETOWNER = 0x800454cc
|
||||||
|
TUNSETPERSIST = 0x800454cb
|
||||||
|
TUNSETQUEUE = 0x800454d9
|
||||||
|
TUNSETSNDBUF = 0x800454d4
|
||||||
|
TUNSETSTEERINGEBPF = 0x400454e0
|
||||||
|
TUNSETTXFILTER = 0x800454d1
|
||||||
|
TUNSETVNETBE = 0x800454de
|
||||||
|
TUNSETVNETHDRSZ = 0x800454d8
|
||||||
|
TUNSETVNETLE = 0x800454dc
|
||||||
|
UBI_IOCATT = 0x80186f40
|
||||||
|
UBI_IOCDET = 0x80046f41
|
||||||
|
UBI_IOCEBCH = 0x80044f02
|
||||||
|
UBI_IOCEBER = 0x80044f01
|
||||||
|
UBI_IOCEBISMAP = 0x40044f05
|
||||||
|
UBI_IOCEBMAP = 0x80084f03
|
||||||
|
UBI_IOCEBUNMAP = 0x80044f04
|
||||||
|
UBI_IOCMKVOL = 0x80986f00
|
||||||
|
UBI_IOCRMVOL = 0x80046f01
|
||||||
|
UBI_IOCRNVOL = 0x91106f03
|
||||||
|
UBI_IOCRPEB = 0x80046f04
|
||||||
|
UBI_IOCRSVOL = 0x800c6f02
|
||||||
|
UBI_IOCSETVOLPROP = 0x80104f06
|
||||||
|
UBI_IOCSPEB = 0x80046f05
|
||||||
|
UBI_IOCVOLCRBLK = 0x80804f07
|
||||||
|
UBI_IOCVOLRMBLK = 0x20004f08
|
||||||
|
UBI_IOCVOLUP = 0x80084f00
|
||||||
|
VDISCARD = 0x10
|
||||||
|
VEOF = 0x4
|
||||||
|
VEOL = 0x6
|
||||||
|
VEOL2 = 0x8
|
||||||
|
VMIN = 0x5
|
||||||
|
VREPRINT = 0xb
|
||||||
|
VSTART = 0xd
|
||||||
|
VSTOP = 0xe
|
||||||
|
VSUSP = 0xc
|
||||||
|
VSWTC = 0x9
|
||||||
|
VT1 = 0x10000
|
||||||
|
VTDLY = 0x10000
|
||||||
|
VTIME = 0x7
|
||||||
|
VWERASE = 0xa
|
||||||
|
WDIOC_GETBOOTSTATUS = 0x40045702
|
||||||
|
WDIOC_GETPRETIMEOUT = 0x40045709
|
||||||
|
WDIOC_GETSTATUS = 0x40045701
|
||||||
|
WDIOC_GETSUPPORT = 0x40285700
|
||||||
|
WDIOC_GETTEMP = 0x40045703
|
||||||
|
WDIOC_GETTIMELEFT = 0x4004570a
|
||||||
|
WDIOC_GETTIMEOUT = 0x40045707
|
||||||
|
WDIOC_KEEPALIVE = 0x40045705
|
||||||
|
WDIOC_SETOPTIONS = 0x40045704
|
||||||
|
WORDSIZE = 0x20
|
||||||
|
XCASE = 0x4000
|
||||||
|
XTABS = 0xc00
|
||||||
|
_HIDIOCGRAWNAME = 0x40804804
|
||||||
|
_HIDIOCGRAWPHYS = 0x40404805
|
||||||
|
_HIDIOCGRAWUNIQ = 0x40404808
|
||||||
|
)
|
||||||
|
|
||||||
|
// Errors
|
||||||
|
const (
|
||||||
|
EADDRINUSE = syscall.Errno(0x62)
|
||||||
|
EADDRNOTAVAIL = syscall.Errno(0x63)
|
||||||
|
EADV = syscall.Errno(0x44)
|
||||||
|
EAFNOSUPPORT = syscall.Errno(0x61)
|
||||||
|
EALREADY = syscall.Errno(0x72)
|
||||||
|
EBADE = syscall.Errno(0x34)
|
||||||
|
EBADFD = syscall.Errno(0x4d)
|
||||||
|
EBADMSG = syscall.Errno(0x4a)
|
||||||
|
EBADR = syscall.Errno(0x35)
|
||||||
|
EBADRQC = syscall.Errno(0x38)
|
||||||
|
EBADSLT = syscall.Errno(0x39)
|
||||||
|
EBFONT = syscall.Errno(0x3b)
|
||||||
|
ECANCELED = syscall.Errno(0x7d)
|
||||||
|
ECHRNG = syscall.Errno(0x2c)
|
||||||
|
ECOMM = syscall.Errno(0x46)
|
||||||
|
ECONNABORTED = syscall.Errno(0x67)
|
||||||
|
ECONNREFUSED = syscall.Errno(0x6f)
|
||||||
|
ECONNRESET = syscall.Errno(0x68)
|
||||||
|
EDEADLK = syscall.Errno(0x23)
|
||||||
|
EDEADLOCK = syscall.Errno(0x3a)
|
||||||
|
EDESTADDRREQ = syscall.Errno(0x59)
|
||||||
|
EDOTDOT = syscall.Errno(0x49)
|
||||||
|
EDQUOT = syscall.Errno(0x7a)
|
||||||
|
EHOSTDOWN = syscall.Errno(0x70)
|
||||||
|
EHOSTUNREACH = syscall.Errno(0x71)
|
||||||
|
EHWPOISON = syscall.Errno(0x85)
|
||||||
|
EIDRM = syscall.Errno(0x2b)
|
||||||
|
EILSEQ = syscall.Errno(0x54)
|
||||||
|
EINPROGRESS = syscall.Errno(0x73)
|
||||||
|
EISCONN = syscall.Errno(0x6a)
|
||||||
|
EISNAM = syscall.Errno(0x78)
|
||||||
|
EKEYEXPIRED = syscall.Errno(0x7f)
|
||||||
|
EKEYREJECTED = syscall.Errno(0x81)
|
||||||
|
EKEYREVOKED = syscall.Errno(0x80)
|
||||||
|
EL2HLT = syscall.Errno(0x33)
|
||||||
|
EL2NSYNC = syscall.Errno(0x2d)
|
||||||
|
EL3HLT = syscall.Errno(0x2e)
|
||||||
|
EL3RST = syscall.Errno(0x2f)
|
||||||
|
ELIBACC = syscall.Errno(0x4f)
|
||||||
|
ELIBBAD = syscall.Errno(0x50)
|
||||||
|
ELIBEXEC = syscall.Errno(0x53)
|
||||||
|
ELIBMAX = syscall.Errno(0x52)
|
||||||
|
ELIBSCN = syscall.Errno(0x51)
|
||||||
|
ELNRNG = syscall.Errno(0x30)
|
||||||
|
ELOOP = syscall.Errno(0x28)
|
||||||
|
EMEDIUMTYPE = syscall.Errno(0x7c)
|
||||||
|
EMSGSIZE = syscall.Errno(0x5a)
|
||||||
|
EMULTIHOP = syscall.Errno(0x48)
|
||||||
|
ENAMETOOLONG = syscall.Errno(0x24)
|
||||||
|
ENAVAIL = syscall.Errno(0x77)
|
||||||
|
ENETDOWN = syscall.Errno(0x64)
|
||||||
|
ENETRESET = syscall.Errno(0x66)
|
||||||
|
ENETUNREACH = syscall.Errno(0x65)
|
||||||
|
ENOANO = syscall.Errno(0x37)
|
||||||
|
ENOBUFS = syscall.Errno(0x69)
|
||||||
|
ENOCSI = syscall.Errno(0x32)
|
||||||
|
ENODATA = syscall.Errno(0x3d)
|
||||||
|
ENOKEY = syscall.Errno(0x7e)
|
||||||
|
ENOLCK = syscall.Errno(0x25)
|
||||||
|
ENOLINK = syscall.Errno(0x43)
|
||||||
|
ENOMEDIUM = syscall.Errno(0x7b)
|
||||||
|
ENOMSG = syscall.Errno(0x2a)
|
||||||
|
ENONET = syscall.Errno(0x40)
|
||||||
|
ENOPKG = syscall.Errno(0x41)
|
||||||
|
ENOPROTOOPT = syscall.Errno(0x5c)
|
||||||
|
ENOSR = syscall.Errno(0x3f)
|
||||||
|
ENOSTR = syscall.Errno(0x3c)
|
||||||
|
ENOSYS = syscall.Errno(0x26)
|
||||||
|
ENOTCONN = syscall.Errno(0x6b)
|
||||||
|
ENOTEMPTY = syscall.Errno(0x27)
|
||||||
|
ENOTNAM = syscall.Errno(0x76)
|
||||||
|
ENOTRECOVERABLE = syscall.Errno(0x83)
|
||||||
|
ENOTSOCK = syscall.Errno(0x58)
|
||||||
|
ENOTSUP = syscall.Errno(0x5f)
|
||||||
|
ENOTUNIQ = syscall.Errno(0x4c)
|
||||||
|
EOPNOTSUPP = syscall.Errno(0x5f)
|
||||||
|
EOVERFLOW = syscall.Errno(0x4b)
|
||||||
|
EOWNERDEAD = syscall.Errno(0x82)
|
||||||
|
EPFNOSUPPORT = syscall.Errno(0x60)
|
||||||
|
EPROTO = syscall.Errno(0x47)
|
||||||
|
EPROTONOSUPPORT = syscall.Errno(0x5d)
|
||||||
|
EPROTOTYPE = syscall.Errno(0x5b)
|
||||||
|
EREMCHG = syscall.Errno(0x4e)
|
||||||
|
EREMOTE = syscall.Errno(0x42)
|
||||||
|
EREMOTEIO = syscall.Errno(0x79)
|
||||||
|
ERESTART = syscall.Errno(0x55)
|
||||||
|
ERFKILL = syscall.Errno(0x84)
|
||||||
|
ESHUTDOWN = syscall.Errno(0x6c)
|
||||||
|
ESOCKTNOSUPPORT = syscall.Errno(0x5e)
|
||||||
|
ESRMNT = syscall.Errno(0x45)
|
||||||
|
ESTALE = syscall.Errno(0x74)
|
||||||
|
ESTRPIPE = syscall.Errno(0x56)
|
||||||
|
ETIME = syscall.Errno(0x3e)
|
||||||
|
ETIMEDOUT = syscall.Errno(0x6e)
|
||||||
|
ETOOMANYREFS = syscall.Errno(0x6d)
|
||||||
|
EUCLEAN = syscall.Errno(0x75)
|
||||||
|
EUNATCH = syscall.Errno(0x31)
|
||||||
|
EUSERS = syscall.Errno(0x57)
|
||||||
|
EXFULL = syscall.Errno(0x36)
|
||||||
|
)
|
||||||
|
|
||||||
|
// Signals
|
||||||
|
const (
|
||||||
|
SIGBUS = syscall.Signal(0x7)
|
||||||
|
SIGCHLD = syscall.Signal(0x11)
|
||||||
|
SIGCLD = syscall.Signal(0x11)
|
||||||
|
SIGCONT = syscall.Signal(0x12)
|
||||||
|
SIGIO = syscall.Signal(0x1d)
|
||||||
|
SIGPOLL = syscall.Signal(0x1d)
|
||||||
|
SIGPROF = syscall.Signal(0x1b)
|
||||||
|
SIGPWR = syscall.Signal(0x1e)
|
||||||
|
SIGSTKFLT = syscall.Signal(0x10)
|
||||||
|
SIGSTOP = syscall.Signal(0x13)
|
||||||
|
SIGSYS = syscall.Signal(0x1f)
|
||||||
|
SIGTSTP = syscall.Signal(0x14)
|
||||||
|
SIGTTIN = syscall.Signal(0x15)
|
||||||
|
SIGTTOU = syscall.Signal(0x16)
|
||||||
|
SIGURG = syscall.Signal(0x17)
|
||||||
|
SIGUSR1 = syscall.Signal(0xa)
|
||||||
|
SIGUSR2 = syscall.Signal(0xc)
|
||||||
|
SIGVTALRM = syscall.Signal(0x1a)
|
||||||
|
SIGWINCH = syscall.Signal(0x1c)
|
||||||
|
SIGXCPU = syscall.Signal(0x18)
|
||||||
|
SIGXFSZ = syscall.Signal(0x19)
|
||||||
|
)
|
||||||
|
|
||||||
|
// Error table
|
||||||
|
var errorList = [...]struct {
|
||||||
|
num syscall.Errno
|
||||||
|
name string
|
||||||
|
desc string
|
||||||
|
}{
|
||||||
|
{1, "EPERM", "operation not permitted"},
|
||||||
|
{2, "ENOENT", "no such file or directory"},
|
||||||
|
{3, "ESRCH", "no such process"},
|
||||||
|
{4, "EINTR", "interrupted system call"},
|
||||||
|
{5, "EIO", "input/output error"},
|
||||||
|
{6, "ENXIO", "no such device or address"},
|
||||||
|
{7, "E2BIG", "argument list too long"},
|
||||||
|
{8, "ENOEXEC", "exec format error"},
|
||||||
|
{9, "EBADF", "bad file descriptor"},
|
||||||
|
{10, "ECHILD", "no child processes"},
|
||||||
|
{11, "EAGAIN", "resource temporarily unavailable"},
|
||||||
|
{12, "ENOMEM", "cannot allocate memory"},
|
||||||
|
{13, "EACCES", "permission denied"},
|
||||||
|
{14, "EFAULT", "bad address"},
|
||||||
|
{15, "ENOTBLK", "block device required"},
|
||||||
|
{16, "EBUSY", "device or resource busy"},
|
||||||
|
{17, "EEXIST", "file exists"},
|
||||||
|
{18, "EXDEV", "invalid cross-device link"},
|
||||||
|
{19, "ENODEV", "no such device"},
|
||||||
|
{20, "ENOTDIR", "not a directory"},
|
||||||
|
{21, "EISDIR", "is a directory"},
|
||||||
|
{22, "EINVAL", "invalid argument"},
|
||||||
|
{23, "ENFILE", "too many open files in system"},
|
||||||
|
{24, "EMFILE", "too many open files"},
|
||||||
|
{25, "ENOTTY", "inappropriate ioctl for device"},
|
||||||
|
{26, "ETXTBSY", "text file busy"},
|
||||||
|
{27, "EFBIG", "file too large"},
|
||||||
|
{28, "ENOSPC", "no space left on device"},
|
||||||
|
{29, "ESPIPE", "illegal seek"},
|
||||||
|
{30, "EROFS", "read-only file system"},
|
||||||
|
{31, "EMLINK", "too many links"},
|
||||||
|
{32, "EPIPE", "broken pipe"},
|
||||||
|
{33, "EDOM", "numerical argument out of domain"},
|
||||||
|
{34, "ERANGE", "numerical result out of range"},
|
||||||
|
{35, "EDEADLK", "resource deadlock avoided"},
|
||||||
|
{36, "ENAMETOOLONG", "file name too long"},
|
||||||
|
{37, "ENOLCK", "no locks available"},
|
||||||
|
{38, "ENOSYS", "function not implemented"},
|
||||||
|
{39, "ENOTEMPTY", "directory not empty"},
|
||||||
|
{40, "ELOOP", "too many levels of symbolic links"},
|
||||||
|
{42, "ENOMSG", "no message of desired type"},
|
||||||
|
{43, "EIDRM", "identifier removed"},
|
||||||
|
{44, "ECHRNG", "channel number out of range"},
|
||||||
|
{45, "EL2NSYNC", "level 2 not synchronized"},
|
||||||
|
{46, "EL3HLT", "level 3 halted"},
|
||||||
|
{47, "EL3RST", "level 3 reset"},
|
||||||
|
{48, "ELNRNG", "link number out of range"},
|
||||||
|
{49, "EUNATCH", "protocol driver not attached"},
|
||||||
|
{50, "ENOCSI", "no CSI structure available"},
|
||||||
|
{51, "EL2HLT", "level 2 halted"},
|
||||||
|
{52, "EBADE", "invalid exchange"},
|
||||||
|
{53, "EBADR", "invalid request descriptor"},
|
||||||
|
{54, "EXFULL", "exchange full"},
|
||||||
|
{55, "ENOANO", "no anode"},
|
||||||
|
{56, "EBADRQC", "invalid request code"},
|
||||||
|
{57, "EBADSLT", "invalid slot"},
|
||||||
|
{58, "EDEADLOCK", "file locking deadlock error"},
|
||||||
|
{59, "EBFONT", "bad font file format"},
|
||||||
|
{60, "ENOSTR", "device not a stream"},
|
||||||
|
{61, "ENODATA", "no data available"},
|
||||||
|
{62, "ETIME", "timer expired"},
|
||||||
|
{63, "ENOSR", "out of streams resources"},
|
||||||
|
{64, "ENONET", "machine is not on the network"},
|
||||||
|
{65, "ENOPKG", "package not installed"},
|
||||||
|
{66, "EREMOTE", "object is remote"},
|
||||||
|
{67, "ENOLINK", "link has been severed"},
|
||||||
|
{68, "EADV", "advertise error"},
|
||||||
|
{69, "ESRMNT", "srmount error"},
|
||||||
|
{70, "ECOMM", "communication error on send"},
|
||||||
|
{71, "EPROTO", "protocol error"},
|
||||||
|
{72, "EMULTIHOP", "multihop attempted"},
|
||||||
|
{73, "EDOTDOT", "RFS specific error"},
|
||||||
|
{74, "EBADMSG", "bad message"},
|
||||||
|
{75, "EOVERFLOW", "value too large for defined data type"},
|
||||||
|
{76, "ENOTUNIQ", "name not unique on network"},
|
||||||
|
{77, "EBADFD", "file descriptor in bad state"},
|
||||||
|
{78, "EREMCHG", "remote address changed"},
|
||||||
|
{79, "ELIBACC", "can not access a needed shared library"},
|
||||||
|
{80, "ELIBBAD", "accessing a corrupted shared library"},
|
||||||
|
{81, "ELIBSCN", ".lib section in a.out corrupted"},
|
||||||
|
{82, "ELIBMAX", "attempting to link in too many shared libraries"},
|
||||||
|
{83, "ELIBEXEC", "cannot exec a shared library directly"},
|
||||||
|
{84, "EILSEQ", "invalid or incomplete multibyte or wide character"},
|
||||||
|
{85, "ERESTART", "interrupted system call should be restarted"},
|
||||||
|
{86, "ESTRPIPE", "streams pipe error"},
|
||||||
|
{87, "EUSERS", "too many users"},
|
||||||
|
{88, "ENOTSOCK", "socket operation on non-socket"},
|
||||||
|
{89, "EDESTADDRREQ", "destination address required"},
|
||||||
|
{90, "EMSGSIZE", "message too long"},
|
||||||
|
{91, "EPROTOTYPE", "protocol wrong type for socket"},
|
||||||
|
{92, "ENOPROTOOPT", "protocol not available"},
|
||||||
|
{93, "EPROTONOSUPPORT", "protocol not supported"},
|
||||||
|
{94, "ESOCKTNOSUPPORT", "socket type not supported"},
|
||||||
|
{95, "ENOTSUP", "operation not supported"},
|
||||||
|
{96, "EPFNOSUPPORT", "protocol family not supported"},
|
||||||
|
{97, "EAFNOSUPPORT", "address family not supported by protocol"},
|
||||||
|
{98, "EADDRINUSE", "address already in use"},
|
||||||
|
{99, "EADDRNOTAVAIL", "cannot assign requested address"},
|
||||||
|
{100, "ENETDOWN", "network is down"},
|
||||||
|
{101, "ENETUNREACH", "network is unreachable"},
|
||||||
|
{102, "ENETRESET", "network dropped connection on reset"},
|
||||||
|
{103, "ECONNABORTED", "software caused connection abort"},
|
||||||
|
{104, "ECONNRESET", "connection reset by peer"},
|
||||||
|
{105, "ENOBUFS", "no buffer space available"},
|
||||||
|
{106, "EISCONN", "transport endpoint is already connected"},
|
||||||
|
{107, "ENOTCONN", "transport endpoint is not connected"},
|
||||||
|
{108, "ESHUTDOWN", "cannot send after transport endpoint shutdown"},
|
||||||
|
{109, "ETOOMANYREFS", "too many references: cannot splice"},
|
||||||
|
{110, "ETIMEDOUT", "connection timed out"},
|
||||||
|
{111, "ECONNREFUSED", "connection refused"},
|
||||||
|
{112, "EHOSTDOWN", "host is down"},
|
||||||
|
{113, "EHOSTUNREACH", "no route to host"},
|
||||||
|
{114, "EALREADY", "operation already in progress"},
|
||||||
|
{115, "EINPROGRESS", "operation now in progress"},
|
||||||
|
{116, "ESTALE", "stale file handle"},
|
||||||
|
{117, "EUCLEAN", "structure needs cleaning"},
|
||||||
|
{118, "ENOTNAM", "not a XENIX named type file"},
|
||||||
|
{119, "ENAVAIL", "no XENIX semaphores available"},
|
||||||
|
{120, "EISNAM", "is a named type file"},
|
||||||
|
{121, "EREMOTEIO", "remote I/O error"},
|
||||||
|
{122, "EDQUOT", "disk quota exceeded"},
|
||||||
|
{123, "ENOMEDIUM", "no medium found"},
|
||||||
|
{124, "EMEDIUMTYPE", "wrong medium type"},
|
||||||
|
{125, "ECANCELED", "operation canceled"},
|
||||||
|
{126, "ENOKEY", "required key not available"},
|
||||||
|
{127, "EKEYEXPIRED", "key has expired"},
|
||||||
|
{128, "EKEYREVOKED", "key has been revoked"},
|
||||||
|
{129, "EKEYREJECTED", "key was rejected by service"},
|
||||||
|
{130, "EOWNERDEAD", "owner died"},
|
||||||
|
{131, "ENOTRECOVERABLE", "state not recoverable"},
|
||||||
|
{132, "ERFKILL", "operation not possible due to RF-kill"},
|
||||||
|
{133, "EHWPOISON", "memory page has hardware error"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Signal table
|
||||||
|
var signalList = [...]struct {
|
||||||
|
num syscall.Signal
|
||||||
|
name string
|
||||||
|
desc string
|
||||||
|
}{
|
||||||
|
{1, "SIGHUP", "hangup"},
|
||||||
|
{2, "SIGINT", "interrupt"},
|
||||||
|
{3, "SIGQUIT", "quit"},
|
||||||
|
{4, "SIGILL", "illegal instruction"},
|
||||||
|
{5, "SIGTRAP", "trace/breakpoint trap"},
|
||||||
|
{6, "SIGABRT", "aborted"},
|
||||||
|
{7, "SIGBUS", "bus error"},
|
||||||
|
{8, "SIGFPE", "floating point exception"},
|
||||||
|
{9, "SIGKILL", "killed"},
|
||||||
|
{10, "SIGUSR1", "user defined signal 1"},
|
||||||
|
{11, "SIGSEGV", "segmentation fault"},
|
||||||
|
{12, "SIGUSR2", "user defined signal 2"},
|
||||||
|
{13, "SIGPIPE", "broken pipe"},
|
||||||
|
{14, "SIGALRM", "alarm clock"},
|
||||||
|
{15, "SIGTERM", "terminated"},
|
||||||
|
{16, "SIGSTKFLT", "stack fault"},
|
||||||
|
{17, "SIGCHLD", "child exited"},
|
||||||
|
{18, "SIGCONT", "continued"},
|
||||||
|
{19, "SIGSTOP", "stopped (signal)"},
|
||||||
|
{20, "SIGTSTP", "stopped"},
|
||||||
|
{21, "SIGTTIN", "stopped (tty input)"},
|
||||||
|
{22, "SIGTTOU", "stopped (tty output)"},
|
||||||
|
{23, "SIGURG", "urgent I/O condition"},
|
||||||
|
{24, "SIGXCPU", "CPU time limit exceeded"},
|
||||||
|
{25, "SIGXFSZ", "file size limit exceeded"},
|
||||||
|
{26, "SIGVTALRM", "virtual timer expired"},
|
||||||
|
{27, "SIGPROF", "profiling timer expired"},
|
||||||
|
{28, "SIGWINCH", "window changed"},
|
||||||
|
{29, "SIGIO", "I/O possible"},
|
||||||
|
{30, "SIGPWR", "power failure"},
|
||||||
|
{31, "SIGSYS", "bad system call"},
|
||||||
|
}
|
||||||
|
|
@ -366,6 +366,7 @@ const (
|
||||||
HUPCL = 0x400
|
HUPCL = 0x400
|
||||||
IBSHIFT = 0x10
|
IBSHIFT = 0x10
|
||||||
ICANON = 0x2
|
ICANON = 0x2
|
||||||
|
ICMP6_FILTER = 0x1
|
||||||
ICRNL = 0x100
|
ICRNL = 0x100
|
||||||
IEXTEN = 0x8000
|
IEXTEN = 0x8000
|
||||||
IFF_ADDRCONF = 0x80000
|
IFF_ADDRCONF = 0x80000
|
||||||
|
|
@ -612,6 +613,7 @@ const (
|
||||||
IP_RECVPKTINFO = 0x1a
|
IP_RECVPKTINFO = 0x1a
|
||||||
IP_RECVRETOPTS = 0x6
|
IP_RECVRETOPTS = 0x6
|
||||||
IP_RECVSLLA = 0xa
|
IP_RECVSLLA = 0xa
|
||||||
|
IP_RECVTOS = 0xc
|
||||||
IP_RECVTTL = 0xb
|
IP_RECVTTL = 0xb
|
||||||
IP_RETOPTS = 0x8
|
IP_RETOPTS = 0x8
|
||||||
IP_REUSEADDR = 0x104
|
IP_REUSEADDR = 0x104
|
||||||
|
|
@ -704,6 +706,7 @@ const (
|
||||||
O_APPEND = 0x8
|
O_APPEND = 0x8
|
||||||
O_CLOEXEC = 0x800000
|
O_CLOEXEC = 0x800000
|
||||||
O_CREAT = 0x100
|
O_CREAT = 0x100
|
||||||
|
O_DIRECT = 0x2000000
|
||||||
O_DIRECTORY = 0x1000000
|
O_DIRECTORY = 0x1000000
|
||||||
O_DSYNC = 0x40
|
O_DSYNC = 0x40
|
||||||
O_EXCL = 0x400
|
O_EXCL = 0x400
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,7 @@ const (
|
||||||
IP_TTL = 3
|
IP_TTL = 3
|
||||||
IP_UNBLOCK_SOURCE = 11
|
IP_UNBLOCK_SOURCE = 11
|
||||||
ICANON = 0x0010
|
ICANON = 0x0010
|
||||||
|
ICMP6_FILTER = 0x26
|
||||||
ICRNL = 0x0002
|
ICRNL = 0x0002
|
||||||
IEXTEN = 0x0020
|
IEXTEN = 0x0020
|
||||||
IGNBRK = 0x0004
|
IGNBRK = 0x0004
|
||||||
|
|
@ -163,6 +164,12 @@ const (
|
||||||
MAP_PRIVATE = 0x1 // changes are private
|
MAP_PRIVATE = 0x1 // changes are private
|
||||||
MAP_SHARED = 0x2 // changes are shared
|
MAP_SHARED = 0x2 // changes are shared
|
||||||
MAP_FIXED = 0x4 // place exactly
|
MAP_FIXED = 0x4 // place exactly
|
||||||
|
MCAST_JOIN_GROUP = 40
|
||||||
|
MCAST_LEAVE_GROUP = 41
|
||||||
|
MCAST_JOIN_SOURCE_GROUP = 42
|
||||||
|
MCAST_LEAVE_SOURCE_GROUP = 43
|
||||||
|
MCAST_BLOCK_SOURCE = 44
|
||||||
|
MCAST_UNBLOCK_SOURCE = 45
|
||||||
MS_SYNC = 0x1 // msync - synchronous writes
|
MS_SYNC = 0x1 // msync - synchronous writes
|
||||||
MS_ASYNC = 0x2 // asynchronous writes
|
MS_ASYNC = 0x2 // asynchronous writes
|
||||||
MS_INVALIDATE = 0x4 // invalidate mappings
|
MS_INVALIDATE = 0x4 // invalidate mappings
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,762 @@
|
||||||
|
// go run mksyscall.go -b32 -tags linux,ppc syscall_linux.go syscall_linux_ppc.go
|
||||||
|
// Code generated by the command above; see README.md. DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:build linux && ppc
|
||||||
|
// +build linux,ppc
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ syscall.Errno
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func fanotifyMark(fd int, flags uint, mask uint64, dirFd int, pathname *byte) (err error) {
|
||||||
|
_, _, e1 := Syscall6(SYS_FANOTIFY_MARK, uintptr(fd), uintptr(flags), uintptr(mask>>32), uintptr(mask), uintptr(dirFd), uintptr(unsafe.Pointer(pathname)))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Fallocate(fd int, mode uint32, off int64, len int64) (err error) {
|
||||||
|
_, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off>>32), uintptr(off), uintptr(len>>32), uintptr(len))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) {
|
||||||
|
r0, r1, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0)
|
||||||
|
n = int64(int64(r0)<<32 | int64(r1))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func dup2(oldfd int, newfd int) (err error) {
|
||||||
|
_, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func EpollCreate(size int) (fd int, err error) {
|
||||||
|
r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0)
|
||||||
|
fd = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) {
|
||||||
|
var _p0 unsafe.Pointer
|
||||||
|
if len(events) > 0 {
|
||||||
|
_p0 = unsafe.Pointer(&events[0])
|
||||||
|
} else {
|
||||||
|
_p0 = unsafe.Pointer(&_zero)
|
||||||
|
}
|
||||||
|
r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0)
|
||||||
|
n = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Fchown(fd int, uid int, gid int) (err error) {
|
||||||
|
_, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Fstat(fd int, stat *Stat_t) (err error) {
|
||||||
|
_, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(path)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := Syscall6(SYS_FSTATAT64, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Ftruncate(fd int, length int64) (err error) {
|
||||||
|
_, _, e1 := Syscall(SYS_FTRUNCATE64, uintptr(fd), uintptr(length>>32), uintptr(length))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Getegid() (egid int) {
|
||||||
|
r0, _ := RawSyscallNoError(SYS_GETEGID, 0, 0, 0)
|
||||||
|
egid = int(r0)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Geteuid() (euid int) {
|
||||||
|
r0, _ := RawSyscallNoError(SYS_GETEUID, 0, 0, 0)
|
||||||
|
euid = int(r0)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Getgid() (gid int) {
|
||||||
|
r0, _ := RawSyscallNoError(SYS_GETGID, 0, 0, 0)
|
||||||
|
gid = int(r0)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Getuid() (uid int) {
|
||||||
|
r0, _ := RawSyscallNoError(SYS_GETUID, 0, 0, 0)
|
||||||
|
uid = int(r0)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func InotifyInit() (fd int, err error) {
|
||||||
|
r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0)
|
||||||
|
fd = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Ioperm(from int, num int, on int) (err error) {
|
||||||
|
_, _, e1 := Syscall(SYS_IOPERM, uintptr(from), uintptr(num), uintptr(on))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Iopl(level int) (err error) {
|
||||||
|
_, _, e1 := Syscall(SYS_IOPL, uintptr(level), 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Lchown(path string, uid int, gid int) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(path)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Listen(s int, n int) (err error) {
|
||||||
|
_, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Lstat(path string, stat *Stat_t) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(path)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Pause() (err error) {
|
||||||
|
_, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Pread(fd int, p []byte, offset int64) (n int, err error) {
|
||||||
|
var _p0 unsafe.Pointer
|
||||||
|
if len(p) > 0 {
|
||||||
|
_p0 = unsafe.Pointer(&p[0])
|
||||||
|
} else {
|
||||||
|
_p0 = unsafe.Pointer(&_zero)
|
||||||
|
}
|
||||||
|
r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset>>32), uintptr(offset), 0)
|
||||||
|
n = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
|
||||||
|
var _p0 unsafe.Pointer
|
||||||
|
if len(p) > 0 {
|
||||||
|
_p0 = unsafe.Pointer(&p[0])
|
||||||
|
} else {
|
||||||
|
_p0 = unsafe.Pointer(&_zero)
|
||||||
|
}
|
||||||
|
r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset>>32), uintptr(offset), 0)
|
||||||
|
n = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(oldpath)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var _p1 *byte
|
||||||
|
_p1, err = BytePtrFromString(newpath)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
|
||||||
|
r0, _, e1 := Syscall6(SYS__NEWSELECT, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
|
||||||
|
n = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
r0, _, e1 := Syscall6(SYS_SENDFILE64, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
|
||||||
|
written = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func setfsgid(gid int) (prev int, err error) {
|
||||||
|
r0, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0)
|
||||||
|
prev = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func setfsuid(uid int) (prev int, err error) {
|
||||||
|
r0, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0)
|
||||||
|
prev = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Setregid(rgid int, egid int) (err error) {
|
||||||
|
_, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Setresgid(rgid int, egid int, sgid int) (err error) {
|
||||||
|
_, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Setresuid(ruid int, euid int, suid int) (err error) {
|
||||||
|
_, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Setreuid(ruid int, euid int) (err error) {
|
||||||
|
_, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Shutdown(fd int, how int) (err error) {
|
||||||
|
_, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) {
|
||||||
|
r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags))
|
||||||
|
n = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Stat(path string, stat *Stat_t) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(path)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Truncate(path string, length int64) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(path)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := Syscall(SYS_TRUNCATE64, uintptr(unsafe.Pointer(_p0)), uintptr(length>>32), uintptr(length))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Ustat(dev int, ubuf *Ustat_t) (err error) {
|
||||||
|
_, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
|
||||||
|
r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
|
||||||
|
fd = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) {
|
||||||
|
r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
|
||||||
|
fd = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
|
||||||
|
_, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
|
||||||
|
_, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func getgroups(n int, list *_Gid_t) (nn int, err error) {
|
||||||
|
r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
|
||||||
|
nn = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func setgroups(n int, list *_Gid_t) (err error) {
|
||||||
|
_, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
|
||||||
|
_, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
|
||||||
|
_, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func socket(domain int, typ int, proto int) (fd int, err error) {
|
||||||
|
r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
|
||||||
|
fd = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
|
||||||
|
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
|
||||||
|
_, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
|
||||||
|
_, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
|
||||||
|
var _p0 unsafe.Pointer
|
||||||
|
if len(p) > 0 {
|
||||||
|
_p0 = unsafe.Pointer(&p[0])
|
||||||
|
} else {
|
||||||
|
_p0 = unsafe.Pointer(&_zero)
|
||||||
|
}
|
||||||
|
r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
|
||||||
|
n = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
|
||||||
|
var _p0 unsafe.Pointer
|
||||||
|
if len(buf) > 0 {
|
||||||
|
_p0 = unsafe.Pointer(&buf[0])
|
||||||
|
} else {
|
||||||
|
_p0 = unsafe.Pointer(&_zero)
|
||||||
|
}
|
||||||
|
_, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
|
||||||
|
r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
|
||||||
|
n = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
|
||||||
|
r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
|
||||||
|
n = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func futimesat(dirfd int, path string, times *[2]Timeval) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(path)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Gettimeofday(tv *Timeval) (err error) {
|
||||||
|
_, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Time(t *Time_t) (tt Time_t, err error) {
|
||||||
|
r0, _, e1 := RawSyscall(SYS_TIME, uintptr(unsafe.Pointer(t)), 0, 0)
|
||||||
|
tt = Time_t(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Utime(path string, buf *Utimbuf) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(path)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func utimes(path string, times *[2]Timeval) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(path)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error) {
|
||||||
|
r0, _, e1 := Syscall6(SYS_MMAP2, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(pageOffset))
|
||||||
|
xaddr = uintptr(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func getrlimit(resource int, rlim *rlimit32) (err error) {
|
||||||
|
_, _, e1 := RawSyscall(SYS_UGETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func setrlimit(resource int, rlim *rlimit32) (err error) {
|
||||||
|
_, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func pipe(p *[2]_C_int) (err error) {
|
||||||
|
_, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
|
||||||
|
r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
|
||||||
|
n = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func syncFileRange2(fd int, flags int, off int64, n int64) (err error) {
|
||||||
|
_, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE2, uintptr(fd), uintptr(flags), uintptr(off>>32), uintptr(off), uintptr(n>>32), uintptr(n))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(cmdline)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,433 @@
|
||||||
|
// go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h
|
||||||
|
// Code generated by the command above; see README.md. DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:build ppc && linux
|
||||||
|
// +build ppc,linux
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const (
|
||||||
|
SYS_RESTART_SYSCALL = 0
|
||||||
|
SYS_EXIT = 1
|
||||||
|
SYS_FORK = 2
|
||||||
|
SYS_READ = 3
|
||||||
|
SYS_WRITE = 4
|
||||||
|
SYS_OPEN = 5
|
||||||
|
SYS_CLOSE = 6
|
||||||
|
SYS_WAITPID = 7
|
||||||
|
SYS_CREAT = 8
|
||||||
|
SYS_LINK = 9
|
||||||
|
SYS_UNLINK = 10
|
||||||
|
SYS_EXECVE = 11
|
||||||
|
SYS_CHDIR = 12
|
||||||
|
SYS_TIME = 13
|
||||||
|
SYS_MKNOD = 14
|
||||||
|
SYS_CHMOD = 15
|
||||||
|
SYS_LCHOWN = 16
|
||||||
|
SYS_BREAK = 17
|
||||||
|
SYS_OLDSTAT = 18
|
||||||
|
SYS_LSEEK = 19
|
||||||
|
SYS_GETPID = 20
|
||||||
|
SYS_MOUNT = 21
|
||||||
|
SYS_UMOUNT = 22
|
||||||
|
SYS_SETUID = 23
|
||||||
|
SYS_GETUID = 24
|
||||||
|
SYS_STIME = 25
|
||||||
|
SYS_PTRACE = 26
|
||||||
|
SYS_ALARM = 27
|
||||||
|
SYS_OLDFSTAT = 28
|
||||||
|
SYS_PAUSE = 29
|
||||||
|
SYS_UTIME = 30
|
||||||
|
SYS_STTY = 31
|
||||||
|
SYS_GTTY = 32
|
||||||
|
SYS_ACCESS = 33
|
||||||
|
SYS_NICE = 34
|
||||||
|
SYS_FTIME = 35
|
||||||
|
SYS_SYNC = 36
|
||||||
|
SYS_KILL = 37
|
||||||
|
SYS_RENAME = 38
|
||||||
|
SYS_MKDIR = 39
|
||||||
|
SYS_RMDIR = 40
|
||||||
|
SYS_DUP = 41
|
||||||
|
SYS_PIPE = 42
|
||||||
|
SYS_TIMES = 43
|
||||||
|
SYS_PROF = 44
|
||||||
|
SYS_BRK = 45
|
||||||
|
SYS_SETGID = 46
|
||||||
|
SYS_GETGID = 47
|
||||||
|
SYS_SIGNAL = 48
|
||||||
|
SYS_GETEUID = 49
|
||||||
|
SYS_GETEGID = 50
|
||||||
|
SYS_ACCT = 51
|
||||||
|
SYS_UMOUNT2 = 52
|
||||||
|
SYS_LOCK = 53
|
||||||
|
SYS_IOCTL = 54
|
||||||
|
SYS_FCNTL = 55
|
||||||
|
SYS_MPX = 56
|
||||||
|
SYS_SETPGID = 57
|
||||||
|
SYS_ULIMIT = 58
|
||||||
|
SYS_OLDOLDUNAME = 59
|
||||||
|
SYS_UMASK = 60
|
||||||
|
SYS_CHROOT = 61
|
||||||
|
SYS_USTAT = 62
|
||||||
|
SYS_DUP2 = 63
|
||||||
|
SYS_GETPPID = 64
|
||||||
|
SYS_GETPGRP = 65
|
||||||
|
SYS_SETSID = 66
|
||||||
|
SYS_SIGACTION = 67
|
||||||
|
SYS_SGETMASK = 68
|
||||||
|
SYS_SSETMASK = 69
|
||||||
|
SYS_SETREUID = 70
|
||||||
|
SYS_SETREGID = 71
|
||||||
|
SYS_SIGSUSPEND = 72
|
||||||
|
SYS_SIGPENDING = 73
|
||||||
|
SYS_SETHOSTNAME = 74
|
||||||
|
SYS_SETRLIMIT = 75
|
||||||
|
SYS_GETRLIMIT = 76
|
||||||
|
SYS_GETRUSAGE = 77
|
||||||
|
SYS_GETTIMEOFDAY = 78
|
||||||
|
SYS_SETTIMEOFDAY = 79
|
||||||
|
SYS_GETGROUPS = 80
|
||||||
|
SYS_SETGROUPS = 81
|
||||||
|
SYS_SELECT = 82
|
||||||
|
SYS_SYMLINK = 83
|
||||||
|
SYS_OLDLSTAT = 84
|
||||||
|
SYS_READLINK = 85
|
||||||
|
SYS_USELIB = 86
|
||||||
|
SYS_SWAPON = 87
|
||||||
|
SYS_REBOOT = 88
|
||||||
|
SYS_READDIR = 89
|
||||||
|
SYS_MMAP = 90
|
||||||
|
SYS_MUNMAP = 91
|
||||||
|
SYS_TRUNCATE = 92
|
||||||
|
SYS_FTRUNCATE = 93
|
||||||
|
SYS_FCHMOD = 94
|
||||||
|
SYS_FCHOWN = 95
|
||||||
|
SYS_GETPRIORITY = 96
|
||||||
|
SYS_SETPRIORITY = 97
|
||||||
|
SYS_PROFIL = 98
|
||||||
|
SYS_STATFS = 99
|
||||||
|
SYS_FSTATFS = 100
|
||||||
|
SYS_IOPERM = 101
|
||||||
|
SYS_SOCKETCALL = 102
|
||||||
|
SYS_SYSLOG = 103
|
||||||
|
SYS_SETITIMER = 104
|
||||||
|
SYS_GETITIMER = 105
|
||||||
|
SYS_STAT = 106
|
||||||
|
SYS_LSTAT = 107
|
||||||
|
SYS_FSTAT = 108
|
||||||
|
SYS_OLDUNAME = 109
|
||||||
|
SYS_IOPL = 110
|
||||||
|
SYS_VHANGUP = 111
|
||||||
|
SYS_IDLE = 112
|
||||||
|
SYS_VM86 = 113
|
||||||
|
SYS_WAIT4 = 114
|
||||||
|
SYS_SWAPOFF = 115
|
||||||
|
SYS_SYSINFO = 116
|
||||||
|
SYS_IPC = 117
|
||||||
|
SYS_FSYNC = 118
|
||||||
|
SYS_SIGRETURN = 119
|
||||||
|
SYS_CLONE = 120
|
||||||
|
SYS_SETDOMAINNAME = 121
|
||||||
|
SYS_UNAME = 122
|
||||||
|
SYS_MODIFY_LDT = 123
|
||||||
|
SYS_ADJTIMEX = 124
|
||||||
|
SYS_MPROTECT = 125
|
||||||
|
SYS_SIGPROCMASK = 126
|
||||||
|
SYS_CREATE_MODULE = 127
|
||||||
|
SYS_INIT_MODULE = 128
|
||||||
|
SYS_DELETE_MODULE = 129
|
||||||
|
SYS_GET_KERNEL_SYMS = 130
|
||||||
|
SYS_QUOTACTL = 131
|
||||||
|
SYS_GETPGID = 132
|
||||||
|
SYS_FCHDIR = 133
|
||||||
|
SYS_BDFLUSH = 134
|
||||||
|
SYS_SYSFS = 135
|
||||||
|
SYS_PERSONALITY = 136
|
||||||
|
SYS_AFS_SYSCALL = 137
|
||||||
|
SYS_SETFSUID = 138
|
||||||
|
SYS_SETFSGID = 139
|
||||||
|
SYS__LLSEEK = 140
|
||||||
|
SYS_GETDENTS = 141
|
||||||
|
SYS__NEWSELECT = 142
|
||||||
|
SYS_FLOCK = 143
|
||||||
|
SYS_MSYNC = 144
|
||||||
|
SYS_READV = 145
|
||||||
|
SYS_WRITEV = 146
|
||||||
|
SYS_GETSID = 147
|
||||||
|
SYS_FDATASYNC = 148
|
||||||
|
SYS__SYSCTL = 149
|
||||||
|
SYS_MLOCK = 150
|
||||||
|
SYS_MUNLOCK = 151
|
||||||
|
SYS_MLOCKALL = 152
|
||||||
|
SYS_MUNLOCKALL = 153
|
||||||
|
SYS_SCHED_SETPARAM = 154
|
||||||
|
SYS_SCHED_GETPARAM = 155
|
||||||
|
SYS_SCHED_SETSCHEDULER = 156
|
||||||
|
SYS_SCHED_GETSCHEDULER = 157
|
||||||
|
SYS_SCHED_YIELD = 158
|
||||||
|
SYS_SCHED_GET_PRIORITY_MAX = 159
|
||||||
|
SYS_SCHED_GET_PRIORITY_MIN = 160
|
||||||
|
SYS_SCHED_RR_GET_INTERVAL = 161
|
||||||
|
SYS_NANOSLEEP = 162
|
||||||
|
SYS_MREMAP = 163
|
||||||
|
SYS_SETRESUID = 164
|
||||||
|
SYS_GETRESUID = 165
|
||||||
|
SYS_QUERY_MODULE = 166
|
||||||
|
SYS_POLL = 167
|
||||||
|
SYS_NFSSERVCTL = 168
|
||||||
|
SYS_SETRESGID = 169
|
||||||
|
SYS_GETRESGID = 170
|
||||||
|
SYS_PRCTL = 171
|
||||||
|
SYS_RT_SIGRETURN = 172
|
||||||
|
SYS_RT_SIGACTION = 173
|
||||||
|
SYS_RT_SIGPROCMASK = 174
|
||||||
|
SYS_RT_SIGPENDING = 175
|
||||||
|
SYS_RT_SIGTIMEDWAIT = 176
|
||||||
|
SYS_RT_SIGQUEUEINFO = 177
|
||||||
|
SYS_RT_SIGSUSPEND = 178
|
||||||
|
SYS_PREAD64 = 179
|
||||||
|
SYS_PWRITE64 = 180
|
||||||
|
SYS_CHOWN = 181
|
||||||
|
SYS_GETCWD = 182
|
||||||
|
SYS_CAPGET = 183
|
||||||
|
SYS_CAPSET = 184
|
||||||
|
SYS_SIGALTSTACK = 185
|
||||||
|
SYS_SENDFILE = 186
|
||||||
|
SYS_GETPMSG = 187
|
||||||
|
SYS_PUTPMSG = 188
|
||||||
|
SYS_VFORK = 189
|
||||||
|
SYS_UGETRLIMIT = 190
|
||||||
|
SYS_READAHEAD = 191
|
||||||
|
SYS_MMAP2 = 192
|
||||||
|
SYS_TRUNCATE64 = 193
|
||||||
|
SYS_FTRUNCATE64 = 194
|
||||||
|
SYS_STAT64 = 195
|
||||||
|
SYS_LSTAT64 = 196
|
||||||
|
SYS_FSTAT64 = 197
|
||||||
|
SYS_PCICONFIG_READ = 198
|
||||||
|
SYS_PCICONFIG_WRITE = 199
|
||||||
|
SYS_PCICONFIG_IOBASE = 200
|
||||||
|
SYS_MULTIPLEXER = 201
|
||||||
|
SYS_GETDENTS64 = 202
|
||||||
|
SYS_PIVOT_ROOT = 203
|
||||||
|
SYS_FCNTL64 = 204
|
||||||
|
SYS_MADVISE = 205
|
||||||
|
SYS_MINCORE = 206
|
||||||
|
SYS_GETTID = 207
|
||||||
|
SYS_TKILL = 208
|
||||||
|
SYS_SETXATTR = 209
|
||||||
|
SYS_LSETXATTR = 210
|
||||||
|
SYS_FSETXATTR = 211
|
||||||
|
SYS_GETXATTR = 212
|
||||||
|
SYS_LGETXATTR = 213
|
||||||
|
SYS_FGETXATTR = 214
|
||||||
|
SYS_LISTXATTR = 215
|
||||||
|
SYS_LLISTXATTR = 216
|
||||||
|
SYS_FLISTXATTR = 217
|
||||||
|
SYS_REMOVEXATTR = 218
|
||||||
|
SYS_LREMOVEXATTR = 219
|
||||||
|
SYS_FREMOVEXATTR = 220
|
||||||
|
SYS_FUTEX = 221
|
||||||
|
SYS_SCHED_SETAFFINITY = 222
|
||||||
|
SYS_SCHED_GETAFFINITY = 223
|
||||||
|
SYS_TUXCALL = 225
|
||||||
|
SYS_SENDFILE64 = 226
|
||||||
|
SYS_IO_SETUP = 227
|
||||||
|
SYS_IO_DESTROY = 228
|
||||||
|
SYS_IO_GETEVENTS = 229
|
||||||
|
SYS_IO_SUBMIT = 230
|
||||||
|
SYS_IO_CANCEL = 231
|
||||||
|
SYS_SET_TID_ADDRESS = 232
|
||||||
|
SYS_FADVISE64 = 233
|
||||||
|
SYS_EXIT_GROUP = 234
|
||||||
|
SYS_LOOKUP_DCOOKIE = 235
|
||||||
|
SYS_EPOLL_CREATE = 236
|
||||||
|
SYS_EPOLL_CTL = 237
|
||||||
|
SYS_EPOLL_WAIT = 238
|
||||||
|
SYS_REMAP_FILE_PAGES = 239
|
||||||
|
SYS_TIMER_CREATE = 240
|
||||||
|
SYS_TIMER_SETTIME = 241
|
||||||
|
SYS_TIMER_GETTIME = 242
|
||||||
|
SYS_TIMER_GETOVERRUN = 243
|
||||||
|
SYS_TIMER_DELETE = 244
|
||||||
|
SYS_CLOCK_SETTIME = 245
|
||||||
|
SYS_CLOCK_GETTIME = 246
|
||||||
|
SYS_CLOCK_GETRES = 247
|
||||||
|
SYS_CLOCK_NANOSLEEP = 248
|
||||||
|
SYS_SWAPCONTEXT = 249
|
||||||
|
SYS_TGKILL = 250
|
||||||
|
SYS_UTIMES = 251
|
||||||
|
SYS_STATFS64 = 252
|
||||||
|
SYS_FSTATFS64 = 253
|
||||||
|
SYS_FADVISE64_64 = 254
|
||||||
|
SYS_RTAS = 255
|
||||||
|
SYS_SYS_DEBUG_SETCONTEXT = 256
|
||||||
|
SYS_MIGRATE_PAGES = 258
|
||||||
|
SYS_MBIND = 259
|
||||||
|
SYS_GET_MEMPOLICY = 260
|
||||||
|
SYS_SET_MEMPOLICY = 261
|
||||||
|
SYS_MQ_OPEN = 262
|
||||||
|
SYS_MQ_UNLINK = 263
|
||||||
|
SYS_MQ_TIMEDSEND = 264
|
||||||
|
SYS_MQ_TIMEDRECEIVE = 265
|
||||||
|
SYS_MQ_NOTIFY = 266
|
||||||
|
SYS_MQ_GETSETATTR = 267
|
||||||
|
SYS_KEXEC_LOAD = 268
|
||||||
|
SYS_ADD_KEY = 269
|
||||||
|
SYS_REQUEST_KEY = 270
|
||||||
|
SYS_KEYCTL = 271
|
||||||
|
SYS_WAITID = 272
|
||||||
|
SYS_IOPRIO_SET = 273
|
||||||
|
SYS_IOPRIO_GET = 274
|
||||||
|
SYS_INOTIFY_INIT = 275
|
||||||
|
SYS_INOTIFY_ADD_WATCH = 276
|
||||||
|
SYS_INOTIFY_RM_WATCH = 277
|
||||||
|
SYS_SPU_RUN = 278
|
||||||
|
SYS_SPU_CREATE = 279
|
||||||
|
SYS_PSELECT6 = 280
|
||||||
|
SYS_PPOLL = 281
|
||||||
|
SYS_UNSHARE = 282
|
||||||
|
SYS_SPLICE = 283
|
||||||
|
SYS_TEE = 284
|
||||||
|
SYS_VMSPLICE = 285
|
||||||
|
SYS_OPENAT = 286
|
||||||
|
SYS_MKDIRAT = 287
|
||||||
|
SYS_MKNODAT = 288
|
||||||
|
SYS_FCHOWNAT = 289
|
||||||
|
SYS_FUTIMESAT = 290
|
||||||
|
SYS_FSTATAT64 = 291
|
||||||
|
SYS_UNLINKAT = 292
|
||||||
|
SYS_RENAMEAT = 293
|
||||||
|
SYS_LINKAT = 294
|
||||||
|
SYS_SYMLINKAT = 295
|
||||||
|
SYS_READLINKAT = 296
|
||||||
|
SYS_FCHMODAT = 297
|
||||||
|
SYS_FACCESSAT = 298
|
||||||
|
SYS_GET_ROBUST_LIST = 299
|
||||||
|
SYS_SET_ROBUST_LIST = 300
|
||||||
|
SYS_MOVE_PAGES = 301
|
||||||
|
SYS_GETCPU = 302
|
||||||
|
SYS_EPOLL_PWAIT = 303
|
||||||
|
SYS_UTIMENSAT = 304
|
||||||
|
SYS_SIGNALFD = 305
|
||||||
|
SYS_TIMERFD_CREATE = 306
|
||||||
|
SYS_EVENTFD = 307
|
||||||
|
SYS_SYNC_FILE_RANGE2 = 308
|
||||||
|
SYS_FALLOCATE = 309
|
||||||
|
SYS_SUBPAGE_PROT = 310
|
||||||
|
SYS_TIMERFD_SETTIME = 311
|
||||||
|
SYS_TIMERFD_GETTIME = 312
|
||||||
|
SYS_SIGNALFD4 = 313
|
||||||
|
SYS_EVENTFD2 = 314
|
||||||
|
SYS_EPOLL_CREATE1 = 315
|
||||||
|
SYS_DUP3 = 316
|
||||||
|
SYS_PIPE2 = 317
|
||||||
|
SYS_INOTIFY_INIT1 = 318
|
||||||
|
SYS_PERF_EVENT_OPEN = 319
|
||||||
|
SYS_PREADV = 320
|
||||||
|
SYS_PWRITEV = 321
|
||||||
|
SYS_RT_TGSIGQUEUEINFO = 322
|
||||||
|
SYS_FANOTIFY_INIT = 323
|
||||||
|
SYS_FANOTIFY_MARK = 324
|
||||||
|
SYS_PRLIMIT64 = 325
|
||||||
|
SYS_SOCKET = 326
|
||||||
|
SYS_BIND = 327
|
||||||
|
SYS_CONNECT = 328
|
||||||
|
SYS_LISTEN = 329
|
||||||
|
SYS_ACCEPT = 330
|
||||||
|
SYS_GETSOCKNAME = 331
|
||||||
|
SYS_GETPEERNAME = 332
|
||||||
|
SYS_SOCKETPAIR = 333
|
||||||
|
SYS_SEND = 334
|
||||||
|
SYS_SENDTO = 335
|
||||||
|
SYS_RECV = 336
|
||||||
|
SYS_RECVFROM = 337
|
||||||
|
SYS_SHUTDOWN = 338
|
||||||
|
SYS_SETSOCKOPT = 339
|
||||||
|
SYS_GETSOCKOPT = 340
|
||||||
|
SYS_SENDMSG = 341
|
||||||
|
SYS_RECVMSG = 342
|
||||||
|
SYS_RECVMMSG = 343
|
||||||
|
SYS_ACCEPT4 = 344
|
||||||
|
SYS_NAME_TO_HANDLE_AT = 345
|
||||||
|
SYS_OPEN_BY_HANDLE_AT = 346
|
||||||
|
SYS_CLOCK_ADJTIME = 347
|
||||||
|
SYS_SYNCFS = 348
|
||||||
|
SYS_SENDMMSG = 349
|
||||||
|
SYS_SETNS = 350
|
||||||
|
SYS_PROCESS_VM_READV = 351
|
||||||
|
SYS_PROCESS_VM_WRITEV = 352
|
||||||
|
SYS_FINIT_MODULE = 353
|
||||||
|
SYS_KCMP = 354
|
||||||
|
SYS_SCHED_SETATTR = 355
|
||||||
|
SYS_SCHED_GETATTR = 356
|
||||||
|
SYS_RENAMEAT2 = 357
|
||||||
|
SYS_SECCOMP = 358
|
||||||
|
SYS_GETRANDOM = 359
|
||||||
|
SYS_MEMFD_CREATE = 360
|
||||||
|
SYS_BPF = 361
|
||||||
|
SYS_EXECVEAT = 362
|
||||||
|
SYS_SWITCH_ENDIAN = 363
|
||||||
|
SYS_USERFAULTFD = 364
|
||||||
|
SYS_MEMBARRIER = 365
|
||||||
|
SYS_MLOCK2 = 378
|
||||||
|
SYS_COPY_FILE_RANGE = 379
|
||||||
|
SYS_PREADV2 = 380
|
||||||
|
SYS_PWRITEV2 = 381
|
||||||
|
SYS_KEXEC_FILE_LOAD = 382
|
||||||
|
SYS_STATX = 383
|
||||||
|
SYS_PKEY_ALLOC = 384
|
||||||
|
SYS_PKEY_FREE = 385
|
||||||
|
SYS_PKEY_MPROTECT = 386
|
||||||
|
SYS_RSEQ = 387
|
||||||
|
SYS_IO_PGETEVENTS = 388
|
||||||
|
SYS_SEMGET = 393
|
||||||
|
SYS_SEMCTL = 394
|
||||||
|
SYS_SHMGET = 395
|
||||||
|
SYS_SHMCTL = 396
|
||||||
|
SYS_SHMAT = 397
|
||||||
|
SYS_SHMDT = 398
|
||||||
|
SYS_MSGGET = 399
|
||||||
|
SYS_MSGSND = 400
|
||||||
|
SYS_MSGRCV = 401
|
||||||
|
SYS_MSGCTL = 402
|
||||||
|
SYS_CLOCK_GETTIME64 = 403
|
||||||
|
SYS_CLOCK_SETTIME64 = 404
|
||||||
|
SYS_CLOCK_ADJTIME64 = 405
|
||||||
|
SYS_CLOCK_GETRES_TIME64 = 406
|
||||||
|
SYS_CLOCK_NANOSLEEP_TIME64 = 407
|
||||||
|
SYS_TIMER_GETTIME64 = 408
|
||||||
|
SYS_TIMER_SETTIME64 = 409
|
||||||
|
SYS_TIMERFD_GETTIME64 = 410
|
||||||
|
SYS_TIMERFD_SETTIME64 = 411
|
||||||
|
SYS_UTIMENSAT_TIME64 = 412
|
||||||
|
SYS_PSELECT6_TIME64 = 413
|
||||||
|
SYS_PPOLL_TIME64 = 414
|
||||||
|
SYS_IO_PGETEVENTS_TIME64 = 416
|
||||||
|
SYS_RECVMMSG_TIME64 = 417
|
||||||
|
SYS_MQ_TIMEDSEND_TIME64 = 418
|
||||||
|
SYS_MQ_TIMEDRECEIVE_TIME64 = 419
|
||||||
|
SYS_SEMTIMEDOP_TIME64 = 420
|
||||||
|
SYS_RT_SIGTIMEDWAIT_TIME64 = 421
|
||||||
|
SYS_FUTEX_TIME64 = 422
|
||||||
|
SYS_SCHED_RR_GET_INTERVAL_TIME64 = 423
|
||||||
|
SYS_PIDFD_SEND_SIGNAL = 424
|
||||||
|
SYS_IO_URING_SETUP = 425
|
||||||
|
SYS_IO_URING_ENTER = 426
|
||||||
|
SYS_IO_URING_REGISTER = 427
|
||||||
|
SYS_OPEN_TREE = 428
|
||||||
|
SYS_MOVE_MOUNT = 429
|
||||||
|
SYS_FSOPEN = 430
|
||||||
|
SYS_FSCONFIG = 431
|
||||||
|
SYS_FSMOUNT = 432
|
||||||
|
SYS_FSPICK = 433
|
||||||
|
SYS_PIDFD_OPEN = 434
|
||||||
|
SYS_CLONE3 = 435
|
||||||
|
SYS_CLOSE_RANGE = 436
|
||||||
|
SYS_OPENAT2 = 437
|
||||||
|
SYS_PIDFD_GETFD = 438
|
||||||
|
SYS_FACCESSAT2 = 439
|
||||||
|
SYS_PROCESS_MADVISE = 440
|
||||||
|
SYS_EPOLL_PWAIT2 = 441
|
||||||
|
)
|
||||||
|
|
@ -221,6 +221,12 @@ type IPMreq struct {
|
||||||
Interface [4]byte /* in_addr */
|
Interface [4]byte /* in_addr */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type IPMreqn struct {
|
||||||
|
Multiaddr [4]byte /* in_addr */
|
||||||
|
Address [4]byte /* in_addr */
|
||||||
|
Ifindex int32
|
||||||
|
}
|
||||||
|
|
||||||
type IPv6Mreq struct {
|
type IPv6Mreq struct {
|
||||||
Multiaddr [16]byte /* in6_addr */
|
Multiaddr [16]byte /* in6_addr */
|
||||||
Interface uint32
|
Interface uint32
|
||||||
|
|
@ -272,6 +278,7 @@ const (
|
||||||
SizeofLinger = 0x8
|
SizeofLinger = 0x8
|
||||||
SizeofIovec = 0x8
|
SizeofIovec = 0x8
|
||||||
SizeofIPMreq = 0x8
|
SizeofIPMreq = 0x8
|
||||||
|
SizeofIPMreqn = 0xc
|
||||||
SizeofIPv6Mreq = 0x14
|
SizeofIPv6Mreq = 0x14
|
||||||
SizeofMsghdr = 0x1c
|
SizeofMsghdr = 0x1c
|
||||||
SizeofCmsghdr = 0xc
|
SizeofCmsghdr = 0xc
|
||||||
|
|
|
||||||
|
|
@ -233,6 +233,12 @@ type IPMreq struct {
|
||||||
Interface [4]byte /* in_addr */
|
Interface [4]byte /* in_addr */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type IPMreqn struct {
|
||||||
|
Multiaddr [4]byte /* in_addr */
|
||||||
|
Address [4]byte /* in_addr */
|
||||||
|
Ifindex int32
|
||||||
|
}
|
||||||
|
|
||||||
type IPv6Mreq struct {
|
type IPv6Mreq struct {
|
||||||
Multiaddr [16]byte /* in6_addr */
|
Multiaddr [16]byte /* in6_addr */
|
||||||
Interface uint32
|
Interface uint32
|
||||||
|
|
@ -285,6 +291,7 @@ const (
|
||||||
SizeofLinger = 0x8
|
SizeofLinger = 0x8
|
||||||
SizeofIovec = 0x10
|
SizeofIovec = 0x10
|
||||||
SizeofIPMreq = 0x8
|
SizeofIPMreq = 0x8
|
||||||
|
SizeofIPMreqn = 0xc
|
||||||
SizeofIPv6Mreq = 0x14
|
SizeofIPv6Mreq = 0x14
|
||||||
SizeofMsghdr = 0x30
|
SizeofMsghdr = 0x30
|
||||||
SizeofCmsghdr = 0xc
|
SizeofCmsghdr = 0xc
|
||||||
|
|
|
||||||
|
|
@ -221,6 +221,12 @@ type IPMreq struct {
|
||||||
Interface [4]byte /* in_addr */
|
Interface [4]byte /* in_addr */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type IPMreqn struct {
|
||||||
|
Multiaddr [4]byte /* in_addr */
|
||||||
|
Address [4]byte /* in_addr */
|
||||||
|
Ifindex int32
|
||||||
|
}
|
||||||
|
|
||||||
type IPv6Mreq struct {
|
type IPv6Mreq struct {
|
||||||
Multiaddr [16]byte /* in6_addr */
|
Multiaddr [16]byte /* in6_addr */
|
||||||
Interface uint32
|
Interface uint32
|
||||||
|
|
@ -272,6 +278,7 @@ const (
|
||||||
SizeofLinger = 0x8
|
SizeofLinger = 0x8
|
||||||
SizeofIovec = 0x8
|
SizeofIovec = 0x8
|
||||||
SizeofIPMreq = 0x8
|
SizeofIPMreq = 0x8
|
||||||
|
SizeofIPMreqn = 0xc
|
||||||
SizeofIPv6Mreq = 0x14
|
SizeofIPv6Mreq = 0x14
|
||||||
SizeofMsghdr = 0x1c
|
SizeofMsghdr = 0x1c
|
||||||
SizeofCmsghdr = 0xc
|
SizeofCmsghdr = 0xc
|
||||||
|
|
|
||||||
|
|
@ -233,6 +233,12 @@ type IPMreq struct {
|
||||||
Interface [4]byte /* in_addr */
|
Interface [4]byte /* in_addr */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type IPMreqn struct {
|
||||||
|
Multiaddr [4]byte /* in_addr */
|
||||||
|
Address [4]byte /* in_addr */
|
||||||
|
Ifindex int32
|
||||||
|
}
|
||||||
|
|
||||||
type IPv6Mreq struct {
|
type IPv6Mreq struct {
|
||||||
Multiaddr [16]byte /* in6_addr */
|
Multiaddr [16]byte /* in6_addr */
|
||||||
Interface uint32
|
Interface uint32
|
||||||
|
|
@ -285,6 +291,7 @@ const (
|
||||||
SizeofLinger = 0x8
|
SizeofLinger = 0x8
|
||||||
SizeofIovec = 0x10
|
SizeofIovec = 0x10
|
||||||
SizeofIPMreq = 0x8
|
SizeofIPMreq = 0x8
|
||||||
|
SizeofIPMreqn = 0xc
|
||||||
SizeofIPv6Mreq = 0x14
|
SizeofIPv6Mreq = 0x14
|
||||||
SizeofMsghdr = 0x30
|
SizeofMsghdr = 0x30
|
||||||
SizeofCmsghdr = 0xc
|
SizeofCmsghdr = 0xc
|
||||||
|
|
|
||||||
|
|
@ -3698,6 +3698,21 @@ const (
|
||||||
ETHTOOL_A_TUNNEL_INFO_MAX = 0x2
|
ETHTOOL_A_TUNNEL_INFO_MAX = 0x2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type EthtoolDrvinfo struct {
|
||||||
|
Cmd uint32
|
||||||
|
Driver [32]byte
|
||||||
|
Version [32]byte
|
||||||
|
Fw_version [32]byte
|
||||||
|
Bus_info [32]byte
|
||||||
|
Erom_version [32]byte
|
||||||
|
Reserved2 [12]byte
|
||||||
|
N_priv_flags uint32
|
||||||
|
N_stats uint32
|
||||||
|
Testinfo_len uint32
|
||||||
|
Eedump_len uint32
|
||||||
|
Regdump_len uint32
|
||||||
|
}
|
||||||
|
|
||||||
type (
|
type (
|
||||||
HIDRawReportDescriptor struct {
|
HIDRawReportDescriptor struct {
|
||||||
Size uint32
|
Size uint32
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,627 @@
|
||||||
|
// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/linux/types.go | go run mkpost.go
|
||||||
|
// Code generated by the command above; see README.md. DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:build ppc && linux
|
||||||
|
// +build ppc,linux
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const (
|
||||||
|
SizeofPtr = 0x4
|
||||||
|
SizeofLong = 0x4
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
_C_long int32
|
||||||
|
)
|
||||||
|
|
||||||
|
type Timespec struct {
|
||||||
|
Sec int32
|
||||||
|
Nsec int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type Timeval struct {
|
||||||
|
Sec int32
|
||||||
|
Usec int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type Timex struct {
|
||||||
|
Modes uint32
|
||||||
|
Offset int32
|
||||||
|
Freq int32
|
||||||
|
Maxerror int32
|
||||||
|
Esterror int32
|
||||||
|
Status int32
|
||||||
|
Constant int32
|
||||||
|
Precision int32
|
||||||
|
Tolerance int32
|
||||||
|
Time Timeval
|
||||||
|
Tick int32
|
||||||
|
Ppsfreq int32
|
||||||
|
Jitter int32
|
||||||
|
Shift int32
|
||||||
|
Stabil int32
|
||||||
|
Jitcnt int32
|
||||||
|
Calcnt int32
|
||||||
|
Errcnt int32
|
||||||
|
Stbcnt int32
|
||||||
|
Tai int32
|
||||||
|
_ [44]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type Time_t int32
|
||||||
|
|
||||||
|
type Tms struct {
|
||||||
|
Utime int32
|
||||||
|
Stime int32
|
||||||
|
Cutime int32
|
||||||
|
Cstime int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type Utimbuf struct {
|
||||||
|
Actime int32
|
||||||
|
Modtime int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type Rusage struct {
|
||||||
|
Utime Timeval
|
||||||
|
Stime Timeval
|
||||||
|
Maxrss int32
|
||||||
|
Ixrss int32
|
||||||
|
Idrss int32
|
||||||
|
Isrss int32
|
||||||
|
Minflt int32
|
||||||
|
Majflt int32
|
||||||
|
Nswap int32
|
||||||
|
Inblock int32
|
||||||
|
Oublock int32
|
||||||
|
Msgsnd int32
|
||||||
|
Msgrcv int32
|
||||||
|
Nsignals int32
|
||||||
|
Nvcsw int32
|
||||||
|
Nivcsw int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type Stat_t struct {
|
||||||
|
Dev uint64
|
||||||
|
Ino uint64
|
||||||
|
Mode uint32
|
||||||
|
Nlink uint32
|
||||||
|
Uid uint32
|
||||||
|
Gid uint32
|
||||||
|
Rdev uint64
|
||||||
|
_ uint16
|
||||||
|
_ [4]byte
|
||||||
|
Size int64
|
||||||
|
Blksize int32
|
||||||
|
_ [4]byte
|
||||||
|
Blocks int64
|
||||||
|
Atim Timespec
|
||||||
|
Mtim Timespec
|
||||||
|
Ctim Timespec
|
||||||
|
_ uint32
|
||||||
|
_ uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type Dirent struct {
|
||||||
|
Ino uint64
|
||||||
|
Off int64
|
||||||
|
Reclen uint16
|
||||||
|
Type uint8
|
||||||
|
Name [256]uint8
|
||||||
|
_ [5]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type Flock_t struct {
|
||||||
|
Type int16
|
||||||
|
Whence int16
|
||||||
|
_ [4]byte
|
||||||
|
Start int64
|
||||||
|
Len int64
|
||||||
|
Pid int32
|
||||||
|
_ [4]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type DmNameList struct {
|
||||||
|
Dev uint64
|
||||||
|
Next uint32
|
||||||
|
Name [0]byte
|
||||||
|
_ [4]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
FADV_DONTNEED = 0x4
|
||||||
|
FADV_NOREUSE = 0x5
|
||||||
|
)
|
||||||
|
|
||||||
|
type RawSockaddr struct {
|
||||||
|
Family uint16
|
||||||
|
Data [14]uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type RawSockaddrAny struct {
|
||||||
|
Addr RawSockaddr
|
||||||
|
Pad [96]uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type Iovec struct {
|
||||||
|
Base *byte
|
||||||
|
Len uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type Msghdr struct {
|
||||||
|
Name *byte
|
||||||
|
Namelen uint32
|
||||||
|
Iov *Iovec
|
||||||
|
Iovlen uint32
|
||||||
|
Control *byte
|
||||||
|
Controllen uint32
|
||||||
|
Flags int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type Cmsghdr struct {
|
||||||
|
Len uint32
|
||||||
|
Level int32
|
||||||
|
Type int32
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
SizeofIovec = 0x8
|
||||||
|
SizeofMsghdr = 0x1c
|
||||||
|
SizeofCmsghdr = 0xc
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
SizeofSockFprog = 0x8
|
||||||
|
)
|
||||||
|
|
||||||
|
type PtraceRegs struct {
|
||||||
|
Gpr [32]uint32
|
||||||
|
Nip uint32
|
||||||
|
Msr uint32
|
||||||
|
Orig_gpr3 uint32
|
||||||
|
Ctr uint32
|
||||||
|
Link uint32
|
||||||
|
Xer uint32
|
||||||
|
Ccr uint32
|
||||||
|
Mq uint32
|
||||||
|
Trap uint32
|
||||||
|
Dar uint32
|
||||||
|
Dsisr uint32
|
||||||
|
Result uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type FdSet struct {
|
||||||
|
Bits [32]int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type Sysinfo_t struct {
|
||||||
|
Uptime int32
|
||||||
|
Loads [3]uint32
|
||||||
|
Totalram uint32
|
||||||
|
Freeram uint32
|
||||||
|
Sharedram uint32
|
||||||
|
Bufferram uint32
|
||||||
|
Totalswap uint32
|
||||||
|
Freeswap uint32
|
||||||
|
Procs uint16
|
||||||
|
Pad uint16
|
||||||
|
Totalhigh uint32
|
||||||
|
Freehigh uint32
|
||||||
|
Unit uint32
|
||||||
|
_ [8]uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type Ustat_t struct {
|
||||||
|
Tfree int32
|
||||||
|
Tinode uint32
|
||||||
|
Fname [6]uint8
|
||||||
|
Fpack [6]uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type EpollEvent struct {
|
||||||
|
Events uint32
|
||||||
|
_ int32
|
||||||
|
Fd int32
|
||||||
|
Pad int32
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
POLLRDHUP = 0x2000
|
||||||
|
)
|
||||||
|
|
||||||
|
type Sigset_t struct {
|
||||||
|
Val [32]uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
const _C__NSIG = 0x41
|
||||||
|
|
||||||
|
type Termios struct {
|
||||||
|
Iflag uint32
|
||||||
|
Oflag uint32
|
||||||
|
Cflag uint32
|
||||||
|
Lflag uint32
|
||||||
|
Cc [19]uint8
|
||||||
|
Line uint8
|
||||||
|
Ispeed uint32
|
||||||
|
Ospeed uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type Taskstats struct {
|
||||||
|
Version uint16
|
||||||
|
Ac_exitcode uint32
|
||||||
|
Ac_flag uint8
|
||||||
|
Ac_nice uint8
|
||||||
|
_ [4]byte
|
||||||
|
Cpu_count uint64
|
||||||
|
Cpu_delay_total uint64
|
||||||
|
Blkio_count uint64
|
||||||
|
Blkio_delay_total uint64
|
||||||
|
Swapin_count uint64
|
||||||
|
Swapin_delay_total uint64
|
||||||
|
Cpu_run_real_total uint64
|
||||||
|
Cpu_run_virtual_total uint64
|
||||||
|
Ac_comm [32]uint8
|
||||||
|
Ac_sched uint8
|
||||||
|
Ac_pad [3]uint8
|
||||||
|
_ [4]byte
|
||||||
|
Ac_uid uint32
|
||||||
|
Ac_gid uint32
|
||||||
|
Ac_pid uint32
|
||||||
|
Ac_ppid uint32
|
||||||
|
Ac_btime uint32
|
||||||
|
_ [4]byte
|
||||||
|
Ac_etime uint64
|
||||||
|
Ac_utime uint64
|
||||||
|
Ac_stime uint64
|
||||||
|
Ac_minflt uint64
|
||||||
|
Ac_majflt uint64
|
||||||
|
Coremem uint64
|
||||||
|
Virtmem uint64
|
||||||
|
Hiwater_rss uint64
|
||||||
|
Hiwater_vm uint64
|
||||||
|
Read_char uint64
|
||||||
|
Write_char uint64
|
||||||
|
Read_syscalls uint64
|
||||||
|
Write_syscalls uint64
|
||||||
|
Read_bytes uint64
|
||||||
|
Write_bytes uint64
|
||||||
|
Cancelled_write_bytes uint64
|
||||||
|
Nvcsw uint64
|
||||||
|
Nivcsw uint64
|
||||||
|
Ac_utimescaled uint64
|
||||||
|
Ac_stimescaled uint64
|
||||||
|
Cpu_scaled_run_real_total uint64
|
||||||
|
Freepages_count uint64
|
||||||
|
Freepages_delay_total uint64
|
||||||
|
Thrashing_count uint64
|
||||||
|
Thrashing_delay_total uint64
|
||||||
|
Ac_btime64 uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type cpuMask uint32
|
||||||
|
|
||||||
|
const (
|
||||||
|
_NCPUBITS = 0x20
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
CBitFieldMaskBit0 = 0x8000000000000000
|
||||||
|
CBitFieldMaskBit1 = 0x4000000000000000
|
||||||
|
CBitFieldMaskBit2 = 0x2000000000000000
|
||||||
|
CBitFieldMaskBit3 = 0x1000000000000000
|
||||||
|
CBitFieldMaskBit4 = 0x800000000000000
|
||||||
|
CBitFieldMaskBit5 = 0x400000000000000
|
||||||
|
CBitFieldMaskBit6 = 0x200000000000000
|
||||||
|
CBitFieldMaskBit7 = 0x100000000000000
|
||||||
|
CBitFieldMaskBit8 = 0x80000000000000
|
||||||
|
CBitFieldMaskBit9 = 0x40000000000000
|
||||||
|
CBitFieldMaskBit10 = 0x20000000000000
|
||||||
|
CBitFieldMaskBit11 = 0x10000000000000
|
||||||
|
CBitFieldMaskBit12 = 0x8000000000000
|
||||||
|
CBitFieldMaskBit13 = 0x4000000000000
|
||||||
|
CBitFieldMaskBit14 = 0x2000000000000
|
||||||
|
CBitFieldMaskBit15 = 0x1000000000000
|
||||||
|
CBitFieldMaskBit16 = 0x800000000000
|
||||||
|
CBitFieldMaskBit17 = 0x400000000000
|
||||||
|
CBitFieldMaskBit18 = 0x200000000000
|
||||||
|
CBitFieldMaskBit19 = 0x100000000000
|
||||||
|
CBitFieldMaskBit20 = 0x80000000000
|
||||||
|
CBitFieldMaskBit21 = 0x40000000000
|
||||||
|
CBitFieldMaskBit22 = 0x20000000000
|
||||||
|
CBitFieldMaskBit23 = 0x10000000000
|
||||||
|
CBitFieldMaskBit24 = 0x8000000000
|
||||||
|
CBitFieldMaskBit25 = 0x4000000000
|
||||||
|
CBitFieldMaskBit26 = 0x2000000000
|
||||||
|
CBitFieldMaskBit27 = 0x1000000000
|
||||||
|
CBitFieldMaskBit28 = 0x800000000
|
||||||
|
CBitFieldMaskBit29 = 0x400000000
|
||||||
|
CBitFieldMaskBit30 = 0x200000000
|
||||||
|
CBitFieldMaskBit31 = 0x100000000
|
||||||
|
CBitFieldMaskBit32 = 0x80000000
|
||||||
|
CBitFieldMaskBit33 = 0x40000000
|
||||||
|
CBitFieldMaskBit34 = 0x20000000
|
||||||
|
CBitFieldMaskBit35 = 0x10000000
|
||||||
|
CBitFieldMaskBit36 = 0x8000000
|
||||||
|
CBitFieldMaskBit37 = 0x4000000
|
||||||
|
CBitFieldMaskBit38 = 0x2000000
|
||||||
|
CBitFieldMaskBit39 = 0x1000000
|
||||||
|
CBitFieldMaskBit40 = 0x800000
|
||||||
|
CBitFieldMaskBit41 = 0x400000
|
||||||
|
CBitFieldMaskBit42 = 0x200000
|
||||||
|
CBitFieldMaskBit43 = 0x100000
|
||||||
|
CBitFieldMaskBit44 = 0x80000
|
||||||
|
CBitFieldMaskBit45 = 0x40000
|
||||||
|
CBitFieldMaskBit46 = 0x20000
|
||||||
|
CBitFieldMaskBit47 = 0x10000
|
||||||
|
CBitFieldMaskBit48 = 0x8000
|
||||||
|
CBitFieldMaskBit49 = 0x4000
|
||||||
|
CBitFieldMaskBit50 = 0x2000
|
||||||
|
CBitFieldMaskBit51 = 0x1000
|
||||||
|
CBitFieldMaskBit52 = 0x800
|
||||||
|
CBitFieldMaskBit53 = 0x400
|
||||||
|
CBitFieldMaskBit54 = 0x200
|
||||||
|
CBitFieldMaskBit55 = 0x100
|
||||||
|
CBitFieldMaskBit56 = 0x80
|
||||||
|
CBitFieldMaskBit57 = 0x40
|
||||||
|
CBitFieldMaskBit58 = 0x20
|
||||||
|
CBitFieldMaskBit59 = 0x10
|
||||||
|
CBitFieldMaskBit60 = 0x8
|
||||||
|
CBitFieldMaskBit61 = 0x4
|
||||||
|
CBitFieldMaskBit62 = 0x2
|
||||||
|
CBitFieldMaskBit63 = 0x1
|
||||||
|
)
|
||||||
|
|
||||||
|
type SockaddrStorage struct {
|
||||||
|
Family uint16
|
||||||
|
_ [122]uint8
|
||||||
|
_ uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type HDGeometry struct {
|
||||||
|
Heads uint8
|
||||||
|
Sectors uint8
|
||||||
|
Cylinders uint16
|
||||||
|
Start uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type Statfs_t struct {
|
||||||
|
Type int32
|
||||||
|
Bsize int32
|
||||||
|
Blocks uint64
|
||||||
|
Bfree uint64
|
||||||
|
Bavail uint64
|
||||||
|
Files uint64
|
||||||
|
Ffree uint64
|
||||||
|
Fsid Fsid
|
||||||
|
Namelen int32
|
||||||
|
Frsize int32
|
||||||
|
Flags int32
|
||||||
|
Spare [4]int32
|
||||||
|
_ [4]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type TpacketHdr struct {
|
||||||
|
Status uint32
|
||||||
|
Len uint32
|
||||||
|
Snaplen uint32
|
||||||
|
Mac uint16
|
||||||
|
Net uint16
|
||||||
|
Sec uint32
|
||||||
|
Usec uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
SizeofTpacketHdr = 0x18
|
||||||
|
)
|
||||||
|
|
||||||
|
type RTCPLLInfo struct {
|
||||||
|
Ctrl int32
|
||||||
|
Value int32
|
||||||
|
Max int32
|
||||||
|
Min int32
|
||||||
|
Posmult int32
|
||||||
|
Negmult int32
|
||||||
|
Clock int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type BlkpgPartition struct {
|
||||||
|
Start int64
|
||||||
|
Length int64
|
||||||
|
Pno int32
|
||||||
|
Devname [64]uint8
|
||||||
|
Volname [64]uint8
|
||||||
|
_ [4]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
BLKPG = 0x20001269
|
||||||
|
)
|
||||||
|
|
||||||
|
type XDPUmemReg struct {
|
||||||
|
Addr uint64
|
||||||
|
Len uint64
|
||||||
|
Size uint32
|
||||||
|
Headroom uint32
|
||||||
|
Flags uint32
|
||||||
|
_ [4]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type CryptoUserAlg struct {
|
||||||
|
Name [64]uint8
|
||||||
|
Driver_name [64]uint8
|
||||||
|
Module_name [64]uint8
|
||||||
|
Type uint32
|
||||||
|
Mask uint32
|
||||||
|
Refcnt uint32
|
||||||
|
Flags uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type CryptoStatAEAD struct {
|
||||||
|
Type [64]uint8
|
||||||
|
Encrypt_cnt uint64
|
||||||
|
Encrypt_tlen uint64
|
||||||
|
Decrypt_cnt uint64
|
||||||
|
Decrypt_tlen uint64
|
||||||
|
Err_cnt uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type CryptoStatAKCipher struct {
|
||||||
|
Type [64]uint8
|
||||||
|
Encrypt_cnt uint64
|
||||||
|
Encrypt_tlen uint64
|
||||||
|
Decrypt_cnt uint64
|
||||||
|
Decrypt_tlen uint64
|
||||||
|
Verify_cnt uint64
|
||||||
|
Sign_cnt uint64
|
||||||
|
Err_cnt uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type CryptoStatCipher struct {
|
||||||
|
Type [64]uint8
|
||||||
|
Encrypt_cnt uint64
|
||||||
|
Encrypt_tlen uint64
|
||||||
|
Decrypt_cnt uint64
|
||||||
|
Decrypt_tlen uint64
|
||||||
|
Err_cnt uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type CryptoStatCompress struct {
|
||||||
|
Type [64]uint8
|
||||||
|
Compress_cnt uint64
|
||||||
|
Compress_tlen uint64
|
||||||
|
Decompress_cnt uint64
|
||||||
|
Decompress_tlen uint64
|
||||||
|
Err_cnt uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type CryptoStatHash struct {
|
||||||
|
Type [64]uint8
|
||||||
|
Hash_cnt uint64
|
||||||
|
Hash_tlen uint64
|
||||||
|
Err_cnt uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type CryptoStatKPP struct {
|
||||||
|
Type [64]uint8
|
||||||
|
Setsecret_cnt uint64
|
||||||
|
Generate_public_key_cnt uint64
|
||||||
|
Compute_shared_secret_cnt uint64
|
||||||
|
Err_cnt uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type CryptoStatRNG struct {
|
||||||
|
Type [64]uint8
|
||||||
|
Generate_cnt uint64
|
||||||
|
Generate_tlen uint64
|
||||||
|
Seed_cnt uint64
|
||||||
|
Err_cnt uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type CryptoStatLarval struct {
|
||||||
|
Type [64]uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type CryptoReportLarval struct {
|
||||||
|
Type [64]uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type CryptoReportHash struct {
|
||||||
|
Type [64]uint8
|
||||||
|
Blocksize uint32
|
||||||
|
Digestsize uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type CryptoReportCipher struct {
|
||||||
|
Type [64]uint8
|
||||||
|
Blocksize uint32
|
||||||
|
Min_keysize uint32
|
||||||
|
Max_keysize uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type CryptoReportBlkCipher struct {
|
||||||
|
Type [64]uint8
|
||||||
|
Geniv [64]uint8
|
||||||
|
Blocksize uint32
|
||||||
|
Min_keysize uint32
|
||||||
|
Max_keysize uint32
|
||||||
|
Ivsize uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type CryptoReportAEAD struct {
|
||||||
|
Type [64]uint8
|
||||||
|
Geniv [64]uint8
|
||||||
|
Blocksize uint32
|
||||||
|
Maxauthsize uint32
|
||||||
|
Ivsize uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type CryptoReportComp struct {
|
||||||
|
Type [64]uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type CryptoReportRNG struct {
|
||||||
|
Type [64]uint8
|
||||||
|
Seedsize uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type CryptoReportAKCipher struct {
|
||||||
|
Type [64]uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type CryptoReportKPP struct {
|
||||||
|
Type [64]uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type CryptoReportAcomp struct {
|
||||||
|
Type [64]uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoopInfo struct {
|
||||||
|
Number int32
|
||||||
|
Device uint32
|
||||||
|
Inode uint32
|
||||||
|
Rdevice uint32
|
||||||
|
Offset int32
|
||||||
|
Encrypt_type int32
|
||||||
|
Encrypt_key_size int32
|
||||||
|
Flags int32
|
||||||
|
Name [64]uint8
|
||||||
|
Encrypt_key [32]uint8
|
||||||
|
Init [2]uint32
|
||||||
|
Reserved [4]uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type TIPCSubscr struct {
|
||||||
|
Seq TIPCServiceRange
|
||||||
|
Timeout uint32
|
||||||
|
Filter uint32
|
||||||
|
Handle [8]uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type TIPCSIOCLNReq struct {
|
||||||
|
Peer uint32
|
||||||
|
Id uint32
|
||||||
|
Linkname [68]uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type TIPCSIOCNodeIDReq struct {
|
||||||
|
Peer uint32
|
||||||
|
Id [16]uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type PPSKInfo struct {
|
||||||
|
Assert_sequence uint32
|
||||||
|
Clear_sequence uint32
|
||||||
|
Assert_tu PPSKTime
|
||||||
|
Clear_tu PPSKTime
|
||||||
|
Current_mode int32
|
||||||
|
_ [4]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
PPS_GETPARAMS = 0x400470a1
|
||||||
|
PPS_SETPARAMS = 0x800470a2
|
||||||
|
PPS_GETCAP = 0x400470a3
|
||||||
|
PPS_FETCH = 0xc00470a4
|
||||||
|
)
|
||||||
|
|
@ -1334,7 +1334,11 @@ func (absoluteSD *SECURITY_DESCRIPTOR) ToSelfRelative() (selfRelativeSD *SECURIT
|
||||||
}
|
}
|
||||||
|
|
||||||
func (selfRelativeSD *SECURITY_DESCRIPTOR) copySelfRelativeSecurityDescriptor() *SECURITY_DESCRIPTOR {
|
func (selfRelativeSD *SECURITY_DESCRIPTOR) copySelfRelativeSecurityDescriptor() *SECURITY_DESCRIPTOR {
|
||||||
sdLen := (int)(selfRelativeSD.Length())
|
sdLen := int(selfRelativeSD.Length())
|
||||||
|
const min = int(unsafe.Sizeof(SECURITY_DESCRIPTOR{}))
|
||||||
|
if sdLen < min {
|
||||||
|
sdLen = min
|
||||||
|
}
|
||||||
|
|
||||||
var src []byte
|
var src []byte
|
||||||
h := (*unsafeheader.Slice)(unsafe.Pointer(&src))
|
h := (*unsafeheader.Slice)(unsafe.Pointer(&src))
|
||||||
|
|
@ -1342,7 +1346,15 @@ func (selfRelativeSD *SECURITY_DESCRIPTOR) copySelfRelativeSecurityDescriptor()
|
||||||
h.Len = sdLen
|
h.Len = sdLen
|
||||||
h.Cap = sdLen
|
h.Cap = sdLen
|
||||||
|
|
||||||
dst := make([]byte, sdLen)
|
const psize = int(unsafe.Sizeof(uintptr(0)))
|
||||||
|
|
||||||
|
var dst []byte
|
||||||
|
h = (*unsafeheader.Slice)(unsafe.Pointer(&dst))
|
||||||
|
alloc := make([]uintptr, (sdLen+psize-1)/psize)
|
||||||
|
h.Data = (*unsafeheader.Slice)(unsafe.Pointer(&alloc)).Data
|
||||||
|
h.Len = sdLen
|
||||||
|
h.Cap = sdLen
|
||||||
|
|
||||||
copy(dst, src)
|
copy(dst, src)
|
||||||
return (*SECURITY_DESCRIPTOR)(unsafe.Pointer(&dst[0]))
|
return (*SECURITY_DESCRIPTOR)(unsafe.Pointer(&dst[0]))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ loop:
|
||||||
err = transform.ErrShortSrc
|
err = transform.ErrShortSrc
|
||||||
break loop
|
break loop
|
||||||
}
|
}
|
||||||
r = utf8.RuneError
|
r, size = utf8.RuneError, 1
|
||||||
goto write
|
goto write
|
||||||
}
|
}
|
||||||
size = 2
|
size = 2
|
||||||
|
|
|
||||||
|
|
@ -303,9 +303,17 @@ func (t Tag) Extensions() []string {
|
||||||
// are of the allowed values defined for the Unicode locale extension ('u') in
|
// are of the allowed values defined for the Unicode locale extension ('u') in
|
||||||
// https://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers.
|
// https://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers.
|
||||||
// TypeForKey will traverse the inheritance chain to get the correct value.
|
// TypeForKey will traverse the inheritance chain to get the correct value.
|
||||||
|
//
|
||||||
|
// If there are multiple types associated with a key, only the first will be
|
||||||
|
// returned. If there is no type associated with a key, it returns the empty
|
||||||
|
// string.
|
||||||
func (t Tag) TypeForKey(key string) string {
|
func (t Tag) TypeForKey(key string) string {
|
||||||
if start, end, _ := t.findTypeForKey(key); end != start {
|
if _, start, end, _ := t.findTypeForKey(key); end != start {
|
||||||
return t.str[start:end]
|
s := t.str[start:end]
|
||||||
|
if p := strings.IndexByte(s, '-'); p >= 0 {
|
||||||
|
s = s[:p]
|
||||||
|
}
|
||||||
|
return s
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
@ -329,13 +337,13 @@ func (t Tag) SetTypeForKey(key, value string) (Tag, error) {
|
||||||
|
|
||||||
// Remove the setting if value is "".
|
// Remove the setting if value is "".
|
||||||
if value == "" {
|
if value == "" {
|
||||||
start, end, _ := t.findTypeForKey(key)
|
start, sep, end, _ := t.findTypeForKey(key)
|
||||||
if start != end {
|
if start != sep {
|
||||||
// Remove key tag and leading '-'.
|
|
||||||
start -= 4
|
|
||||||
|
|
||||||
// Remove a possible empty extension.
|
// Remove a possible empty extension.
|
||||||
if (end == len(t.str) || t.str[end+2] == '-') && t.str[start-2] == '-' {
|
switch {
|
||||||
|
case t.str[start-2] != '-': // has previous elements.
|
||||||
|
case end == len(t.str), // end of string
|
||||||
|
end+2 < len(t.str) && t.str[end+2] == '-': // end of extension
|
||||||
start -= 2
|
start -= 2
|
||||||
}
|
}
|
||||||
if start == int(t.pVariant) && end == len(t.str) {
|
if start == int(t.pVariant) && end == len(t.str) {
|
||||||
|
|
@ -381,14 +389,14 @@ func (t Tag) SetTypeForKey(key, value string) (Tag, error) {
|
||||||
t.str = string(buf[:uStart+len(b)])
|
t.str = string(buf[:uStart+len(b)])
|
||||||
} else {
|
} else {
|
||||||
s := t.str
|
s := t.str
|
||||||
start, end, hasExt := t.findTypeForKey(key)
|
start, sep, end, hasExt := t.findTypeForKey(key)
|
||||||
if start == end {
|
if start == sep {
|
||||||
if hasExt {
|
if hasExt {
|
||||||
b = b[2:]
|
b = b[2:]
|
||||||
}
|
}
|
||||||
t.str = fmt.Sprintf("%s-%s%s", s[:start], b, s[end:])
|
t.str = fmt.Sprintf("%s-%s%s", s[:sep], b, s[end:])
|
||||||
} else {
|
} else {
|
||||||
t.str = fmt.Sprintf("%s%s%s", s[:start], value, s[end:])
|
t.str = fmt.Sprintf("%s-%s%s", s[:start+3], value, s[end:])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return t, nil
|
return t, nil
|
||||||
|
|
@ -399,10 +407,10 @@ func (t Tag) SetTypeForKey(key, value string) (Tag, error) {
|
||||||
// wasn't found. The hasExt return value reports whether an -u extension was present.
|
// wasn't found. The hasExt return value reports whether an -u extension was present.
|
||||||
// Note: the extensions are typically very small and are likely to contain
|
// Note: the extensions are typically very small and are likely to contain
|
||||||
// only one key-type pair.
|
// only one key-type pair.
|
||||||
func (t Tag) findTypeForKey(key string) (start, end int, hasExt bool) {
|
func (t Tag) findTypeForKey(key string) (start, sep, end int, hasExt bool) {
|
||||||
p := int(t.pExt)
|
p := int(t.pExt)
|
||||||
if len(key) != 2 || p == len(t.str) || p == 0 {
|
if len(key) != 2 || p == len(t.str) || p == 0 {
|
||||||
return p, p, false
|
return p, p, p, false
|
||||||
}
|
}
|
||||||
s := t.str
|
s := t.str
|
||||||
|
|
||||||
|
|
@ -410,10 +418,10 @@ func (t Tag) findTypeForKey(key string) (start, end int, hasExt bool) {
|
||||||
for p++; s[p] != 'u'; p++ {
|
for p++; s[p] != 'u'; p++ {
|
||||||
if s[p] > 'u' {
|
if s[p] > 'u' {
|
||||||
p--
|
p--
|
||||||
return p, p, false
|
return p, p, p, false
|
||||||
}
|
}
|
||||||
if p = nextExtension(s, p); p == len(s) {
|
if p = nextExtension(s, p); p == len(s) {
|
||||||
return len(s), len(s), false
|
return len(s), len(s), len(s), false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Proceed to the hyphen following the extension name.
|
// Proceed to the hyphen following the extension name.
|
||||||
|
|
@ -424,40 +432,28 @@ func (t Tag) findTypeForKey(key string) (start, end int, hasExt bool) {
|
||||||
|
|
||||||
// Iterate over keys until we get the end of a section.
|
// Iterate over keys until we get the end of a section.
|
||||||
for {
|
for {
|
||||||
// p points to the hyphen preceding the current token.
|
end = p
|
||||||
if p3 := p + 3; s[p3] == '-' {
|
for p++; p < len(s) && s[p] != '-'; p++ {
|
||||||
// Found a key.
|
|
||||||
// Check whether we just processed the key that was requested.
|
|
||||||
if curKey == key {
|
|
||||||
return start, p, true
|
|
||||||
}
|
}
|
||||||
// Set to the next key and continue scanning type tokens.
|
n := p - end - 1
|
||||||
curKey = s[p+1 : p3]
|
if n <= 2 && curKey == key {
|
||||||
|
if sep < end {
|
||||||
|
sep++
|
||||||
|
}
|
||||||
|
return start, sep, end, true
|
||||||
|
}
|
||||||
|
switch n {
|
||||||
|
case 0, // invalid string
|
||||||
|
1: // next extension
|
||||||
|
return end, end, end, true
|
||||||
|
case 2:
|
||||||
|
// next key
|
||||||
|
curKey = s[end+1 : p]
|
||||||
if curKey > key {
|
if curKey > key {
|
||||||
return p, p, true
|
return end, end, end, true
|
||||||
}
|
}
|
||||||
// Start of the type token sequence.
|
start = end
|
||||||
start = p + 4
|
sep = p
|
||||||
// A type is at least 3 characters long.
|
|
||||||
p += 7 // 4 + 3
|
|
||||||
} else {
|
|
||||||
// Attribute or type, which is at least 3 characters long.
|
|
||||||
p += 4
|
|
||||||
}
|
|
||||||
// p points past the third character of a type or attribute.
|
|
||||||
max := p + 5 // maximum length of token plus hyphen.
|
|
||||||
if len(s) < max {
|
|
||||||
max = len(s)
|
|
||||||
}
|
|
||||||
for ; p < max && s[p] != '-'; p++ {
|
|
||||||
}
|
|
||||||
// Bail if we have exhausted all tokens or if the next token starts
|
|
||||||
// a new extension.
|
|
||||||
if p == len(s) || s[p+2] == '-' {
|
|
||||||
if curKey == key {
|
|
||||||
return start, p, true
|
|
||||||
}
|
|
||||||
return p, p, true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -133,14 +133,15 @@ func (s *scanner) resizeRange(oldStart, oldEnd, newSize int) {
|
||||||
s.start = oldStart
|
s.start = oldStart
|
||||||
if end := oldStart + newSize; end != oldEnd {
|
if end := oldStart + newSize; end != oldEnd {
|
||||||
diff := end - oldEnd
|
diff := end - oldEnd
|
||||||
if end < cap(s.b) {
|
var b []byte
|
||||||
b := make([]byte, len(s.b)+diff)
|
if n := len(s.b) + diff; n > cap(s.b) {
|
||||||
|
b = make([]byte, n)
|
||||||
copy(b, s.b[:oldStart])
|
copy(b, s.b[:oldStart])
|
||||||
|
} else {
|
||||||
|
b = s.b[:n]
|
||||||
|
}
|
||||||
copy(b[end:], s.b[oldEnd:])
|
copy(b[end:], s.b[oldEnd:])
|
||||||
s.b = b
|
s.b = b
|
||||||
} else {
|
|
||||||
s.b = append(s.b[end:], s.b[oldEnd:]...)
|
|
||||||
}
|
|
||||||
s.next = end + (s.next - s.end)
|
s.next = end + (s.next - s.end)
|
||||||
s.end = end
|
s.end = end
|
||||||
}
|
}
|
||||||
|
|
@ -482,7 +483,7 @@ func parseExtensions(scan *scanner) int {
|
||||||
func parseExtension(scan *scanner) int {
|
func parseExtension(scan *scanner) int {
|
||||||
start, end := scan.start, scan.end
|
start, end := scan.start, scan.end
|
||||||
switch scan.token[0] {
|
switch scan.token[0] {
|
||||||
case 'u':
|
case 'u': // https://www.ietf.org/rfc/rfc6067.txt
|
||||||
attrStart := end
|
attrStart := end
|
||||||
scan.scan()
|
scan.scan()
|
||||||
for last := []byte{}; len(scan.token) > 2; scan.scan() {
|
for last := []byte{}; len(scan.token) > 2; scan.scan() {
|
||||||
|
|
@ -502,27 +503,29 @@ func parseExtension(scan *scanner) int {
|
||||||
last = scan.token
|
last = scan.token
|
||||||
end = scan.end
|
end = scan.end
|
||||||
}
|
}
|
||||||
|
// Scan key-type sequences. A key is of length 2 and may be followed
|
||||||
|
// by 0 or more "type" subtags from 3 to the maximum of 8 letters.
|
||||||
var last, key []byte
|
var last, key []byte
|
||||||
for attrEnd := end; len(scan.token) == 2; last = key {
|
for attrEnd := end; len(scan.token) == 2; last = key {
|
||||||
key = scan.token
|
key = scan.token
|
||||||
keyEnd := scan.end
|
end = scan.end
|
||||||
end = scan.acceptMinSize(3)
|
for scan.scan(); end < scan.end && len(scan.token) > 2; scan.scan() {
|
||||||
|
end = scan.end
|
||||||
|
}
|
||||||
// TODO: check key value validity
|
// TODO: check key value validity
|
||||||
if keyEnd == end || bytes.Compare(key, last) != 1 {
|
if bytes.Compare(key, last) != 1 || scan.err != nil {
|
||||||
// We have an invalid key or the keys are not sorted.
|
// We have an invalid key or the keys are not sorted.
|
||||||
// Start scanning keys from scratch and reorder.
|
// Start scanning keys from scratch and reorder.
|
||||||
p := attrEnd + 1
|
p := attrEnd + 1
|
||||||
scan.next = p
|
scan.next = p
|
||||||
keys := [][]byte{}
|
keys := [][]byte{}
|
||||||
for scan.scan(); len(scan.token) == 2; {
|
for scan.scan(); len(scan.token) == 2; {
|
||||||
keyStart, keyEnd := scan.start, scan.end
|
keyStart := scan.start
|
||||||
end = scan.acceptMinSize(3)
|
end = scan.end
|
||||||
if keyEnd != end {
|
for scan.scan(); end < scan.end && len(scan.token) > 2; scan.scan() {
|
||||||
keys = append(keys, scan.b[keyStart:end])
|
end = scan.end
|
||||||
} else {
|
|
||||||
scan.setError(ErrSyntax)
|
|
||||||
end = keyStart
|
|
||||||
}
|
}
|
||||||
|
keys = append(keys, scan.b[keyStart:end])
|
||||||
}
|
}
|
||||||
sort.Stable(bytesSort{keys, 2})
|
sort.Stable(bytesSort{keys, 2})
|
||||||
if n := len(keys); n > 0 {
|
if n := len(keys); n > 0 {
|
||||||
|
|
@ -546,7 +549,7 @@ func parseExtension(scan *scanner) int {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 't':
|
case 't': // https://www.ietf.org/rfc/rfc6497.txt
|
||||||
scan.scan()
|
scan.scan()
|
||||||
if n := len(scan.token); n >= 2 && n <= 3 && isAlpha(scan.token[1]) {
|
if n := len(scan.token); n >= 2 && n <= 3 && isAlpha(scan.token[1]) {
|
||||||
_, end = parseTag(scan)
|
_, end = parseTag(scan)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build !go1.2
|
||||||
// +build !go1.2
|
// +build !go1.2
|
||||||
|
|
||||||
package language
|
package language
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build go1.2
|
||||||
// +build go1.2
|
// +build go1.2
|
||||||
|
|
||||||
package language
|
package language
|
||||||
|
|
|
||||||
|
|
@ -412,6 +412,10 @@ func (t Tag) Extensions() []Extension {
|
||||||
// are of the allowed values defined for the Unicode locale extension ('u') in
|
// are of the allowed values defined for the Unicode locale extension ('u') in
|
||||||
// https://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers.
|
// https://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers.
|
||||||
// TypeForKey will traverse the inheritance chain to get the correct value.
|
// TypeForKey will traverse the inheritance chain to get the correct value.
|
||||||
|
//
|
||||||
|
// If there are multiple types associated with a key, only the first will be
|
||||||
|
// returned. If there is no type associated with a key, it returns the empty
|
||||||
|
// string.
|
||||||
func (t Tag) TypeForKey(key string) string {
|
func (t Tag) TypeForKey(key string) string {
|
||||||
if !compact.Tag(t).MayHaveExtensions() {
|
if !compact.Tag(t).MayHaveExtensions() {
|
||||||
if key != "rg" && key != "va" {
|
if key != "rg" && key != "va" {
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ const (
|
||||||
_Zzzz = 251
|
_Zzzz = 251
|
||||||
)
|
)
|
||||||
|
|
||||||
var regionToGroups = []uint8{ // 357 elements
|
var regionToGroups = []uint8{ // 358 elements
|
||||||
// Entry 0 - 3F
|
// Entry 0 - 3F
|
||||||
0x00, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x04,
|
0x00, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x04,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x00,
|
||||||
|
|
@ -98,8 +98,8 @@ var regionToGroups = []uint8{ // 357 elements
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
} // Size: 381 bytes
|
} // Size: 382 bytes
|
||||||
|
|
||||||
var paradigmLocales = [][3]uint16{ // 3 elements
|
var paradigmLocales = [][3]uint16{ // 3 elements
|
||||||
0: [3]uint16{0x139, 0x0, 0x7b},
|
0: [3]uint16{0x139, 0x0, 0x7b},
|
||||||
|
|
@ -295,4 +295,4 @@ var matchRegion = []regionIntelligibility{ // 15 elements
|
||||||
14: {lang: 0x529, script: 0x3c, group: 0x80, distance: 0x5},
|
14: {lang: 0x529, script: 0x3c, group: 0x80, distance: 0x5},
|
||||||
} // Size: 114 bytes
|
} // Size: 114 bytes
|
||||||
|
|
||||||
// Total table size 1471 bytes (1KiB); checksum: 4CB1CD46
|
// Total table size 1472 bytes (1KiB); checksum: F86C669
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build go1.10
|
||||||
// +build go1.10
|
// +build go1.10
|
||||||
|
|
||||||
package bidirule
|
package bidirule
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build !go1.10
|
||||||
// +build !go1.10
|
// +build !go1.10
|
||||||
|
|
||||||
package bidirule
|
package bidirule
|
||||||
|
|
|
||||||
|
|
@ -12,15 +12,14 @@
|
||||||
// and without notice.
|
// and without notice.
|
||||||
package bidi // import "golang.org/x/text/unicode/bidi"
|
package bidi // import "golang.org/x/text/unicode/bidi"
|
||||||
|
|
||||||
// TODO:
|
// TODO
|
||||||
// The following functionality would not be hard to implement, but hinges on
|
|
||||||
// the definition of a Segmenter interface. For now this is up to the user.
|
|
||||||
// - Iterate over paragraphs
|
|
||||||
// - Segmenter to iterate over runs directly from a given text.
|
|
||||||
// Also:
|
|
||||||
// - Transformer for reordering?
|
// - Transformer for reordering?
|
||||||
// - Transformer (validator, really) for Bidi Rule.
|
// - Transformer (validator, really) for Bidi Rule.
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
)
|
||||||
|
|
||||||
// This API tries to avoid dealing with embedding levels for now. Under the hood
|
// This API tries to avoid dealing with embedding levels for now. Under the hood
|
||||||
// these will be computed, but the question is to which extent the user should
|
// these will be computed, but the question is to which extent the user should
|
||||||
// know they exist. We should at some point allow the user to specify an
|
// know they exist. We should at some point allow the user to specify an
|
||||||
|
|
@ -49,7 +48,9 @@ const (
|
||||||
Neutral
|
Neutral
|
||||||
)
|
)
|
||||||
|
|
||||||
type options struct{}
|
type options struct {
|
||||||
|
defaultDirection Direction
|
||||||
|
}
|
||||||
|
|
||||||
// An Option is an option for Bidi processing.
|
// An Option is an option for Bidi processing.
|
||||||
type Option func(*options)
|
type Option func(*options)
|
||||||
|
|
@ -66,12 +67,62 @@ type Option func(*options)
|
||||||
// DefaultDirection sets the default direction for a Paragraph. The direction is
|
// DefaultDirection sets the default direction for a Paragraph. The direction is
|
||||||
// overridden if the text contains directional characters.
|
// overridden if the text contains directional characters.
|
||||||
func DefaultDirection(d Direction) Option {
|
func DefaultDirection(d Direction) Option {
|
||||||
panic("unimplemented")
|
return func(opts *options) {
|
||||||
|
opts.defaultDirection = d
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A Paragraph holds a single Paragraph for Bidi processing.
|
// A Paragraph holds a single Paragraph for Bidi processing.
|
||||||
type Paragraph struct {
|
type Paragraph struct {
|
||||||
// buffers
|
p []byte
|
||||||
|
o Ordering
|
||||||
|
opts []Option
|
||||||
|
types []Class
|
||||||
|
pairTypes []bracketType
|
||||||
|
pairValues []rune
|
||||||
|
runes []rune
|
||||||
|
options options
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize the p.pairTypes, p.pairValues and p.types from the input previously
|
||||||
|
// set by p.SetBytes() or p.SetString(). Also limit the input up to (and including) a paragraph
|
||||||
|
// separator (bidi class B).
|
||||||
|
//
|
||||||
|
// The function p.Order() needs these values to be set, so this preparation could be postponed.
|
||||||
|
// But since the SetBytes and SetStrings functions return the length of the input up to the paragraph
|
||||||
|
// separator, the whole input needs to be processed anyway and should not be done twice.
|
||||||
|
//
|
||||||
|
// The function has the same return values as SetBytes() / SetString()
|
||||||
|
func (p *Paragraph) prepareInput() (n int, err error) {
|
||||||
|
p.runes = bytes.Runes(p.p)
|
||||||
|
bytecount := 0
|
||||||
|
// clear slices from previous SetString or SetBytes
|
||||||
|
p.pairTypes = nil
|
||||||
|
p.pairValues = nil
|
||||||
|
p.types = nil
|
||||||
|
|
||||||
|
for _, r := range p.runes {
|
||||||
|
props, i := LookupRune(r)
|
||||||
|
bytecount += i
|
||||||
|
cls := props.Class()
|
||||||
|
if cls == B {
|
||||||
|
return bytecount, nil
|
||||||
|
}
|
||||||
|
p.types = append(p.types, cls)
|
||||||
|
if props.IsOpeningBracket() {
|
||||||
|
p.pairTypes = append(p.pairTypes, bpOpen)
|
||||||
|
p.pairValues = append(p.pairValues, r)
|
||||||
|
} else if props.IsBracket() {
|
||||||
|
// this must be a closing bracket,
|
||||||
|
// since IsOpeningBracket is not true
|
||||||
|
p.pairTypes = append(p.pairTypes, bpClose)
|
||||||
|
p.pairValues = append(p.pairValues, r)
|
||||||
|
} else {
|
||||||
|
p.pairTypes = append(p.pairTypes, bpNone)
|
||||||
|
p.pairValues = append(p.pairValues, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bytecount, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetBytes configures p for the given paragraph text. It replaces text
|
// SetBytes configures p for the given paragraph text. It replaces text
|
||||||
|
|
@ -80,70 +131,150 @@ type Paragraph struct {
|
||||||
// consumed from b including this separator. Error may be non-nil if options are
|
// consumed from b including this separator. Error may be non-nil if options are
|
||||||
// given.
|
// given.
|
||||||
func (p *Paragraph) SetBytes(b []byte, opts ...Option) (n int, err error) {
|
func (p *Paragraph) SetBytes(b []byte, opts ...Option) (n int, err error) {
|
||||||
panic("unimplemented")
|
p.p = b
|
||||||
|
p.opts = opts
|
||||||
|
return p.prepareInput()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetString configures p for the given paragraph text. It replaces text
|
// SetString configures s for the given paragraph text. It replaces text
|
||||||
// previously set by SetBytes or SetString. If b contains a paragraph separator
|
// previously set by SetBytes or SetString. If s contains a paragraph separator
|
||||||
// it will only process the first paragraph and report the number of bytes
|
// it will only process the first paragraph and report the number of bytes
|
||||||
// consumed from b including this separator. Error may be non-nil if options are
|
// consumed from s including this separator. Error may be non-nil if options are
|
||||||
// given.
|
// given.
|
||||||
func (p *Paragraph) SetString(s string, opts ...Option) (n int, err error) {
|
func (p *Paragraph) SetString(s string, opts ...Option) (n int, err error) {
|
||||||
panic("unimplemented")
|
p.p = []byte(s)
|
||||||
|
p.opts = opts
|
||||||
|
return p.prepareInput()
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsLeftToRight reports whether the principle direction of rendering for this
|
// IsLeftToRight reports whether the principle direction of rendering for this
|
||||||
// paragraphs is left-to-right. If this returns false, the principle direction
|
// paragraphs is left-to-right. If this returns false, the principle direction
|
||||||
// of rendering is right-to-left.
|
// of rendering is right-to-left.
|
||||||
func (p *Paragraph) IsLeftToRight() bool {
|
func (p *Paragraph) IsLeftToRight() bool {
|
||||||
panic("unimplemented")
|
return p.Direction() == LeftToRight
|
||||||
}
|
}
|
||||||
|
|
||||||
// Direction returns the direction of the text of this paragraph.
|
// Direction returns the direction of the text of this paragraph.
|
||||||
//
|
//
|
||||||
// The direction may be LeftToRight, RightToLeft, Mixed, or Neutral.
|
// The direction may be LeftToRight, RightToLeft, Mixed, or Neutral.
|
||||||
func (p *Paragraph) Direction() Direction {
|
func (p *Paragraph) Direction() Direction {
|
||||||
panic("unimplemented")
|
return p.o.Direction()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: what happens if the position is > len(input)? This should return an error.
|
||||||
|
|
||||||
// RunAt reports the Run at the given position of the input text.
|
// RunAt reports the Run at the given position of the input text.
|
||||||
//
|
//
|
||||||
// This method can be used for computing line breaks on paragraphs.
|
// This method can be used for computing line breaks on paragraphs.
|
||||||
func (p *Paragraph) RunAt(pos int) Run {
|
func (p *Paragraph) RunAt(pos int) Run {
|
||||||
panic("unimplemented")
|
c := 0
|
||||||
|
runNumber := 0
|
||||||
|
for i, r := range p.o.runes {
|
||||||
|
c += len(r)
|
||||||
|
if pos < c {
|
||||||
|
runNumber = i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return p.o.Run(runNumber)
|
||||||
|
}
|
||||||
|
|
||||||
|
func calculateOrdering(levels []level, runes []rune) Ordering {
|
||||||
|
var curDir Direction
|
||||||
|
|
||||||
|
prevDir := Neutral
|
||||||
|
prevI := 0
|
||||||
|
|
||||||
|
o := Ordering{}
|
||||||
|
// lvl = 0,2,4,...: left to right
|
||||||
|
// lvl = 1,3,5,...: right to left
|
||||||
|
for i, lvl := range levels {
|
||||||
|
if lvl%2 == 0 {
|
||||||
|
curDir = LeftToRight
|
||||||
|
} else {
|
||||||
|
curDir = RightToLeft
|
||||||
|
}
|
||||||
|
if curDir != prevDir {
|
||||||
|
if i > 0 {
|
||||||
|
o.runes = append(o.runes, runes[prevI:i])
|
||||||
|
o.directions = append(o.directions, prevDir)
|
||||||
|
o.startpos = append(o.startpos, prevI)
|
||||||
|
}
|
||||||
|
prevI = i
|
||||||
|
prevDir = curDir
|
||||||
|
}
|
||||||
|
}
|
||||||
|
o.runes = append(o.runes, runes[prevI:])
|
||||||
|
o.directions = append(o.directions, prevDir)
|
||||||
|
o.startpos = append(o.startpos, prevI)
|
||||||
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
// Order computes the visual ordering of all the runs in a Paragraph.
|
// Order computes the visual ordering of all the runs in a Paragraph.
|
||||||
func (p *Paragraph) Order() (Ordering, error) {
|
func (p *Paragraph) Order() (Ordering, error) {
|
||||||
panic("unimplemented")
|
if len(p.types) == 0 {
|
||||||
|
return Ordering{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, fn := range p.opts {
|
||||||
|
fn(&p.options)
|
||||||
|
}
|
||||||
|
lvl := level(-1)
|
||||||
|
if p.options.defaultDirection == RightToLeft {
|
||||||
|
lvl = 1
|
||||||
|
}
|
||||||
|
para, err := newParagraph(p.types, p.pairTypes, p.pairValues, lvl)
|
||||||
|
if err != nil {
|
||||||
|
return Ordering{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
levels := para.getLevels([]int{len(p.types)})
|
||||||
|
|
||||||
|
p.o = calculateOrdering(levels, p.runes)
|
||||||
|
return p.o, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Line computes the visual ordering of runs for a single line starting and
|
// Line computes the visual ordering of runs for a single line starting and
|
||||||
// ending at the given positions in the original text.
|
// ending at the given positions in the original text.
|
||||||
func (p *Paragraph) Line(start, end int) (Ordering, error) {
|
func (p *Paragraph) Line(start, end int) (Ordering, error) {
|
||||||
panic("unimplemented")
|
lineTypes := p.types[start:end]
|
||||||
|
para, err := newParagraph(lineTypes, p.pairTypes[start:end], p.pairValues[start:end], -1)
|
||||||
|
if err != nil {
|
||||||
|
return Ordering{}, err
|
||||||
|
}
|
||||||
|
levels := para.getLevels([]int{len(lineTypes)})
|
||||||
|
o := calculateOrdering(levels, p.runes[start:end])
|
||||||
|
return o, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// An Ordering holds the computed visual order of runs of a Paragraph. Calling
|
// An Ordering holds the computed visual order of runs of a Paragraph. Calling
|
||||||
// SetBytes or SetString on the originating Paragraph invalidates an Ordering.
|
// SetBytes or SetString on the originating Paragraph invalidates an Ordering.
|
||||||
// The methods of an Ordering should only be called by one goroutine at a time.
|
// The methods of an Ordering should only be called by one goroutine at a time.
|
||||||
type Ordering struct{}
|
type Ordering struct {
|
||||||
|
runes [][]rune
|
||||||
|
directions []Direction
|
||||||
|
startpos []int
|
||||||
|
}
|
||||||
|
|
||||||
// Direction reports the directionality of the runs.
|
// Direction reports the directionality of the runs.
|
||||||
//
|
//
|
||||||
// The direction may be LeftToRight, RightToLeft, Mixed, or Neutral.
|
// The direction may be LeftToRight, RightToLeft, Mixed, or Neutral.
|
||||||
func (o *Ordering) Direction() Direction {
|
func (o *Ordering) Direction() Direction {
|
||||||
panic("unimplemented")
|
return o.directions[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
// NumRuns returns the number of runs.
|
// NumRuns returns the number of runs.
|
||||||
func (o *Ordering) NumRuns() int {
|
func (o *Ordering) NumRuns() int {
|
||||||
panic("unimplemented")
|
return len(o.runes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run returns the ith run within the ordering.
|
// Run returns the ith run within the ordering.
|
||||||
func (o *Ordering) Run(i int) Run {
|
func (o *Ordering) Run(i int) Run {
|
||||||
panic("unimplemented")
|
r := Run{
|
||||||
|
runes: o.runes[i],
|
||||||
|
direction: o.directions[i],
|
||||||
|
startpos: o.startpos[i],
|
||||||
|
}
|
||||||
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: perhaps with options.
|
// TODO: perhaps with options.
|
||||||
|
|
@ -155,16 +286,19 @@ func (o *Ordering) Run(i int) Run {
|
||||||
|
|
||||||
// A Run is a continuous sequence of characters of a single direction.
|
// A Run is a continuous sequence of characters of a single direction.
|
||||||
type Run struct {
|
type Run struct {
|
||||||
|
runes []rune
|
||||||
|
direction Direction
|
||||||
|
startpos int
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns the text of the run in its original order.
|
// String returns the text of the run in its original order.
|
||||||
func (r *Run) String() string {
|
func (r *Run) String() string {
|
||||||
panic("unimplemented")
|
return string(r.runes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bytes returns the text of the run in its original order.
|
// Bytes returns the text of the run in its original order.
|
||||||
func (r *Run) Bytes() []byte {
|
func (r *Run) Bytes() []byte {
|
||||||
panic("unimplemented")
|
return []byte(r.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: methods for
|
// TODO: methods for
|
||||||
|
|
@ -174,25 +308,52 @@ func (r *Run) Bytes() []byte {
|
||||||
|
|
||||||
// Direction reports the direction of the run.
|
// Direction reports the direction of the run.
|
||||||
func (r *Run) Direction() Direction {
|
func (r *Run) Direction() Direction {
|
||||||
panic("unimplemented")
|
return r.direction
|
||||||
}
|
}
|
||||||
|
|
||||||
// Position of the Run within the text passed to SetBytes or SetString of the
|
// Pos returns the position of the Run within the text passed to SetBytes or SetString of the
|
||||||
// originating Paragraph value.
|
// originating Paragraph value.
|
||||||
func (r *Run) Pos() (start, end int) {
|
func (r *Run) Pos() (start, end int) {
|
||||||
panic("unimplemented")
|
return r.startpos, r.startpos + len(r.runes) - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppendReverse reverses the order of characters of in, appends them to out,
|
// AppendReverse reverses the order of characters of in, appends them to out,
|
||||||
// and returns the result. Modifiers will still follow the runes they modify.
|
// and returns the result. Modifiers will still follow the runes they modify.
|
||||||
// Brackets are replaced with their counterparts.
|
// Brackets are replaced with their counterparts.
|
||||||
func AppendReverse(out, in []byte) []byte {
|
func AppendReverse(out, in []byte) []byte {
|
||||||
panic("unimplemented")
|
ret := make([]byte, len(in)+len(out))
|
||||||
|
copy(ret, out)
|
||||||
|
inRunes := bytes.Runes(in)
|
||||||
|
|
||||||
|
for i, r := range inRunes {
|
||||||
|
prop, _ := LookupRune(r)
|
||||||
|
if prop.IsBracket() {
|
||||||
|
inRunes[i] = prop.reverseBracket(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, j := 0, len(inRunes)-1; i < j; i, j = i+1, j-1 {
|
||||||
|
inRunes[i], inRunes[j] = inRunes[j], inRunes[i]
|
||||||
|
}
|
||||||
|
copy(ret[len(out):], string(inRunes))
|
||||||
|
|
||||||
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReverseString reverses the order of characters in s and returns a new string.
|
// ReverseString reverses the order of characters in s and returns a new string.
|
||||||
// Modifiers will still follow the runes they modify. Brackets are replaced with
|
// Modifiers will still follow the runes they modify. Brackets are replaced with
|
||||||
// their counterparts.
|
// their counterparts.
|
||||||
func ReverseString(s string) string {
|
func ReverseString(s string) string {
|
||||||
panic("unimplemented")
|
input := []rune(s)
|
||||||
|
li := len(input)
|
||||||
|
ret := make([]rune, li)
|
||||||
|
for i, r := range input {
|
||||||
|
prop, _ := LookupRune(r)
|
||||||
|
if prop.IsBracket() {
|
||||||
|
ret[li-i-1] = prop.reverseBracket(r)
|
||||||
|
} else {
|
||||||
|
ret[li-i-1] = r
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return string(ret)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,10 @@
|
||||||
|
|
||||||
package bidi
|
package bidi
|
||||||
|
|
||||||
import "log"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
)
|
||||||
|
|
||||||
// This implementation is a port based on the reference implementation found at:
|
// This implementation is a port based on the reference implementation found at:
|
||||||
// https://www.unicode.org/Public/PROGRAMS/BidiReferenceJava/
|
// https://www.unicode.org/Public/PROGRAMS/BidiReferenceJava/
|
||||||
|
|
@ -97,13 +100,20 @@ type paragraph struct {
|
||||||
// rune (suggested is the rune of the open bracket for opening and matching
|
// rune (suggested is the rune of the open bracket for opening and matching
|
||||||
// close brackets, after normalization). The embedding levels are optional, but
|
// close brackets, after normalization). The embedding levels are optional, but
|
||||||
// may be supplied to encode embedding levels of styled text.
|
// may be supplied to encode embedding levels of styled text.
|
||||||
//
|
func newParagraph(types []Class, pairTypes []bracketType, pairValues []rune, levels level) (*paragraph, error) {
|
||||||
// TODO: return an error.
|
var err error
|
||||||
func newParagraph(types []Class, pairTypes []bracketType, pairValues []rune, levels level) *paragraph {
|
if err = validateTypes(types); err != nil {
|
||||||
validateTypes(types)
|
return nil, err
|
||||||
validatePbTypes(pairTypes)
|
}
|
||||||
validatePbValues(pairValues, pairTypes)
|
if err = validatePbTypes(pairTypes); err != nil {
|
||||||
validateParagraphEmbeddingLevel(levels)
|
return nil, err
|
||||||
|
}
|
||||||
|
if err = validatePbValues(pairValues, pairTypes); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err = validateParagraphEmbeddingLevel(levels); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
p := ¶graph{
|
p := ¶graph{
|
||||||
initialTypes: append([]Class(nil), types...),
|
initialTypes: append([]Class(nil), types...),
|
||||||
|
|
@ -115,7 +125,7 @@ func newParagraph(types []Class, pairTypes []bracketType, pairValues []rune, lev
|
||||||
resultTypes: append([]Class(nil), types...),
|
resultTypes: append([]Class(nil), types...),
|
||||||
}
|
}
|
||||||
p.run()
|
p.run()
|
||||||
return p
|
return p, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *paragraph) Len() int { return len(p.initialTypes) }
|
func (p *paragraph) Len() int { return len(p.initialTypes) }
|
||||||
|
|
@ -1001,58 +1011,61 @@ func typeForLevel(level level) Class {
|
||||||
return R
|
return R
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: change validation to not panic
|
func validateTypes(types []Class) error {
|
||||||
|
|
||||||
func validateTypes(types []Class) {
|
|
||||||
if len(types) == 0 {
|
if len(types) == 0 {
|
||||||
log.Panic("types is null")
|
return fmt.Errorf("types is null")
|
||||||
}
|
}
|
||||||
for i, t := range types[:len(types)-1] {
|
for i, t := range types[:len(types)-1] {
|
||||||
if t == B {
|
if t == B {
|
||||||
log.Panicf("B type before end of paragraph at index: %d", i)
|
return fmt.Errorf("B type before end of paragraph at index: %d", i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateParagraphEmbeddingLevel(embeddingLevel level) {
|
func validateParagraphEmbeddingLevel(embeddingLevel level) error {
|
||||||
if embeddingLevel != implicitLevel &&
|
if embeddingLevel != implicitLevel &&
|
||||||
embeddingLevel != 0 &&
|
embeddingLevel != 0 &&
|
||||||
embeddingLevel != 1 {
|
embeddingLevel != 1 {
|
||||||
log.Panicf("illegal paragraph embedding level: %d", embeddingLevel)
|
return fmt.Errorf("illegal paragraph embedding level: %d", embeddingLevel)
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateLineBreaks(linebreaks []int, textLength int) {
|
func validateLineBreaks(linebreaks []int, textLength int) error {
|
||||||
prev := 0
|
prev := 0
|
||||||
for i, next := range linebreaks {
|
for i, next := range linebreaks {
|
||||||
if next <= prev {
|
if next <= prev {
|
||||||
log.Panicf("bad linebreak: %d at index: %d", next, i)
|
return fmt.Errorf("bad linebreak: %d at index: %d", next, i)
|
||||||
}
|
}
|
||||||
prev = next
|
prev = next
|
||||||
}
|
}
|
||||||
if prev != textLength {
|
if prev != textLength {
|
||||||
log.Panicf("last linebreak was %d, want %d", prev, textLength)
|
return fmt.Errorf("last linebreak was %d, want %d", prev, textLength)
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func validatePbTypes(pairTypes []bracketType) {
|
func validatePbTypes(pairTypes []bracketType) error {
|
||||||
if len(pairTypes) == 0 {
|
if len(pairTypes) == 0 {
|
||||||
log.Panic("pairTypes is null")
|
return fmt.Errorf("pairTypes is null")
|
||||||
}
|
}
|
||||||
for i, pt := range pairTypes {
|
for i, pt := range pairTypes {
|
||||||
switch pt {
|
switch pt {
|
||||||
case bpNone, bpOpen, bpClose:
|
case bpNone, bpOpen, bpClose:
|
||||||
default:
|
default:
|
||||||
log.Panicf("illegal pairType value at %d: %v", i, pairTypes[i])
|
return fmt.Errorf("illegal pairType value at %d: %v", i, pairTypes[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func validatePbValues(pairValues []rune, pairTypes []bracketType) {
|
func validatePbValues(pairValues []rune, pairTypes []bracketType) error {
|
||||||
if pairValues == nil {
|
if pairValues == nil {
|
||||||
log.Panic("pairValues is null")
|
return fmt.Errorf("pairValues is null")
|
||||||
}
|
}
|
||||||
if len(pairTypes) != len(pairValues) {
|
if len(pairTypes) != len(pairValues) {
|
||||||
log.Panic("pairTypes is different length from pairValues")
|
return fmt.Errorf("pairTypes is different length from pairValues")
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:build go1.10 && !go1.13
|
||||||
// +build go1.10,!go1.13
|
// +build go1.10,!go1.13
|
||||||
|
|
||||||
package bidi
|
package bidi
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:build go1.13 && !go1.14
|
||||||
// +build go1.13,!go1.14
|
// +build go1.13,!go1.14
|
||||||
|
|
||||||
package bidi
|
package bidi
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:build go1.14 && !go1.16
|
||||||
// +build go1.14,!go1.16
|
// +build go1.14,!go1.16
|
||||||
|
|
||||||
package bidi
|
package bidi
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:build go1.16
|
||||||
// +build go1.16
|
// +build go1.16
|
||||||
|
|
||||||
package bidi
|
package bidi
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:build !go1.10
|
||||||
// +build !go1.10
|
// +build !go1.10
|
||||||
|
|
||||||
package bidi
|
package bidi
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:build go1.10 && !go1.13
|
||||||
// +build go1.10,!go1.13
|
// +build go1.10,!go1.13
|
||||||
|
|
||||||
package norm
|
package norm
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:build go1.13 && !go1.14
|
||||||
// +build go1.13,!go1.14
|
// +build go1.13,!go1.14
|
||||||
|
|
||||||
package norm
|
package norm
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:build go1.14 && !go1.16
|
||||||
// +build go1.14,!go1.16
|
// +build go1.14,!go1.16
|
||||||
|
|
||||||
package norm
|
package norm
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:build go1.16
|
||||||
// +build go1.16
|
// +build go1.16
|
||||||
|
|
||||||
package norm
|
package norm
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:build !go1.10
|
||||||
// +build !go1.10
|
// +build !go1.10
|
||||||
|
|
||||||
package norm
|
package norm
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ package prototext
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
"google.golang.org/protobuf/internal/encoding/messageset"
|
"google.golang.org/protobuf/internal/encoding/messageset"
|
||||||
|
|
@ -23,6 +22,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Unmarshal reads the given []byte into the given proto.Message.
|
// Unmarshal reads the given []byte into the given proto.Message.
|
||||||
|
// The provided message must be mutable (e.g., a non-nil pointer to a message).
|
||||||
func Unmarshal(b []byte, m proto.Message) error {
|
func Unmarshal(b []byte, m proto.Message) error {
|
||||||
return UnmarshalOptions{}.Unmarshal(b, m)
|
return UnmarshalOptions{}.Unmarshal(b, m)
|
||||||
}
|
}
|
||||||
|
|
@ -51,8 +51,9 @@ type UnmarshalOptions struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unmarshal reads the given []byte and populates the given proto.Message using options in
|
// Unmarshal reads the given []byte and populates the given proto.Message
|
||||||
// UnmarshalOptions object.
|
// using options in the UnmarshalOptions object.
|
||||||
|
// The provided message must be mutable (e.g., a non-nil pointer to a message).
|
||||||
func (o UnmarshalOptions) Unmarshal(b []byte, m proto.Message) error {
|
func (o UnmarshalOptions) Unmarshal(b []byte, m proto.Message) error {
|
||||||
return o.unmarshal(b, m)
|
return o.unmarshal(b, m)
|
||||||
}
|
}
|
||||||
|
|
@ -158,21 +159,11 @@ func (d decoder) unmarshalMessage(m pref.Message, checkDelims bool) error {
|
||||||
switch tok.NameKind() {
|
switch tok.NameKind() {
|
||||||
case text.IdentName:
|
case text.IdentName:
|
||||||
name = pref.Name(tok.IdentName())
|
name = pref.Name(tok.IdentName())
|
||||||
fd = fieldDescs.ByName(name)
|
fd = fieldDescs.ByTextName(string(name))
|
||||||
if fd == nil {
|
|
||||||
// The proto name of a group field is in all lowercase,
|
|
||||||
// while the textproto field name is the group message name.
|
|
||||||
gd := fieldDescs.ByName(pref.Name(strings.ToLower(string(name))))
|
|
||||||
if gd != nil && gd.Kind() == pref.GroupKind && gd.Message().Name() == name {
|
|
||||||
fd = gd
|
|
||||||
}
|
|
||||||
} else if fd.Kind() == pref.GroupKind && fd.Message().Name() != name {
|
|
||||||
fd = nil // reset since field name is actually the message name
|
|
||||||
}
|
|
||||||
|
|
||||||
case text.TypeName:
|
case text.TypeName:
|
||||||
// Handle extensions only. This code path is not for Any.
|
// Handle extensions only. This code path is not for Any.
|
||||||
xt, xtErr = d.findExtension(pref.FullName(tok.TypeName()))
|
xt, xtErr = d.opts.Resolver.FindExtensionByName(pref.FullName(tok.TypeName()))
|
||||||
|
|
||||||
case text.FieldNumber:
|
case text.FieldNumber:
|
||||||
isFieldNumberName = true
|
isFieldNumberName = true
|
||||||
|
|
@ -269,15 +260,6 @@ func (d decoder) unmarshalMessage(m pref.Message, checkDelims bool) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// findExtension returns protoreflect.ExtensionType from the Resolver if found.
|
|
||||||
func (d decoder) findExtension(xtName pref.FullName) (pref.ExtensionType, error) {
|
|
||||||
xt, err := d.opts.Resolver.FindExtensionByName(xtName)
|
|
||||||
if err == nil {
|
|
||||||
return xt, nil
|
|
||||||
}
|
|
||||||
return messageset.FindMessageSetExtension(d.opts.Resolver, xtName)
|
|
||||||
}
|
|
||||||
|
|
||||||
// unmarshalSingular unmarshals a non-repeated field value specified by the
|
// unmarshalSingular unmarshals a non-repeated field value specified by the
|
||||||
// given FieldDescriptor.
|
// given FieldDescriptor.
|
||||||
func (d decoder) unmarshalSingular(fd pref.FieldDescriptor, m pref.Message) error {
|
func (d decoder) unmarshalSingular(fd pref.FieldDescriptor, m pref.Message) error {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ package prototext
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
|
|
@ -16,10 +15,11 @@ import (
|
||||||
"google.golang.org/protobuf/internal/errors"
|
"google.golang.org/protobuf/internal/errors"
|
||||||
"google.golang.org/protobuf/internal/flags"
|
"google.golang.org/protobuf/internal/flags"
|
||||||
"google.golang.org/protobuf/internal/genid"
|
"google.golang.org/protobuf/internal/genid"
|
||||||
"google.golang.org/protobuf/internal/mapsort"
|
"google.golang.org/protobuf/internal/order"
|
||||||
"google.golang.org/protobuf/internal/pragma"
|
"google.golang.org/protobuf/internal/pragma"
|
||||||
"google.golang.org/protobuf/internal/strs"
|
"google.golang.org/protobuf/internal/strs"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
|
"google.golang.org/protobuf/reflect/protoreflect"
|
||||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
"google.golang.org/protobuf/reflect/protoregistry"
|
"google.golang.org/protobuf/reflect/protoregistry"
|
||||||
)
|
)
|
||||||
|
|
@ -169,35 +169,15 @@ func (e encoder) marshalMessage(m pref.Message, inclDelims bool) error {
|
||||||
// If unable to expand, continue on to marshal Any as a regular message.
|
// If unable to expand, continue on to marshal Any as a regular message.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Marshal known fields.
|
// Marshal fields.
|
||||||
fieldDescs := messageDesc.Fields()
|
var err error
|
||||||
size := fieldDescs.Len()
|
order.RangeFields(m, order.IndexNameFieldOrder, func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
|
||||||
for i := 0; i < size; {
|
if err = e.marshalField(fd.TextName(), v, fd); err != nil {
|
||||||
fd := fieldDescs.Get(i)
|
return false
|
||||||
if od := fd.ContainingOneof(); od != nil {
|
|
||||||
fd = m.WhichOneof(od)
|
|
||||||
i += od.Fields().Len()
|
|
||||||
} else {
|
|
||||||
i++
|
|
||||||
}
|
}
|
||||||
|
return true
|
||||||
if fd == nil || !m.Has(fd) {
|
})
|
||||||
continue
|
if err != nil {
|
||||||
}
|
|
||||||
|
|
||||||
name := fd.Name()
|
|
||||||
// Use type name for group field name.
|
|
||||||
if fd.Kind() == pref.GroupKind {
|
|
||||||
name = fd.Message().Name()
|
|
||||||
}
|
|
||||||
val := m.Get(fd)
|
|
||||||
if err := e.marshalField(string(name), val, fd); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Marshal extensions.
|
|
||||||
if err := e.marshalExtensions(m); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -290,7 +270,7 @@ func (e encoder) marshalList(name string, list pref.List, fd pref.FieldDescripto
|
||||||
// marshalMap marshals the given protoreflect.Map as multiple name-value fields.
|
// marshalMap marshals the given protoreflect.Map as multiple name-value fields.
|
||||||
func (e encoder) marshalMap(name string, mmap pref.Map, fd pref.FieldDescriptor) error {
|
func (e encoder) marshalMap(name string, mmap pref.Map, fd pref.FieldDescriptor) error {
|
||||||
var err error
|
var err error
|
||||||
mapsort.Range(mmap, fd.MapKey().Kind(), func(key pref.MapKey, val pref.Value) bool {
|
order.RangeEntries(mmap, order.GenericKeyOrder, func(key pref.MapKey, val pref.Value) bool {
|
||||||
e.WriteName(name)
|
e.WriteName(name)
|
||||||
e.StartMessage()
|
e.StartMessage()
|
||||||
defer e.EndMessage()
|
defer e.EndMessage()
|
||||||
|
|
@ -311,48 +291,6 @@ func (e encoder) marshalMap(name string, mmap pref.Map, fd pref.FieldDescriptor)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// marshalExtensions marshals extension fields.
|
|
||||||
func (e encoder) marshalExtensions(m pref.Message) error {
|
|
||||||
type entry struct {
|
|
||||||
key string
|
|
||||||
value pref.Value
|
|
||||||
desc pref.FieldDescriptor
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get a sorted list based on field key first.
|
|
||||||
var entries []entry
|
|
||||||
m.Range(func(fd pref.FieldDescriptor, v pref.Value) bool {
|
|
||||||
if !fd.IsExtension() {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
// For MessageSet extensions, the name used is the parent message.
|
|
||||||
name := fd.FullName()
|
|
||||||
if messageset.IsMessageSetExtension(fd) {
|
|
||||||
name = name.Parent()
|
|
||||||
}
|
|
||||||
entries = append(entries, entry{
|
|
||||||
key: string(name),
|
|
||||||
value: v,
|
|
||||||
desc: fd,
|
|
||||||
})
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
// Sort extensions lexicographically.
|
|
||||||
sort.Slice(entries, func(i, j int) bool {
|
|
||||||
return entries[i].key < entries[j].key
|
|
||||||
})
|
|
||||||
|
|
||||||
// Write out sorted list.
|
|
||||||
for _, entry := range entries {
|
|
||||||
// Extension field name is the proto field name enclosed in [].
|
|
||||||
name := "[" + entry.key + "]"
|
|
||||||
if err := e.marshalField(name, entry.value, entry.desc); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// marshalUnknown parses the given []byte and marshals fields out.
|
// marshalUnknown parses the given []byte and marshals fields out.
|
||||||
// This function assumes proper encoding in the given []byte.
|
// This function assumes proper encoding in the given []byte.
|
||||||
func (e encoder) marshalUnknown(b []byte) {
|
func (e encoder) marshalUnknown(b []byte) {
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,8 @@ func formatListOpt(vs list, isRoot, allowMulti bool) string {
|
||||||
name = "FileImports"
|
name = "FileImports"
|
||||||
case pref.Descriptor:
|
case pref.Descriptor:
|
||||||
name = reflect.ValueOf(vs).MethodByName("Get").Type().Out(0).Name() + "s"
|
name = reflect.ValueOf(vs).MethodByName("Get").Type().Out(0).Name() + "s"
|
||||||
|
default:
|
||||||
|
name = reflect.ValueOf(vs).Elem().Type().Name()
|
||||||
}
|
}
|
||||||
start, end = name+"{", "}"
|
start, end = name+"{", "}"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,14 @@ func Bool() bool {
|
||||||
return randSeed%2 == 1
|
return randSeed%2 == 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Intn returns a deterministically random integer between 0 and n-1, inclusive.
|
||||||
|
func Intn(n int) int {
|
||||||
|
if n <= 0 {
|
||||||
|
panic("must be positive")
|
||||||
|
}
|
||||||
|
return int(randSeed % uint64(n))
|
||||||
|
}
|
||||||
|
|
||||||
// randSeed is a best-effort at an approximate hash of the Go binary.
|
// randSeed is a best-effort at an approximate hash of the Go binary.
|
||||||
var randSeed = binaryHash()
|
var randSeed = binaryHash()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,9 @@ import (
|
||||||
"google.golang.org/protobuf/encoding/protowire"
|
"google.golang.org/protobuf/encoding/protowire"
|
||||||
"google.golang.org/protobuf/internal/errors"
|
"google.golang.org/protobuf/internal/errors"
|
||||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
preg "google.golang.org/protobuf/reflect/protoregistry"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// The MessageSet wire format is equivalent to a message defiend as follows,
|
// The MessageSet wire format is equivalent to a message defined as follows,
|
||||||
// where each Item defines an extension field with a field number of 'type_id'
|
// where each Item defines an extension field with a field number of 'type_id'
|
||||||
// and content of 'message'. MessageSet extensions must be non-repeated message
|
// and content of 'message'. MessageSet extensions must be non-repeated message
|
||||||
// fields.
|
// fields.
|
||||||
|
|
@ -48,33 +47,17 @@ func IsMessageSet(md pref.MessageDescriptor) bool {
|
||||||
return ok && xmd.IsMessageSet()
|
return ok && xmd.IsMessageSet()
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsMessageSetExtension reports this field extends a MessageSet.
|
// IsMessageSetExtension reports this field properly extends a MessageSet.
|
||||||
func IsMessageSetExtension(fd pref.FieldDescriptor) bool {
|
func IsMessageSetExtension(fd pref.FieldDescriptor) bool {
|
||||||
if fd.Name() != ExtensionName {
|
switch {
|
||||||
|
case fd.Name() != ExtensionName:
|
||||||
|
return false
|
||||||
|
case !IsMessageSet(fd.ContainingMessage()):
|
||||||
|
return false
|
||||||
|
case fd.FullName().Parent() != fd.Message().FullName():
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if fd.FullName().Parent() != fd.Message().FullName() {
|
return true
|
||||||
return false
|
|
||||||
}
|
|
||||||
return IsMessageSet(fd.ContainingMessage())
|
|
||||||
}
|
|
||||||
|
|
||||||
// FindMessageSetExtension locates a MessageSet extension field by name.
|
|
||||||
// In text and JSON formats, the extension name used is the message itself.
|
|
||||||
// The extension field name is derived by appending ExtensionName.
|
|
||||||
func FindMessageSetExtension(r preg.ExtensionTypeResolver, s pref.FullName) (pref.ExtensionType, error) {
|
|
||||||
name := s.Append(ExtensionName)
|
|
||||||
xt, err := r.FindExtensionByName(name)
|
|
||||||
if err != nil {
|
|
||||||
if err == preg.NotFound {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return nil, errors.Wrap(err, "%q", name)
|
|
||||||
}
|
|
||||||
if !IsMessageSetExtension(xt.TypeDescriptor()) {
|
|
||||||
return nil, preg.NotFound
|
|
||||||
}
|
|
||||||
return xt, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SizeField returns the size of a MessageSet item field containing an extension
|
// SizeField returns the size of a MessageSet item field containing an extension
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ func Unmarshal(tag string, goType reflect.Type, evs pref.EnumValueDescriptors) p
|
||||||
case strings.HasPrefix(s, "json="):
|
case strings.HasPrefix(s, "json="):
|
||||||
jsonName := s[len("json="):]
|
jsonName := s[len("json="):]
|
||||||
if jsonName != strs.JSONCamelCase(string(f.L0.FullName.Name())) {
|
if jsonName != strs.JSONCamelCase(string(f.L0.FullName.Name())) {
|
||||||
f.L1.JSONName.Init(jsonName)
|
f.L1.StringName.InitJSON(jsonName)
|
||||||
}
|
}
|
||||||
case s == "packed":
|
case s == "packed":
|
||||||
f.L1.HasPacked = true
|
f.L1.HasPacked = true
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ type Encoder struct {
|
||||||
encoderState
|
encoderState
|
||||||
|
|
||||||
indent string
|
indent string
|
||||||
newline string // set to "\n" if len(indent) > 0
|
|
||||||
delims [2]byte
|
delims [2]byte
|
||||||
outputASCII bool
|
outputASCII bool
|
||||||
}
|
}
|
||||||
|
|
@ -61,7 +60,6 @@ func NewEncoder(indent string, delims [2]byte, outputASCII bool) (*Encoder, erro
|
||||||
return nil, errors.New("indent may only be composed of space and tab characters")
|
return nil, errors.New("indent may only be composed of space and tab characters")
|
||||||
}
|
}
|
||||||
e.indent = indent
|
e.indent = indent
|
||||||
e.newline = "\n"
|
|
||||||
}
|
}
|
||||||
switch delims {
|
switch delims {
|
||||||
case [2]byte{0, 0}:
|
case [2]byte{0, 0}:
|
||||||
|
|
@ -126,7 +124,7 @@ func appendString(out []byte, in string, outputASCII bool) []byte {
|
||||||
// are used to represent both the proto string and bytes type.
|
// are used to represent both the proto string and bytes type.
|
||||||
r = rune(in[0])
|
r = rune(in[0])
|
||||||
fallthrough
|
fallthrough
|
||||||
case r < ' ' || r == '"' || r == '\\':
|
case r < ' ' || r == '"' || r == '\\' || r == 0x7f:
|
||||||
out = append(out, '\\')
|
out = append(out, '\\')
|
||||||
switch r {
|
switch r {
|
||||||
case '"', '\\':
|
case '"', '\\':
|
||||||
|
|
@ -143,7 +141,7 @@ func appendString(out []byte, in string, outputASCII bool) []byte {
|
||||||
out = strconv.AppendUint(out, uint64(r), 16)
|
out = strconv.AppendUint(out, uint64(r), 16)
|
||||||
}
|
}
|
||||||
in = in[n:]
|
in = in[n:]
|
||||||
case outputASCII && r >= utf8.RuneSelf:
|
case r >= utf8.RuneSelf && (outputASCII || r <= 0x009f):
|
||||||
out = append(out, '\\')
|
out = append(out, '\\')
|
||||||
if r <= math.MaxUint16 {
|
if r <= math.MaxUint16 {
|
||||||
out = append(out, 'u')
|
out = append(out, 'u')
|
||||||
|
|
@ -168,7 +166,7 @@ func appendString(out []byte, in string, outputASCII bool) []byte {
|
||||||
// escaping. If no characters need escaping, this returns the input length.
|
// escaping. If no characters need escaping, this returns the input length.
|
||||||
func indexNeedEscapeInString(s string) int {
|
func indexNeedEscapeInString(s string) int {
|
||||||
for i := 0; i < len(s); i++ {
|
for i := 0; i < len(s); i++ {
|
||||||
if c := s[i]; c < ' ' || c == '"' || c == '\'' || c == '\\' || c >= utf8.RuneSelf {
|
if c := s[i]; c < ' ' || c == '"' || c == '\'' || c == '\\' || c >= 0x7f {
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
// Copyright 2019 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// Package fieldsort defines an ordering of fields.
|
|
||||||
//
|
|
||||||
// The ordering defined by this package matches the historic behavior of the proto
|
|
||||||
// package, placing extensions first and oneofs last.
|
|
||||||
//
|
|
||||||
// There is no guarantee about stability of the wire encoding, and users should not
|
|
||||||
// depend on the order defined in this package as it is subject to change without
|
|
||||||
// notice.
|
|
||||||
package fieldsort
|
|
||||||
|
|
||||||
import (
|
|
||||||
"google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Less returns true if field a comes before field j in ordered wire marshal output.
|
|
||||||
func Less(a, b protoreflect.FieldDescriptor) bool {
|
|
||||||
ea := a.IsExtension()
|
|
||||||
eb := b.IsExtension()
|
|
||||||
oa := a.ContainingOneof()
|
|
||||||
ob := b.ContainingOneof()
|
|
||||||
switch {
|
|
||||||
case ea != eb:
|
|
||||||
return ea
|
|
||||||
case oa != nil && ob != nil:
|
|
||||||
if oa == ob {
|
|
||||||
return a.Number() < b.Number()
|
|
||||||
}
|
|
||||||
return oa.Index() < ob.Index()
|
|
||||||
case oa != nil && !oa.IsSynthetic():
|
|
||||||
return false
|
|
||||||
case ob != nil && !ob.IsSynthetic():
|
|
||||||
return true
|
|
||||||
default:
|
|
||||||
return a.Number() < b.Number()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -3,6 +3,9 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// Package filedesc provides functionality for constructing descriptors.
|
// Package filedesc provides functionality for constructing descriptors.
|
||||||
|
//
|
||||||
|
// The types in this package implement interfaces in the protoreflect package
|
||||||
|
// related to protobuf descripriptors.
|
||||||
package filedesc
|
package filedesc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"google.golang.org/protobuf/internal/descfmt"
|
"google.golang.org/protobuf/internal/descfmt"
|
||||||
"google.golang.org/protobuf/internal/descopts"
|
"google.golang.org/protobuf/internal/descopts"
|
||||||
"google.golang.org/protobuf/internal/encoding/defval"
|
"google.golang.org/protobuf/internal/encoding/defval"
|
||||||
|
"google.golang.org/protobuf/internal/encoding/messageset"
|
||||||
"google.golang.org/protobuf/internal/genid"
|
"google.golang.org/protobuf/internal/genid"
|
||||||
"google.golang.org/protobuf/internal/pragma"
|
"google.golang.org/protobuf/internal/pragma"
|
||||||
"google.golang.org/protobuf/internal/strs"
|
"google.golang.org/protobuf/internal/strs"
|
||||||
|
|
@ -99,15 +100,6 @@ func (fd *File) lazyInitOnce() {
|
||||||
fd.mu.Unlock()
|
fd.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProtoLegacyRawDesc is a pseudo-internal API for allowing the v1 code
|
|
||||||
// to be able to retrieve the raw descriptor.
|
|
||||||
//
|
|
||||||
// WARNING: This method is exempt from the compatibility promise and may be
|
|
||||||
// removed in the future without warning.
|
|
||||||
func (fd *File) ProtoLegacyRawDesc() []byte {
|
|
||||||
return fd.builder.RawDescriptor
|
|
||||||
}
|
|
||||||
|
|
||||||
// GoPackagePath is a pseudo-internal API for determining the Go package path
|
// GoPackagePath is a pseudo-internal API for determining the Go package path
|
||||||
// that this file descriptor is declared in.
|
// that this file descriptor is declared in.
|
||||||
//
|
//
|
||||||
|
|
@ -207,7 +199,7 @@ type (
|
||||||
Number pref.FieldNumber
|
Number pref.FieldNumber
|
||||||
Cardinality pref.Cardinality // must be consistent with Message.RequiredNumbers
|
Cardinality pref.Cardinality // must be consistent with Message.RequiredNumbers
|
||||||
Kind pref.Kind
|
Kind pref.Kind
|
||||||
JSONName jsonName
|
StringName stringName
|
||||||
IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
|
IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
|
||||||
IsWeak bool // promoted from google.protobuf.FieldOptions
|
IsWeak bool // promoted from google.protobuf.FieldOptions
|
||||||
HasPacked bool // promoted from google.protobuf.FieldOptions
|
HasPacked bool // promoted from google.protobuf.FieldOptions
|
||||||
|
|
@ -277,8 +269,9 @@ func (fd *Field) Options() pref.ProtoMessage {
|
||||||
func (fd *Field) Number() pref.FieldNumber { return fd.L1.Number }
|
func (fd *Field) Number() pref.FieldNumber { return fd.L1.Number }
|
||||||
func (fd *Field) Cardinality() pref.Cardinality { return fd.L1.Cardinality }
|
func (fd *Field) Cardinality() pref.Cardinality { return fd.L1.Cardinality }
|
||||||
func (fd *Field) Kind() pref.Kind { return fd.L1.Kind }
|
func (fd *Field) Kind() pref.Kind { return fd.L1.Kind }
|
||||||
func (fd *Field) HasJSONName() bool { return fd.L1.JSONName.has }
|
func (fd *Field) HasJSONName() bool { return fd.L1.StringName.hasJSON }
|
||||||
func (fd *Field) JSONName() string { return fd.L1.JSONName.get(fd) }
|
func (fd *Field) JSONName() string { return fd.L1.StringName.getJSON(fd) }
|
||||||
|
func (fd *Field) TextName() string { return fd.L1.StringName.getText(fd) }
|
||||||
func (fd *Field) HasPresence() bool {
|
func (fd *Field) HasPresence() bool {
|
||||||
return fd.L1.Cardinality != pref.Repeated && (fd.L0.ParentFile.L1.Syntax == pref.Proto2 || fd.L1.Message != nil || fd.L1.ContainingOneof != nil)
|
return fd.L1.Cardinality != pref.Repeated && (fd.L0.ParentFile.L1.Syntax == pref.Proto2 || fd.L1.Message != nil || fd.L1.ContainingOneof != nil)
|
||||||
}
|
}
|
||||||
|
|
@ -373,7 +366,7 @@ type (
|
||||||
}
|
}
|
||||||
ExtensionL2 struct {
|
ExtensionL2 struct {
|
||||||
Options func() pref.ProtoMessage
|
Options func() pref.ProtoMessage
|
||||||
JSONName jsonName
|
StringName stringName
|
||||||
IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
|
IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
|
||||||
IsPacked bool // promoted from google.protobuf.FieldOptions
|
IsPacked bool // promoted from google.protobuf.FieldOptions
|
||||||
Default defaultValue
|
Default defaultValue
|
||||||
|
|
@ -391,8 +384,9 @@ func (xd *Extension) Options() pref.ProtoMessage {
|
||||||
func (xd *Extension) Number() pref.FieldNumber { return xd.L1.Number }
|
func (xd *Extension) Number() pref.FieldNumber { return xd.L1.Number }
|
||||||
func (xd *Extension) Cardinality() pref.Cardinality { return xd.L1.Cardinality }
|
func (xd *Extension) Cardinality() pref.Cardinality { return xd.L1.Cardinality }
|
||||||
func (xd *Extension) Kind() pref.Kind { return xd.L1.Kind }
|
func (xd *Extension) Kind() pref.Kind { return xd.L1.Kind }
|
||||||
func (xd *Extension) HasJSONName() bool { return xd.lazyInit().JSONName.has }
|
func (xd *Extension) HasJSONName() bool { return xd.lazyInit().StringName.hasJSON }
|
||||||
func (xd *Extension) JSONName() string { return xd.lazyInit().JSONName.get(xd) }
|
func (xd *Extension) JSONName() string { return xd.lazyInit().StringName.getJSON(xd) }
|
||||||
|
func (xd *Extension) TextName() string { return xd.lazyInit().StringName.getText(xd) }
|
||||||
func (xd *Extension) HasPresence() bool { return xd.L1.Cardinality != pref.Repeated }
|
func (xd *Extension) HasPresence() bool { return xd.L1.Cardinality != pref.Repeated }
|
||||||
func (xd *Extension) HasOptionalKeyword() bool {
|
func (xd *Extension) HasOptionalKeyword() bool {
|
||||||
return (xd.L0.ParentFile.L1.Syntax == pref.Proto2 && xd.L1.Cardinality == pref.Optional) || xd.lazyInit().IsProto3Optional
|
return (xd.L0.ParentFile.L1.Syntax == pref.Proto2 && xd.L1.Cardinality == pref.Optional) || xd.lazyInit().IsProto3Optional
|
||||||
|
|
@ -506,27 +500,50 @@ func (d *Base) Syntax() pref.Syntax { return d.L0.ParentFile.Syn
|
||||||
func (d *Base) IsPlaceholder() bool { return false }
|
func (d *Base) IsPlaceholder() bool { return false }
|
||||||
func (d *Base) ProtoInternal(pragma.DoNotImplement) {}
|
func (d *Base) ProtoInternal(pragma.DoNotImplement) {}
|
||||||
|
|
||||||
type jsonName struct {
|
type stringName struct {
|
||||||
has bool
|
hasJSON bool
|
||||||
once sync.Once
|
once sync.Once
|
||||||
name string
|
nameJSON string
|
||||||
|
nameText string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init initializes the name. It is exported for use by other internal packages.
|
// InitJSON initializes the name. It is exported for use by other internal packages.
|
||||||
func (js *jsonName) Init(s string) {
|
func (s *stringName) InitJSON(name string) {
|
||||||
js.has = true
|
s.hasJSON = true
|
||||||
js.name = s
|
s.nameJSON = name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (js *jsonName) get(fd pref.FieldDescriptor) string {
|
func (s *stringName) lazyInit(fd pref.FieldDescriptor) *stringName {
|
||||||
if !js.has {
|
s.once.Do(func() {
|
||||||
js.once.Do(func() {
|
if fd.IsExtension() {
|
||||||
js.name = strs.JSONCamelCase(string(fd.Name()))
|
// For extensions, JSON and text are formatted the same way.
|
||||||
})
|
var name string
|
||||||
|
if messageset.IsMessageSetExtension(fd) {
|
||||||
|
name = string("[" + fd.FullName().Parent() + "]")
|
||||||
|
} else {
|
||||||
|
name = string("[" + fd.FullName() + "]")
|
||||||
}
|
}
|
||||||
return js.name
|
s.nameJSON = name
|
||||||
|
s.nameText = name
|
||||||
|
} else {
|
||||||
|
// Format the JSON name.
|
||||||
|
if !s.hasJSON {
|
||||||
|
s.nameJSON = strs.JSONCamelCase(string(fd.Name()))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format the text name.
|
||||||
|
s.nameText = string(fd.Name())
|
||||||
|
if fd.Kind() == pref.GroupKind {
|
||||||
|
s.nameText = string(fd.Message().Name())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *stringName) getJSON(fd pref.FieldDescriptor) string { return s.lazyInit(fd).nameJSON }
|
||||||
|
func (s *stringName) getText(fd pref.FieldDescriptor) string { return s.lazyInit(fd).nameText }
|
||||||
|
|
||||||
func DefaultValue(v pref.Value, ev pref.EnumValueDescriptor) defaultValue {
|
func DefaultValue(v pref.Value, ev pref.EnumValueDescriptor) defaultValue {
|
||||||
dv := defaultValue{has: v.IsValid(), val: v, enum: ev}
|
dv := defaultValue{has: v.IsValid(), val: v, enum: ev}
|
||||||
if b, ok := v.Interface().([]byte); ok {
|
if b, ok := v.Interface().([]byte); ok {
|
||||||
|
|
|
||||||
|
|
@ -451,7 +451,7 @@ func (fd *Field) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd pref.Des
|
||||||
case genid.FieldDescriptorProto_Name_field_number:
|
case genid.FieldDescriptorProto_Name_field_number:
|
||||||
fd.L0.FullName = appendFullName(sb, pd.FullName(), v)
|
fd.L0.FullName = appendFullName(sb, pd.FullName(), v)
|
||||||
case genid.FieldDescriptorProto_JsonName_field_number:
|
case genid.FieldDescriptorProto_JsonName_field_number:
|
||||||
fd.L1.JSONName.Init(sb.MakeString(v))
|
fd.L1.StringName.InitJSON(sb.MakeString(v))
|
||||||
case genid.FieldDescriptorProto_DefaultValue_field_number:
|
case genid.FieldDescriptorProto_DefaultValue_field_number:
|
||||||
fd.L1.Default.val = pref.ValueOfBytes(v) // temporarily store as bytes; later resolved in resolveMessages
|
fd.L1.Default.val = pref.ValueOfBytes(v) // temporarily store as bytes; later resolved in resolveMessages
|
||||||
case genid.FieldDescriptorProto_TypeName_field_number:
|
case genid.FieldDescriptorProto_TypeName_field_number:
|
||||||
|
|
@ -551,7 +551,7 @@ func (xd *Extension) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||||
b = b[m:]
|
b = b[m:]
|
||||||
switch num {
|
switch num {
|
||||||
case genid.FieldDescriptorProto_JsonName_field_number:
|
case genid.FieldDescriptorProto_JsonName_field_number:
|
||||||
xd.L2.JSONName.Init(sb.MakeString(v))
|
xd.L2.StringName.InitJSON(sb.MakeString(v))
|
||||||
case genid.FieldDescriptorProto_DefaultValue_field_number:
|
case genid.FieldDescriptorProto_DefaultValue_field_number:
|
||||||
xd.L2.Default.val = pref.ValueOfBytes(v) // temporarily store as bytes; later resolved in resolveExtensions
|
xd.L2.Default.val = pref.ValueOfBytes(v) // temporarily store as bytes; later resolved in resolveExtensions
|
||||||
case genid.FieldDescriptorProto_TypeName_field_number:
|
case genid.FieldDescriptorProto_TypeName_field_number:
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,12 @@ package filedesc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/internal/genid"
|
||||||
|
|
||||||
"google.golang.org/protobuf/encoding/protowire"
|
"google.golang.org/protobuf/encoding/protowire"
|
||||||
"google.golang.org/protobuf/internal/descfmt"
|
"google.golang.org/protobuf/internal/descfmt"
|
||||||
"google.golang.org/protobuf/internal/errors"
|
"google.golang.org/protobuf/internal/errors"
|
||||||
|
|
@ -245,6 +248,7 @@ type OneofFields struct {
|
||||||
once sync.Once
|
once sync.Once
|
||||||
byName map[pref.Name]pref.FieldDescriptor // protected by once
|
byName map[pref.Name]pref.FieldDescriptor // protected by once
|
||||||
byJSON map[string]pref.FieldDescriptor // protected by once
|
byJSON map[string]pref.FieldDescriptor // protected by once
|
||||||
|
byText map[string]pref.FieldDescriptor // protected by once
|
||||||
byNum map[pref.FieldNumber]pref.FieldDescriptor // protected by once
|
byNum map[pref.FieldNumber]pref.FieldDescriptor // protected by once
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -252,6 +256,7 @@ func (p *OneofFields) Len() int { return
|
||||||
func (p *OneofFields) Get(i int) pref.FieldDescriptor { return p.List[i] }
|
func (p *OneofFields) Get(i int) pref.FieldDescriptor { return p.List[i] }
|
||||||
func (p *OneofFields) ByName(s pref.Name) pref.FieldDescriptor { return p.lazyInit().byName[s] }
|
func (p *OneofFields) ByName(s pref.Name) pref.FieldDescriptor { return p.lazyInit().byName[s] }
|
||||||
func (p *OneofFields) ByJSONName(s string) pref.FieldDescriptor { return p.lazyInit().byJSON[s] }
|
func (p *OneofFields) ByJSONName(s string) pref.FieldDescriptor { return p.lazyInit().byJSON[s] }
|
||||||
|
func (p *OneofFields) ByTextName(s string) pref.FieldDescriptor { return p.lazyInit().byText[s] }
|
||||||
func (p *OneofFields) ByNumber(n pref.FieldNumber) pref.FieldDescriptor { return p.lazyInit().byNum[n] }
|
func (p *OneofFields) ByNumber(n pref.FieldNumber) pref.FieldDescriptor { return p.lazyInit().byNum[n] }
|
||||||
func (p *OneofFields) Format(s fmt.State, r rune) { descfmt.FormatList(s, r, p) }
|
func (p *OneofFields) Format(s fmt.State, r rune) { descfmt.FormatList(s, r, p) }
|
||||||
func (p *OneofFields) ProtoInternal(pragma.DoNotImplement) {}
|
func (p *OneofFields) ProtoInternal(pragma.DoNotImplement) {}
|
||||||
|
|
@ -261,11 +266,13 @@ func (p *OneofFields) lazyInit() *OneofFields {
|
||||||
if len(p.List) > 0 {
|
if len(p.List) > 0 {
|
||||||
p.byName = make(map[pref.Name]pref.FieldDescriptor, len(p.List))
|
p.byName = make(map[pref.Name]pref.FieldDescriptor, len(p.List))
|
||||||
p.byJSON = make(map[string]pref.FieldDescriptor, len(p.List))
|
p.byJSON = make(map[string]pref.FieldDescriptor, len(p.List))
|
||||||
|
p.byText = make(map[string]pref.FieldDescriptor, len(p.List))
|
||||||
p.byNum = make(map[pref.FieldNumber]pref.FieldDescriptor, len(p.List))
|
p.byNum = make(map[pref.FieldNumber]pref.FieldDescriptor, len(p.List))
|
||||||
for _, f := range p.List {
|
for _, f := range p.List {
|
||||||
// Field names and numbers are guaranteed to be unique.
|
// Field names and numbers are guaranteed to be unique.
|
||||||
p.byName[f.Name()] = f
|
p.byName[f.Name()] = f
|
||||||
p.byJSON[f.JSONName()] = f
|
p.byJSON[f.JSONName()] = f
|
||||||
|
p.byText[f.TextName()] = f
|
||||||
p.byNum[f.Number()] = f
|
p.byNum[f.Number()] = f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -274,9 +281,170 @@ func (p *OneofFields) lazyInit() *OneofFields {
|
||||||
}
|
}
|
||||||
|
|
||||||
type SourceLocations struct {
|
type SourceLocations struct {
|
||||||
|
// List is a list of SourceLocations.
|
||||||
|
// The SourceLocation.Next field does not need to be populated
|
||||||
|
// as it will be lazily populated upon first need.
|
||||||
List []pref.SourceLocation
|
List []pref.SourceLocation
|
||||||
|
|
||||||
|
// File is the parent file descriptor that these locations are relative to.
|
||||||
|
// If non-nil, ByDescriptor verifies that the provided descriptor
|
||||||
|
// is a child of this file descriptor.
|
||||||
|
File pref.FileDescriptor
|
||||||
|
|
||||||
|
once sync.Once
|
||||||
|
byPath map[pathKey]int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *SourceLocations) Len() int { return len(p.List) }
|
func (p *SourceLocations) Len() int { return len(p.List) }
|
||||||
func (p *SourceLocations) Get(i int) pref.SourceLocation { return p.List[i] }
|
func (p *SourceLocations) Get(i int) pref.SourceLocation { return p.lazyInit().List[i] }
|
||||||
|
func (p *SourceLocations) byKey(k pathKey) pref.SourceLocation {
|
||||||
|
if i, ok := p.lazyInit().byPath[k]; ok {
|
||||||
|
return p.List[i]
|
||||||
|
}
|
||||||
|
return pref.SourceLocation{}
|
||||||
|
}
|
||||||
|
func (p *SourceLocations) ByPath(path pref.SourcePath) pref.SourceLocation {
|
||||||
|
return p.byKey(newPathKey(path))
|
||||||
|
}
|
||||||
|
func (p *SourceLocations) ByDescriptor(desc pref.Descriptor) pref.SourceLocation {
|
||||||
|
if p.File != nil && desc != nil && p.File != desc.ParentFile() {
|
||||||
|
return pref.SourceLocation{} // mismatching parent files
|
||||||
|
}
|
||||||
|
var pathArr [16]int32
|
||||||
|
path := pathArr[:0]
|
||||||
|
for {
|
||||||
|
switch desc.(type) {
|
||||||
|
case pref.FileDescriptor:
|
||||||
|
// Reverse the path since it was constructed in reverse.
|
||||||
|
for i, j := 0, len(path)-1; i < j; i, j = i+1, j-1 {
|
||||||
|
path[i], path[j] = path[j], path[i]
|
||||||
|
}
|
||||||
|
return p.byKey(newPathKey(path))
|
||||||
|
case pref.MessageDescriptor:
|
||||||
|
path = append(path, int32(desc.Index()))
|
||||||
|
desc = desc.Parent()
|
||||||
|
switch desc.(type) {
|
||||||
|
case pref.FileDescriptor:
|
||||||
|
path = append(path, int32(genid.FileDescriptorProto_MessageType_field_number))
|
||||||
|
case pref.MessageDescriptor:
|
||||||
|
path = append(path, int32(genid.DescriptorProto_NestedType_field_number))
|
||||||
|
default:
|
||||||
|
return pref.SourceLocation{}
|
||||||
|
}
|
||||||
|
case pref.FieldDescriptor:
|
||||||
|
isExtension := desc.(pref.FieldDescriptor).IsExtension()
|
||||||
|
path = append(path, int32(desc.Index()))
|
||||||
|
desc = desc.Parent()
|
||||||
|
if isExtension {
|
||||||
|
switch desc.(type) {
|
||||||
|
case pref.FileDescriptor:
|
||||||
|
path = append(path, int32(genid.FileDescriptorProto_Extension_field_number))
|
||||||
|
case pref.MessageDescriptor:
|
||||||
|
path = append(path, int32(genid.DescriptorProto_Extension_field_number))
|
||||||
|
default:
|
||||||
|
return pref.SourceLocation{}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch desc.(type) {
|
||||||
|
case pref.MessageDescriptor:
|
||||||
|
path = append(path, int32(genid.DescriptorProto_Field_field_number))
|
||||||
|
default:
|
||||||
|
return pref.SourceLocation{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case pref.OneofDescriptor:
|
||||||
|
path = append(path, int32(desc.Index()))
|
||||||
|
desc = desc.Parent()
|
||||||
|
switch desc.(type) {
|
||||||
|
case pref.MessageDescriptor:
|
||||||
|
path = append(path, int32(genid.DescriptorProto_OneofDecl_field_number))
|
||||||
|
default:
|
||||||
|
return pref.SourceLocation{}
|
||||||
|
}
|
||||||
|
case pref.EnumDescriptor:
|
||||||
|
path = append(path, int32(desc.Index()))
|
||||||
|
desc = desc.Parent()
|
||||||
|
switch desc.(type) {
|
||||||
|
case pref.FileDescriptor:
|
||||||
|
path = append(path, int32(genid.FileDescriptorProto_EnumType_field_number))
|
||||||
|
case pref.MessageDescriptor:
|
||||||
|
path = append(path, int32(genid.DescriptorProto_EnumType_field_number))
|
||||||
|
default:
|
||||||
|
return pref.SourceLocation{}
|
||||||
|
}
|
||||||
|
case pref.EnumValueDescriptor:
|
||||||
|
path = append(path, int32(desc.Index()))
|
||||||
|
desc = desc.Parent()
|
||||||
|
switch desc.(type) {
|
||||||
|
case pref.EnumDescriptor:
|
||||||
|
path = append(path, int32(genid.EnumDescriptorProto_Value_field_number))
|
||||||
|
default:
|
||||||
|
return pref.SourceLocation{}
|
||||||
|
}
|
||||||
|
case pref.ServiceDescriptor:
|
||||||
|
path = append(path, int32(desc.Index()))
|
||||||
|
desc = desc.Parent()
|
||||||
|
switch desc.(type) {
|
||||||
|
case pref.FileDescriptor:
|
||||||
|
path = append(path, int32(genid.FileDescriptorProto_Service_field_number))
|
||||||
|
default:
|
||||||
|
return pref.SourceLocation{}
|
||||||
|
}
|
||||||
|
case pref.MethodDescriptor:
|
||||||
|
path = append(path, int32(desc.Index()))
|
||||||
|
desc = desc.Parent()
|
||||||
|
switch desc.(type) {
|
||||||
|
case pref.ServiceDescriptor:
|
||||||
|
path = append(path, int32(genid.ServiceDescriptorProto_Method_field_number))
|
||||||
|
default:
|
||||||
|
return pref.SourceLocation{}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return pref.SourceLocation{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (p *SourceLocations) lazyInit() *SourceLocations {
|
||||||
|
p.once.Do(func() {
|
||||||
|
if len(p.List) > 0 {
|
||||||
|
// Collect all the indexes for a given path.
|
||||||
|
pathIdxs := make(map[pathKey][]int, len(p.List))
|
||||||
|
for i, l := range p.List {
|
||||||
|
k := newPathKey(l.Path)
|
||||||
|
pathIdxs[k] = append(pathIdxs[k], i)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the next index for all locations.
|
||||||
|
p.byPath = make(map[pathKey]int, len(p.List))
|
||||||
|
for k, idxs := range pathIdxs {
|
||||||
|
for i := 0; i < len(idxs)-1; i++ {
|
||||||
|
p.List[idxs[i]].Next = idxs[i+1]
|
||||||
|
}
|
||||||
|
p.List[idxs[len(idxs)-1]].Next = 0
|
||||||
|
p.byPath[k] = idxs[0] // record the first location for this path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return p
|
||||||
|
}
|
||||||
func (p *SourceLocations) ProtoInternal(pragma.DoNotImplement) {}
|
func (p *SourceLocations) ProtoInternal(pragma.DoNotImplement) {}
|
||||||
|
|
||||||
|
// pathKey is a comparable representation of protoreflect.SourcePath.
|
||||||
|
type pathKey struct {
|
||||||
|
arr [16]uint8 // first n-1 path segments; last element is the length
|
||||||
|
str string // used if the path does not fit in arr
|
||||||
|
}
|
||||||
|
|
||||||
|
func newPathKey(p pref.SourcePath) (k pathKey) {
|
||||||
|
if len(p) < len(k.arr) {
|
||||||
|
for i, ps := range p {
|
||||||
|
if ps < 0 || math.MaxUint8 <= ps {
|
||||||
|
return pathKey{str: p.String()}
|
||||||
|
}
|
||||||
|
k.arr[i] = uint8(ps)
|
||||||
|
}
|
||||||
|
k.arr[len(k.arr)-1] = uint8(len(p))
|
||||||
|
return k
|
||||||
|
}
|
||||||
|
return pathKey{str: p.String()}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,7 @@ type Fields struct {
|
||||||
once sync.Once
|
once sync.Once
|
||||||
byName map[protoreflect.Name]*Field // protected by once
|
byName map[protoreflect.Name]*Field // protected by once
|
||||||
byJSON map[string]*Field // protected by once
|
byJSON map[string]*Field // protected by once
|
||||||
|
byText map[string]*Field // protected by once
|
||||||
byNum map[protoreflect.FieldNumber]*Field // protected by once
|
byNum map[protoreflect.FieldNumber]*Field // protected by once
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -163,6 +164,12 @@ func (p *Fields) ByJSONName(s string) protoreflect.FieldDescriptor {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
func (p *Fields) ByTextName(s string) protoreflect.FieldDescriptor {
|
||||||
|
if d := p.lazyInit().byText[s]; d != nil {
|
||||||
|
return d
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
func (p *Fields) ByNumber(n protoreflect.FieldNumber) protoreflect.FieldDescriptor {
|
func (p *Fields) ByNumber(n protoreflect.FieldNumber) protoreflect.FieldDescriptor {
|
||||||
if d := p.lazyInit().byNum[n]; d != nil {
|
if d := p.lazyInit().byNum[n]; d != nil {
|
||||||
return d
|
return d
|
||||||
|
|
@ -178,6 +185,7 @@ func (p *Fields) lazyInit() *Fields {
|
||||||
if len(p.List) > 0 {
|
if len(p.List) > 0 {
|
||||||
p.byName = make(map[protoreflect.Name]*Field, len(p.List))
|
p.byName = make(map[protoreflect.Name]*Field, len(p.List))
|
||||||
p.byJSON = make(map[string]*Field, len(p.List))
|
p.byJSON = make(map[string]*Field, len(p.List))
|
||||||
|
p.byText = make(map[string]*Field, len(p.List))
|
||||||
p.byNum = make(map[protoreflect.FieldNumber]*Field, len(p.List))
|
p.byNum = make(map[protoreflect.FieldNumber]*Field, len(p.List))
|
||||||
for i := range p.List {
|
for i := range p.List {
|
||||||
d := &p.List[i]
|
d := &p.List[i]
|
||||||
|
|
@ -187,6 +195,9 @@ func (p *Fields) lazyInit() *Fields {
|
||||||
if _, ok := p.byJSON[d.JSONName()]; !ok {
|
if _, ok := p.byJSON[d.JSONName()]; !ok {
|
||||||
p.byJSON[d.JSONName()] = d
|
p.byJSON[d.JSONName()] = d
|
||||||
}
|
}
|
||||||
|
if _, ok := p.byText[d.TextName()]; !ok {
|
||||||
|
p.byText[d.TextName()] = d
|
||||||
|
}
|
||||||
if _, ok := p.byNum[d.Number()]; !ok {
|
if _, ok := p.byNum[d.Number()]; !ok {
|
||||||
p.byNum[d.Number()] = d
|
p.byNum[d.Number()] = d
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ func (Export) MessageTypeOf(m message) pref.MessageType {
|
||||||
if mv := (Export{}).protoMessageV2Of(m); mv != nil {
|
if mv := (Export{}).protoMessageV2Of(m); mv != nil {
|
||||||
return mv.ProtoReflect().Type()
|
return mv.ProtoReflect().Type()
|
||||||
}
|
}
|
||||||
return legacyLoadMessageInfo(reflect.TypeOf(m), "")
|
return legacyLoadMessageType(reflect.TypeOf(m), "")
|
||||||
}
|
}
|
||||||
|
|
||||||
// MessageStringOf returns the message value as a string,
|
// MessageStringOf returns the message value as a string,
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"google.golang.org/protobuf/encoding/protowire"
|
"google.golang.org/protobuf/encoding/protowire"
|
||||||
|
"google.golang.org/protobuf/internal/errors"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
preg "google.golang.org/protobuf/reflect/protoregistry"
|
preg "google.golang.org/protobuf/reflect/protoregistry"
|
||||||
|
|
@ -20,6 +21,7 @@ type errInvalidUTF8 struct{}
|
||||||
|
|
||||||
func (errInvalidUTF8) Error() string { return "string field contains invalid UTF-8" }
|
func (errInvalidUTF8) Error() string { return "string field contains invalid UTF-8" }
|
||||||
func (errInvalidUTF8) InvalidUTF8() bool { return true }
|
func (errInvalidUTF8) InvalidUTF8() bool { return true }
|
||||||
|
func (errInvalidUTF8) Unwrap() error { return errors.Error }
|
||||||
|
|
||||||
// initOneofFieldCoders initializes the fast-path functions for the fields in a oneof.
|
// initOneofFieldCoders initializes the fast-path functions for the fields in a oneof.
|
||||||
//
|
//
|
||||||
|
|
@ -242,7 +244,7 @@ func consumeMessageInfo(b []byte, p pointer, wtyp protowire.Type, f *coderFieldI
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeBytes(b)
|
v, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return out, protowire.ParseError(n)
|
return out, errDecode
|
||||||
}
|
}
|
||||||
if p.Elem().IsNil() {
|
if p.Elem().IsNil() {
|
||||||
p.SetPointer(pointerOfValue(reflect.New(f.mi.GoReflectType.Elem())))
|
p.SetPointer(pointerOfValue(reflect.New(f.mi.GoReflectType.Elem())))
|
||||||
|
|
@ -276,7 +278,7 @@ func consumeMessage(b []byte, m proto.Message, wtyp protowire.Type, opts unmarsh
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeBytes(b)
|
v, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return out, protowire.ParseError(n)
|
return out, errDecode
|
||||||
}
|
}
|
||||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||||
Buf: v,
|
Buf: v,
|
||||||
|
|
@ -420,7 +422,7 @@ func consumeGroup(b []byte, m proto.Message, num protowire.Number, wtyp protowir
|
||||||
}
|
}
|
||||||
b, n := protowire.ConsumeGroup(num, b)
|
b, n := protowire.ConsumeGroup(num, b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return out, protowire.ParseError(n)
|
return out, errDecode
|
||||||
}
|
}
|
||||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||||
Buf: b,
|
Buf: b,
|
||||||
|
|
@ -494,7 +496,7 @@ func consumeMessageSliceInfo(b []byte, p pointer, wtyp protowire.Type, f *coderF
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeBytes(b)
|
v, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return out, protowire.ParseError(n)
|
return out, errDecode
|
||||||
}
|
}
|
||||||
m := reflect.New(f.mi.GoReflectType.Elem()).Interface()
|
m := reflect.New(f.mi.GoReflectType.Elem()).Interface()
|
||||||
mp := pointerOfIface(m)
|
mp := pointerOfIface(m)
|
||||||
|
|
@ -550,7 +552,7 @@ func consumeMessageSlice(b []byte, p pointer, goType reflect.Type, wtyp protowir
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeBytes(b)
|
v, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return out, protowire.ParseError(n)
|
return out, errDecode
|
||||||
}
|
}
|
||||||
mp := reflect.New(goType.Elem())
|
mp := reflect.New(goType.Elem())
|
||||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||||
|
|
@ -613,7 +615,7 @@ func consumeMessageSliceValue(b []byte, listv pref.Value, _ protowire.Number, wt
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeBytes(b)
|
v, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return pref.Value{}, out, protowire.ParseError(n)
|
return pref.Value{}, out, errDecode
|
||||||
}
|
}
|
||||||
m := list.NewElement()
|
m := list.NewElement()
|
||||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||||
|
|
@ -681,7 +683,7 @@ func consumeGroupSliceValue(b []byte, listv pref.Value, num protowire.Number, wt
|
||||||
}
|
}
|
||||||
b, n := protowire.ConsumeGroup(num, b)
|
b, n := protowire.ConsumeGroup(num, b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return pref.Value{}, out, protowire.ParseError(n)
|
return pref.Value{}, out, errDecode
|
||||||
}
|
}
|
||||||
m := list.NewElement()
|
m := list.NewElement()
|
||||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||||
|
|
@ -767,7 +769,7 @@ func consumeGroupSlice(b []byte, p pointer, num protowire.Number, wtyp protowire
|
||||||
}
|
}
|
||||||
b, n := protowire.ConsumeGroup(num, b)
|
b, n := protowire.ConsumeGroup(num, b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return out, protowire.ParseError(n)
|
return out, errDecode
|
||||||
}
|
}
|
||||||
mp := reflect.New(goType.Elem())
|
mp := reflect.New(goType.Elem())
|
||||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -5,7 +5,6 @@
|
||||||
package impl
|
package impl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
|
|
@ -118,7 +117,7 @@ func consumeMap(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi *mapInfo
|
||||||
}
|
}
|
||||||
b, n := protowire.ConsumeBytes(b)
|
b, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return out, protowire.ParseError(n)
|
return out, errDecode
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
key = mapi.keyZero
|
key = mapi.keyZero
|
||||||
|
|
@ -127,10 +126,10 @@ func consumeMap(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi *mapInfo
|
||||||
for len(b) > 0 {
|
for len(b) > 0 {
|
||||||
num, wtyp, n := protowire.ConsumeTag(b)
|
num, wtyp, n := protowire.ConsumeTag(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return out, protowire.ParseError(n)
|
return out, errDecode
|
||||||
}
|
}
|
||||||
if num > protowire.MaxValidNumber {
|
if num > protowire.MaxValidNumber {
|
||||||
return out, errors.New("invalid field number")
|
return out, errDecode
|
||||||
}
|
}
|
||||||
b = b[n:]
|
b = b[n:]
|
||||||
err := errUnknown
|
err := errUnknown
|
||||||
|
|
@ -157,7 +156,7 @@ func consumeMap(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi *mapInfo
|
||||||
if err == errUnknown {
|
if err == errUnknown {
|
||||||
n = protowire.ConsumeFieldValue(num, wtyp, b)
|
n = protowire.ConsumeFieldValue(num, wtyp, b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return out, protowire.ParseError(n)
|
return out, errDecode
|
||||||
}
|
}
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return out, err
|
return out, err
|
||||||
|
|
@ -175,7 +174,7 @@ func consumeMapOfMessage(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi
|
||||||
}
|
}
|
||||||
b, n := protowire.ConsumeBytes(b)
|
b, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return out, protowire.ParseError(n)
|
return out, errDecode
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
key = mapi.keyZero
|
key = mapi.keyZero
|
||||||
|
|
@ -184,10 +183,10 @@ func consumeMapOfMessage(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi
|
||||||
for len(b) > 0 {
|
for len(b) > 0 {
|
||||||
num, wtyp, n := protowire.ConsumeTag(b)
|
num, wtyp, n := protowire.ConsumeTag(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return out, protowire.ParseError(n)
|
return out, errDecode
|
||||||
}
|
}
|
||||||
if num > protowire.MaxValidNumber {
|
if num > protowire.MaxValidNumber {
|
||||||
return out, errors.New("invalid field number")
|
return out, errDecode
|
||||||
}
|
}
|
||||||
b = b[n:]
|
b = b[n:]
|
||||||
err := errUnknown
|
err := errUnknown
|
||||||
|
|
@ -208,7 +207,7 @@ func consumeMapOfMessage(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi
|
||||||
var v []byte
|
var v []byte
|
||||||
v, n = protowire.ConsumeBytes(b)
|
v, n = protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return out, protowire.ParseError(n)
|
return out, errDecode
|
||||||
}
|
}
|
||||||
var o unmarshalOutput
|
var o unmarshalOutput
|
||||||
o, err = f.mi.unmarshalPointer(v, pointerOfValue(val), 0, opts)
|
o, err = f.mi.unmarshalPointer(v, pointerOfValue(val), 0, opts)
|
||||||
|
|
@ -221,7 +220,7 @@ func consumeMapOfMessage(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi
|
||||||
if err == errUnknown {
|
if err == errUnknown {
|
||||||
n = protowire.ConsumeFieldValue(num, wtyp, b)
|
n = protowire.ConsumeFieldValue(num, wtyp, b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return out, protowire.ParseError(n)
|
return out, errDecode
|
||||||
}
|
}
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return out, err
|
return out, err
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
"google.golang.org/protobuf/encoding/protowire"
|
"google.golang.org/protobuf/encoding/protowire"
|
||||||
"google.golang.org/protobuf/internal/encoding/messageset"
|
"google.golang.org/protobuf/internal/encoding/messageset"
|
||||||
"google.golang.org/protobuf/internal/fieldsort"
|
"google.golang.org/protobuf/internal/order"
|
||||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
piface "google.golang.org/protobuf/runtime/protoiface"
|
piface "google.golang.org/protobuf/runtime/protoiface"
|
||||||
)
|
)
|
||||||
|
|
@ -27,6 +27,7 @@ type coderMessageInfo struct {
|
||||||
coderFields map[protowire.Number]*coderFieldInfo
|
coderFields map[protowire.Number]*coderFieldInfo
|
||||||
sizecacheOffset offset
|
sizecacheOffset offset
|
||||||
unknownOffset offset
|
unknownOffset offset
|
||||||
|
unknownPtrKind bool
|
||||||
extensionOffset offset
|
extensionOffset offset
|
||||||
needsInitCheck bool
|
needsInitCheck bool
|
||||||
isMessageSet bool
|
isMessageSet bool
|
||||||
|
|
@ -47,9 +48,20 @@ type coderFieldInfo struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||||
|
mi.sizecacheOffset = invalidOffset
|
||||||
|
mi.unknownOffset = invalidOffset
|
||||||
|
mi.extensionOffset = invalidOffset
|
||||||
|
|
||||||
|
if si.sizecacheOffset.IsValid() && si.sizecacheType == sizecacheType {
|
||||||
mi.sizecacheOffset = si.sizecacheOffset
|
mi.sizecacheOffset = si.sizecacheOffset
|
||||||
|
}
|
||||||
|
if si.unknownOffset.IsValid() && (si.unknownType == unknownFieldsAType || si.unknownType == unknownFieldsBType) {
|
||||||
mi.unknownOffset = si.unknownOffset
|
mi.unknownOffset = si.unknownOffset
|
||||||
|
mi.unknownPtrKind = si.unknownType.Kind() == reflect.Ptr
|
||||||
|
}
|
||||||
|
if si.extensionOffset.IsValid() && si.extensionType == extensionFieldsType {
|
||||||
mi.extensionOffset = si.extensionOffset
|
mi.extensionOffset = si.extensionOffset
|
||||||
|
}
|
||||||
|
|
||||||
mi.coderFields = make(map[protowire.Number]*coderFieldInfo)
|
mi.coderFields = make(map[protowire.Number]*coderFieldInfo)
|
||||||
fields := mi.Desc.Fields()
|
fields := mi.Desc.Fields()
|
||||||
|
|
@ -73,6 +85,27 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||||
var funcs pointerCoderFuncs
|
var funcs pointerCoderFuncs
|
||||||
var childMessage *MessageInfo
|
var childMessage *MessageInfo
|
||||||
switch {
|
switch {
|
||||||
|
case ft == nil:
|
||||||
|
// This never occurs for generated message types.
|
||||||
|
// It implies that a hand-crafted type has missing Go fields
|
||||||
|
// for specific protobuf message fields.
|
||||||
|
funcs = pointerCoderFuncs{
|
||||||
|
size: func(p pointer, f *coderFieldInfo, opts marshalOptions) int {
|
||||||
|
return 0
|
||||||
|
},
|
||||||
|
marshal: func(b []byte, p pointer, f *coderFieldInfo, opts marshalOptions) ([]byte, error) {
|
||||||
|
return nil, nil
|
||||||
|
},
|
||||||
|
unmarshal: func(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (unmarshalOutput, error) {
|
||||||
|
panic("missing Go struct field for " + string(fd.FullName()))
|
||||||
|
},
|
||||||
|
isInit: func(p pointer, f *coderFieldInfo) error {
|
||||||
|
panic("missing Go struct field for " + string(fd.FullName()))
|
||||||
|
},
|
||||||
|
merge: func(dst, src pointer, f *coderFieldInfo, opts mergeOptions) {
|
||||||
|
panic("missing Go struct field for " + string(fd.FullName()))
|
||||||
|
},
|
||||||
|
}
|
||||||
case isOneof:
|
case isOneof:
|
||||||
fieldOffset = offsetOf(fs, mi.Exporter)
|
fieldOffset = offsetOf(fs, mi.Exporter)
|
||||||
case fd.IsWeak():
|
case fd.IsWeak():
|
||||||
|
|
@ -136,7 +169,7 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||||
sort.Slice(mi.orderedCoderFields, func(i, j int) bool {
|
sort.Slice(mi.orderedCoderFields, func(i, j int) bool {
|
||||||
fi := fields.ByNumber(mi.orderedCoderFields[i].num)
|
fi := fields.ByNumber(mi.orderedCoderFields[i].num)
|
||||||
fj := fields.ByNumber(mi.orderedCoderFields[j].num)
|
fj := fields.ByNumber(mi.orderedCoderFields[j].num)
|
||||||
return fieldsort.Less(fi, fj)
|
return order.LegacyFieldOrder(fi, fj)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -157,3 +190,28 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||||
mi.methods.Merge = mi.merge
|
mi.methods.Merge = mi.merge
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getUnknownBytes returns a *[]byte for the unknown fields.
|
||||||
|
// It is the caller's responsibility to check whether the pointer is nil.
|
||||||
|
// This function is specially designed to be inlineable.
|
||||||
|
func (mi *MessageInfo) getUnknownBytes(p pointer) *[]byte {
|
||||||
|
if mi.unknownPtrKind {
|
||||||
|
return *p.Apply(mi.unknownOffset).BytesPtr()
|
||||||
|
} else {
|
||||||
|
return p.Apply(mi.unknownOffset).Bytes()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// mutableUnknownBytes returns a *[]byte for the unknown fields.
|
||||||
|
// The returned pointer is guaranteed to not be nil.
|
||||||
|
func (mi *MessageInfo) mutableUnknownBytes(p pointer) *[]byte {
|
||||||
|
if mi.unknownPtrKind {
|
||||||
|
bp := p.Apply(mi.unknownOffset).BytesPtr()
|
||||||
|
if *bp == nil {
|
||||||
|
*bp = new([]byte)
|
||||||
|
}
|
||||||
|
return *bp
|
||||||
|
} else {
|
||||||
|
return p.Apply(mi.unknownOffset).Bytes()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,9 @@ func sizeMessageSet(mi *MessageInfo, p pointer, opts marshalOptions) (size int)
|
||||||
size += xi.funcs.size(x.Value(), protowire.SizeTag(messageset.FieldMessage), opts)
|
size += xi.funcs.size(x.Value(), protowire.SizeTag(messageset.FieldMessage), opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
unknown := *p.Apply(mi.unknownOffset).Bytes()
|
if u := mi.getUnknownBytes(p); u != nil {
|
||||||
size += messageset.SizeUnknown(unknown)
|
size += messageset.SizeUnknown(*u)
|
||||||
|
}
|
||||||
|
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
@ -69,11 +70,13 @@ func marshalMessageSet(mi *MessageInfo, b []byte, p pointer, opts marshalOptions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unknown := *p.Apply(mi.unknownOffset).Bytes()
|
if u := mi.getUnknownBytes(p); u != nil {
|
||||||
b, err := messageset.AppendUnknown(b, unknown)
|
var err error
|
||||||
|
b, err = messageset.AppendUnknown(b, *u)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return b, err
|
return b, err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
|
|
@ -100,13 +103,13 @@ func unmarshalMessageSet(mi *MessageInfo, b []byte, p pointer, opts unmarshalOpt
|
||||||
*ep = make(map[int32]ExtensionField)
|
*ep = make(map[int32]ExtensionField)
|
||||||
}
|
}
|
||||||
ext := *ep
|
ext := *ep
|
||||||
unknown := p.Apply(mi.unknownOffset).Bytes()
|
|
||||||
initialized := true
|
initialized := true
|
||||||
err = messageset.Unmarshal(b, true, func(num protowire.Number, v []byte) error {
|
err = messageset.Unmarshal(b, true, func(num protowire.Number, v []byte) error {
|
||||||
o, err := mi.unmarshalExtension(v, num, protowire.BytesType, ext, opts)
|
o, err := mi.unmarshalExtension(v, num, protowire.BytesType, ext, opts)
|
||||||
if err == errUnknown {
|
if err == errUnknown {
|
||||||
*unknown = protowire.AppendTag(*unknown, num, protowire.BytesType)
|
u := mi.mutableUnknownBytes(p)
|
||||||
*unknown = append(*unknown, v...)
|
*u = protowire.AppendTag(*u, num, protowire.BytesType)
|
||||||
|
*u = append(*u, v...)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if !o.initialized {
|
if !o.initialized {
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ func consumeEnum(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, _
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeVarint(b)
|
v, n := protowire.ConsumeVarint(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return out, protowire.ParseError(n)
|
return out, errDecode
|
||||||
}
|
}
|
||||||
p.v.Elem().SetInt(int64(v))
|
p.v.Elem().SetInt(int64(v))
|
||||||
out.n = n
|
out.n = n
|
||||||
|
|
@ -130,12 +130,12 @@ func consumeEnumSlice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInf
|
||||||
if wtyp == protowire.BytesType {
|
if wtyp == protowire.BytesType {
|
||||||
b, n := protowire.ConsumeBytes(b)
|
b, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return out, protowire.ParseError(n)
|
return out, errDecode
|
||||||
}
|
}
|
||||||
for len(b) > 0 {
|
for len(b) > 0 {
|
||||||
v, n := protowire.ConsumeVarint(b)
|
v, n := protowire.ConsumeVarint(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return out, protowire.ParseError(n)
|
return out, errDecode
|
||||||
}
|
}
|
||||||
rv := reflect.New(s.Type().Elem()).Elem()
|
rv := reflect.New(s.Type().Elem()).Elem()
|
||||||
rv.SetInt(int64(v))
|
rv.SetInt(int64(v))
|
||||||
|
|
@ -150,7 +150,7 @@ func consumeEnumSlice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInf
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeVarint(b)
|
v, n := protowire.ConsumeVarint(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return out, protowire.ParseError(n)
|
return out, errDecode
|
||||||
}
|
}
|
||||||
rv := reflect.New(s.Type().Elem()).Elem()
|
rv := reflect.New(s.Type().Elem()).Elem()
|
||||||
rv.SetInt(int64(v))
|
rv.SetInt(int64(v))
|
||||||
|
|
|
||||||
|
|
@ -423,6 +423,13 @@ func (c *messageConverter) PBValueOf(v reflect.Value) pref.Value {
|
||||||
if v.Type() != c.goType {
|
if v.Type() != c.goType {
|
||||||
panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType))
|
panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType))
|
||||||
}
|
}
|
||||||
|
if c.isNonPointer() {
|
||||||
|
if v.CanAddr() {
|
||||||
|
v = v.Addr() // T => *T
|
||||||
|
} else {
|
||||||
|
v = reflect.Zero(reflect.PtrTo(v.Type()))
|
||||||
|
}
|
||||||
|
}
|
||||||
if m, ok := v.Interface().(pref.ProtoMessage); ok {
|
if m, ok := v.Interface().(pref.ProtoMessage); ok {
|
||||||
return pref.ValueOfMessage(m.ProtoReflect())
|
return pref.ValueOfMessage(m.ProtoReflect())
|
||||||
}
|
}
|
||||||
|
|
@ -437,6 +444,16 @@ func (c *messageConverter) GoValueOf(v pref.Value) reflect.Value {
|
||||||
} else {
|
} else {
|
||||||
rv = reflect.ValueOf(m.Interface())
|
rv = reflect.ValueOf(m.Interface())
|
||||||
}
|
}
|
||||||
|
if c.isNonPointer() {
|
||||||
|
if rv.Type() != reflect.PtrTo(c.goType) {
|
||||||
|
panic(fmt.Sprintf("invalid type: got %v, want %v", rv.Type(), reflect.PtrTo(c.goType)))
|
||||||
|
}
|
||||||
|
if !rv.IsNil() {
|
||||||
|
rv = rv.Elem() // *T => T
|
||||||
|
} else {
|
||||||
|
rv = reflect.Zero(rv.Type().Elem())
|
||||||
|
}
|
||||||
|
}
|
||||||
if rv.Type() != c.goType {
|
if rv.Type() != c.goType {
|
||||||
panic(fmt.Sprintf("invalid type: got %v, want %v", rv.Type(), c.goType))
|
panic(fmt.Sprintf("invalid type: got %v, want %v", rv.Type(), c.goType))
|
||||||
}
|
}
|
||||||
|
|
@ -451,6 +468,9 @@ func (c *messageConverter) IsValidPB(v pref.Value) bool {
|
||||||
} else {
|
} else {
|
||||||
rv = reflect.ValueOf(m.Interface())
|
rv = reflect.ValueOf(m.Interface())
|
||||||
}
|
}
|
||||||
|
if c.isNonPointer() {
|
||||||
|
return rv.Type() == reflect.PtrTo(c.goType)
|
||||||
|
}
|
||||||
return rv.Type() == c.goType
|
return rv.Type() == c.goType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -459,9 +479,18 @@ func (c *messageConverter) IsValidGo(v reflect.Value) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *messageConverter) New() pref.Value {
|
func (c *messageConverter) New() pref.Value {
|
||||||
|
if c.isNonPointer() {
|
||||||
|
return c.PBValueOf(reflect.New(c.goType).Elem())
|
||||||
|
}
|
||||||
return c.PBValueOf(reflect.New(c.goType.Elem()))
|
return c.PBValueOf(reflect.New(c.goType.Elem()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *messageConverter) Zero() pref.Value {
|
func (c *messageConverter) Zero() pref.Value {
|
||||||
return c.PBValueOf(reflect.Zero(c.goType))
|
return c.PBValueOf(reflect.Zero(c.goType))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isNonPointer reports whether the type is a non-pointer type.
|
||||||
|
// This never occurs for generated message types.
|
||||||
|
func (c *messageConverter) isNonPointer() bool {
|
||||||
|
return c.goType.Kind() != reflect.Ptr
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ import (
|
||||||
piface "google.golang.org/protobuf/runtime/protoiface"
|
piface "google.golang.org/protobuf/runtime/protoiface"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var errDecode = errors.New("cannot parse invalid wire-format data")
|
||||||
|
|
||||||
type unmarshalOptions struct {
|
type unmarshalOptions struct {
|
||||||
flags protoiface.UnmarshalInputFlags
|
flags protoiface.UnmarshalInputFlags
|
||||||
resolver interface {
|
resolver interface {
|
||||||
|
|
@ -100,13 +102,13 @@ func (mi *MessageInfo) unmarshalPointer(b []byte, p pointer, groupTag protowire.
|
||||||
var n int
|
var n int
|
||||||
tag, n = protowire.ConsumeVarint(b)
|
tag, n = protowire.ConsumeVarint(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return out, protowire.ParseError(n)
|
return out, errDecode
|
||||||
}
|
}
|
||||||
b = b[n:]
|
b = b[n:]
|
||||||
}
|
}
|
||||||
var num protowire.Number
|
var num protowire.Number
|
||||||
if n := tag >> 3; n < uint64(protowire.MinValidNumber) || n > uint64(protowire.MaxValidNumber) {
|
if n := tag >> 3; n < uint64(protowire.MinValidNumber) || n > uint64(protowire.MaxValidNumber) {
|
||||||
return out, errors.New("invalid field number")
|
return out, errDecode
|
||||||
} else {
|
} else {
|
||||||
num = protowire.Number(n)
|
num = protowire.Number(n)
|
||||||
}
|
}
|
||||||
|
|
@ -114,7 +116,7 @@ func (mi *MessageInfo) unmarshalPointer(b []byte, p pointer, groupTag protowire.
|
||||||
|
|
||||||
if wtyp == protowire.EndGroupType {
|
if wtyp == protowire.EndGroupType {
|
||||||
if num != groupTag {
|
if num != groupTag {
|
||||||
return out, errors.New("mismatching end group marker")
|
return out, errDecode
|
||||||
}
|
}
|
||||||
groupTag = 0
|
groupTag = 0
|
||||||
break
|
break
|
||||||
|
|
@ -170,10 +172,10 @@ func (mi *MessageInfo) unmarshalPointer(b []byte, p pointer, groupTag protowire.
|
||||||
}
|
}
|
||||||
n = protowire.ConsumeFieldValue(num, wtyp, b)
|
n = protowire.ConsumeFieldValue(num, wtyp, b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return out, protowire.ParseError(n)
|
return out, errDecode
|
||||||
}
|
}
|
||||||
if !opts.DiscardUnknown() && mi.unknownOffset.IsValid() {
|
if !opts.DiscardUnknown() && mi.unknownOffset.IsValid() {
|
||||||
u := p.Apply(mi.unknownOffset).Bytes()
|
u := mi.mutableUnknownBytes(p)
|
||||||
*u = protowire.AppendTag(*u, num, wtyp)
|
*u = protowire.AppendTag(*u, num, wtyp)
|
||||||
*u = append(*u, b[:n]...)
|
*u = append(*u, b[:n]...)
|
||||||
}
|
}
|
||||||
|
|
@ -181,7 +183,7 @@ func (mi *MessageInfo) unmarshalPointer(b []byte, p pointer, groupTag protowire.
|
||||||
b = b[n:]
|
b = b[n:]
|
||||||
}
|
}
|
||||||
if groupTag != 0 {
|
if groupTag != 0 {
|
||||||
return out, errors.New("missing end group marker")
|
return out, errDecode
|
||||||
}
|
}
|
||||||
if mi.numRequiredFields > 0 && bits.OnesCount64(requiredMask) != int(mi.numRequiredFields) {
|
if mi.numRequiredFields > 0 && bits.OnesCount64(requiredMask) != int(mi.numRequiredFields) {
|
||||||
initialized = false
|
initialized = false
|
||||||
|
|
@ -221,7 +223,7 @@ func (mi *MessageInfo) unmarshalExtension(b []byte, num protowire.Number, wtyp p
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
case ValidationInvalid:
|
case ValidationInvalid:
|
||||||
return out, errors.New("invalid wire format")
|
return out, errDecode
|
||||||
case ValidationUnknown:
|
case ValidationUnknown:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,8 +79,9 @@ func (mi *MessageInfo) sizePointerSlow(p pointer, opts marshalOptions) (size int
|
||||||
size += f.funcs.size(fptr, f, opts)
|
size += f.funcs.size(fptr, f, opts)
|
||||||
}
|
}
|
||||||
if mi.unknownOffset.IsValid() {
|
if mi.unknownOffset.IsValid() {
|
||||||
u := *p.Apply(mi.unknownOffset).Bytes()
|
if u := mi.getUnknownBytes(p); u != nil {
|
||||||
size += len(u)
|
size += len(*u)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if mi.sizecacheOffset.IsValid() {
|
if mi.sizecacheOffset.IsValid() {
|
||||||
if size > math.MaxInt32 {
|
if size > math.MaxInt32 {
|
||||||
|
|
@ -141,8 +142,9 @@ func (mi *MessageInfo) marshalAppendPointer(b []byte, p pointer, opts marshalOpt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if mi.unknownOffset.IsValid() && !mi.isMessageSet {
|
if mi.unknownOffset.IsValid() && !mi.isMessageSet {
|
||||||
u := *p.Apply(mi.unknownOffset).Bytes()
|
if u := mi.getUnknownBytes(p); u != nil {
|
||||||
b = append(b, u...)
|
b = append(b, (*u)...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ func (Export) LegacyMessageTypeOf(m piface.MessageV1, name pref.FullName) pref.M
|
||||||
if mv := (Export{}).protoMessageV2Of(m); mv != nil {
|
if mv := (Export{}).protoMessageV2Of(m); mv != nil {
|
||||||
return mv.ProtoReflect().Type()
|
return mv.ProtoReflect().Type()
|
||||||
}
|
}
|
||||||
return legacyLoadMessageInfo(reflect.TypeOf(m), name)
|
return legacyLoadMessageType(reflect.TypeOf(m), name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSONEnum unmarshals an enum from a JSON-encoded input.
|
// UnmarshalJSONEnum unmarshals an enum from a JSON-encoded input.
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,8 @@ func (x placeholderExtension) Number() pref.FieldNumber { retu
|
||||||
func (x placeholderExtension) Cardinality() pref.Cardinality { return 0 }
|
func (x placeholderExtension) Cardinality() pref.Cardinality { return 0 }
|
||||||
func (x placeholderExtension) Kind() pref.Kind { return 0 }
|
func (x placeholderExtension) Kind() pref.Kind { return 0 }
|
||||||
func (x placeholderExtension) HasJSONName() bool { return false }
|
func (x placeholderExtension) HasJSONName() bool { return false }
|
||||||
func (x placeholderExtension) JSONName() string { return "" }
|
func (x placeholderExtension) JSONName() string { return "[" + string(x.name) + "]" }
|
||||||
|
func (x placeholderExtension) TextName() string { return "[" + string(x.name) + "]" }
|
||||||
func (x placeholderExtension) HasPresence() bool { return false }
|
func (x placeholderExtension) HasPresence() bool { return false }
|
||||||
func (x placeholderExtension) HasOptionalKeyword() bool { return false }
|
func (x placeholderExtension) HasOptionalKeyword() bool { return false }
|
||||||
func (x placeholderExtension) IsExtension() bool { return true }
|
func (x placeholderExtension) IsExtension() bool { return true }
|
||||||
|
|
|
||||||
|
|
@ -24,14 +24,24 @@ import (
|
||||||
// legacyWrapMessage wraps v as a protoreflect.Message,
|
// legacyWrapMessage wraps v as a protoreflect.Message,
|
||||||
// where v must be a *struct kind and not implement the v2 API already.
|
// where v must be a *struct kind and not implement the v2 API already.
|
||||||
func legacyWrapMessage(v reflect.Value) pref.Message {
|
func legacyWrapMessage(v reflect.Value) pref.Message {
|
||||||
typ := v.Type()
|
t := v.Type()
|
||||||
if typ.Kind() != reflect.Ptr || typ.Elem().Kind() != reflect.Struct {
|
if t.Kind() != reflect.Ptr || t.Elem().Kind() != reflect.Struct {
|
||||||
return aberrantMessage{v: v}
|
return aberrantMessage{v: v}
|
||||||
}
|
}
|
||||||
mt := legacyLoadMessageInfo(typ, "")
|
mt := legacyLoadMessageInfo(t, "")
|
||||||
return mt.MessageOf(v.Interface())
|
return mt.MessageOf(v.Interface())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// legacyLoadMessageType dynamically loads a protoreflect.Type for t,
|
||||||
|
// where t must be not implement the v2 API already.
|
||||||
|
// The provided name is used if it cannot be determined from the message.
|
||||||
|
func legacyLoadMessageType(t reflect.Type, name pref.FullName) protoreflect.MessageType {
|
||||||
|
if t.Kind() != reflect.Ptr || t.Elem().Kind() != reflect.Struct {
|
||||||
|
return aberrantMessageType{t}
|
||||||
|
}
|
||||||
|
return legacyLoadMessageInfo(t, name)
|
||||||
|
}
|
||||||
|
|
||||||
var legacyMessageTypeCache sync.Map // map[reflect.Type]*MessageInfo
|
var legacyMessageTypeCache sync.Map // map[reflect.Type]*MessageInfo
|
||||||
|
|
||||||
// legacyLoadMessageInfo dynamically loads a *MessageInfo for t,
|
// legacyLoadMessageInfo dynamically loads a *MessageInfo for t,
|
||||||
|
|
@ -49,8 +59,9 @@ func legacyLoadMessageInfo(t reflect.Type, name pref.FullName) *MessageInfo {
|
||||||
GoReflectType: t,
|
GoReflectType: t,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hasMarshal, hasUnmarshal bool
|
||||||
v := reflect.Zero(t).Interface()
|
v := reflect.Zero(t).Interface()
|
||||||
if _, ok := v.(legacyMarshaler); ok {
|
if _, hasMarshal = v.(legacyMarshaler); hasMarshal {
|
||||||
mi.methods.Marshal = legacyMarshal
|
mi.methods.Marshal = legacyMarshal
|
||||||
|
|
||||||
// We have no way to tell whether the type's Marshal method
|
// We have no way to tell whether the type's Marshal method
|
||||||
|
|
@ -59,10 +70,10 @@ func legacyLoadMessageInfo(t reflect.Type, name pref.FullName) *MessageInfo {
|
||||||
// calling Marshal methods when present.
|
// calling Marshal methods when present.
|
||||||
mi.methods.Flags |= piface.SupportMarshalDeterministic
|
mi.methods.Flags |= piface.SupportMarshalDeterministic
|
||||||
}
|
}
|
||||||
if _, ok := v.(legacyUnmarshaler); ok {
|
if _, hasUnmarshal = v.(legacyUnmarshaler); hasUnmarshal {
|
||||||
mi.methods.Unmarshal = legacyUnmarshal
|
mi.methods.Unmarshal = legacyUnmarshal
|
||||||
}
|
}
|
||||||
if _, ok := v.(legacyMerger); ok {
|
if _, hasMerge := v.(legacyMerger); hasMerge || (hasMarshal && hasUnmarshal) {
|
||||||
mi.methods.Merge = legacyMerge
|
mi.methods.Merge = legacyMerge
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,7 +86,7 @@ func legacyLoadMessageInfo(t reflect.Type, name pref.FullName) *MessageInfo {
|
||||||
var legacyMessageDescCache sync.Map // map[reflect.Type]protoreflect.MessageDescriptor
|
var legacyMessageDescCache sync.Map // map[reflect.Type]protoreflect.MessageDescriptor
|
||||||
|
|
||||||
// LegacyLoadMessageDesc returns an MessageDescriptor derived from the Go type,
|
// LegacyLoadMessageDesc returns an MessageDescriptor derived from the Go type,
|
||||||
// which must be a *struct kind and not implement the v2 API already.
|
// which should be a *struct kind and must not implement the v2 API already.
|
||||||
//
|
//
|
||||||
// This is exported for testing purposes.
|
// This is exported for testing purposes.
|
||||||
func LegacyLoadMessageDesc(t reflect.Type) pref.MessageDescriptor {
|
func LegacyLoadMessageDesc(t reflect.Type) pref.MessageDescriptor {
|
||||||
|
|
@ -114,6 +125,7 @@ func legacyLoadMessageDesc(t reflect.Type, name pref.FullName) pref.MessageDescr
|
||||||
// If the Go type has no fields, then this might be a proto3 empty message
|
// If the Go type has no fields, then this might be a proto3 empty message
|
||||||
// from before the size cache was added. If there are any fields, check to
|
// from before the size cache was added. If there are any fields, check to
|
||||||
// see that at least one of them looks like something we generated.
|
// see that at least one of them looks like something we generated.
|
||||||
|
if t.Elem().Kind() == reflect.Struct {
|
||||||
if nfield := t.Elem().NumField(); nfield > 0 {
|
if nfield := t.Elem().NumField(); nfield > 0 {
|
||||||
hasProtoField := false
|
hasProtoField := false
|
||||||
for i := 0; i < nfield; i++ {
|
for i := 0; i < nfield; i++ {
|
||||||
|
|
@ -127,6 +139,7 @@ func legacyLoadMessageDesc(t reflect.Type, name pref.FullName) pref.MessageDescr
|
||||||
return aberrantLoadMessageDesc(t, name)
|
return aberrantLoadMessageDesc(t, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
md := legacyLoadFileDesc(b).Messages().Get(idxs[0])
|
md := legacyLoadFileDesc(b).Messages().Get(idxs[0])
|
||||||
for _, i := range idxs[1:] {
|
for _, i := range idxs[1:] {
|
||||||
|
|
@ -370,7 +383,7 @@ type legacyMerger interface {
|
||||||
Merge(protoiface.MessageV1)
|
Merge(protoiface.MessageV1)
|
||||||
}
|
}
|
||||||
|
|
||||||
var legacyProtoMethods = &piface.Methods{
|
var aberrantProtoMethods = &piface.Methods{
|
||||||
Marshal: legacyMarshal,
|
Marshal: legacyMarshal,
|
||||||
Unmarshal: legacyUnmarshal,
|
Unmarshal: legacyUnmarshal,
|
||||||
Merge: legacyMerge,
|
Merge: legacyMerge,
|
||||||
|
|
@ -401,18 +414,40 @@ func legacyUnmarshal(in piface.UnmarshalInput) (piface.UnmarshalOutput, error) {
|
||||||
v := in.Message.(unwrapper).protoUnwrap()
|
v := in.Message.(unwrapper).protoUnwrap()
|
||||||
unmarshaler, ok := v.(legacyUnmarshaler)
|
unmarshaler, ok := v.(legacyUnmarshaler)
|
||||||
if !ok {
|
if !ok {
|
||||||
return piface.UnmarshalOutput{}, errors.New("%T does not implement Marshal", v)
|
return piface.UnmarshalOutput{}, errors.New("%T does not implement Unmarshal", v)
|
||||||
}
|
}
|
||||||
return piface.UnmarshalOutput{}, unmarshaler.Unmarshal(in.Buf)
|
return piface.UnmarshalOutput{}, unmarshaler.Unmarshal(in.Buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
func legacyMerge(in piface.MergeInput) piface.MergeOutput {
|
func legacyMerge(in piface.MergeInput) piface.MergeOutput {
|
||||||
|
// Check whether this supports the legacy merger.
|
||||||
dstv := in.Destination.(unwrapper).protoUnwrap()
|
dstv := in.Destination.(unwrapper).protoUnwrap()
|
||||||
merger, ok := dstv.(legacyMerger)
|
merger, ok := dstv.(legacyMerger)
|
||||||
|
if ok {
|
||||||
|
merger.Merge(Export{}.ProtoMessageV1Of(in.Source))
|
||||||
|
return piface.MergeOutput{Flags: piface.MergeComplete}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If legacy merger is unavailable, implement merge in terms of
|
||||||
|
// a marshal and unmarshal operation.
|
||||||
|
srcv := in.Source.(unwrapper).protoUnwrap()
|
||||||
|
marshaler, ok := srcv.(legacyMarshaler)
|
||||||
if !ok {
|
if !ok {
|
||||||
return piface.MergeOutput{}
|
return piface.MergeOutput{}
|
||||||
}
|
}
|
||||||
merger.Merge(Export{}.ProtoMessageV1Of(in.Source))
|
dstv = in.Destination.(unwrapper).protoUnwrap()
|
||||||
|
unmarshaler, ok := dstv.(legacyUnmarshaler)
|
||||||
|
if !ok {
|
||||||
|
return piface.MergeOutput{}
|
||||||
|
}
|
||||||
|
b, err := marshaler.Marshal()
|
||||||
|
if err != nil {
|
||||||
|
return piface.MergeOutput{}
|
||||||
|
}
|
||||||
|
err = unmarshaler.Unmarshal(b)
|
||||||
|
if err != nil {
|
||||||
|
return piface.MergeOutput{}
|
||||||
|
}
|
||||||
return piface.MergeOutput{Flags: piface.MergeComplete}
|
return piface.MergeOutput{Flags: piface.MergeComplete}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -422,6 +457,9 @@ type aberrantMessageType struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mt aberrantMessageType) New() pref.Message {
|
func (mt aberrantMessageType) New() pref.Message {
|
||||||
|
if mt.t.Kind() == reflect.Ptr {
|
||||||
|
return aberrantMessage{reflect.New(mt.t.Elem())}
|
||||||
|
}
|
||||||
return aberrantMessage{reflect.Zero(mt.t)}
|
return aberrantMessage{reflect.Zero(mt.t)}
|
||||||
}
|
}
|
||||||
func (mt aberrantMessageType) Zero() pref.Message {
|
func (mt aberrantMessageType) Zero() pref.Message {
|
||||||
|
|
@ -443,6 +481,17 @@ type aberrantMessage struct {
|
||||||
v reflect.Value
|
v reflect.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset implements the v1 proto.Message.Reset method.
|
||||||
|
func (m aberrantMessage) Reset() {
|
||||||
|
if mr, ok := m.v.Interface().(interface{ Reset() }); ok {
|
||||||
|
mr.Reset()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if m.v.Kind() == reflect.Ptr && !m.v.IsNil() {
|
||||||
|
m.v.Elem().Set(reflect.Zero(m.v.Type().Elem()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (m aberrantMessage) ProtoReflect() pref.Message {
|
func (m aberrantMessage) ProtoReflect() pref.Message {
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
@ -454,33 +503,40 @@ func (m aberrantMessage) Type() pref.MessageType {
|
||||||
return aberrantMessageType{m.v.Type()}
|
return aberrantMessageType{m.v.Type()}
|
||||||
}
|
}
|
||||||
func (m aberrantMessage) New() pref.Message {
|
func (m aberrantMessage) New() pref.Message {
|
||||||
|
if m.v.Type().Kind() == reflect.Ptr {
|
||||||
|
return aberrantMessage{reflect.New(m.v.Type().Elem())}
|
||||||
|
}
|
||||||
return aberrantMessage{reflect.Zero(m.v.Type())}
|
return aberrantMessage{reflect.Zero(m.v.Type())}
|
||||||
}
|
}
|
||||||
func (m aberrantMessage) Interface() pref.ProtoMessage {
|
func (m aberrantMessage) Interface() pref.ProtoMessage {
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
func (m aberrantMessage) Range(f func(pref.FieldDescriptor, pref.Value) bool) {
|
func (m aberrantMessage) Range(f func(pref.FieldDescriptor, pref.Value) bool) {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
func (m aberrantMessage) Has(pref.FieldDescriptor) bool {
|
func (m aberrantMessage) Has(pref.FieldDescriptor) bool {
|
||||||
panic("invalid field descriptor")
|
return false
|
||||||
}
|
}
|
||||||
func (m aberrantMessage) Clear(pref.FieldDescriptor) {
|
func (m aberrantMessage) Clear(pref.FieldDescriptor) {
|
||||||
panic("invalid field descriptor")
|
panic("invalid Message.Clear on " + string(m.Descriptor().FullName()))
|
||||||
}
|
}
|
||||||
func (m aberrantMessage) Get(pref.FieldDescriptor) pref.Value {
|
func (m aberrantMessage) Get(fd pref.FieldDescriptor) pref.Value {
|
||||||
panic("invalid field descriptor")
|
if fd.Default().IsValid() {
|
||||||
|
return fd.Default()
|
||||||
|
}
|
||||||
|
panic("invalid Message.Get on " + string(m.Descriptor().FullName()))
|
||||||
}
|
}
|
||||||
func (m aberrantMessage) Set(pref.FieldDescriptor, pref.Value) {
|
func (m aberrantMessage) Set(pref.FieldDescriptor, pref.Value) {
|
||||||
panic("invalid field descriptor")
|
panic("invalid Message.Set on " + string(m.Descriptor().FullName()))
|
||||||
}
|
}
|
||||||
func (m aberrantMessage) Mutable(pref.FieldDescriptor) pref.Value {
|
func (m aberrantMessage) Mutable(pref.FieldDescriptor) pref.Value {
|
||||||
panic("invalid field descriptor")
|
panic("invalid Message.Mutable on " + string(m.Descriptor().FullName()))
|
||||||
}
|
}
|
||||||
func (m aberrantMessage) NewField(pref.FieldDescriptor) pref.Value {
|
func (m aberrantMessage) NewField(pref.FieldDescriptor) pref.Value {
|
||||||
panic("invalid field descriptor")
|
panic("invalid Message.NewField on " + string(m.Descriptor().FullName()))
|
||||||
}
|
}
|
||||||
func (m aberrantMessage) WhichOneof(pref.OneofDescriptor) pref.FieldDescriptor {
|
func (m aberrantMessage) WhichOneof(pref.OneofDescriptor) pref.FieldDescriptor {
|
||||||
panic("invalid oneof descriptor")
|
panic("invalid Message.WhichOneof descriptor on " + string(m.Descriptor().FullName()))
|
||||||
}
|
}
|
||||||
func (m aberrantMessage) GetUnknown() pref.RawFields {
|
func (m aberrantMessage) GetUnknown() pref.RawFields {
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -489,13 +545,13 @@ func (m aberrantMessage) SetUnknown(pref.RawFields) {
|
||||||
// SetUnknown discards its input on messages which don't support unknown field storage.
|
// SetUnknown discards its input on messages which don't support unknown field storage.
|
||||||
}
|
}
|
||||||
func (m aberrantMessage) IsValid() bool {
|
func (m aberrantMessage) IsValid() bool {
|
||||||
// An invalid message is a read-only, empty message. Since we don't know anything
|
if m.v.Kind() == reflect.Ptr {
|
||||||
// about the alleged contents of this message, we can't say with confidence that
|
return !m.v.IsNil()
|
||||||
// it is invalid in this sense. Therefore, report it as valid.
|
}
|
||||||
return true
|
return false
|
||||||
}
|
}
|
||||||
func (m aberrantMessage) ProtoMethods() *piface.Methods {
|
func (m aberrantMessage) ProtoMethods() *piface.Methods {
|
||||||
return legacyProtoMethods
|
return aberrantProtoMethods
|
||||||
}
|
}
|
||||||
func (m aberrantMessage) protoUnwrap() interface{} {
|
func (m aberrantMessage) protoUnwrap() interface{} {
|
||||||
return m.v.Interface()
|
return m.v.Interface()
|
||||||
|
|
|
||||||
|
|
@ -77,9 +77,9 @@ func (mi *MessageInfo) mergePointer(dst, src pointer, opts mergeOptions) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if mi.unknownOffset.IsValid() {
|
if mi.unknownOffset.IsValid() {
|
||||||
du := dst.Apply(mi.unknownOffset).Bytes()
|
su := mi.getUnknownBytes(src)
|
||||||
su := src.Apply(mi.unknownOffset).Bytes()
|
if su != nil && len(*su) > 0 {
|
||||||
if len(*su) > 0 {
|
du := mi.mutableUnknownBytes(dst)
|
||||||
*du = append(*du, *su...)
|
*du = append(*du, *su...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import (
|
||||||
"google.golang.org/protobuf/internal/genid"
|
"google.golang.org/protobuf/internal/genid"
|
||||||
"google.golang.org/protobuf/reflect/protoreflect"
|
"google.golang.org/protobuf/reflect/protoreflect"
|
||||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
preg "google.golang.org/protobuf/reflect/protoregistry"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MessageInfo provides protobuf related functionality for a given Go type
|
// MessageInfo provides protobuf related functionality for a given Go type
|
||||||
|
|
@ -109,22 +110,29 @@ func (mi *MessageInfo) getPointer(m pref.Message) (p pointer, ok bool) {
|
||||||
type (
|
type (
|
||||||
SizeCache = int32
|
SizeCache = int32
|
||||||
WeakFields = map[int32]protoreflect.ProtoMessage
|
WeakFields = map[int32]protoreflect.ProtoMessage
|
||||||
UnknownFields = []byte
|
UnknownFields = unknownFieldsA // TODO: switch to unknownFieldsB
|
||||||
|
unknownFieldsA = []byte
|
||||||
|
unknownFieldsB = *[]byte
|
||||||
ExtensionFields = map[int32]ExtensionField
|
ExtensionFields = map[int32]ExtensionField
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
sizecacheType = reflect.TypeOf(SizeCache(0))
|
sizecacheType = reflect.TypeOf(SizeCache(0))
|
||||||
weakFieldsType = reflect.TypeOf(WeakFields(nil))
|
weakFieldsType = reflect.TypeOf(WeakFields(nil))
|
||||||
unknownFieldsType = reflect.TypeOf(UnknownFields(nil))
|
unknownFieldsAType = reflect.TypeOf(unknownFieldsA(nil))
|
||||||
|
unknownFieldsBType = reflect.TypeOf(unknownFieldsB(nil))
|
||||||
extensionFieldsType = reflect.TypeOf(ExtensionFields(nil))
|
extensionFieldsType = reflect.TypeOf(ExtensionFields(nil))
|
||||||
)
|
)
|
||||||
|
|
||||||
type structInfo struct {
|
type structInfo struct {
|
||||||
sizecacheOffset offset
|
sizecacheOffset offset
|
||||||
|
sizecacheType reflect.Type
|
||||||
weakOffset offset
|
weakOffset offset
|
||||||
|
weakType reflect.Type
|
||||||
unknownOffset offset
|
unknownOffset offset
|
||||||
|
unknownType reflect.Type
|
||||||
extensionOffset offset
|
extensionOffset offset
|
||||||
|
extensionType reflect.Type
|
||||||
|
|
||||||
fieldsByNumber map[pref.FieldNumber]reflect.StructField
|
fieldsByNumber map[pref.FieldNumber]reflect.StructField
|
||||||
oneofsByName map[pref.Name]reflect.StructField
|
oneofsByName map[pref.Name]reflect.StructField
|
||||||
|
|
@ -151,18 +159,22 @@ fieldLoop:
|
||||||
case genid.SizeCache_goname, genid.SizeCacheA_goname:
|
case genid.SizeCache_goname, genid.SizeCacheA_goname:
|
||||||
if f.Type == sizecacheType {
|
if f.Type == sizecacheType {
|
||||||
si.sizecacheOffset = offsetOf(f, mi.Exporter)
|
si.sizecacheOffset = offsetOf(f, mi.Exporter)
|
||||||
|
si.sizecacheType = f.Type
|
||||||
}
|
}
|
||||||
case genid.WeakFields_goname, genid.WeakFieldsA_goname:
|
case genid.WeakFields_goname, genid.WeakFieldsA_goname:
|
||||||
if f.Type == weakFieldsType {
|
if f.Type == weakFieldsType {
|
||||||
si.weakOffset = offsetOf(f, mi.Exporter)
|
si.weakOffset = offsetOf(f, mi.Exporter)
|
||||||
|
si.weakType = f.Type
|
||||||
}
|
}
|
||||||
case genid.UnknownFields_goname, genid.UnknownFieldsA_goname:
|
case genid.UnknownFields_goname, genid.UnknownFieldsA_goname:
|
||||||
if f.Type == unknownFieldsType {
|
if f.Type == unknownFieldsAType || f.Type == unknownFieldsBType {
|
||||||
si.unknownOffset = offsetOf(f, mi.Exporter)
|
si.unknownOffset = offsetOf(f, mi.Exporter)
|
||||||
|
si.unknownType = f.Type
|
||||||
}
|
}
|
||||||
case genid.ExtensionFields_goname, genid.ExtensionFieldsA_goname, genid.ExtensionFieldsB_goname:
|
case genid.ExtensionFields_goname, genid.ExtensionFieldsA_goname, genid.ExtensionFieldsB_goname:
|
||||||
if f.Type == extensionFieldsType {
|
if f.Type == extensionFieldsType {
|
||||||
si.extensionOffset = offsetOf(f, mi.Exporter)
|
si.extensionOffset = offsetOf(f, mi.Exporter)
|
||||||
|
si.extensionType = f.Type
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
for _, s := range strings.Split(f.Tag.Get("protobuf"), ",") {
|
for _, s := range strings.Split(f.Tag.Get("protobuf"), ",") {
|
||||||
|
|
@ -212,4 +224,53 @@ func (mi *MessageInfo) New() protoreflect.Message {
|
||||||
func (mi *MessageInfo) Zero() protoreflect.Message {
|
func (mi *MessageInfo) Zero() protoreflect.Message {
|
||||||
return mi.MessageOf(reflect.Zero(mi.GoReflectType).Interface())
|
return mi.MessageOf(reflect.Zero(mi.GoReflectType).Interface())
|
||||||
}
|
}
|
||||||
func (mi *MessageInfo) Descriptor() protoreflect.MessageDescriptor { return mi.Desc }
|
func (mi *MessageInfo) Descriptor() protoreflect.MessageDescriptor {
|
||||||
|
return mi.Desc
|
||||||
|
}
|
||||||
|
func (mi *MessageInfo) Enum(i int) protoreflect.EnumType {
|
||||||
|
mi.init()
|
||||||
|
fd := mi.Desc.Fields().Get(i)
|
||||||
|
return Export{}.EnumTypeOf(mi.fieldTypes[fd.Number()])
|
||||||
|
}
|
||||||
|
func (mi *MessageInfo) Message(i int) protoreflect.MessageType {
|
||||||
|
mi.init()
|
||||||
|
fd := mi.Desc.Fields().Get(i)
|
||||||
|
switch {
|
||||||
|
case fd.IsWeak():
|
||||||
|
mt, _ := preg.GlobalTypes.FindMessageByName(fd.Message().FullName())
|
||||||
|
return mt
|
||||||
|
case fd.IsMap():
|
||||||
|
return mapEntryType{fd.Message(), mi.fieldTypes[fd.Number()]}
|
||||||
|
default:
|
||||||
|
return Export{}.MessageTypeOf(mi.fieldTypes[fd.Number()])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type mapEntryType struct {
|
||||||
|
desc protoreflect.MessageDescriptor
|
||||||
|
valType interface{} // zero value of enum or message type
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mt mapEntryType) New() protoreflect.Message {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (mt mapEntryType) Zero() protoreflect.Message {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (mt mapEntryType) Descriptor() protoreflect.MessageDescriptor {
|
||||||
|
return mt.desc
|
||||||
|
}
|
||||||
|
func (mt mapEntryType) Enum(i int) protoreflect.EnumType {
|
||||||
|
fd := mt.desc.Fields().Get(i)
|
||||||
|
if fd.Enum() == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return Export{}.EnumTypeOf(mt.valType)
|
||||||
|
}
|
||||||
|
func (mt mapEntryType) Message(i int) protoreflect.MessageType {
|
||||||
|
fd := mt.desc.Fields().Get(i)
|
||||||
|
if fd.Message() == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return Export{}.MessageTypeOf(mt.valType)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/internal/detrand"
|
||||||
"google.golang.org/protobuf/internal/pragma"
|
"google.golang.org/protobuf/internal/pragma"
|
||||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
)
|
)
|
||||||
|
|
@ -16,6 +17,11 @@ type reflectMessageInfo struct {
|
||||||
fields map[pref.FieldNumber]*fieldInfo
|
fields map[pref.FieldNumber]*fieldInfo
|
||||||
oneofs map[pref.Name]*oneofInfo
|
oneofs map[pref.Name]*oneofInfo
|
||||||
|
|
||||||
|
// fieldTypes contains the zero value of an enum or message field.
|
||||||
|
// For lists, it contains the element type.
|
||||||
|
// For maps, it contains the entry value type.
|
||||||
|
fieldTypes map[pref.FieldNumber]interface{}
|
||||||
|
|
||||||
// denseFields is a subset of fields where:
|
// denseFields is a subset of fields where:
|
||||||
// 0 < fieldDesc.Number() < len(denseFields)
|
// 0 < fieldDesc.Number() < len(denseFields)
|
||||||
// It provides faster access to the fieldInfo, but may be incomplete.
|
// It provides faster access to the fieldInfo, but may be incomplete.
|
||||||
|
|
@ -36,6 +42,7 @@ func (mi *MessageInfo) makeReflectFuncs(t reflect.Type, si structInfo) {
|
||||||
mi.makeKnownFieldsFunc(si)
|
mi.makeKnownFieldsFunc(si)
|
||||||
mi.makeUnknownFieldsFunc(t, si)
|
mi.makeUnknownFieldsFunc(t, si)
|
||||||
mi.makeExtensionFieldsFunc(t, si)
|
mi.makeExtensionFieldsFunc(t, si)
|
||||||
|
mi.makeFieldTypes(si)
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeKnownFieldsFunc generates functions for operations that can be performed
|
// makeKnownFieldsFunc generates functions for operations that can be performed
|
||||||
|
|
@ -51,17 +58,23 @@ func (mi *MessageInfo) makeKnownFieldsFunc(si structInfo) {
|
||||||
for i := 0; i < fds.Len(); i++ {
|
for i := 0; i < fds.Len(); i++ {
|
||||||
fd := fds.Get(i)
|
fd := fds.Get(i)
|
||||||
fs := si.fieldsByNumber[fd.Number()]
|
fs := si.fieldsByNumber[fd.Number()]
|
||||||
|
isOneof := fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic()
|
||||||
|
if isOneof {
|
||||||
|
fs = si.oneofsByName[fd.ContainingOneof().Name()]
|
||||||
|
}
|
||||||
var fi fieldInfo
|
var fi fieldInfo
|
||||||
switch {
|
switch {
|
||||||
case fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic():
|
case fs.Type == nil:
|
||||||
fi = fieldInfoForOneof(fd, si.oneofsByName[fd.ContainingOneof().Name()], mi.Exporter, si.oneofWrappersByNumber[fd.Number()])
|
fi = fieldInfoForMissing(fd) // never occurs for officially generated message types
|
||||||
|
case isOneof:
|
||||||
|
fi = fieldInfoForOneof(fd, fs, mi.Exporter, si.oneofWrappersByNumber[fd.Number()])
|
||||||
case fd.IsMap():
|
case fd.IsMap():
|
||||||
fi = fieldInfoForMap(fd, fs, mi.Exporter)
|
fi = fieldInfoForMap(fd, fs, mi.Exporter)
|
||||||
case fd.IsList():
|
case fd.IsList():
|
||||||
fi = fieldInfoForList(fd, fs, mi.Exporter)
|
fi = fieldInfoForList(fd, fs, mi.Exporter)
|
||||||
case fd.IsWeak():
|
case fd.IsWeak():
|
||||||
fi = fieldInfoForWeakMessage(fd, si.weakOffset)
|
fi = fieldInfoForWeakMessage(fd, si.weakOffset)
|
||||||
case fd.Kind() == pref.MessageKind || fd.Kind() == pref.GroupKind:
|
case fd.Message() != nil:
|
||||||
fi = fieldInfoForMessage(fd, fs, mi.Exporter)
|
fi = fieldInfoForMessage(fd, fs, mi.Exporter)
|
||||||
default:
|
default:
|
||||||
fi = fieldInfoForScalar(fd, fs, mi.Exporter)
|
fi = fieldInfoForScalar(fd, fs, mi.Exporter)
|
||||||
|
|
@ -92,27 +105,53 @@ func (mi *MessageInfo) makeKnownFieldsFunc(si structInfo) {
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Introduce instability to iteration order, but keep it deterministic.
|
||||||
|
if len(mi.rangeInfos) > 1 && detrand.Bool() {
|
||||||
|
i := detrand.Intn(len(mi.rangeInfos) - 1)
|
||||||
|
mi.rangeInfos[i], mi.rangeInfos[i+1] = mi.rangeInfos[i+1], mi.rangeInfos[i]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mi *MessageInfo) makeUnknownFieldsFunc(t reflect.Type, si structInfo) {
|
func (mi *MessageInfo) makeUnknownFieldsFunc(t reflect.Type, si structInfo) {
|
||||||
mi.getUnknown = func(pointer) pref.RawFields { return nil }
|
switch {
|
||||||
mi.setUnknown = func(pointer, pref.RawFields) { return }
|
case si.unknownOffset.IsValid() && si.unknownType == unknownFieldsAType:
|
||||||
if si.unknownOffset.IsValid() {
|
// Handle as []byte.
|
||||||
mi.getUnknown = func(p pointer) pref.RawFields {
|
mi.getUnknown = func(p pointer) pref.RawFields {
|
||||||
if p.IsNil() {
|
if p.IsNil() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
rv := p.Apply(si.unknownOffset).AsValueOf(unknownFieldsType)
|
return *p.Apply(mi.unknownOffset).Bytes()
|
||||||
return pref.RawFields(*rv.Interface().(*[]byte))
|
|
||||||
}
|
}
|
||||||
mi.setUnknown = func(p pointer, b pref.RawFields) {
|
mi.setUnknown = func(p pointer, b pref.RawFields) {
|
||||||
if p.IsNil() {
|
if p.IsNil() {
|
||||||
panic("invalid SetUnknown on nil Message")
|
panic("invalid SetUnknown on nil Message")
|
||||||
}
|
}
|
||||||
rv := p.Apply(si.unknownOffset).AsValueOf(unknownFieldsType)
|
*p.Apply(mi.unknownOffset).Bytes() = b
|
||||||
*rv.Interface().(*[]byte) = []byte(b)
|
|
||||||
}
|
}
|
||||||
} else {
|
case si.unknownOffset.IsValid() && si.unknownType == unknownFieldsBType:
|
||||||
|
// Handle as *[]byte.
|
||||||
|
mi.getUnknown = func(p pointer) pref.RawFields {
|
||||||
|
if p.IsNil() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
bp := p.Apply(mi.unknownOffset).BytesPtr()
|
||||||
|
if *bp == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return **bp
|
||||||
|
}
|
||||||
|
mi.setUnknown = func(p pointer, b pref.RawFields) {
|
||||||
|
if p.IsNil() {
|
||||||
|
panic("invalid SetUnknown on nil Message")
|
||||||
|
}
|
||||||
|
bp := p.Apply(mi.unknownOffset).BytesPtr()
|
||||||
|
if *bp == nil {
|
||||||
|
*bp = new([]byte)
|
||||||
|
}
|
||||||
|
**bp = b
|
||||||
|
}
|
||||||
|
default:
|
||||||
mi.getUnknown = func(pointer) pref.RawFields {
|
mi.getUnknown = func(pointer) pref.RawFields {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -139,6 +178,58 @@ func (mi *MessageInfo) makeExtensionFieldsFunc(t reflect.Type, si structInfo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func (mi *MessageInfo) makeFieldTypes(si structInfo) {
|
||||||
|
md := mi.Desc
|
||||||
|
fds := md.Fields()
|
||||||
|
for i := 0; i < fds.Len(); i++ {
|
||||||
|
var ft reflect.Type
|
||||||
|
fd := fds.Get(i)
|
||||||
|
fs := si.fieldsByNumber[fd.Number()]
|
||||||
|
isOneof := fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic()
|
||||||
|
if isOneof {
|
||||||
|
fs = si.oneofsByName[fd.ContainingOneof().Name()]
|
||||||
|
}
|
||||||
|
var isMessage bool
|
||||||
|
switch {
|
||||||
|
case fs.Type == nil:
|
||||||
|
continue // never occurs for officially generated message types
|
||||||
|
case isOneof:
|
||||||
|
if fd.Enum() != nil || fd.Message() != nil {
|
||||||
|
ft = si.oneofWrappersByNumber[fd.Number()].Field(0).Type
|
||||||
|
}
|
||||||
|
case fd.IsMap():
|
||||||
|
if fd.MapValue().Enum() != nil || fd.MapValue().Message() != nil {
|
||||||
|
ft = fs.Type.Elem()
|
||||||
|
}
|
||||||
|
isMessage = fd.MapValue().Message() != nil
|
||||||
|
case fd.IsList():
|
||||||
|
if fd.Enum() != nil || fd.Message() != nil {
|
||||||
|
ft = fs.Type.Elem()
|
||||||
|
}
|
||||||
|
isMessage = fd.Message() != nil
|
||||||
|
case fd.Enum() != nil:
|
||||||
|
ft = fs.Type
|
||||||
|
if fd.HasPresence() && ft.Kind() == reflect.Ptr {
|
||||||
|
ft = ft.Elem()
|
||||||
|
}
|
||||||
|
case fd.Message() != nil:
|
||||||
|
ft = fs.Type
|
||||||
|
if fd.IsWeak() {
|
||||||
|
ft = nil
|
||||||
|
}
|
||||||
|
isMessage = true
|
||||||
|
}
|
||||||
|
if isMessage && ft != nil && ft.Kind() != reflect.Ptr {
|
||||||
|
ft = reflect.PtrTo(ft) // never occurs for officially generated message types
|
||||||
|
}
|
||||||
|
if ft != nil {
|
||||||
|
if mi.fieldTypes == nil {
|
||||||
|
mi.fieldTypes = make(map[pref.FieldNumber]interface{})
|
||||||
|
}
|
||||||
|
mi.fieldTypes[fd.Number()] = reflect.Zero(ft).Interface()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type extensionMap map[int32]ExtensionField
|
type extensionMap map[int32]ExtensionField
|
||||||
|
|
||||||
|
|
@ -306,7 +397,6 @@ var (
|
||||||
// pointer to a named Go struct. If the provided type has a ProtoReflect method,
|
// pointer to a named Go struct. If the provided type has a ProtoReflect method,
|
||||||
// it must be implemented by calling this method.
|
// it must be implemented by calling this method.
|
||||||
func (mi *MessageInfo) MessageOf(m interface{}) pref.Message {
|
func (mi *MessageInfo) MessageOf(m interface{}) pref.Message {
|
||||||
// TODO: Switch the input to be an opaque Pointer.
|
|
||||||
if reflect.TypeOf(m) != mi.GoReflectType {
|
if reflect.TypeOf(m) != mi.GoReflectType {
|
||||||
panic(fmt.Sprintf("type mismatch: got %T, want %v", m, mi.GoReflectType))
|
panic(fmt.Sprintf("type mismatch: got %T, want %v", m, mi.GoReflectType))
|
||||||
}
|
}
|
||||||
|
|
@ -320,6 +410,17 @@ func (mi *MessageInfo) MessageOf(m interface{}) pref.Message {
|
||||||
func (m *messageReflectWrapper) pointer() pointer { return m.p }
|
func (m *messageReflectWrapper) pointer() pointer { return m.p }
|
||||||
func (m *messageReflectWrapper) messageInfo() *MessageInfo { return m.mi }
|
func (m *messageReflectWrapper) messageInfo() *MessageInfo { return m.mi }
|
||||||
|
|
||||||
|
// Reset implements the v1 proto.Message.Reset method.
|
||||||
|
func (m *messageIfaceWrapper) Reset() {
|
||||||
|
if mr, ok := m.protoUnwrap().(interface{ Reset() }); ok {
|
||||||
|
mr.Reset()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
rv := reflect.ValueOf(m.protoUnwrap())
|
||||||
|
if rv.Kind() == reflect.Ptr && !rv.IsNil() {
|
||||||
|
rv.Elem().Set(reflect.Zero(rv.Type().Elem()))
|
||||||
|
}
|
||||||
|
}
|
||||||
func (m *messageIfaceWrapper) ProtoReflect() pref.Message {
|
func (m *messageIfaceWrapper) ProtoReflect() pref.Message {
|
||||||
return (*messageReflectWrapper)(m)
|
return (*messageReflectWrapper)(m)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,39 @@ type fieldInfo struct {
|
||||||
newField func() pref.Value
|
newField func() pref.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func fieldInfoForMissing(fd pref.FieldDescriptor) fieldInfo {
|
||||||
|
// This never occurs for generated message types.
|
||||||
|
// It implies that a hand-crafted type has missing Go fields
|
||||||
|
// for specific protobuf message fields.
|
||||||
|
return fieldInfo{
|
||||||
|
fieldDesc: fd,
|
||||||
|
has: func(p pointer) bool {
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
clear: func(p pointer) {
|
||||||
|
panic("missing Go struct field for " + string(fd.FullName()))
|
||||||
|
},
|
||||||
|
get: func(p pointer) pref.Value {
|
||||||
|
return fd.Default()
|
||||||
|
},
|
||||||
|
set: func(p pointer, v pref.Value) {
|
||||||
|
panic("missing Go struct field for " + string(fd.FullName()))
|
||||||
|
},
|
||||||
|
mutable: func(p pointer) pref.Value {
|
||||||
|
panic("missing Go struct field for " + string(fd.FullName()))
|
||||||
|
},
|
||||||
|
newMessage: func() pref.Message {
|
||||||
|
panic("missing Go struct field for " + string(fd.FullName()))
|
||||||
|
},
|
||||||
|
newField: func() pref.Value {
|
||||||
|
if v := fd.Default(); v.IsValid() {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
panic("missing Go struct field for " + string(fd.FullName()))
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func fieldInfoForOneof(fd pref.FieldDescriptor, fs reflect.StructField, x exporter, ot reflect.Type) fieldInfo {
|
func fieldInfoForOneof(fd pref.FieldDescriptor, fs reflect.StructField, x exporter, ot reflect.Type) fieldInfo {
|
||||||
ft := fs.Type
|
ft := fs.Type
|
||||||
if ft.Kind() != reflect.Interface {
|
if ft.Kind() != reflect.Interface {
|
||||||
|
|
@ -97,7 +130,7 @@ func fieldInfoForOneof(fd pref.FieldDescriptor, fs reflect.StructField, x export
|
||||||
rv.Set(reflect.New(ot))
|
rv.Set(reflect.New(ot))
|
||||||
}
|
}
|
||||||
rv = rv.Elem().Elem().Field(0)
|
rv = rv.Elem().Elem().Field(0)
|
||||||
if rv.IsNil() {
|
if rv.Kind() == reflect.Ptr && rv.IsNil() {
|
||||||
rv.Set(conv.GoValueOf(pref.ValueOfMessage(conv.New().Message())))
|
rv.Set(conv.GoValueOf(pref.ValueOfMessage(conv.New().Message())))
|
||||||
}
|
}
|
||||||
return conv.PBValueOf(rv)
|
return conv.PBValueOf(rv)
|
||||||
|
|
@ -225,7 +258,10 @@ func fieldInfoForScalar(fd pref.FieldDescriptor, fs reflect.StructField, x expor
|
||||||
isBytes := ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.Uint8
|
isBytes := ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.Uint8
|
||||||
if nullable {
|
if nullable {
|
||||||
if ft.Kind() != reflect.Ptr && ft.Kind() != reflect.Slice {
|
if ft.Kind() != reflect.Ptr && ft.Kind() != reflect.Slice {
|
||||||
panic(fmt.Sprintf("field %v has invalid type: got %v, want pointer", fd.FullName(), ft))
|
// This never occurs for generated message types.
|
||||||
|
// Despite the protobuf type system specifying presence,
|
||||||
|
// the Go field type cannot represent it.
|
||||||
|
nullable = false
|
||||||
}
|
}
|
||||||
if ft.Kind() == reflect.Ptr {
|
if ft.Kind() == reflect.Ptr {
|
||||||
ft = ft.Elem()
|
ft = ft.Elem()
|
||||||
|
|
@ -388,6 +424,9 @@ func fieldInfoForMessage(fd pref.FieldDescriptor, fs reflect.StructField, x expo
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||||
|
if fs.Type.Kind() != reflect.Ptr {
|
||||||
|
return !isZero(rv)
|
||||||
|
}
|
||||||
return !rv.IsNil()
|
return !rv.IsNil()
|
||||||
},
|
},
|
||||||
clear: func(p pointer) {
|
clear: func(p pointer) {
|
||||||
|
|
@ -404,13 +443,13 @@ func fieldInfoForMessage(fd pref.FieldDescriptor, fs reflect.StructField, x expo
|
||||||
set: func(p pointer, v pref.Value) {
|
set: func(p pointer, v pref.Value) {
|
||||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||||
rv.Set(conv.GoValueOf(v))
|
rv.Set(conv.GoValueOf(v))
|
||||||
if rv.IsNil() {
|
if fs.Type.Kind() == reflect.Ptr && rv.IsNil() {
|
||||||
panic(fmt.Sprintf("field %v has invalid nil pointer", fd.FullName()))
|
panic(fmt.Sprintf("field %v has invalid nil pointer", fd.FullName()))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mutable: func(p pointer) pref.Value {
|
mutable: func(p pointer) pref.Value {
|
||||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||||
if rv.IsNil() {
|
if fs.Type.Kind() == reflect.Ptr && rv.IsNil() {
|
||||||
rv.Set(conv.GoValueOf(conv.New()))
|
rv.Set(conv.GoValueOf(conv.New()))
|
||||||
}
|
}
|
||||||
return conv.PBValueOf(rv)
|
return conv.PBValueOf(rv)
|
||||||
|
|
@ -464,3 +503,41 @@ func makeOneofInfo(od pref.OneofDescriptor, si structInfo, x exporter) *oneofInf
|
||||||
}
|
}
|
||||||
return oi
|
return oi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isZero is identical to reflect.Value.IsZero.
|
||||||
|
// TODO: Remove this when Go1.13 is the minimally supported Go version.
|
||||||
|
func isZero(v reflect.Value) bool {
|
||||||
|
switch v.Kind() {
|
||||||
|
case reflect.Bool:
|
||||||
|
return !v.Bool()
|
||||||
|
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||||
|
return v.Int() == 0
|
||||||
|
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
||||||
|
return v.Uint() == 0
|
||||||
|
case reflect.Float32, reflect.Float64:
|
||||||
|
return math.Float64bits(v.Float()) == 0
|
||||||
|
case reflect.Complex64, reflect.Complex128:
|
||||||
|
c := v.Complex()
|
||||||
|
return math.Float64bits(real(c)) == 0 && math.Float64bits(imag(c)) == 0
|
||||||
|
case reflect.Array:
|
||||||
|
for i := 0; i < v.Len(); i++ {
|
||||||
|
if !isZero(v.Index(i)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice, reflect.UnsafePointer:
|
||||||
|
return v.IsNil()
|
||||||
|
case reflect.String:
|
||||||
|
return v.Len() == 0
|
||||||
|
case reflect.Struct:
|
||||||
|
for i := 0; i < v.NumField(); i++ {
|
||||||
|
if !isZero(v.Field(i)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
default:
|
||||||
|
panic(&reflect.ValueError{"reflect.Value.IsZero", v.Kind()})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,7 @@ func (p pointer) String() *string { return p.v.Interface().(*string) }
|
||||||
func (p pointer) StringPtr() **string { return p.v.Interface().(**string) }
|
func (p pointer) StringPtr() **string { return p.v.Interface().(**string) }
|
||||||
func (p pointer) StringSlice() *[]string { return p.v.Interface().(*[]string) }
|
func (p pointer) StringSlice() *[]string { return p.v.Interface().(*[]string) }
|
||||||
func (p pointer) Bytes() *[]byte { return p.v.Interface().(*[]byte) }
|
func (p pointer) Bytes() *[]byte { return p.v.Interface().(*[]byte) }
|
||||||
|
func (p pointer) BytesPtr() **[]byte { return p.v.Interface().(**[]byte) }
|
||||||
func (p pointer) BytesSlice() *[][]byte { return p.v.Interface().(*[][]byte) }
|
func (p pointer) BytesSlice() *[][]byte { return p.v.Interface().(*[][]byte) }
|
||||||
func (p pointer) WeakFields() *weakFields { return (*weakFields)(p.v.Interface().(*WeakFields)) }
|
func (p pointer) WeakFields() *weakFields { return (*weakFields)(p.v.Interface().(*WeakFields)) }
|
||||||
func (p pointer) Extensions() *map[int32]ExtensionField {
|
func (p pointer) Extensions() *map[int32]ExtensionField {
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,7 @@ func (p pointer) String() *string { return (*string)(p.p)
|
||||||
func (p pointer) StringPtr() **string { return (**string)(p.p) }
|
func (p pointer) StringPtr() **string { return (**string)(p.p) }
|
||||||
func (p pointer) StringSlice() *[]string { return (*[]string)(p.p) }
|
func (p pointer) StringSlice() *[]string { return (*[]string)(p.p) }
|
||||||
func (p pointer) Bytes() *[]byte { return (*[]byte)(p.p) }
|
func (p pointer) Bytes() *[]byte { return (*[]byte)(p.p) }
|
||||||
|
func (p pointer) BytesPtr() **[]byte { return (**[]byte)(p.p) }
|
||||||
func (p pointer) BytesSlice() *[][]byte { return (*[][]byte)(p.p) }
|
func (p pointer) BytesSlice() *[][]byte { return (*[][]byte)(p.p) }
|
||||||
func (p pointer) WeakFields() *weakFields { return (*weakFields)(p.p) }
|
func (p pointer) WeakFields() *weakFields { return (*weakFields)(p.p) }
|
||||||
func (p pointer) Extensions() *map[int32]ExtensionField { return (*map[int32]ExtensionField)(p.p) }
|
func (p pointer) Extensions() *map[int32]ExtensionField { return (*map[int32]ExtensionField)(p.p) }
|
||||||
|
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
// Copyright 2019 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// Package mapsort provides sorted access to maps.
|
|
||||||
package mapsort
|
|
||||||
|
|
||||||
import (
|
|
||||||
"sort"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Range iterates over every map entry in sorted key order,
|
|
||||||
// calling f for each key and value encountered.
|
|
||||||
func Range(mapv protoreflect.Map, keyKind protoreflect.Kind, f func(protoreflect.MapKey, protoreflect.Value) bool) {
|
|
||||||
var keys []protoreflect.MapKey
|
|
||||||
mapv.Range(func(key protoreflect.MapKey, _ protoreflect.Value) bool {
|
|
||||||
keys = append(keys, key)
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
sort.Slice(keys, func(i, j int) bool {
|
|
||||||
switch keyKind {
|
|
||||||
case protoreflect.BoolKind:
|
|
||||||
return !keys[i].Bool() && keys[j].Bool()
|
|
||||||
case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind,
|
|
||||||
protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind:
|
|
||||||
return keys[i].Int() < keys[j].Int()
|
|
||||||
case protoreflect.Uint32Kind, protoreflect.Fixed32Kind,
|
|
||||||
protoreflect.Uint64Kind, protoreflect.Fixed64Kind:
|
|
||||||
return keys[i].Uint() < keys[j].Uint()
|
|
||||||
case protoreflect.StringKind:
|
|
||||||
return keys[i].String() < keys[j].String()
|
|
||||||
default:
|
|
||||||
panic("invalid kind: " + keyKind.String())
|
|
||||||
}
|
|
||||||
})
|
|
||||||
for _, key := range keys {
|
|
||||||
if !f(key, mapv.Get(key)) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,89 @@
|
||||||
|
// Copyright 2020 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package order
|
||||||
|
|
||||||
|
import (
|
||||||
|
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FieldOrder specifies the ordering to visit message fields.
|
||||||
|
// It is a function that reports whether x is ordered before y.
|
||||||
|
type FieldOrder func(x, y pref.FieldDescriptor) bool
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AnyFieldOrder specifies no specific field ordering.
|
||||||
|
AnyFieldOrder FieldOrder = nil
|
||||||
|
|
||||||
|
// LegacyFieldOrder sorts fields in the same ordering as emitted by
|
||||||
|
// wire serialization in the github.com/golang/protobuf implementation.
|
||||||
|
LegacyFieldOrder FieldOrder = func(x, y pref.FieldDescriptor) bool {
|
||||||
|
ox, oy := x.ContainingOneof(), y.ContainingOneof()
|
||||||
|
inOneof := func(od pref.OneofDescriptor) bool {
|
||||||
|
return od != nil && !od.IsSynthetic()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extension fields sort before non-extension fields.
|
||||||
|
if x.IsExtension() != y.IsExtension() {
|
||||||
|
return x.IsExtension() && !y.IsExtension()
|
||||||
|
}
|
||||||
|
// Fields not within a oneof sort before those within a oneof.
|
||||||
|
if inOneof(ox) != inOneof(oy) {
|
||||||
|
return !inOneof(ox) && inOneof(oy)
|
||||||
|
}
|
||||||
|
// Fields in disjoint oneof sets are sorted by declaration index.
|
||||||
|
if ox != nil && oy != nil && ox != oy {
|
||||||
|
return ox.Index() < oy.Index()
|
||||||
|
}
|
||||||
|
// Fields sorted by field number.
|
||||||
|
return x.Number() < y.Number()
|
||||||
|
}
|
||||||
|
|
||||||
|
// NumberFieldOrder sorts fields by their field number.
|
||||||
|
NumberFieldOrder FieldOrder = func(x, y pref.FieldDescriptor) bool {
|
||||||
|
return x.Number() < y.Number()
|
||||||
|
}
|
||||||
|
|
||||||
|
// IndexNameFieldOrder sorts non-extension fields before extension fields.
|
||||||
|
// Non-extensions are sorted according to their declaration index.
|
||||||
|
// Extensions are sorted according to their full name.
|
||||||
|
IndexNameFieldOrder FieldOrder = func(x, y pref.FieldDescriptor) bool {
|
||||||
|
// Non-extension fields sort before extension fields.
|
||||||
|
if x.IsExtension() != y.IsExtension() {
|
||||||
|
return !x.IsExtension() && y.IsExtension()
|
||||||
|
}
|
||||||
|
// Extensions sorted by fullname.
|
||||||
|
if x.IsExtension() && y.IsExtension() {
|
||||||
|
return x.FullName() < y.FullName()
|
||||||
|
}
|
||||||
|
// Non-extensions sorted by declaration index.
|
||||||
|
return x.Index() < y.Index()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// KeyOrder specifies the ordering to visit map entries.
|
||||||
|
// It is a function that reports whether x is ordered before y.
|
||||||
|
type KeyOrder func(x, y pref.MapKey) bool
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AnyKeyOrder specifies no specific key ordering.
|
||||||
|
AnyKeyOrder KeyOrder = nil
|
||||||
|
|
||||||
|
// GenericKeyOrder sorts false before true, numeric keys in ascending order,
|
||||||
|
// and strings in lexicographical ordering according to UTF-8 codepoints.
|
||||||
|
GenericKeyOrder KeyOrder = func(x, y pref.MapKey) bool {
|
||||||
|
switch x.Interface().(type) {
|
||||||
|
case bool:
|
||||||
|
return !x.Bool() && y.Bool()
|
||||||
|
case int32, int64:
|
||||||
|
return x.Int() < y.Int()
|
||||||
|
case uint32, uint64:
|
||||||
|
return x.Uint() < y.Uint()
|
||||||
|
case string:
|
||||||
|
return x.String() < y.String()
|
||||||
|
default:
|
||||||
|
panic("invalid map key type")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,115 @@
|
||||||
|
// Copyright 2020 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Package order provides ordered access to messages and maps.
|
||||||
|
package order
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sort"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
)
|
||||||
|
|
||||||
|
type messageField struct {
|
||||||
|
fd pref.FieldDescriptor
|
||||||
|
v pref.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
var messageFieldPool = sync.Pool{
|
||||||
|
New: func() interface{} { return new([]messageField) },
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
// FieldRnger is an interface for visiting all fields in a message.
|
||||||
|
// The protoreflect.Message type implements this interface.
|
||||||
|
FieldRanger interface{ Range(VisitField) }
|
||||||
|
// VisitField is called everytime a message field is visited.
|
||||||
|
VisitField = func(pref.FieldDescriptor, pref.Value) bool
|
||||||
|
)
|
||||||
|
|
||||||
|
// RangeFields iterates over the fields of fs according to the specified order.
|
||||||
|
func RangeFields(fs FieldRanger, less FieldOrder, fn VisitField) {
|
||||||
|
if less == nil {
|
||||||
|
fs.Range(fn)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtain a pre-allocated scratch buffer.
|
||||||
|
p := messageFieldPool.Get().(*[]messageField)
|
||||||
|
fields := (*p)[:0]
|
||||||
|
defer func() {
|
||||||
|
if cap(fields) < 1024 {
|
||||||
|
*p = fields
|
||||||
|
messageFieldPool.Put(p)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// Collect all fields in the message and sort them.
|
||||||
|
fs.Range(func(fd pref.FieldDescriptor, v pref.Value) bool {
|
||||||
|
fields = append(fields, messageField{fd, v})
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
sort.Slice(fields, func(i, j int) bool {
|
||||||
|
return less(fields[i].fd, fields[j].fd)
|
||||||
|
})
|
||||||
|
|
||||||
|
// Visit the fields in the specified ordering.
|
||||||
|
for _, f := range fields {
|
||||||
|
if !fn(f.fd, f.v) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type mapEntry struct {
|
||||||
|
k pref.MapKey
|
||||||
|
v pref.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
var mapEntryPool = sync.Pool{
|
||||||
|
New: func() interface{} { return new([]mapEntry) },
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
// EntryRanger is an interface for visiting all fields in a message.
|
||||||
|
// The protoreflect.Map type implements this interface.
|
||||||
|
EntryRanger interface{ Range(VisitEntry) }
|
||||||
|
// VisitEntry is called everytime a map entry is visited.
|
||||||
|
VisitEntry = func(pref.MapKey, pref.Value) bool
|
||||||
|
)
|
||||||
|
|
||||||
|
// RangeEntries iterates over the entries of es according to the specified order.
|
||||||
|
func RangeEntries(es EntryRanger, less KeyOrder, fn VisitEntry) {
|
||||||
|
if less == nil {
|
||||||
|
es.Range(fn)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtain a pre-allocated scratch buffer.
|
||||||
|
p := mapEntryPool.Get().(*[]mapEntry)
|
||||||
|
entries := (*p)[:0]
|
||||||
|
defer func() {
|
||||||
|
if cap(entries) < 1024 {
|
||||||
|
*p = entries
|
||||||
|
mapEntryPool.Put(p)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// Collect all entries in the map and sort them.
|
||||||
|
es.Range(func(k pref.MapKey, v pref.Value) bool {
|
||||||
|
entries = append(entries, mapEntry{k, v})
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
sort.Slice(entries, func(i, j int) bool {
|
||||||
|
return less(entries[i].k, entries[j].k)
|
||||||
|
})
|
||||||
|
|
||||||
|
// Visit the entries in the specified ordering.
|
||||||
|
for _, e := range entries {
|
||||||
|
if !fn(e.k, e.v) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -52,7 +52,7 @@ import (
|
||||||
// 10. Send out the CL for review and submit it.
|
// 10. Send out the CL for review and submit it.
|
||||||
const (
|
const (
|
||||||
Major = 1
|
Major = 1
|
||||||
Minor = 25
|
Minor = 26
|
||||||
Patch = 0
|
Patch = 0
|
||||||
PreRelease = ""
|
PreRelease = ""
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -45,12 +45,14 @@ type UnmarshalOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unmarshal parses the wire-format message in b and places the result in m.
|
// Unmarshal parses the wire-format message in b and places the result in m.
|
||||||
|
// The provided message must be mutable (e.g., a non-nil pointer to a message).
|
||||||
func Unmarshal(b []byte, m Message) error {
|
func Unmarshal(b []byte, m Message) error {
|
||||||
_, err := UnmarshalOptions{}.unmarshal(b, m.ProtoReflect())
|
_, err := UnmarshalOptions{}.unmarshal(b, m.ProtoReflect())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unmarshal parses the wire-format message in b and places the result in m.
|
// Unmarshal parses the wire-format message in b and places the result in m.
|
||||||
|
// The provided message must be mutable (e.g., a non-nil pointer to a message).
|
||||||
func (o UnmarshalOptions) Unmarshal(b []byte, m Message) error {
|
func (o UnmarshalOptions) Unmarshal(b []byte, m Message) error {
|
||||||
_, err := o.unmarshal(b, m.ProtoReflect())
|
_, err := o.unmarshal(b, m.ProtoReflect())
|
||||||
return err
|
return err
|
||||||
|
|
@ -116,10 +118,10 @@ func (o UnmarshalOptions) unmarshalMessageSlow(b []byte, m protoreflect.Message)
|
||||||
// Parse the tag (field number and wire type).
|
// Parse the tag (field number and wire type).
|
||||||
num, wtyp, tagLen := protowire.ConsumeTag(b)
|
num, wtyp, tagLen := protowire.ConsumeTag(b)
|
||||||
if tagLen < 0 {
|
if tagLen < 0 {
|
||||||
return protowire.ParseError(tagLen)
|
return errDecode
|
||||||
}
|
}
|
||||||
if num > protowire.MaxValidNumber {
|
if num > protowire.MaxValidNumber {
|
||||||
return errors.New("invalid field number")
|
return errDecode
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the field descriptor for this field number.
|
// Find the field descriptor for this field number.
|
||||||
|
|
@ -159,7 +161,7 @@ func (o UnmarshalOptions) unmarshalMessageSlow(b []byte, m protoreflect.Message)
|
||||||
}
|
}
|
||||||
valLen = protowire.ConsumeFieldValue(num, wtyp, b[tagLen:])
|
valLen = protowire.ConsumeFieldValue(num, wtyp, b[tagLen:])
|
||||||
if valLen < 0 {
|
if valLen < 0 {
|
||||||
return protowire.ParseError(valLen)
|
return errDecode
|
||||||
}
|
}
|
||||||
if !o.DiscardUnknown {
|
if !o.DiscardUnknown {
|
||||||
m.SetUnknown(append(m.GetUnknown(), b[:tagLen+valLen]...))
|
m.SetUnknown(append(m.GetUnknown(), b[:tagLen+valLen]...))
|
||||||
|
|
@ -194,7 +196,7 @@ func (o UnmarshalOptions) unmarshalMap(b []byte, wtyp protowire.Type, mapv proto
|
||||||
}
|
}
|
||||||
b, n = protowire.ConsumeBytes(b)
|
b, n = protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
keyField = fd.MapKey()
|
keyField = fd.MapKey()
|
||||||
|
|
@ -213,10 +215,10 @@ func (o UnmarshalOptions) unmarshalMap(b []byte, wtyp protowire.Type, mapv proto
|
||||||
for len(b) > 0 {
|
for len(b) > 0 {
|
||||||
num, wtyp, n := protowire.ConsumeTag(b)
|
num, wtyp, n := protowire.ConsumeTag(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
if num > protowire.MaxValidNumber {
|
if num > protowire.MaxValidNumber {
|
||||||
return 0, errors.New("invalid field number")
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
b = b[n:]
|
b = b[n:]
|
||||||
err = errUnknown
|
err = errUnknown
|
||||||
|
|
@ -246,7 +248,7 @@ func (o UnmarshalOptions) unmarshalMap(b []byte, wtyp protowire.Type, mapv proto
|
||||||
if err == errUnknown {
|
if err == errUnknown {
|
||||||
n = protowire.ConsumeFieldValue(num, wtyp, b)
|
n = protowire.ConsumeFieldValue(num, wtyp, b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
|
|
@ -272,3 +274,5 @@ func (o UnmarshalOptions) unmarshalMap(b []byte, wtyp protowire.Type, mapv proto
|
||||||
// to the unknown field set of a message. It is never returned from an exported
|
// to the unknown field set of a message. It is never returned from an exported
|
||||||
// function.
|
// function.
|
||||||
var errUnknown = errors.New("BUG: internal error (unknown)")
|
var errUnknown = errors.New("BUG: internal error (unknown)")
|
||||||
|
|
||||||
|
var errDecode = errors.New("cannot parse invalid wire-format data")
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeVarint(b)
|
v, n := protowire.ConsumeVarint(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return val, 0, protowire.ParseError(n)
|
return val, 0, errDecode
|
||||||
}
|
}
|
||||||
return protoreflect.ValueOfBool(protowire.DecodeBool(v)), n, nil
|
return protoreflect.ValueOfBool(protowire.DecodeBool(v)), n, nil
|
||||||
case protoreflect.EnumKind:
|
case protoreflect.EnumKind:
|
||||||
|
|
@ -36,7 +36,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeVarint(b)
|
v, n := protowire.ConsumeVarint(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return val, 0, protowire.ParseError(n)
|
return val, 0, errDecode
|
||||||
}
|
}
|
||||||
return protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)), n, nil
|
return protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)), n, nil
|
||||||
case protoreflect.Int32Kind:
|
case protoreflect.Int32Kind:
|
||||||
|
|
@ -45,7 +45,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeVarint(b)
|
v, n := protowire.ConsumeVarint(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return val, 0, protowire.ParseError(n)
|
return val, 0, errDecode
|
||||||
}
|
}
|
||||||
return protoreflect.ValueOfInt32(int32(v)), n, nil
|
return protoreflect.ValueOfInt32(int32(v)), n, nil
|
||||||
case protoreflect.Sint32Kind:
|
case protoreflect.Sint32Kind:
|
||||||
|
|
@ -54,7 +54,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeVarint(b)
|
v, n := protowire.ConsumeVarint(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return val, 0, protowire.ParseError(n)
|
return val, 0, errDecode
|
||||||
}
|
}
|
||||||
return protoreflect.ValueOfInt32(int32(protowire.DecodeZigZag(v & math.MaxUint32))), n, nil
|
return protoreflect.ValueOfInt32(int32(protowire.DecodeZigZag(v & math.MaxUint32))), n, nil
|
||||||
case protoreflect.Uint32Kind:
|
case protoreflect.Uint32Kind:
|
||||||
|
|
@ -63,7 +63,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeVarint(b)
|
v, n := protowire.ConsumeVarint(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return val, 0, protowire.ParseError(n)
|
return val, 0, errDecode
|
||||||
}
|
}
|
||||||
return protoreflect.ValueOfUint32(uint32(v)), n, nil
|
return protoreflect.ValueOfUint32(uint32(v)), n, nil
|
||||||
case protoreflect.Int64Kind:
|
case protoreflect.Int64Kind:
|
||||||
|
|
@ -72,7 +72,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeVarint(b)
|
v, n := protowire.ConsumeVarint(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return val, 0, protowire.ParseError(n)
|
return val, 0, errDecode
|
||||||
}
|
}
|
||||||
return protoreflect.ValueOfInt64(int64(v)), n, nil
|
return protoreflect.ValueOfInt64(int64(v)), n, nil
|
||||||
case protoreflect.Sint64Kind:
|
case protoreflect.Sint64Kind:
|
||||||
|
|
@ -81,7 +81,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeVarint(b)
|
v, n := protowire.ConsumeVarint(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return val, 0, protowire.ParseError(n)
|
return val, 0, errDecode
|
||||||
}
|
}
|
||||||
return protoreflect.ValueOfInt64(protowire.DecodeZigZag(v)), n, nil
|
return protoreflect.ValueOfInt64(protowire.DecodeZigZag(v)), n, nil
|
||||||
case protoreflect.Uint64Kind:
|
case protoreflect.Uint64Kind:
|
||||||
|
|
@ -90,7 +90,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeVarint(b)
|
v, n := protowire.ConsumeVarint(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return val, 0, protowire.ParseError(n)
|
return val, 0, errDecode
|
||||||
}
|
}
|
||||||
return protoreflect.ValueOfUint64(v), n, nil
|
return protoreflect.ValueOfUint64(v), n, nil
|
||||||
case protoreflect.Sfixed32Kind:
|
case protoreflect.Sfixed32Kind:
|
||||||
|
|
@ -99,7 +99,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeFixed32(b)
|
v, n := protowire.ConsumeFixed32(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return val, 0, protowire.ParseError(n)
|
return val, 0, errDecode
|
||||||
}
|
}
|
||||||
return protoreflect.ValueOfInt32(int32(v)), n, nil
|
return protoreflect.ValueOfInt32(int32(v)), n, nil
|
||||||
case protoreflect.Fixed32Kind:
|
case protoreflect.Fixed32Kind:
|
||||||
|
|
@ -108,7 +108,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeFixed32(b)
|
v, n := protowire.ConsumeFixed32(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return val, 0, protowire.ParseError(n)
|
return val, 0, errDecode
|
||||||
}
|
}
|
||||||
return protoreflect.ValueOfUint32(uint32(v)), n, nil
|
return protoreflect.ValueOfUint32(uint32(v)), n, nil
|
||||||
case protoreflect.FloatKind:
|
case protoreflect.FloatKind:
|
||||||
|
|
@ -117,7 +117,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeFixed32(b)
|
v, n := protowire.ConsumeFixed32(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return val, 0, protowire.ParseError(n)
|
return val, 0, errDecode
|
||||||
}
|
}
|
||||||
return protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))), n, nil
|
return protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))), n, nil
|
||||||
case protoreflect.Sfixed64Kind:
|
case protoreflect.Sfixed64Kind:
|
||||||
|
|
@ -126,7 +126,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeFixed64(b)
|
v, n := protowire.ConsumeFixed64(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return val, 0, protowire.ParseError(n)
|
return val, 0, errDecode
|
||||||
}
|
}
|
||||||
return protoreflect.ValueOfInt64(int64(v)), n, nil
|
return protoreflect.ValueOfInt64(int64(v)), n, nil
|
||||||
case protoreflect.Fixed64Kind:
|
case protoreflect.Fixed64Kind:
|
||||||
|
|
@ -135,7 +135,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeFixed64(b)
|
v, n := protowire.ConsumeFixed64(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return val, 0, protowire.ParseError(n)
|
return val, 0, errDecode
|
||||||
}
|
}
|
||||||
return protoreflect.ValueOfUint64(v), n, nil
|
return protoreflect.ValueOfUint64(v), n, nil
|
||||||
case protoreflect.DoubleKind:
|
case protoreflect.DoubleKind:
|
||||||
|
|
@ -144,7 +144,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeFixed64(b)
|
v, n := protowire.ConsumeFixed64(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return val, 0, protowire.ParseError(n)
|
return val, 0, errDecode
|
||||||
}
|
}
|
||||||
return protoreflect.ValueOfFloat64(math.Float64frombits(v)), n, nil
|
return protoreflect.ValueOfFloat64(math.Float64frombits(v)), n, nil
|
||||||
case protoreflect.StringKind:
|
case protoreflect.StringKind:
|
||||||
|
|
@ -153,7 +153,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeBytes(b)
|
v, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return val, 0, protowire.ParseError(n)
|
return val, 0, errDecode
|
||||||
}
|
}
|
||||||
if strs.EnforceUTF8(fd) && !utf8.Valid(v) {
|
if strs.EnforceUTF8(fd) && !utf8.Valid(v) {
|
||||||
return protoreflect.Value{}, 0, errors.InvalidUTF8(string(fd.FullName()))
|
return protoreflect.Value{}, 0, errors.InvalidUTF8(string(fd.FullName()))
|
||||||
|
|
@ -165,7 +165,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeBytes(b)
|
v, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return val, 0, protowire.ParseError(n)
|
return val, 0, errDecode
|
||||||
}
|
}
|
||||||
return protoreflect.ValueOfBytes(append(emptyBuf[:], v...)), n, nil
|
return protoreflect.ValueOfBytes(append(emptyBuf[:], v...)), n, nil
|
||||||
case protoreflect.MessageKind:
|
case protoreflect.MessageKind:
|
||||||
|
|
@ -174,7 +174,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeBytes(b)
|
v, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return val, 0, protowire.ParseError(n)
|
return val, 0, errDecode
|
||||||
}
|
}
|
||||||
return protoreflect.ValueOfBytes(v), n, nil
|
return protoreflect.ValueOfBytes(v), n, nil
|
||||||
case protoreflect.GroupKind:
|
case protoreflect.GroupKind:
|
||||||
|
|
@ -183,7 +183,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeGroup(fd.Number(), b)
|
v, n := protowire.ConsumeGroup(fd.Number(), b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return val, 0, protowire.ParseError(n)
|
return val, 0, errDecode
|
||||||
}
|
}
|
||||||
return protoreflect.ValueOfBytes(v), n, nil
|
return protoreflect.ValueOfBytes(v), n, nil
|
||||||
default:
|
default:
|
||||||
|
|
@ -197,12 +197,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
if wtyp == protowire.BytesType {
|
if wtyp == protowire.BytesType {
|
||||||
buf, n := protowire.ConsumeBytes(b)
|
buf, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
for len(buf) > 0 {
|
for len(buf) > 0 {
|
||||||
v, n := protowire.ConsumeVarint(buf)
|
v, n := protowire.ConsumeVarint(buf)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
buf = buf[n:]
|
buf = buf[n:]
|
||||||
list.Append(protoreflect.ValueOfBool(protowire.DecodeBool(v)))
|
list.Append(protoreflect.ValueOfBool(protowire.DecodeBool(v)))
|
||||||
|
|
@ -214,7 +214,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeVarint(b)
|
v, n := protowire.ConsumeVarint(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
list.Append(protoreflect.ValueOfBool(protowire.DecodeBool(v)))
|
list.Append(protoreflect.ValueOfBool(protowire.DecodeBool(v)))
|
||||||
return n, nil
|
return n, nil
|
||||||
|
|
@ -222,12 +222,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
if wtyp == protowire.BytesType {
|
if wtyp == protowire.BytesType {
|
||||||
buf, n := protowire.ConsumeBytes(b)
|
buf, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
for len(buf) > 0 {
|
for len(buf) > 0 {
|
||||||
v, n := protowire.ConsumeVarint(buf)
|
v, n := protowire.ConsumeVarint(buf)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
buf = buf[n:]
|
buf = buf[n:]
|
||||||
list.Append(protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)))
|
list.Append(protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)))
|
||||||
|
|
@ -239,7 +239,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeVarint(b)
|
v, n := protowire.ConsumeVarint(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
list.Append(protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)))
|
list.Append(protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)))
|
||||||
return n, nil
|
return n, nil
|
||||||
|
|
@ -247,12 +247,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
if wtyp == protowire.BytesType {
|
if wtyp == protowire.BytesType {
|
||||||
buf, n := protowire.ConsumeBytes(b)
|
buf, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
for len(buf) > 0 {
|
for len(buf) > 0 {
|
||||||
v, n := protowire.ConsumeVarint(buf)
|
v, n := protowire.ConsumeVarint(buf)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
buf = buf[n:]
|
buf = buf[n:]
|
||||||
list.Append(protoreflect.ValueOfInt32(int32(v)))
|
list.Append(protoreflect.ValueOfInt32(int32(v)))
|
||||||
|
|
@ -264,7 +264,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeVarint(b)
|
v, n := protowire.ConsumeVarint(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
list.Append(protoreflect.ValueOfInt32(int32(v)))
|
list.Append(protoreflect.ValueOfInt32(int32(v)))
|
||||||
return n, nil
|
return n, nil
|
||||||
|
|
@ -272,12 +272,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
if wtyp == protowire.BytesType {
|
if wtyp == protowire.BytesType {
|
||||||
buf, n := protowire.ConsumeBytes(b)
|
buf, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
for len(buf) > 0 {
|
for len(buf) > 0 {
|
||||||
v, n := protowire.ConsumeVarint(buf)
|
v, n := protowire.ConsumeVarint(buf)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
buf = buf[n:]
|
buf = buf[n:]
|
||||||
list.Append(protoreflect.ValueOfInt32(int32(protowire.DecodeZigZag(v & math.MaxUint32))))
|
list.Append(protoreflect.ValueOfInt32(int32(protowire.DecodeZigZag(v & math.MaxUint32))))
|
||||||
|
|
@ -289,7 +289,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeVarint(b)
|
v, n := protowire.ConsumeVarint(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
list.Append(protoreflect.ValueOfInt32(int32(protowire.DecodeZigZag(v & math.MaxUint32))))
|
list.Append(protoreflect.ValueOfInt32(int32(protowire.DecodeZigZag(v & math.MaxUint32))))
|
||||||
return n, nil
|
return n, nil
|
||||||
|
|
@ -297,12 +297,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
if wtyp == protowire.BytesType {
|
if wtyp == protowire.BytesType {
|
||||||
buf, n := protowire.ConsumeBytes(b)
|
buf, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
for len(buf) > 0 {
|
for len(buf) > 0 {
|
||||||
v, n := protowire.ConsumeVarint(buf)
|
v, n := protowire.ConsumeVarint(buf)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
buf = buf[n:]
|
buf = buf[n:]
|
||||||
list.Append(protoreflect.ValueOfUint32(uint32(v)))
|
list.Append(protoreflect.ValueOfUint32(uint32(v)))
|
||||||
|
|
@ -314,7 +314,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeVarint(b)
|
v, n := protowire.ConsumeVarint(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
list.Append(protoreflect.ValueOfUint32(uint32(v)))
|
list.Append(protoreflect.ValueOfUint32(uint32(v)))
|
||||||
return n, nil
|
return n, nil
|
||||||
|
|
@ -322,12 +322,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
if wtyp == protowire.BytesType {
|
if wtyp == protowire.BytesType {
|
||||||
buf, n := protowire.ConsumeBytes(b)
|
buf, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
for len(buf) > 0 {
|
for len(buf) > 0 {
|
||||||
v, n := protowire.ConsumeVarint(buf)
|
v, n := protowire.ConsumeVarint(buf)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
buf = buf[n:]
|
buf = buf[n:]
|
||||||
list.Append(protoreflect.ValueOfInt64(int64(v)))
|
list.Append(protoreflect.ValueOfInt64(int64(v)))
|
||||||
|
|
@ -339,7 +339,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeVarint(b)
|
v, n := protowire.ConsumeVarint(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
list.Append(protoreflect.ValueOfInt64(int64(v)))
|
list.Append(protoreflect.ValueOfInt64(int64(v)))
|
||||||
return n, nil
|
return n, nil
|
||||||
|
|
@ -347,12 +347,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
if wtyp == protowire.BytesType {
|
if wtyp == protowire.BytesType {
|
||||||
buf, n := protowire.ConsumeBytes(b)
|
buf, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
for len(buf) > 0 {
|
for len(buf) > 0 {
|
||||||
v, n := protowire.ConsumeVarint(buf)
|
v, n := protowire.ConsumeVarint(buf)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
buf = buf[n:]
|
buf = buf[n:]
|
||||||
list.Append(protoreflect.ValueOfInt64(protowire.DecodeZigZag(v)))
|
list.Append(protoreflect.ValueOfInt64(protowire.DecodeZigZag(v)))
|
||||||
|
|
@ -364,7 +364,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeVarint(b)
|
v, n := protowire.ConsumeVarint(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
list.Append(protoreflect.ValueOfInt64(protowire.DecodeZigZag(v)))
|
list.Append(protoreflect.ValueOfInt64(protowire.DecodeZigZag(v)))
|
||||||
return n, nil
|
return n, nil
|
||||||
|
|
@ -372,12 +372,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
if wtyp == protowire.BytesType {
|
if wtyp == protowire.BytesType {
|
||||||
buf, n := protowire.ConsumeBytes(b)
|
buf, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
for len(buf) > 0 {
|
for len(buf) > 0 {
|
||||||
v, n := protowire.ConsumeVarint(buf)
|
v, n := protowire.ConsumeVarint(buf)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
buf = buf[n:]
|
buf = buf[n:]
|
||||||
list.Append(protoreflect.ValueOfUint64(v))
|
list.Append(protoreflect.ValueOfUint64(v))
|
||||||
|
|
@ -389,7 +389,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeVarint(b)
|
v, n := protowire.ConsumeVarint(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
list.Append(protoreflect.ValueOfUint64(v))
|
list.Append(protoreflect.ValueOfUint64(v))
|
||||||
return n, nil
|
return n, nil
|
||||||
|
|
@ -397,12 +397,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
if wtyp == protowire.BytesType {
|
if wtyp == protowire.BytesType {
|
||||||
buf, n := protowire.ConsumeBytes(b)
|
buf, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
for len(buf) > 0 {
|
for len(buf) > 0 {
|
||||||
v, n := protowire.ConsumeFixed32(buf)
|
v, n := protowire.ConsumeFixed32(buf)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
buf = buf[n:]
|
buf = buf[n:]
|
||||||
list.Append(protoreflect.ValueOfInt32(int32(v)))
|
list.Append(protoreflect.ValueOfInt32(int32(v)))
|
||||||
|
|
@ -414,7 +414,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeFixed32(b)
|
v, n := protowire.ConsumeFixed32(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
list.Append(protoreflect.ValueOfInt32(int32(v)))
|
list.Append(protoreflect.ValueOfInt32(int32(v)))
|
||||||
return n, nil
|
return n, nil
|
||||||
|
|
@ -422,12 +422,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
if wtyp == protowire.BytesType {
|
if wtyp == protowire.BytesType {
|
||||||
buf, n := protowire.ConsumeBytes(b)
|
buf, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
for len(buf) > 0 {
|
for len(buf) > 0 {
|
||||||
v, n := protowire.ConsumeFixed32(buf)
|
v, n := protowire.ConsumeFixed32(buf)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
buf = buf[n:]
|
buf = buf[n:]
|
||||||
list.Append(protoreflect.ValueOfUint32(uint32(v)))
|
list.Append(protoreflect.ValueOfUint32(uint32(v)))
|
||||||
|
|
@ -439,7 +439,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeFixed32(b)
|
v, n := protowire.ConsumeFixed32(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
list.Append(protoreflect.ValueOfUint32(uint32(v)))
|
list.Append(protoreflect.ValueOfUint32(uint32(v)))
|
||||||
return n, nil
|
return n, nil
|
||||||
|
|
@ -447,12 +447,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
if wtyp == protowire.BytesType {
|
if wtyp == protowire.BytesType {
|
||||||
buf, n := protowire.ConsumeBytes(b)
|
buf, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
for len(buf) > 0 {
|
for len(buf) > 0 {
|
||||||
v, n := protowire.ConsumeFixed32(buf)
|
v, n := protowire.ConsumeFixed32(buf)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
buf = buf[n:]
|
buf = buf[n:]
|
||||||
list.Append(protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))))
|
list.Append(protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))))
|
||||||
|
|
@ -464,7 +464,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeFixed32(b)
|
v, n := protowire.ConsumeFixed32(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
list.Append(protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))))
|
list.Append(protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))))
|
||||||
return n, nil
|
return n, nil
|
||||||
|
|
@ -472,12 +472,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
if wtyp == protowire.BytesType {
|
if wtyp == protowire.BytesType {
|
||||||
buf, n := protowire.ConsumeBytes(b)
|
buf, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
for len(buf) > 0 {
|
for len(buf) > 0 {
|
||||||
v, n := protowire.ConsumeFixed64(buf)
|
v, n := protowire.ConsumeFixed64(buf)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
buf = buf[n:]
|
buf = buf[n:]
|
||||||
list.Append(protoreflect.ValueOfInt64(int64(v)))
|
list.Append(protoreflect.ValueOfInt64(int64(v)))
|
||||||
|
|
@ -489,7 +489,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeFixed64(b)
|
v, n := protowire.ConsumeFixed64(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
list.Append(protoreflect.ValueOfInt64(int64(v)))
|
list.Append(protoreflect.ValueOfInt64(int64(v)))
|
||||||
return n, nil
|
return n, nil
|
||||||
|
|
@ -497,12 +497,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
if wtyp == protowire.BytesType {
|
if wtyp == protowire.BytesType {
|
||||||
buf, n := protowire.ConsumeBytes(b)
|
buf, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
for len(buf) > 0 {
|
for len(buf) > 0 {
|
||||||
v, n := protowire.ConsumeFixed64(buf)
|
v, n := protowire.ConsumeFixed64(buf)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
buf = buf[n:]
|
buf = buf[n:]
|
||||||
list.Append(protoreflect.ValueOfUint64(v))
|
list.Append(protoreflect.ValueOfUint64(v))
|
||||||
|
|
@ -514,7 +514,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeFixed64(b)
|
v, n := protowire.ConsumeFixed64(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
list.Append(protoreflect.ValueOfUint64(v))
|
list.Append(protoreflect.ValueOfUint64(v))
|
||||||
return n, nil
|
return n, nil
|
||||||
|
|
@ -522,12 +522,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
if wtyp == protowire.BytesType {
|
if wtyp == protowire.BytesType {
|
||||||
buf, n := protowire.ConsumeBytes(b)
|
buf, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
for len(buf) > 0 {
|
for len(buf) > 0 {
|
||||||
v, n := protowire.ConsumeFixed64(buf)
|
v, n := protowire.ConsumeFixed64(buf)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
buf = buf[n:]
|
buf = buf[n:]
|
||||||
list.Append(protoreflect.ValueOfFloat64(math.Float64frombits(v)))
|
list.Append(protoreflect.ValueOfFloat64(math.Float64frombits(v)))
|
||||||
|
|
@ -539,7 +539,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeFixed64(b)
|
v, n := protowire.ConsumeFixed64(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
list.Append(protoreflect.ValueOfFloat64(math.Float64frombits(v)))
|
list.Append(protoreflect.ValueOfFloat64(math.Float64frombits(v)))
|
||||||
return n, nil
|
return n, nil
|
||||||
|
|
@ -549,7 +549,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeBytes(b)
|
v, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
if strs.EnforceUTF8(fd) && !utf8.Valid(v) {
|
if strs.EnforceUTF8(fd) && !utf8.Valid(v) {
|
||||||
return 0, errors.InvalidUTF8(string(fd.FullName()))
|
return 0, errors.InvalidUTF8(string(fd.FullName()))
|
||||||
|
|
@ -562,7 +562,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeBytes(b)
|
v, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
list.Append(protoreflect.ValueOfBytes(append(emptyBuf[:], v...)))
|
list.Append(protoreflect.ValueOfBytes(append(emptyBuf[:], v...)))
|
||||||
return n, nil
|
return n, nil
|
||||||
|
|
@ -572,7 +572,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeBytes(b)
|
v, n := protowire.ConsumeBytes(b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
m := list.NewElement()
|
m := list.NewElement()
|
||||||
if err := o.unmarshalMessage(v, m.Message()); err != nil {
|
if err := o.unmarshalMessage(v, m.Message()); err != nil {
|
||||||
|
|
@ -586,7 +586,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||||
}
|
}
|
||||||
v, n := protowire.ConsumeGroup(fd.Number(), b)
|
v, n := protowire.ConsumeGroup(fd.Number(), b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return 0, protowire.ParseError(n)
|
return 0, errDecode
|
||||||
}
|
}
|
||||||
m := list.NewElement()
|
m := list.NewElement()
|
||||||
if err := o.unmarshalMessage(v, m.Message()); err != nil {
|
if err := o.unmarshalMessage(v, m.Message()); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,9 @@
|
||||||
package proto
|
package proto
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sort"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/encoding/protowire"
|
"google.golang.org/protobuf/encoding/protowire"
|
||||||
"google.golang.org/protobuf/internal/encoding/messageset"
|
"google.golang.org/protobuf/internal/encoding/messageset"
|
||||||
"google.golang.org/protobuf/internal/fieldsort"
|
"google.golang.org/protobuf/internal/order"
|
||||||
"google.golang.org/protobuf/internal/mapsort"
|
|
||||||
"google.golang.org/protobuf/internal/pragma"
|
"google.golang.org/protobuf/internal/pragma"
|
||||||
"google.golang.org/protobuf/reflect/protoreflect"
|
"google.golang.org/protobuf/reflect/protoreflect"
|
||||||
"google.golang.org/protobuf/runtime/protoiface"
|
"google.golang.org/protobuf/runtime/protoiface"
|
||||||
|
|
@ -211,14 +208,15 @@ func (o MarshalOptions) marshalMessageSlow(b []byte, m protoreflect.Message) ([]
|
||||||
if messageset.IsMessageSet(m.Descriptor()) {
|
if messageset.IsMessageSet(m.Descriptor()) {
|
||||||
return o.marshalMessageSet(b, m)
|
return o.marshalMessageSet(b, m)
|
||||||
}
|
}
|
||||||
// There are many choices for what order we visit fields in. The default one here
|
fieldOrder := order.AnyFieldOrder
|
||||||
// is chosen for reasonable efficiency and simplicity given the protoreflect API.
|
if o.Deterministic {
|
||||||
// It is not deterministic, since Message.Range does not return fields in any
|
// TODO: This should use a more natural ordering like NumberFieldOrder,
|
||||||
// defined order.
|
// but doing so breaks golden tests that make invalid assumption about
|
||||||
//
|
// output stability of this implementation.
|
||||||
// When using deterministic serialization, we sort the known fields.
|
fieldOrder = order.LegacyFieldOrder
|
||||||
|
}
|
||||||
var err error
|
var err error
|
||||||
o.rangeFields(m, func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
|
order.RangeFields(m, fieldOrder, func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
|
||||||
b, err = o.marshalField(b, fd, v)
|
b, err = o.marshalField(b, fd, v)
|
||||||
return err == nil
|
return err == nil
|
||||||
})
|
})
|
||||||
|
|
@ -229,27 +227,6 @@ func (o MarshalOptions) marshalMessageSlow(b []byte, m protoreflect.Message) ([]
|
||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// rangeFields visits fields in a defined order when deterministic serialization is enabled.
|
|
||||||
func (o MarshalOptions) rangeFields(m protoreflect.Message, f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
|
|
||||||
if !o.Deterministic {
|
|
||||||
m.Range(f)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var fds []protoreflect.FieldDescriptor
|
|
||||||
m.Range(func(fd protoreflect.FieldDescriptor, _ protoreflect.Value) bool {
|
|
||||||
fds = append(fds, fd)
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
sort.Slice(fds, func(a, b int) bool {
|
|
||||||
return fieldsort.Less(fds[a], fds[b])
|
|
||||||
})
|
|
||||||
for _, fd := range fds {
|
|
||||||
if !f(fd, m.Get(fd)) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o MarshalOptions) marshalField(b []byte, fd protoreflect.FieldDescriptor, value protoreflect.Value) ([]byte, error) {
|
func (o MarshalOptions) marshalField(b []byte, fd protoreflect.FieldDescriptor, value protoreflect.Value) ([]byte, error) {
|
||||||
switch {
|
switch {
|
||||||
case fd.IsList():
|
case fd.IsList():
|
||||||
|
|
@ -292,8 +269,12 @@ func (o MarshalOptions) marshalList(b []byte, fd protoreflect.FieldDescriptor, l
|
||||||
func (o MarshalOptions) marshalMap(b []byte, fd protoreflect.FieldDescriptor, mapv protoreflect.Map) ([]byte, error) {
|
func (o MarshalOptions) marshalMap(b []byte, fd protoreflect.FieldDescriptor, mapv protoreflect.Map) ([]byte, error) {
|
||||||
keyf := fd.MapKey()
|
keyf := fd.MapKey()
|
||||||
valf := fd.MapValue()
|
valf := fd.MapValue()
|
||||||
|
keyOrder := order.AnyKeyOrder
|
||||||
|
if o.Deterministic {
|
||||||
|
keyOrder = order.GenericKeyOrder
|
||||||
|
}
|
||||||
var err error
|
var err error
|
||||||
o.rangeMap(mapv, keyf.Kind(), func(key protoreflect.MapKey, value protoreflect.Value) bool {
|
order.RangeEntries(mapv, keyOrder, func(key protoreflect.MapKey, value protoreflect.Value) bool {
|
||||||
b = protowire.AppendTag(b, fd.Number(), protowire.BytesType)
|
b = protowire.AppendTag(b, fd.Number(), protowire.BytesType)
|
||||||
var pos int
|
var pos int
|
||||||
b, pos = appendSpeculativeLength(b)
|
b, pos = appendSpeculativeLength(b)
|
||||||
|
|
@ -312,14 +293,6 @@ func (o MarshalOptions) marshalMap(b []byte, fd protoreflect.FieldDescriptor, ma
|
||||||
return b, err
|
return b, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o MarshalOptions) rangeMap(mapv protoreflect.Map, kind protoreflect.Kind, f func(protoreflect.MapKey, protoreflect.Value) bool) {
|
|
||||||
if !o.Deterministic {
|
|
||||||
mapv.Range(f)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
mapsort.Range(mapv, kind, f)
|
|
||||||
}
|
|
||||||
|
|
||||||
// When encoding length-prefixed fields, we speculatively set aside some number of bytes
|
// When encoding length-prefixed fields, we speculatively set aside some number of bytes
|
||||||
// for the length, encode the data, and then encode the length (shifting the data if necessary
|
// for the length, encode the data, and then encode the length (shifting the data if necessary
|
||||||
// to make room).
|
// to make room).
|
||||||
|
|
|
||||||
|
|
@ -111,18 +111,31 @@ func equalList(fd pref.FieldDescriptor, x, y pref.List) bool {
|
||||||
|
|
||||||
// equalValue compares two singular values.
|
// equalValue compares two singular values.
|
||||||
func equalValue(fd pref.FieldDescriptor, x, y pref.Value) bool {
|
func equalValue(fd pref.FieldDescriptor, x, y pref.Value) bool {
|
||||||
switch {
|
switch fd.Kind() {
|
||||||
case fd.Message() != nil:
|
case pref.BoolKind:
|
||||||
return equalMessage(x.Message(), y.Message())
|
return x.Bool() == y.Bool()
|
||||||
case fd.Kind() == pref.BytesKind:
|
case pref.EnumKind:
|
||||||
return bytes.Equal(x.Bytes(), y.Bytes())
|
return x.Enum() == y.Enum()
|
||||||
case fd.Kind() == pref.FloatKind, fd.Kind() == pref.DoubleKind:
|
case pref.Int32Kind, pref.Sint32Kind,
|
||||||
|
pref.Int64Kind, pref.Sint64Kind,
|
||||||
|
pref.Sfixed32Kind, pref.Sfixed64Kind:
|
||||||
|
return x.Int() == y.Int()
|
||||||
|
case pref.Uint32Kind, pref.Uint64Kind,
|
||||||
|
pref.Fixed32Kind, pref.Fixed64Kind:
|
||||||
|
return x.Uint() == y.Uint()
|
||||||
|
case pref.FloatKind, pref.DoubleKind:
|
||||||
fx := x.Float()
|
fx := x.Float()
|
||||||
fy := y.Float()
|
fy := y.Float()
|
||||||
if math.IsNaN(fx) || math.IsNaN(fy) {
|
if math.IsNaN(fx) || math.IsNaN(fy) {
|
||||||
return math.IsNaN(fx) && math.IsNaN(fy)
|
return math.IsNaN(fx) && math.IsNaN(fy)
|
||||||
}
|
}
|
||||||
return fx == fy
|
return fx == fy
|
||||||
|
case pref.StringKind:
|
||||||
|
return x.String() == y.String()
|
||||||
|
case pref.BytesKind:
|
||||||
|
return bytes.Equal(x.Bytes(), y.Bytes())
|
||||||
|
case pref.MessageKind, pref.GroupKind:
|
||||||
|
return equalMessage(x.Message(), y.Message())
|
||||||
default:
|
default:
|
||||||
return x.Interface() == y.Interface()
|
return x.Interface() == y.Interface()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"google.golang.org/protobuf/internal/encoding/messageset"
|
"google.golang.org/protobuf/internal/encoding/messageset"
|
||||||
"google.golang.org/protobuf/internal/errors"
|
"google.golang.org/protobuf/internal/errors"
|
||||||
"google.golang.org/protobuf/internal/flags"
|
"google.golang.org/protobuf/internal/flags"
|
||||||
|
"google.golang.org/protobuf/internal/order"
|
||||||
"google.golang.org/protobuf/reflect/protoreflect"
|
"google.golang.org/protobuf/reflect/protoreflect"
|
||||||
"google.golang.org/protobuf/reflect/protoregistry"
|
"google.golang.org/protobuf/reflect/protoregistry"
|
||||||
)
|
)
|
||||||
|
|
@ -28,8 +29,12 @@ func (o MarshalOptions) marshalMessageSet(b []byte, m protoreflect.Message) ([]b
|
||||||
if !flags.ProtoLegacy {
|
if !flags.ProtoLegacy {
|
||||||
return b, errors.New("no support for message_set_wire_format")
|
return b, errors.New("no support for message_set_wire_format")
|
||||||
}
|
}
|
||||||
|
fieldOrder := order.AnyFieldOrder
|
||||||
|
if o.Deterministic {
|
||||||
|
fieldOrder = order.NumberFieldOrder
|
||||||
|
}
|
||||||
var err error
|
var err error
|
||||||
o.rangeFields(m, func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
|
order.RangeFields(m, fieldOrder, func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
|
||||||
b, err = o.marshalMessageSetField(b, fd, v)
|
b, err = o.marshalMessageSetField(b, fd, v)
|
||||||
return err == nil
|
return err == nil
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue