From 9eb7ac2634f454df94ade988c1dee01b64187603 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 5 Apr 2014 16:31:11 +0200 Subject: [PATCH 1/2] Update to current rust: struct fields are private by default. --- color.rs | 8 ++++---- layers.rs | 12 ++++++------ platform/android/surface.rs | 2 +- platform/linux/surface.rs | 2 +- scene.rs | 8 ++++---- texturegl.rs | 8 ++++---- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/color.rs b/color.rs index ed97527..85c8eb7 100644 --- a/color.rs +++ b/color.rs @@ -8,8 +8,8 @@ // except according to those terms. pub struct Color { - r: f32, - g: f32, - b: f32, - a: f32 + pub r: f32, + pub g: f32, + pub b: f32, + pub a: f32, } diff --git a/layers.rs b/layers.rs index a57e1be..c4d5775 100644 --- a/layers.rs +++ b/layers.rs @@ -44,7 +44,7 @@ pub struct CommonLayer { prev_sibling: Option, next_sibling: Option, - transform: Matrix4, + pub transform: Matrix4, } impl CommonLayer { @@ -65,10 +65,10 @@ pub fn CommonLayer() -> CommonLayer { pub struct ContainerLayer { - common: RefCell, + pub common: RefCell, first_child: RefCell>, last_child: RefCell>, - scissor: RefCell>>, + pub scissor: RefCell>>, } @@ -214,13 +214,13 @@ pub enum Flip { } pub struct TextureLayer { - common: RefCell, + pub common: RefCell, /// A handle to the GPU texture. - texture: Texture, + pub texture: Texture, /// The size of the texture in pixels. size: Size2D, /// Whether this texture is flipped vertically. - flip: Flip, + pub flip: Flip, } impl TextureLayer { diff --git a/platform/android/surface.rs b/platform/android/surface.rs index 72e240a..97b3d96 100644 --- a/platform/android/surface.rs +++ b/platform/android/surface.rs @@ -25,7 +25,7 @@ use std::libc::c_void; /// FIXME(Aydin Kim) :Currently, native surface is consist of 2 types of hybrid image buffer. EGLImageKHR is used to GPU rendering and vector is used to CPU rendering. EGL extension seems not provide simple way to accessing its bitmap directly. In the future, we need to find out the way to integrate them. pub struct NativeGraphicsMetadata { - display : EGLDisplay, + pub display: EGLDisplay, } pub struct NativePaintingGraphicsContext{ diff --git a/platform/linux/surface.rs b/platform/linux/surface.rs index 722192d..63c907a 100644 --- a/platform/linux/surface.rs +++ b/platform/linux/surface.rs @@ -119,7 +119,7 @@ impl NativeCompositingGraphicsContext { /// The X display. #[deriving(Clone)] pub struct NativeGraphicsMetadata { - display: *Display, + pub display: *Display, } impl NativeGraphicsMetadata { diff --git a/scene.rs b/scene.rs index 772d464..7737b55 100755 --- a/scene.rs +++ b/scene.rs @@ -13,10 +13,10 @@ use geom::size::Size2D; use geom::matrix::Matrix4; pub struct Scene { - root: Layer, - size: Size2D, - transform: Matrix4, - background_color: Color + pub root: Layer, + pub size: Size2D, + pub transform: Matrix4, + pub background_color: Color } pub fn Scene(root: Layer, size: Size2D, transform: Matrix4) -> Scene { diff --git a/texturegl.rs b/texturegl.rs index b016574..68eb6d4 100644 --- a/texturegl.rs +++ b/texturegl.rs @@ -48,12 +48,12 @@ impl TextureTarget { /// TODO: Include client storage here for `GL_CLIENT_STORAGE_APPLE`. pub struct Texture { /// The OpenGL texture ID. - priv id: GLuint, + id: GLuint, /// The texture target. - target: TextureTarget, + pub target: TextureTarget, /// Whether this texture is weak. Weak textures will not be cleaned up by /// the destructor. - priv weak: bool, + weak: bool, } impl Drop for Texture { @@ -88,7 +88,7 @@ impl Zero for Texture { /// Encapsulates a bound texture. This ensures that the texture is unbound /// properly. struct BoundTexture { - target: TextureTarget + pub target: TextureTarget } impl Drop for BoundTexture { From 01081bb9c20d3cb0cc407adb7b930f8947037474 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 5 Apr 2014 16:32:12 +0200 Subject: [PATCH 2/2] Update to current rust: RefCell::{get, set} are gone. --- layers.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/layers.rs b/layers.rs index c4d5775..2f73256 100644 --- a/layers.rs +++ b/layers.rs @@ -103,7 +103,7 @@ impl Iterator for ChildIterator { impl ContainerLayer { pub fn children(&self) -> ChildIterator { ChildIterator { - current: self.first_child.get().clone(), + current: self.first_child.borrow().clone(), } } @@ -117,7 +117,7 @@ impl ContainerLayer { new_child_common.parent = Some(ContainerLayerKind(pseudo_self.clone())); - match pseudo_self.first_child.get() { + match *pseudo_self.first_child.borrow() { None => {} Some(ref first_child) => { first_child.with_common(|first_child_common| { @@ -128,11 +128,11 @@ impl ContainerLayer { } } - pseudo_self.first_child.set(Some(new_child.clone())); + *pseudo_self.first_child.borrow_mut() = Some(new_child.clone()); - let should_set = pseudo_self.last_child.get().is_none(); + let should_set = pseudo_self.last_child.borrow().is_none(); if should_set { - pseudo_self.last_child.set(Some(new_child.clone())); + *pseudo_self.last_child.borrow_mut() = Some(new_child.clone()); } }); } @@ -148,7 +148,7 @@ impl ContainerLayer { new_child_common.parent = Some(ContainerLayerKind(pseudo_self.clone())); - match pseudo_self.last_child.get() { + match *pseudo_self.last_child.borrow() { None => {} Some(ref last_child) => { last_child.with_common(|last_child_common| { @@ -159,7 +159,7 @@ impl ContainerLayer { } } - pseudo_self.last_child.set(Some(new_child.clone())); + *pseudo_self.last_child.borrow_mut() = Some(new_child.clone()); let mut child = pseudo_self.first_child.borrow_mut(); match *child { @@ -182,7 +182,7 @@ impl ContainerLayer { match child_common.next_sibling { None => { // this is the last child - pseudo_self.last_child.set(child_common.prev_sibling.clone()); + *pseudo_self.last_child.borrow_mut() = child_common.prev_sibling.clone(); }, Some(ref sibling) => { sibling.with_common(|sibling_common| { @@ -192,7 +192,7 @@ impl ContainerLayer { } match child_common.prev_sibling { None => { // this is the first child - pseudo_self.first_child.set(child_common.next_sibling.clone()); + *pseudo_self.first_child.borrow_mut() = child_common.next_sibling.clone(); }, Some(ref sibling) => { sibling.with_common(|sibling_common| {