Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: mojom/generators/c/templates/struct.tmpl.go

Issue 2163793002: C bindings: Implement _Validate(), and some pre-requisites (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: address comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojom/generators/c/templates/interface.tmpl.go ('k') | mojom/generators/c/templates/type_table.tmpl.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojom/generators/c/templates/struct.tmpl.go
diff --git a/mojom/generators/c/templates/struct.tmpl.go b/mojom/generators/c/templates/struct.tmpl.go
index 9bdc77819386e067f654ddcb5c7ab70c2506160b..7cefe7824c66dc78fe74c3fbfdc295b1e72ab203 100644
--- a/mojom/generators/c/templates/struct.tmpl.go
+++ b/mojom/generators/c/templates/struct.tmpl.go
@@ -51,6 +51,10 @@ void {{$struct.Name}}_DecodePointersAndHandles(
struct {{$struct.Name}}* inout_struct, uint32_t in_struct_size,
MojoHandle inout_handles[], uint32_t in_num_handles);
+MojomValidationResult {{$struct.Name}}_Validate(
+ const struct {{$struct.Name}}* in_struct, uint32_t in_struct_size,
+ uint32_t in_num_handles);
+
{{end}}
`
@@ -89,5 +93,18 @@ void {{$struct.Name}}_DecodePointersAndHandles(
inout_handles, in_num_handles);
}
+MojomValidationResult {{$struct.Name}}_Validate(
+ const struct {{$struct.Name}}* in_struct, uint32_t in_struct_size,
+ uint32_t in_num_handles) {
+ struct MojomValidationContext context = {
+ .next_handle_index = 0,
+ .next_pointer = (char*)in_struct + in_struct->header_.num_bytes,
+ };
+ return MojomStruct_Validate(
+ &{{$struct.Name}}__TypeDesc,
+ (struct MojomStructHeader*)in_struct, in_struct_size, in_num_handles,
+ &context);
+}
+
{{end}}
`
« no previous file with comments | « mojom/generators/c/templates/interface.tmpl.go ('k') | mojom/generators/c/templates/type_table.tmpl.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698