| class $CLASS { |
| public: |
| typedef internal::${CLASS}_Data Data; |
| |
| $CLASS() : data_(NULL) { |
| } |
| |
| template <typename U> |
| $CLASS(const U& u, mojo::Buffer* buf = mojo::Buffer::current()) { |
| *this = mojo::TypeConverter<$CLASS,U>::ConvertFrom(u, buf); |
| } |
| |
| template <typename U> |
| $CLASS& operator=(const U& u) { |
| *this = |
| mojo::TypeConverter<$CLASS,U>::ConvertFrom(u, mojo::Buffer::current()); |
| return *this; |
| } |
| |
| template <typename U> |
| operator U() const { |
| return To<U>(); |
| } |
| |
| template <typename U> |
| U To() const { |
| return mojo::TypeConverter<$CLASS,U>::ConvertTo(*this); |
| } |
| |
| bool is_null() const { return !data_; } |
| |
| $GETTERS |
| |
| class Builder { |
| public: |
| explicit Builder(mojo::Buffer* buf = mojo::Buffer::current()); |
| |
| $SETTERS |
| |
| $CLASS Finish(); |
| |
| private: |
| $CLASS::Data* data_; |
| MOJO_DISALLOW_COPY_AND_ASSIGN(Builder); |
| }; |
| |
| private: |
| friend class mojo::internal::WrapperHelper<$CLASS>; |
| |
| struct Wrap {}; |
| $CLASS(Wrap, const Data* data) : data_(data) {} |
| |
| const Data* data_; |
| }; |