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

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

Issue 2200843002: C bindings: Implement _DeepCopy() & some unittests. (Closed) Base URL: git@github.com:domokit/mojo.git@cgen_validate
Patch Set: fix tab indent, update sha1 Created 4 years, 4 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/cgen/type_table.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 7cefe7824c66dc78fe74c3fbfdc295b1e72ab203..7ba98bc67acca812f8153e470b64b409813a9ced 100644
--- a/mojom/generators/c/templates/struct.tmpl.go
+++ b/mojom/generators/c/templates/struct.tmpl.go
@@ -38,7 +38,7 @@ void {{$struct.Name}}_CloseAllHandles(
struct {{$struct.Name}}* {{$struct.Name}}_DeepCopy(
struct MojomBuffer* in_buffer,
- struct {{$struct.Name}}* in_data);
+ struct {{$struct.Name}}* in_struct);
size_t {{$struct.Name}}_ComputeSerializedSize(
const struct {{$struct.Name}}* in_data);
@@ -68,6 +68,19 @@ const GenerateStructDefinitions = `
const {{$const.Type}} {{$const.Name}} = {{$const.Value}};
{{end -}}
+struct {{$struct.Name}}* {{$struct.Name}}_DeepCopy(
+ struct MojomBuffer* in_buffer,
+ struct {{$struct.Name}}* in_struct) {
+ struct {{$struct.Name}}* out_struct = NULL;
+ if (!MojomStruct_DeepCopy(
+ in_buffer, &{{$struct.Name}}__TypeDesc,
+ (struct MojomStructHeader*)in_struct,
+ (struct MojomStructHeader**)&out_struct)) {
+ return NULL;
+ }
+ return out_struct;
+}
+
size_t {{$struct.Name}}_ComputeSerializedSize(
const struct {{$struct.Name}}* in_data) {
return MojomStruct_ComputeSerializedSize(
« no previous file with comments | « mojom/generators/c/cgen/type_table.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