| // mojo/public/interfaces/bindings/tests/sample_factory.mojom-shared.cc is auto generated by mojom_bindings_generator.py, do not edit |
| |
| // Copyright 2016 The Chromium Authors |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #include "mojo/public/interfaces/bindings/tests/sample_factory.mojom-shared.h" |
| |
| // Used to support stream output operator for enums. |
| // TODO(dcheng): Consider omitting this somehow if not needed. |
| #include <ostream> |
| #include <utility> |
| |
| #include "base/strings/stringprintf.h" |
| #include "mojo/public/cpp/bindings/lib/validate_params.h" |
| #include "mojo/public/cpp/bindings/lib/validation_errors.h" |
| #include "mojo/public/cpp/bindings/lib/validation_util.h" |
| #include "third_party/perfetto/include/perfetto/tracing/traced_value.h" |
| |
| #include "mojo/public/interfaces/bindings/tests/sample_factory.mojom-params-data.h" |
| namespace sample { |
| |
| namespace internal { |
| |
| |
| // static |
| bool Request_Data::Validate( |
| const void* data, |
| mojo::internal::ValidationContext* validation_context) { |
| if (!data) |
| return true; |
| if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory( |
| data, 32, validation_context)) { |
| return false; |
| } |
| |
| // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if |
| // the message comes from an older version. |
| [[maybe_unused]] const Request_Data* object = |
| static_cast<const Request_Data*>(data); |
| |
| if (!mojo::internal::ValidateHandleOrInterface(object->pipe, |
| validation_context)) { |
| return false; |
| } |
| |
| constexpr const mojo::internal::ContainerValidateParams& more_pipes_validate_params = |
| mojo::internal::GetArrayValidator<0, false, nullptr>(); |
| if (!mojo::internal::ValidateContainer(object->more_pipes, validation_context, |
| &more_pipes_validate_params)) { |
| return false; |
| } |
| |
| if (!mojo::internal::ValidateHandleOrInterface(object->obj, |
| validation_context)) { |
| return false; |
| } |
| |
| return true; |
| } |
| |
| Request_Data::Request_Data() |
| : header_({sizeof(*this), 0}) {} |
| |
| |
| // static |
| bool Response_Data::Validate( |
| const void* data, |
| mojo::internal::ValidationContext* validation_context) { |
| if (!data) |
| return true; |
| if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory( |
| data, 16, validation_context)) { |
| return false; |
| } |
| |
| // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if |
| // the message comes from an older version. |
| [[maybe_unused]] const Response_Data* object = |
| static_cast<const Response_Data*>(data); |
| |
| if (!mojo::internal::ValidateHandleOrInterface(object->pipe, |
| validation_context)) { |
| return false; |
| } |
| |
| return true; |
| } |
| |
| Response_Data::Response_Data() |
| : header_({sizeof(*this), 0}) {} |
| |
| |
| // static |
| bool NamedObject_SetName_Params_Data::Validate( |
| const void* data, |
| mojo::internal::ValidationContext* validation_context) { |
| if (!data) |
| return true; |
| if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory( |
| data, 16, validation_context)) { |
| return false; |
| } |
| |
| // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if |
| // the message comes from an older version. |
| [[maybe_unused]] const NamedObject_SetName_Params_Data* object = |
| static_cast<const NamedObject_SetName_Params_Data*>(data); |
| |
| if (!mojo::internal::ValidatePointerNonNullable( |
| object->name, 1, validation_context)) { |
| return false; |
| } |
| constexpr const mojo::internal::ContainerValidateParams& name_validate_params = |
| mojo::internal::GetArrayValidator<0, false, nullptr>(); |
| if (!mojo::internal::ValidateContainer(object->name, validation_context, |
| &name_validate_params)) { |
| return false; |
| } |
| |
| return true; |
| } |
| |
| NamedObject_SetName_Params_Data::NamedObject_SetName_Params_Data() |
| : header_({sizeof(*this), 0}) {} |
| |
| |
| // static |
| bool NamedObject_GetName_Params_Data::Validate( |
| const void* data, |
| mojo::internal::ValidationContext* validation_context) { |
| if (!data) |
| return true; |
| if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory( |
| data, 8, validation_context)) { |
| return false; |
| } |
| |
| // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if |
| // the message comes from an older version. |
| [[maybe_unused]] const NamedObject_GetName_Params_Data* object = |
| static_cast<const NamedObject_GetName_Params_Data*>(data); |
| |
| return true; |
| } |
| |
| NamedObject_GetName_Params_Data::NamedObject_GetName_Params_Data() |
| : header_({sizeof(*this), 0}) {} |
| |
| |
| // static |
| bool NamedObject_GetName_ResponseParams_Data::Validate( |
| const void* data, |
| mojo::internal::ValidationContext* validation_context) { |
| if (!data) |
| return true; |
| if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory( |
| data, 16, validation_context)) { |
| return false; |
| } |
| |
| // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if |
| // the message comes from an older version. |
| [[maybe_unused]] const NamedObject_GetName_ResponseParams_Data* object = |
| static_cast<const NamedObject_GetName_ResponseParams_Data*>(data); |
| |
| if (!mojo::internal::ValidatePointerNonNullable( |
| object->name, 1, validation_context)) { |
| return false; |
| } |
| constexpr const mojo::internal::ContainerValidateParams& name_validate_params = |
| mojo::internal::GetArrayValidator<0, false, nullptr>(); |
| if (!mojo::internal::ValidateContainer(object->name, validation_context, |
| &name_validate_params)) { |
| return false; |
| } |
| |
| return true; |
| } |
| |
| NamedObject_GetName_ResponseParams_Data::NamedObject_GetName_ResponseParams_Data() |
| : header_({sizeof(*this), 0}) {} |
| |
| |
| // static |
| bool Factory_DoStuff_Params_Data::Validate( |
| const void* data, |
| mojo::internal::ValidationContext* validation_context) { |
| if (!data) |
| return true; |
| if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory( |
| data, 24, validation_context)) { |
| return false; |
| } |
| |
| // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if |
| // the message comes from an older version. |
| [[maybe_unused]] const Factory_DoStuff_Params_Data* object = |
| static_cast<const Factory_DoStuff_Params_Data*>(data); |
| |
| if (!mojo::internal::ValidatePointerNonNullable( |
| object->request, 1, validation_context)) { |
| return false; |
| } |
| if (!mojo::internal::ValidateStruct(object->request, validation_context)) |
| return false; |
| |
| if (!mojo::internal::ValidateHandleOrInterface(object->pipe, |
| validation_context)) { |
| return false; |
| } |
| |
| return true; |
| } |
| |
| Factory_DoStuff_Params_Data::Factory_DoStuff_Params_Data() |
| : header_({sizeof(*this), 0}) {} |
| |
| |
| // static |
| bool Factory_DoStuff_ResponseParams_Data::Validate( |
| const void* data, |
| mojo::internal::ValidationContext* validation_context) { |
| if (!data) |
| return true; |
| if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory( |
| data, 24, validation_context)) { |
| return false; |
| } |
| |
| // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if |
| // the message comes from an older version. |
| [[maybe_unused]] const Factory_DoStuff_ResponseParams_Data* object = |
| static_cast<const Factory_DoStuff_ResponseParams_Data*>(data); |
| |
| if (!mojo::internal::ValidatePointerNonNullable( |
| object->response, 1, validation_context)) { |
| return false; |
| } |
| if (!mojo::internal::ValidateStruct(object->response, validation_context)) |
| return false; |
| |
| if (!mojo::internal::ValidatePointerNonNullable( |
| object->text, 2, validation_context)) { |
| return false; |
| } |
| constexpr const mojo::internal::ContainerValidateParams& text_validate_params = |
| mojo::internal::GetArrayValidator<0, false, nullptr>(); |
| if (!mojo::internal::ValidateContainer(object->text, validation_context, |
| &text_validate_params)) { |
| return false; |
| } |
| |
| return true; |
| } |
| |
| Factory_DoStuff_ResponseParams_Data::Factory_DoStuff_ResponseParams_Data() |
| : header_({sizeof(*this), 0}) {} |
| |
| |
| // static |
| bool Factory_DoStuff2_Params_Data::Validate( |
| const void* data, |
| mojo::internal::ValidationContext* validation_context) { |
| if (!data) |
| return true; |
| if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory( |
| data, 16, validation_context)) { |
| return false; |
| } |
| |
| // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if |
| // the message comes from an older version. |
| [[maybe_unused]] const Factory_DoStuff2_Params_Data* object = |
| static_cast<const Factory_DoStuff2_Params_Data*>(data); |
| |
| if (!mojo::internal::ValidateHandleOrInterfaceNonNullable( |
| object->pipe, 1, validation_context)) { |
| return false; |
| } |
| if (!mojo::internal::ValidateHandleOrInterface(object->pipe, |
| validation_context)) { |
| return false; |
| } |
| |
| return true; |
| } |
| |
| Factory_DoStuff2_Params_Data::Factory_DoStuff2_Params_Data() |
| : header_({sizeof(*this), 0}) {} |
| |
| |
| // static |
| bool Factory_DoStuff2_ResponseParams_Data::Validate( |
| const void* data, |
| mojo::internal::ValidationContext* validation_context) { |
| if (!data) |
| return true; |
| if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory( |
| data, 16, validation_context)) { |
| return false; |
| } |
| |
| // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if |
| // the message comes from an older version. |
| [[maybe_unused]] const Factory_DoStuff2_ResponseParams_Data* object = |
| static_cast<const Factory_DoStuff2_ResponseParams_Data*>(data); |
| |
| if (!mojo::internal::ValidatePointerNonNullable( |
| object->text, 1, validation_context)) { |
| return false; |
| } |
| constexpr const mojo::internal::ContainerValidateParams& text_validate_params = |
| mojo::internal::GetArrayValidator<0, false, nullptr>(); |
| if (!mojo::internal::ValidateContainer(object->text, validation_context, |
| &text_validate_params)) { |
| return false; |
| } |
| |
| return true; |
| } |
| |
| Factory_DoStuff2_ResponseParams_Data::Factory_DoStuff2_ResponseParams_Data() |
| : header_({sizeof(*this), 0}) {} |
| |
| |
| // static |
| bool Factory_CreateNamedObject_Params_Data::Validate( |
| const void* data, |
| mojo::internal::ValidationContext* validation_context) { |
| if (!data) |
| return true; |
| if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory( |
| data, 16, validation_context)) { |
| return false; |
| } |
| |
| // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if |
| // the message comes from an older version. |
| [[maybe_unused]] const Factory_CreateNamedObject_Params_Data* object = |
| static_cast<const Factory_CreateNamedObject_Params_Data*>(data); |
| |
| if (!mojo::internal::ValidateHandleOrInterfaceNonNullable( |
| object->obj, 1, validation_context)) { |
| return false; |
| } |
| if (!mojo::internal::ValidateHandleOrInterface(object->obj, |
| validation_context)) { |
| return false; |
| } |
| |
| return true; |
| } |
| |
| Factory_CreateNamedObject_Params_Data::Factory_CreateNamedObject_Params_Data() |
| : header_({sizeof(*this), 0}) {} |
| |
| |
| // static |
| bool Factory_RequestImportedInterface_Params_Data::Validate( |
| const void* data, |
| mojo::internal::ValidationContext* validation_context) { |
| if (!data) |
| return true; |
| if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory( |
| data, 16, validation_context)) { |
| return false; |
| } |
| |
| // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if |
| // the message comes from an older version. |
| [[maybe_unused]] const Factory_RequestImportedInterface_Params_Data* object = |
| static_cast<const Factory_RequestImportedInterface_Params_Data*>(data); |
| |
| if (!mojo::internal::ValidateHandleOrInterfaceNonNullable( |
| object->obj, 1, validation_context)) { |
| return false; |
| } |
| if (!mojo::internal::ValidateHandleOrInterface(object->obj, |
| validation_context)) { |
| return false; |
| } |
| |
| return true; |
| } |
| |
| Factory_RequestImportedInterface_Params_Data::Factory_RequestImportedInterface_Params_Data() |
| : header_({sizeof(*this), 0}) {} |
| |
| |
| // static |
| bool Factory_RequestImportedInterface_ResponseParams_Data::Validate( |
| const void* data, |
| mojo::internal::ValidationContext* validation_context) { |
| if (!data) |
| return true; |
| if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory( |
| data, 16, validation_context)) { |
| return false; |
| } |
| |
| // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if |
| // the message comes from an older version. |
| [[maybe_unused]] const Factory_RequestImportedInterface_ResponseParams_Data* object = |
| static_cast<const Factory_RequestImportedInterface_ResponseParams_Data*>(data); |
| |
| if (!mojo::internal::ValidateHandleOrInterfaceNonNullable( |
| object->obj, 1, validation_context)) { |
| return false; |
| } |
| if (!mojo::internal::ValidateHandleOrInterface(object->obj, |
| validation_context)) { |
| return false; |
| } |
| |
| return true; |
| } |
| |
| Factory_RequestImportedInterface_ResponseParams_Data::Factory_RequestImportedInterface_ResponseParams_Data() |
| : header_({sizeof(*this), 0}) {} |
| |
| |
| // static |
| bool Factory_TakeImportedInterface_Params_Data::Validate( |
| const void* data, |
| mojo::internal::ValidationContext* validation_context) { |
| if (!data) |
| return true; |
| if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory( |
| data, 16, validation_context)) { |
| return false; |
| } |
| |
| // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if |
| // the message comes from an older version. |
| [[maybe_unused]] const Factory_TakeImportedInterface_Params_Data* object = |
| static_cast<const Factory_TakeImportedInterface_Params_Data*>(data); |
| |
| if (!mojo::internal::ValidateHandleOrInterfaceNonNullable( |
| object->obj, 1, validation_context)) { |
| return false; |
| } |
| if (!mojo::internal::ValidateHandleOrInterface(object->obj, |
| validation_context)) { |
| return false; |
| } |
| |
| return true; |
| } |
| |
| Factory_TakeImportedInterface_Params_Data::Factory_TakeImportedInterface_Params_Data() |
| : header_({sizeof(*this), 0}) {} |
| |
| |
| // static |
| bool Factory_TakeImportedInterface_ResponseParams_Data::Validate( |
| const void* data, |
| mojo::internal::ValidationContext* validation_context) { |
| if (!data) |
| return true; |
| if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory( |
| data, 16, validation_context)) { |
| return false; |
| } |
| |
| // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if |
| // the message comes from an older version. |
| [[maybe_unused]] const Factory_TakeImportedInterface_ResponseParams_Data* object = |
| static_cast<const Factory_TakeImportedInterface_ResponseParams_Data*>(data); |
| |
| if (!mojo::internal::ValidateHandleOrInterfaceNonNullable( |
| object->obj, 1, validation_context)) { |
| return false; |
| } |
| if (!mojo::internal::ValidateHandleOrInterface(object->obj, |
| validation_context)) { |
| return false; |
| } |
| |
| return true; |
| } |
| |
| Factory_TakeImportedInterface_ResponseParams_Data::Factory_TakeImportedInterface_ResponseParams_Data() |
| : header_({sizeof(*this), 0}) {} |
| |
| } // namespace internal |
| } // namespace sample |