| Index: mojo/public/tools/bindings/generators/cpp_templates/module-common.cc.tmpl
|
| diff --git a/mojo/public/tools/bindings/generators/cpp_templates/module-common.cc.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/module-common.cc.tmpl
|
| deleted file mode 100644
|
| index 1cbbeddfde0aa8a87e104833f333f69307ae5497..0000000000000000000000000000000000000000
|
| --- a/mojo/public/tools/bindings/generators/cpp_templates/module-common.cc.tmpl
|
| +++ /dev/null
|
| @@ -1,280 +0,0 @@
|
| -// NOTE: This file was generated by the Mojo bindings generator.
|
| -#include "{{module.path}}-common.h"
|
| -
|
| -#include <math.h>
|
| -#include <ostream>
|
| -
|
| -#include "mojo/public/cpp/bindings/lib/array_serialization.h"
|
| -#include "mojo/public/cpp/bindings/lib/bindings_serialization.h"
|
| -#include "mojo/public/cpp/bindings/lib/bounds_checker.h"
|
| -#include "mojo/public/cpp/bindings/lib/map_data_internal.h"
|
| -#include "mojo/public/cpp/bindings/lib/map_serialization.h"
|
| -#include "mojo/public/cpp/bindings/lib/message_builder.h"
|
| -#include "mojo/public/cpp/bindings/lib/message_validation.h"
|
| -#include "mojo/public/cpp/bindings/lib/string_serialization.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 "mojo/public/cpp/environment/logging.h"
|
| -#include "mojo/public/interfaces/bindings/interface_control_messages.mojom.h"
|
| -
|
| -{%- for namespace in namespaces_as_array %}
|
| -namespace {{namespace}} {
|
| -{%- endfor %}
|
| -
|
| -// --- Constants ---
|
| -{%- for constant in module.constants %}
|
| -{%- if not constant.kind|is_integral_kind %}
|
| -const {{constant.kind|cpp_pod_type}} {{constant.name}}
|
| - = {{constant|constant_value}};
|
| -{%- endif %}
|
| -{%- endfor %}
|
| -
|
| -namespace internal {
|
| -
|
| -// --- Struct definitions ---
|
| -{% for struct in structs %}
|
| -{%- include "struct_definition.tmpl" %}
|
| -{%- endfor %}
|
| -
|
| -// --- Union definitions ---
|
| -{% for union in unions %}
|
| -{%- include "union_definition.tmpl" %}
|
| -{%- endfor %}
|
| -
|
| -// --- Definitions of the data structs for interface methods ---
|
| -{%- for interface in interfaces %}
|
| -{%- for method in interface.methods %}
|
| -{% set struct = method.param_struct %}
|
| -{%- include "struct_definition.tmpl" %}
|
| -{%- if method.response_parameters != None %}
|
| -{%- set struct = method.response_param_struct %}
|
| -{%- include "struct_definition.tmpl" %}
|
| -{%- endif %}
|
| -{%- endfor %}
|
| -{%- endfor %}
|
| -
|
| -} // namespace internal
|
| -
|
| -// --- Request and response validator definitions for interfaces ---
|
| -{%- for interface in interfaces %}
|
| -{%- set base_name = "internal::%s_Base"|format(interface.name) %}
|
| -mojo::internal::ValidationError {{interface.name}}RequestValidator::Validate(
|
| - const mojo::Message* message,
|
| - std::string* err) {
|
| - mojo::internal::ValidationError retval;
|
| - if (mojo::internal::ControlMessageHandler::IsControlMessage(message)) {
|
| - retval = mojo::internal::ValidateControlRequest(message, err);
|
| - if (retval != mojo::internal::ValidationError::NONE) {
|
| - MOJO_INTERNAL_DEBUG_SET_ERROR_MSG(err)
|
| - << "request validation error for interface '{{interface.name}}', "
|
| - "message name '" << message->header()->name << "': " <<
|
| - (err ? *err : "");
|
| - ReportValidationError(retval, err);
|
| - return retval;
|
| - }
|
| - return mojo::internal::ValidationError::NONE;
|
| - }
|
| -
|
| - {{base_name}}::MessageOrdinals method_ordinal =
|
| - static_cast<{{base_name}}::MessageOrdinals>(message->header()->name);
|
| - switch (method_ordinal) {
|
| -{%- for method in interface.methods %}
|
| - case {{base_name}}::MessageOrdinals::{{method.name}}: {
|
| -{%- if method.response_parameters != None %}
|
| - retval =
|
| - mojo::internal::ValidateMessageIsRequestExpectingResponse(message,
|
| - err);
|
| - if (retval != mojo::internal::ValidationError::NONE) {
|
| - MOJO_INTERNAL_DEBUG_SET_ERROR_MSG(err)
|
| - << "request validation error for interface '{{interface.name}}', "
|
| - "message name '" << message->header()->name << "': " <<
|
| - (err ? *err : "");
|
| - ReportValidationError(retval, err);
|
| - return retval;
|
| - }
|
| -{%- else %}
|
| - retval = mojo::internal::ValidateMessageIsRequestWithoutResponse(message,
|
| - err);
|
| - if (retval != mojo::internal::ValidationError::NONE) {
|
| - MOJO_INTERNAL_DEBUG_SET_ERROR_MSG(err)
|
| - << "request validation error for interface '{{interface.name}}', "
|
| - "message name '" << message->header()->name << "': " <<
|
| - (err ? *err : "");
|
| - ReportValidationError(retval, err);
|
| - return retval;
|
| - }
|
| -{%- endif %}
|
| - retval = mojo::internal::ValidateMessagePayload<
|
| - internal::{{interface.name}}_{{method.name}}_Params_Data>(
|
| - message, err);
|
| - if (retval != mojo::internal::ValidationError::NONE) {
|
| - MOJO_INTERNAL_DEBUG_SET_ERROR_MSG(err)
|
| - << "request validation error for interface '{{interface.name}}', "
|
| - "message name '" << message->header()->name << "': " <<
|
| - (err ? *err : "");
|
| - ReportValidationError(retval, err);
|
| - return retval;
|
| - }
|
| - return mojo::internal::ValidationError::NONE;
|
| - }
|
| -{%- endfor %}
|
| - default:
|
| - break;
|
| - }
|
| -
|
| - // Unrecognized message.
|
| - MOJO_INTERNAL_DEBUG_SET_ERROR_MSG(err) << "unknown request message name '"
|
| - << message->header()->name
|
| - << "' for interface "
|
| - "'{{interface.name}}'";
|
| - ReportValidationError(
|
| - mojo::internal::ValidationError::MESSAGE_HEADER_UNKNOWN_METHOD, err);
|
| - return mojo::internal::ValidationError::MESSAGE_HEADER_UNKNOWN_METHOD;
|
| -}
|
| -
|
| -{#--- Response validator definitions #}
|
| -{%- if interface|has_callbacks %}
|
| -mojo::internal::ValidationError {{interface.name}}ResponseValidator::Validate(
|
| - const mojo::Message* message,
|
| - std::string* err) {
|
| - mojo::internal::ValidationError retval;
|
| - if (mojo::internal::ControlMessageHandler::IsControlMessage(message)) {
|
| - retval = mojo::internal::ValidateControlResponse(message, err);
|
| - if (retval != mojo::internal::ValidationError::NONE) {
|
| - MOJO_INTERNAL_DEBUG_SET_ERROR_MSG(err)
|
| - << "response validation error for interface '{{interface.name}}', "
|
| - "message name '" << message->header()->name << "': " <<
|
| - (err ? *err : "");
|
| - ReportValidationError(retval, err);
|
| - return retval;
|
| - }
|
| - return mojo::internal::ValidationError::NONE;
|
| - }
|
| -
|
| - retval = mojo::internal::ValidateMessageIsResponse(message, err);
|
| - if (retval != mojo::internal::ValidationError::NONE) {
|
| - MOJO_INTERNAL_DEBUG_SET_ERROR_MSG(err)
|
| - << "response validation error for interface '{{interface.name}}', "
|
| - "message name '" << message->header()->name << "': " <<
|
| - (err ? *err : "");
|
| - ReportValidationError(retval, err);
|
| - return retval;
|
| - }
|
| -
|
| - {{base_name}}::MessageOrdinals method_ordinal =
|
| - static_cast<{{base_name}}::MessageOrdinals>(message->header()->name);
|
| - switch (method_ordinal) {
|
| -{%- for method in interface.methods if method.response_parameters != None %}
|
| - case {{base_name}}::MessageOrdinals::{{method.name}}: {
|
| - retval = mojo::internal::ValidateMessagePayload<
|
| - internal::{{interface.name}}_{{method.name}}_ResponseParams_Data>(
|
| - message, err);
|
| - if (retval != mojo::internal::ValidationError::NONE) {
|
| - MOJO_INTERNAL_DEBUG_SET_ERROR_MSG(err)
|
| - << "response validation error for interface '{{interface.name}}',"
|
| - " message name '" << message->header()->name << "': " <<
|
| - (err ? *err : "");
|
| - ReportValidationError(retval, err);
|
| - return retval;
|
| - }
|
| - return mojo::internal::ValidationError::NONE;
|
| - }
|
| -{%- endfor %}
|
| - default:
|
| - break;
|
| - }
|
| -
|
| - // Unrecognized message.
|
| - MOJO_INTERNAL_DEBUG_SET_ERROR_MSG(err) << "unknown response message name '"
|
| - << message->header()->name
|
| - << "' for interface "
|
| - "'{{interface.name}}'";
|
| - ReportValidationError(
|
| - mojo::internal::ValidationError::MESSAGE_HEADER_UNKNOWN_METHOD, err);
|
| - return mojo::internal::ValidationError::MESSAGE_HEADER_UNKNOWN_METHOD;
|
| -}
|
| -{%- endif -%}
|
| -
|
| -{%- endfor %} {# for each interface #}
|
| -
|
| -// --- Enums ---
|
| -{%- from "enum_macros.tmpl" import is_valid_enum_def -%}
|
| -{%- from "enum_macros.tmpl" import global_enum_operators_def -%}
|
| -{%- for enum in enums -%}
|
| - {{is_valid_enum_def(enum, class_name='')}}
|
| - {{global_enum_operators_def(enum, class_name='')}}
|
| -{%- endfor %}
|
| -
|
| -// Base interface definitions (Name_, Version_, Constants, Enums)
|
| -{%- for interface in interfaces %}
|
| -{%- set base_name = "internal::%s_Base"|format(interface.name) -%}
|
| -{%- if interface.service_name %}
|
| -const char {{base_name}}::Name_[] = "{{interface.service_name}}";
|
| -{%- endif %}
|
| -const uint32_t {{base_name}}::Version_;
|
| -
|
| -// Constants
|
| -{%- for constant in interface.constants %}
|
| -{%- if constant.kind|is_integral_kind %}
|
| -const {{constant.kind|cpp_pod_type}} {{base_name}}::{{constant.name}};
|
| -{%- else %}
|
| -const {{constant.kind|cpp_pod_type}} {{base_name}}::{{constant.name}} = {{constant|constant_value}};
|
| -{%- endif %}
|
| -{%- endfor %}
|
| -
|
| -// Enums
|
| -{%- for enum in interface.enums %}
|
| - {{is_valid_enum_def(enum, class_name=base_name)}}
|
| - {{global_enum_operators_def(enum, class_name=base_name)}}
|
| -{%- endfor %}
|
| -{%- endfor %}
|
| -
|
| -// Struct Constants
|
| -{%- for struct in structs %}
|
| -{%- for constant in struct.constants %}
|
| -{%- if constant.kind|is_integral_kind %}
|
| -const {{constant.kind|cpp_pod_type}} {{struct.name}}::{{constant.name}};
|
| -{%- else %}
|
| -const {{constant.kind|cpp_pod_type}} {{struct.name}}::{{constant.name}} = {{constant|constant_value}};
|
| -{%- endif %}
|
| -{%- endfor %}
|
| -{%- endfor %}
|
| -
|
| -// --- Struct builder definitions ---
|
| -{%- for struct in structs %}
|
| -{%- include "wrapper_class_definition.tmpl" %}
|
| -{%- endfor %}
|
| -
|
| -// --- Union builder definitions ---
|
| -{%- for union in unions %}
|
| -{%- include "wrapper_union_class_definition.tmpl" %}
|
| -{%- endfor %}
|
| -
|
| -// --- Struct Serialization Helpers ---
|
| -{%- for struct in structs %}
|
| -{%- include "struct_serialization_definition.tmpl" %}
|
| -{%- endfor %}
|
| -
|
| -// --- Union Serialization Helpers ---
|
| -{%- for union in unions %}
|
| -{%- include "union_serialization_definition.tmpl" %}
|
| -{%- endfor %}
|
| -
|
| -// --- Structs for interface method parameters ---
|
| -{%- for interface in interfaces %}
|
| -{%- for method in interface.methods %}
|
| -{% set struct = method.param_struct %}
|
| -{%- include "wrapper_class_definition.tmpl" %}
|
| -{%- include "struct_serialization_definition.tmpl" %}
|
| -{%- if method.response_parameters != None %}
|
| -{%- set struct = method.response_param_struct %}
|
| -{%- include "wrapper_class_definition.tmpl" %}
|
| -{%- include "struct_serialization_definition.tmpl" %}
|
| -{%- endif %}
|
| -{%- endfor %}
|
| -{%- endfor %}
|
| -
|
| -{%- for namespace in namespaces_as_array|reverse %}
|
| -} // namespace {{namespace}}
|
| -{%- endfor %}
|
|
|