Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
eshikafe committed Dec 31, 2023
1 parent 1a3ecf8 commit d9aef48
Show file tree
Hide file tree
Showing 23 changed files with 57 additions and 41 deletions.
13 changes: 8 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
[package]
name = "synfig-core"
name = "synfig-rs"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[workspace]
members = [
"synfig-core"
]

[dependencies]
lazy_static = "1.4.0"
log = "0.4.17"
env_logger = "0.9.1"
guid-create = "0.3.1"
synfig-core = {path = "synfig-core", version = "0.1.0"}

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Test](https://github.com/eshikafe/synfig-rs/actions/workflows/rust.yml/badge.svg?branch=main)](https://github.com/eshikafe/synfig-rs/actions/workflows/rust.yml)

# synfig-core
# synfig-rs

The `synfig-core` crate is an implementation of [synfig-core](https://github.com/synfig/synfig/tree/master/synfig-core/src/synfig) in Rust.
`synfig-rs` is a Rust implementation of [synfig](https://github.com/synfig/synfig).
7 changes: 0 additions & 7 deletions src/layer.rs

This file was deleted.

16 changes: 1 addition & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1 @@
// extern crate lazy_static;
pub mod loadcanvas;
pub mod layer;
pub mod color;
pub mod canvas;
pub mod vector;
pub mod version;
pub mod uniqueid;
pub mod widthpoint;
pub mod valuenode;

pub type Real = f64;

pub mod time;
pub mod segment;
pub use synfig_core;
15 changes: 15 additions & 0 deletions synfig-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "synfig-core"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
lazy_static = "1.4.0"
log = "0.4.17"
env_logger = "0.9.1"
guid-create = "0.3.1"
#rayon = "1.8"
#quick-xml = "0.31.0"

Empty file added synfig-core/README.md
Empty file.
File renamed without changes.
10 changes: 5 additions & 5 deletions src/canvas.rs → synfig-core/src/canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ pub struct Canvas {

// File identifier of Canvas
// see get_identifier(), set_identifier()
// identifier_FileSystem::Identifier,
// identifier_: FileSystem::Identifier,

// Metadata map for Canvas.
// see get_meta_data(), set_meta_data(), erase_meta_data()
meta_data_: HashMap<String, String>,

// Contains a list of ValueNodes that are in this Canvas
// see value_node_list(), find_value_node()
// value_node_list_ValueNodeList,
// value_node_list: ValueNodeList,

// Contains a list of Keyframes that are in the Canvas
// see keyframe_list()
Expand All @@ -46,18 +46,18 @@ pub struct Canvas {
// A handle to the parent canvas of this canvas.
// If canvas is a root canvas, then this handle is empty
// see parent()
// parent_LooseHandle,
// parent_: LooseHandle,

// List containing any child Canvases
// see children() */
// children_: Children,

// Render Description for Canvas
// see rend_desc() */
// RendDesc desc_;
// desc_: RendDesc,

// Contains the value of the last call to set_time()
// Time cur_time_;
// cur_time_: Time,

// Map of external Canvases used in this Canvas
// mutable std::map<String,Handle> externals_;
Expand Down
3 changes: 3 additions & 0 deletions synfig-core/src/canvasbase.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
use crate::layer::Layer;

pub type CanvasBase = Vec<Layer>;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions synfig-core/src/layer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pub struct Layer {
pub active: bool,
pub optimized: bool,
pub exclude_from_rendering: bool,
pub description: String,
pub group: String,
}
13 changes: 13 additions & 0 deletions synfig-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// extern crate lazy_static;
pub mod loadcanvas;
pub mod layer;
pub mod color;
pub mod canvas;
pub mod vector;
pub mod version;
pub mod uniqueid;
pub mod widthpoint;
pub mod valuenode;

pub mod time;
pub mod segment;
10 changes: 3 additions & 7 deletions src/loadcanvas.rs → synfig-core/src/loadcanvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use lazy_static::lazy_static;
use crate::canvas;
use crate::color::*;
use crate::valuenode;
use crate::Real;
use crate::time::Time;
use crate::vector::*;
use crate::segment::Segment;
Expand All @@ -28,6 +27,7 @@ lazy_static! {
});
}

// TODO: Replace with a quick_xml crate
mod xmlpp {
#[derive(Debug)]
pub struct Node;
Expand All @@ -36,20 +36,16 @@ mod xmlpp {
pub struct Element;
}

/// CanvasParser handles xmlpp elements from a sif file and
/// converts them into Synfig objects
/// CanvasParser converts xml elements from a sif file to Synfig objects
pub struct CanvasParser {
// Maximum number of allowed warnings before fatal error is thrown
max_warnings: i32,
// Total number of warning during canvas parsing
total_warnings: i32,
total_errors: i32,
allow_errors: bool,
filename: String,
path: String,
errors_text: String,
warnings_text: String,
// Seems not to be used
guid: GUID,
in_bones_section: bool,
// Set of absolute file names of the canvases currently being parsed
Expand Down Expand Up @@ -239,7 +235,7 @@ impl CanvasParser {
}

// Real Value Base Parsing Function
fn parse_real(&mut self, node: &xmlpp::Element) -> Real {
fn parse_real(&mut self, node: &xmlpp::Element) -> f64 {
0.0
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit d9aef48

Please sign in to comment.