Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Side by Side Diff: mojo/public/tools/bindings/generators/cpp_templates/interface_definition.tmpl

Issue 268363003: Mojo: Add support for constants to the IDL compiler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: JS export constants Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 {%- import "interface_macros.tmpl" as interface_macros %} 1 {%- import "interface_macros.tmpl" as interface_macros %}
2 {%- set class_name = interface.name %} 2 {%- set class_name = interface.name %}
3 {%- set proxy_name = interface.name ~ "Proxy" %} 3 {%- set proxy_name = interface.name ~ "Proxy" %}
4 4
5 {%- macro pass_params(parameters) %} 5 {%- macro pass_params(parameters) %}
6 {%- for param in parameters %} 6 {%- for param in parameters %}
7 {%- if param.kind|is_object_kind -%} 7 {%- if param.kind|is_object_kind -%}
8 mojo::internal::Wrap(params->{{param.name}}()) 8 mojo::internal::Wrap(params->{{param.name}}())
9 {%- elif param.kind|is_handle_kind -%} 9 {%- elif param.kind|is_handle_kind -%}
10 mojo::MakePassable(params->{{param.name}}()).Pass() 10 mojo::MakePassable(params->{{param.name}}()).Pass()
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 params->set_{{param.name}}(in_{{param.name}}.release()); 42 params->set_{{param.name}}(in_{{param.name}}.release());
43 {%- else %} 43 {%- else %}
44 params->set_{{param.name}}(in_{{param.name}}); 44 params->set_{{param.name}}(in_{{param.name}});
45 {%- endif %} 45 {%- endif %}
46 {%- endfor %} 46 {%- endfor %}
47 mojo::Message message; 47 mojo::Message message;
48 params->EncodePointersAndHandles(message.mutable_handles()); 48 params->EncodePointersAndHandles(message.mutable_handles());
49 builder.Finish(&message); 49 builder.Finish(&message);
50 {%- endmacro %} 50 {%- endmacro %}
51 51
52 {#--- Begin #}
53
54 {#--- Constants #}
55 {% for constant in interface.constants %}
56 const {{constant.kind|cpp_pod_type}} {{interface.name}}::{{constant.name}} = {{c onstant.value|expression_to_text(module)}};
57 {%- endfor %}
58
52 {#--- ForwardToCallback definition #} 59 {#--- ForwardToCallback definition #}
53 {%- for method in interface.methods -%} 60 {%- for method in interface.methods -%}
54 {%- if method.response_parameters != None %} 61 {%- if method.response_parameters != None %}
55 class {{class_name}}_{{method.name}}_ForwardToCallback 62 class {{class_name}}_{{method.name}}_ForwardToCallback
56 : public mojo::MessageReceiver { 63 : public mojo::MessageReceiver {
57 public: 64 public:
58 {{class_name}}_{{method.name}}_ForwardToCallback( 65 {{class_name}}_{{method.name}}_ForwardToCallback(
59 const {{interface_macros.declare_callback(method)}}& callback) 66 const {{interface_macros.declare_callback(method)}}& callback)
60 : callback_(callback) { 67 : callback_(callback) {
61 } 68 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 return true; 226 return true;
220 {%- else %} 227 {%- else %}
221 break; 228 break;
222 {%- endif %} 229 {%- endif %}
223 } 230 }
224 {%- endfor %} 231 {%- endfor %}
225 } 232 }
226 {%- endif %} 233 {%- endif %}
227 return false; 234 return false;
228 } 235 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698