Skip to content

Commit

Permalink
Merge branch 'release/v0.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
lo48576 committed Nov 21, 2019
2 parents 8111780 + 8a15c97 commit 782ed2e
Show file tree
Hide file tree
Showing 14 changed files with 348 additions and 33 deletions.
31 changes: 29 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,35 @@ rust:
- stable
- beta
- 1.34.0
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
fi
before_script:
# Use dependencies with minimal versions.
- |
if [ "${TEST_MINIMAL_VERSIONS:-0}" -ne 0 ] ; then
cargo +nightly update -Z minimal-versions
fi
script:
- cargo build --verbose --all-features
- cargo test --verbose --all-features
# TODO: Use `--workspace` instead of `--all` for Rust 1.39 or later.
- 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.
- if [ "${LINT:-0}" -ne 0 ] ; then cargo clippy --all-features -- --deny warnings ; fi
notifications:
email: false
34 changes: 33 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,37 @@

## [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.
+ 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.
* Deprecated items are removed.
+ `low::FbxHeader::read_fbx_header()`
+ `pull_parser::v7400::attribute::DirectAttributeValue`

### Breaking changes
* `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
(8c3d8b7f210fe8422784ef86b468e5331bb0c2ee).
+ 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.
* Deprecated items are removed (9e38b4217d33ed8bca3f7e8b11d210845a4fa8c1).
+ `low::FbxHeader::read_fbx_header()`
+ `pull_parser::v7400::attribute::DirectAttributeValue`

## [0.4.4]

* Documents are improved a little.
Expand Down Expand Up @@ -211,7 +242,8 @@

Totally rewritten.

[Unreleased]: <https://github.com/lo48576/fbxcel/compare/v0.4.4...develop>
[Unreleased]: <https://github.com/lo48576/fbxcel/compare/v0.5.0...develop>
[0.4.4]: <https://github.com/lo48576/fbxcel/releases/tag/v0.5.0>
[0.4.4]: <https://github.com/lo48576/fbxcel/releases/tag/v0.4.4>
[0.4.3]: <https://github.com/lo48576/fbxcel/releases/tag/v0.4.3>
[0.4.2]: <https://github.com/lo48576/fbxcel/releases/tag/v0.4.2>
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fbxcel"
version = "0.4.4"
version = "0.5.0"
authors = ["YOSHIOKA Takuma <[email protected]>"]
edition = "2018"
license = "MIT OR Apache-2.0"
Expand All @@ -27,10 +27,10 @@ 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" }
maintenance = { status = "passively-maintained" }
travis-ci = { repository = "lo48576/fbxcel" }

[[example]]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]

Expand Down
6 changes: 0 additions & 6 deletions src/low/fbx_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, HeaderError> {
Self::load(reader)
}

/// Returns FBX version.
pub fn version(self) -> FbxVersion {
self.version
Expand Down
3 changes: 3 additions & 0 deletions src/pull_parser/error/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/pull_parser/error/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand All @@ -32,6 +34,7 @@ impl fmt::Display for OperationError {
"Unsupported FBX version: parser={:?}, fbx={:?}",
parser, fbx
),
OperationError::__Nonexhaustive => unreachable!("`__Nonexhaustive` should never used"),
}
}
}
9 changes: 9 additions & 0 deletions src/pull_parser/error/warning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,8 +19,12 @@ 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)]
__Nonexhaustive,
}

impl error::Error for Warning {}
Expand All @@ -27,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")
}
Expand All @@ -35,7 +42,9 @@ 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"),
}
}
}
9 changes: 0 additions & 9 deletions src/pull_parser/v7400/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/pull_parser/v7400/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 8 additions & 9 deletions src/pull_parser/v7400/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
use std::{fmt, io};

use log::debug;

use crate::{
low::{
v7400::{FbxFooter, NodeHeader},
Expand Down Expand Up @@ -304,13 +302,9 @@ impl<R: ParserSource> Parser<R> {
// 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);
}
}
}
Expand All @@ -332,6 +326,11 @@ impl<R: ParserSource> Parser<R> {
)
.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),
Expand Down
2 changes: 1 addition & 1 deletion src/tree/v7400/node/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading

0 comments on commit 782ed2e

Please sign in to comment.