Skip to content

Commit

Permalink
add google type
Browse files Browse the repository at this point in the history
  • Loading branch information
Multiply authored and johanbrandhorst committed Dec 12, 2019
1 parent b8d18e9 commit e5a9c66
Show file tree
Hide file tree
Showing 31 changed files with 9,891 additions and 119 deletions.
104 changes: 104 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,32 @@ regenerate:
google/api/expr/v1alpha1/syntax.proto \
google/api/expr/v1alpha1/value.proto

protoc \
--gogogoogleapis_out=\
Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor,\
:. \
-I=. \
google/type/calendar_period.proto \
google/type/color.proto \
google/type/date.proto \
google/type/dayofweek.proto \
google/type/expr.proto \
google/type/fraction.proto \
google/type/latlng.proto \
google/type/money.proto \
google/type/month.proto \
google/type/postal_address.proto \
google/type/quaternion.proto \
google/type/timeofday.proto

protoc \
--gogogoogleapis_out=\
Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor,\
:. \
-I=. \
google/type/datetime.proto

update:
go get github.com/gogo/protobuf/gogoreplace

Expand Down Expand Up @@ -77,3 +103,81 @@ update:
'option go_package = "google.golang.org/genproto/googleapis/api/expr/v1alpha1;expr";' \
'option go_package = "expr";' \
./google/api/expr/v1alpha1/value.proto

(cd ./google/type && rm calendar_period.proto; wget ${URL}/google/type/calendar_period.proto)
gogoreplace \
'option go_package = "google.golang.org/genproto/googleapis/type/calendarperiod;calendarperiod";' \
'option go_package = "type";' \
./google/type/calendar_period.proto

(cd ./google/type && rm color.proto; wget ${URL}/google/type/color.proto)
gogoreplace \
'option go_package = "google.golang.org/genproto/googleapis/type/color;color";' \
'option go_package = "type";' \
./google/type/color.proto

(cd ./google/type && rm date.proto; wget ${URL}/google/type/date.proto)
gogoreplace \
'option go_package = "google.golang.org/genproto/googleapis/type/date;date";' \
'option go_package = "type";' \
./google/type/date.proto

(cd ./google/type && rm datetime.proto; wget ${URL}/google/type/datetime.proto)
gogoreplace \
'option go_package = "google.golang.org/genproto/googleapis/type/datetime;datetime";' \
'option go_package = "type";' \
./google/type/datetime.proto

(cd ./google/type && rm dayofweek.proto; wget ${URL}/google/type/dayofweek.proto)
gogoreplace \
'option go_package = "google.golang.org/genproto/googleapis/type/dayofweek;dayofweek";' \
'option go_package = "type";' \
./google/type/dayofweek.proto

(cd ./google/type && rm expr.proto; wget ${URL}/google/type/expr.proto)
gogoreplace \
'option go_package = "google.golang.org/genproto/googleapis/type/expr;expr";' \
'option go_package = "type";' \
./google/type/expr.proto

(cd ./google/type && rm fraction.proto; wget ${URL}/google/type/fraction.proto)
gogoreplace \
'option go_package = "google.golang.org/genproto/googleapis/type/fraction;fraction";' \
'option go_package = "type";' \
./google/type/fraction.proto

(cd ./google/type && rm latlng.proto; wget ${URL}/google/type/latlng.proto)
gogoreplace \
'option go_package = "google.golang.org/genproto/googleapis/type/latlng;latlng";' \
'option go_package = "type";' \
./google/type/latlng.proto

(cd ./google/type && rm money.proto; wget ${URL}/google/type/money.proto)
gogoreplace \
'option go_package = "google.golang.org/genproto/googleapis/type/money;money";' \
'option go_package = "type";' \
./google/type/money.proto

(cd ./google/type && rm month.proto; wget ${URL}/google/type/month.proto)
gogoreplace \
'option go_package = "google.golang.org/genproto/googleapis/type/month;month";' \
'option go_package = "type";' \
./google/type/month.proto

(cd ./google/type && rm postal_address.proto; wget ${URL}/google/type/postal_address.proto)
gogoreplace \
'option go_package = "google.golang.org/genproto/googleapis/type/postaladdress;postaladdress";' \
'option go_package = "type";' \
./google/type/postal_address.proto

(cd ./google/type && rm quaternion.proto; wget ${URL}/google/type/quaternion.proto)
gogoreplace \
'option go_package = "google.golang.org/genproto/googleapis/type/quaternion;quaternion";' \
'option go_package = "type";' \
./google/type/quaternion.proto

