Home | History | Annotate | Download | only in cpp_templates
      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 {%- set header_guard = "%s_H_"|
      6         format(module.path|upper|replace("/","_")|replace(".","_")) %}
      7 
      8 #ifndef {{header_guard}}
      9 #define {{header_guard}}
     10 
     11 #include "mojo/public/cpp/bindings/array.h"
     12 #include "mojo/public/cpp/bindings/callback.h"
     13 #include "mojo/public/cpp/bindings/interface_impl.h"
     14 #include "mojo/public/cpp/bindings/interface_ptr.h"
     15 #include "mojo/public/cpp/bindings/interface_request.h"
     16 #include "mojo/public/cpp/bindings/message_filter.h"
     17 #include "mojo/public/cpp/bindings/no_interface.h"
     18 #include "mojo/public/cpp/bindings/string.h"
     19 #include "mojo/public/cpp/bindings/struct_ptr.h"
     20 #include "{{module.path}}-internal.h"
     21 {%- for import in imports %}
     22 #include "{{import.module.path}}.h"
     23 {%- endfor %}
     24 
     25 {%- for namespace in namespaces_as_array %}
     26 namespace {{namespace}} {
     27 {%- endfor %}
     28 
     29 {#--- Constants #}
     30 {%  for constant in module.constants %}
     31 extern const {{constant.kind|cpp_pod_type}} {{constant.name}};
     32 {%- endfor %}
     33 
     34 {#--- Enums #}
     35 {%  for enum in enums %}
     36 {%    include "enum_declaration.tmpl" %}
     37 {%- endfor %}
     38 
     39 {#--- Interface Forward Declarations -#}
     40 {%  for interface in interfaces %}
     41 class {{interface.name}};
     42 typedef mojo::InterfacePtr<{{interface.name}}> {{interface.name}}Ptr;
     43 {%  endfor %}
     44 
     45 {#--- Struct Forward Declarations -#}
     46 {%  for struct in structs %}
     47 class {{struct.name}};
     48 {%    if struct|should_inline %}
     49 typedef mojo::InlinedStructPtr<{{struct.name}}> {{struct.name}}Ptr;
     50 {%    else %}
     51 typedef mojo::StructPtr<{{struct.name}}> {{struct.name}}Ptr;
     52 {%    endif %}
     53 {%  endfor %}
     54 
     55 {#--- NOTE: Non-inlined structs may have pointers to inlined structs, so we  #}
     56 {#---       need to fully define inlined structs ahead of the others.        #}
     57 
     58 {#--- Inlined structs #}
     59 {%  for struct in structs %}
     60 {%    if struct|should_inline %}
     61 {%      include "wrapper_class_declaration.tmpl" %}
     62 {%    endif %}
     63 {%- endfor %}
     64 
     65 {#--- Non-inlined structs #}
     66 {%  for struct in structs %}
     67 {%    if not struct|should_inline %}
     68 {%      include "wrapper_class_declaration.tmpl" %}
     69 {%    endif %}
     70 {%- endfor %}
     71 
     72 {#--- Interfaces -#}
     73 {%  for interface in interfaces %}
     74 {%    include "interface_declaration.tmpl" %}
     75 {%- endfor %}
     76 
     77 {#--- Interface Proxies -#}
     78 {%  for interface in interfaces %}
     79 {%    include "interface_proxy_declaration.tmpl" %}
     80 {%- endfor %}
     81 
     82 {#--- Interface Stubs -#}
     83 {%  for interface in interfaces %}
     84 {%    include "interface_stub_declaration.tmpl" %}
     85 {%- endfor %}
     86 
     87 {#--- Interface Request Validators -#}
     88 {%  for interface in interfaces %}
     89 {%    include "interface_request_validator_declaration.tmpl" %}
     90 {%- endfor %}
     91 
     92 {#--- Interface Response Validators -#}
     93 {%  for interface in interfaces if interface|has_callbacks %}
     94 {%    include "interface_response_validator_declaration.tmpl" %}
     95 {%- endfor %}
     96 
     97 {#--- Struct Serialization Helpers -#}
     98 {%  if structs %}
     99 {%    for struct in structs %}
    100 {%      include "struct_serialization_declaration.tmpl" %}
    101 {%-   endfor %}
    102 {%- endif %}
    103 
    104 {%- for namespace in namespaces_as_array|reverse %}
    105 }  // namespace {{namespace}}
    106 {%- endfor %}
    107 
    108 #endif  // {{header_guard}}
    109