Home | History | Annotate | Download | only in lib
      1 // Copyright 2016 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_NATIVE_STRUCT_DATA_H_
      6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_NATIVE_STRUCT_DATA_H_
      7 
      8 #include <vector>
      9 
     10 #include "mojo/public/cpp/bindings/bindings_export.h"
     11 #include "mojo/public/cpp/bindings/lib/array_internal.h"
     12 #include "mojo/public/cpp/system/handle.h"
     13 
     14 namespace mojo {
     15 namespace internal {
     16 
     17 class ValidationContext;
     18 
     19 class MOJO_CPP_BINDINGS_EXPORT NativeStruct_Data {
     20  public:
     21   static bool Validate(const void* data, ValidationContext* validation_context);
     22 
     23   // Unlike normal structs, the memory layout is exactly the same as an array
     24   // of uint8_t.
     25   Array_Data<uint8_t> data;
     26 
     27  private:
     28   NativeStruct_Data() = delete;
     29   ~NativeStruct_Data() = delete;
     30 };
     31 
     32 static_assert(sizeof(Array_Data<uint8_t>) == sizeof(NativeStruct_Data),
     33               "Mismatched NativeStruct_Data and Array_Data<uint8_t> size");
     34 
     35 }  // namespace internal
     36 }  // namespace mojo
     37 
     38 #endif  // MOJO_PUBLIC_CPP_BINDINGS_LIB_NATIVE_STRUCT_DATA_H_
     39