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

Unified Diff: mojo/examples/pepper_container_app/type_converters.h

Issue 294833002: Mojo: more idiomatic C++ bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more 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 side-by-side diff with in-line comments
Download patch
Index: mojo/examples/pepper_container_app/type_converters.h
diff --git a/mojo/examples/pepper_container_app/type_converters.h b/mojo/examples/pepper_container_app/type_converters.h
index 3938b6e8dff581c38d0620db6f3af10921eaf020..e8d1753534df6c53eb0af8fea7cddd9e8f36cd0c 100644
--- a/mojo/examples/pepper_container_app/type_converters.h
+++ b/mojo/examples/pepper_container_app/type_converters.h
@@ -14,58 +14,52 @@
namespace mojo {
template <>
-class TypeConverter<Point, PP_Point> {
+class TypeConverter<PointPtr, PP_Point> {
public:
- static Point ConvertFrom(const PP_Point& input, Buffer* buf) {
- Point::Builder point(buf);
- point.set_x(input.x);
- point.set_y(input.y);
- return point.Finish();
+ static PointPtr ConvertFrom(const PP_Point& input) {
+ PointPtr point(Point::New());
+ point->x = input.x;
+ point->y = input.y;
+ return point.Pass();
}
- static PP_Point ConvertTo(const Point& input) {
- return PP_MakePoint(static_cast<int32_t>(input.x()),
- static_cast<int32_t>(input.y()));
+ static PP_Point ConvertTo(const PointPtr& input) {
+ return PP_MakePoint(static_cast<int32_t>(input->x),
+ static_cast<int32_t>(input->y));
}
-
- MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION();
};
template <>
-class TypeConverter<Size, PP_Size> {
+class TypeConverter<SizePtr, PP_Size> {
public:
- static Size ConvertFrom(const PP_Size& input, Buffer* buf) {
- Size::Builder size(buf);
- size.set_width(input.width);
- size.set_height(input.height);
- return size.Finish();
+ static SizePtr ConvertFrom(const PP_Size& input) {
+ SizePtr size(Size::New());
+ size->width = input.width;
+ size->height = input.height;
+ return size.Pass();
}
- static PP_Size ConvertTo(const Size& input) {
- return PP_MakeSize(static_cast<int32_t>(input.width()),
- static_cast<int32_t>(input.height()));
+ static PP_Size ConvertTo(const SizePtr& input) {
+ return PP_MakeSize(static_cast<int32_t>(input->width),
+ static_cast<int32_t>(input->height));
}
-
- MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION();
};
template <>
-class TypeConverter<Rect, PP_Rect> {
+class TypeConverter<RectPtr, PP_Rect> {
public:
- static Rect ConvertFrom(const PP_Rect& input, Buffer* buf) {
- Rect::Builder rect(buf);
- rect.set_position(input.point);
- rect.set_size(input.size);
- return rect.Finish();
+ static RectPtr ConvertFrom(const PP_Rect& input) {
+ RectPtr rect(Rect::New());
+ rect->position = Point::From(input.point);
+ rect->size = Size::From(input.size);
+ return rect.Pass();
}
- static PP_Rect ConvertTo(const Rect& input) {
- PP_Rect rect = { input.position().To<PP_Point>(),
- input.size().To<PP_Size>() };
+ static PP_Rect ConvertTo(const RectPtr& input) {
+ PP_Rect rect = { input->position.To<PP_Point>(),
+ input->size.To<PP_Size>() };
return rect;
}
-
- MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION();
};
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698