// Protos returns a cel.EnvOption to configure extended macros and functions for // proto manipulation. // // Note, all macros use the 'proto' namespace; however, at the time of macro // expansion the namespace looks just like any other identifier. If you are // currently using a variable named 'proto', the macro will likely work just as // intended; however, there is some chance for collision. // // # Protos.GetExt // // Macro which generates a select expression that retrieves an extension field // from the input proto2 syntax message. If the field is not set, the default // value forthe extension field is returned according to safe-traversal semantics. // // proto.getExt(<msg>, <fully.qualified.extension.name>) -> <field-type> // // Examples: // // proto.getExt(msg, google.expr.proto2.test.int32_ext) // returns int value // // # Protos.HasExt // // Macro which generates a test-only select expression that determines whether // an extension field is set on a proto2 syntax message. // // proto.hasExt(<msg>, <fully.qualified.extension.name>) -> <bool> // // Examples: // // proto.hasExt(msg, google.expr.proto2.test.int32_ext) // returns true || false func Protos() cel.EnvOption { … } var protoNamespace … var hasExtension … var getExtension … type protoLib … // LibraryName implements the SingletonLibrary interface method. func (protoLib) LibraryName() string { … } // CompileOptions implements the Library interface method. func (protoLib) CompileOptions() []cel.EnvOption { … } // ProgramOptions implements the Library interface method. func (protoLib) ProgramOptions() []cel.ProgramOption { … } // hasProtoExt generates a test-only select expression for a fully-qualified extension name on a protobuf message. func hasProtoExt(mef cel.MacroExprFactory, target ast.Expr, args []ast.Expr) (ast.Expr, *cel.Error) { … } // getProtoExt generates a select expression for a fully-qualified extension name on a protobuf message. func getProtoExt(mef cel.MacroExprFactory, target ast.Expr, args []ast.Expr) (ast.Expr, *cel.Error) { … } func getExtFieldName(mef cel.MacroExprFactory, expr ast.Expr) (string, *cel.Error) { … } func validateIdentifier(expr ast.Expr) (string, bool) { … }