Skip to content

Commit 759bc85

Browse files
committed
add *_default annotation parameter
1 parent 02dedd1 commit 759bc85

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

Diff for: src/grammar/grammar.go

+10-9
Original file line numberDiff line numberDiff line change
@@ -1532,14 +1532,6 @@ func default_() Options[AnnotationParameter] {
15321532
})
15331533
}
15341534

1535-
func raw_default() Options[AnnotationParameter] {
1536-
return opt(AnnotationParameter{
1537-
Name: "raw_default",
1538-
Description: "Sets the raw default value for field.",
1539-
Types: types(String),
1540-
})
1541-
}
1542-
15431535
func mut() Options[AnnotationParameter] {
15441536
return opt(AnnotationParameter{
15451537
Name: "mut",
@@ -1595,6 +1587,14 @@ func lang_alias() Options[AnnotationParameter] {
15951587
})
15961588
}
15971589

1590+
func lang_default() Options[AnnotationParameter] {
1591+
return opt(AnnotationParameter{
1592+
Name: ".+_default",
1593+
Description: "Sets the default value expression for field in target languages.",
1594+
Types: types(String),
1595+
})
1596+
}
1597+
15981598
func appendTo[S ~[]T, T any](s *S, x ...T) {
15991599
*s = append(*s, x...)
16001600
}
@@ -1656,6 +1656,7 @@ func appendTo[S ~[]T, T any](s *S, x ...T) {
16561656
// available="!java",
16571657
// tokens="Name",
16581658
// default="John Doe",
1659+
// cpp_default="\"John Doe\"",
16591660
// cpp_alias="std::string",
16601661
// )
16611662
// @optional
@@ -1705,7 +1706,7 @@ var Builtin = Grammar{
17051706
Struct: Struct{
17061707
Annotations: Annotations{base_next("struct", lang_alias()), deprecated()},
17071708
Field: StructField{
1708-
Annotations: Annotations{base_next("struct.field", raw_default(), default_(), lang_alias()), optional(), deprecated()},
1709+
Annotations: Annotations{base_next("struct.field", lang_default(), default_(), lang_alias()), optional(), deprecated()},
17091710
},
17101711
},
17111712
Interface: Interface{

Diff for: website/docs/api/preview/grammar.mdx

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ struct User {
116116
available="!java",
117117
tokens="Name",
118118
default="John Doe",
119+
cpp_default="\"John Doe\"",
119120
cpp_alias="std::string",
120121
)
121122
@optional

0 commit comments

Comments
 (0)