diff --git a/Makefile b/Makefile index 6c8ffa2..a668407 100644 --- a/Makefile +++ b/Makefile @@ -154,9 +154,10 @@ checkgenerate: @# Used in CI to verify that `make generate` doesn't produce a diff. git --no-pager diff --exit-code >&2 -internal/gen/*/*.pb.go: $(BIN)/buf internal/proto/*/*/*.proto internal/proto/*/*/*/*.proto +internal/gen/*/*.pb.go: $(BIN)/buf internal/proto/*/*/*.proto internal/proto/*/*/*/*.proto internal/gencode/* internal/gencode/generator/* $(BIN)/buf generate --clean $(BIN)/buf generate --template buf.gen.vt.yaml + $(BIN)/buf generate --template buf.gen.hyperpb.yaml .PHONY: $(BIN)/hypertest $(BIN)/hypertest: generate diff --git a/buf.gen.hyperpb.yaml b/buf.gen.hyperpb.yaml new file mode 100644 index 0000000..d1af8ff --- /dev/null +++ b/buf.gen.hyperpb.yaml @@ -0,0 +1,12 @@ +version: v2 +managed: + enabled: true + override: + - file_option: go_package_prefix + value: buf.build/go/hyperpb/internal/gen +plugins: + - local: ["go", "run", "./cmd/protoc-gen-hyperpb"] + out: internal/gen + opt: paths=source_relative +inputs: + - directory: internal/proto/test diff --git a/cmd/protoc-gen-hyperpb/export/export.go b/cmd/protoc-gen-hyperpb/export/export.go new file mode 100644 index 0000000..6bd0689 --- /dev/null +++ b/cmd/protoc-gen-hyperpb/export/export.go @@ -0,0 +1,43 @@ +// Copyright 2025 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package export contains exported types and functions for use by gencode. +// +// Importing this package outside of the gencode voids any API compatibility +// guarantees. +package export + +import ( + "google.golang.org/protobuf/reflect/protoreflect" + + "buf.build/go/hyperpb/internal/gencode" + "buf.build/go/hyperpb/internal/tdp/repeated" + "buf.build/go/hyperpb/internal/xunsafe" +) + +type ( + DoNotImplement = gencode.DoNotImplement + Type = gencode.Type + UnsafeMessage = gencode.UnsafeMessage +) + +func Reflect[P gencode.Message[M], M any](m P) protoreflect.Message { return gencode.Reflect(m) } + +func CastRepeatedEnum[E ~int32](r *repeated.Scalars[byte, protoreflect.EnumNumber]) *repeated.Scalars[byte, E] { + return xunsafe.Cast[repeated.Scalars[byte, E]](r) +} + +func CastRepeatedMessage[P gencode.Message[M], M any](r *repeated.UntypedMessages) *repeated.Messages[M, P] { + return xunsafe.Cast[repeated.Messages[M, P]](r) +} diff --git a/cmd/protoc-gen-hyperpb/main.go b/cmd/protoc-gen-hyperpb/main.go new file mode 100644 index 0000000..d7391b1 --- /dev/null +++ b/cmd/protoc-gen-hyperpb/main.go @@ -0,0 +1,34 @@ +// Copyright 2025 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Binary protoc-gen-hyperpb is a protoc plugin that generates Protobuf APIs for +// working with specific hyperpb-compiled messages without reflection. +// +// The generated API follows, but is not a drop-in replacement for, the opaque +// Go API, particularly returning non-slice values for accessing repeated +// fields. +// +// All message types emitted by this generator export the full interface of +// [hyperpb.Message], which can be used to access optimized operations, such +// as [hyperpb.Message.Unmarshal]. +package main + +import ( + "buf.build/go/hyperpb" + "buf.build/go/hyperpb/internal/gencode/generator" +) + +func main() { generator.Main() } + +var _ hyperpb.Message // For documentation links. diff --git a/internal/gen/test/hyper-test/descriptor.pb.go b/internal/gen/test/hyper-test/descriptor.pb.go new file mode 100644 index 0000000..885355c --- /dev/null +++ b/internal/gen/test/hyper-test/descriptor.pb.go @@ -0,0 +1,3792 @@ +// Copyright 2025 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-hyperpb. DO NOT EDIT. +// source: test/descriptor.proto + +// Copy of google/protobuf/descriptor.proto so that we can generate code for it +// using alternative runtimes that we might want to benchmark against. + +// This file is additionally covered by the following license: +// +// Copyright 2008 Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// buf:lint:ignore PACKAGE_VERSION_SUFFIX +// buf:lint:ignore PACKAGE_DIRECTORY_MATCH + +package test + +import ( + hyperpb "buf.build/go/hyperpb" + export "buf.build/go/hyperpb/cmd/protoc-gen-hyperpb/export" + test "buf.build/go/hyperpb/internal/gen/test" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + math "math" + unsafe "unsafe" +) + +// FileDescriptorSet is undocumented in the .proto file. +type FileDescriptorSet struct{ _ hyperpb.Message } + +var tFileDescriptorSet export.Type + +func init() { tFileDescriptorSet.Init("hyperpb.test.FileDescriptorSet") } + +// NewFileDescriptorSet allocates a new FileDescriptorSet. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(FileDescriptorSet) will not work. +func NewFileDescriptorSet(s *hyperpb.Shared) *FileDescriptorSet { + m := s.NewMessage(tFileDescriptorSet.Get()) + return (*FileDescriptorSet)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *FileDescriptorSet) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *FileDescriptorSet) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetFile extracts the value of hyperpb.test.FileDescriptorSet.file. +// +// This definition is undocumented in the .proto file. +func (x *FileDescriptorSet) GetFile() hyperpb.List[*FileDescriptorProto] { + v := x.unsafe().GetRepeatedMessage(0) + return export.CastRepeatedMessage[*FileDescriptorProto](v) +} + +// ProtoReflect implements proto.Message. +func (x *FileDescriptorSet) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*FileDescriptorSet) HyperMessage(export.DoNotImplement, *FileDescriptorSet) {} + +func (x *FileDescriptorSet) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *FileDescriptorSet) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// FileDescriptorProto is undocumented in the .proto file. +type FileDescriptorProto struct{ _ hyperpb.Message } + +var tFileDescriptorProto export.Type + +func init() { tFileDescriptorProto.Init("hyperpb.test.FileDescriptorProto") } + +// NewFileDescriptorProto allocates a new FileDescriptorProto. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(FileDescriptorProto) will not work. +func NewFileDescriptorProto(s *hyperpb.Shared) *FileDescriptorProto { + m := s.NewMessage(tFileDescriptorProto.Get()) + return (*FileDescriptorProto)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *FileDescriptorProto) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *FileDescriptorProto) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetName extracts the value of hyperpb.test.FileDescriptorProto.name. +// +// This definition is undocumented in the .proto file. +func (x *FileDescriptorProto) GetName() string { + v := x.unsafe().GetString(0, "") + return v +} + +// HasName checks whether hyperpb.test.FileDescriptorProto.name is populated. +// +// See [FileDescriptorProto.GetString]. +func (x *FileDescriptorProto) HasName() bool { + return x.unsafe().Has(0) +} + +// GetPackage extracts the value of hyperpb.test.FileDescriptorProto.package. +// +// This definition is undocumented in the .proto file. +func (x *FileDescriptorProto) GetPackage() string { + v := x.unsafe().GetString(1, "") + return v +} + +// HasPackage checks whether hyperpb.test.FileDescriptorProto.package is populated. +// +// See [FileDescriptorProto.GetString]. +func (x *FileDescriptorProto) HasPackage() bool { + return x.unsafe().Has(1) +} + +// GetDependency extracts the value of hyperpb.test.FileDescriptorProto.dependency. +// +// This definition is undocumented in the .proto file. +func (x *FileDescriptorProto) GetDependency() hyperpb.List[string] { + v := x.unsafe().GetRepeatedString(2) + return v +} + +// GetPublicDependency extracts the value of hyperpb.test.FileDescriptorProto.public_dependency. +// +// This definition is undocumented in the .proto file. +func (x *FileDescriptorProto) GetPublicDependency() hyperpb.List[int32] { + v := x.unsafe().GetRepeatedInt32(3) + return v +} + +// GetWeakDependency extracts the value of hyperpb.test.FileDescriptorProto.weak_dependency. +// +// This definition is undocumented in the .proto file. +func (x *FileDescriptorProto) GetWeakDependency() hyperpb.List[int32] { + v := x.unsafe().GetRepeatedInt32(4) + return v +} + +// GetMessageType extracts the value of hyperpb.test.FileDescriptorProto.message_type. +// +// This definition is undocumented in the .proto file. +func (x *FileDescriptorProto) GetMessageType() hyperpb.List[*DescriptorProto] { + v := x.unsafe().GetRepeatedMessage(5) + return export.CastRepeatedMessage[*DescriptorProto](v) +} + +// GetEnumType extracts the value of hyperpb.test.FileDescriptorProto.enum_type. +// +// This definition is undocumented in the .proto file. +func (x *FileDescriptorProto) GetEnumType() hyperpb.List[*EnumDescriptorProto] { + v := x.unsafe().GetRepeatedMessage(6) + return export.CastRepeatedMessage[*EnumDescriptorProto](v) +} + +// GetService extracts the value of hyperpb.test.FileDescriptorProto.service. +// +// This definition is undocumented in the .proto file. +func (x *FileDescriptorProto) GetService() hyperpb.List[*ServiceDescriptorProto] { + v := x.unsafe().GetRepeatedMessage(7) + return export.CastRepeatedMessage[*ServiceDescriptorProto](v) +} + +// GetExtension extracts the value of hyperpb.test.FileDescriptorProto.extension. +// +// This definition is undocumented in the .proto file. +func (x *FileDescriptorProto) GetExtension() hyperpb.List[*FieldDescriptorProto] { + v := x.unsafe().GetRepeatedMessage(8) + return export.CastRepeatedMessage[*FieldDescriptorProto](v) +} + +// GetOptions extracts the value of hyperpb.test.FileDescriptorProto.options. +// +// This definition is undocumented in the .proto file. +func (x *FileDescriptorProto) GetOptions() *FileOptions { + v := x.unsafe().GetMessage(9) + return (*FileOptions)(v) +} + +// HasOptions checks whether hyperpb.test.FileDescriptorProto.options is populated. +// +// See [FileDescriptorProto.GetMessage]. +func (x *FileDescriptorProto) HasOptions() bool { + return x.unsafe().Has(9) +} + +// GetSourceCodeInfo extracts the value of hyperpb.test.FileDescriptorProto.source_code_info. +// +// This definition is undocumented in the .proto file. +func (x *FileDescriptorProto) GetSourceCodeInfo() *SourceCodeInfo { + v := x.unsafe().GetMessage(10) + return (*SourceCodeInfo)(v) +} + +// HasSourceCodeInfo checks whether hyperpb.test.FileDescriptorProto.source_code_info is populated. +// +// See [FileDescriptorProto.GetMessage]. +func (x *FileDescriptorProto) HasSourceCodeInfo() bool { + return x.unsafe().Has(10) +} + +// GetSyntax extracts the value of hyperpb.test.FileDescriptorProto.syntax. +// +// This definition is undocumented in the .proto file. +func (x *FileDescriptorProto) GetSyntax() string { + v := x.unsafe().GetString(11, "") + return v +} + +// HasSyntax checks whether hyperpb.test.FileDescriptorProto.syntax is populated. +// +// See [FileDescriptorProto.GetString]. +func (x *FileDescriptorProto) HasSyntax() bool { + return x.unsafe().Has(11) +} + +// GetEdition extracts the value of hyperpb.test.FileDescriptorProto.edition. +// +// This definition is undocumented in the .proto file. +func (x *FileDescriptorProto) GetEdition() test.Edition { + v := x.unsafe().GetEnum(12, 0) + return test.Edition(v) +} + +// HasEdition checks whether hyperpb.test.FileDescriptorProto.edition is populated. +// +// See [FileDescriptorProto.GetEnum]. +func (x *FileDescriptorProto) HasEdition() bool { + return x.unsafe().Has(12) +} + +// ProtoReflect implements proto.Message. +func (x *FileDescriptorProto) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*FileDescriptorProto) HyperMessage(export.DoNotImplement, *FileDescriptorProto) {} + +func (x *FileDescriptorProto) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *FileDescriptorProto) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// DescriptorProto is undocumented in the .proto file. +type DescriptorProto struct{ _ hyperpb.Message } + +var tDescriptorProto export.Type + +func init() { tDescriptorProto.Init("hyperpb.test.DescriptorProto") } + +// NewDescriptorProto allocates a new DescriptorProto. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(DescriptorProto) will not work. +func NewDescriptorProto(s *hyperpb.Shared) *DescriptorProto { + m := s.NewMessage(tDescriptorProto.Get()) + return (*DescriptorProto)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *DescriptorProto) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *DescriptorProto) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetName extracts the value of hyperpb.test.DescriptorProto.name. +// +// This definition is undocumented in the .proto file. +func (x *DescriptorProto) GetName() string { + v := x.unsafe().GetString(0, "") + return v +} + +// HasName checks whether hyperpb.test.DescriptorProto.name is populated. +// +// See [DescriptorProto.GetString]. +func (x *DescriptorProto) HasName() bool { + return x.unsafe().Has(0) +} + +// GetField extracts the value of hyperpb.test.DescriptorProto.field. +// +// This definition is undocumented in the .proto file. +func (x *DescriptorProto) GetField() hyperpb.List[*FieldDescriptorProto] { + v := x.unsafe().GetRepeatedMessage(1) + return export.CastRepeatedMessage[*FieldDescriptorProto](v) +} + +// GetExtension extracts the value of hyperpb.test.DescriptorProto.extension. +// +// This definition is undocumented in the .proto file. +func (x *DescriptorProto) GetExtension() hyperpb.List[*FieldDescriptorProto] { + v := x.unsafe().GetRepeatedMessage(2) + return export.CastRepeatedMessage[*FieldDescriptorProto](v) +} + +// GetNestedType extracts the value of hyperpb.test.DescriptorProto.nested_type. +// +// This definition is undocumented in the .proto file. +func (x *DescriptorProto) GetNestedType() hyperpb.List[*DescriptorProto] { + v := x.unsafe().GetRepeatedMessage(3) + return export.CastRepeatedMessage[*DescriptorProto](v) +} + +// GetEnumType extracts the value of hyperpb.test.DescriptorProto.enum_type. +// +// This definition is undocumented in the .proto file. +func (x *DescriptorProto) GetEnumType() hyperpb.List[*EnumDescriptorProto] { + v := x.unsafe().GetRepeatedMessage(4) + return export.CastRepeatedMessage[*EnumDescriptorProto](v) +} + +// GetExtensionRange extracts the value of hyperpb.test.DescriptorProto.extension_range. +// +// This definition is undocumented in the .proto file. +func (x *DescriptorProto) GetExtensionRange() hyperpb.List[*DescriptorProto_ExtensionRange] { + v := x.unsafe().GetRepeatedMessage(5) + return export.CastRepeatedMessage[*DescriptorProto_ExtensionRange](v) +} + +// GetOneofDecl extracts the value of hyperpb.test.DescriptorProto.oneof_decl. +// +// This definition is undocumented in the .proto file. +func (x *DescriptorProto) GetOneofDecl() hyperpb.List[*OneofDescriptorProto] { + v := x.unsafe().GetRepeatedMessage(6) + return export.CastRepeatedMessage[*OneofDescriptorProto](v) +} + +// GetOptions extracts the value of hyperpb.test.DescriptorProto.options. +// +// This definition is undocumented in the .proto file. +func (x *DescriptorProto) GetOptions() *MessageOptions { + v := x.unsafe().GetMessage(7) + return (*MessageOptions)(v) +} + +// HasOptions checks whether hyperpb.test.DescriptorProto.options is populated. +// +// See [DescriptorProto.GetMessage]. +func (x *DescriptorProto) HasOptions() bool { + return x.unsafe().Has(7) +} + +// GetReservedRange extracts the value of hyperpb.test.DescriptorProto.reserved_range. +// +// This definition is undocumented in the .proto file. +func (x *DescriptorProto) GetReservedRange() hyperpb.List[*DescriptorProto_ReservedRange] { + v := x.unsafe().GetRepeatedMessage(8) + return export.CastRepeatedMessage[*DescriptorProto_ReservedRange](v) +} + +// GetReservedName extracts the value of hyperpb.test.DescriptorProto.reserved_name. +// +// This definition is undocumented in the .proto file. +func (x *DescriptorProto) GetReservedName() hyperpb.List[string] { + v := x.unsafe().GetRepeatedString(9) + return v +} + +// ProtoReflect implements proto.Message. +func (x *DescriptorProto) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*DescriptorProto) HyperMessage(export.DoNotImplement, *DescriptorProto) {} + +func (x *DescriptorProto) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *DescriptorProto) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// DescriptorProto_ExtensionRange is undocumented in the .proto file. +type DescriptorProto_ExtensionRange struct{ _ hyperpb.Message } + +var tDescriptorProto_ExtensionRange export.Type + +func init() { tDescriptorProto_ExtensionRange.Init("hyperpb.test.DescriptorProto.ExtensionRange") } + +// NewDescriptorProto_ExtensionRange allocates a new DescriptorProto_ExtensionRange. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(DescriptorProto_ExtensionRange) will not work. +func NewDescriptorProto_ExtensionRange(s *hyperpb.Shared) *DescriptorProto_ExtensionRange { + m := s.NewMessage(tDescriptorProto_ExtensionRange.Get()) + return (*DescriptorProto_ExtensionRange)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *DescriptorProto_ExtensionRange) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *DescriptorProto_ExtensionRange) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetStart extracts the value of hyperpb.test.DescriptorProto.ExtensionRange.start. +// +// This definition is undocumented in the .proto file. +func (x *DescriptorProto_ExtensionRange) GetStart() int32 { + v := x.unsafe().GetInt32(0, 0) + return v +} + +// HasStart checks whether hyperpb.test.DescriptorProto.ExtensionRange.start is populated. +// +// See [DescriptorProto_ExtensionRange.GetInt32]. +func (x *DescriptorProto_ExtensionRange) HasStart() bool { + return x.unsafe().Has(0) +} + +// GetEnd extracts the value of hyperpb.test.DescriptorProto.ExtensionRange.end. +// +// This definition is undocumented in the .proto file. +func (x *DescriptorProto_ExtensionRange) GetEnd() int32 { + v := x.unsafe().GetInt32(1, 0) + return v +} + +// HasEnd checks whether hyperpb.test.DescriptorProto.ExtensionRange.end is populated. +// +// See [DescriptorProto_ExtensionRange.GetInt32]. +func (x *DescriptorProto_ExtensionRange) HasEnd() bool { + return x.unsafe().Has(1) +} + +// GetOptions extracts the value of hyperpb.test.DescriptorProto.ExtensionRange.options. +// +// This definition is undocumented in the .proto file. +func (x *DescriptorProto_ExtensionRange) GetOptions() *ExtensionRangeOptions { + v := x.unsafe().GetMessage(2) + return (*ExtensionRangeOptions)(v) +} + +// HasOptions checks whether hyperpb.test.DescriptorProto.ExtensionRange.options is populated. +// +// See [DescriptorProto_ExtensionRange.GetMessage]. +func (x *DescriptorProto_ExtensionRange) HasOptions() bool { + return x.unsafe().Has(2) +} + +// ProtoReflect implements proto.Message. +func (x *DescriptorProto_ExtensionRange) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*DescriptorProto_ExtensionRange) HyperMessage(export.DoNotImplement, *DescriptorProto_ExtensionRange) { +} + +func (x *DescriptorProto_ExtensionRange) impl() *hyperpb.Message { + return (*hyperpb.Message)(unsafe.Pointer(x)) +} + +func (x *DescriptorProto_ExtensionRange) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// DescriptorProto_ReservedRange is undocumented in the .proto file. +type DescriptorProto_ReservedRange struct{ _ hyperpb.Message } + +var tDescriptorProto_ReservedRange export.Type + +func init() { tDescriptorProto_ReservedRange.Init("hyperpb.test.DescriptorProto.ReservedRange") } + +// NewDescriptorProto_ReservedRange allocates a new DescriptorProto_ReservedRange. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(DescriptorProto_ReservedRange) will not work. +func NewDescriptorProto_ReservedRange(s *hyperpb.Shared) *DescriptorProto_ReservedRange { + m := s.NewMessage(tDescriptorProto_ReservedRange.Get()) + return (*DescriptorProto_ReservedRange)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *DescriptorProto_ReservedRange) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *DescriptorProto_ReservedRange) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetStart extracts the value of hyperpb.test.DescriptorProto.ReservedRange.start. +// +// This definition is undocumented in the .proto file. +func (x *DescriptorProto_ReservedRange) GetStart() int32 { + v := x.unsafe().GetInt32(0, 0) + return v +} + +// HasStart checks whether hyperpb.test.DescriptorProto.ReservedRange.start is populated. +// +// See [DescriptorProto_ReservedRange.GetInt32]. +func (x *DescriptorProto_ReservedRange) HasStart() bool { + return x.unsafe().Has(0) +} + +// GetEnd extracts the value of hyperpb.test.DescriptorProto.ReservedRange.end. +// +// This definition is undocumented in the .proto file. +func (x *DescriptorProto_ReservedRange) GetEnd() int32 { + v := x.unsafe().GetInt32(1, 0) + return v +} + +// HasEnd checks whether hyperpb.test.DescriptorProto.ReservedRange.end is populated. +// +// See [DescriptorProto_ReservedRange.GetInt32]. +func (x *DescriptorProto_ReservedRange) HasEnd() bool { + return x.unsafe().Has(1) +} + +// ProtoReflect implements proto.Message. +func (x *DescriptorProto_ReservedRange) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*DescriptorProto_ReservedRange) HyperMessage(export.DoNotImplement, *DescriptorProto_ReservedRange) { +} + +func (x *DescriptorProto_ReservedRange) impl() *hyperpb.Message { + return (*hyperpb.Message)(unsafe.Pointer(x)) +} + +func (x *DescriptorProto_ReservedRange) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// ExtensionRangeOptions is undocumented in the .proto file. +type ExtensionRangeOptions struct{ _ hyperpb.Message } + +var tExtensionRangeOptions export.Type + +func init() { tExtensionRangeOptions.Init("hyperpb.test.ExtensionRangeOptions") } + +// NewExtensionRangeOptions allocates a new ExtensionRangeOptions. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(ExtensionRangeOptions) will not work. +func NewExtensionRangeOptions(s *hyperpb.Shared) *ExtensionRangeOptions { + m := s.NewMessage(tExtensionRangeOptions.Get()) + return (*ExtensionRangeOptions)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *ExtensionRangeOptions) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *ExtensionRangeOptions) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetUninterpretedOption extracts the value of hyperpb.test.ExtensionRangeOptions.uninterpreted_option. +// +// This definition is undocumented in the .proto file. +func (x *ExtensionRangeOptions) GetUninterpretedOption() hyperpb.List[*UninterpretedOption] { + v := x.unsafe().GetRepeatedMessage(0) + return export.CastRepeatedMessage[*UninterpretedOption](v) +} + +// GetDeclaration extracts the value of hyperpb.test.ExtensionRangeOptions.declaration. +// +// This definition is undocumented in the .proto file. +func (x *ExtensionRangeOptions) GetDeclaration() hyperpb.List[*ExtensionRangeOptions_Declaration] { + v := x.unsafe().GetRepeatedMessage(1) + return export.CastRepeatedMessage[*ExtensionRangeOptions_Declaration](v) +} + +// GetFeatures extracts the value of hyperpb.test.ExtensionRangeOptions.features. +// +// This definition is undocumented in the .proto file. +func (x *ExtensionRangeOptions) GetFeatures() *FeatureSet { + v := x.unsafe().GetMessage(2) + return (*FeatureSet)(v) +} + +// HasFeatures checks whether hyperpb.test.ExtensionRangeOptions.features is populated. +// +// See [ExtensionRangeOptions.GetMessage]. +func (x *ExtensionRangeOptions) HasFeatures() bool { + return x.unsafe().Has(2) +} + +// GetVerification extracts the value of hyperpb.test.ExtensionRangeOptions.verification. +// +// This definition is undocumented in the .proto file. +func (x *ExtensionRangeOptions) GetVerification() test.ExtensionRangeOptions_VerificationState { + v := x.unsafe().GetEnum(3, 1) + return test.ExtensionRangeOptions_VerificationState(v) +} + +// HasVerification checks whether hyperpb.test.ExtensionRangeOptions.verification is populated. +// +// See [ExtensionRangeOptions.GetEnum]. +func (x *ExtensionRangeOptions) HasVerification() bool { + return x.unsafe().Has(3) +} + +// ProtoReflect implements proto.Message. +func (x *ExtensionRangeOptions) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*ExtensionRangeOptions) HyperMessage(export.DoNotImplement, *ExtensionRangeOptions) {} + +func (x *ExtensionRangeOptions) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *ExtensionRangeOptions) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// ExtensionRangeOptions_Declaration is undocumented in the .proto file. +type ExtensionRangeOptions_Declaration struct{ _ hyperpb.Message } + +var tExtensionRangeOptions_Declaration export.Type + +func init() { + tExtensionRangeOptions_Declaration.Init("hyperpb.test.ExtensionRangeOptions.Declaration") +} + +// NewExtensionRangeOptions_Declaration allocates a new ExtensionRangeOptions_Declaration. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(ExtensionRangeOptions_Declaration) will not work. +func NewExtensionRangeOptions_Declaration(s *hyperpb.Shared) *ExtensionRangeOptions_Declaration { + m := s.NewMessage(tExtensionRangeOptions_Declaration.Get()) + return (*ExtensionRangeOptions_Declaration)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *ExtensionRangeOptions_Declaration) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *ExtensionRangeOptions_Declaration) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetNumber extracts the value of hyperpb.test.ExtensionRangeOptions.Declaration.number. +// +// This definition is undocumented in the .proto file. +func (x *ExtensionRangeOptions_Declaration) GetNumber() int32 { + v := x.unsafe().GetInt32(0, 0) + return v +} + +// HasNumber checks whether hyperpb.test.ExtensionRangeOptions.Declaration.number is populated. +// +// See [ExtensionRangeOptions_Declaration.GetInt32]. +func (x *ExtensionRangeOptions_Declaration) HasNumber() bool { + return x.unsafe().Has(0) +} + +// GetFullName extracts the value of hyperpb.test.ExtensionRangeOptions.Declaration.full_name. +// +// This definition is undocumented in the .proto file. +func (x *ExtensionRangeOptions_Declaration) GetFullName() string { + v := x.unsafe().GetString(1, "") + return v +} + +// HasFullName checks whether hyperpb.test.ExtensionRangeOptions.Declaration.full_name is populated. +// +// See [ExtensionRangeOptions_Declaration.GetString]. +func (x *ExtensionRangeOptions_Declaration) HasFullName() bool { + return x.unsafe().Has(1) +} + +// GetType extracts the value of hyperpb.test.ExtensionRangeOptions.Declaration.type. +// +// This definition is undocumented in the .proto file. +func (x *ExtensionRangeOptions_Declaration) GetType() string { + v := x.unsafe().GetString(2, "") + return v +} + +// HasType checks whether hyperpb.test.ExtensionRangeOptions.Declaration.type is populated. +// +// See [ExtensionRangeOptions_Declaration.GetString]. +func (x *ExtensionRangeOptions_Declaration) HasType() bool { + return x.unsafe().Has(2) +} + +// GetReserved extracts the value of hyperpb.test.ExtensionRangeOptions.Declaration.reserved. +// +// This definition is undocumented in the .proto file. +func (x *ExtensionRangeOptions_Declaration) GetReserved() bool { + v := x.unsafe().GetBool(3, false) + return v +} + +// HasReserved checks whether hyperpb.test.ExtensionRangeOptions.Declaration.reserved is populated. +// +// See [ExtensionRangeOptions_Declaration.GetBool]. +func (x *ExtensionRangeOptions_Declaration) HasReserved() bool { + return x.unsafe().Has(3) +} + +// GetRepeated extracts the value of hyperpb.test.ExtensionRangeOptions.Declaration.repeated. +// +// This definition is undocumented in the .proto file. +func (x *ExtensionRangeOptions_Declaration) GetRepeated() bool { + v := x.unsafe().GetBool(4, false) + return v +} + +// HasRepeated checks whether hyperpb.test.ExtensionRangeOptions.Declaration.repeated is populated. +// +// See [ExtensionRangeOptions_Declaration.GetBool]. +func (x *ExtensionRangeOptions_Declaration) HasRepeated() bool { + return x.unsafe().Has(4) +} + +// ProtoReflect implements proto.Message. +func (x *ExtensionRangeOptions_Declaration) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*ExtensionRangeOptions_Declaration) HyperMessage(export.DoNotImplement, *ExtensionRangeOptions_Declaration) { +} + +func (x *ExtensionRangeOptions_Declaration) impl() *hyperpb.Message { + return (*hyperpb.Message)(unsafe.Pointer(x)) +} + +func (x *ExtensionRangeOptions_Declaration) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// FieldDescriptorProto is undocumented in the .proto file. +type FieldDescriptorProto struct{ _ hyperpb.Message } + +var tFieldDescriptorProto export.Type + +func init() { tFieldDescriptorProto.Init("hyperpb.test.FieldDescriptorProto") } + +// NewFieldDescriptorProto allocates a new FieldDescriptorProto. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(FieldDescriptorProto) will not work. +func NewFieldDescriptorProto(s *hyperpb.Shared) *FieldDescriptorProto { + m := s.NewMessage(tFieldDescriptorProto.Get()) + return (*FieldDescriptorProto)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *FieldDescriptorProto) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *FieldDescriptorProto) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetName extracts the value of hyperpb.test.FieldDescriptorProto.name. +// +// This definition is undocumented in the .proto file. +func (x *FieldDescriptorProto) GetName() string { + v := x.unsafe().GetString(0, "") + return v +} + +// HasName checks whether hyperpb.test.FieldDescriptorProto.name is populated. +// +// See [FieldDescriptorProto.GetString]. +func (x *FieldDescriptorProto) HasName() bool { + return x.unsafe().Has(0) +} + +// GetNumber extracts the value of hyperpb.test.FieldDescriptorProto.number. +// +// This definition is undocumented in the .proto file. +func (x *FieldDescriptorProto) GetNumber() int32 { + v := x.unsafe().GetInt32(1, 0) + return v +} + +// HasNumber checks whether hyperpb.test.FieldDescriptorProto.number is populated. +// +// See [FieldDescriptorProto.GetInt32]. +func (x *FieldDescriptorProto) HasNumber() bool { + return x.unsafe().Has(1) +} + +// GetLabel extracts the value of hyperpb.test.FieldDescriptorProto.label. +// +// This definition is undocumented in the .proto file. +func (x *FieldDescriptorProto) GetLabel() test.FieldDescriptorProto_Label { + v := x.unsafe().GetEnum(2, 1) + return test.FieldDescriptorProto_Label(v) +} + +// HasLabel checks whether hyperpb.test.FieldDescriptorProto.label is populated. +// +// See [FieldDescriptorProto.GetEnum]. +func (x *FieldDescriptorProto) HasLabel() bool { + return x.unsafe().Has(2) +} + +// GetType extracts the value of hyperpb.test.FieldDescriptorProto.type. +// +// This definition is undocumented in the .proto file. +func (x *FieldDescriptorProto) GetType() test.FieldDescriptorProto_Type { + v := x.unsafe().GetEnum(3, 1) + return test.FieldDescriptorProto_Type(v) +} + +// HasType checks whether hyperpb.test.FieldDescriptorProto.type is populated. +// +// See [FieldDescriptorProto.GetEnum]. +func (x *FieldDescriptorProto) HasType() bool { + return x.unsafe().Has(3) +} + +// GetTypeName extracts the value of hyperpb.test.FieldDescriptorProto.type_name. +// +// This definition is undocumented in the .proto file. +func (x *FieldDescriptorProto) GetTypeName() string { + v := x.unsafe().GetString(4, "") + return v +} + +// HasTypeName checks whether hyperpb.test.FieldDescriptorProto.type_name is populated. +// +// See [FieldDescriptorProto.GetString]. +func (x *FieldDescriptorProto) HasTypeName() bool { + return x.unsafe().Has(4) +} + +// GetExtendee extracts the value of hyperpb.test.FieldDescriptorProto.extendee. +// +// This definition is undocumented in the .proto file. +func (x *FieldDescriptorProto) GetExtendee() string { + v := x.unsafe().GetString(5, "") + return v +} + +// HasExtendee checks whether hyperpb.test.FieldDescriptorProto.extendee is populated. +// +// See [FieldDescriptorProto.GetString]. +func (x *FieldDescriptorProto) HasExtendee() bool { + return x.unsafe().Has(5) +} + +// GetDefaultValue extracts the value of hyperpb.test.FieldDescriptorProto.default_value. +// +// This definition is undocumented in the .proto file. +func (x *FieldDescriptorProto) GetDefaultValue() string { + v := x.unsafe().GetString(6, "") + return v +} + +// HasDefaultValue checks whether hyperpb.test.FieldDescriptorProto.default_value is populated. +// +// See [FieldDescriptorProto.GetString]. +func (x *FieldDescriptorProto) HasDefaultValue() bool { + return x.unsafe().Has(6) +} + +// GetOneofIndex extracts the value of hyperpb.test.FieldDescriptorProto.oneof_index. +// +// This definition is undocumented in the .proto file. +func (x *FieldDescriptorProto) GetOneofIndex() int32 { + v := x.unsafe().GetInt32(7, 0) + return v +} + +// HasOneofIndex checks whether hyperpb.test.FieldDescriptorProto.oneof_index is populated. +// +// See [FieldDescriptorProto.GetInt32]. +func (x *FieldDescriptorProto) HasOneofIndex() bool { + return x.unsafe().Has(7) +} + +// GetJsonName extracts the value of hyperpb.test.FieldDescriptorProto.json_name. +// +// This definition is undocumented in the .proto file. +func (x *FieldDescriptorProto) GetJsonName() string { + v := x.unsafe().GetString(8, "") + return v +} + +// HasJsonName checks whether hyperpb.test.FieldDescriptorProto.json_name is populated. +// +// See [FieldDescriptorProto.GetString]. +func (x *FieldDescriptorProto) HasJsonName() bool { + return x.unsafe().Has(8) +} + +// GetOptions extracts the value of hyperpb.test.FieldDescriptorProto.options. +// +// This definition is undocumented in the .proto file. +func (x *FieldDescriptorProto) GetOptions() *FieldOptions { + v := x.unsafe().GetMessage(9) + return (*FieldOptions)(v) +} + +// HasOptions checks whether hyperpb.test.FieldDescriptorProto.options is populated. +// +// See [FieldDescriptorProto.GetMessage]. +func (x *FieldDescriptorProto) HasOptions() bool { + return x.unsafe().Has(9) +} + +// GetProto3Optional extracts the value of hyperpb.test.FieldDescriptorProto.proto3_optional. +// +// This definition is undocumented in the .proto file. +func (x *FieldDescriptorProto) GetProto3Optional() bool { + v := x.unsafe().GetBool(10, false) + return v +} + +// HasProto3Optional checks whether hyperpb.test.FieldDescriptorProto.proto3_optional is populated. +// +// See [FieldDescriptorProto.GetBool]. +func (x *FieldDescriptorProto) HasProto3Optional() bool { + return x.unsafe().Has(10) +} + +// ProtoReflect implements proto.Message. +func (x *FieldDescriptorProto) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*FieldDescriptorProto) HyperMessage(export.DoNotImplement, *FieldDescriptorProto) {} + +func (x *FieldDescriptorProto) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *FieldDescriptorProto) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// OneofDescriptorProto is undocumented in the .proto file. +type OneofDescriptorProto struct{ _ hyperpb.Message } + +var tOneofDescriptorProto export.Type + +func init() { tOneofDescriptorProto.Init("hyperpb.test.OneofDescriptorProto") } + +// NewOneofDescriptorProto allocates a new OneofDescriptorProto. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(OneofDescriptorProto) will not work. +func NewOneofDescriptorProto(s *hyperpb.Shared) *OneofDescriptorProto { + m := s.NewMessage(tOneofDescriptorProto.Get()) + return (*OneofDescriptorProto)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *OneofDescriptorProto) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *OneofDescriptorProto) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetName extracts the value of hyperpb.test.OneofDescriptorProto.name. +// +// This definition is undocumented in the .proto file. +func (x *OneofDescriptorProto) GetName() string { + v := x.unsafe().GetString(0, "") + return v +} + +// HasName checks whether hyperpb.test.OneofDescriptorProto.name is populated. +// +// See [OneofDescriptorProto.GetString]. +func (x *OneofDescriptorProto) HasName() bool { + return x.unsafe().Has(0) +} + +// GetOptions extracts the value of hyperpb.test.OneofDescriptorProto.options. +// +// This definition is undocumented in the .proto file. +func (x *OneofDescriptorProto) GetOptions() *OneofOptions { + v := x.unsafe().GetMessage(1) + return (*OneofOptions)(v) +} + +// HasOptions checks whether hyperpb.test.OneofDescriptorProto.options is populated. +// +// See [OneofDescriptorProto.GetMessage]. +func (x *OneofDescriptorProto) HasOptions() bool { + return x.unsafe().Has(1) +} + +// ProtoReflect implements proto.Message. +func (x *OneofDescriptorProto) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*OneofDescriptorProto) HyperMessage(export.DoNotImplement, *OneofDescriptorProto) {} + +func (x *OneofDescriptorProto) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *OneofDescriptorProto) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// EnumDescriptorProto is undocumented in the .proto file. +type EnumDescriptorProto struct{ _ hyperpb.Message } + +var tEnumDescriptorProto export.Type + +func init() { tEnumDescriptorProto.Init("hyperpb.test.EnumDescriptorProto") } + +// NewEnumDescriptorProto allocates a new EnumDescriptorProto. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(EnumDescriptorProto) will not work. +func NewEnumDescriptorProto(s *hyperpb.Shared) *EnumDescriptorProto { + m := s.NewMessage(tEnumDescriptorProto.Get()) + return (*EnumDescriptorProto)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *EnumDescriptorProto) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *EnumDescriptorProto) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetName extracts the value of hyperpb.test.EnumDescriptorProto.name. +// +// This definition is undocumented in the .proto file. +func (x *EnumDescriptorProto) GetName() string { + v := x.unsafe().GetString(0, "") + return v +} + +// HasName checks whether hyperpb.test.EnumDescriptorProto.name is populated. +// +// See [EnumDescriptorProto.GetString]. +func (x *EnumDescriptorProto) HasName() bool { + return x.unsafe().Has(0) +} + +// GetValue extracts the value of hyperpb.test.EnumDescriptorProto.value. +// +// This definition is undocumented in the .proto file. +func (x *EnumDescriptorProto) GetValue() hyperpb.List[*EnumValueDescriptorProto] { + v := x.unsafe().GetRepeatedMessage(1) + return export.CastRepeatedMessage[*EnumValueDescriptorProto](v) +} + +// GetOptions extracts the value of hyperpb.test.EnumDescriptorProto.options. +// +// This definition is undocumented in the .proto file. +func (x *EnumDescriptorProto) GetOptions() *EnumOptions { + v := x.unsafe().GetMessage(2) + return (*EnumOptions)(v) +} + +// HasOptions checks whether hyperpb.test.EnumDescriptorProto.options is populated. +// +// See [EnumDescriptorProto.GetMessage]. +func (x *EnumDescriptorProto) HasOptions() bool { + return x.unsafe().Has(2) +} + +// GetReservedRange extracts the value of hyperpb.test.EnumDescriptorProto.reserved_range. +// +// This definition is undocumented in the .proto file. +func (x *EnumDescriptorProto) GetReservedRange() hyperpb.List[*EnumDescriptorProto_EnumReservedRange] { + v := x.unsafe().GetRepeatedMessage(3) + return export.CastRepeatedMessage[*EnumDescriptorProto_EnumReservedRange](v) +} + +// GetReservedName extracts the value of hyperpb.test.EnumDescriptorProto.reserved_name. +// +// This definition is undocumented in the .proto file. +func (x *EnumDescriptorProto) GetReservedName() hyperpb.List[string] { + v := x.unsafe().GetRepeatedString(4) + return v +} + +// ProtoReflect implements proto.Message. +func (x *EnumDescriptorProto) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*EnumDescriptorProto) HyperMessage(export.DoNotImplement, *EnumDescriptorProto) {} + +func (x *EnumDescriptorProto) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *EnumDescriptorProto) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// EnumDescriptorProto_EnumReservedRange is undocumented in the .proto file. +type EnumDescriptorProto_EnumReservedRange struct{ _ hyperpb.Message } + +var tEnumDescriptorProto_EnumReservedRange export.Type + +func init() { + tEnumDescriptorProto_EnumReservedRange.Init("hyperpb.test.EnumDescriptorProto.EnumReservedRange") +} + +// NewEnumDescriptorProto_EnumReservedRange allocates a new EnumDescriptorProto_EnumReservedRange. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(EnumDescriptorProto_EnumReservedRange) will not work. +func NewEnumDescriptorProto_EnumReservedRange(s *hyperpb.Shared) *EnumDescriptorProto_EnumReservedRange { + m := s.NewMessage(tEnumDescriptorProto_EnumReservedRange.Get()) + return (*EnumDescriptorProto_EnumReservedRange)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *EnumDescriptorProto_EnumReservedRange) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *EnumDescriptorProto_EnumReservedRange) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetStart extracts the value of hyperpb.test.EnumDescriptorProto.EnumReservedRange.start. +// +// This definition is undocumented in the .proto file. +func (x *EnumDescriptorProto_EnumReservedRange) GetStart() int32 { + v := x.unsafe().GetInt32(0, 0) + return v +} + +// HasStart checks whether hyperpb.test.EnumDescriptorProto.EnumReservedRange.start is populated. +// +// See [EnumDescriptorProto_EnumReservedRange.GetInt32]. +func (x *EnumDescriptorProto_EnumReservedRange) HasStart() bool { + return x.unsafe().Has(0) +} + +// GetEnd extracts the value of hyperpb.test.EnumDescriptorProto.EnumReservedRange.end. +// +// This definition is undocumented in the .proto file. +func (x *EnumDescriptorProto_EnumReservedRange) GetEnd() int32 { + v := x.unsafe().GetInt32(1, 0) + return v +} + +// HasEnd checks whether hyperpb.test.EnumDescriptorProto.EnumReservedRange.end is populated. +// +// See [EnumDescriptorProto_EnumReservedRange.GetInt32]. +func (x *EnumDescriptorProto_EnumReservedRange) HasEnd() bool { + return x.unsafe().Has(1) +} + +// ProtoReflect implements proto.Message. +func (x *EnumDescriptorProto_EnumReservedRange) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*EnumDescriptorProto_EnumReservedRange) HyperMessage(export.DoNotImplement, *EnumDescriptorProto_EnumReservedRange) { +} + +func (x *EnumDescriptorProto_EnumReservedRange) impl() *hyperpb.Message { + return (*hyperpb.Message)(unsafe.Pointer(x)) +} + +func (x *EnumDescriptorProto_EnumReservedRange) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// EnumValueDescriptorProto is undocumented in the .proto file. +type EnumValueDescriptorProto struct{ _ hyperpb.Message } + +var tEnumValueDescriptorProto export.Type + +func init() { tEnumValueDescriptorProto.Init("hyperpb.test.EnumValueDescriptorProto") } + +// NewEnumValueDescriptorProto allocates a new EnumValueDescriptorProto. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(EnumValueDescriptorProto) will not work. +func NewEnumValueDescriptorProto(s *hyperpb.Shared) *EnumValueDescriptorProto { + m := s.NewMessage(tEnumValueDescriptorProto.Get()) + return (*EnumValueDescriptorProto)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *EnumValueDescriptorProto) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *EnumValueDescriptorProto) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetName extracts the value of hyperpb.test.EnumValueDescriptorProto.name. +// +// This definition is undocumented in the .proto file. +func (x *EnumValueDescriptorProto) GetName() string { + v := x.unsafe().GetString(0, "") + return v +} + +// HasName checks whether hyperpb.test.EnumValueDescriptorProto.name is populated. +// +// See [EnumValueDescriptorProto.GetString]. +func (x *EnumValueDescriptorProto) HasName() bool { + return x.unsafe().Has(0) +} + +// GetNumber extracts the value of hyperpb.test.EnumValueDescriptorProto.number. +// +// This definition is undocumented in the .proto file. +func (x *EnumValueDescriptorProto) GetNumber() int32 { + v := x.unsafe().GetInt32(1, 0) + return v +} + +// HasNumber checks whether hyperpb.test.EnumValueDescriptorProto.number is populated. +// +// See [EnumValueDescriptorProto.GetInt32]. +func (x *EnumValueDescriptorProto) HasNumber() bool { + return x.unsafe().Has(1) +} + +// GetOptions extracts the value of hyperpb.test.EnumValueDescriptorProto.options. +// +// This definition is undocumented in the .proto file. +func (x *EnumValueDescriptorProto) GetOptions() *EnumValueOptions { + v := x.unsafe().GetMessage(2) + return (*EnumValueOptions)(v) +} + +// HasOptions checks whether hyperpb.test.EnumValueDescriptorProto.options is populated. +// +// See [EnumValueDescriptorProto.GetMessage]. +func (x *EnumValueDescriptorProto) HasOptions() bool { + return x.unsafe().Has(2) +} + +// ProtoReflect implements proto.Message. +func (x *EnumValueDescriptorProto) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*EnumValueDescriptorProto) HyperMessage(export.DoNotImplement, *EnumValueDescriptorProto) {} + +func (x *EnumValueDescriptorProto) impl() *hyperpb.Message { + return (*hyperpb.Message)(unsafe.Pointer(x)) +} + +func (x *EnumValueDescriptorProto) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// ServiceDescriptorProto is undocumented in the .proto file. +type ServiceDescriptorProto struct{ _ hyperpb.Message } + +var tServiceDescriptorProto export.Type + +func init() { tServiceDescriptorProto.Init("hyperpb.test.ServiceDescriptorProto") } + +// NewServiceDescriptorProto allocates a new ServiceDescriptorProto. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(ServiceDescriptorProto) will not work. +func NewServiceDescriptorProto(s *hyperpb.Shared) *ServiceDescriptorProto { + m := s.NewMessage(tServiceDescriptorProto.Get()) + return (*ServiceDescriptorProto)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *ServiceDescriptorProto) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *ServiceDescriptorProto) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetName extracts the value of hyperpb.test.ServiceDescriptorProto.name. +// +// This definition is undocumented in the .proto file. +func (x *ServiceDescriptorProto) GetName() string { + v := x.unsafe().GetString(0, "") + return v +} + +// HasName checks whether hyperpb.test.ServiceDescriptorProto.name is populated. +// +// See [ServiceDescriptorProto.GetString]. +func (x *ServiceDescriptorProto) HasName() bool { + return x.unsafe().Has(0) +} + +// GetMethod extracts the value of hyperpb.test.ServiceDescriptorProto.method. +// +// This definition is undocumented in the .proto file. +func (x *ServiceDescriptorProto) GetMethod() hyperpb.List[*MethodDescriptorProto] { + v := x.unsafe().GetRepeatedMessage(1) + return export.CastRepeatedMessage[*MethodDescriptorProto](v) +} + +// GetOptions extracts the value of hyperpb.test.ServiceDescriptorProto.options. +// +// This definition is undocumented in the .proto file. +func (x *ServiceDescriptorProto) GetOptions() *ServiceOptions { + v := x.unsafe().GetMessage(2) + return (*ServiceOptions)(v) +} + +// HasOptions checks whether hyperpb.test.ServiceDescriptorProto.options is populated. +// +// See [ServiceDescriptorProto.GetMessage]. +func (x *ServiceDescriptorProto) HasOptions() bool { + return x.unsafe().Has(2) +} + +// ProtoReflect implements proto.Message. +func (x *ServiceDescriptorProto) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*ServiceDescriptorProto) HyperMessage(export.DoNotImplement, *ServiceDescriptorProto) {} + +func (x *ServiceDescriptorProto) impl() *hyperpb.Message { + return (*hyperpb.Message)(unsafe.Pointer(x)) +} + +func (x *ServiceDescriptorProto) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// MethodDescriptorProto is undocumented in the .proto file. +type MethodDescriptorProto struct{ _ hyperpb.Message } + +var tMethodDescriptorProto export.Type + +func init() { tMethodDescriptorProto.Init("hyperpb.test.MethodDescriptorProto") } + +// NewMethodDescriptorProto allocates a new MethodDescriptorProto. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(MethodDescriptorProto) will not work. +func NewMethodDescriptorProto(s *hyperpb.Shared) *MethodDescriptorProto { + m := s.NewMessage(tMethodDescriptorProto.Get()) + return (*MethodDescriptorProto)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *MethodDescriptorProto) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *MethodDescriptorProto) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetName extracts the value of hyperpb.test.MethodDescriptorProto.name. +// +// This definition is undocumented in the .proto file. +func (x *MethodDescriptorProto) GetName() string { + v := x.unsafe().GetString(0, "") + return v +} + +// HasName checks whether hyperpb.test.MethodDescriptorProto.name is populated. +// +// See [MethodDescriptorProto.GetString]. +func (x *MethodDescriptorProto) HasName() bool { + return x.unsafe().Has(0) +} + +// GetInputType extracts the value of hyperpb.test.MethodDescriptorProto.input_type. +// +// This definition is undocumented in the .proto file. +func (x *MethodDescriptorProto) GetInputType() string { + v := x.unsafe().GetString(1, "") + return v +} + +// HasInputType checks whether hyperpb.test.MethodDescriptorProto.input_type is populated. +// +// See [MethodDescriptorProto.GetString]. +func (x *MethodDescriptorProto) HasInputType() bool { + return x.unsafe().Has(1) +} + +// GetOutputType extracts the value of hyperpb.test.MethodDescriptorProto.output_type. +// +// This definition is undocumented in the .proto file. +func (x *MethodDescriptorProto) GetOutputType() string { + v := x.unsafe().GetString(2, "") + return v +} + +// HasOutputType checks whether hyperpb.test.MethodDescriptorProto.output_type is populated. +// +// See [MethodDescriptorProto.GetString]. +func (x *MethodDescriptorProto) HasOutputType() bool { + return x.unsafe().Has(2) +} + +// GetOptions extracts the value of hyperpb.test.MethodDescriptorProto.options. +// +// This definition is undocumented in the .proto file. +func (x *MethodDescriptorProto) GetOptions() *MethodOptions { + v := x.unsafe().GetMessage(3) + return (*MethodOptions)(v) +} + +// HasOptions checks whether hyperpb.test.MethodDescriptorProto.options is populated. +// +// See [MethodDescriptorProto.GetMessage]. +func (x *MethodDescriptorProto) HasOptions() bool { + return x.unsafe().Has(3) +} + +// GetClientStreaming extracts the value of hyperpb.test.MethodDescriptorProto.client_streaming. +// +// This definition is undocumented in the .proto file. +func (x *MethodDescriptorProto) GetClientStreaming() bool { + v := x.unsafe().GetBool(4, false) + return v +} + +// HasClientStreaming checks whether hyperpb.test.MethodDescriptorProto.client_streaming is populated. +// +// See [MethodDescriptorProto.GetBool]. +func (x *MethodDescriptorProto) HasClientStreaming() bool { + return x.unsafe().Has(4) +} + +// GetServerStreaming extracts the value of hyperpb.test.MethodDescriptorProto.server_streaming. +// +// This definition is undocumented in the .proto file. +func (x *MethodDescriptorProto) GetServerStreaming() bool { + v := x.unsafe().GetBool(5, false) + return v +} + +// HasServerStreaming checks whether hyperpb.test.MethodDescriptorProto.server_streaming is populated. +// +// See [MethodDescriptorProto.GetBool]. +func (x *MethodDescriptorProto) HasServerStreaming() bool { + return x.unsafe().Has(5) +} + +// ProtoReflect implements proto.Message. +func (x *MethodDescriptorProto) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*MethodDescriptorProto) HyperMessage(export.DoNotImplement, *MethodDescriptorProto) {} + +func (x *MethodDescriptorProto) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *MethodDescriptorProto) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// FileOptions is undocumented in the .proto file. +type FileOptions struct{ _ hyperpb.Message } + +var tFileOptions export.Type + +func init() { tFileOptions.Init("hyperpb.test.FileOptions") } + +// NewFileOptions allocates a new FileOptions. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(FileOptions) will not work. +func NewFileOptions(s *hyperpb.Shared) *FileOptions { + m := s.NewMessage(tFileOptions.Get()) + return (*FileOptions)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *FileOptions) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *FileOptions) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetJavaPackage extracts the value of hyperpb.test.FileOptions.java_package. +// +// This definition is undocumented in the .proto file. +func (x *FileOptions) GetJavaPackage() string { + v := x.unsafe().GetString(0, "") + return v +} + +// HasJavaPackage checks whether hyperpb.test.FileOptions.java_package is populated. +// +// See [FileOptions.GetString]. +func (x *FileOptions) HasJavaPackage() bool { + return x.unsafe().Has(0) +} + +// GetJavaOuterClassname extracts the value of hyperpb.test.FileOptions.java_outer_classname. +// +// This definition is undocumented in the .proto file. +func (x *FileOptions) GetJavaOuterClassname() string { + v := x.unsafe().GetString(1, "") + return v +} + +// HasJavaOuterClassname checks whether hyperpb.test.FileOptions.java_outer_classname is populated. +// +// See [FileOptions.GetString]. +func (x *FileOptions) HasJavaOuterClassname() bool { + return x.unsafe().Has(1) +} + +// GetJavaMultipleFiles extracts the value of hyperpb.test.FileOptions.java_multiple_files. +// +// This definition is undocumented in the .proto file. +func (x *FileOptions) GetJavaMultipleFiles() bool { + v := x.unsafe().GetBool(2, false) + return v +} + +// HasJavaMultipleFiles checks whether hyperpb.test.FileOptions.java_multiple_files is populated. +// +// See [FileOptions.GetBool]. +func (x *FileOptions) HasJavaMultipleFiles() bool { + return x.unsafe().Has(2) +} + +// GetJavaGenerateEqualsAndHash extracts the value of hyperpb.test.FileOptions.java_generate_equals_and_hash. +// +// This definition is undocumented in the .proto file. +func (x *FileOptions) GetJavaGenerateEqualsAndHash() bool { + v := x.unsafe().GetBool(3, false) + return v +} + +// HasJavaGenerateEqualsAndHash checks whether hyperpb.test.FileOptions.java_generate_equals_and_hash is populated. +// +// See [FileOptions.GetBool]. +func (x *FileOptions) HasJavaGenerateEqualsAndHash() bool { + return x.unsafe().Has(3) +} + +// GetJavaStringCheckUtf8 extracts the value of hyperpb.test.FileOptions.java_string_check_utf8. +// +// This definition is undocumented in the .proto file. +func (x *FileOptions) GetJavaStringCheckUtf8() bool { + v := x.unsafe().GetBool(4, false) + return v +} + +// HasJavaStringCheckUtf8 checks whether hyperpb.test.FileOptions.java_string_check_utf8 is populated. +// +// See [FileOptions.GetBool]. +func (x *FileOptions) HasJavaStringCheckUtf8() bool { + return x.unsafe().Has(4) +} + +// GetOptimizeFor extracts the value of hyperpb.test.FileOptions.optimize_for. +// +// This definition is undocumented in the .proto file. +func (x *FileOptions) GetOptimizeFor() test.FileOptions_OptimizeMode { + v := x.unsafe().GetEnum(5, 1) + return test.FileOptions_OptimizeMode(v) +} + +// HasOptimizeFor checks whether hyperpb.test.FileOptions.optimize_for is populated. +// +// See [FileOptions.GetEnum]. +func (x *FileOptions) HasOptimizeFor() bool { + return x.unsafe().Has(5) +} + +// GetGoPackage extracts the value of hyperpb.test.FileOptions.go_package. +// +// This definition is undocumented in the .proto file. +func (x *FileOptions) GetGoPackage() string { + v := x.unsafe().GetString(6, "") + return v +} + +// HasGoPackage checks whether hyperpb.test.FileOptions.go_package is populated. +// +// See [FileOptions.GetString]. +func (x *FileOptions) HasGoPackage() bool { + return x.unsafe().Has(6) +} + +// GetCcGenericServices extracts the value of hyperpb.test.FileOptions.cc_generic_services. +// +// This definition is undocumented in the .proto file. +func (x *FileOptions) GetCcGenericServices() bool { + v := x.unsafe().GetBool(7, false) + return v +} + +// HasCcGenericServices checks whether hyperpb.test.FileOptions.cc_generic_services is populated. +// +// See [FileOptions.GetBool]. +func (x *FileOptions) HasCcGenericServices() bool { + return x.unsafe().Has(7) +} + +// GetJavaGenericServices extracts the value of hyperpb.test.FileOptions.java_generic_services. +// +// This definition is undocumented in the .proto file. +func (x *FileOptions) GetJavaGenericServices() bool { + v := x.unsafe().GetBool(8, false) + return v +} + +// HasJavaGenericServices checks whether hyperpb.test.FileOptions.java_generic_services is populated. +// +// See [FileOptions.GetBool]. +func (x *FileOptions) HasJavaGenericServices() bool { + return x.unsafe().Has(8) +} + +// GetPyGenericServices extracts the value of hyperpb.test.FileOptions.py_generic_services. +// +// This definition is undocumented in the .proto file. +func (x *FileOptions) GetPyGenericServices() bool { + v := x.unsafe().GetBool(9, false) + return v +} + +// HasPyGenericServices checks whether hyperpb.test.FileOptions.py_generic_services is populated. +// +// See [FileOptions.GetBool]. +func (x *FileOptions) HasPyGenericServices() bool { + return x.unsafe().Has(9) +} + +// GetDeprecated extracts the value of hyperpb.test.FileOptions.deprecated. +// +// This definition is undocumented in the .proto file. +func (x *FileOptions) GetDeprecated() bool { + v := x.unsafe().GetBool(10, false) + return v +} + +// HasDeprecated checks whether hyperpb.test.FileOptions.deprecated is populated. +// +// See [FileOptions.GetBool]. +func (x *FileOptions) HasDeprecated() bool { + return x.unsafe().Has(10) +} + +// GetCcEnableArenas extracts the value of hyperpb.test.FileOptions.cc_enable_arenas. +// +// This definition is undocumented in the .proto file. +func (x *FileOptions) GetCcEnableArenas() bool { + v := x.unsafe().GetBool(11, true) + return v +} + +// HasCcEnableArenas checks whether hyperpb.test.FileOptions.cc_enable_arenas is populated. +// +// See [FileOptions.GetBool]. +func (x *FileOptions) HasCcEnableArenas() bool { + return x.unsafe().Has(11) +} + +// GetObjcClassPrefix extracts the value of hyperpb.test.FileOptions.objc_class_prefix. +// +// This definition is undocumented in the .proto file. +func (x *FileOptions) GetObjcClassPrefix() string { + v := x.unsafe().GetString(12, "") + return v +} + +// HasObjcClassPrefix checks whether hyperpb.test.FileOptions.objc_class_prefix is populated. +// +// See [FileOptions.GetString]. +func (x *FileOptions) HasObjcClassPrefix() bool { + return x.unsafe().Has(12) +} + +// GetCsharpNamespace extracts the value of hyperpb.test.FileOptions.csharp_namespace. +// +// This definition is undocumented in the .proto file. +func (x *FileOptions) GetCsharpNamespace() string { + v := x.unsafe().GetString(13, "") + return v +} + +// HasCsharpNamespace checks whether hyperpb.test.FileOptions.csharp_namespace is populated. +// +// See [FileOptions.GetString]. +func (x *FileOptions) HasCsharpNamespace() bool { + return x.unsafe().Has(13) +} + +// GetSwiftPrefix extracts the value of hyperpb.test.FileOptions.swift_prefix. +// +// This definition is undocumented in the .proto file. +func (x *FileOptions) GetSwiftPrefix() string { + v := x.unsafe().GetString(14, "") + return v +} + +// HasSwiftPrefix checks whether hyperpb.test.FileOptions.swift_prefix is populated. +// +// See [FileOptions.GetString]. +func (x *FileOptions) HasSwiftPrefix() bool { + return x.unsafe().Has(14) +} + +// GetPhpClassPrefix extracts the value of hyperpb.test.FileOptions.php_class_prefix. +// +// This definition is undocumented in the .proto file. +func (x *FileOptions) GetPhpClassPrefix() string { + v := x.unsafe().GetString(15, "") + return v +} + +// HasPhpClassPrefix checks whether hyperpb.test.FileOptions.php_class_prefix is populated. +// +// See [FileOptions.GetString]. +func (x *FileOptions) HasPhpClassPrefix() bool { + return x.unsafe().Has(15) +} + +// GetPhpNamespace extracts the value of hyperpb.test.FileOptions.php_namespace. +// +// This definition is undocumented in the .proto file. +func (x *FileOptions) GetPhpNamespace() string { + v := x.unsafe().GetString(16, "") + return v +} + +// HasPhpNamespace checks whether hyperpb.test.FileOptions.php_namespace is populated. +// +// See [FileOptions.GetString]. +func (x *FileOptions) HasPhpNamespace() bool { + return x.unsafe().Has(16) +} + +// GetPhpMetadataNamespace extracts the value of hyperpb.test.FileOptions.php_metadata_namespace. +// +// This definition is undocumented in the .proto file. +func (x *FileOptions) GetPhpMetadataNamespace() string { + v := x.unsafe().GetString(17, "") + return v +} + +// HasPhpMetadataNamespace checks whether hyperpb.test.FileOptions.php_metadata_namespace is populated. +// +// See [FileOptions.GetString]. +func (x *FileOptions) HasPhpMetadataNamespace() bool { + return x.unsafe().Has(17) +} + +// GetRubyPackage extracts the value of hyperpb.test.FileOptions.ruby_package. +// +// This definition is undocumented in the .proto file. +func (x *FileOptions) GetRubyPackage() string { + v := x.unsafe().GetString(18, "") + return v +} + +// HasRubyPackage checks whether hyperpb.test.FileOptions.ruby_package is populated. +// +// See [FileOptions.GetString]. +func (x *FileOptions) HasRubyPackage() bool { + return x.unsafe().Has(18) +} + +// GetFeatures extracts the value of hyperpb.test.FileOptions.features. +// +// This definition is undocumented in the .proto file. +func (x *FileOptions) GetFeatures() *FeatureSet { + v := x.unsafe().GetMessage(19) + return (*FeatureSet)(v) +} + +// HasFeatures checks whether hyperpb.test.FileOptions.features is populated. +// +// See [FileOptions.GetMessage]. +func (x *FileOptions) HasFeatures() bool { + return x.unsafe().Has(19) +} + +// GetUninterpretedOption extracts the value of hyperpb.test.FileOptions.uninterpreted_option. +// +// This definition is undocumented in the .proto file. +func (x *FileOptions) GetUninterpretedOption() hyperpb.List[*UninterpretedOption] { + v := x.unsafe().GetRepeatedMessage(20) + return export.CastRepeatedMessage[*UninterpretedOption](v) +} + +// ProtoReflect implements proto.Message. +func (x *FileOptions) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*FileOptions) HyperMessage(export.DoNotImplement, *FileOptions) {} + +func (x *FileOptions) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *FileOptions) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// MessageOptions is undocumented in the .proto file. +type MessageOptions struct{ _ hyperpb.Message } + +var tMessageOptions export.Type + +func init() { tMessageOptions.Init("hyperpb.test.MessageOptions") } + +// NewMessageOptions allocates a new MessageOptions. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(MessageOptions) will not work. +func NewMessageOptions(s *hyperpb.Shared) *MessageOptions { + m := s.NewMessage(tMessageOptions.Get()) + return (*MessageOptions)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *MessageOptions) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *MessageOptions) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetMessageSetWireFormat extracts the value of hyperpb.test.MessageOptions.message_set_wire_format. +// +// This definition is undocumented in the .proto file. +func (x *MessageOptions) GetMessageSetWireFormat() bool { + v := x.unsafe().GetBool(0, false) + return v +} + +// HasMessageSetWireFormat checks whether hyperpb.test.MessageOptions.message_set_wire_format is populated. +// +// See [MessageOptions.GetBool]. +func (x *MessageOptions) HasMessageSetWireFormat() bool { + return x.unsafe().Has(0) +} + +// GetNoStandardDescriptorAccessor extracts the value of hyperpb.test.MessageOptions.no_standard_descriptor_accessor. +// +// This definition is undocumented in the .proto file. +func (x *MessageOptions) GetNoStandardDescriptorAccessor() bool { + v := x.unsafe().GetBool(1, false) + return v +} + +// HasNoStandardDescriptorAccessor checks whether hyperpb.test.MessageOptions.no_standard_descriptor_accessor is populated. +// +// See [MessageOptions.GetBool]. +func (x *MessageOptions) HasNoStandardDescriptorAccessor() bool { + return x.unsafe().Has(1) +} + +// GetDeprecated extracts the value of hyperpb.test.MessageOptions.deprecated. +// +// This definition is undocumented in the .proto file. +func (x *MessageOptions) GetDeprecated() bool { + v := x.unsafe().GetBool(2, false) + return v +} + +// HasDeprecated checks whether hyperpb.test.MessageOptions.deprecated is populated. +// +// See [MessageOptions.GetBool]. +func (x *MessageOptions) HasDeprecated() bool { + return x.unsafe().Has(2) +} + +// GetMapEntry extracts the value of hyperpb.test.MessageOptions.map_entry. +// +// This definition is undocumented in the .proto file. +func (x *MessageOptions) GetMapEntry() bool { + v := x.unsafe().GetBool(3, false) + return v +} + +// HasMapEntry checks whether hyperpb.test.MessageOptions.map_entry is populated. +// +// See [MessageOptions.GetBool]. +func (x *MessageOptions) HasMapEntry() bool { + return x.unsafe().Has(3) +} + +// GetDeprecatedLegacyJsonFieldConflicts extracts the value of hyperpb.test.MessageOptions.deprecated_legacy_json_field_conflicts. +// +// This definition is undocumented in the .proto file. +func (x *MessageOptions) GetDeprecatedLegacyJsonFieldConflicts() bool { + v := x.unsafe().GetBool(4, false) + return v +} + +// HasDeprecatedLegacyJsonFieldConflicts checks whether hyperpb.test.MessageOptions.deprecated_legacy_json_field_conflicts is populated. +// +// See [MessageOptions.GetBool]. +func (x *MessageOptions) HasDeprecatedLegacyJsonFieldConflicts() bool { + return x.unsafe().Has(4) +} + +// GetFeatures extracts the value of hyperpb.test.MessageOptions.features. +// +// This definition is undocumented in the .proto file. +func (x *MessageOptions) GetFeatures() *FeatureSet { + v := x.unsafe().GetMessage(5) + return (*FeatureSet)(v) +} + +// HasFeatures checks whether hyperpb.test.MessageOptions.features is populated. +// +// See [MessageOptions.GetMessage]. +func (x *MessageOptions) HasFeatures() bool { + return x.unsafe().Has(5) +} + +// GetUninterpretedOption extracts the value of hyperpb.test.MessageOptions.uninterpreted_option. +// +// This definition is undocumented in the .proto file. +func (x *MessageOptions) GetUninterpretedOption() hyperpb.List[*UninterpretedOption] { + v := x.unsafe().GetRepeatedMessage(6) + return export.CastRepeatedMessage[*UninterpretedOption](v) +} + +// ProtoReflect implements proto.Message. +func (x *MessageOptions) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*MessageOptions) HyperMessage(export.DoNotImplement, *MessageOptions) {} + +func (x *MessageOptions) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *MessageOptions) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// FieldOptions is undocumented in the .proto file. +type FieldOptions struct{ _ hyperpb.Message } + +var tFieldOptions export.Type + +func init() { tFieldOptions.Init("hyperpb.test.FieldOptions") } + +// NewFieldOptions allocates a new FieldOptions. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(FieldOptions) will not work. +func NewFieldOptions(s *hyperpb.Shared) *FieldOptions { + m := s.NewMessage(tFieldOptions.Get()) + return (*FieldOptions)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *FieldOptions) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *FieldOptions) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetCtype extracts the value of hyperpb.test.FieldOptions.ctype. +// +// This definition is undocumented in the .proto file. +func (x *FieldOptions) GetCtype() test.FieldOptions_CType { + v := x.unsafe().GetEnum(0, 0) + return test.FieldOptions_CType(v) +} + +// HasCtype checks whether hyperpb.test.FieldOptions.ctype is populated. +// +// See [FieldOptions.GetEnum]. +func (x *FieldOptions) HasCtype() bool { + return x.unsafe().Has(0) +} + +// GetPacked extracts the value of hyperpb.test.FieldOptions.packed. +// +// This definition is undocumented in the .proto file. +func (x *FieldOptions) GetPacked() bool { + v := x.unsafe().GetBool(1, false) + return v +} + +// HasPacked checks whether hyperpb.test.FieldOptions.packed is populated. +// +// See [FieldOptions.GetBool]. +func (x *FieldOptions) HasPacked() bool { + return x.unsafe().Has(1) +} + +// GetJstype extracts the value of hyperpb.test.FieldOptions.jstype. +// +// This definition is undocumented in the .proto file. +func (x *FieldOptions) GetJstype() test.FieldOptions_JSType { + v := x.unsafe().GetEnum(2, 0) + return test.FieldOptions_JSType(v) +} + +// HasJstype checks whether hyperpb.test.FieldOptions.jstype is populated. +// +// See [FieldOptions.GetEnum]. +func (x *FieldOptions) HasJstype() bool { + return x.unsafe().Has(2) +} + +// GetLazy extracts the value of hyperpb.test.FieldOptions.lazy. +// +// This definition is undocumented in the .proto file. +func (x *FieldOptions) GetLazy() bool { + v := x.unsafe().GetBool(3, false) + return v +} + +// HasLazy checks whether hyperpb.test.FieldOptions.lazy is populated. +// +// See [FieldOptions.GetBool]. +func (x *FieldOptions) HasLazy() bool { + return x.unsafe().Has(3) +} + +// GetUnverifiedLazy extracts the value of hyperpb.test.FieldOptions.unverified_lazy. +// +// This definition is undocumented in the .proto file. +func (x *FieldOptions) GetUnverifiedLazy() bool { + v := x.unsafe().GetBool(4, false) + return v +} + +// HasUnverifiedLazy checks whether hyperpb.test.FieldOptions.unverified_lazy is populated. +// +// See [FieldOptions.GetBool]. +func (x *FieldOptions) HasUnverifiedLazy() bool { + return x.unsafe().Has(4) +} + +// GetDeprecated extracts the value of hyperpb.test.FieldOptions.deprecated. +// +// This definition is undocumented in the .proto file. +func (x *FieldOptions) GetDeprecated() bool { + v := x.unsafe().GetBool(5, false) + return v +} + +// HasDeprecated checks whether hyperpb.test.FieldOptions.deprecated is populated. +// +// See [FieldOptions.GetBool]. +func (x *FieldOptions) HasDeprecated() bool { + return x.unsafe().Has(5) +} + +// GetWeak extracts the value of hyperpb.test.FieldOptions.weak. +// +// This definition is undocumented in the .proto file. +func (x *FieldOptions) GetWeak() bool { + v := x.unsafe().GetBool(6, false) + return v +} + +// HasWeak checks whether hyperpb.test.FieldOptions.weak is populated. +// +// See [FieldOptions.GetBool]. +func (x *FieldOptions) HasWeak() bool { + return x.unsafe().Has(6) +} + +// GetDebugRedact extracts the value of hyperpb.test.FieldOptions.debug_redact. +// +// This definition is undocumented in the .proto file. +func (x *FieldOptions) GetDebugRedact() bool { + v := x.unsafe().GetBool(7, false) + return v +} + +// HasDebugRedact checks whether hyperpb.test.FieldOptions.debug_redact is populated. +// +// See [FieldOptions.GetBool]. +func (x *FieldOptions) HasDebugRedact() bool { + return x.unsafe().Has(7) +} + +// GetRetention extracts the value of hyperpb.test.FieldOptions.retention. +// +// This definition is undocumented in the .proto file. +func (x *FieldOptions) GetRetention() test.FieldOptions_OptionRetention { + v := x.unsafe().GetEnum(8, 0) + return test.FieldOptions_OptionRetention(v) +} + +// HasRetention checks whether hyperpb.test.FieldOptions.retention is populated. +// +// See [FieldOptions.GetEnum]. +func (x *FieldOptions) HasRetention() bool { + return x.unsafe().Has(8) +} + +// GetTargets extracts the value of hyperpb.test.FieldOptions.targets. +// +// This definition is undocumented in the .proto file. +func (x *FieldOptions) GetTargets() hyperpb.List[test.FieldOptions_OptionTargetType] { + v := x.unsafe().GetRepeatedEnum(9) + return export.CastRepeatedEnum[test.FieldOptions_OptionTargetType](v) +} + +// GetEditionDefaults extracts the value of hyperpb.test.FieldOptions.edition_defaults. +// +// This definition is undocumented in the .proto file. +func (x *FieldOptions) GetEditionDefaults() hyperpb.List[*FieldOptions_EditionDefault] { + v := x.unsafe().GetRepeatedMessage(10) + return export.CastRepeatedMessage[*FieldOptions_EditionDefault](v) +} + +// GetFeatures extracts the value of hyperpb.test.FieldOptions.features. +// +// This definition is undocumented in the .proto file. +func (x *FieldOptions) GetFeatures() *FeatureSet { + v := x.unsafe().GetMessage(11) + return (*FeatureSet)(v) +} + +// HasFeatures checks whether hyperpb.test.FieldOptions.features is populated. +// +// See [FieldOptions.GetMessage]. +func (x *FieldOptions) HasFeatures() bool { + return x.unsafe().Has(11) +} + +// GetFeatureSupport extracts the value of hyperpb.test.FieldOptions.feature_support. +// +// This definition is undocumented in the .proto file. +func (x *FieldOptions) GetFeatureSupport() *FieldOptions_FeatureSupport { + v := x.unsafe().GetMessage(12) + return (*FieldOptions_FeatureSupport)(v) +} + +// HasFeatureSupport checks whether hyperpb.test.FieldOptions.feature_support is populated. +// +// See [FieldOptions.GetMessage]. +func (x *FieldOptions) HasFeatureSupport() bool { + return x.unsafe().Has(12) +} + +// GetUninterpretedOption extracts the value of hyperpb.test.FieldOptions.uninterpreted_option. +// +// This definition is undocumented in the .proto file. +func (x *FieldOptions) GetUninterpretedOption() hyperpb.List[*UninterpretedOption] { + v := x.unsafe().GetRepeatedMessage(13) + return export.CastRepeatedMessage[*UninterpretedOption](v) +} + +// ProtoReflect implements proto.Message. +func (x *FieldOptions) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*FieldOptions) HyperMessage(export.DoNotImplement, *FieldOptions) {} + +func (x *FieldOptions) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *FieldOptions) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// FieldOptions_EditionDefault is undocumented in the .proto file. +type FieldOptions_EditionDefault struct{ _ hyperpb.Message } + +var tFieldOptions_EditionDefault export.Type + +func init() { tFieldOptions_EditionDefault.Init("hyperpb.test.FieldOptions.EditionDefault") } + +// NewFieldOptions_EditionDefault allocates a new FieldOptions_EditionDefault. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(FieldOptions_EditionDefault) will not work. +func NewFieldOptions_EditionDefault(s *hyperpb.Shared) *FieldOptions_EditionDefault { + m := s.NewMessage(tFieldOptions_EditionDefault.Get()) + return (*FieldOptions_EditionDefault)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *FieldOptions_EditionDefault) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *FieldOptions_EditionDefault) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetEdition extracts the value of hyperpb.test.FieldOptions.EditionDefault.edition. +// +// This definition is undocumented in the .proto file. +func (x *FieldOptions_EditionDefault) GetEdition() test.Edition { + v := x.unsafe().GetEnum(0, 0) + return test.Edition(v) +} + +// HasEdition checks whether hyperpb.test.FieldOptions.EditionDefault.edition is populated. +// +// See [FieldOptions_EditionDefault.GetEnum]. +func (x *FieldOptions_EditionDefault) HasEdition() bool { + return x.unsafe().Has(0) +} + +// GetValue extracts the value of hyperpb.test.FieldOptions.EditionDefault.value. +// +// This definition is undocumented in the .proto file. +func (x *FieldOptions_EditionDefault) GetValue() string { + v := x.unsafe().GetString(1, "") + return v +} + +// HasValue checks whether hyperpb.test.FieldOptions.EditionDefault.value is populated. +// +// See [FieldOptions_EditionDefault.GetString]. +func (x *FieldOptions_EditionDefault) HasValue() bool { + return x.unsafe().Has(1) +} + +// ProtoReflect implements proto.Message. +func (x *FieldOptions_EditionDefault) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*FieldOptions_EditionDefault) HyperMessage(export.DoNotImplement, *FieldOptions_EditionDefault) { +} + +func (x *FieldOptions_EditionDefault) impl() *hyperpb.Message { + return (*hyperpb.Message)(unsafe.Pointer(x)) +} + +func (x *FieldOptions_EditionDefault) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// FieldOptions_FeatureSupport is undocumented in the .proto file. +type FieldOptions_FeatureSupport struct{ _ hyperpb.Message } + +var tFieldOptions_FeatureSupport export.Type + +func init() { tFieldOptions_FeatureSupport.Init("hyperpb.test.FieldOptions.FeatureSupport") } + +// NewFieldOptions_FeatureSupport allocates a new FieldOptions_FeatureSupport. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(FieldOptions_FeatureSupport) will not work. +func NewFieldOptions_FeatureSupport(s *hyperpb.Shared) *FieldOptions_FeatureSupport { + m := s.NewMessage(tFieldOptions_FeatureSupport.Get()) + return (*FieldOptions_FeatureSupport)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *FieldOptions_FeatureSupport) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *FieldOptions_FeatureSupport) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetEditionIntroduced extracts the value of hyperpb.test.FieldOptions.FeatureSupport.edition_introduced. +// +// This definition is undocumented in the .proto file. +func (x *FieldOptions_FeatureSupport) GetEditionIntroduced() test.Edition { + v := x.unsafe().GetEnum(0, 0) + return test.Edition(v) +} + +// HasEditionIntroduced checks whether hyperpb.test.FieldOptions.FeatureSupport.edition_introduced is populated. +// +// See [FieldOptions_FeatureSupport.GetEnum]. +func (x *FieldOptions_FeatureSupport) HasEditionIntroduced() bool { + return x.unsafe().Has(0) +} + +// GetEditionDeprecated extracts the value of hyperpb.test.FieldOptions.FeatureSupport.edition_deprecated. +// +// This definition is undocumented in the .proto file. +func (x *FieldOptions_FeatureSupport) GetEditionDeprecated() test.Edition { + v := x.unsafe().GetEnum(1, 0) + return test.Edition(v) +} + +// HasEditionDeprecated checks whether hyperpb.test.FieldOptions.FeatureSupport.edition_deprecated is populated. +// +// See [FieldOptions_FeatureSupport.GetEnum]. +func (x *FieldOptions_FeatureSupport) HasEditionDeprecated() bool { + return x.unsafe().Has(1) +} + +// GetDeprecationWarning extracts the value of hyperpb.test.FieldOptions.FeatureSupport.deprecation_warning. +// +// This definition is undocumented in the .proto file. +func (x *FieldOptions_FeatureSupport) GetDeprecationWarning() string { + v := x.unsafe().GetString(2, "") + return v +} + +// HasDeprecationWarning checks whether hyperpb.test.FieldOptions.FeatureSupport.deprecation_warning is populated. +// +// See [FieldOptions_FeatureSupport.GetString]. +func (x *FieldOptions_FeatureSupport) HasDeprecationWarning() bool { + return x.unsafe().Has(2) +} + +// GetEditionRemoved extracts the value of hyperpb.test.FieldOptions.FeatureSupport.edition_removed. +// +// This definition is undocumented in the .proto file. +func (x *FieldOptions_FeatureSupport) GetEditionRemoved() test.Edition { + v := x.unsafe().GetEnum(3, 0) + return test.Edition(v) +} + +// HasEditionRemoved checks whether hyperpb.test.FieldOptions.FeatureSupport.edition_removed is populated. +// +// See [FieldOptions_FeatureSupport.GetEnum]. +func (x *FieldOptions_FeatureSupport) HasEditionRemoved() bool { + return x.unsafe().Has(3) +} + +// ProtoReflect implements proto.Message. +func (x *FieldOptions_FeatureSupport) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*FieldOptions_FeatureSupport) HyperMessage(export.DoNotImplement, *FieldOptions_FeatureSupport) { +} + +func (x *FieldOptions_FeatureSupport) impl() *hyperpb.Message { + return (*hyperpb.Message)(unsafe.Pointer(x)) +} + +func (x *FieldOptions_FeatureSupport) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// OneofOptions is undocumented in the .proto file. +type OneofOptions struct{ _ hyperpb.Message } + +var tOneofOptions export.Type + +func init() { tOneofOptions.Init("hyperpb.test.OneofOptions") } + +// NewOneofOptions allocates a new OneofOptions. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(OneofOptions) will not work. +func NewOneofOptions(s *hyperpb.Shared) *OneofOptions { + m := s.NewMessage(tOneofOptions.Get()) + return (*OneofOptions)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *OneofOptions) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *OneofOptions) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetFeatures extracts the value of hyperpb.test.OneofOptions.features. +// +// This definition is undocumented in the .proto file. +func (x *OneofOptions) GetFeatures() *FeatureSet { + v := x.unsafe().GetMessage(0) + return (*FeatureSet)(v) +} + +// HasFeatures checks whether hyperpb.test.OneofOptions.features is populated. +// +// See [OneofOptions.GetMessage]. +func (x *OneofOptions) HasFeatures() bool { + return x.unsafe().Has(0) +} + +// GetUninterpretedOption extracts the value of hyperpb.test.OneofOptions.uninterpreted_option. +// +// This definition is undocumented in the .proto file. +func (x *OneofOptions) GetUninterpretedOption() hyperpb.List[*UninterpretedOption] { + v := x.unsafe().GetRepeatedMessage(1) + return export.CastRepeatedMessage[*UninterpretedOption](v) +} + +// ProtoReflect implements proto.Message. +func (x *OneofOptions) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*OneofOptions) HyperMessage(export.DoNotImplement, *OneofOptions) {} + +func (x *OneofOptions) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *OneofOptions) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// EnumOptions is undocumented in the .proto file. +type EnumOptions struct{ _ hyperpb.Message } + +var tEnumOptions export.Type + +func init() { tEnumOptions.Init("hyperpb.test.EnumOptions") } + +// NewEnumOptions allocates a new EnumOptions. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(EnumOptions) will not work. +func NewEnumOptions(s *hyperpb.Shared) *EnumOptions { + m := s.NewMessage(tEnumOptions.Get()) + return (*EnumOptions)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *EnumOptions) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *EnumOptions) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetAllowAlias extracts the value of hyperpb.test.EnumOptions.allow_alias. +// +// This definition is undocumented in the .proto file. +func (x *EnumOptions) GetAllowAlias() bool { + v := x.unsafe().GetBool(0, false) + return v +} + +// HasAllowAlias checks whether hyperpb.test.EnumOptions.allow_alias is populated. +// +// See [EnumOptions.GetBool]. +func (x *EnumOptions) HasAllowAlias() bool { + return x.unsafe().Has(0) +} + +// GetDeprecated extracts the value of hyperpb.test.EnumOptions.deprecated. +// +// This definition is undocumented in the .proto file. +func (x *EnumOptions) GetDeprecated() bool { + v := x.unsafe().GetBool(1, false) + return v +} + +// HasDeprecated checks whether hyperpb.test.EnumOptions.deprecated is populated. +// +// See [EnumOptions.GetBool]. +func (x *EnumOptions) HasDeprecated() bool { + return x.unsafe().Has(1) +} + +// GetDeprecatedLegacyJsonFieldConflicts extracts the value of hyperpb.test.EnumOptions.deprecated_legacy_json_field_conflicts. +// +// This definition is undocumented in the .proto file. +func (x *EnumOptions) GetDeprecatedLegacyJsonFieldConflicts() bool { + v := x.unsafe().GetBool(2, false) + return v +} + +// HasDeprecatedLegacyJsonFieldConflicts checks whether hyperpb.test.EnumOptions.deprecated_legacy_json_field_conflicts is populated. +// +// See [EnumOptions.GetBool]. +func (x *EnumOptions) HasDeprecatedLegacyJsonFieldConflicts() bool { + return x.unsafe().Has(2) +} + +// GetFeatures extracts the value of hyperpb.test.EnumOptions.features. +// +// This definition is undocumented in the .proto file. +func (x *EnumOptions) GetFeatures() *FeatureSet { + v := x.unsafe().GetMessage(3) + return (*FeatureSet)(v) +} + +// HasFeatures checks whether hyperpb.test.EnumOptions.features is populated. +// +// See [EnumOptions.GetMessage]. +func (x *EnumOptions) HasFeatures() bool { + return x.unsafe().Has(3) +} + +// GetUninterpretedOption extracts the value of hyperpb.test.EnumOptions.uninterpreted_option. +// +// This definition is undocumented in the .proto file. +func (x *EnumOptions) GetUninterpretedOption() hyperpb.List[*UninterpretedOption] { + v := x.unsafe().GetRepeatedMessage(4) + return export.CastRepeatedMessage[*UninterpretedOption](v) +} + +// ProtoReflect implements proto.Message. +func (x *EnumOptions) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*EnumOptions) HyperMessage(export.DoNotImplement, *EnumOptions) {} + +func (x *EnumOptions) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *EnumOptions) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// EnumValueOptions is undocumented in the .proto file. +type EnumValueOptions struct{ _ hyperpb.Message } + +var tEnumValueOptions export.Type + +func init() { tEnumValueOptions.Init("hyperpb.test.EnumValueOptions") } + +// NewEnumValueOptions allocates a new EnumValueOptions. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(EnumValueOptions) will not work. +func NewEnumValueOptions(s *hyperpb.Shared) *EnumValueOptions { + m := s.NewMessage(tEnumValueOptions.Get()) + return (*EnumValueOptions)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *EnumValueOptions) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *EnumValueOptions) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetDeprecated extracts the value of hyperpb.test.EnumValueOptions.deprecated. +// +// This definition is undocumented in the .proto file. +func (x *EnumValueOptions) GetDeprecated() bool { + v := x.unsafe().GetBool(0, false) + return v +} + +// HasDeprecated checks whether hyperpb.test.EnumValueOptions.deprecated is populated. +// +// See [EnumValueOptions.GetBool]. +func (x *EnumValueOptions) HasDeprecated() bool { + return x.unsafe().Has(0) +} + +// GetFeatures extracts the value of hyperpb.test.EnumValueOptions.features. +// +// This definition is undocumented in the .proto file. +func (x *EnumValueOptions) GetFeatures() *FeatureSet { + v := x.unsafe().GetMessage(1) + return (*FeatureSet)(v) +} + +// HasFeatures checks whether hyperpb.test.EnumValueOptions.features is populated. +// +// See [EnumValueOptions.GetMessage]. +func (x *EnumValueOptions) HasFeatures() bool { + return x.unsafe().Has(1) +} + +// GetDebugRedact extracts the value of hyperpb.test.EnumValueOptions.debug_redact. +// +// This definition is undocumented in the .proto file. +func (x *EnumValueOptions) GetDebugRedact() bool { + v := x.unsafe().GetBool(2, false) + return v +} + +// HasDebugRedact checks whether hyperpb.test.EnumValueOptions.debug_redact is populated. +// +// See [EnumValueOptions.GetBool]. +func (x *EnumValueOptions) HasDebugRedact() bool { + return x.unsafe().Has(2) +} + +// GetFeatureSupport extracts the value of hyperpb.test.EnumValueOptions.feature_support. +// +// This definition is undocumented in the .proto file. +func (x *EnumValueOptions) GetFeatureSupport() *FieldOptions_FeatureSupport { + v := x.unsafe().GetMessage(3) + return (*FieldOptions_FeatureSupport)(v) +} + +// HasFeatureSupport checks whether hyperpb.test.EnumValueOptions.feature_support is populated. +// +// See [EnumValueOptions.GetMessage]. +func (x *EnumValueOptions) HasFeatureSupport() bool { + return x.unsafe().Has(3) +} + +// GetUninterpretedOption extracts the value of hyperpb.test.EnumValueOptions.uninterpreted_option. +// +// This definition is undocumented in the .proto file. +func (x *EnumValueOptions) GetUninterpretedOption() hyperpb.List[*UninterpretedOption] { + v := x.unsafe().GetRepeatedMessage(4) + return export.CastRepeatedMessage[*UninterpretedOption](v) +} + +// ProtoReflect implements proto.Message. +func (x *EnumValueOptions) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*EnumValueOptions) HyperMessage(export.DoNotImplement, *EnumValueOptions) {} + +func (x *EnumValueOptions) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *EnumValueOptions) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// ServiceOptions is undocumented in the .proto file. +type ServiceOptions struct{ _ hyperpb.Message } + +var tServiceOptions export.Type + +func init() { tServiceOptions.Init("hyperpb.test.ServiceOptions") } + +// NewServiceOptions allocates a new ServiceOptions. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(ServiceOptions) will not work. +func NewServiceOptions(s *hyperpb.Shared) *ServiceOptions { + m := s.NewMessage(tServiceOptions.Get()) + return (*ServiceOptions)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *ServiceOptions) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *ServiceOptions) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetFeatures extracts the value of hyperpb.test.ServiceOptions.features. +// +// This definition is undocumented in the .proto file. +func (x *ServiceOptions) GetFeatures() *FeatureSet { + v := x.unsafe().GetMessage(0) + return (*FeatureSet)(v) +} + +// HasFeatures checks whether hyperpb.test.ServiceOptions.features is populated. +// +// See [ServiceOptions.GetMessage]. +func (x *ServiceOptions) HasFeatures() bool { + return x.unsafe().Has(0) +} + +// GetDeprecated extracts the value of hyperpb.test.ServiceOptions.deprecated. +// +// This definition is undocumented in the .proto file. +func (x *ServiceOptions) GetDeprecated() bool { + v := x.unsafe().GetBool(1, false) + return v +} + +// HasDeprecated checks whether hyperpb.test.ServiceOptions.deprecated is populated. +// +// See [ServiceOptions.GetBool]. +func (x *ServiceOptions) HasDeprecated() bool { + return x.unsafe().Has(1) +} + +// GetUninterpretedOption extracts the value of hyperpb.test.ServiceOptions.uninterpreted_option. +// +// This definition is undocumented in the .proto file. +func (x *ServiceOptions) GetUninterpretedOption() hyperpb.List[*UninterpretedOption] { + v := x.unsafe().GetRepeatedMessage(2) + return export.CastRepeatedMessage[*UninterpretedOption](v) +} + +// ProtoReflect implements proto.Message. +func (x *ServiceOptions) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*ServiceOptions) HyperMessage(export.DoNotImplement, *ServiceOptions) {} + +func (x *ServiceOptions) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *ServiceOptions) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// MethodOptions is undocumented in the .proto file. +type MethodOptions struct{ _ hyperpb.Message } + +var tMethodOptions export.Type + +func init() { tMethodOptions.Init("hyperpb.test.MethodOptions") } + +// NewMethodOptions allocates a new MethodOptions. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(MethodOptions) will not work. +func NewMethodOptions(s *hyperpb.Shared) *MethodOptions { + m := s.NewMessage(tMethodOptions.Get()) + return (*MethodOptions)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *MethodOptions) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *MethodOptions) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetDeprecated extracts the value of hyperpb.test.MethodOptions.deprecated. +// +// This definition is undocumented in the .proto file. +func (x *MethodOptions) GetDeprecated() bool { + v := x.unsafe().GetBool(0, false) + return v +} + +// HasDeprecated checks whether hyperpb.test.MethodOptions.deprecated is populated. +// +// See [MethodOptions.GetBool]. +func (x *MethodOptions) HasDeprecated() bool { + return x.unsafe().Has(0) +} + +// GetIdempotencyLevel extracts the value of hyperpb.test.MethodOptions.idempotency_level. +// +// This definition is undocumented in the .proto file. +func (x *MethodOptions) GetIdempotencyLevel() test.MethodOptions_IdempotencyLevel { + v := x.unsafe().GetEnum(1, 0) + return test.MethodOptions_IdempotencyLevel(v) +} + +// HasIdempotencyLevel checks whether hyperpb.test.MethodOptions.idempotency_level is populated. +// +// See [MethodOptions.GetEnum]. +func (x *MethodOptions) HasIdempotencyLevel() bool { + return x.unsafe().Has(1) +} + +// GetFeatures extracts the value of hyperpb.test.MethodOptions.features. +// +// This definition is undocumented in the .proto file. +func (x *MethodOptions) GetFeatures() *FeatureSet { + v := x.unsafe().GetMessage(2) + return (*FeatureSet)(v) +} + +// HasFeatures checks whether hyperpb.test.MethodOptions.features is populated. +// +// See [MethodOptions.GetMessage]. +func (x *MethodOptions) HasFeatures() bool { + return x.unsafe().Has(2) +} + +// GetUninterpretedOption extracts the value of hyperpb.test.MethodOptions.uninterpreted_option. +// +// This definition is undocumented in the .proto file. +func (x *MethodOptions) GetUninterpretedOption() hyperpb.List[*UninterpretedOption] { + v := x.unsafe().GetRepeatedMessage(3) + return export.CastRepeatedMessage[*UninterpretedOption](v) +} + +// ProtoReflect implements proto.Message. +func (x *MethodOptions) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*MethodOptions) HyperMessage(export.DoNotImplement, *MethodOptions) {} + +func (x *MethodOptions) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *MethodOptions) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// UninterpretedOption is undocumented in the .proto file. +type UninterpretedOption struct{ _ hyperpb.Message } + +var tUninterpretedOption export.Type + +func init() { tUninterpretedOption.Init("hyperpb.test.UninterpretedOption") } + +// NewUninterpretedOption allocates a new UninterpretedOption. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(UninterpretedOption) will not work. +func NewUninterpretedOption(s *hyperpb.Shared) *UninterpretedOption { + m := s.NewMessage(tUninterpretedOption.Get()) + return (*UninterpretedOption)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *UninterpretedOption) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *UninterpretedOption) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetName extracts the value of hyperpb.test.UninterpretedOption.name. +// +// This definition is undocumented in the .proto file. +func (x *UninterpretedOption) GetName() hyperpb.List[*UninterpretedOption_NamePart] { + v := x.unsafe().GetRepeatedMessage(0) + return export.CastRepeatedMessage[*UninterpretedOption_NamePart](v) +} + +// GetIdentifierValue extracts the value of hyperpb.test.UninterpretedOption.identifier_value. +// +// This definition is undocumented in the .proto file. +func (x *UninterpretedOption) GetIdentifierValue() string { + v := x.unsafe().GetString(1, "") + return v +} + +// HasIdentifierValue checks whether hyperpb.test.UninterpretedOption.identifier_value is populated. +// +// See [UninterpretedOption.GetString]. +func (x *UninterpretedOption) HasIdentifierValue() bool { + return x.unsafe().Has(1) +} + +// GetPositiveIntValue extracts the value of hyperpb.test.UninterpretedOption.positive_int_value. +// +// This definition is undocumented in the .proto file. +func (x *UninterpretedOption) GetPositiveIntValue() uint64 { + v := x.unsafe().GetUint64(2, 0) + return v +} + +// HasPositiveIntValue checks whether hyperpb.test.UninterpretedOption.positive_int_value is populated. +// +// See [UninterpretedOption.GetUint64]. +func (x *UninterpretedOption) HasPositiveIntValue() bool { + return x.unsafe().Has(2) +} + +// GetNegativeIntValue extracts the value of hyperpb.test.UninterpretedOption.negative_int_value. +// +// This definition is undocumented in the .proto file. +func (x *UninterpretedOption) GetNegativeIntValue() int64 { + v := x.unsafe().GetInt64(3, 0) + return v +} + +// HasNegativeIntValue checks whether hyperpb.test.UninterpretedOption.negative_int_value is populated. +// +// See [UninterpretedOption.GetInt64]. +func (x *UninterpretedOption) HasNegativeIntValue() bool { + return x.unsafe().Has(3) +} + +// GetDoubleValue extracts the value of hyperpb.test.UninterpretedOption.double_value. +// +// This definition is undocumented in the .proto file. +func (x *UninterpretedOption) GetDoubleValue() float64 { + v := x.unsafe().GetFloat64(4, math.Float64frombits(0x0)) + return v +} + +// HasDoubleValue checks whether hyperpb.test.UninterpretedOption.double_value is populated. +// +// See [UninterpretedOption.GetFloat64]. +func (x *UninterpretedOption) HasDoubleValue() bool { + return x.unsafe().Has(4) +} + +// GetStringValue extracts the value of hyperpb.test.UninterpretedOption.string_value. +// +// This definition is undocumented in the .proto file. +func (x *UninterpretedOption) GetStringValue() []byte { + v := x.unsafe().GetBytes(5, "") + return v +} + +// HasStringValue checks whether hyperpb.test.UninterpretedOption.string_value is populated. +// +// See [UninterpretedOption.GetBytes]. +func (x *UninterpretedOption) HasStringValue() bool { + return x.unsafe().Has(5) +} + +// GetAggregateValue extracts the value of hyperpb.test.UninterpretedOption.aggregate_value. +// +// This definition is undocumented in the .proto file. +func (x *UninterpretedOption) GetAggregateValue() string { + v := x.unsafe().GetString(6, "") + return v +} + +// HasAggregateValue checks whether hyperpb.test.UninterpretedOption.aggregate_value is populated. +// +// See [UninterpretedOption.GetString]. +func (x *UninterpretedOption) HasAggregateValue() bool { + return x.unsafe().Has(6) +} + +// ProtoReflect implements proto.Message. +func (x *UninterpretedOption) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*UninterpretedOption) HyperMessage(export.DoNotImplement, *UninterpretedOption) {} + +func (x *UninterpretedOption) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *UninterpretedOption) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// UninterpretedOption_NamePart is undocumented in the .proto file. +type UninterpretedOption_NamePart struct{ _ hyperpb.Message } + +var tUninterpretedOption_NamePart export.Type + +func init() { tUninterpretedOption_NamePart.Init("hyperpb.test.UninterpretedOption.NamePart") } + +// NewUninterpretedOption_NamePart allocates a new UninterpretedOption_NamePart. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(UninterpretedOption_NamePart) will not work. +func NewUninterpretedOption_NamePart(s *hyperpb.Shared) *UninterpretedOption_NamePart { + m := s.NewMessage(tUninterpretedOption_NamePart.Get()) + return (*UninterpretedOption_NamePart)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *UninterpretedOption_NamePart) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *UninterpretedOption_NamePart) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetNamePart extracts the value of hyperpb.test.UninterpretedOption.NamePart.name_part. +// +// This definition is undocumented in the .proto file. +func (x *UninterpretedOption_NamePart) GetNamePart() string { + v := x.unsafe().GetString(0, "") + return v +} + +// GetIsExtension extracts the value of hyperpb.test.UninterpretedOption.NamePart.is_extension. +// +// This definition is undocumented in the .proto file. +func (x *UninterpretedOption_NamePart) GetIsExtension() bool { + v := x.unsafe().GetBool(1, false) + return v +} + +// ProtoReflect implements proto.Message. +func (x *UninterpretedOption_NamePart) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*UninterpretedOption_NamePart) HyperMessage(export.DoNotImplement, *UninterpretedOption_NamePart) { +} + +func (x *UninterpretedOption_NamePart) impl() *hyperpb.Message { + return (*hyperpb.Message)(unsafe.Pointer(x)) +} + +func (x *UninterpretedOption_NamePart) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// FeatureSet is undocumented in the .proto file. +type FeatureSet struct{ _ hyperpb.Message } + +var tFeatureSet export.Type + +func init() { tFeatureSet.Init("hyperpb.test.FeatureSet") } + +// NewFeatureSet allocates a new FeatureSet. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(FeatureSet) will not work. +func NewFeatureSet(s *hyperpb.Shared) *FeatureSet { + m := s.NewMessage(tFeatureSet.Get()) + return (*FeatureSet)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *FeatureSet) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *FeatureSet) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetFieldPresence extracts the value of hyperpb.test.FeatureSet.field_presence. +// +// This definition is undocumented in the .proto file. +func (x *FeatureSet) GetFieldPresence() test.FeatureSet_FieldPresence { + v := x.unsafe().GetEnum(0, 0) + return test.FeatureSet_FieldPresence(v) +} + +// HasFieldPresence checks whether hyperpb.test.FeatureSet.field_presence is populated. +// +// See [FeatureSet.GetEnum]. +func (x *FeatureSet) HasFieldPresence() bool { + return x.unsafe().Has(0) +} + +// GetEnumType extracts the value of hyperpb.test.FeatureSet.enum_type. +// +// This definition is undocumented in the .proto file. +func (x *FeatureSet) GetEnumType() test.FeatureSet_EnumType { + v := x.unsafe().GetEnum(1, 0) + return test.FeatureSet_EnumType(v) +} + +// HasEnumType checks whether hyperpb.test.FeatureSet.enum_type is populated. +// +// See [FeatureSet.GetEnum]. +func (x *FeatureSet) HasEnumType() bool { + return x.unsafe().Has(1) +} + +// GetRepeatedFieldEncoding extracts the value of hyperpb.test.FeatureSet.repeated_field_encoding. +// +// This definition is undocumented in the .proto file. +func (x *FeatureSet) GetRepeatedFieldEncoding() test.FeatureSet_RepeatedFieldEncoding { + v := x.unsafe().GetEnum(2, 0) + return test.FeatureSet_RepeatedFieldEncoding(v) +} + +// HasRepeatedFieldEncoding checks whether hyperpb.test.FeatureSet.repeated_field_encoding is populated. +// +// See [FeatureSet.GetEnum]. +func (x *FeatureSet) HasRepeatedFieldEncoding() bool { + return x.unsafe().Has(2) +} + +// GetUtf8Validation extracts the value of hyperpb.test.FeatureSet.utf8_validation. +// +// This definition is undocumented in the .proto file. +func (x *FeatureSet) GetUtf8Validation() test.FeatureSet_Utf8Validation { + v := x.unsafe().GetEnum(3, 0) + return test.FeatureSet_Utf8Validation(v) +} + +// HasUtf8Validation checks whether hyperpb.test.FeatureSet.utf8_validation is populated. +// +// See [FeatureSet.GetEnum]. +func (x *FeatureSet) HasUtf8Validation() bool { + return x.unsafe().Has(3) +} + +// GetMessageEncoding extracts the value of hyperpb.test.FeatureSet.message_encoding. +// +// This definition is undocumented in the .proto file. +func (x *FeatureSet) GetMessageEncoding() test.FeatureSet_MessageEncoding { + v := x.unsafe().GetEnum(4, 0) + return test.FeatureSet_MessageEncoding(v) +} + +// HasMessageEncoding checks whether hyperpb.test.FeatureSet.message_encoding is populated. +// +// See [FeatureSet.GetEnum]. +func (x *FeatureSet) HasMessageEncoding() bool { + return x.unsafe().Has(4) +} + +// GetJsonFormat extracts the value of hyperpb.test.FeatureSet.json_format. +// +// This definition is undocumented in the .proto file. +func (x *FeatureSet) GetJsonFormat() test.FeatureSet_JsonFormat { + v := x.unsafe().GetEnum(5, 0) + return test.FeatureSet_JsonFormat(v) +} + +// HasJsonFormat checks whether hyperpb.test.FeatureSet.json_format is populated. +// +// See [FeatureSet.GetEnum]. +func (x *FeatureSet) HasJsonFormat() bool { + return x.unsafe().Has(5) +} + +// GetEnforceNamingStyle extracts the value of hyperpb.test.FeatureSet.enforce_naming_style. +// +// This definition is undocumented in the .proto file. +func (x *FeatureSet) GetEnforceNamingStyle() test.FeatureSet_EnforceNamingStyle { + v := x.unsafe().GetEnum(6, 0) + return test.FeatureSet_EnforceNamingStyle(v) +} + +// HasEnforceNamingStyle checks whether hyperpb.test.FeatureSet.enforce_naming_style is populated. +// +// See [FeatureSet.GetEnum]. +func (x *FeatureSet) HasEnforceNamingStyle() bool { + return x.unsafe().Has(6) +} + +// ProtoReflect implements proto.Message. +func (x *FeatureSet) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*FeatureSet) HyperMessage(export.DoNotImplement, *FeatureSet) {} + +func (x *FeatureSet) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *FeatureSet) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// FeatureSetDefaults is undocumented in the .proto file. +type FeatureSetDefaults struct{ _ hyperpb.Message } + +var tFeatureSetDefaults export.Type + +func init() { tFeatureSetDefaults.Init("hyperpb.test.FeatureSetDefaults") } + +// NewFeatureSetDefaults allocates a new FeatureSetDefaults. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(FeatureSetDefaults) will not work. +func NewFeatureSetDefaults(s *hyperpb.Shared) *FeatureSetDefaults { + m := s.NewMessage(tFeatureSetDefaults.Get()) + return (*FeatureSetDefaults)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *FeatureSetDefaults) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *FeatureSetDefaults) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetDefaults extracts the value of hyperpb.test.FeatureSetDefaults.defaults. +// +// This definition is undocumented in the .proto file. +func (x *FeatureSetDefaults) GetDefaults() hyperpb.List[*FeatureSetDefaults_FeatureSetEditionDefault] { + v := x.unsafe().GetRepeatedMessage(0) + return export.CastRepeatedMessage[*FeatureSetDefaults_FeatureSetEditionDefault](v) +} + +// GetMinimumEdition extracts the value of hyperpb.test.FeatureSetDefaults.minimum_edition. +// +// This definition is undocumented in the .proto file. +func (x *FeatureSetDefaults) GetMinimumEdition() test.Edition { + v := x.unsafe().GetEnum(1, 0) + return test.Edition(v) +} + +// HasMinimumEdition checks whether hyperpb.test.FeatureSetDefaults.minimum_edition is populated. +// +// See [FeatureSetDefaults.GetEnum]. +func (x *FeatureSetDefaults) HasMinimumEdition() bool { + return x.unsafe().Has(1) +} + +// GetMaximumEdition extracts the value of hyperpb.test.FeatureSetDefaults.maximum_edition. +// +// This definition is undocumented in the .proto file. +func (x *FeatureSetDefaults) GetMaximumEdition() test.Edition { + v := x.unsafe().GetEnum(2, 0) + return test.Edition(v) +} + +// HasMaximumEdition checks whether hyperpb.test.FeatureSetDefaults.maximum_edition is populated. +// +// See [FeatureSetDefaults.GetEnum]. +func (x *FeatureSetDefaults) HasMaximumEdition() bool { + return x.unsafe().Has(2) +} + +// ProtoReflect implements proto.Message. +func (x *FeatureSetDefaults) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*FeatureSetDefaults) HyperMessage(export.DoNotImplement, *FeatureSetDefaults) {} + +func (x *FeatureSetDefaults) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *FeatureSetDefaults) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// FeatureSetDefaults_FeatureSetEditionDefault is undocumented in the .proto file. +type FeatureSetDefaults_FeatureSetEditionDefault struct{ _ hyperpb.Message } + +var tFeatureSetDefaults_FeatureSetEditionDefault export.Type + +func init() { + tFeatureSetDefaults_FeatureSetEditionDefault.Init("hyperpb.test.FeatureSetDefaults.FeatureSetEditionDefault") +} + +// NewFeatureSetDefaults_FeatureSetEditionDefault allocates a new FeatureSetDefaults_FeatureSetEditionDefault. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(FeatureSetDefaults_FeatureSetEditionDefault) will not work. +func NewFeatureSetDefaults_FeatureSetEditionDefault(s *hyperpb.Shared) *FeatureSetDefaults_FeatureSetEditionDefault { + m := s.NewMessage(tFeatureSetDefaults_FeatureSetEditionDefault.Get()) + return (*FeatureSetDefaults_FeatureSetEditionDefault)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *FeatureSetDefaults_FeatureSetEditionDefault) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *FeatureSetDefaults_FeatureSetEditionDefault) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetEdition extracts the value of hyperpb.test.FeatureSetDefaults.FeatureSetEditionDefault.edition. +// +// This definition is undocumented in the .proto file. +func (x *FeatureSetDefaults_FeatureSetEditionDefault) GetEdition() test.Edition { + v := x.unsafe().GetEnum(0, 0) + return test.Edition(v) +} + +// HasEdition checks whether hyperpb.test.FeatureSetDefaults.FeatureSetEditionDefault.edition is populated. +// +// See [FeatureSetDefaults_FeatureSetEditionDefault.GetEnum]. +func (x *FeatureSetDefaults_FeatureSetEditionDefault) HasEdition() bool { + return x.unsafe().Has(0) +} + +// GetOverridableFeatures extracts the value of hyperpb.test.FeatureSetDefaults.FeatureSetEditionDefault.overridable_features. +// +// This definition is undocumented in the .proto file. +func (x *FeatureSetDefaults_FeatureSetEditionDefault) GetOverridableFeatures() *FeatureSet { + v := x.unsafe().GetMessage(1) + return (*FeatureSet)(v) +} + +// HasOverridableFeatures checks whether hyperpb.test.FeatureSetDefaults.FeatureSetEditionDefault.overridable_features is populated. +// +// See [FeatureSetDefaults_FeatureSetEditionDefault.GetMessage]. +func (x *FeatureSetDefaults_FeatureSetEditionDefault) HasOverridableFeatures() bool { + return x.unsafe().Has(1) +} + +// GetFixedFeatures extracts the value of hyperpb.test.FeatureSetDefaults.FeatureSetEditionDefault.fixed_features. +// +// This definition is undocumented in the .proto file. +func (x *FeatureSetDefaults_FeatureSetEditionDefault) GetFixedFeatures() *FeatureSet { + v := x.unsafe().GetMessage(2) + return (*FeatureSet)(v) +} + +// HasFixedFeatures checks whether hyperpb.test.FeatureSetDefaults.FeatureSetEditionDefault.fixed_features is populated. +// +// See [FeatureSetDefaults_FeatureSetEditionDefault.GetMessage]. +func (x *FeatureSetDefaults_FeatureSetEditionDefault) HasFixedFeatures() bool { + return x.unsafe().Has(2) +} + +// ProtoReflect implements proto.Message. +func (x *FeatureSetDefaults_FeatureSetEditionDefault) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*FeatureSetDefaults_FeatureSetEditionDefault) HyperMessage(export.DoNotImplement, *FeatureSetDefaults_FeatureSetEditionDefault) { +} + +func (x *FeatureSetDefaults_FeatureSetEditionDefault) impl() *hyperpb.Message { + return (*hyperpb.Message)(unsafe.Pointer(x)) +} + +func (x *FeatureSetDefaults_FeatureSetEditionDefault) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// SourceCodeInfo is undocumented in the .proto file. +type SourceCodeInfo struct{ _ hyperpb.Message } + +var tSourceCodeInfo export.Type + +func init() { tSourceCodeInfo.Init("hyperpb.test.SourceCodeInfo") } + +// NewSourceCodeInfo allocates a new SourceCodeInfo. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(SourceCodeInfo) will not work. +func NewSourceCodeInfo(s *hyperpb.Shared) *SourceCodeInfo { + m := s.NewMessage(tSourceCodeInfo.Get()) + return (*SourceCodeInfo)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *SourceCodeInfo) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *SourceCodeInfo) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetLocation extracts the value of hyperpb.test.SourceCodeInfo.location. +// +// This definition is undocumented in the .proto file. +func (x *SourceCodeInfo) GetLocation() hyperpb.List[*SourceCodeInfo_Location] { + v := x.unsafe().GetRepeatedMessage(0) + return export.CastRepeatedMessage[*SourceCodeInfo_Location](v) +} + +// ProtoReflect implements proto.Message. +func (x *SourceCodeInfo) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*SourceCodeInfo) HyperMessage(export.DoNotImplement, *SourceCodeInfo) {} + +func (x *SourceCodeInfo) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *SourceCodeInfo) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// SourceCodeInfo_Location is undocumented in the .proto file. +type SourceCodeInfo_Location struct{ _ hyperpb.Message } + +var tSourceCodeInfo_Location export.Type + +func init() { tSourceCodeInfo_Location.Init("hyperpb.test.SourceCodeInfo.Location") } + +// NewSourceCodeInfo_Location allocates a new SourceCodeInfo_Location. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(SourceCodeInfo_Location) will not work. +func NewSourceCodeInfo_Location(s *hyperpb.Shared) *SourceCodeInfo_Location { + m := s.NewMessage(tSourceCodeInfo_Location.Get()) + return (*SourceCodeInfo_Location)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *SourceCodeInfo_Location) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *SourceCodeInfo_Location) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetPath extracts the value of hyperpb.test.SourceCodeInfo.Location.path. +// +// This definition is undocumented in the .proto file. +func (x *SourceCodeInfo_Location) GetPath() hyperpb.List[int32] { + v := x.unsafe().GetRepeatedInt32(0) + return v +} + +// GetSpan extracts the value of hyperpb.test.SourceCodeInfo.Location.span. +// +// This definition is undocumented in the .proto file. +func (x *SourceCodeInfo_Location) GetSpan() hyperpb.List[int32] { + v := x.unsafe().GetRepeatedInt32(1) + return v +} + +// GetLeadingComments extracts the value of hyperpb.test.SourceCodeInfo.Location.leading_comments. +// +// This definition is undocumented in the .proto file. +func (x *SourceCodeInfo_Location) GetLeadingComments() string { + v := x.unsafe().GetString(2, "") + return v +} + +// HasLeadingComments checks whether hyperpb.test.SourceCodeInfo.Location.leading_comments is populated. +// +// See [SourceCodeInfo_Location.GetString]. +func (x *SourceCodeInfo_Location) HasLeadingComments() bool { + return x.unsafe().Has(2) +} + +// GetTrailingComments extracts the value of hyperpb.test.SourceCodeInfo.Location.trailing_comments. +// +// This definition is undocumented in the .proto file. +func (x *SourceCodeInfo_Location) GetTrailingComments() string { + v := x.unsafe().GetString(3, "") + return v +} + +// HasTrailingComments checks whether hyperpb.test.SourceCodeInfo.Location.trailing_comments is populated. +// +// See [SourceCodeInfo_Location.GetString]. +func (x *SourceCodeInfo_Location) HasTrailingComments() bool { + return x.unsafe().Has(3) +} + +// GetLeadingDetachedComments extracts the value of hyperpb.test.SourceCodeInfo.Location.leading_detached_comments. +// +// This definition is undocumented in the .proto file. +func (x *SourceCodeInfo_Location) GetLeadingDetachedComments() hyperpb.List[string] { + v := x.unsafe().GetRepeatedString(4) + return v +} + +// ProtoReflect implements proto.Message. +func (x *SourceCodeInfo_Location) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*SourceCodeInfo_Location) HyperMessage(export.DoNotImplement, *SourceCodeInfo_Location) {} + +func (x *SourceCodeInfo_Location) impl() *hyperpb.Message { + return (*hyperpb.Message)(unsafe.Pointer(x)) +} + +func (x *SourceCodeInfo_Location) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// GeneratedCodeInfo is undocumented in the .proto file. +type GeneratedCodeInfo struct{ _ hyperpb.Message } + +var tGeneratedCodeInfo export.Type + +func init() { tGeneratedCodeInfo.Init("hyperpb.test.GeneratedCodeInfo") } + +// NewGeneratedCodeInfo allocates a new GeneratedCodeInfo. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(GeneratedCodeInfo) will not work. +func NewGeneratedCodeInfo(s *hyperpb.Shared) *GeneratedCodeInfo { + m := s.NewMessage(tGeneratedCodeInfo.Get()) + return (*GeneratedCodeInfo)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *GeneratedCodeInfo) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *GeneratedCodeInfo) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetAnnotation extracts the value of hyperpb.test.GeneratedCodeInfo.annotation. +// +// This definition is undocumented in the .proto file. +func (x *GeneratedCodeInfo) GetAnnotation() hyperpb.List[*GeneratedCodeInfo_Annotation] { + v := x.unsafe().GetRepeatedMessage(0) + return export.CastRepeatedMessage[*GeneratedCodeInfo_Annotation](v) +} + +// ProtoReflect implements proto.Message. +func (x *GeneratedCodeInfo) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*GeneratedCodeInfo) HyperMessage(export.DoNotImplement, *GeneratedCodeInfo) {} + +func (x *GeneratedCodeInfo) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *GeneratedCodeInfo) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// GeneratedCodeInfo_Annotation is undocumented in the .proto file. +type GeneratedCodeInfo_Annotation struct{ _ hyperpb.Message } + +var tGeneratedCodeInfo_Annotation export.Type + +func init() { tGeneratedCodeInfo_Annotation.Init("hyperpb.test.GeneratedCodeInfo.Annotation") } + +// NewGeneratedCodeInfo_Annotation allocates a new GeneratedCodeInfo_Annotation. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(GeneratedCodeInfo_Annotation) will not work. +func NewGeneratedCodeInfo_Annotation(s *hyperpb.Shared) *GeneratedCodeInfo_Annotation { + m := s.NewMessage(tGeneratedCodeInfo_Annotation.Get()) + return (*GeneratedCodeInfo_Annotation)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *GeneratedCodeInfo_Annotation) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *GeneratedCodeInfo_Annotation) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetPath extracts the value of hyperpb.test.GeneratedCodeInfo.Annotation.path. +// +// This definition is undocumented in the .proto file. +func (x *GeneratedCodeInfo_Annotation) GetPath() hyperpb.List[int32] { + v := x.unsafe().GetRepeatedInt32(0) + return v +} + +// GetSourceFile extracts the value of hyperpb.test.GeneratedCodeInfo.Annotation.source_file. +// +// This definition is undocumented in the .proto file. +func (x *GeneratedCodeInfo_Annotation) GetSourceFile() string { + v := x.unsafe().GetString(1, "") + return v +} + +// HasSourceFile checks whether hyperpb.test.GeneratedCodeInfo.Annotation.source_file is populated. +// +// See [GeneratedCodeInfo_Annotation.GetString]. +func (x *GeneratedCodeInfo_Annotation) HasSourceFile() bool { + return x.unsafe().Has(1) +} + +// GetBegin extracts the value of hyperpb.test.GeneratedCodeInfo.Annotation.begin. +// +// This definition is undocumented in the .proto file. +func (x *GeneratedCodeInfo_Annotation) GetBegin() int32 { + v := x.unsafe().GetInt32(2, 0) + return v +} + +// HasBegin checks whether hyperpb.test.GeneratedCodeInfo.Annotation.begin is populated. +// +// See [GeneratedCodeInfo_Annotation.GetInt32]. +func (x *GeneratedCodeInfo_Annotation) HasBegin() bool { + return x.unsafe().Has(2) +} + +// GetEnd extracts the value of hyperpb.test.GeneratedCodeInfo.Annotation.end. +// +// This definition is undocumented in the .proto file. +func (x *GeneratedCodeInfo_Annotation) GetEnd() int32 { + v := x.unsafe().GetInt32(3, 0) + return v +} + +// HasEnd checks whether hyperpb.test.GeneratedCodeInfo.Annotation.end is populated. +// +// See [GeneratedCodeInfo_Annotation.GetInt32]. +func (x *GeneratedCodeInfo_Annotation) HasEnd() bool { + return x.unsafe().Has(3) +} + +// GetSemantic extracts the value of hyperpb.test.GeneratedCodeInfo.Annotation.semantic. +// +// This definition is undocumented in the .proto file. +func (x *GeneratedCodeInfo_Annotation) GetSemantic() test.GeneratedCodeInfo_Annotation_Semantic { + v := x.unsafe().GetEnum(4, 0) + return test.GeneratedCodeInfo_Annotation_Semantic(v) +} + +// HasSemantic checks whether hyperpb.test.GeneratedCodeInfo.Annotation.semantic is populated. +// +// See [GeneratedCodeInfo_Annotation.GetEnum]. +func (x *GeneratedCodeInfo_Annotation) HasSemantic() bool { + return x.unsafe().Has(4) +} + +// ProtoReflect implements proto.Message. +func (x *GeneratedCodeInfo_Annotation) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*GeneratedCodeInfo_Annotation) HyperMessage(export.DoNotImplement, *GeneratedCodeInfo_Annotation) { +} + +func (x *GeneratedCodeInfo_Annotation) impl() *hyperpb.Message { + return (*hyperpb.Message)(unsafe.Pointer(x)) +} + +func (x *GeneratedCodeInfo_Annotation) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} diff --git a/internal/gen/test/hyper-test/editions.pb.go b/internal/gen/test/hyper-test/editions.pb.go new file mode 100644 index 0000000..635a6dc --- /dev/null +++ b/internal/gen/test/hyper-test/editions.pb.go @@ -0,0 +1,104 @@ +// Copyright 2025 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-hyperpb. DO NOT EDIT. +// source: test/editions.proto + +// buf:lint:ignore PACKAGE_VERSION_SUFFIX +// buf:lint:ignore PACKAGE_DIRECTORY_MATCH + +package test + +import ( + hyperpb "buf.build/go/hyperpb" + export "buf.build/go/hyperpb/cmd/protoc-gen-hyperpb/export" + _ "buf.build/go/hyperpb/internal/gen/test" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + unsafe "unsafe" +) + +// Proto2Strings is undocumented in the .proto file. +type Proto2Strings struct{ _ hyperpb.Message } + +var tProto2Strings export.Type + +func init() { tProto2Strings.Init("hyperpb.test.Proto2Strings") } + +// NewProto2Strings allocates a new Proto2Strings. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(Proto2Strings) will not work. +func NewProto2Strings(s *hyperpb.Shared) *Proto2Strings { + m := s.NewMessage(tProto2Strings.Get()) + return (*Proto2Strings)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *Proto2Strings) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *Proto2Strings) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetS1 extracts the value of hyperpb.test.Proto2Strings.s1. +// +// This definition is undocumented in the .proto file. +func (x *Proto2Strings) GetS1() string { + v := x.unsafe().GetString(0, "") + return v +} + +// GetS2 extracts the value of hyperpb.test.Proto2Strings.s2. +// +// This definition is undocumented in the .proto file. +func (x *Proto2Strings) GetS2() hyperpb.List[string] { + v := x.unsafe().GetRepeatedString(1) + return v +} + +// GetS4 extracts the value of hyperpb.test.Proto2Strings.s4. +// +// This definition is undocumented in the .proto file. +func (x *Proto2Strings) GetS4() string { + v := x.unsafe().GetString(3, "") + return v +} + +// GetZ extracts the value of hyperpb.test.Proto2Strings.z. +// +// This definition is undocumented in the .proto file. +func (x *Proto2Strings) GetZ() int32 { + v := x.unsafe().GetInt32(4, 0) + return v +} + +// ProtoReflect implements proto.Message. +func (x *Proto2Strings) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*Proto2Strings) HyperMessage(export.DoNotImplement, *Proto2Strings) {} + +func (x *Proto2Strings) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *Proto2Strings) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} diff --git a/internal/gen/test/hyper-test/proto2.pb.go b/internal/gen/test/hyper-test/proto2.pb.go new file mode 100644 index 0000000..9baccb5 --- /dev/null +++ b/internal/gen/test/hyper-test/proto2.pb.go @@ -0,0 +1,553 @@ +// Copyright 2025 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-hyperpb. DO NOT EDIT. +// source: test/proto2.proto + +// buf:lint:ignore PACKAGE_VERSION_SUFFIX +// buf:lint:ignore PACKAGE_DIRECTORY_MATCH + +package test + +import ( + hyperpb "buf.build/go/hyperpb" + export "buf.build/go/hyperpb/cmd/protoc-gen-hyperpb/export" + _ "buf.build/go/hyperpb/internal/gen/test" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + unsafe "unsafe" +) + +// Extensions is undocumented in the .proto file. +type Extensions struct{ _ hyperpb.Message } + +var tExtensions export.Type + +func init() { tExtensions.Init("hyperpb.test.Extensions") } + +// NewExtensions allocates a new Extensions. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(Extensions) will not work. +func NewExtensions(s *hyperpb.Shared) *Extensions { + m := s.NewMessage(tExtensions.Get()) + return (*Extensions)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *Extensions) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *Extensions) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// ProtoReflect implements proto.Message. +func (x *Extensions) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*Extensions) HyperMessage(export.DoNotImplement, *Extensions) {} + +func (x *Extensions) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *Extensions) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// Required is undocumented in the .proto file. +type Required struct{ _ hyperpb.Message } + +var tRequired export.Type + +func init() { tRequired.Init("hyperpb.test.Required") } + +// NewRequired allocates a new Required. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(Required) will not work. +func NewRequired(s *hyperpb.Shared) *Required { + m := s.NewMessage(tRequired.Get()) + return (*Required)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *Required) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *Required) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetX extracts the value of hyperpb.test.Required.x. +// +// buf:lint:ignore FIELD_NOT_REQUIRED +func (x *Required) GetX() int32 { + v := x.unsafe().GetInt32(0, 0) + return v +} + +// GetY extracts the value of hyperpb.test.Required.y. +// +// This definition is undocumented in the .proto file. +func (x *Required) GetY() *Required { + v := x.unsafe().GetMessage(1) + return (*Required)(v) +} + +// HasY checks whether hyperpb.test.Required.y is populated. +// +// See [Required.GetMessage]. +func (x *Required) HasY() bool { + return x.unsafe().Has(1) +} + +// GetZ extracts the value of hyperpb.test.Required.z. +// +// buf:lint:ignore FIELD_NOT_REQUIRED +func (x *Required) GetZ() *Required_Empty { + v := x.unsafe().GetMessage(2) + return (*Required_Empty)(v) +} + +// ProtoReflect implements proto.Message. +func (x *Required) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*Required) HyperMessage(export.DoNotImplement, *Required) {} + +func (x *Required) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *Required) unsafe() *export.UnsafeMessage { return (*export.UnsafeMessage)(unsafe.Pointer(x)) } + +// Required_Empty is undocumented in the .proto file. +type Required_Empty struct{ _ hyperpb.Message } + +var tRequired_Empty export.Type + +func init() { tRequired_Empty.Init("hyperpb.test.Required.Empty") } + +// NewRequired_Empty allocates a new Required_Empty. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(Required_Empty) will not work. +func NewRequired_Empty(s *hyperpb.Shared) *Required_Empty { + m := s.NewMessage(tRequired_Empty.Get()) + return (*Required_Empty)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *Required_Empty) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *Required_Empty) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// ProtoReflect implements proto.Message. +func (x *Required_Empty) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*Required_Empty) HyperMessage(export.DoNotImplement, *Required_Empty) {} + +func (x *Required_Empty) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *Required_Empty) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// DependsOnRequired is undocumented in the .proto file. +type DependsOnRequired struct{ _ hyperpb.Message } + +var tDependsOnRequired export.Type + +func init() { tDependsOnRequired.Init("hyperpb.test.DependsOnRequired") } + +// NewDependsOnRequired allocates a new DependsOnRequired. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(DependsOnRequired) will not work. +func NewDependsOnRequired(s *hyperpb.Shared) *DependsOnRequired { + m := s.NewMessage(tDependsOnRequired.Get()) + return (*DependsOnRequired)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *DependsOnRequired) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *DependsOnRequired) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetA extracts the value of hyperpb.test.DependsOnRequired.a. +// +// This definition is undocumented in the .proto file. +func (x *DependsOnRequired) GetA() *Required { + v := x.unsafe().GetMessage(0) + return (*Required)(v) +} + +// HasA checks whether hyperpb.test.DependsOnRequired.a is populated. +// +// See [DependsOnRequired.GetMessage]. +func (x *DependsOnRequired) HasA() bool { + return x.unsafe().Has(0) +} + +// GetB extracts the value of hyperpb.test.DependsOnRequired.b. +// +// This definition is undocumented in the .proto file. +func (x *DependsOnRequired) GetB() hyperpb.List[*Required] { + v := x.unsafe().GetRepeatedMessage(1) + return export.CastRepeatedMessage[*Required](v) +} + +// ProtoReflect implements proto.Message. +func (x *DependsOnRequired) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*DependsOnRequired) HyperMessage(export.DoNotImplement, *DependsOnRequired) {} + +func (x *DependsOnRequired) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *DependsOnRequired) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// Groups is undocumented in the .proto file. +type Groups struct{ _ hyperpb.Message } + +var tGroups export.Type + +func init() { tGroups.Init("hyperpb.test.Groups") } + +// NewGroups allocates a new Groups. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(Groups) will not work. +func NewGroups(s *hyperpb.Shared) *Groups { + m := s.NewMessage(tGroups.Get()) + return (*Groups)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *Groups) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *Groups) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetSingular extracts the value of hyperpb.test.Groups.singular. +// +// This definition is undocumented in the .proto file. +func (x *Groups) GetSingular() *Groups_Singular { + v := x.unsafe().GetMessage(0) + return (*Groups_Singular)(v) +} + +// HasSingular checks whether hyperpb.test.Groups.singular is populated. +// +// See [Groups.GetMessage]. +func (x *Groups) HasSingular() bool { + return x.unsafe().Has(0) +} + +// GetRepeated extracts the value of hyperpb.test.Groups.repeated. +// +// This definition is undocumented in the .proto file. +func (x *Groups) GetRepeated() hyperpb.List[*Groups_Repeated] { + v := x.unsafe().GetRepeatedMessage(1) + return export.CastRepeatedMessage[*Groups_Repeated](v) +} + +// ProtoReflect implements proto.Message. +func (x *Groups) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*Groups) HyperMessage(export.DoNotImplement, *Groups) {} + +func (x *Groups) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *Groups) unsafe() *export.UnsafeMessage { return (*export.UnsafeMessage)(unsafe.Pointer(x)) } + +// Groups_Singular is undocumented in the .proto file. +type Groups_Singular struct{ _ hyperpb.Message } + +var tGroups_Singular export.Type + +func init() { tGroups_Singular.Init("hyperpb.test.Groups.Singular") } + +// NewGroups_Singular allocates a new Groups_Singular. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(Groups_Singular) will not work. +func NewGroups_Singular(s *hyperpb.Shared) *Groups_Singular { + m := s.NewMessage(tGroups_Singular.Get()) + return (*Groups_Singular)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *Groups_Singular) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *Groups_Singular) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetA extracts the value of hyperpb.test.Groups.Singular.a. +// +// This definition is undocumented in the .proto file. +func (x *Groups_Singular) GetA() int32 { + v := x.unsafe().GetInt32(0, 0) + return v +} + +// HasA checks whether hyperpb.test.Groups.Singular.a is populated. +// +// See [Groups_Singular.GetInt32]. +func (x *Groups_Singular) HasA() bool { + return x.unsafe().Has(0) +} + +// GetB extracts the value of hyperpb.test.Groups.Singular.b. +// +// This definition is undocumented in the .proto file. +func (x *Groups_Singular) GetB() int32 { + v := x.unsafe().GetInt32(1, 0) + return v +} + +// HasB checks whether hyperpb.test.Groups.Singular.b is populated. +// +// See [Groups_Singular.GetInt32]. +func (x *Groups_Singular) HasB() bool { + return x.unsafe().Has(1) +} + +// GetG extracts the value of hyperpb.test.Groups.Singular.g. +// +// This definition is undocumented in the .proto file. +func (x *Groups_Singular) GetG() *Groups { + v := x.unsafe().GetMessage(2) + return (*Groups)(v) +} + +// HasG checks whether hyperpb.test.Groups.Singular.g is populated. +// +// See [Groups_Singular.GetMessage]. +func (x *Groups_Singular) HasG() bool { + return x.unsafe().Has(2) +} + +// GetNested extracts the value of hyperpb.test.Groups.Singular.nested. +// +// This definition is undocumented in the .proto file. +func (x *Groups_Singular) GetNested() *Groups_Singular_Nested { + v := x.unsafe().GetMessage(3) + return (*Groups_Singular_Nested)(v) +} + +// HasNested checks whether hyperpb.test.Groups.Singular.nested is populated. +// +// See [Groups_Singular.GetMessage]. +func (x *Groups_Singular) HasNested() bool { + return x.unsafe().Has(3) +} + +// ProtoReflect implements proto.Message. +func (x *Groups_Singular) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*Groups_Singular) HyperMessage(export.DoNotImplement, *Groups_Singular) {} + +func (x *Groups_Singular) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *Groups_Singular) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// Groups_Singular_Nested is undocumented in the .proto file. +type Groups_Singular_Nested struct{ _ hyperpb.Message } + +var tGroups_Singular_Nested export.Type + +func init() { tGroups_Singular_Nested.Init("hyperpb.test.Groups.Singular.Nested") } + +// NewGroups_Singular_Nested allocates a new Groups_Singular_Nested. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(Groups_Singular_Nested) will not work. +func NewGroups_Singular_Nested(s *hyperpb.Shared) *Groups_Singular_Nested { + m := s.NewMessage(tGroups_Singular_Nested.Get()) + return (*Groups_Singular_Nested)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *Groups_Singular_Nested) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *Groups_Singular_Nested) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetA extracts the value of hyperpb.test.Groups.Singular.Nested.a. +// +// This definition is undocumented in the .proto file. +func (x *Groups_Singular_Nested) GetA() int32 { + v := x.unsafe().GetInt32(0, 0) + return v +} + +// HasA checks whether hyperpb.test.Groups.Singular.Nested.a is populated. +// +// See [Groups_Singular_Nested.GetInt32]. +func (x *Groups_Singular_Nested) HasA() bool { + return x.unsafe().Has(0) +} + +// ProtoReflect implements proto.Message. +func (x *Groups_Singular_Nested) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*Groups_Singular_Nested) HyperMessage(export.DoNotImplement, *Groups_Singular_Nested) {} + +func (x *Groups_Singular_Nested) impl() *hyperpb.Message { + return (*hyperpb.Message)(unsafe.Pointer(x)) +} + +func (x *Groups_Singular_Nested) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// Groups_Repeated is undocumented in the .proto file. +type Groups_Repeated struct{ _ hyperpb.Message } + +var tGroups_Repeated export.Type + +func init() { tGroups_Repeated.Init("hyperpb.test.Groups.Repeated") } + +// NewGroups_Repeated allocates a new Groups_Repeated. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(Groups_Repeated) will not work. +func NewGroups_Repeated(s *hyperpb.Shared) *Groups_Repeated { + m := s.NewMessage(tGroups_Repeated.Get()) + return (*Groups_Repeated)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *Groups_Repeated) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *Groups_Repeated) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetA extracts the value of hyperpb.test.Groups.Repeated.a. +// +// This definition is undocumented in the .proto file. +func (x *Groups_Repeated) GetA() int32 { + v := x.unsafe().GetInt32(0, 0) + return v +} + +// HasA checks whether hyperpb.test.Groups.Repeated.a is populated. +// +// See [Groups_Repeated.GetInt32]. +func (x *Groups_Repeated) HasA() bool { + return x.unsafe().Has(0) +} + +// GetB extracts the value of hyperpb.test.Groups.Repeated.b. +// +// This definition is undocumented in the .proto file. +func (x *Groups_Repeated) GetB() int32 { + v := x.unsafe().GetInt32(1, 0) + return v +} + +// HasB checks whether hyperpb.test.Groups.Repeated.b is populated. +// +// See [Groups_Repeated.GetInt32]. +func (x *Groups_Repeated) HasB() bool { + return x.unsafe().Has(1) +} + +// ProtoReflect implements proto.Message. +func (x *Groups_Repeated) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*Groups_Repeated) HyperMessage(export.DoNotImplement, *Groups_Repeated) {} + +func (x *Groups_Repeated) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *Groups_Repeated) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} diff --git a/internal/gen/test/hyper-test/test.pb.go b/internal/gen/test/hyper-test/test.pb.go new file mode 100644 index 0000000..6aa0b12 --- /dev/null +++ b/internal/gen/test/hyper-test/test.pb.go @@ -0,0 +1,1159 @@ +// Copyright 2025 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-hyperpb. DO NOT EDIT. +// source: test/test.proto + +// buf:lint:ignore PACKAGE_VERSION_SUFFIX +// buf:lint:ignore PACKAGE_DIRECTORY_MATCH + +package test + +import ( + hyperpb "buf.build/go/hyperpb" + export "buf.build/go/hyperpb/cmd/protoc-gen-hyperpb/export" + _ "buf.build/go/hyperpb/internal/gen/test" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + math "math" + unsafe "unsafe" +) + +// Scalars is undocumented in the .proto file. +type Scalars struct{ _ hyperpb.Message } + +var tScalars export.Type + +func init() { tScalars.Init("hyperpb.test.Scalars") } + +// NewScalars allocates a new Scalars. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(Scalars) will not work. +func NewScalars(s *hyperpb.Shared) *Scalars { + m := s.NewMessage(tScalars.Get()) + return (*Scalars)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *Scalars) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *Scalars) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetA1 extracts the value of hyperpb.test.Scalars.a1. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetA1() int32 { + v := x.unsafe().GetInt32(0, 0) + return v +} + +// GetA2 extracts the value of hyperpb.test.Scalars.a2. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetA2() int64 { + v := x.unsafe().GetInt64(1, 0) + return v +} + +// GetA3 extracts the value of hyperpb.test.Scalars.a3. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetA3() uint32 { + v := x.unsafe().GetUint32(2, 0) + return v +} + +// GetA4 extracts the value of hyperpb.test.Scalars.a4. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetA4() uint64 { + v := x.unsafe().GetUint64(3, 0) + return v +} + +// GetA5 extracts the value of hyperpb.test.Scalars.a5. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetA5() int32 { + v := x.unsafe().GetInt32(4, 0) + return v +} + +// GetA6 extracts the value of hyperpb.test.Scalars.a6. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetA6() int64 { + v := x.unsafe().GetInt64(5, 0) + return v +} + +// GetA7 extracts the value of hyperpb.test.Scalars.a7. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetA7() uint32 { + v := x.unsafe().GetUint32(6, 0) + return v +} + +// GetA8 extracts the value of hyperpb.test.Scalars.a8. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetA8() uint64 { + v := x.unsafe().GetUint64(7, 0) + return v +} + +// GetA9 extracts the value of hyperpb.test.Scalars.a9. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetA9() int32 { + v := x.unsafe().GetInt32(8, 0) + return v +} + +// GetA10 extracts the value of hyperpb.test.Scalars.a10. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetA10() int64 { + v := x.unsafe().GetInt64(9, 0) + return v +} + +// GetA11 extracts the value of hyperpb.test.Scalars.a11. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetA11() float32 { + v := x.unsafe().GetFloat32(10, math.Float32frombits(0x0)) + return v +} + +// GetA12 extracts the value of hyperpb.test.Scalars.a12. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetA12() float64 { + v := x.unsafe().GetFloat64(11, math.Float64frombits(0x0)) + return v +} + +// GetA13 extracts the value of hyperpb.test.Scalars.a13. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetA13() bool { + v := x.unsafe().GetBool(12, false) + return v +} + +// GetA14 extracts the value of hyperpb.test.Scalars.a14. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetA14() string { + v := x.unsafe().GetString(13, "") + return v +} + +// GetA15 extracts the value of hyperpb.test.Scalars.a15. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetA15() []byte { + v := x.unsafe().GetBytes(14, "") + return v +} + +// GetB1 extracts the value of hyperpb.test.Scalars.b1. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetB1() int32 { + v := x.unsafe().GetInt32(15, 0) + return v +} + +// HasB1 checks whether hyperpb.test.Scalars.b1 is populated. +// +// See [Scalars.GetInt32]. +func (x *Scalars) HasB1() bool { + return x.unsafe().Has(15) +} + +// GetB2 extracts the value of hyperpb.test.Scalars.b2. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetB2() int64 { + v := x.unsafe().GetInt64(16, 0) + return v +} + +// HasB2 checks whether hyperpb.test.Scalars.b2 is populated. +// +// See [Scalars.GetInt64]. +func (x *Scalars) HasB2() bool { + return x.unsafe().Has(16) +} + +// GetB3 extracts the value of hyperpb.test.Scalars.b3. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetB3() uint32 { + v := x.unsafe().GetUint32(17, 0) + return v +} + +// HasB3 checks whether hyperpb.test.Scalars.b3 is populated. +// +// See [Scalars.GetUint32]. +func (x *Scalars) HasB3() bool { + return x.unsafe().Has(17) +} + +// GetB4 extracts the value of hyperpb.test.Scalars.b4. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetB4() uint64 { + v := x.unsafe().GetUint64(18, 0) + return v +} + +// HasB4 checks whether hyperpb.test.Scalars.b4 is populated. +// +// See [Scalars.GetUint64]. +func (x *Scalars) HasB4() bool { + return x.unsafe().Has(18) +} + +// GetB5 extracts the value of hyperpb.test.Scalars.b5. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetB5() int32 { + v := x.unsafe().GetInt32(19, 0) + return v +} + +// HasB5 checks whether hyperpb.test.Scalars.b5 is populated. +// +// See [Scalars.GetInt32]. +func (x *Scalars) HasB5() bool { + return x.unsafe().Has(19) +} + +// GetB6 extracts the value of hyperpb.test.Scalars.b6. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetB6() int64 { + v := x.unsafe().GetInt64(20, 0) + return v +} + +// HasB6 checks whether hyperpb.test.Scalars.b6 is populated. +// +// See [Scalars.GetInt64]. +func (x *Scalars) HasB6() bool { + return x.unsafe().Has(20) +} + +// GetB7 extracts the value of hyperpb.test.Scalars.b7. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetB7() uint32 { + v := x.unsafe().GetUint32(21, 0) + return v +} + +// HasB7 checks whether hyperpb.test.Scalars.b7 is populated. +// +// See [Scalars.GetUint32]. +func (x *Scalars) HasB7() bool { + return x.unsafe().Has(21) +} + +// GetB8 extracts the value of hyperpb.test.Scalars.b8. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetB8() uint64 { + v := x.unsafe().GetUint64(22, 0) + return v +} + +// HasB8 checks whether hyperpb.test.Scalars.b8 is populated. +// +// See [Scalars.GetUint64]. +func (x *Scalars) HasB8() bool { + return x.unsafe().Has(22) +} + +// GetB9 extracts the value of hyperpb.test.Scalars.b9. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetB9() int32 { + v := x.unsafe().GetInt32(23, 0) + return v +} + +// HasB9 checks whether hyperpb.test.Scalars.b9 is populated. +// +// See [Scalars.GetInt32]. +func (x *Scalars) HasB9() bool { + return x.unsafe().Has(23) +} + +// GetB10 extracts the value of hyperpb.test.Scalars.b10. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetB10() int64 { + v := x.unsafe().GetInt64(24, 0) + return v +} + +// HasB10 checks whether hyperpb.test.Scalars.b10 is populated. +// +// See [Scalars.GetInt64]. +func (x *Scalars) HasB10() bool { + return x.unsafe().Has(24) +} + +// GetB11 extracts the value of hyperpb.test.Scalars.b11. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetB11() float32 { + v := x.unsafe().GetFloat32(25, math.Float32frombits(0x0)) + return v +} + +// HasB11 checks whether hyperpb.test.Scalars.b11 is populated. +// +// See [Scalars.GetFloat32]. +func (x *Scalars) HasB11() bool { + return x.unsafe().Has(25) +} + +// GetB12 extracts the value of hyperpb.test.Scalars.b12. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetB12() float64 { + v := x.unsafe().GetFloat64(26, math.Float64frombits(0x0)) + return v +} + +// HasB12 checks whether hyperpb.test.Scalars.b12 is populated. +// +// See [Scalars.GetFloat64]. +func (x *Scalars) HasB12() bool { + return x.unsafe().Has(26) +} + +// GetB13 extracts the value of hyperpb.test.Scalars.b13. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetB13() bool { + v := x.unsafe().GetBool(27, false) + return v +} + +// HasB13 checks whether hyperpb.test.Scalars.b13 is populated. +// +// See [Scalars.GetBool]. +func (x *Scalars) HasB13() bool { + return x.unsafe().Has(27) +} + +// GetB14 extracts the value of hyperpb.test.Scalars.b14. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetB14() string { + v := x.unsafe().GetString(28, "") + return v +} + +// HasB14 checks whether hyperpb.test.Scalars.b14 is populated. +// +// See [Scalars.GetString]. +func (x *Scalars) HasB14() bool { + return x.unsafe().Has(28) +} + +// GetB15 extracts the value of hyperpb.test.Scalars.b15. +// +// This definition is undocumented in the .proto file. +func (x *Scalars) GetB15() []byte { + v := x.unsafe().GetBytes(29, "") + return v +} + +// HasB15 checks whether hyperpb.test.Scalars.b15 is populated. +// +// See [Scalars.GetBytes]. +func (x *Scalars) HasB15() bool { + return x.unsafe().Has(29) +} + +// ProtoReflect implements proto.Message. +func (x *Scalars) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*Scalars) HyperMessage(export.DoNotImplement, *Scalars) {} + +func (x *Scalars) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *Scalars) unsafe() *export.UnsafeMessage { return (*export.UnsafeMessage)(unsafe.Pointer(x)) } + +// Numbers is undocumented in the .proto file. +type Numbers struct{ _ hyperpb.Message } + +var tNumbers export.Type + +func init() { tNumbers.Init("hyperpb.test.Numbers") } + +// NewNumbers allocates a new Numbers. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(Numbers) will not work. +func NewNumbers(s *hyperpb.Shared) *Numbers { + m := s.NewMessage(tNumbers.Get()) + return (*Numbers)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *Numbers) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *Numbers) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetA1 extracts the value of hyperpb.test.Numbers.a1. +// +// This definition is undocumented in the .proto file. +func (x *Numbers) GetA1() int32 { + v := x.unsafe().GetInt32(0, 0) + return v +} + +// GetA2 extracts the value of hyperpb.test.Numbers.a2. +// +// This definition is undocumented in the .proto file. +func (x *Numbers) GetA2() int32 { + v := x.unsafe().GetInt32(1, 0) + return v +} + +// GetA3 extracts the value of hyperpb.test.Numbers.a3. +// +// This definition is undocumented in the .proto file. +func (x *Numbers) GetA3() int32 { + v := x.unsafe().GetInt32(2, 0) + return v +} + +// GetA4 extracts the value of hyperpb.test.Numbers.a4. +// +// This definition is undocumented in the .proto file. +func (x *Numbers) GetA4() int32 { + v := x.unsafe().GetInt32(3, 0) + return v +} + +// GetA5 extracts the value of hyperpb.test.Numbers.a5. +// +// This definition is undocumented in the .proto file. +func (x *Numbers) GetA5() int32 { + v := x.unsafe().GetInt32(4, 0) + return v +} + +// GetA6 extracts the value of hyperpb.test.Numbers.a6. +// +// This definition is undocumented in the .proto file. +func (x *Numbers) GetA6() int32 { + v := x.unsafe().GetInt32(5, 0) + return v +} + +// GetA7 extracts the value of hyperpb.test.Numbers.a7. +// +// This definition is undocumented in the .proto file. +func (x *Numbers) GetA7() int32 { + v := x.unsafe().GetInt32(6, 0) + return v +} + +// GetA8 extracts the value of hyperpb.test.Numbers.a8. +// +// This definition is undocumented in the .proto file. +func (x *Numbers) GetA8() int32 { + v := x.unsafe().GetInt32(7, 0) + return v +} + +// GetA9 extracts the value of hyperpb.test.Numbers.a9. +// +// This definition is undocumented in the .proto file. +func (x *Numbers) GetA9() int32 { + v := x.unsafe().GetInt32(8, 0) + return v +} + +// GetAa extracts the value of hyperpb.test.Numbers.aa. +// +// This definition is undocumented in the .proto file. +func (x *Numbers) GetAa() int32 { + v := x.unsafe().GetInt32(9, 0) + return v +} + +// ProtoReflect implements proto.Message. +func (x *Numbers) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*Numbers) HyperMessage(export.DoNotImplement, *Numbers) {} + +func (x *Numbers) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *Numbers) unsafe() *export.UnsafeMessage { return (*export.UnsafeMessage)(unsafe.Pointer(x)) } + +// Repeated is undocumented in the .proto file. +type Repeated struct{ _ hyperpb.Message } + +var tRepeated export.Type + +func init() { tRepeated.Init("hyperpb.test.Repeated") } + +// NewRepeated allocates a new Repeated. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(Repeated) will not work. +func NewRepeated(s *hyperpb.Shared) *Repeated { + m := s.NewMessage(tRepeated.Get()) + return (*Repeated)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *Repeated) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *Repeated) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetR1 extracts the value of hyperpb.test.Repeated.r1. +// +// This definition is undocumented in the .proto file. +func (x *Repeated) GetR1() hyperpb.List[int32] { + v := x.unsafe().GetRepeatedInt32(0) + return v +} + +// GetR2 extracts the value of hyperpb.test.Repeated.r2. +// +// This definition is undocumented in the .proto file. +func (x *Repeated) GetR2() hyperpb.List[int64] { + v := x.unsafe().GetRepeatedInt64(1) + return v +} + +// GetR3 extracts the value of hyperpb.test.Repeated.r3. +// +// This definition is undocumented in the .proto file. +func (x *Repeated) GetR3() hyperpb.List[int32] { + v := x.unsafe().GetRepeatedSint32(2) + return v +} + +// GetR4 extracts the value of hyperpb.test.Repeated.r4. +// +// This definition is undocumented in the .proto file. +func (x *Repeated) GetR4() hyperpb.List[int64] { + v := x.unsafe().GetRepeatedSint64(3) + return v +} + +// GetR5 extracts the value of hyperpb.test.Repeated.r5. +// +// This definition is undocumented in the .proto file. +func (x *Repeated) GetR5() hyperpb.List[uint32] { + v := x.unsafe().GetRepeatedFixed32(4) + return v +} + +// GetR6 extracts the value of hyperpb.test.Repeated.r6. +// +// This definition is undocumented in the .proto file. +func (x *Repeated) GetR6() hyperpb.List[uint64] { + v := x.unsafe().GetRepeatedFixed64(5) + return v +} + +// GetR7 extracts the value of hyperpb.test.Repeated.r7. +// +// This definition is undocumented in the .proto file. +func (x *Repeated) GetR7() hyperpb.List[string] { + v := x.unsafe().GetRepeatedString(6) + return v +} + +// GetR8 extracts the value of hyperpb.test.Repeated.r8. +// +// This definition is undocumented in the .proto file. +func (x *Repeated) GetR8() hyperpb.List[[]byte] { + v := x.unsafe().GetRepeatedBytes(7) + return v +} + +// ProtoReflect implements proto.Message. +func (x *Repeated) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*Repeated) HyperMessage(export.DoNotImplement, *Repeated) {} + +func (x *Repeated) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *Repeated) unsafe() *export.UnsafeMessage { return (*export.UnsafeMessage)(unsafe.Pointer(x)) } + +// Graph is undocumented in the .proto file. +type Graph struct{ _ hyperpb.Message } + +var tGraph export.Type + +func init() { tGraph.Init("hyperpb.test.Graph") } + +// NewGraph allocates a new Graph. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(Graph) will not work. +func NewGraph(s *hyperpb.Shared) *Graph { + m := s.NewMessage(tGraph.Get()) + return (*Graph)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *Graph) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *Graph) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetV extracts the value of hyperpb.test.Graph.v. +// +// This definition is undocumented in the .proto file. +func (x *Graph) GetV() int32 { + v := x.unsafe().GetInt32(0, 0) + return v +} + +// GetS extracts the value of hyperpb.test.Graph.s. +// +// This definition is undocumented in the .proto file. +func (x *Graph) GetS() *Graph { + v := x.unsafe().GetMessage(1) + return (*Graph)(v) +} + +// GetR extracts the value of hyperpb.test.Graph.r. +// +// This definition is undocumented in the .proto file. +func (x *Graph) GetR() hyperpb.List[*Graph] { + v := x.unsafe().GetRepeatedMessage(2) + return export.CastRepeatedMessage[*Graph](v) +} + +// ProtoReflect implements proto.Message. +func (x *Graph) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*Graph) HyperMessage(export.DoNotImplement, *Graph) {} + +func (x *Graph) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *Graph) unsafe() *export.UnsafeMessage { return (*export.UnsafeMessage)(unsafe.Pointer(x)) } + +// Oneof is undocumented in the .proto file. +type Oneof struct{ _ hyperpb.Message } + +var tOneof export.Type + +func init() { tOneof.Init("hyperpb.test.Oneof") } + +// NewOneof allocates a new Oneof. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(Oneof) will not work. +func NewOneof(s *hyperpb.Shared) *Oneof { + m := s.NewMessage(tOneof.Get()) + return (*Oneof)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *Oneof) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *Oneof) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetS1 extracts the value of hyperpb.test.Oneof.s1. +// +// This definition is undocumented in the .proto file. +func (x *Oneof) GetS1() int32 { + v := x.unsafe().GetInt32(0, 0) + return v +} + +// GetM1 extracts the value of hyperpb.test.Oneof.m1. +// +// This definition is undocumented in the .proto file. +func (x *Oneof) GetM1() int32 { + v := x.unsafe().GetInt32(1, 0) + return v +} + +// GetM2 extracts the value of hyperpb.test.Oneof.m2. +// +// This definition is undocumented in the .proto file. +func (x *Oneof) GetM2() int64 { + v := x.unsafe().GetInt64(2, 0) + return v +} + +// GetM3 extracts the value of hyperpb.test.Oneof.m3. +// +// This definition is undocumented in the .proto file. +func (x *Oneof) GetM3() int32 { + v := x.unsafe().GetInt32(3, 0) + return v +} + +// GetM4 extracts the value of hyperpb.test.Oneof.m4. +// +// This definition is undocumented in the .proto file. +func (x *Oneof) GetM4() int64 { + v := x.unsafe().GetInt64(4, 0) + return v +} + +// GetM5 extracts the value of hyperpb.test.Oneof.m5. +// +// This definition is undocumented in the .proto file. +func (x *Oneof) GetM5() uint32 { + v := x.unsafe().GetUint32(5, 0) + return v +} + +// GetM6 extracts the value of hyperpb.test.Oneof.m6. +// +// This definition is undocumented in the .proto file. +func (x *Oneof) GetM6() uint64 { + v := x.unsafe().GetUint64(6, 0) + return v +} + +// GetM7 extracts the value of hyperpb.test.Oneof.m7. +// +// This definition is undocumented in the .proto file. +func (x *Oneof) GetM7() bool { + v := x.unsafe().GetBool(7, false) + return v +} + +// GetM8 extracts the value of hyperpb.test.Oneof.m8. +// +// This definition is undocumented in the .proto file. +func (x *Oneof) GetM8() string { + v := x.unsafe().GetString(8, "") + return v +} + +// GetM9 extracts the value of hyperpb.test.Oneof.m9. +// +// This definition is undocumented in the .proto file. +func (x *Oneof) GetM9() []byte { + v := x.unsafe().GetBytes(9, "") + return v +} + +// GetM10 extracts the value of hyperpb.test.Oneof.m10. +// +// This definition is undocumented in the .proto file. +func (x *Oneof) GetM10() *Oneof { + v := x.unsafe().GetMessage(10) + return (*Oneof)(v) +} + +// GetTail extracts the value of hyperpb.test.Oneof.tail. +// +// This definition is undocumented in the .proto file. +func (x *Oneof) GetTail() int32 { + v := x.unsafe().GetInt32(11, 0) + return v +} + +// ProtoReflect implements proto.Message. +func (x *Oneof) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*Oneof) HyperMessage(export.DoNotImplement, *Oneof) {} + +func (x *Oneof) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *Oneof) unsafe() *export.UnsafeMessage { return (*export.UnsafeMessage)(unsafe.Pointer(x)) } + +// Maps is undocumented in the .proto file. +type Maps struct{ _ hyperpb.Message } + +var tMaps export.Type + +func init() { tMaps.Init("hyperpb.test.Maps") } + +// NewMaps allocates a new Maps. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(Maps) will not work. +func NewMaps(s *hyperpb.Shared) *Maps { + m := s.NewMessage(tMaps.Get()) + return (*Maps)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *Maps) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *Maps) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// ProtoReflect implements proto.Message. +func (x *Maps) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*Maps) HyperMessage(export.DoNotImplement, *Maps) {} + +func (x *Maps) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *Maps) unsafe() *export.UnsafeMessage { return (*export.UnsafeMessage)(unsafe.Pointer(x)) } + +// MessageMaps is undocumented in the .proto file. +type MessageMaps struct{ _ hyperpb.Message } + +var tMessageMaps export.Type + +func init() { tMessageMaps.Init("hyperpb.test.MessageMaps") } + +// NewMessageMaps allocates a new MessageMaps. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(MessageMaps) will not work. +func NewMessageMaps(s *hyperpb.Shared) *MessageMaps { + m := s.NewMessage(tMessageMaps.Get()) + return (*MessageMaps)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *MessageMaps) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *MessageMaps) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetScalars extracts the value of hyperpb.test.MessageMaps.scalars. +// +// This definition is undocumented in the .proto file. +func (x *MessageMaps) GetScalars() *Scalars { + v := x.unsafe().GetMessage(0) + return (*Scalars)(v) +} + +// ProtoReflect implements proto.Message. +func (x *MessageMaps) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*MessageMaps) HyperMessage(export.DoNotImplement, *MessageMaps) {} + +func (x *MessageMaps) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *MessageMaps) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// A message with a repeated message field that has many, many fields, but +// only one of which winds up being set. +type Pathological struct{ _ hyperpb.Message } + +var tPathological export.Type + +func init() { tPathological.Init("hyperpb.test.Pathological") } + +// NewPathological allocates a new Pathological. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(Pathological) will not work. +func NewPathological(s *hyperpb.Shared) *Pathological { + m := s.NewMessage(tPathological.Get()) + return (*Pathological)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *Pathological) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *Pathological) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetX extracts the value of hyperpb.test.Pathological.x. +// +// This definition is undocumented in the .proto file. +func (x *Pathological) GetX() hyperpb.List[*Pathological_Inner] { + v := x.unsafe().GetRepeatedMessage(0) + return export.CastRepeatedMessage[*Pathological_Inner](v) +} + +// ProtoReflect implements proto.Message. +func (x *Pathological) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*Pathological) HyperMessage(export.DoNotImplement, *Pathological) {} + +func (x *Pathological) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *Pathological) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} + +// Pathological_Inner is undocumented in the .proto file. +type Pathological_Inner struct{ _ hyperpb.Message } + +var tPathological_Inner export.Type + +func init() { tPathological_Inner.Init("hyperpb.test.Pathological.Inner") } + +// NewPathological_Inner allocates a new Pathological_Inner. +// +// s should usually be nil, but it may be used to re-use resources between messages; see [hyperpb.Shared.NewMessage]. +// +// Only this function can create valid values; new(Pathological_Inner) will not work. +func NewPathological_Inner(s *hyperpb.Shared) *Pathological_Inner { + m := s.NewMessage(tPathological_Inner.Get()) + return (*Pathological_Inner)(unsafe.Pointer(m)) +} + +// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific +// tuning options to be set. +// +// See [hyperpb.Message.Unmarshal]. +func (x *Pathological_Inner) Unmarshal(data []byte, options ...hyperpb.UnmarshalOption) error { + return x.impl().Unmarshal(data, options...) +} + +// Shared returns state shared by this message and its submessages. +func (x *Pathological_Inner) Shared() *hyperpb.Shared { + return x.impl().Shared() +} + +// GetX1 extracts the value of hyperpb.test.Pathological.Inner.x1. +// +// This definition is undocumented in the .proto file. +func (x *Pathological_Inner) GetX1() int32 { + v := x.unsafe().GetInt32(0, 0) + return v +} + +// GetX2 extracts the value of hyperpb.test.Pathological.Inner.x2. +// +// This definition is undocumented in the .proto file. +func (x *Pathological_Inner) GetX2() int32 { + v := x.unsafe().GetInt32(1, 0) + return v +} + +// GetX3 extracts the value of hyperpb.test.Pathological.Inner.x3. +// +// This definition is undocumented in the .proto file. +func (x *Pathological_Inner) GetX3() int32 { + v := x.unsafe().GetInt32(2, 0) + return v +} + +// GetX4 extracts the value of hyperpb.test.Pathological.Inner.x4. +// +// This definition is undocumented in the .proto file. +func (x *Pathological_Inner) GetX4() int32 { + v := x.unsafe().GetInt32(3, 0) + return v +} + +// GetX5 extracts the value of hyperpb.test.Pathological.Inner.x5. +// +// This definition is undocumented in the .proto file. +func (x *Pathological_Inner) GetX5() int32 { + v := x.unsafe().GetInt32(4, 0) + return v +} + +// GetX6 extracts the value of hyperpb.test.Pathological.Inner.x6. +// +// This definition is undocumented in the .proto file. +func (x *Pathological_Inner) GetX6() int32 { + v := x.unsafe().GetInt32(5, 0) + return v +} + +// GetX7 extracts the value of hyperpb.test.Pathological.Inner.x7. +// +// This definition is undocumented in the .proto file. +func (x *Pathological_Inner) GetX7() int32 { + v := x.unsafe().GetInt32(6, 0) + return v +} + +// GetX8 extracts the value of hyperpb.test.Pathological.Inner.x8. +// +// This definition is undocumented in the .proto file. +func (x *Pathological_Inner) GetX8() int32 { + v := x.unsafe().GetInt32(7, 0) + return v +} + +// GetX9 extracts the value of hyperpb.test.Pathological.Inner.x9. +// +// This definition is undocumented in the .proto file. +func (x *Pathological_Inner) GetX9() int32 { + v := x.unsafe().GetInt32(8, 0) + return v +} + +// GetXa extracts the value of hyperpb.test.Pathological.Inner.xa. +// +// This definition is undocumented in the .proto file. +func (x *Pathological_Inner) GetXa() int32 { + v := x.unsafe().GetInt32(9, 0) + return v +} + +// GetXb extracts the value of hyperpb.test.Pathological.Inner.xb. +// +// This definition is undocumented in the .proto file. +func (x *Pathological_Inner) GetXb() int32 { + v := x.unsafe().GetInt32(10, 0) + return v +} + +// GetXc extracts the value of hyperpb.test.Pathological.Inner.xc. +// +// This definition is undocumented in the .proto file. +func (x *Pathological_Inner) GetXc() int32 { + v := x.unsafe().GetInt32(11, 0) + return v +} + +// GetXd extracts the value of hyperpb.test.Pathological.Inner.xd. +// +// This definition is undocumented in the .proto file. +func (x *Pathological_Inner) GetXd() int32 { + v := x.unsafe().GetInt32(12, 0) + return v +} + +// GetXe extracts the value of hyperpb.test.Pathological.Inner.xe. +// +// This definition is undocumented in the .proto file. +func (x *Pathological_Inner) GetXe() int32 { + v := x.unsafe().GetInt32(13, 0) + return v +} + +// GetXf extracts the value of hyperpb.test.Pathological.Inner.xf. +// +// This definition is undocumented in the .proto file. +func (x *Pathological_Inner) GetXf() int32 { + v := x.unsafe().GetInt32(14, 0) + return v +} + +// GetActual extracts the value of hyperpb.test.Pathological.Inner.actual. +// +// This definition is undocumented in the .proto file. +func (x *Pathological_Inner) GetActual() string { + v := x.unsafe().GetString(15, "") + return v +} + +// ProtoReflect implements proto.Message. +func (x *Pathological_Inner) ProtoReflect() protoreflect.Message { + return export.Reflect(x) +} + +func (*Pathological_Inner) HyperMessage(export.DoNotImplement, *Pathological_Inner) {} + +func (x *Pathological_Inner) impl() *hyperpb.Message { return (*hyperpb.Message)(unsafe.Pointer(x)) } + +func (x *Pathological_Inner) unsafe() *export.UnsafeMessage { + return (*export.UnsafeMessage)(unsafe.Pointer(x)) +} diff --git a/internal/gencode/gencode_test.go b/internal/gencode/gencode_test.go new file mode 100644 index 0000000..478d158 --- /dev/null +++ b/internal/gencode/gencode_test.go @@ -0,0 +1,103 @@ +// Copyright 2025 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package gencode_test + +import ( + "math" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" + + testpb "buf.build/go/hyperpb/internal/gen/test" + testhy "buf.build/go/hyperpb/internal/gen/test/hyper-test" +) + +func TestSmoke(t *testing.T) { + t.Parallel() + + t.Run("ints", func(t *testing.T) { + t.Parallel() + + want := &testpb.Scalars{ + A1: 42, + B1: proto.Int32(42), + } + data, err := proto.Marshal(want) + require.NoError(t, err) + + got := testhy.NewScalars(nil) + err = proto.Unmarshal(data, got) + require.NoError(t, err) + + assert.Equal(t, want.GetA1(), got.GetA1()) + assert.Equal(t, want.GetB1(), got.GetB1()) + assert.True(t, got.HasB1()) + }) + + t.Run("repeated", func(t *testing.T) { + t.Parallel() + + want := &testpb.Repeated{ + R1: []int32{math.MinInt32, math.MaxInt32}, + R4: []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, + R7: []string{"foo", "bar", "baz"}, + } + data, err := proto.Marshal(want) + require.NoError(t, err) + + got := testhy.NewRepeated(nil) + err = proto.Unmarshal(data, got) + require.NoError(t, err) + + assert.Equal(t, want.R1, got.GetR1().Copy(nil)) + assert.Equal(t, want.R4, got.GetR4().Copy(nil)) + assert.Equal(t, want.R7, got.GetR7().Copy(nil)) + }) + + t.Run("messages", func(t *testing.T) { + t.Parallel() + + want := &testpb.Graph{ + V: 1, + S: &testpb.Graph{ + V: 2, + R: []*testpb.Graph{ + {V: 3}, + {V: 4}, + }, + }, + } + data, err := proto.Marshal(want) + require.NoError(t, err) + + got := testhy.NewGraph(nil) + err = proto.Unmarshal(data, got) + require.NoError(t, err) + + assert.Equal(t, want.V, got.GetV()) + assert.Equal(t, want.S.V, got.GetS().GetV()) + assert.Equal(t, len(want.R), got.GetR().Len()) + assert.Equal(t, len(want.S.R), got.GetS().GetR().Len()) + for i, g1 := range want.S.R { + g2 := got.GetS().GetR().Get(i) + assert.Equal(t, g1.V, g2.GetV()) + assert.Nil(t, g2.GetS()) + assert.Equal(t, int32(0), g2.GetS().GetV()) + assert.Equal(t, len(g1.R), g2.GetR().Len()) + } + }) +} diff --git a/internal/gencode/generator/generator.go b/internal/gencode/generator/generator.go new file mode 100644 index 0000000..46a0237 --- /dev/null +++ b/internal/gencode/generator/generator.go @@ -0,0 +1,518 @@ +// Copyright 2025 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package generator + +import ( + "fmt" + "math" + "path/filepath" + "strconv" + + "google.golang.org/protobuf/compiler/protogen" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/types/descriptorpb" + + "buf.build/go/hyperpb/internal/gencode/printer" + "buf.build/go/hyperpb/internal/gencode/wkt" +) + +type Generator struct { + // Set of messages whose identifiers' paths have been updated. + updated map[*protogen.Message]struct{} +} + +func (g *Generator) Generate(pl *protogen.Plugin, subdir string, f *protogen.File) { + dir := filepath.Dir(f.GeneratedFilenamePrefix) + base := filepath.Base(f.GeneratedFilenamePrefix) + path := filepath.Join(dir, subdir, base+".pb.go") + + origPath := f.GoImportPath + g.updatePkg(f, subdir) + + fg := &file{ + Printer: printer.NewPrinter(pl.NewGeneratedFile(path, f.GoImportPath)), + pl: pl, + file: f, + ordinary: origPath, + subdir: subdir, + } + fg.Run() +} + +func (g *Generator) updatePkg(f *protogen.File, subdir string) { + f.GoImportPath += protogen.GoImportPath("/" + subdir) + for _, m := range f.Messages { + g.updateMessagePkg(m, subdir) + } +} + +func (g *Generator) updateMessagePkg(m *protogen.Message, subdir string) { + if _, ok := g.updated[m]; ok { + return + } + if g.updated == nil { + g.updated = make(map[*protogen.Message]struct{}) + } + + g.updated[m] = struct{}{} + m.GoIdent.GoImportPath += protogen.GoImportPath("/" + subdir) + + for _, m := range m.Messages { + g.updateMessagePkg(m, subdir) + } +} + +type file struct { + *printer.Printer + pl *protogen.Plugin + file *protogen.File + ordinary protogen.GoImportPath + subdir string + + deprecated bool + + // Current source code info path. + scPath []int32 +} + +func (f *file) Run() { + //nolint:errcheck + f.deprecated = f.file.Desc.Options().(*descriptorpb.FileOptions).GetDeprecated() + + loc := f.LocationIn(wkt.FileDescriptorProto_Syntax) + f.DetachedLeadingComments(loc) + f.P("\n") + f.P("// Code generated by protoc-gen-hyperpb. DO NOT EDIT.\n") + f.P("// source: %s\n", f.file.Desc.Path()) + f.P("\n") + loc = f.LocationIn(wkt.FileDescriptorProto_Package) + f.DetachedLeadingComments(loc) + f.P("\n") + f.P("package %s\n\n", f.file.GoPackageName) + + imports := f.file.Desc.Imports() + for i := range imports.Len() { + f.Import(imports.Get(i)) + } + f.GeneratedFile.Import(f.ordinary) + + f.Messages(wkt.FileDescriptorProto_Messages, f.file.Messages) + + _ = f.Finish() +} + +func (f *file) Import(imp protoreflect.FileImport) { + file, ok := f.pl.FilesByPath[imp.Path()] + if !ok { + return + } + + path := file.GoImportPath + path += "/" + path += protogen.GoImportPath(f.subdir) + + if path == f.file.GoImportPath { + return + } + + // Generate imports for all dependencies, even if they are not + // referenced, because other code and tools depend on having the + // full transitive closure of protocol buffer types in the binary. + f.GeneratedFile.Import(path) + if !imp.IsPublic { + return + } + + // TODO: Public import forwards. + f.Messages(wkt.FileDescriptorProto_Messages, f.file.Messages) +} + +func (f *file) Messages(fd protoreflect.FieldDescriptor, mds []*protogen.Message) { + for i, md := range mds { + f.InList(fd, i, func() { f.Message(md) }) + } +} + +func (f *file) Message(md *protogen.Message) { + if md.Desc.IsMapEntry() { + return + } + + f.AnnotateSymbol(md.GoIdent.GoName, protogen.Annotation{ + Location: md.Location, + }) + f.DefComments(md.GoIdent.GoName, f.Location()) + f.Deprecated(md.Desc) + + f.P("type %s struct { _ hyperpb.Message }\n\n", md.GoIdent.GoName) + f.P("var t%s %s\n\n", md.GoIdent.GoName, exportType) + f.P("func init() { t%s.Init(%q) }\n\n", md.GoIdent.GoName, md.Desc.FullName()) + + f.P("// New%s allocates a new %s.\n", md.GoIdent.GoName, md.GoIdent.GoName) + f.P("//\n") + f.P("// s should usually be nil, but it may be used to re-use resources " + + "between messages; see [hyperpb.Shared.NewMessage].\n") + f.P("//\n") + f.P("// Only this function can create valid values; new(%s) will not work.\n", md.GoIdent.GoName) + f.P("func New%s(s *%s) *%s ", + md.GoIdent.GoName, + hyperpbShared, + md.GoIdent.GoName, + ) + f.Block("{", "}", func() { + f.P("m := s.NewMessage(t%s.Get())\n", md.GoIdent.GoName) + f.P("return (*%s)(%s(m))\n", md.GoIdent.GoName, unsafePointer) + }) + f.P("\n\n") + + f.P("// Unmarshal is like [proto.Unmarshal], but permits hyperpb-specific\n") + f.P("// tuning options to be set.\n") + f.P("//\n") + f.P("// See [hyperpb.Message.Unmarshal].\n") + f.P("func (x *%s) Unmarshal(data []byte, options ...%s) error ", md.GoIdent.GoName, hyperpbOption) + f.Block("{", "}", func() { + f.P("return x.impl().Unmarshal(data, options...)\n") + }) + f.P("\n\n") + + f.P("// Shared returns state shared by this message and its submessages.\n") + f.P("func (x *%s) Shared() *%s ", md.GoIdent.GoName, hyperpbShared) + f.Block("{", "}", func() { + f.P("return x.impl().Shared()\n") + }) + f.P("\n\n") + + for i, fd := range md.Fields { + f.InList(wkt.MessageDescriptorProto_Fields, i, func() { + switch { + case fd.Desc.IsList(): + f.Repeated(md, fd) + case fd.Desc.IsMap(): + return + default: + f.Singular(md, fd) + } + }) + } + + f.P("// ProtoReflect implements proto.Message.\n") + f.P("func (x *%s) ProtoReflect() %s ", md.GoIdent.GoName, reflectMessage) + f.Block("{", "}", func() { + f.P("return %s(x)\n", exportReflect) + }) + f.P("\n\n") + + f.P("func (*%s) HyperMessage(%s, *%s) {}\n\n", + md.GoIdent.GoName, + exportDNI, + md.GoIdent.GoName, + ) + + f.P("func (x *%s) impl() *%s { return (*%[2]s)(%s(x)) }\n\n", + md.GoIdent.GoName, + hyperpbMessage, + unsafePointer, + md.GoIdent.GoName, + ) + + f.P("func (x *%s) unsafe() *%s { return (*%[2]s)(%s(x)) }\n\n", + md.GoIdent.GoName, + exportMessage, + unsafePointer, + md.GoIdent.GoName, + ) + + f.Messages(wkt.MessageDescriptorProto_Messages, md.Messages) +} + +//nolint:goconst +func (f *file) Singular(md *protogen.Message, fd *protogen.Field) { + var ty any + var unsafeGetter string + kind := fd.Desc.Kind() + switch kind { + case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind: + ty = "int32" + unsafeGetter = "GetInt32" + case protoreflect.Uint32Kind, protoreflect.Fixed32Kind: + ty = "uint32" + unsafeGetter = "GetUint32" + case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind: + ty = "int64" + unsafeGetter = "GetInt64" + case protoreflect.Uint64Kind, protoreflect.Fixed64Kind: + ty = "uint64" + unsafeGetter = "GetUint64" + + case protoreflect.FloatKind: + ty = "float32" + unsafeGetter = "GetFloat32" + case protoreflect.DoubleKind: + ty = "float64" + unsafeGetter = "GetFloat64" + + case protoreflect.StringKind: + ty = "string" + unsafeGetter = "GetString" + case protoreflect.BytesKind: + ty = "[]byte" + unsafeGetter = "GetBytes" + case protoreflect.BoolKind: + ty = "bool" + unsafeGetter = "GetBool" + + case protoreflect.EnumKind: + ty = f.QualifiedGoIdent(fd.Enum.GoIdent) + unsafeGetter = "GetEnum" + case protoreflect.MessageKind, protoreflect.GroupKind: + ty = "*" + f.QualifiedGoIdent(fd.Message.GoIdent) + unsafeGetter = "GetMessage" + } + + var ifNil string + switch kind { + case protoreflect.FloatKind: + ifNil = fmt.Sprintf("%s(%#x)", + f.QualifiedGoIdent(mathFloat32), + math.Float32bits(float32(fd.Desc.Default().Float()))) + case protoreflect.DoubleKind: + ifNil = fmt.Sprintf("%s(%#x)", + f.QualifiedGoIdent(mathFloat64), + math.Float64bits(fd.Desc.Default().Float())) + + case protoreflect.MessageKind, protoreflect.GroupKind: + break + + case protoreflect.StringKind: + ifNil = strconv.Quote(fd.Desc.Default().String()) + case protoreflect.BytesKind: + ifNil = strconv.Quote(string(fd.Desc.Default().Bytes())) + + default: + ifNil = fd.Desc.Default().String() + } + if ifNil != "" { + ifNil = ", " + ifNil + } + + getter, _ := fd.MethodName("Get") + f.P("// %s extracts the value of %s.\n", getter, fd.Desc.FullName()) + f.P("//\n") + f.DefComments("", f.Location()) + f.P("func (x *%s) %s() %s ", + md.GoIdent.GoName, + getter, + ty, + ) + f.Block("{", "}", func() { + f.P("v := x.unsafe().%s(%d%s)\n", + unsafeGetter, + fd.Desc.Index(), + ifNil, + ) + + if enum := fd.Enum; enum != nil { + f.P("return %s(v)\n", ty) + return + } + + if message := fd.Message; message != nil { + f.P("return (%s)(v)\n", ty) + return + } + + f.P("return v\n") + }) + f.P("\n\n") + + if fd.Desc.HasOptionalKeyword() { + hazzer, _ := fd.MethodName("Has") + f.P("// %s checks whether %s is populated.\n", hazzer, fd.Desc.FullName()) + f.P("//\n") + f.P("// See [%s.%s].\n", md.GoIdent.GoName, unsafeGetter) + f.P("func (x *%s) %s() bool ", + md.GoIdent.GoName, + hazzer, + ) + f.Block("{", "}", func() { + f.P("return x.unsafe().Has(%d)\n", + fd.Desc.Index(), + ) + }) + f.P("\n\n") + } +} + +func (f *file) Repeated(md *protogen.Message, fd *protogen.Field) { + var ty, unsafeGetter string + kind := fd.Desc.Kind() + switch kind { + case protoreflect.Int32Kind: + ty = "int32" + unsafeGetter = "GetRepeatedInt32" + case protoreflect.Sint32Kind: + ty = "int32" + unsafeGetter = "GetRepeatedSint32" + case protoreflect.Sfixed32Kind: + ty = "int32" + unsafeGetter = "GetRepeatedSfixed32" + + case protoreflect.Uint32Kind: + ty = "uint32" + unsafeGetter = "GetRepeatedUint32" + case protoreflect.Fixed32Kind: + ty = "uint32" + unsafeGetter = "GetRepeatedFixed32" + + case protoreflect.Int64Kind: + ty = "int64" + unsafeGetter = "GetRepeatedInt64" + case protoreflect.Sint64Kind: + ty = "int64" + unsafeGetter = "GetRepeatedSint64" + case protoreflect.Sfixed64Kind: + ty = "int64" + unsafeGetter = "GetRepeatedSfixed64" + + case protoreflect.Uint64Kind: + ty = "uint64" + unsafeGetter = "GetRepeatedUint64" + case protoreflect.Fixed64Kind: + ty = "uint64" + unsafeGetter = "GetRepeatedFixed64" + + case protoreflect.FloatKind: + ty = "float32" + unsafeGetter = "GetRepeatedFloat32" + case protoreflect.DoubleKind: + ty = "float64" + unsafeGetter = "GetRepeatedFloat64" + + case protoreflect.StringKind: + ty = "string" + unsafeGetter = "GetRepeatedString" + case protoreflect.BytesKind: + ty = "[]byte" + unsafeGetter = "GetRepeatedBytes" + case protoreflect.BoolKind: + ty = "bool" + unsafeGetter = "GetRepeatedBool" + + case protoreflect.EnumKind: + ty = f.QualifiedGoIdent(fd.Enum.GoIdent) + unsafeGetter = "GetRepeatedEnum" + + case protoreflect.MessageKind, protoreflect.GroupKind: + ty = "*" + f.QualifiedGoIdent(fd.Message.GoIdent) + unsafeGetter = "GetRepeatedMessage" + } + + getter, _ := fd.MethodName("Get") + f.P("// %s extracts the value of %s.\n", getter, fd.Desc.FullName()) + f.P("//\n") + f.DefComments("", f.Location()) + f.P("func (x *%s) %s() %s[%s] ", + md.GoIdent.GoName, + getter, + hyperpbList, + ty, + ) + f.Block("{", "}", func() { + f.P("v := x.unsafe().%s(%d)\n", + unsafeGetter, + fd.Desc.Index(), + ) + + if enum := fd.Enum; enum != nil { + f.P("return %s[%s](v)\n", exportCastEnum, ty) + return + } + + if message := fd.Message; message != nil { + f.P("return %s[%s](v)\n", exportCastMessage, ty) + return + } + + f.P("return v\n") + }) + f.P("\n\n") +} + +// In runs a callback in the context of a particular field descriptor, necessary +// for source code info lookups to work correctly. +func (f *file) In(fd protoreflect.FieldDescriptor, body func()) { + f.scPath = append(f.scPath, int32(fd.Number())) + body() + f.scPath = f.scPath[:len(f.scPath)-1] +} + +// InList is like In, but for recursing into a repeated field. +func (f *file) InList(fd protoreflect.FieldDescriptor, n int, body func()) { + f.scPath = append(f.scPath, int32(fd.Number()), int32(n)) + body() + f.scPath = f.scPath[:len(f.scPath)-2] +} + +// Location returns the source location for the current position. +func (f *file) Location() protoreflect.SourceLocation { + return f.file.Desc.SourceLocations().ByPath(f.scPath) +} + +// LocationIn returns the source location for a field of the current position. +func (f *file) LocationIn(fd protoreflect.FieldDescriptor) protoreflect.SourceLocation { + return f.file.Desc.SourceLocations().ByPath(append(f.scPath, int32(fd.Number()))) +} + +func (f *file) DefComments(name string, loc protoreflect.SourceLocation) { + if c := loc.LeadingComments; c != "" { + f.P("%v", protogen.Comments(c)) + return + } + + if name == "" { + name = "This definition" + } + + f.P("// %v is undocumented in the .proto file.\n", name) +} + +// Deprecated prints deprecation warnings. +func (f *file) Deprecated(node interface { + FullName() protoreflect.FullName + Options() proto.Message +}, +) { + if f.deprecated { + f.P("//\n// Deprecated: the file %s is marked as deprecated.", f.file.Desc.Path()) + return + } + + //nolint:errcheck + options := node.Options().(interface{ GetDeprecated() bool }) + if options.GetDeprecated() { + f.P("//\n// Deprecated: %s is marked as deprecated.", node.FullName()) + } +} + +func (f *file) DetachedLeadingComments(loc protoreflect.SourceLocation) { + for _, c := range loc.LeadingDetachedComments { + f.P("%v\n", protogen.Comments(c)) + } + + if c := loc.LeadingComments; c != "" { + f.P("%v\n", protogen.Comments(c)) + } +} diff --git a/internal/gencode/generator/idents.go b/internal/gencode/generator/idents.go new file mode 100644 index 0000000..69fef08 --- /dev/null +++ b/internal/gencode/generator/idents.go @@ -0,0 +1,85 @@ +// Copyright 2025 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package generator + +import "google.golang.org/protobuf/compiler/protogen" + +const ( + hyperpbPath = "buf.build/go/hyperpb" + hyperpbExportPath = "buf.build/go/hyperpb/cmd/protoc-gen-hyperpb/export" + protoreflectPkgPath = "google.golang.org/protobuf/reflect/protoreflect" +) + +var ( + hyperpbMessage = protogen.GoIdent{ + GoImportPath: hyperpbPath, + GoName: "Message", + } + hyperpbNew = protogen.GoIdent{ + GoImportPath: hyperpbPath, + GoName: "NewMessage", + } + hyperpbList = protogen.GoIdent{ + GoImportPath: hyperpbPath, + GoName: "List", + } + hyperpbShared = protogen.GoIdent{ + GoImportPath: hyperpbPath, + GoName: "Shared", + } + hyperpbOption = protogen.GoIdent{ + GoImportPath: hyperpbPath, + GoName: "UnmarshalOption", + } + + exportType = protogen.GoIdent{ + GoImportPath: hyperpbExportPath, + GoName: "Type", + } + exportReflect = protogen.GoIdent{ + GoImportPath: hyperpbExportPath, + GoName: "Reflect", + } + exportDNI = protogen.GoIdent{ + GoImportPath: hyperpbExportPath, + GoName: "DoNotImplement", + } + exportMessage = protogen.GoIdent{ + GoImportPath: hyperpbExportPath, + GoName: "UnsafeMessage", + } + exportCastEnum = protogen.GoIdent{ + GoImportPath: hyperpbExportPath, + GoName: "CastRepeatedEnum", + } + exportCastMessage = protogen.GoIdent{ + GoImportPath: hyperpbExportPath, + GoName: "CastRepeatedMessage", + } + + reflectMessage = protogen.GoIdent{ + GoImportPath: protoreflectPkgPath, + GoName: "Message", + } + reflectType = protogen.GoIdent{ + GoImportPath: protoreflectPkgPath, + GoName: "MessageType", + } + + unsafePointer = protogen.GoIdent{GoImportPath: "unsafe", GoName: "Pointer"} + + mathFloat32 = protogen.GoIdent{GoImportPath: "math", GoName: "Float32frombits"} + mathFloat64 = protogen.GoIdent{GoImportPath: "math", GoName: "Float64frombits"} +) diff --git a/internal/gencode/generator/main.go b/internal/gencode/generator/main.go new file mode 100644 index 0000000..752bf3e --- /dev/null +++ b/internal/gencode/generator/main.go @@ -0,0 +1,78 @@ +// Copyright 2025 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package generator + +import ( + "flag" + "fmt" + "os" + "path/filepath" + "runtime/debug" + + "google.golang.org/protobuf/compiler/protogen" + "google.golang.org/protobuf/types/descriptorpb" + "google.golang.org/protobuf/types/gofeaturespb" + "google.golang.org/protobuf/types/pluginpb" +) + +const ( + genGoDocURL = "https://protobuf.dev/reference/go/go-generated" + SupportedFeatures = uint64( + pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL | + pluginpb.CodeGeneratorResponse_FEATURE_SUPPORTS_EDITIONS) + + MinEdition = descriptorpb.Edition_EDITION_PROTO2 + MaxEdition = descriptorpb.Edition_EDITION_2023 +) + +// Main is the main function of the generator. This is called by main() in +// the actual main package. +func Main() { + if len(os.Args) == 2 && os.Args[1] == "--version" { + fmt.Fprintf(os.Stdout, "%v %v\n", filepath.Base(os.Args[0]), version()) + return + } + + if len(os.Args) == 2 && os.Args[1] == "--help" { + fmt.Fprintf(os.Stdout, "See "+genGoDocURL+" for usage information.\n") + return + } + + var flags flag.FlagSet + protogen.Options{ + ParamFunc: flags.Set, + DefaultAPILevel: gofeaturespb.GoFeatures_API_OPAQUE, + }.Run(func(pl *protogen.Plugin) error { + g := new(Generator) + for _, f := range pl.Files { + if f.Generate { + g.Generate(pl, "hyper-"+string(f.GoPackageName), f) + } + } + + pl.SupportedFeatures = SupportedFeatures + pl.SupportedEditionsMinimum = MinEdition + pl.SupportedEditionsMaximum = MaxEdition + return nil + }) +} + +func version() string { + build, ok := debug.ReadBuildInfo() + if !ok { + return "" + } + return build.Main.Version +} diff --git a/internal/gencode/message.go b/internal/gencode/message.go new file mode 100644 index 0000000..3e91f69 --- /dev/null +++ b/internal/gencode/message.go @@ -0,0 +1,30 @@ +// Copyright 2025 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package constraint defines an interface satisfied by any pointer to a gencode +// type. +package gencode + +import ( + "google.golang.org/protobuf/proto" +) + +// DoNotImplement indicates that something should not be implemented. +type DoNotImplement struct{ _ struct{} } + +// Message is a pointer to a type generated by protoc-gen-hyperpb. +type Message[M any] interface { + proto.Message + HyperMessage(DoNotImplement, *M) +} diff --git a/internal/gencode/printer/caller.go b/internal/gencode/printer/caller.go new file mode 100644 index 0000000..32209c9 --- /dev/null +++ b/internal/gencode/printer/caller.go @@ -0,0 +1,43 @@ +// Copyright 2025 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package printer + +import ( + "runtime" + "strings" +) + +var root = func() string { + _, f, _, ok := runtime.Caller(1) + if !ok { + return "" + } + + f, ok = strings.CutSuffix(f, "internal/gencode/printer/caller.go") + if !ok { + panic("hyperpb: caller.go appears to have moved") + } + + return f +}() + +// Caller returns the file and line of its caller, adjusted for pretty-printing. +// +// Returns "", 0 if the binary was stripped. +func Caller() (file string, line int) { + _, file, line, _ = runtime.Caller(1) + file = strings.TrimPrefix(file, root) + return file, line +} diff --git a/internal/gencode/printer/printer.go b/internal/gencode/printer/printer.go new file mode 100644 index 0000000..484d907 --- /dev/null +++ b/internal/gencode/printer/printer.go @@ -0,0 +1,144 @@ +// Copyright 2025 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package gencode provides helpers for printing generated code. +package printer + +import ( + "bytes" + "fmt" + "strings" + + "google.golang.org/protobuf/compiler/protogen" +) + +// Printer is a gencode pretty-printer. +// +// The zero value is ready to use. +type Printer struct { + *protogen.GeneratedFile + buf indented + + // If true, printing will show the site at which a print function was called. + trace bool +} + +// NewPrinter wraps a [protogen.GenreatedFile]. +func NewPrinter(g *protogen.GeneratedFile) *Printer { + return &Printer{GeneratedFile: g} +} + +// SetTrace sets whether this printer should print trace comments. +func (p *Printer) SetTrace(trace bool) { + p.trace = trace +} + +// P prints some text directly to this printer. +func (p *Printer) P(format string, args ...any) { + var comment string + if p.trace { + file, line := Caller() + if file != "" { + file = strings.TrimPrefix(file, "buf.build/go/hyperpb/") + comment = fmt.Sprintf("// %s:%d", file, line) + } + } + + for i, arg := range args { + if id, ok := arg.(protogen.GoIdent); ok { + args[i] = p.QualifiedGoIdent(id) + } + } + + comment, p.buf.comment = p.buf.comment, comment + fmt.Fprintf(&p.buf, format, args...) + p.buf.comment = comment +} + +// Block helps with printing a delimited multi-line block. open/close are +// the delimiters, such as "{" and "}". All printing of the contents of the +// block should happen in body. +func (p *Printer) Block(open, close string, body func()) { + var comment string + if p.trace { + file, line := Caller() + if file != "" { + file = strings.TrimPrefix(file, "buf.build/go/hyperpb/") + comment = fmt.Sprintf("// %s:%d", file, line) + } + } + + comment, p.buf.comment = p.buf.comment, comment + p.buf.buf.WriteString(open) + backtrack := p.buf.buf.Len() + + fmt.Fprintln(&p.buf) + mark := p.buf.buf.Len() + + p.buf.indent++ + body() + p.buf.indent-- + + if p.buf.buf.Len() == mark { + // Nothing got printed. Get rid of the newline. + p.buf.buf.Truncate(backtrack) + } else if p.buf.indented { + // Need a newline before the close. + fmt.Fprintln(&p.buf) + } + + p.buf.buf.WriteString(close) + p.buf.comment = comment +} + +// Write implements [io.Writer]. +func (p *Printer) Write(buf []byte) (int, error) { + return p.buf.Write(buf) +} + +// Finish dumps this printer's buffer into the given writer. +func (p *Printer) Finish() error { + _, err := p.GeneratedFile.Write(p.buf.buf.Bytes()) + return err +} + +type indented struct { + buf bytes.Buffer + indent int // Number of tabs to indent with. + indented bool // Whether or not we have already indented the current line. + + comment string // Used to print debugging information. +} + +func (i *indented) Write(buf []byte) (int, error) { + n := len(buf) + for len(buf) > 0 { + line, rest, nl := bytes.Cut(buf, []byte("\n")) + buf = rest + if len(line) > 0 && !i.indented { + for range i.indent { + i.buf.WriteByte('\t') + } + i.indented = true + } + i.buf.Write(line) + if nl { + i.buf.WriteString(i.comment) + i.buf.WriteByte('\n') + i.indented = false + } + } + + return n, nil +} diff --git a/internal/gencode/reflect.go b/internal/gencode/reflect.go new file mode 100644 index 0000000..b0f37bd --- /dev/null +++ b/internal/gencode/reflect.go @@ -0,0 +1,65 @@ +// Copyright 2025 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package gencode contains helpers used by protoc-gen-hyperpb's gencode. +package gencode + +import ( + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + + "buf.build/go/hyperpb" + "buf.build/go/hyperpb/internal/xunsafe" +) + +// Reflect returns a type reflection value for M. +func Reflect[P Message[M], M any](m P) protoreflect.Message { + return xunsafe.BitCast[*reflectMessage[P, M]](m) +} + +// reflectMessage is a wrapper that implements [protoreflect.Message] for M. +type reflectMessage[P Message[M], M any] struct{ message } + +func (r *reflectMessage[P, M]) Interface() proto.Message { + //nolint:errcheck + return xunsafe.BitCast[P](r.message.Interface().(*hyperpb.Message)) +} + +func (r *reflectMessage[P, M]) Type() protoreflect.MessageType { + return xunsafe.Cast[reflectType[P, M]](r.HyperType()) +} + +func (r *reflectMessage[P, M]) New() protoreflect.Message { + return xunsafe.Cast[reflectMessage[P, M]](hyperpb.NewMessage(r.HyperType())) +} + +// reflectType is a wrapper that implements [protoreflect.MessageType] for M. +type reflectType[P Message[M], M any] struct{ typ } + +func (t *reflectType[P, M]) HyperType() *hyperpb.MessageType { + return &t.typ +} + +func (t *reflectType[P, M]) New() protoreflect.Message { + return xunsafe.Cast[reflectMessage[P, M]](hyperpb.NewMessage(t.HyperType())) +} + +func (t *reflectType[P, M]) Zero() protoreflect.Message { + return (*reflectMessage[P, M])(nil) +} + +type ( + message = hyperpb.Message + typ = hyperpb.MessageType +) diff --git a/internal/gencode/type.go b/internal/gencode/type.go new file mode 100644 index 0000000..c54ac05 --- /dev/null +++ b/internal/gencode/type.go @@ -0,0 +1,89 @@ +// Copyright 2025 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package gencode + +import ( + "fmt" + "sync/atomic" + + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" + + "buf.build/go/hyperpb" + "buf.build/go/hyperpb/internal/tdp" + "buf.build/go/hyperpb/internal/xunsafe" +) + +// This map is only written to during initialization, which all runs on the +// same goroutine, so it does not need lock protection. +var types = make(map[protoreflect.MessageDescriptor]*Type) + +// Type is a pointer to a compiled type that can be updated atomically by the +// gencode runtime. +// +// Gencode contains globals for each type relevant to it, which are registered +// with the gencode runtime at startup. +// +// We depend on the ordinary Protobuf Go gencode to provide us with compiled-in +// descriptors. +type Type struct { + desc protoreflect.MessageDescriptor + value atomic.Pointer[hyperpb.MessageType] +} + +// Init initializes a Type. +// +// This is meant to be called only once the desired type has landed in +// GlobalTypes, so its package must import the "ordinary" package to ensure +// correct ordering. +func (t *Type) Init(name protoreflect.FullName) { + ty, err := protoregistry.GlobalTypes.FindMessageByName(name) + if err != nil { + panic(fmt.Errorf("could not find descriptor for %s; this is a gencode bug", name)) + } + t.desc = ty.Descriptor() + types[t.desc] = t +} + +// Get returns the associated hyperpb.Type, or compiles it if necessary. +func (t *Type) Get() *hyperpb.MessageType { + p := t.value.Load() + if p != nil { + return p + } + + // Slow case. Need to compile a type. When we do, we use this as an + // opportunity to fill in types for all of its dependencies, too. + ty := hyperpb.CompileMessageDescriptor( + t.desc, + hyperpb.WithExtensionsFromTypes(protoregistry.GlobalTypes), + ) + + t.store(ty) + return ty +} + +// store records ty as the type for this value, and recurses into its dependent +// types. +func (t *Type) store(ty *hyperpb.MessageType) { + if t == nil || !t.value.CompareAndSwap(nil, ty) { + return + } + + // Update all of the submessage types if possible, too. + for t := range xunsafe.Cast[tdp.Type](ty).Submessages() { + types[t.Descriptor].store(xunsafe.Cast[hyperpb.MessageType](t)) + } +} diff --git a/internal/gencode/unsafe.go b/internal/gencode/unsafe.go new file mode 100644 index 0000000..bec8919 --- /dev/null +++ b/internal/gencode/unsafe.go @@ -0,0 +1,345 @@ +// Copyright 2025 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package gencode + +import ( + "math" + "unsafe" + + "google.golang.org/protobuf/reflect/protoreflect" + + "buf.build/go/hyperpb/internal/tdp/dynamic" + "buf.build/go/hyperpb/internal/tdp/repeated" + "buf.build/go/hyperpb/internal/xprotoreflect" + "buf.build/go/hyperpb/internal/xunsafe" +) + +// UnsafeMessage is a helper for extracting fields of specific types from a +// message type without performing any redundant safety checks. +type UnsafeMessage dynamic.Message + +// Raw returns the underlying dynamic message value. +func (u *UnsafeMessage) Raw() *dynamic.Message { + return xunsafe.Cast[dynamic.Message](u) +} + +// Has returns whether this singular field is populated or not. +func (u *UnsafeMessage) Has(index int) bool { + return u.Raw().GetByIndexUnchecked(index).IsValid() +} + +// GetInt32 gets a singular int32 field. +func (u *UnsafeMessage) GetInt32(index int, ifNil int32) int32 { + if u == nil { + return ifNil + } + + v := u.Raw().GetByIndexUnchecked(index) + r := xprotoreflect.GetRawInt(v) + return int32(r) +} + +// GetInt64 gets a singular int64 field. +func (u *UnsafeMessage) GetInt64(index int, ifNil int64) int64 { + if u == nil { + return ifNil + } + + v := u.Raw().GetByIndexUnchecked(index) + r := xprotoreflect.GetRawInt(v) + return int64(r) +} + +// GetUint32 gets a singular uint32 field. +func (u *UnsafeMessage) GetUint32(index int, ifNil uint32) uint32 { + if u == nil { + return ifNil + } + + v := u.Raw().GetByIndexUnchecked(index) + r := xprotoreflect.GetRawInt(v) + return uint32(r) +} + +// GetUint64 gets a singular uint64 field. +func (u *UnsafeMessage) GetUint64(index int, ifNil uint64) uint64 { + if u == nil { + return ifNil + } + + v := u.Raw().GetByIndexUnchecked(index) + r := xprotoreflect.GetRawInt(v) + return r +} + +// GetFloat32 gets a singular float32 field. +func (u *UnsafeMessage) GetFloat32(index int, ifNil float32) float32 { + if u == nil { + return ifNil + } + + v := u.Raw().GetByIndexUnchecked(index) + r := xprotoreflect.GetRawInt(v) + return math.Float32frombits(uint32(r)) +} + +// GetFloat64 gets a singular float64 field. +func (u *UnsafeMessage) GetFloat64(index int, ifNil float64) float64 { + if u == nil { + return ifNil + } + + v := u.Raw().GetByIndexUnchecked(index) + r := xprotoreflect.GetRawInt(v) + return math.Float64frombits(r) +} + +// GetBool gets a singular bool field. +func (u *UnsafeMessage) GetBool(index int, ifNil bool) bool { + if u == nil { + return ifNil + } + + v := u.Raw().GetByIndexUnchecked(index) + r := xprotoreflect.GetRawInt(v) + return r != 0 +} + +// GetEnum gets a singular enum field. +func (u *UnsafeMessage) GetEnum(index int, ifNil int32) protoreflect.EnumNumber { + return protoreflect.EnumNumber(u.GetInt32(index, ifNil)) +} + +// GetString gets a singular string field. +func (u *UnsafeMessage) GetString(index int, ifNil string) string { + if u == nil { + return ifNil + } + + v := u.Raw().GetByIndexUnchecked(index) + p := xprotoreflect.GetRawPointer(v) + n := xprotoreflect.GetRawInt(v) + return unsafe.String((*byte)(p), n) +} + +// GetBytes gets a singular bytes field. +func (u *UnsafeMessage) GetBytes(index int, ifNil string) []byte { + if u == nil { + return []byte(ifNil) + } + + v := u.Raw().GetByIndexUnchecked(index) + p := xprotoreflect.GetRawPointer(v) + n := xprotoreflect.GetRawInt(v) + return unsafe.Slice((*byte)(p), n) +} + +// GetMessage returns a singular message field. +func (u *UnsafeMessage) GetMessage(index int) unsafe.Pointer { + if u == nil { + return nil + } + + v := u.Raw().GetByIndexUnchecked(index) + p := xprotoreflect.GetRawPointer(v) + return p +} + +// GetRepeatedInt32 gets a repeated int32 field. +func (u *UnsafeMessage) GetRepeatedInt32(index int) *repeated.Scalars[byte, int32] { + if u == nil { + return nil + } + + v := u.Raw().GetByIndexUnchecked(index) + p := xprotoreflect.GetRawPointer(v) + return (*repeated.Scalars[byte, int32])(p) +} + +// GetRepeatedInt64 gets a singular int64 field. +func (u *UnsafeMessage) GetRepeatedInt64(index int) *repeated.Scalars[byte, int64] { + if u == nil { + return nil + } + + v := u.Raw().GetByIndexUnchecked(index) + p := xprotoreflect.GetRawPointer(v) + return (*repeated.Scalars[byte, int64])(p) +} + +// GetRepeatedUint32 gets a singular uint32 field. +func (u *UnsafeMessage) GetRepeatedUint32(index int) *repeated.Scalars[byte, uint32] { + if u == nil { + return nil + } + + v := u.Raw().GetByIndexUnchecked(index) + p := xprotoreflect.GetRawPointer(v) + return (*repeated.Scalars[byte, uint32])(p) +} + +// GetRepeatedUint64 gets a singular uint64 field. +func (u *UnsafeMessage) GetRepeatedUint64(index int) *repeated.Scalars[byte, uint64] { + if u == nil { + return nil + } + + v := u.Raw().GetByIndexUnchecked(index) + p := xprotoreflect.GetRawPointer(v) + return (*repeated.Scalars[byte, uint64])(p) +} + +// GetRepeatedSfixed32 gets a repeated int32 field. +func (u *UnsafeMessage) GetRepeatedSfixed32(index int) *repeated.Scalars[int32, int32] { + if u == nil { + return nil + } + + v := u.Raw().GetByIndexUnchecked(index) + p := xprotoreflect.GetRawPointer(v) + return (*repeated.Scalars[int32, int32])(p) +} + +// GetRepeatedSfixed64 gets a singular int64 field. +func (u *UnsafeMessage) GetRepeatedSfixed64(index int) *repeated.Scalars[int64, int64] { + if u == nil { + return nil + } + + v := u.Raw().GetByIndexUnchecked(index) + p := xprotoreflect.GetRawPointer(v) + return (*repeated.Scalars[int64, int64])(p) +} + +// GetRepeatedFixed32 gets a singular uint32 field. +func (u *UnsafeMessage) GetRepeatedFixed32(index int) *repeated.Scalars[uint32, uint32] { + if u == nil { + return nil + } + + v := u.Raw().GetByIndexUnchecked(index) + p := xprotoreflect.GetRawPointer(v) + return (*repeated.Scalars[uint32, uint32])(p) +} + +// GetRepeatedFixed64 gets a singular uint64 field. +func (u *UnsafeMessage) GetRepeatedFixed64(index int) *repeated.Scalars[uint64, uint64] { + if u == nil { + return nil + } + + v := u.Raw().GetByIndexUnchecked(index) + p := xprotoreflect.GetRawPointer(v) + return (*repeated.Scalars[uint64, uint64])(p) +} + +// GetRepeatedSint32 gets a repeated sint32 field. +func (u *UnsafeMessage) GetRepeatedSint32(index int) *repeated.Zigzags[byte, int32] { + if u == nil { + return nil + } + + v := u.Raw().GetByIndexUnchecked(index) + p := xprotoreflect.GetRawPointer(v) + return (*repeated.Zigzags[byte, int32])(p) +} + +// GetRepeatedSint64 gets a singular sint64 field. +func (u *UnsafeMessage) GetRepeatedSint64(index int) *repeated.Zigzags[byte, int64] { + if u == nil { + return nil + } + + v := u.Raw().GetByIndexUnchecked(index) + p := xprotoreflect.GetRawPointer(v) + return (*repeated.Zigzags[byte, int64])(p) +} + +// GetRepeatedFloat32 gets a singular float32 field. +func (u *UnsafeMessage) GetRepeatedFloat32(index int) *repeated.Scalars[float32, float32] { + if u == nil { + return nil + } + + v := u.Raw().GetByIndexUnchecked(index) + p := xprotoreflect.GetRawPointer(v) + return (*repeated.Scalars[float32, float32])(p) +} + +// GetRepeatedFloat64 gets a singular float64 field. +func (u *UnsafeMessage) GetRepeatedFloat64(index int) *repeated.Scalars[float64, float64] { + if u == nil { + return nil + } + + v := u.Raw().GetByIndexUnchecked(index) + p := xprotoreflect.GetRawPointer(v) + return (*repeated.Scalars[float64, float64])(p) +} + +// GetRepeatedBool gets a singular bool field. +func (u *UnsafeMessage) GetRepeatedBool(index int) *repeated.Bools { + if u == nil { + return nil + } + + v := u.Raw().GetByIndexUnchecked(index) + p := xprotoreflect.GetRawPointer(v) + return (*repeated.Bools)(p) +} + +// GetRepeatedEnum gets a singular enum field. +func (u *UnsafeMessage) GetRepeatedEnum(index int) *repeated.Scalars[byte, protoreflect.EnumNumber] { + if u == nil { + return nil + } + + v := u.Raw().GetByIndexUnchecked(index) + p := xprotoreflect.GetRawPointer(v) + return (*repeated.Scalars[byte, protoreflect.EnumNumber])(p) +} + +// GetRepeatedString gets a singular string field. +func (u *UnsafeMessage) GetRepeatedString(index int) *repeated.Strings { + if u == nil { + return nil + } + + v := u.Raw().GetByIndexUnchecked(index) + p := xprotoreflect.GetRawPointer(v) + return (*repeated.Strings)(p) +} + +// GetRepeatedBytes gets a singular bytes field. +func (u *UnsafeMessage) GetRepeatedBytes(index int) *repeated.Bytes { + if u == nil { + return nil + } + + v := u.Raw().GetByIndexUnchecked(index) + p := xprotoreflect.GetRawPointer(v) + return (*repeated.Bytes)(p) +} + +// GetRepeatedMessage returns a singular message field. +func (u *UnsafeMessage) GetRepeatedMessage(index int) *repeated.UntypedMessages { + if u == nil { + return nil + } + + v := u.Raw().GetByIndexUnchecked(index) + p := xprotoreflect.GetRawPointer(v) + return (*repeated.UntypedMessages)(p) +} diff --git a/internal/gencode/wkt/wkt.go b/internal/gencode/wkt/wkt.go new file mode 100644 index 0000000..4e33da8 --- /dev/null +++ b/internal/gencode/wkt/wkt.go @@ -0,0 +1,52 @@ +// Copyright 2025 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package wkt contains descriptors for well-known-type components. +package wkt + +import ( + "fmt" + + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" + _ "google.golang.org/protobuf/types/descriptorpb" +) + +var ( + FileDescriptorProto = message("google.protobuf.FileDescriptorProto") + FileDescriptorProto_Syntax = field(FileDescriptorProto, "syntax") + FileDescriptorProto_Package = field(FileDescriptorProto, "package") + FileDescriptorProto_Messages = field(FileDescriptorProto, "message_type") + + MessageDescriptorProto = message("google.protobuf.DescriptorProto") + MessageDescriptorProto_Messages = field(MessageDescriptorProto, "nested_type") + MessageDescriptorProto_Fields = field(MessageDescriptorProto, "field") +) + +func message(path string) protoreflect.MessageDescriptor { + ty, err := protoregistry.GlobalTypes.FindMessageByName(protoreflect.FullName(path)) + if err != nil { + panic(fmt.Errorf("not found: %s", path)) + } + + return ty.Descriptor() +} + +func field(md protoreflect.MessageDescriptor, name string) protoreflect.FieldDescriptor { + field := md.Fields().ByName(protoreflect.Name(name)) + if field == nil { + panic(fmt.Errorf("not found: %s.%s", md.FullName(), name)) + } + return field +} diff --git a/internal/tdp/dynamic/message.go b/internal/tdp/dynamic/message.go index 8eb2b00..371a814 100644 --- a/internal/tdp/dynamic/message.go +++ b/internal/tdp/dynamic/message.go @@ -90,11 +90,6 @@ func (m *Message) Range(yield func(protoreflect.FieldDescriptor, protoreflect.Va if v.Map().Len() == 0 { goto skip } - - case fd.Message() != nil: - if _, empty := v.Interface().(empty.Message); empty { - goto skip - } } if !yield(ty.FieldDescriptors[i], v) { @@ -129,10 +124,6 @@ func (m *Message) Has(fd protoreflect.FieldDescriptor) bool { case fd.IsMap(): return v.Map().Len() > 0 - case fd.Message() != nil: - _, empty := v.Interface().(empty.Message) - return !empty - default: return true } @@ -152,9 +143,12 @@ func (m *Message) Get(fd protoreflect.FieldDescriptor) protoreflect.Value { } if v := f.Get(unsafe.Pointer(m)); v.IsValid() { - // NOTE: non-scalar (message/repeated) fields always return a valid value. + // NOTE: non-singular fields always return a valid value. return v + } else if fd.Cardinality() != protoreflect.Repeated && fd.Message() != nil { + return protoreflect.ValueOfMessage(empty.NewMessage(f.Message)) } + return fd.Default() } diff --git a/internal/tdp/repeated/bools.go b/internal/tdp/repeated/bools.go index 61401e5..ea911d8 100644 --- a/internal/tdp/repeated/bools.go +++ b/internal/tdp/repeated/bools.go @@ -25,8 +25,6 @@ import ( ) // Bools is a repeated field containing bools. -// -//nolint:recvcheck type Bools struct { _ [0]bool // Prevent sketchy casts. @@ -34,21 +32,29 @@ type Bools struct { } // Len returns the length of this repeated field. -func (b Bools) Len() int { +func (b *Bools) Len() int { + if b == nil { + return 0 + } + return int(b.Raw.Len) } // Get extracts a value at the given index. // // Panics if the index is out-of-bounds. -func (b Bools) Get(n int) bool { +func (b *Bools) Get(n int) bool { r := slice.CastUntyped[byte](b.Raw).Raw()[n] return r != 0 } // Values returns an iterator over the elements of s. -func (b Bools) Values() iter.Seq[bool] { +func (b *Bools) Values() iter.Seq[bool] { return func(yield func(bool) bool) { + if b == nil { + return + } + for _, v := range slice.CastUntyped[byte](b.Raw).Raw() { if !yield(v != 0) { return @@ -58,8 +64,12 @@ func (b Bools) Values() iter.Seq[bool] { } // All returns an iterator over the indices and elements of s. -func (b Bools) All() iter.Seq2[int, bool] { +func (b *Bools) All() iter.Seq2[int, bool] { return func(yield func(int, bool) bool) { + if b == nil { + return + } + for i, v := range slice.CastUntyped[byte](b.Raw).Raw() { if !yield(i, v != 0) { return @@ -71,7 +81,11 @@ func (b Bools) All() iter.Seq2[int, bool] { // Copy copies these bools to a slice, appending to out. // // To get a fresh slice, pass nil to this function. -func (b Bools) Copy(out []bool) []bool { +func (b *Bools) Copy(out []bool) []bool { + if b == nil { + return out + } + out = slices.Grow(out, b.Len()) for v := range b.Values() { out = append(out, v) @@ -83,3 +97,5 @@ func (b Bools) Copy(out []bool) []bool { func (b *Bools) ProtoReflect() protoreflect.List { return xunsafe.Cast[reflectBools](b) } + +func (*Bools) Repeated(DoNotImplement) {} diff --git a/internal/tdp/repeated/bytes.go b/internal/tdp/repeated/bytes.go index 20718c7..af18ed1 100644 --- a/internal/tdp/repeated/bytes.go +++ b/internal/tdp/repeated/bytes.go @@ -26,8 +26,6 @@ import ( ) // Bytes is a repeated field containing bytes. -// -//nolint:recvcheck type Bytes struct { _ [0][]byte // Prevent sketchy casts. @@ -36,21 +34,29 @@ type Bytes struct { } // Len returns the length of this repeated field. -func (b Bytes) Len() int { +func (b *Bytes) Len() int { + if b == nil { + return 0 + } + return b.Raw.Len() } // Get extracts a value at the given index. // // Panics if the index is out-of-bounds. -func (b Bytes) Get(n int) []byte { +func (b *Bytes) Get(n int) []byte { r := b.Raw.Raw()[n] return r.Bytes(b.Src) } // Values returns an iterator over the elements of b. -func (b Bytes) Values() iter.Seq[[]byte] { +func (b *Bytes) Values() iter.Seq[[]byte] { return func(yield func([]byte) bool) { + if b == nil { + return + } + for _, v := range b.Raw.Raw() { if !yield(v.Bytes(b.Src)) { return @@ -60,8 +66,12 @@ func (b Bytes) Values() iter.Seq[[]byte] { } // All returns an iterator over the indices and elements of b. -func (b Bytes) All() iter.Seq2[int, []byte] { +func (b *Bytes) All() iter.Seq2[int, []byte] { return func(yield func(int, []byte) bool) { + if b == nil { + return + } + for i, v := range b.Raw.Raw() { if !yield(i, v.Bytes(b.Src)) { return @@ -70,13 +80,24 @@ func (b Bytes) All() iter.Seq2[int, []byte] { } } -// Copy copies these bytes to a slice, appending to out. +// Copy copies these strings to a slice, appending to out. // -// If copy is true, this will make defensive copies of the returned strings. +// To get a fresh slice, pass nil to this function. +func (b *Bytes) Copy(out [][]byte) [][]byte { + return b.CopyAlias(out, false) +} + +// Copy copies these strings to a slice, appending to out. +// +// If alias is true, this will not make defensive copies of the returned strings. // // To get a fresh slice, pass nil to this function. -func (b Bytes) Copy(out [][]byte, copy bool) [][]byte { - if !copy { +func (b *Bytes) CopyAlias(out [][]byte, alias bool) [][]byte { + if b == nil { + return out + } + + if alias { out = slices.Grow(out, b.Len()) for v := range b.Values() { out = append(out, v) @@ -106,3 +127,5 @@ func (b Bytes) Copy(out [][]byte, copy bool) [][]byte { func (b *Bytes) ProtoReflect() protoreflect.List { return xunsafe.Cast[reflectBytes](b) } + +func (*Bytes) Repeated(DoNotImplement) {} diff --git a/internal/tdp/repeated/messages.go b/internal/tdp/repeated/messages.go index 6891e87..172ffe8 100644 --- a/internal/tdp/repeated/messages.go +++ b/internal/tdp/repeated/messages.go @@ -21,6 +21,7 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" "buf.build/go/hyperpb/internal/arena/slice" + "buf.build/go/hyperpb/internal/tdp/dynamic" "buf.build/go/hyperpb/internal/xunsafe" ) @@ -32,16 +33,22 @@ import ( // and outlined modes; the stride is zero in the latter case. We switch to the // outlined mode to avoid needing to copy parsed messages on slice resize. // -// M *must* be some type which wraps a dynamic.Message. -type Messages[M any] struct { +// M *must* be some type which wraps a dynamic.Message, and P must be *M. +type Messages[M any, P interface{ ProtoReflect() protoreflect.Message }] struct { // Slice[byte] if stride is nonzero, Slice[*Message] otherwise. Raw slice.Untyped // The array stride for when raw is an inlined message list. Stride uint32 } +type UntypedMessages = Messages[dynamic.Message, *dynamic.Message] + // Len returns the length of this repeated field. -func (m Messages[_]) Len() int { +func (m *Messages[_, _]) Len() int { + if m == nil { + return 0 + } + if m.Stride != 0 { return int(m.Raw.Len) / int(m.Stride) } @@ -52,7 +59,7 @@ func (m Messages[_]) Len() int { // Get extracts a value at the given index. // // Panics if the index is out-of-bounds. -func (m Messages[M]) Get(n int) *M { +func (m *Messages[M, _]) Get(n int) *M { if m.Stride != 0 { xunsafe.BoundsCheck(n, int(m.Raw.Len)/int(m.Stride)) @@ -66,8 +73,12 @@ func (m Messages[M]) Get(n int) *M { } // Values returns an iterator over the elements of m. -func (m Messages[M]) Values() iter.Seq[*M] { +func (m *Messages[M, _]) Values() iter.Seq[*M] { return func(yield func(*M) bool) { + if m == nil { + return + } + if m.Stride != 0 { for k := 0; k < int(m.Raw.Len); k += int(m.Stride) { p := xunsafe.ByteAdd[M](m.Raw.Ptr.AssertValid(), k) @@ -86,8 +97,12 @@ func (m Messages[M]) Values() iter.Seq[*M] { } // All returns an iterator over the indices and elements of m. -func (m Messages[M]) All() iter.Seq2[int, *M] { +func (m *Messages[M, _]) All() iter.Seq2[int, *M] { return func(yield func(int, *M) bool) { + if m == nil { + return + } + if m.Stride != 0 { i := 0 for k := 0; k < int(m.Raw.Len); k += int(m.Stride) { @@ -110,7 +125,11 @@ func (m Messages[M]) All() iter.Seq2[int, *M] { // Copy copies these scalars to a slice, appending to out. // // To get a fresh slice, pass nil to this function. -func (m Messages[M]) Copy(out []*M) []*M { +func (m *Messages[M, _]) Copy(out []*M) []*M { + if m == nil { + return out + } + if m.Stride == 0 { return append(out, slice.CastUntyped[*M](m.Raw).Raw()...) } @@ -123,6 +142,8 @@ func (m Messages[M]) Copy(out []*M) []*M { } // ProtoReflect returns a reflection value for this list. -func (m *Messages[M]) ProtoReflect() protoreflect.List { - return xunsafe.Cast[reflectMessages](m) +func (m *Messages[M, P]) ProtoReflect() protoreflect.List { + return xunsafe.Cast[reflectMessages[M, P]](m) } + +func (*Messages[_, _]) Repeated(DoNotImplement) {} diff --git a/internal/tdp/repeated/reflect.go b/internal/tdp/repeated/reflect.go index 5ea448d..da17c08 100644 --- a/internal/tdp/repeated/reflect.go +++ b/internal/tdp/repeated/reflect.go @@ -18,9 +18,9 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" "buf.build/go/hyperpb/internal/tdp" - "buf.build/go/hyperpb/internal/tdp/dynamic" "buf.build/go/hyperpb/internal/tdp/empty" "buf.build/go/hyperpb/internal/xprotoreflect" + "buf.build/go/hyperpb/internal/xunsafe" ) // reflectScalars wraps a repeated.Scalars so that it implements protoreflect.List. @@ -119,20 +119,20 @@ func (r *reflectBytes) Get(n int) protoreflect.Value { } // reflectMessages wraps a repeated.Bytes so that it implements protoreflect.List. -type reflectMessages struct { +type reflectMessages[M any, P interface{ ProtoReflect() protoreflect.Message }] struct { empty.List - raw Messages[dynamic.Message] + raw Messages[M, P] } // IsValid implements [protoreflect.List]. -func (r *reflectMessages) IsValid() bool { return r != nil } +func (r *reflectMessages[M, _]) IsValid() bool { return r != nil } // Len implements [protoreflect.List]. -func (r *reflectMessages) Len() int { +func (r *reflectMessages[M, _]) Len() int { return r.raw.Len() } // Get implements [protoreflect.List]. -func (r *reflectMessages) Get(n int) protoreflect.Value { - return protoreflect.ValueOfMessage(r.raw.Get(n).ProtoReflect()) +func (r *reflectMessages[M, P]) Get(n int) protoreflect.Value { + return protoreflect.ValueOfMessage(xunsafe.BitCast[P](r.raw.Get(n)).ProtoReflect()) } diff --git a/internal/tdp/repeated/doc.go b/internal/tdp/repeated/repeated.go similarity index 81% rename from internal/tdp/repeated/doc.go rename to internal/tdp/repeated/repeated.go index 68162b3..7ad577e 100644 --- a/internal/tdp/repeated/doc.go +++ b/internal/tdp/repeated/repeated.go @@ -15,3 +15,7 @@ // Package repeated contains shared layouts for repeated field implementations, // for sharing between the tdp packages and the gencode packages. package repeated + +// DoNotImplement is used for tagging types in this package in such a way +// that users cannot implement hyperpb.List themselves. +type DoNotImplement struct{ _ struct{} } diff --git a/internal/tdp/repeated/scalars.go b/internal/tdp/repeated/scalars.go index 1e22b15..a9e9573 100644 --- a/internal/tdp/repeated/scalars.go +++ b/internal/tdp/repeated/scalars.go @@ -40,19 +40,23 @@ type Scalars[ZC, E tdp.Number] struct { } // IsZC returns whether this Scalars is in zero-copy mode. -func (s Scalars[ZC, E]) IsZC() bool { +func (s *Scalars[ZC, E]) IsZC() bool { return s.Raw.OffArena() } // Len returns the length of this repeated field. -func (s Scalars[ZC, E]) Len() int { +func (s *Scalars[ZC, E]) Len() int { + if s == nil { + return 0 + } + return int(s.Raw.Len) } // Get extracts a value at the given index. // // Panics if the index is out-of-bounds. -func (s Scalars[ZC, E]) Get(n int) E { +func (s *Scalars[ZC, E]) Get(n int) E { if s.IsZC() { r := slice.CastUntyped[ZC](s.Raw).Raw() return E(r[n]) @@ -63,8 +67,12 @@ func (s Scalars[ZC, E]) Get(n int) E { } // Values returns an iterator over the elements of s. -func (s Scalars[ZC, E]) Values() iter.Seq[E] { +func (s *Scalars[ZC, E]) Values() iter.Seq[E] { return func(yield func(E) bool) { + if s == nil { + return + } + if s.IsZC() { r := slice.CastUntyped[ZC](s.Raw).Raw() for _, v := range r { @@ -84,8 +92,12 @@ func (s Scalars[ZC, E]) Values() iter.Seq[E] { } // All returns an iterator over the indices and elements of s. -func (s Scalars[ZC, E]) All() iter.Seq2[int, E] { +func (s *Scalars[ZC, E]) All() iter.Seq2[int, E] { return func(yield func(int, E) bool) { + if s == nil { + return + } + if s.IsZC() { r := slice.CastUntyped[ZC](s.Raw).Raw() for i, v := range r { @@ -107,7 +119,11 @@ func (s Scalars[ZC, E]) All() iter.Seq2[int, E] { // Copy copies these scalars to a slice, appending to out. // // To get a fresh slice, pass nil to this function. -func (s Scalars[ZC, E]) Copy(out []E) []E { +func (s *Scalars[ZC, E]) Copy(out []E) []E { + if s == nil { + return out + } + if layout.Size[ZC]() == layout.Size[E]() || !s.IsZC() { return append(out, slice.CastUntyped[E](s.Raw).Raw()...) } @@ -123,3 +139,5 @@ func (s Scalars[ZC, E]) Copy(out []E) []E { func (s *Scalars[ZC, E]) ProtoReflect() protoreflect.List { return xunsafe.Cast[reflectScalars[ZC, E]](s) } + +func (*Scalars[_, _]) Repeated(DoNotImplement) {} diff --git a/internal/tdp/repeated/strings.go b/internal/tdp/repeated/strings.go index 259a31a..1e7c1b7 100644 --- a/internal/tdp/repeated/strings.go +++ b/internal/tdp/repeated/strings.go @@ -28,8 +28,6 @@ import ( // Strings is a repeated field containing strings. // // The elements are zero-copy ranges relative to a source pointer. -// -//nolint:recvcheck type Strings struct { _ [0]string // Prevent sketchy casts. @@ -38,21 +36,29 @@ type Strings struct { } // Len returns the length of this repeated field. -func (s Strings) Len() int { +func (s *Strings) Len() int { + if s == nil { + return 0 + } + return s.Raw.Len() } // Get extracts a value at the given index. // // Panics if the index is out-of-bounds. -func (s Strings) Get(n int) string { +func (s *Strings) Get(n int) string { r := s.Raw.Raw()[n] return r.String(s.Src) } // Values returns an iterator over the elements of s. -func (s Strings) Values() iter.Seq[string] { +func (s *Strings) Values() iter.Seq[string] { return func(yield func(string) bool) { + if s == nil { + return + } + for _, v := range s.Raw.Raw() { if !yield(v.String(s.Src)) { return @@ -62,8 +68,12 @@ func (s Strings) Values() iter.Seq[string] { } // All returns an iterator over the indices and elements of s. -func (s Strings) All() iter.Seq2[int, string] { +func (s *Strings) All() iter.Seq2[int, string] { return func(yield func(int, string) bool) { + if s == nil { + return + } + for i, v := range s.Raw.Raw() { if !yield(i, v.String(s.Src)) { return @@ -74,11 +84,22 @@ func (s Strings) All() iter.Seq2[int, string] { // Copy copies these strings to a slice, appending to out. // -// If copy is true, this will make defensive copies of the returned strings. +// To get a fresh slice, pass nil to this function. +func (s *Strings) Copy(out []string) []string { + return s.CopyAlias(out, false) +} + +// Copy copies these strings to a slice, appending to out. +// +// If alias is true, this will not make defensive copies of the returned strings. // // To get a fresh slice, pass nil to this function. -func (s Strings) Copy(out []string, copy bool) []string { - if !copy { +func (s *Strings) CopyAlias(out []string, alias bool) []string { + if s == nil { + return out + } + + if alias { out = slices.Grow(out, s.Len()) for v := range s.Values() { out = append(out, v) @@ -108,3 +129,5 @@ func (s Strings) Copy(out []string, copy bool) []string { func (s *Strings) ProtoReflect() protoreflect.List { return xunsafe.Cast[reflectStrings](s) } + +func (*Strings) Repeated(DoNotImplement) {} diff --git a/internal/tdp/repeated/zigzag.go b/internal/tdp/repeated/zigzag.go index fee7901..051405e 100644 --- a/internal/tdp/repeated/zigzag.go +++ b/internal/tdp/repeated/zigzag.go @@ -35,19 +35,23 @@ type Zigzags[ZC, E tdp.Number] struct { } // IsZC returns whether this Scalars is in zero-copy mode. -func (z Zigzags[ZC, E]) IsZC() bool { +func (z *Zigzags[ZC, E]) IsZC() bool { return z.Raw.OffArena() } // Len returns the length of this repeated field. -func (z Zigzags[ZC, E]) Len() int { +func (z *Zigzags[ZC, E]) Len() int { + if z == nil { + return 0 + } + return int(z.Raw.Len) } // Get extracts a value at the given index. // // Panics if the index is out-of-bounds. -func (z Zigzags[ZC, E]) Get(n int) E { +func (z *Zigzags[ZC, E]) Get(n int) E { if z.IsZC() { r := slice.CastUntyped[ZC](z.Raw).Raw() return zigzag.Decode(E(r[n])) @@ -58,8 +62,12 @@ func (z Zigzags[ZC, E]) Get(n int) E { } // Values returns an iterator over the elements of s. -func (z Zigzags[ZC, E]) Values() iter.Seq[E] { +func (z *Zigzags[ZC, E]) Values() iter.Seq[E] { return func(yield func(E) bool) { + if z == nil { + return + } + if z.IsZC() { r := slice.CastUntyped[ZC](z.Raw).Raw() for _, v := range r { @@ -79,8 +87,12 @@ func (z Zigzags[ZC, E]) Values() iter.Seq[E] { } // All returns an iterator over the indices and elements of s. -func (z Zigzags[ZC, E]) All() iter.Seq2[int, E] { +func (z *Zigzags[ZC, E]) All() iter.Seq2[int, E] { return func(yield func(int, E) bool) { + if z == nil { + return + } + if z.IsZC() { r := slice.CastUntyped[ZC](z.Raw).Raw() for i, v := range r { @@ -102,7 +114,11 @@ func (z Zigzags[ZC, E]) All() iter.Seq2[int, E] { // Copy copies these scalars to a slice, appending to out. // // To get a fresh slice, pass nil to this function. -func (z Zigzags[ZC, E]) Copy(out []E) []E { +func (z *Zigzags[ZC, E]) Copy(out []E) []E { + if z == nil { + return out + } + out = slices.Grow(out, z.Len()) for v := range z.Values() { out = append(out, v) @@ -114,3 +130,5 @@ func (z Zigzags[ZC, E]) Copy(out []E) []E { func (s *Zigzags[ZC, E]) ProtoReflect() protoreflect.List { return xunsafe.Cast[reflectZigzags[ZC, E]](s) } + +func (*Zigzags[_, _]) Repeated(DoNotImplement) {} diff --git a/internal/tdp/thunks/oneof.go b/internal/tdp/thunks/oneof.go index 3c5903f..50f3bdd 100644 --- a/internal/tdp/thunks/oneof.go +++ b/internal/tdp/thunks/oneof.go @@ -21,7 +21,6 @@ import ( "buf.build/go/hyperpb/internal/tdp" "buf.build/go/hyperpb/internal/tdp/compiler" "buf.build/go/hyperpb/internal/tdp/dynamic" - "buf.build/go/hyperpb/internal/tdp/empty" "buf.build/go/hyperpb/internal/tdp/vm" "buf.build/go/hyperpb/internal/xprotoreflect" "buf.build/go/hyperpb/internal/xunsafe" @@ -215,7 +214,7 @@ func getOneofBytes(m *dynamic.Message, _ *tdp.Type, getter *tdp.Accessor) protor func getOneofMessage(m *dynamic.Message, ty *tdp.Type, getter *tdp.Accessor) protoreflect.Value { which := xunsafe.ByteLoad[uint32](m, getter.Offset.Bit) if which != getter.Offset.Number { - return protoreflect.ValueOfMessage(empty.NewMessage(ty)) + return protoreflect.Value{} } ptr := *dynamic.GetField[*dynamic.Message](m, getter.Offset) return protoreflect.ValueOfMessage(ptr.ProtoReflect()) diff --git a/internal/tdp/thunks/repeated.go b/internal/tdp/thunks/repeated.go index 9223c88..2cd6f0e 100644 --- a/internal/tdp/thunks/repeated.go +++ b/internal/tdp/thunks/repeated.go @@ -188,12 +188,12 @@ var repeatedFields = map[protoreflect.Kind]*compiler.Archetype{ // Message types. protoreflect.MessageKind: { - Layout: layout.Of[repeated.Messages[dynamic.Message]](), + Layout: layout.Of[repeated.UntypedMessages](), Getter: getRepeatedMessage, Parsers: []compiler.Parser{{Kind: protowire.BytesType, Retry: true, Thunk: parseRepeatedMessage}}, }, protoreflect.GroupKind: { - Layout: layout.Of[repeated.Messages[dynamic.Message]](), + Layout: layout.Of[repeated.UntypedMessages](), Getter: getRepeatedMessage, Parsers: []compiler.Parser{{Kind: protowire.StartGroupType, Retry: true, Thunk: parseRepeatedGroup}}, }, diff --git a/internal/tdp/thunks/repeated_message.go b/internal/tdp/thunks/repeated_message.go index 0bd27b7..fc9af48 100644 --- a/internal/tdp/thunks/repeated_message.go +++ b/internal/tdp/thunks/repeated_message.go @@ -27,7 +27,7 @@ import ( ) func getRepeatedMessage(m *dynamic.Message, _ *tdp.Type, getter *tdp.Accessor) protoreflect.Value { - p := dynamic.GetField[repeated.Messages[dynamic.Message]](m, getter.Offset) + p := dynamic.GetField[repeated.UntypedMessages](m, getter.Offset) return protoreflect.ValueOfList(p.ProtoReflect()) } @@ -60,8 +60,8 @@ func allocRepeatedMessageSplit(p1 vm.P1, p2 vm.P2) (vm.P1, vm.P2, *dynamic.Messa //go:nosplit func allocRepeatedMessage2(p1 vm.P1, p2 vm.P2) (vm.P1, vm.P2, *dynamic.Message) { - var r *repeated.Messages[dynamic.Message] - p1, p2, r = vm.GetMutableField[repeated.Messages[dynamic.Message]](p1, p2) + var r *repeated.UntypedMessages + p1, p2, r = vm.GetMutableField[repeated.UntypedMessages](p1, p2) p1.Log(p2, "repeated message", "%v", r.Raw) var m *dynamic.Message @@ -115,7 +115,7 @@ pointers: } //go:noinline -func newInlineRepeatedField(p1 vm.P1, p2 vm.P2, r *repeated.Messages[dynamic.Message]) (vm.P1, vm.P2, *repeated.Messages[dynamic.Message]) { +func newInlineRepeatedField(p1 vm.P1, p2 vm.P2, r *repeated.UntypedMessages) (vm.P1, vm.P2, *repeated.UntypedMessages) { // First element of this field. Allocate a byte array large enough to // hold one element. ty := p1.Shared().Library().AtOffset(p2.Field().Message.TypeOffset) @@ -132,7 +132,7 @@ func newInlineRepeatedField(p1 vm.P1, p2 vm.P2, r *repeated.Messages[dynamic.Mes } //go:noinline -func spillInlineRepeatedField(p1 vm.P1, p2 vm.P2, r *repeated.Messages[dynamic.Message]) (vm.P1, vm.P2) { +func spillInlineRepeatedField(p1 vm.P1, p2 vm.P2, r *repeated.UntypedMessages) (vm.P1, vm.P2) { ty := p1.Shared().Library().AtOffset(p2.Field().Message.TypeOffset) stride := int(ty.Size) s := slice.CastUntyped[byte](r.Raw) @@ -155,8 +155,8 @@ func spillInlineRepeatedField(p1 vm.P1, p2 vm.P2, r *repeated.Messages[dynamic.M //go:noinline func appendOneMessage(p1 vm.P1, p2 vm.P2, m *dynamic.Message) (vm.P1, vm.P2, *dynamic.Message) { - var r *repeated.Messages[dynamic.Message] - p1, p2, r = vm.GetMutableField[repeated.Messages[dynamic.Message]](p1, p2) + var r *repeated.UntypedMessages + p1, p2, r = vm.GetMutableField[repeated.UntypedMessages](p1, p2) s := slice.CastUntyped[xunsafe.Addr[dynamic.Message]](r.Raw) r.Raw = s.AppendOne(p1.Arena(), xunsafe.AddrOf(m)).Addr().Untyped() return p1, p2, m diff --git a/internal/tdp/thunks/singular.go b/internal/tdp/thunks/singular.go index cf469d3..ff32cd4 100644 --- a/internal/tdp/thunks/singular.go +++ b/internal/tdp/thunks/singular.go @@ -23,7 +23,6 @@ import ( "buf.build/go/hyperpb/internal/tdp" "buf.build/go/hyperpb/internal/tdp/compiler" "buf.build/go/hyperpb/internal/tdp/dynamic" - "buf.build/go/hyperpb/internal/tdp/empty" "buf.build/go/hyperpb/internal/tdp/vm" "buf.build/go/hyperpb/internal/xprotoreflect" "buf.build/go/hyperpb/internal/xunsafe" @@ -246,12 +245,12 @@ func getBytes(m *dynamic.Message, _ *tdp.Type, getter *tdp.Accessor) protoreflec func getMessage(m *dynamic.Message, ty *tdp.Type, getter *tdp.Accessor) protoreflect.Value { p := dynamic.GetField[*dynamic.Message](m, getter.Offset) if p == nil { - return protoreflect.ValueOfMessage(empty.NewMessage(ty)) + return protoreflect.Value{} } sub := *p if sub == nil { - return protoreflect.ValueOfMessage(empty.NewMessage(ty)) + return protoreflect.Value{} } return protoreflect.ValueOfMessage(sub.ProtoReflect()) } diff --git a/internal/xprotoreflect/value.go b/internal/xprotoreflect/value.go index 09c9d15..ff40113 100644 --- a/internal/xprotoreflect/value.go +++ b/internal/xprotoreflect/value.go @@ -94,6 +94,13 @@ func GetRawPointer(v protoreflect.Value) unsafe.Pointer { return unsafe.Pointer(unwrapValue(v).data) } +// Is returns whether v contains a value of the given type. +func Is[T any](v protoreflect.Value) bool { + r := unwrapValue(v) + var z T + return r.typ == xunsafe.AnyType(z) +} + // GetMessage extracts an message value out of a [protoreflect.Value]. // This is faster than just calling v.Interface(), since that has a massive // type switch that performs slow sidecasts, rather than a direct downcast. diff --git a/list.go b/list.go new file mode 100644 index 0000000..f760a70 --- /dev/null +++ b/list.go @@ -0,0 +1,49 @@ +// Copyright 2025 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package hyperpb + +import ( + "iter" + + "google.golang.org/protobuf/reflect/protoreflect" + + "buf.build/go/hyperpb/internal/tdp/repeated" +) + +// List is a type-generic version of [protoreflect.List], which is implemented +// by types for repeated fields returned by hyperpb gencode. +type List[E any] interface { + // Len returns the length of the list. + Len() int + + // Get returns the nth element of the list. + // + // Panics if n is negative or greater than or equal to Len(). + Get(n int) E + + // Copy copies the elements of this list to the given slice. + Copy(to []E) []E + + // Values returns an iterator over the values of this list. + Values() iter.Seq[E] + + // All returns an iterator over the values of this list and their indices. + All() iter.Seq2[int, E] + + // ProtoReflect returns a protoreflect view of this list. + ProtoReflect() protoreflect.List + + Repeated(repeated.DoNotImplement) +} diff --git a/message.go b/message.go index 81374a4..8051d20 100644 --- a/message.go +++ b/message.go @@ -209,7 +209,7 @@ func (m *Message) Initialized() error { f := m.impl.Type().ByIndex(int(^idx)) switch v := f.Get(unsafe.Pointer(m)).Interface().(type) { - case empty.Message: + case nil: continue case *Message: if err := v.Initialized(); err != nil {