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

Unified Diff: mojo/public/c/bindings/struct.h

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 | « mojo/public/c/bindings/lib/union.c ('k') | mojo/public/c/bindings/tests/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/c/bindings/struct.h
diff --git a/mojo/public/c/bindings/struct.h b/mojo/public/c/bindings/struct.h
index 67798c3c3daaa3abe27c7a81d740de2fe1bfbc80..c185999a029dd4f69423a5578fc6cd375d753c2c 100644
--- a/mojo/public/c/bindings/struct.h
+++ b/mojo/public/c/bindings/struct.h
@@ -88,6 +88,22 @@ MojomValidationResult MojomStruct_Validate(
uint32_t in_num_handles,
struct MojomValidationContext* inout_context);
+// Creates a new copy of |in_struct| using |buffer| to allocate space.
+// Recursively creates new copies of any references from |in_struct|, and
+// updates the references to point to the new copies. This operation is useful
+// if you want to linearize |in_struct| using the buffer backed by |buffer|. If
+// there is insufficient space in the buffer or has unknown-typed data, this
+// function returns false and the supplied buffer may be partially used.
+// Otherwise, |out_struct| is set to the new copy of the struct.
+// |buffer|: A mojom buffer used to allocate space for the new struct.
+// |in_type_desc|: Describes the pointer and handle fields of the mojom struct.
+// |in_struct|: The unencoded mojom struct to be copied.
+// |out_struct|: Will be set to the new unencoded mojom struct.
+bool MojomStruct_DeepCopy(struct MojomBuffer* buffer,
+ const struct MojomTypeDescriptorStruct* in_type_desc,
+ const struct MojomStructHeader* in_struct,
+ struct MojomStructHeader** out_struct);
+
MOJO_END_EXTERN_C
#endif // MOJO_PUBLIC_C_BINDINGS_STRUCT_H_
« no previous file with comments | « mojo/public/c/bindings/lib/union.c ('k') | mojo/public/c/bindings/tests/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698