~bigbes/tarantool

tarantool-protobuf

ref: 5c5414165838069d5fcfc199bf1ebf9690c7c3c8 tarantool-protobuf/cmd/protoc-gen-tarantool/internal/gen/options.go -rw-r--r-- 1.5 KiB
5c541416 — Eugene Blikh bench(c_accel): drop defensive lua_type checks; refresh numbers 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package gen

import (
	"google.golang.org/protobuf/proto"
	"google.golang.org/protobuf/reflect/protoreflect"
	"google.golang.org/protobuf/reflect/protoregistry"
	"google.golang.org/protobuf/runtime/protoimpl"
	"google.golang.org/protobuf/types/descriptorpb"
)

// E_LuaPackage mirrors the option declared in options/tarantool/tarantool.proto.
// We register it manually here to avoid having to ship a generated stub for our
// own option file.
var E_LuaPackage = &protoimpl.ExtensionInfo{
	ExtendedType:  (*descriptorpb.FileOptions)(nil),
	ExtensionType: (*string)(nil),
	Field:         60001,
	Name:          "tarantool.lua_package",
	Tag:           "bytes,60001,opt,name=lua_package",
	Filename:      "tarantool/tarantool.proto",
}

// Register the extension in the global type registry so that
// proto.GetExtension can resolve it on FileOptions parsed by protoc-gen-go's
// plugin scaffolding. Without this, the option's value lands in the message's
// unknown fields and GetExtension returns the zero value ("").
func init() {
	if err := protoregistry.GlobalTypes.RegisterExtension(E_LuaPackage); err != nil {
		panic("tarantool-protobuf: register E_LuaPackage: " + err.Error())
	}
}

// luaPackageOption returns the value of (tarantool.lua_package) on the file
// options, or "" when unset.
func luaPackageOption(f protoreflect.FileDescriptor) string {
	opts, _ := f.Options().(*descriptorpb.FileOptions)
	if opts == nil {
		return ""
	}
	v, ok := proto.GetExtension(opts, E_LuaPackage).(string)
	if !ok {
		return ""
	}
	return v
}