Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Commit

Permalink
graphene: Add new* for each init*
Browse files Browse the repository at this point in the history
  • Loading branch information
sfanxiang committed Mar 6, 2019
1 parent 54985ac commit 0cb45bf
Show file tree
Hide file tree
Showing 36 changed files with 845 additions and 168 deletions.
24 changes: 12 additions & 12 deletions src/auto/box_.rs
Expand Up @@ -125,21 +125,21 @@ impl Box {
}
}

pub fn init(&mut self, min: Option<&Point3D>, max: Option<&Point3D>) -> Option<Box> {
pub fn init(&mut self, min: Option<&Point3D>, max: Option<&Point3D>) {
unsafe {
from_glib_none(ffi::graphene_box_init(self.to_glib_none_mut().0, min.to_glib_none().0, max.to_glib_none().0))
ffi::graphene_box_init(self.to_glib_none_mut().0, min.to_glib_none().0, max.to_glib_none().0);
}
}

pub fn init_from_box(&mut self, src: &Box) -> Option<Box> {
pub fn init_from_box(&mut self, src: &Box) {
unsafe {
from_glib_none(ffi::graphene_box_init_from_box(self.to_glib_none_mut().0, src.to_glib_none().0))
ffi::graphene_box_init_from_box(self.to_glib_none_mut().0, src.to_glib_none().0);
}
}

pub fn init_from_vec3(&mut self, min: Option<&Vec3>, max: Option<&Vec3>) -> Option<Box> {
pub fn init_from_vec3(&mut self, min: Option<&Vec3>, max: Option<&Vec3>) {
unsafe {
from_glib_none(ffi::graphene_box_init_from_vec3(self.to_glib_none_mut().0, min.to_glib_none().0, max.to_glib_none().0))
ffi::graphene_box_init_from_vec3(self.to_glib_none_mut().0, min.to_glib_none().0, max.to_glib_none().0);
}
}

Expand All @@ -159,42 +159,42 @@ impl Box {
}
}

pub fn empty() -> Option<Box> {
pub fn empty() -> Box {
assert_initialized_main_thread!();
unsafe {
from_glib_none(ffi::graphene_box_empty())
}
}

pub fn infinite() -> Option<Box> {
pub fn infinite() -> Box {
assert_initialized_main_thread!();
unsafe {
from_glib_none(ffi::graphene_box_infinite())
}
}

pub fn minus_one() -> Option<Box> {
pub fn minus_one() -> Box {
assert_initialized_main_thread!();
unsafe {
from_glib_none(ffi::graphene_box_minus_one())
}
}

pub fn one() -> Option<Box> {
pub fn one() -> Box {
assert_initialized_main_thread!();
unsafe {
from_glib_none(ffi::graphene_box_one())
}
}

pub fn one_minus_one() -> Option<Box> {
pub fn one_minus_one() -> Box {
assert_initialized_main_thread!();
unsafe {
from_glib_none(ffi::graphene_box_one_minus_one())
}
}

pub fn zero() -> Option<Box> {
pub fn zero() -> Box {
assert_initialized_main_thread!();
unsafe {
from_glib_none(ffi::graphene_box_zero())
Expand Down
24 changes: 12 additions & 12 deletions src/auto/euler.rs
Expand Up @@ -52,39 +52,39 @@ impl Euler {
}
}

pub fn init(&mut self, x: f32, y: f32, z: f32) -> Option<Euler> {
pub fn init(&mut self, x: f32, y: f32, z: f32) {
unsafe {
from_glib_none(ffi::graphene_euler_init(self.to_glib_none_mut().0, x, y, z))
ffi::graphene_euler_init(self.to_glib_none_mut().0, x, y, z);
}
}

pub fn init_from_euler(&mut self, src: Option<&Euler>) -> Option<Euler> {
pub fn init_from_euler(&mut self, src: Option<&Euler>) {
unsafe {
from_glib_none(ffi::graphene_euler_init_from_euler(self.to_glib_none_mut().0, src.to_glib_none().0))
ffi::graphene_euler_init_from_euler(self.to_glib_none_mut().0, src.to_glib_none().0);
}
}

pub fn init_from_matrix(&mut self, m: Option<&Matrix>, order: EulerOrder) -> Option<Euler> {
pub fn init_from_matrix(&mut self, m: Option<&Matrix>, order: EulerOrder) {
unsafe {
from_glib_none(ffi::graphene_euler_init_from_matrix(self.to_glib_none_mut().0, m.to_glib_none().0, order.to_glib()))
ffi::graphene_euler_init_from_matrix(self.to_glib_none_mut().0, m.to_glib_none().0, order.to_glib());
}
}

pub fn init_from_quaternion(&mut self, q: Option<&Quaternion>, order: EulerOrder) -> Option<Euler> {
pub fn init_from_quaternion(&mut self, q: Option<&Quaternion>, order: EulerOrder) {
unsafe {
from_glib_none(ffi::graphene_euler_init_from_quaternion(self.to_glib_none_mut().0, q.to_glib_none().0, order.to_glib()))
ffi::graphene_euler_init_from_quaternion(self.to_glib_none_mut().0, q.to_glib_none().0, order.to_glib());
}
}

pub fn init_from_vec3(&mut self, v: Option<&Vec3>, order: EulerOrder) -> Option<Euler> {
pub fn init_from_vec3(&mut self, v: Option<&Vec3>, order: EulerOrder) {
unsafe {
from_glib_none(ffi::graphene_euler_init_from_vec3(self.to_glib_none_mut().0, v.to_glib_none().0, order.to_glib()))
ffi::graphene_euler_init_from_vec3(self.to_glib_none_mut().0, v.to_glib_none().0, order.to_glib());
}
}

pub fn init_with_order(&mut self, x: f32, y: f32, z: f32, order: EulerOrder) -> Option<Euler> {
pub fn init_with_order(&mut self, x: f32, y: f32, z: f32, order: EulerOrder) {
unsafe {
from_glib_none(ffi::graphene_euler_init_with_order(self.to_glib_none_mut().0, x, y, z, order.to_glib()))
ffi::graphene_euler_init_with_order(self.to_glib_none_mut().0, x, y, z, order.to_glib());
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/auto/frustum.rs
Expand Up @@ -39,21 +39,21 @@ impl Frustum {
// unsafe { TODO: call ffi::graphene_frustum_get_planes() }
//}

pub fn init(&mut self, p0: &Plane, p1: &Plane, p2: &Plane, p3: &Plane, p4: &Plane, p5: &Plane) -> Option<Frustum> {
pub fn init(&mut self, p0: &Plane, p1: &Plane, p2: &Plane, p3: &Plane, p4: &Plane, p5: &Plane) {
unsafe {
from_glib_none(ffi::graphene_frustum_init(self.to_glib_none_mut().0, p0.to_glib_none().0, p1.to_glib_none().0, p2.to_glib_none().0, p3.to_glib_none().0, p4.to_glib_none().0, p5.to_glib_none().0))
ffi::graphene_frustum_init(self.to_glib_none_mut().0, p0.to_glib_none().0, p1.to_glib_none().0, p2.to_glib_none().0, p3.to_glib_none().0, p4.to_glib_none().0, p5.to_glib_none().0);
}
}

pub fn init_from_frustum(&mut self, src: &Frustum) -> Option<Frustum> {
pub fn init_from_frustum(&mut self, src: &Frustum) {
unsafe {
from_glib_none(ffi::graphene_frustum_init_from_frustum(self.to_glib_none_mut().0, src.to_glib_none().0))
ffi::graphene_frustum_init_from_frustum(self.to_glib_none_mut().0, src.to_glib_none().0);
}
}

pub fn init_from_matrix(&mut self, matrix: &Matrix) -> Option<Frustum> {
pub fn init_from_matrix(&mut self, matrix: &Matrix) {
unsafe {
from_glib_none(ffi::graphene_frustum_init_from_matrix(self.to_glib_none_mut().0, matrix.to_glib_none().0))
ffi::graphene_frustum_init_from_matrix(self.to_glib_none_mut().0, matrix.to_glib_none().0);
}
}

Expand Down
50 changes: 25 additions & 25 deletions src/auto/matrix.rs
Expand Up @@ -68,79 +68,79 @@ impl Matrix {
}
}

pub fn init_from_2d(&mut self, xx: f64, yx: f64, xy: f64, yy: f64, x_0: f64, y_0: f64) -> Option<Matrix> {
pub fn init_from_2d(&mut self, xx: f64, yx: f64, xy: f64, yy: f64, x_0: f64, y_0: f64) {
unsafe {
from_glib_none(ffi::graphene_matrix_init_from_2d(self.to_glib_none_mut().0, xx, yx, xy, yy, x_0, y_0))
ffi::graphene_matrix_init_from_2d(self.to_glib_none_mut().0, xx, yx, xy, yy, x_0, y_0);
}
}

//pub fn init_from_float(&mut self, v: /*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 20 }; 16) -> Option<Matrix> {
//pub fn init_from_float(&mut self, v: /*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 20 }; 16) {
// unsafe { TODO: call ffi::graphene_matrix_init_from_float() }
//}

pub fn init_from_matrix(&mut self, src: &Matrix) -> Option<Matrix> {
pub fn init_from_matrix(&mut self, src: &Matrix) {
unsafe {
from_glib_none(ffi::graphene_matrix_init_from_matrix(self.to_glib_none_mut().0, src.to_glib_none().0))
ffi::graphene_matrix_init_from_matrix(self.to_glib_none_mut().0, src.to_glib_none().0);
}
}

pub fn init_from_vec4(&mut self, v0: &Vec4, v1: &Vec4, v2: &Vec4, v3: &Vec4) -> Option<Matrix> {
pub fn init_from_vec4(&mut self, v0: &Vec4, v1: &Vec4, v2: &Vec4, v3: &Vec4) {
unsafe {
from_glib_none(ffi::graphene_matrix_init_from_vec4(self.to_glib_none_mut().0, v0.to_glib_none().0, v1.to_glib_none().0, v2.to_glib_none().0, v3.to_glib_none().0))
ffi::graphene_matrix_init_from_vec4(self.to_glib_none_mut().0, v0.to_glib_none().0, v1.to_glib_none().0, v2.to_glib_none().0, v3.to_glib_none().0);
}
}

pub fn init_frustum(&mut self, left: f32, right: f32, bottom: f32, top: f32, z_near: f32, z_far: f32) -> Option<Matrix> {
pub fn init_frustum(&mut self, left: f32, right: f32, bottom: f32, top: f32, z_near: f32, z_far: f32) {
unsafe {
from_glib_none(ffi::graphene_matrix_init_frustum(self.to_glib_none_mut().0, left, right, bottom, top, z_near, z_far))
ffi::graphene_matrix_init_frustum(self.to_glib_none_mut().0, left, right, bottom, top, z_near, z_far);
}
}

pub fn init_identity(&mut self) -> Option<Matrix> {
pub fn init_identity(&mut self) {
unsafe {
from_glib_none(ffi::graphene_matrix_init_identity(self.to_glib_none_mut().0))
ffi::graphene_matrix_init_identity(self.to_glib_none_mut().0);
}
}

pub fn init_look_at(&mut self, eye: &Vec3, center: &Vec3, up: &Vec3) -> Option<Matrix> {
pub fn init_look_at(&mut self, eye: &Vec3, center: &Vec3, up: &Vec3) {
unsafe {
from_glib_none(ffi::graphene_matrix_init_look_at(self.to_glib_none_mut().0, eye.to_glib_none().0, center.to_glib_none().0, up.to_glib_none().0))
ffi::graphene_matrix_init_look_at(self.to_glib_none_mut().0, eye.to_glib_none().0, center.to_glib_none().0, up.to_glib_none().0);
}
}

pub fn init_ortho(&mut self, left: f32, right: f32, top: f32, bottom: f32, z_near: f32, z_far: f32) -> Option<Matrix> {
pub fn init_ortho(&mut self, left: f32, right: f32, top: f32, bottom: f32, z_near: f32, z_far: f32) {
unsafe {
from_glib_none(ffi::graphene_matrix_init_ortho(self.to_glib_none_mut().0, left, right, top, bottom, z_near, z_far))
ffi::graphene_matrix_init_ortho(self.to_glib_none_mut().0, left, right, top, bottom, z_near, z_far);
}
}

pub fn init_perspective(&mut self, fovy: f32, aspect: f32, z_near: f32, z_far: f32) -> Option<Matrix> {
pub fn init_perspective(&mut self, fovy: f32, aspect: f32, z_near: f32, z_far: f32) {
unsafe {
from_glib_none(ffi::graphene_matrix_init_perspective(self.to_glib_none_mut().0, fovy, aspect, z_near, z_far))
ffi::graphene_matrix_init_perspective(self.to_glib_none_mut().0, fovy, aspect, z_near, z_far);
}
}

pub fn init_rotate(&mut self, angle: f32, axis: &Vec3) -> Option<Matrix> {
pub fn init_rotate(&mut self, angle: f32, axis: &Vec3) {
unsafe {
from_glib_none(ffi::graphene_matrix_init_rotate(self.to_glib_none_mut().0, angle, axis.to_glib_none().0))
ffi::graphene_matrix_init_rotate(self.to_glib_none_mut().0, angle, axis.to_glib_none().0);
}
}

pub fn init_scale(&mut self, x: f32, y: f32, z: f32) -> Option<Matrix> {
pub fn init_scale(&mut self, x: f32, y: f32, z: f32) {
unsafe {
from_glib_none(ffi::graphene_matrix_init_scale(self.to_glib_none_mut().0, x, y, z))
ffi::graphene_matrix_init_scale(self.to_glib_none_mut().0, x, y, z);
}
}

pub fn init_skew(&mut self, x_skew: f32, y_skew: f32) -> Option<Matrix> {
pub fn init_skew(&mut self, x_skew: f32, y_skew: f32) {
unsafe {
from_glib_none(ffi::graphene_matrix_init_skew(self.to_glib_none_mut().0, x_skew, y_skew))
ffi::graphene_matrix_init_skew(self.to_glib_none_mut().0, x_skew, y_skew);
}
}

pub fn init_translate(&mut self, p: &Point3D) -> Option<Matrix> {
pub fn init_translate(&mut self, p: &Point3D) {
unsafe {
from_glib_none(ffi::graphene_matrix_init_translate(self.to_glib_none_mut().0, p.to_glib_none().0))
ffi::graphene_matrix_init_translate(self.to_glib_none_mut().0, p.to_glib_none().0);
}
}

Expand Down
20 changes: 10 additions & 10 deletions src/auto/plane.rs
Expand Up @@ -47,33 +47,33 @@ impl Plane {
}
}

pub fn init(&mut self, normal: Option<&Vec3>, constant: f32) -> Option<Plane> {
pub fn init(&mut self, normal: Option<&Vec3>, constant: f32) {
unsafe {
from_glib_none(ffi::graphene_plane_init(self.to_glib_none_mut().0, normal.to_glib_none().0, constant))
ffi::graphene_plane_init(self.to_glib_none_mut().0, normal.to_glib_none().0, constant);
}
}

pub fn init_from_plane(&mut self, src: &Plane) -> Option<Plane> {
pub fn init_from_plane(&mut self, src: &Plane) {
unsafe {
from_glib_none(ffi::graphene_plane_init_from_plane(self.to_glib_none_mut().0, src.to_glib_none().0))
ffi::graphene_plane_init_from_plane(self.to_glib_none_mut().0, src.to_glib_none().0);
}
}

pub fn init_from_point(&mut self, normal: &Vec3, point: &Point3D) -> Option<Plane> {
pub fn init_from_point(&mut self, normal: &Vec3, point: &Point3D) {
unsafe {
from_glib_none(ffi::graphene_plane_init_from_point(self.to_glib_none_mut().0, normal.to_glib_none().0, point.to_glib_none().0))
ffi::graphene_plane_init_from_point(self.to_glib_none_mut().0, normal.to_glib_none().0, point.to_glib_none().0);
}
}

pub fn init_from_points(&mut self, a: &Point3D, b: &Point3D, c: &Point3D) -> Option<Plane> {
pub fn init_from_points(&mut self, a: &Point3D, b: &Point3D, c: &Point3D) {
unsafe {
from_glib_none(ffi::graphene_plane_init_from_points(self.to_glib_none_mut().0, a.to_glib_none().0, b.to_glib_none().0, c.to_glib_none().0))
ffi::graphene_plane_init_from_points(self.to_glib_none_mut().0, a.to_glib_none().0, b.to_glib_none().0, c.to_glib_none().0);
}
}

pub fn init_from_vec4(&mut self, src: &Vec4) -> Option<Plane> {
pub fn init_from_vec4(&mut self, src: &Vec4) {
unsafe {
from_glib_none(ffi::graphene_plane_init_from_vec4(self.to_glib_none_mut().0, src.to_glib_none().0))
ffi::graphene_plane_init_from_vec4(self.to_glib_none_mut().0, src.to_glib_none().0);
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/auto/point.rs
Expand Up @@ -35,21 +35,21 @@ impl Point {
}
}

pub fn init(&mut self, x: f32, y: f32) -> Option<Point> {
pub fn init(&mut self, x: f32, y: f32) {
unsafe {
from_glib_none(ffi::graphene_point_init(self.to_glib_none_mut().0, x, y))
ffi::graphene_point_init(self.to_glib_none_mut().0, x, y);
}
}

pub fn init_from_point(&mut self, src: &Point) -> Option<Point> {
pub fn init_from_point(&mut self, src: &Point) {
unsafe {
from_glib_none(ffi::graphene_point_init_from_point(self.to_glib_none_mut().0, src.to_glib_none().0))
ffi::graphene_point_init_from_point(self.to_glib_none_mut().0, src.to_glib_none().0);
}
}

pub fn init_from_vec2(&mut self, src: &Vec2) -> Option<Point> {
pub fn init_from_vec2(&mut self, src: &Vec2) {
unsafe {
from_glib_none(ffi::graphene_point_init_from_vec2(self.to_glib_none_mut().0, src.to_glib_none().0))
ffi::graphene_point_init_from_vec2(self.to_glib_none_mut().0, src.to_glib_none().0);
}
}

Expand All @@ -75,7 +75,7 @@ impl Point {
}
}

pub fn zero() -> Option<Point> {
pub fn zero() -> Point {
assert_initialized_main_thread!();
unsafe {
from_glib_none(ffi::graphene_point_zero())
Expand Down
14 changes: 7 additions & 7 deletions src/auto/point3_d.rs
Expand Up @@ -48,21 +48,21 @@ impl Point3D {
}
}

pub fn init(&mut self, x: f32, y: f32, z: f32) -> Option<Point3D> {
pub fn init(&mut self, x: f32, y: f32, z: f32) {
unsafe {
from_glib_none(ffi::graphene_point3d_init(self.to_glib_none_mut().0, x, y, z))
ffi::graphene_point3d_init(self.to_glib_none_mut().0, x, y, z);
}
}

pub fn init_from_point(&mut self, src: &Point3D) -> Option<Point3D> {
pub fn init_from_point(&mut self, src: &Point3D) {
unsafe {
from_glib_none(ffi::graphene_point3d_init_from_point(self.to_glib_none_mut().0, src.to_glib_none().0))
ffi::graphene_point3d_init_from_point(self.to_glib_none_mut().0, src.to_glib_none().0);
}
}

pub fn init_from_vec3(&mut self, v: &Vec3) -> Option<Point3D> {
pub fn init_from_vec3(&mut self, v: &Vec3) {
unsafe {
from_glib_none(ffi::graphene_point3d_init_from_vec3(self.to_glib_none_mut().0, v.to_glib_none().0))
ffi::graphene_point3d_init_from_vec3(self.to_glib_none_mut().0, v.to_glib_none().0);
}
}

Expand Down Expand Up @@ -118,7 +118,7 @@ impl Point3D {
}
}

pub fn zero() -> Option<Point3D> {
pub fn zero() -> Point3D {
assert_initialized_main_thread!();
unsafe {
from_glib_none(ffi::graphene_point3d_zero())
Expand Down

0 comments on commit 0cb45bf

Please sign in to comment.