Index: mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl |
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl |
index 9c56d25b63da4f44de881aed8c9cfb790b286ba5..10dae9703a3db2ef45eb9ca4fe7cd90cd8765e4f 100644 |
--- a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl |
+++ b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl |
@@ -1,100 +1,29 @@ |
+ |
class {{struct.name}} { |
public: |
- typedef internal::{{struct.name}}_Data Data; |
- |
{#--- Constants #} |
-{% for constant in struct.constants %} |
+{%- for constant in struct.constants %} |
static const {{constant.kind|cpp_pod_type}} {{constant.name}}; |
{%- endfor %} |
- |
{#--- Enums #} |
{%- for enum in struct.enums -%} |
{% macro enum_def() %}{% include "enum_declaration.tmpl" %}{% endmacro %} |
{{enum_def()|indent(2)}} |
{%- endfor %} |
- |
- {{struct.name}}() : data_(NULL) { |
- } |
+ static {{struct.name}}Ptr New(); |
template <typename U> |
- {{struct.name}}(const U& u, mojo::Buffer* buf = mojo::Buffer::current()) { |
- mojo::TypeConverter<{{struct.name}},U>::AssertAllowImplicitTypeConversion(); |
- *this = mojo::TypeConverter<{{struct.name}},U>::ConvertFrom(u, buf); |
+ static {{struct.name}}Ptr From(const U& u) { |
+ return mojo::TypeConverter<{{struct.name}}Ptr, U>::ConvertFrom(u); |
} |
- template <typename U> |
- {{struct.name}}& operator=(const U& u) { |
- mojo::TypeConverter<{{struct.name}},U>::AssertAllowImplicitTypeConversion(); |
- *this = mojo::TypeConverter<{{struct.name}},U>::ConvertFrom(u, mojo::Buffer::current()); |
- return *this; |
- } |
- |
- template <typename U> |
- operator U() const { |
- mojo::TypeConverter<{{struct.name}},U>::AssertAllowImplicitTypeConversion(); |
- return To<U>(); |
- } |
- |
- template <typename U> |
- U To() const { |
- return mojo::TypeConverter<{{struct.name}},U>::ConvertTo(*this); |
- } |
- |
- template <typename U> |
- static {{struct.name}} From(const U& u, mojo::Buffer* buf = mojo::Buffer::current()) { |
- return mojo::TypeConverter<{{struct.name}},U>::ConvertFrom(u, buf); |
- } |
- |
- bool is_null() const { return !data_; } |
+ {{struct.name}}(); |
+ ~{{struct.name}}(); |
{#--- Getters #} |
-{% for packed_field in struct.packed.packed_fields %} |
-{%- set type = packed_field.field.kind|cpp_wrapper_type %} |
-{%- set name = packed_field.field.name %} |
-{%- if packed_field.field.kind|is_object_kind %} |
- const {{type}} {{name}}() const { {# |
- #}return mojo::internal::Wrap(data_->{{name}}()); } |
-{%- elif packed_field.field.kind|is_handle_kind %} |
- {{type}} {{name}}() const { return mojo::MakePassable(data_->{{name}}()); } |
-{%- elif packed_field.field.kind|is_enum_kind %} |
- {{type}} {{name}}() const { return static_cast<{{type}}>(data_->{{name}}()); } |
-{%- else %} |
- {{type}} {{name}}() const { return data_->{{name}}(); } |
-{%- endif %} |
-{%- endfor %} |
- |
- class Builder { |
- public: |
- explicit Builder(mojo::Buffer* buf = mojo::Buffer::current()); |
- |
-{#--- Setters #} |
-{% for packed_field in struct.packed.packed_fields %} |
-{%- set type = packed_field.field.kind|cpp_const_wrapper_type %} |
-{%- set name = packed_field.field.name %} |
-{%- if packed_field.field.kind|is_object_kind %} |
- void set_{{name}}({{type}} {{name}}) { {# |
- #}data_->set_{{name}}(mojo::internal::Unwrap({{name}})); } |
-{%- elif packed_field.field.kind|is_handle_kind %} |
- void set_{{name}}({{type}} {{name}}) { {# |
- #}data_->set_{{name}}({{name}}.release()); } |
-{%- else %} |
- void set_{{name}}({{type}} {{name}}) { {# |
- #}data_->set_{{name}}({{name}}); } |
-{%- endif %} |
+{% for field in struct.fields %} |
+{%- set type = field.kind|cpp_wrapper_type %} |
+{%- set name = field.name %} |
+ {{type}} {{name}}; |
{%- endfor %} |
- |
- {{struct.name}} Finish(); |
- |
- private: |
- {{struct.name}}::Data* data_; |
- MOJO_DISALLOW_COPY_AND_ASSIGN(Builder); |
- }; |
- |
- private: |
- friend class mojo::internal::WrapperHelper<{{struct.name}}>; |
- |
- struct Wrap {}; |
- {{struct.name}}(Wrap, const Data* data) : data_(data) {} |
- |
- const Data* data_; |
}; |