aboutsummaryrefslogtreecommitdiff
path: root/mojo/public/cpp/bindings/lib/native_struct_data.h
blob: 1c7cd81c7703bd90bb59b02af11d1a7d16a23eda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_NATIVE_STRUCT_DATA_H_
#define MOJO_PUBLIC_CPP_BINDINGS_LIB_NATIVE_STRUCT_DATA_H_

#include <vector>

#include "mojo/public/cpp/bindings/bindings_export.h"
#include "mojo/public/cpp/bindings/lib/array_internal.h"
#include "mojo/public/cpp/system/handle.h"

namespace mojo {
namespace internal {

class ValidationContext;

class MOJO_CPP_BINDINGS_EXPORT NativeStruct_Data {
 public:
  static bool Validate(const void* data, ValidationContext* validation_context);

  // Unlike normal structs, the memory layout is exactly the same as an array
  // of uint8_t.
  Array_Data<uint8_t> data;

 private:
  NativeStruct_Data() = delete;
  ~NativeStruct_Data() = delete;
};

static_assert(sizeof(Array_Data<uint8_t>) == sizeof(NativeStruct_Data),
              "Mismatched NativeStruct_Data and Array_Data<uint8_t> size");

}  // namespace internal
}  // namespace mojo

#endif  // MOJO_PUBLIC_CPP_BINDINGS_LIB_NATIVE_STRUCT_DATA_H_