1 // Copyright 2013 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 {%- if variant -%} 6 {%- set variant_path = "%s-%s"|format(module.path, variant) -%} 7 {%- else -%} 8 {%- set variant_path = module.path -%} 9 {%- endif %} 10 11 #if defined(__clang__) 12 #pragma clang diagnostic push 13 #pragma clang diagnostic ignored "-Wunused-private-field" 14 #elif defined(_MSC_VER) 15 #pragma warning(push) 16 #pragma warning(disable:4056) 17 #pragma warning(disable:4065) 18 #pragma warning(disable:4756) 19 #endif 20 21 #include "{{variant_path}}.h" 22 23 #include <math.h> 24 #include <stdint.h> 25 #include <utility> 26 27 #include "base/logging.h" 28 #include "base/trace_event/trace_event.h" 29 #include "mojo/public/cpp/bindings/lib/map_data_internal.h" 30 #include "mojo/public/cpp/bindings/lib/message_builder.h" 31 #include "mojo/public/cpp/bindings/lib/serialization_util.h" 32 #include "mojo/public/cpp/bindings/lib/validate_params.h" 33 #include "mojo/public/cpp/bindings/lib/validation_context.h" 34 #include "mojo/public/cpp/bindings/lib/validation_errors.h" 35 #include "mojo/public/cpp/bindings/lib/validation_util.h" 36 #include "mojo/public/interfaces/bindings/interface_control_messages.mojom.h" 37 38 {%- if for_blink %} 39 #include "mojo/public/cpp/bindings/lib/wtf_serialization.h" 40 {%- endif %} 41 42 {%- for header in extra_traits_headers %} 43 #include "{{header}}" 44 {%- endfor %} 45 46 {%- for namespace in namespaces_as_array %} 47 namespace {{namespace}} { 48 {%- endfor %} 49 {%- if variant %} 50 namespace {{variant}} { 51 {%- endif %} 52 53 {#--- Constants #} 54 {%- for constant in module.constants %} 55 {%- if not constant.kind|is_integral_kind %} 56 const {{constant.kind|cpp_pod_type}} {{constant.name}} = {{constant|constant_value}}; 57 {%- endif %} 58 {%- endfor %} 59 60 namespace internal { 61 namespace { 62 63 #pragma pack(push, 1) 64 65 {#--- Interface parameter definitions #} 66 {%- for interface in interfaces %} 67 {%- for method in interface.methods %} 68 {%- set method_name = "k%s_%s_Name"|format(interface.name, method.name) %} 69 const uint32_t {{method_name}} = {{method.ordinal}}; 70 {% set struct = method.param_struct %} 71 {% include "struct_declaration.tmpl" %} 72 {%- include "struct_definition.tmpl" %} 73 {%- if method.response_parameters != None %} 74 {%- set struct = method.response_param_struct %} 75 {% include "struct_declaration.tmpl" %} 76 {%- include "struct_definition.tmpl" %} 77 {%- endif %} 78 {%- endfor %} 79 {%- endfor %} 80 81 #pragma pack(pop) 82 83 } // namespace 84 85 {#--- Struct definitions #} 86 {% for struct in structs %} 87 {%- if not struct|is_native_only_kind %} 88 {%- include "struct_definition.tmpl" %} 89 {%- endif %} 90 {%- endfor %} 91 92 {#--- Union definitions #} 93 {% for union in unions %} 94 {%- include "union_definition.tmpl" %} 95 {%- endfor %} 96 97 } // namespace internal 98 99 namespace { 100 101 {#--- Interface parameter data view definitions #} 102 {%- for interface in interfaces %} 103 {%- for method in interface.methods %} 104 {% set struct = method.param_struct %} 105 {% include "struct_data_view_declaration.tmpl" %} 106 {% include "struct_data_view_definition.tmpl" %} 107 {%- if method.response_parameters != None %} 108 {%- set struct = method.response_param_struct %} 109 {% include "struct_data_view_declaration.tmpl" %} 110 {% include "struct_data_view_definition.tmpl" %} 111 {%- endif %} 112 {%- endfor %} 113 {%- endfor %} 114 115 } // namespace 116 117 {#--- Struct Constants #} 118 {%- for struct in structs %} 119 {%- for constant in struct.constants %} 120 {%- if constant.kind|is_integral_kind %} 121 const {{constant.kind|cpp_pod_type}} {{struct.name}}::{{constant.name}}; 122 {%- else %} 123 const {{constant.kind|cpp_pod_type}} {{struct.name}}::{{constant.name}} = {{constant|constant_value}}; 124 {%- endif %} 125 {%- endfor %} 126 {%- endfor %} 127 128 {#--- Struct builder definitions #} 129 {%- for struct in structs %} 130 {%- if not struct|is_native_only_kind %} 131 {%- include "wrapper_class_definition.tmpl" %} 132 {%- include "struct_data_view_definition.tmpl" %} 133 {%- endif %} 134 {%- endfor %} 135 136 {#--- Union builder definitions #} 137 {%- for union in unions %} 138 {%- include "wrapper_union_class_definition.tmpl" %} 139 {%- endfor %} 140 141 {#--- Interface definitions #} 142 {%- for interface in interfaces %} 143 {%- include "interface_definition.tmpl" %} 144 {%- endfor %} 145 146 {%- if variant %} 147 } // namespace {{variant}} 148 {%- endif %} 149 {%- for namespace in namespaces_as_array|reverse %} 150 } // namespace {{namespace}} 151 {%- endfor %} 152 153 namespace mojo { 154 155 {#--- Struct Serialization Helpers -#} 156 {% for struct in structs %} 157 {%- if not struct|is_native_only_kind %} 158 {% include "struct_serialization_definition.tmpl" %} 159 {%- endif %} 160 {%- endfor %} 161 162 {#--- Union Serialization Helpers #} 163 {%- for union in unions %} 164 {%- include "union_serialization_definition.tmpl" %} 165 {%- endfor %} 166 167 } // namespace mojo 168 169 170 #if defined(__clang__) 171 #pragma clang diagnostic pop 172 #elif defined(_MSC_VER) 173 #pragma warning(pop) 174 #endif 175