Skip to content

Commit e2327a8

Browse files
committed
Finish implementing the TypeDesc API, adding license headers, etc
Signed-off-by: Scott Wilson <scott@propersquid.com>
1 parent 8a9c0fa commit e2327a8

File tree

8 files changed

+1066
-105
lines changed

8 files changed

+1066
-105
lines changed

src/rust/Cargo.toml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,13 @@ repository = "https://github.com/AcademySoftwareFoundation/OpenImageIO.git"
1818
[workspace]
1919
members = ["oiio-sys"]
2020

21-
[workspace.dependencies]
22-
cxx = { version = "1.0.143", features = ["c++17"] }
23-
thiserror = "2.0.12"
24-
2521
[dependencies]
26-
cxx = { workspace = true }
2722
oiio-sys = { path = "oiio-sys", version = "0.1.0" }
28-
thiserror = { workspace = true }
23+
thiserror = "2.0.12"
2924

3025
[dev-dependencies]
26+
proptest = "1.6.0"
27+
proptest-derive = "0.5.1"
3128

3229
# The docs are the same across all platforms so we only need to build once.
3330
[package.metadata.docs.rs]

src/rust/oiio-sys/build.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright Contributors to the OpenImageIO project.
2+
// SPDX-License-Identifier: Apache-2.0
3+
// https://github.com/AcademySoftwareFoundation/OpenImageIO
4+
15
use anyhow::Result;
26

37
const NAMES: &[&str] = &["typedesc"];

src/rust/oiio-sys/include/typedesc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright Contributors to the OpenImageIO project.
2+
// SPDX-License-Identifier: Apache-2.0
3+
// https://github.com/AcademySoftwareFoundation/OpenImageIO
4+
15
#pragma once
26

37
#include "rust/cxx.h"

src/rust/oiio-sys/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
// Copyright Contributors to the OpenImageIO project.
2+
// SPDX-License-Identifier: Apache-2.0
3+
// https://github.com/AcademySoftwareFoundation/OpenImageIO
4+
15
pub mod typedesc;

src/rust/oiio-sys/src/typedesc.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright Contributors to the OpenImageIO project.
2+
// SPDX-License-Identifier: Apache-2.0
3+
// https://github.com/AcademySoftwareFoundation/OpenImageIO
4+
15
#include "oiio-sys/include/typedesc.h"
26
#include "rust/cxx.h"
37
#include <OpenImageIO/string_view.h>

src/rust/oiio-sys/src/typedesc.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright Contributors to the OpenImageIO project.
2+
// SPDX-License-Identifier: Apache-2.0
3+
// https://github.com/AcademySoftwareFoundation/OpenImageIO
4+
15
pub use ffi::*;
26

37
/// A TypeDesc describes simple data types.
@@ -160,8 +164,8 @@ mod ffi {
160164
arraylen: i32,
161165
) -> TypeDesc;
162166

163-
/// Construct from a string (e.g., "float[3]"). If no valid
164-
/// type could be assembled, set base to UNKNOWN.
167+
/// Construct from a string (e.g., `float[3]`). If no valid
168+
/// type could be assembled, set base to `UNKNOWN`.
165169
///
166170
/// Examples:
167171
///
@@ -178,8 +182,8 @@ mod ffi {
178182
/// Clone constructor.
179183
fn typedesc_clone(t: &TypeDesc) -> TypeDesc;
180184

181-
/// Return the name, for printing and whatnot. For example,
182-
/// "float", "int[5]", "normal"
185+
/// Display the name, for printing and whatnot. For example,
186+
/// `float`, `int[5]`, `normal`
183187
fn typedesc_as_str(typedesc: &TypeDesc) -> &str;
184188

185189
/// Return the number of elements: 1 if not an array, or the array
@@ -261,13 +265,13 @@ mod ffi {
261265
/// inequality is differing vector semantics.
262266
fn typedesc_equivalent(typedesc: &TypeDesc, b: &TypeDesc) -> bool;
263267

264-
/// Is this a 2-vector aggregate (of the given type, float by default)?
268+
/// Is this a 2-vector aggregate (of the given type)?
265269
fn typedesc_is_vec2(typedesc: &TypeDesc, b: BaseType) -> bool;
266270

267-
/// Is this a 3-vector aggregate (of the given type, float by default)?
271+
/// Is this a 3-vector aggregate (of the given type)?
268272
fn typedesc_is_vec3(typedesc: &TypeDesc, b: BaseType) -> bool;
269273

270-
/// Is this a 4-vector aggregate (of the given type, float by default)?
274+
/// Is this a 4-vector aggregate (of the given type)?
271275
fn typedesc_is_vec4(typedesc: &TypeDesc, b: BaseType) -> bool;
272276

273277
/// Is this an array of aggregates that represents a 2D bounding box?
@@ -304,7 +308,7 @@ mod ffi {
304308
/// * If dsttype is int32 or uint32: other integer types will do their best
305309
/// (caveat emptor if you mix signed/unsigned). Also a source string will
306310
/// convert to int if and only if its characters form a valid integer.
307-
/// * If dsttype is float: inteegers and other float types will do
311+
/// * If dsttype is float: integers and other float types will do
308312
/// their best conversion; strings will convert if and only if their
309313
/// characters form a valid float number.
310314
fn typedesc_convert_type(

src/rust/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright Contributors to the OpenImageIO project.
2+
// SPDX-License-Identifier: Apache-2.0
3+
// https://github.com/AcademySoftwareFoundation/OpenImageIO
4+
15
/// Low-level oiio-sys FFI bindings to OpenImageIO.
26
use oiio_sys as sys;
37

0 commit comments

Comments
 (0)