Home | History | Annotate | Download | only in cpp_templates
      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 {%- set header_guard = "%s_SHARED_INTERNAL_H_"|format(
      6         module.path|upper|replace("/","_")|replace(".","_")|
      7             replace("-", "_")) %}
      8 
      9 #ifndef {{header_guard}}
     10 #define {{header_guard}}
     11 
     12 #include <stdint.h>
     13 
     14 #include "mojo/public/cpp/bindings/lib/array_internal.h"
     15 #include "mojo/public/cpp/bindings/lib/bindings_internal.h"
     16 #include "mojo/public/cpp/bindings/lib/map_data_internal.h"
     17 #include "mojo/public/cpp/bindings/lib/native_enum_data.h"
     18 #include "mojo/public/cpp/bindings/lib/native_struct_data.h"
     19 #include "mojo/public/cpp/bindings/lib/buffer.h"
     20 
     21 {%- for import in imports %}
     22 #include "{{import.module.path}}-shared-internal.h"
     23 {%- endfor %}
     24 
     25 namespace mojo {
     26 namespace internal {
     27 class ValidationContext;
     28 }
     29 }
     30 
     31 {%- for namespace in namespaces_as_array %}
     32 namespace {{namespace}} {
     33 {%- endfor %}
     34 namespace internal {
     35 
     36 {#--- Internal forward declarations #}
     37 {%- for struct in structs %}
     38 {%-   if struct|is_native_only_kind %}
     39 using {{struct.name}}_Data = mojo::internal::NativeStruct_Data;
     40 {%-   else %}
     41 class {{struct.name}}_Data;
     42 {%-   endif %}
     43 {%- endfor %}
     44 
     45 {%- for union in unions %}
     46 class {{union.name}}_Data;
     47 {%- endfor %}
     48 
     49 {#--- Enums #}
     50 {%- from "enum_macros.tmpl" import enum_data_decl -%}
     51 {%- for enum in all_enums %}
     52 {%-   if enum|is_native_only_kind %}
     53 using {{enum|get_name_for_kind(flatten_nested_kind=True)}}_Data =
     54     mojo::internal::NativeEnum_Data;
     55 {%-   else %}
     56 {{enum_data_decl(enum)}}
     57 {%-   endif %}
     58 {%- endfor %}
     59 
     60 #pragma pack(push, 1)
     61 
     62 {#--- Unions must be declared first because they can be members of structs #}
     63 {#--- Union class declarations #}
     64 {%- for union in unions %}
     65 {%    include "union_declaration.tmpl" %}
     66 {%- endfor %}
     67 
     68 {#--- Struct class declarations #}
     69 {%- for struct in structs %}
     70 {%-   if not struct|is_native_only_kind %}
     71 {%      include "struct_declaration.tmpl" %}
     72 {%-   endif %}
     73 {%- endfor %}
     74 
     75 {#--- Interface parameter definitions #}
     76 {%- for interface in interfaces %}
     77 {%-   for method in interface.methods %}
     78 {%-     set method_name = "k%s_%s_Name"|format(interface.name, method.name) %}
     79 constexpr uint32_t {{method_name}} = {{method.ordinal}};
     80 {%-     set struct = method.param_struct %}
     81 {%      include "struct_declaration.tmpl" %}
     82 {%-     if method.response_parameters != None %}
     83 {%-       set struct = method.response_param_struct %}
     84 {%        include "struct_declaration.tmpl" %}
     85 {%-     endif %}
     86 {%-   endfor %}
     87 {%- endfor %}
     88 
     89 #pragma pack(pop)
     90 
     91 }  // namespace internal
     92 {%- for namespace in namespaces_as_array|reverse %}
     93 }  // namespace {{namespace}}
     94 {%- endfor %}
     95 
     96 #endif  // {{header_guard}}
     97