(cd ./google/type && rm timeofday.proto; wget ${URL}/google/type/timeofday.proto)
gogoreplace \
'option go_package = "google.golang.org/genproto/googleapis/type/timeofday;timeofday";' \
'option go_package = "type";' \
./google/type/timeofday.proto
417 changes: 312 additions & 105 deletions google/api/expr/v1alpha1/syntax.pb.go

Large diffs are not rendered by default.

32 changes: 19 additions & 13 deletions google/api/expr/v1alpha1/syntax.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 Google LLC.
// Copyright 2019 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -45,24 +45,21 @@ message ParsedExpr {
// operators with the exception of the '.' operator are modelled as function
// calls. This makes it easy to represent new operators into the existing AST.
//
// All references within expressions must resolve to a
// [Decl][google.api.expr.v1alpha1.Decl] provided at type-check for an
// expression to be valid. A reference may either be a bare identifier `name` or
// a qualified identifier `google.api.name`. References may either refer to a
// value or a function declaration.
// All references within expressions must resolve to a [Decl][google.api.expr.v1alpha1.Decl] provided at
// type-check for an expression to be valid. A reference may either be a bare
// identifier `name` or a qualified identifier `google.api.name`. References
// may either refer to a value or a function declaration.
//
// For example, the expression `google.api.name.startsWith('expr')` references
// the declaration `google.api.name` within a
// [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression, and the
// function declaration `startsWith`.
// the declaration `google.api.name` within a [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression, and
// the function declaration `startsWith`.
message Expr {
// An identifier expression. e.g. `request`.
message Ident {
// Required. Holds a single, unqualified identifier, possibly preceded by a
// '.'.
//
// Qualified names are represented by the
// [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression.
// Qualified names are represented by the [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression.
string name = 1;
}

Expand Down Expand Up @@ -239,8 +236,7 @@ message Expr {
// primitives.
//
// Lists and structs are not included as constants as these aggregate types may
// contain [Expr][google.api.expr.v1alpha1.Expr] elements which require
// evaluation and are thus not constant.
// contain [Expr][google.api.expr.v1alpha1.Expr] elements which require evaluation and are thus not constant.
//
// Examples of literals include: `"hello"`, `b'bytes'`, `1u`, `4.2`, `-2`,
// `true`, `null`.
Expand Down Expand Up @@ -302,6 +298,16 @@ message SourceInfo {
// A map from the parse node id (e.g. `Expr.id`) to the character offset
// within source.
map<int64, int32> positions = 4;

// A map from the parse node id where a macro replacement was made to the
// call `Expr` that resulted in a macro expansion.
//
// For example, `has(value.field)` is a function call that is replaced by a
// `test_only` field selection in the AST. Likewise, the call
// `list.exists(e, e > 10)` translates to a comprehension expression. The key
// in the map corresponds to the expression id of the expanded macro, and the
// value is the call `Expr` that was replaced.
map<int64, Expr> macro_calls = 5;
}

// A specific position in source.
Expand Down
2 changes: 1 addition & 1 deletion google/api/expr/v1alpha1/value.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 Google LLC.
// Copyright 2019 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
111 changes: 111 additions & 0 deletions google/type/calendar_period.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions google/type/calendar_period.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2019 Google LLC.
//
// 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.
//

syntax = "proto3";

package google.type;

option go_package = "type";
option java_multiple_files = true;
option java_outer_classname = "CalendarPeriodProto";
option java_package = "com.google.type";
option objc_class_prefix = "GTP";

// A `CalendarPeriod` represents the abstract concept of a time period that has
// a canonical start. Grammatically, "the start of the current
// `CalendarPeriod`." All calendar times begin at midnight UTC.
enum CalendarPeriod {
// Undefined period, raises an error.
CALENDAR_PERIOD_UNSPECIFIED = 0;

// A day.
DAY = 1;

// A week. Weeks begin on Monday, following
// [ISO 8601](https://en.wikipedia.org/wiki/ISO_week_date).
WEEK = 2;

// A fortnight. The first calendar fortnight of the year begins at the start
// of week 1 according to
// [ISO 8601](https://en.wikipedia.org/wiki/ISO_week_date).
FORTNIGHT = 3;

// A month.
MONTH = 4;

// A quarter. Quarters start on dates 1-Jan, 1-Apr, 1-Jul, and 1-Oct of each
// year.
QUARTER = 5;

// A half-year. Half-years start on dates 1-Jan and 1-Jul.
HALF = 6;

// A year.
YEAR = 7;
}
Loading

0 comments on commit e5a9c66

Please sign in to comment.