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

Side by Side Diff: mojo/public/tools/bindings/generators/cpp_templates/struct_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 "struct_macros.tmpl" as struct_macros %} 1 {%- import "struct_macros.tmpl" as struct_macros %}
2 {%- set class_name = struct.name ~ "_Data" %} 2 {%- set class_name = struct.name ~ "_Data" %}
3
3 // static 4 // static
4 {{class_name}}* {{class_name}}::New(mojo::Buffer* buf, mojo::Buffer::Destructor dtor) { 5 {{class_name}}* {{class_name}}::New(mojo::Buffer* buf, mojo::Buffer::Destructor dtor) {
5 return new (buf->Allocate(sizeof({{class_name}}), dtor)) {{class_name}}(); 6 return new (buf->Allocate(sizeof({{class_name}}), dtor)) {{class_name}}();
6 } 7 }
7 8
8 {{class_name}}::{{class_name}}() { 9 {{class_name}}::{{class_name}}() {
9 _header_.num_bytes = sizeof(*this); 10 _header_.num_bytes = sizeof(*this);
10 _header_.num_fields = {{struct.packed.packed_fields|length}}; 11 _header_.num_fields = {{struct.packed.packed_fields|length}};
11 } 12 }
12 13
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 45
45 void {{class_name}}::EncodePointersAndHandles( 46 void {{class_name}}::EncodePointersAndHandles(
46 std::vector<mojo::Handle>* handles) { 47 std::vector<mojo::Handle>* handles) {
47 {{ struct_macros.encodes(struct)|indent(2) }} 48 {{ struct_macros.encodes(struct)|indent(2) }}
48 } 49 }
49 50
50 bool {{class_name}}::DecodePointersAndHandles(mojo::Message* message) { 51 bool {{class_name}}::DecodePointersAndHandles(mojo::Message* message) {
51 {{ struct_macros.decodes(struct)|indent(2) }} 52 {{ struct_macros.decodes(struct)|indent(2) }}
52 return true; 53 return true;
53 } 54 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698