From 7718f50e449ed1e55c3de236bdcf25d5db30c5e6 Mon Sep 17 00:00:00 2001 From: YOSHIOKA Takuma Date: Sun, 25 Aug 2019 18:15:55 +0900 Subject: [PATCH 01/19] Forbid unsafe code This makes it explicit that this crate does not use unsafe code, and prevent from using `unsafe` by accident. --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index 79c4713..9c88f72 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,6 +12,7 @@ //! //! `writer` module provides writer types. //! To use `writer` module, enable `writer` feature. +#![forbid(unsafe_code)] #![warn(missing_docs)] #![warn(clippy::missing_docs_in_private_items)] From 63c350ff42e572e360584725e9c6286698b405f9 Mon Sep 17 00:00:00 2001 From: YOSHIOKA Takuma Date: Fri, 4 Oct 2019 03:47:57 +0900 Subject: [PATCH 02/19] Bump `env_logger` to 0.7 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index cc8345e..4d620b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ log = "0.4.4" string-interner = { version = "0.7", optional = true, default-features = false } [dev-dependencies] -env_logger = "0.6" +env_logger = "0.7" [badges] maintenance = { status = "actively-developed" } From 5a6ba8be4481edfd2f05d46f45d18786f8e69023 Mon Sep 17 00:00:00 2001 From: YOSHIOKA Takuma Date: Wed, 6 Nov 2019 02:34:58 +0900 Subject: [PATCH 03/19] Update links to travis CI status --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 66fc8b3..be06ba8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # fbxcel -[![Build Status](https://travis-ci.org/lo48576/fbxcel.svg?branch=develop)](https://travis-ci.org/lo48576/fbxcel) +[![Build Status](https://travis-ci.com/lo48576/fbxcel.svg?branch=develop)](https://travis-ci.com/lo48576/fbxcel) [![Latest version](https://img.shields.io/crates/v/fbxcel.svg)](https://crates.io/crates/fbxcel) [![Documentation](https://docs.rs/fbxcel/badge.svg)](https://docs.rs/fbxcel) ![Minimum rustc version: 1.34](https://img.shields.io/badge/rustc-1.34+-lightgray.svg) From 5e08c8144c6cedae912a40c1f7c598e8874133dd Mon Sep 17 00:00:00 2001 From: YOSHIOKA Takuma Date: Wed, 6 Nov 2019 01:50:25 +0900 Subject: [PATCH 04/19] Add CI test for dependencies with minimal versions This adds a test with MSRV and dependencies of minimal versions. If this test fails, `Cargo.toml` contains inaccurate dependencies specification. --- .travis.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.travis.yml b/.travis.yml index 886caf7..505ea76 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,16 @@ rust: - stable - beta - 1.34.0 +jobs: + include: + - rust: 1.34.0 + env: TEST_MINIMAL_VERSIONS=1 script: + - | + if [ "${TEST_MINIMAL_VERSIONS:-0}" -ne 0 ] ; then + rustup install nightly + cargo +nightly update -Z minimal-versions + fi - cargo build --verbose --all-features - cargo test --verbose --all-features notifications: From 881f8a81069f3657be9ec8146cc1c976e567ea84 Mon Sep 17 00:00:00 2001 From: YOSHIOKA Takuma Date: Tue, 19 Nov 2019 23:48:08 +0900 Subject: [PATCH 05/19] Put tools installation and deps update to correct stages Additionally, build and test at once (because they are not independent: `cargo test` always fails if `cargo build` fails). --- .travis.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 505ea76..153b57e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,13 +8,19 @@ jobs: include: - rust: 1.34.0 env: TEST_MINIMAL_VERSIONS=1 -script: +before_install: - | if [ "${TEST_MINIMAL_VERSIONS:-0}" -ne 0 ] ; then rustup install nightly + fi +before_script: + # Use dependencies with minimal versions. + - | + if [ "${TEST_MINIMAL_VERSIONS:-0}" -ne 0 ] ; then cargo +nightly update -Z minimal-versions fi - - cargo build --verbose --all-features - - cargo test --verbose --all-features +script: + # TODO: Use `--workspace` instead of `--all` for Rust 1.39 or later. + - cargo build --verbose --all --all-features && cargo test --verbose --all --all-features notifications: email: false From a64bc42b44da88a30b9849328d08e13c7a33f646 Mon Sep 17 00:00:00 2001 From: YOSHIOKA Takuma Date: Tue, 19 Nov 2019 23:50:36 +0900 Subject: [PATCH 06/19] Check lint warnings and format of the code --- .travis.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.travis.yml b/.travis.yml index 153b57e..39f8ffe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,15 @@ jobs: include: - rust: 1.34.0 env: TEST_MINIMAL_VERSIONS=1 + - rust: 1.34.0 + env: LINT=1 before_install: + - | + if [ "${LINT:-0}" -ne 0 ] ; then + rustup component add clippy rustfmt + cargo clippy --version + cargo fmt --version + fi - | if [ "${TEST_MINIMAL_VERSIONS:-0}" -ne 0 ] ; then rustup install nightly @@ -22,5 +30,9 @@ before_script: script: # TODO: Use `--workspace` instead of `--all` for Rust 1.39 or later. - cargo build --verbose --all --all-features && cargo test --verbose --all --all-features + # Fail if the code is correctly formatted. + - if [ "${LINT:-0}" -ne 0 ] ; then cargo fmt --all -- --check ; fi + # Fail if the code has warnings. + - if [ "${LINT:-0}" -ne 0 ] ; then cargo clippy --all-features -- --deny warnings ; fi notifications: email: false From bebdabbef604ba360c531aacc560b7428167be85 Mon Sep 17 00:00:00 2001 From: YOSHIOKA Takuma Date: Wed, 20 Nov 2019 03:43:29 +0900 Subject: [PATCH 07/19] Prevent usual tests from running in lint job --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 39f8ffe..48649c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ before_script: fi script: # TODO: Use `--workspace` instead of `--all` for Rust 1.39 or later. - - cargo build --verbose --all --all-features && cargo test --verbose --all --all-features + - if [ "${LINT:-0}" -eq 0 ] ; then cargo build --verbose --all --all-features && cargo test --verbose --all --all-features ; fi # Fail if the code is correctly formatted. - if [ "${LINT:-0}" -ne 0 ] ; then cargo fmt --all -- --check ; fi # Fail if the code has warnings. From 8a8593c5770871a019a1ba27cb3d54def387e1fa Mon Sep 17 00:00:00 2001 From: YOSHIOKA Takuma Date: Thu, 21 Nov 2019 23:03:59 +0900 Subject: [PATCH 08/19] Use `Iterator::flatten()` instead of `flat_map(identity)` --- src/tree/v7400/node/handle.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tree/v7400/node/handle.rs b/src/tree/v7400/node/handle.rs index 2877ece..e1d0799 100644 --- a/src/tree/v7400/node/handle.rs +++ b/src/tree/v7400/node/handle.rs @@ -82,7 +82,7 @@ impl<'a> NodeHandle<'a> { .node_name_sym(name) .map(|sym| self.children().filter(move |child| child.name_sym() == sym)) .into_iter() - .flat_map(|iter| iter) + .flatten() } /// Compares nodes strictly. From be8ace29db0bcd035e80cf7a9237f9edacdba512 Mon Sep 17 00:00:00 2001 From: YOSHIOKA Takuma Date: Thu, 21 Nov 2019 23:09:06 +0900 Subject: [PATCH 09/19] Make parser error types nonexhaustive Made `DataError`, `OperationError` and `Warning` types nonexhaustive to make future changes non-breaking. --- src/pull_parser/error/data.rs | 3 +++ src/pull_parser/error/operation.rs | 3 +++ src/pull_parser/error/warning.rs | 3 +++ 3 files changed, 9 insertions(+) diff --git a/src/pull_parser/error/data.rs b/src/pull_parser/error/data.rs index 70544b8..3b92ec8 100644 --- a/src/pull_parser/error/data.rs +++ b/src/pull_parser/error/data.rs @@ -43,6 +43,8 @@ pub enum DataError { /// /// The former is the expected, the latter is a description of the actual value. UnexpectedAttribute(String, String), + #[doc(hidden)] + __Nonexhaustive, } impl error::Error for DataError { @@ -86,6 +88,7 @@ impl fmt::Display for DataError { "Unexpected attribute value or type: expected {}, got {}", expected, got ), + DataError::__Nonexhaustive => unreachable!("`__Nonexhaustive` should never used"), } } } diff --git a/src/pull_parser/error/operation.rs b/src/pull_parser/error/operation.rs index 731b016..b0e18ab 100644 --- a/src/pull_parser/error/operation.rs +++ b/src/pull_parser/error/operation.rs @@ -13,6 +13,8 @@ pub enum OperationError { AlreadyFinished, /// Attempt to create a parser with unsupported FBX version. UnsupportedFbxVersion(ParserVersion, FbxVersion), + #[doc(hidden)] + __Nonexhaustive, } impl error::Error for OperationError {} @@ -32,6 +34,7 @@ impl fmt::Display for OperationError { "Unsupported FBX version: parser={:?}, fbx={:?}", parser, fbx ), + OperationError::__Nonexhaustive => unreachable!("`__Nonexhaustive` should never used"), } } } diff --git a/src/pull_parser/error/warning.rs b/src/pull_parser/error/warning.rs index 209265b..8d903f2 100644 --- a/src/pull_parser/error/warning.rs +++ b/src/pull_parser/error/warning.rs @@ -19,6 +19,8 @@ pub enum Warning { InvalidFooterPaddingLength(usize, usize), /// Unexpected value for footer fields (mainly for unknown fields). UnexpectedFooterFieldValue, + #[doc(hidden)] + __Nonexhaustive, } impl error::Error for Warning {} @@ -36,6 +38,7 @@ impl fmt::Display for Warning { expected, got ), Warning::UnexpectedFooterFieldValue => write!(f, "Unexpected footer field value"), + Warning::__Nonexhaustive => unreachable!("`__Nonexhaustive` should never used"), } } } From 14c2cb85fb9de79c153c926db72e9525c1d02c5b Mon Sep 17 00:00:00 2001 From: YOSHIOKA Takuma Date: Thu, 21 Nov 2019 23:12:36 +0900 Subject: [PATCH 10/19] Update CHANGELOG --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f510d79..1f5b7a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ ## [Unreleased] +* `pull_parser::error::{DataError, OperationError, Warning}` is now nonexhaustive. + + This would make some of future changes non-breaking. + +### Breaking changes + +* `pull_parser::error::{DataError, OperationError, Warning}` is now nonexhaustive. + + This would make some of future changes non-breaking. + ## [0.4.4] * Documents are improved a little. From 4818c4c572345881c0d7731fa6e1c957647f1aa4 Mon Sep 17 00:00:00 2001 From: YOSHIOKA Takuma Date: Thu, 21 Nov 2019 23:16:43 +0900 Subject: [PATCH 11/19] Make absence of necessary node end markers warning Previously this was rejected as critical error, but now it is warning and parser can continue parsing. --- src/pull_parser/error/warning.rs | 3 + src/pull_parser/v7400/parser.rs | 12 +- tests/missing-and-extra-node-end-marker.rs | 135 +++++++++++++++++++++ 3 files changed, 141 insertions(+), 9 deletions(-) create mode 100644 tests/missing-and-extra-node-end-marker.rs diff --git a/src/pull_parser/error/warning.rs b/src/pull_parser/error/warning.rs index 8d903f2..70a79af 100644 --- a/src/pull_parser/error/warning.rs +++ b/src/pull_parser/error/warning.rs @@ -17,6 +17,8 @@ pub enum Warning { IncorrectBooleanRepresentation, /// Footer padding length is invalid. InvalidFooterPaddingLength(usize, usize), + /// Missing a node end marker where the marker is expected. + MissingNodeEndMarker, /// Unexpected value for footer fields (mainly for unknown fields). UnexpectedFooterFieldValue, #[doc(hidden)] @@ -37,6 +39,7 @@ impl fmt::Display for Warning { "Invalid footer padding length: expected {} bytes, got {} bytes", expected, got ), + Warning::MissingNodeEndMarker => write!(f, "Missing node end marker"), Warning::UnexpectedFooterFieldValue => write!(f, "Unexpected footer field value"), Warning::__Nonexhaustive => unreachable!("`__Nonexhaustive` should never used"), } diff --git a/src/pull_parser/v7400/parser.rs b/src/pull_parser/v7400/parser.rs index 24ed73d..a8774c0 100644 --- a/src/pull_parser/v7400/parser.rs +++ b/src/pull_parser/v7400/parser.rs @@ -2,8 +2,6 @@ use std::{fmt, io}; -use log::debug; - use crate::{ low::{ v7400::{FbxFooter, NodeHeader}, @@ -304,13 +302,9 @@ impl Parser { // It's odd, the current node should have a node end marker // at the ending, but `node_end_offset` data tells that the // node ends without node end marker. - debug!( - "DataError::NodeLengthMismatch, node_end_offset={}, event_start_offset={}", - current_node.node_end_offset, event_start_offset - ); - return Err( - DataError::NodeLengthMismatch(current_node.node_end_offset, None).into(), - ); + self.warn(Warning::MissingNodeEndMarker, self.position())?; + self.state.started_nodes.pop(); + return Ok(EventKind::EndNode); } } } diff --git a/tests/missing-and-extra-node-end-marker.rs b/tests/missing-and-extra-node-end-marker.rs new file mode 100644 index 0000000..ad8d731 --- /dev/null +++ b/tests/missing-and-extra-node-end-marker.rs @@ -0,0 +1,135 @@ +//! Tests for writer, tree, and parser. +#![cfg(all(feature = "tree", feature = "writer"))] + +use std::{cell::RefCell, io::Cursor, iter, rc::Rc}; + +use fbxcel::{ + low::FbxVersion, + pull_parser::{ + any::{from_seekable_reader, AnyParser}, + error::Warning, + }, +}; + +use self::v7400::writer::{ + expect_fbx_end, expect_node_end, expect_node_start, CUSTOM_UNKNOWN1, MAGIC, UNKNOWN3, +}; + +mod v7400; + +/// Parses a node which lacks necessary node end marker. +#[test] +fn missing_node_end_marker() -> Result<(), Box> { + let data = { + let raw_ver = 7400_u32; + let mut vec = Vec::new(); + // Header. + { + // Magic. + vec.extend(MAGIC); + // Version. + vec.extend(&raw_ver.to_le_bytes()); + } + // Nodes. + { + // Container node. + { + const CONTAINER: &[u8] = b"Container"; + let container_start = vec.len(); + // End offset. + vec.extend(&[0; 4]); + // Number of node properties. + vec.extend(&[0; 4]); + // Length of node properties in bytes. + vec.extend(&[0; 4]); + // Node name length. + vec.push(CONTAINER.len() as u8); + // Node name. + vec.extend(CONTAINER); + + // Invalid node. + { + const INVALID_NODE: &[u8] = b"InvalidNode"; + let invalid_node_start = vec.len(); + // End offset. + vec.extend(&[0; 4]); + // Number of node properties. + vec.extend(&[0; 4]); + // Length of node properties in bytes. + vec.extend(&[0; 4]); + // Node name length. + vec.push(INVALID_NODE.len() as u8); + // Node name. + vec.extend(INVALID_NODE); + let end_pos = (vec.len() as u32).to_le_bytes(); + vec[invalid_node_start..(invalid_node_start + 4)].copy_from_slice(&end_pos); + } + + // Node end marker. + vec.extend(&[0; 13]); + let end_pos = (vec.len() as u32).to_le_bytes(); + vec[container_start..(container_start + 4)].copy_from_slice(&end_pos); + } + // End of implicit root. + { + vec.extend(iter::repeat(0).take(4 * 3 + 1)); + } + } + // Footer. + { + // Footer: unknown1. + vec.extend(&CUSTOM_UNKNOWN1); + // Footer: padding. + { + let len = vec.len().wrapping_neg() % 16; + assert_eq!((vec.len() + len) % 16, 0); + vec.extend(iter::repeat(0).take(len)); + } + // Footer: unknown2. + vec.extend(&[0; 4]); + // Footer: FBX version. + vec.extend(&raw_ver.to_le_bytes()); + // Footer: 120 zeroes. + vec.extend(iter::repeat(0).take(120)); + // Footer: unknown3. + vec.extend(&UNKNOWN3); + } + vec + }; + + assert_eq!(data.len() % 16, 0); + + let mut parser = match from_seekable_reader(Cursor::new(data))? { + AnyParser::V7400(parser) => parser, + _ => panic!("Generated data should be parsable with v7400 parser"), + }; + let warnings = Rc::new(RefCell::new(Vec::new())); + parser.set_warning_handler({ + let warnings = warnings.clone(); + move |warning, _pos| { + warnings.borrow_mut().push(warning); + Ok(()) + } + }); + assert_eq!(parser.fbx_version(), FbxVersion::V7_4); + + { + let attrs = expect_node_start(&mut parser, "Container")?; + assert_eq!(attrs.total_count(), 0); + } + { + let attrs = expect_node_start(&mut parser, "InvalidNode")?; + assert_eq!(attrs.total_count(), 0); + } + expect_node_end(&mut parser)?; + expect_node_end(&mut parser)?; + + let _: Box = expect_fbx_end(&mut parser)??; + + match &warnings.borrow()[..] { + [Warning::MissingNodeEndMarker] => {} + v => panic!("Unexpected warnings: {:?}", v), + } + + Ok(()) +} From a00e7a75baa714cec4e0e1f86753b189edd4894b Mon Sep 17 00:00:00 2001 From: YOSHIOKA Takuma Date: Thu, 21 Nov 2019 23:18:37 +0900 Subject: [PATCH 12/19] Emit warning for extra (unnecessary) node end marker Previously this was silently ignored, but this is invalid and should be notified to users. --- src/pull_parser/error/warning.rs | 3 + src/pull_parser/v7400/parser.rs | 5 + tests/missing-and-extra-node-end-marker.rs | 121 +++++++++++++++++++++ 3 files changed, 129 insertions(+) diff --git a/src/pull_parser/error/warning.rs b/src/pull_parser/error/warning.rs index 70a79af..93a750f 100644 --- a/src/pull_parser/error/warning.rs +++ b/src/pull_parser/error/warning.rs @@ -7,6 +7,8 @@ use std::{error, fmt}; pub enum Warning { /// Node name is empty. EmptyNodeName, + /// Extra (unexpected) node end marker found. + ExtraNodeEndMarker, /// Incorrect boolean representation. /// /// Boolean value in node attributes should be some prescribed value @@ -31,6 +33,7 @@ impl fmt::Display for Warning { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Warning::EmptyNodeName => write!(f, "Node name is empty"), + Warning::ExtraNodeEndMarker => write!(f, "Extra (unexpected) node end marker found"), Warning::IncorrectBooleanRepresentation => { write!(f, "Incorrect boolean representation") } diff --git a/src/pull_parser/v7400/parser.rs b/src/pull_parser/v7400/parser.rs index a8774c0..7d6dcd2 100644 --- a/src/pull_parser/v7400/parser.rs +++ b/src/pull_parser/v7400/parser.rs @@ -326,6 +326,11 @@ impl Parser { ) .into()); } + if closing.attributes_count != 0 && closing.known_children_count == 0 { + // It's odd, the current node should not have a node end + // marker at the ending, but found. + self.warn(Warning::ExtraNodeEndMarker, self.position())?; + } Ok(EventKind::EndNode) } None => Ok(EventKind::EndFbx), diff --git a/tests/missing-and-extra-node-end-marker.rs b/tests/missing-and-extra-node-end-marker.rs index ad8d731..25c4d0a 100644 --- a/tests/missing-and-extra-node-end-marker.rs +++ b/tests/missing-and-extra-node-end-marker.rs @@ -133,3 +133,124 @@ fn missing_node_end_marker() -> Result<(), Box> { Ok(()) } + +/// Parses a node which has extra node end marker. +#[test] +fn extra_node_end_marker() -> Result<(), Box> { + let data = { + let raw_ver = 7400_u32; + let mut vec = Vec::new(); + // Header. + { + // Magic. + vec.extend(MAGIC); + // Version. + vec.extend(&raw_ver.to_le_bytes()); + } + // Nodes. + { + // Container node. + { + const CONTAINER: &[u8] = b"Container"; + let container_start = vec.len(); + // End offset. + vec.extend(&[0; 4]); + // Number of node properties. + vec.extend(&[0; 4]); + // Length of node properties in bytes. + vec.extend(&[0; 4]); + // Node name length. + vec.push(CONTAINER.len() as u8); + // Node name. + vec.extend(CONTAINER); + + // Invalid node. + { + const INVALID_NODE: &[u8] = b"InvalidNode"; + let invalid_node_start = vec.len(); + // End offset. + vec.extend(&[0; 4]); + // Number of node properties. + vec.extend(&1_u32.to_le_bytes()); + // Length of node properties in bytes. + vec.extend(&2_u32.to_le_bytes()); + // Node name length. + vec.push(INVALID_NODE.len() as u8); + // Node name. + vec.extend(INVALID_NODE); + // An attribute. + vec.extend(&[b'C', b'T']); + // Extra node end marker. + vec.extend(&[0; 13]); + let end_pos = (vec.len() as u32).to_le_bytes(); + vec[invalid_node_start..(invalid_node_start + 4)].copy_from_slice(&end_pos); + } + + // Node end marker. + vec.extend(&[0; 13]); + let end_pos = (vec.len() as u32).to_le_bytes(); + vec[container_start..(container_start + 4)].copy_from_slice(&end_pos); + } + // End of implicit root. + { + vec.extend(iter::repeat(0).take(4 * 3 + 1)); + } + } + // Footer. + { + // Footer: unknown1. + vec.extend(&CUSTOM_UNKNOWN1); + // Footer: padding. + { + let len = vec.len().wrapping_neg() % 16; + assert_eq!((vec.len() + len) % 16, 0); + vec.extend(iter::repeat(0).take(len)); + } + // Footer: unknown2. + vec.extend(&[0; 4]); + // Footer: FBX version. + vec.extend(&raw_ver.to_le_bytes()); + // Footer: 120 zeroes. + vec.extend(iter::repeat(0).take(120)); + // Footer: unknown3. + vec.extend(&UNKNOWN3); + } + vec + }; + + assert_eq!(data.len() % 16, 0); + + let mut parser = match from_seekable_reader(Cursor::new(data))? { + AnyParser::V7400(parser) => parser, + _ => panic!("Generated data should be parsable with v7400 parser"), + }; + let warnings = Rc::new(RefCell::new(Vec::new())); + parser.set_warning_handler({ + let warnings = warnings.clone(); + move |warning, _pos| { + warnings.borrow_mut().push(warning); + Ok(()) + } + }); + assert_eq!(parser.fbx_version(), FbxVersion::V7_4); + + { + let attrs = expect_node_start(&mut parser, "Container")?; + assert_eq!(attrs.total_count(), 0); + } + { + let attrs = expect_node_start(&mut parser, "InvalidNode")?; + assert_eq!(attrs.total_count(), 1); + } + expect_node_end(&mut parser)?; + expect_node_end(&mut parser)?; + + let _: Box = expect_fbx_end(&mut parser)??; + + match &warnings.borrow()[..] { + [Warning::ExtraNodeEndMarker] => {} + v => panic!("Unexpected warnings: {:?}", v), + } + + Ok(()) +} From f985b6edf1fa471f59f508dff60afd9e8385d864 Mon Sep 17 00:00:00 2001 From: YOSHIOKA Takuma Date: Fri, 22 Nov 2019 01:33:09 +0900 Subject: [PATCH 13/19] Update CHANGELOG --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f5b7a5..d4685b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,25 @@ * `pull_parser::error::{DataError, OperationError, Warning}` is now nonexhaustive. + This would make some of future changes non-breaking. +* Support parsing nodes with missing or extra node end markers. + + Previously, they are ignored or causing critical errors. + Now they are notified as warnings, and users can continue parsing. + + Two new variants `Warning::{ExtraNodeEndMarker, MissingNodeEndMarker}` are added to + `pull_parser::error::Warning` type. + - Note that `Warning` have been nonexhaustive since this release. ### Breaking changes * `pull_parser::error::{DataError, OperationError, Warning}` is now nonexhaustive. + This would make some of future changes non-breaking. +* Support parsing nodes with missing or extra node end markers. + + Previously, missing node end markers caused errors, and extra node end markers were silently + ignored. + Now they are notified as warnings. + Users can choose whether to continue or abort processing. + + Two new variants `Warning::{ExtraNodeEndMarker, MissingNodeEndMarker}` are added to + `pull_parser::error::Warning` type. + - Note that `Warning` have been nonexhaustive since this release. ## [0.4.4] From c964fe53099e692164ab2e05eae7952b62f96130 Mon Sep 17 00:00:00 2001 From: YOSHIOKA Takuma Date: Fri, 22 Nov 2019 02:04:57 +0900 Subject: [PATCH 14/19] Remove deprecated items The items below are removed: * `low::FbxHeader::read_fbx_header()` * `pull_parser::v7400::attribute::DirectAttributeValue` --- src/low/fbx_header.rs | 6 ------ src/pull_parser/v7400/attribute.rs | 9 --------- 2 files changed, 15 deletions(-) diff --git a/src/low/fbx_header.rs b/src/low/fbx_header.rs index df45ff3..0794b26 100644 --- a/src/low/fbx_header.rs +++ b/src/low/fbx_header.rs @@ -67,12 +67,6 @@ impl FbxHeader { }) } - /// Reads an FBX header from the given reader. - #[deprecated(since = "0.4.1", note = "Renamed to `load`")] - pub fn read_fbx_header(reader: impl io::Read) -> Result { - Self::load(reader) - } - /// Returns FBX version. pub fn version(self) -> FbxVersion { self.version diff --git a/src/pull_parser/v7400/attribute.rs b/src/pull_parser/v7400/attribute.rs index d5eb864..87eab5d 100644 --- a/src/pull_parser/v7400/attribute.rs +++ b/src/pull_parser/v7400/attribute.rs @@ -14,15 +14,6 @@ use crate::{ use self::array::{ArrayAttributeValues, AttributeStreamDecoder, BooleanArrayAttributeValues}; pub use self::loader::LoadAttribute; -/// Use [`low::v7400::AttributeValue`] instead. -/// -/// [`low::v7400::AttributeValue`]: ../../../low/v7400/enum.AttributeValue.html -#[deprecated( - since = "0.4.0", - note = "`DirectAttributeValue` is moved to `low::v7400::AttributeValue`" -)] -pub type DirectAttributeValue = crate::low::v7400::AttributeValue; - mod array; pub mod iter; mod loader; From 2b69cac800f1130a127dc1396050c1d44383d98e Mon Sep 17 00:00:00 2001 From: YOSHIOKA Takuma Date: Fri, 22 Nov 2019 02:08:05 +0900 Subject: [PATCH 15/19] Update CHANGELOG --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4685b3..1cab6b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ + Two new variants `Warning::{ExtraNodeEndMarker, MissingNodeEndMarker}` are added to `pull_parser::error::Warning` type. - Note that `Warning` have been nonexhaustive since this release. +* Deprecated items are removed. + + `low::FbxHeader::read_fbx_header()` + + `pull_parser::v7400::attribute::DirectAttributeValue` ### Breaking changes @@ -23,6 +26,9 @@ + Two new variants `Warning::{ExtraNodeEndMarker, MissingNodeEndMarker}` are added to `pull_parser::error::Warning` type. - Note that `Warning` have been nonexhaustive since this release. +* Deprecated items are removed. + + `low::FbxHeader::read_fbx_header()` + + `pull_parser::v7400::attribute::DirectAttributeValue` ## [0.4.4] From 44e0d82a72ef922f3918e05b9d986da94c2bfb2d Mon Sep 17 00:00:00 2001 From: YOSHIOKA Takuma Date: Fri, 22 Nov 2019 02:09:39 +0900 Subject: [PATCH 16/19] Apply `cargo fix --edition-idioms` --- src/pull_parser/v7400/event.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pull_parser/v7400/event.rs b/src/pull_parser/v7400/event.rs index 93f4aee..2929897 100644 --- a/src/pull_parser/v7400/event.rs +++ b/src/pull_parser/v7400/event.rs @@ -10,7 +10,7 @@ use crate::{ /// Parser event. #[derive(Debug)] -pub enum Event<'a, R: 'a> { +pub enum Event<'a, R> { /// Start of a node. StartNode(StartNode<'a, R>), /// End of a node. From ecdf46e3de233f3f9b2d87248a4f984971aa10cf Mon Sep 17 00:00:00 2001 From: YOSHIOKA Takuma Date: Fri, 22 Nov 2019 02:18:49 +0900 Subject: [PATCH 17/19] Bump verison --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 4d620b0..2efd16a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fbxcel" -version = "0.4.4" +version = "0.5.0" authors = ["YOSHIOKA Takuma "] edition = "2018" license = "MIT OR Apache-2.0" From 737862cd09571b0a38f1bdd53506b13e574dcf82 Mon Sep 17 00:00:00 2001 From: YOSHIOKA Takuma Date: Fri, 22 Nov 2019 02:25:42 +0900 Subject: [PATCH 18/19] Add commit hashes to CHANGELOG --- CHANGELOG.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cab6b6..a3e98c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [Unreleased] +## [0.5.0] + * `pull_parser::error::{DataError, OperationError, Warning}` is now nonexhaustive. + This would make some of future changes non-breaking. * Support parsing nodes with missing or extra node end markers. @@ -15,10 +17,11 @@ + `pull_parser::v7400::attribute::DirectAttributeValue` ### Breaking changes - -* `pull_parser::error::{DataError, OperationError, Warning}` is now nonexhaustive. +* `pull_parser::error::{DataError, OperationError, Warning}` is now nonexhaustive + (d0651118feabf842f9495da626ccb127090db331). + This would make some of future changes non-breaking. -* Support parsing nodes with missing or extra node end markers. +* Support parsing nodes with missing or extra node end markers + (8c3d8b7f210fe8422784ef86b468e5331bb0c2ee). + Previously, missing node end markers caused errors, and extra node end markers were silently ignored. Now they are notified as warnings. @@ -26,7 +29,7 @@ + Two new variants `Warning::{ExtraNodeEndMarker, MissingNodeEndMarker}` are added to `pull_parser::error::Warning` type. - Note that `Warning` have been nonexhaustive since this release. -* Deprecated items are removed. +* Deprecated items are removed (9e38b4217d33ed8bca3f7e8b11d210845a4fa8c1). + `low::FbxHeader::read_fbx_header()` + `pull_parser::v7400::attribute::DirectAttributeValue` @@ -239,7 +242,8 @@ Totally rewritten. -[Unreleased]: +[Unreleased]: +[0.4.4]: [0.4.4]: [0.4.3]: [0.4.2]: From 8a15c9764bd0860fb0b8879ee27cb6aee6e1d30d Mon Sep 17 00:00:00 2001 From: YOSHIOKA Takuma Date: Fri, 22 Nov 2019 02:26:48 +0900 Subject: [PATCH 19/19] Change the project status badge to "passively-maintained" This crate provides low-level features and they seem to be working well. I'll maintain this crate (to add features, fix bugs, refactor, and support more data), but currently I have no plan to add new features or change the API drastically. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 2efd16a..7ae8a63 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ string-interner = { version = "0.7", optional = true, default-features = false } env_logger = "0.7" [badges] -maintenance = { status = "actively-developed" } +maintenance = { status = "passively-maintained" } travis-ci = { repository = "lo48576/fbxcel" } [[example]]