mirror of
https://github.com/enso-org/enso.git
synced 2025-01-02 04:11:32 +03:00
Adding lints to the codebase (https://github.com/enso-org/ide/pull/126)
Addings lints to the codebase
Original commit: cf45cd64ac
This commit is contained in:
parent
d068dfb829
commit
ebfc075938
@ -4,7 +4,9 @@
|
||||
|
||||
#![feature(specialization)]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
#![warn(unsafe_code)]
|
||||
#![warn(missing_copy_implementations)]
|
||||
#![warn(missing_debug_implementations)]
|
||||
|
||||
use basegl_prelude::*;
|
||||
use std::fmt::Write;
|
||||
|
@ -1,4 +1,7 @@
|
||||
#![allow(missing_docs)]
|
||||
#![warn(unsafe_code)]
|
||||
#![warn(missing_copy_implementations)]
|
||||
#![warn(missing_debug_implementations)]
|
||||
|
||||
use basegl_prelude::*;
|
||||
use basegl_prelude::fmt::{Formatter, Error};
|
||||
|
@ -48,6 +48,7 @@ impl EmscriptenRepresentation for f64 {
|
||||
// =======================
|
||||
|
||||
/// View of array in `msdfgen` library memory
|
||||
#[derive(Debug)]
|
||||
pub struct ArrayMemoryView<F : EmscriptenRepresentation> {
|
||||
begin_address : usize,
|
||||
end_address : usize,
|
||||
@ -58,6 +59,7 @@ pub struct ArrayMemoryView<F : EmscriptenRepresentation> {
|
||||
///
|
||||
/// It cannot outlives view from which was created, because one might expect, that data may be freed
|
||||
/// by library once view is destroyed
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub struct ArrayMemoryViewIterator<'a, F : EmscriptenRepresentation> {
|
||||
next_read_address : usize,
|
||||
end_address : usize,
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![allow(unsafe_code)]
|
||||
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
use wasm_bindgen::JsValue;
|
||||
|
||||
|
@ -1,4 +1,7 @@
|
||||
#![allow(missing_docs)]
|
||||
#![warn(unsafe_code)]
|
||||
#![warn(missing_copy_implementations)]
|
||||
#![warn(missing_debug_implementations)]
|
||||
|
||||
mod internal;
|
||||
pub mod emscripten_data;
|
||||
@ -87,6 +90,7 @@ impl Drop for Font {
|
||||
///
|
||||
/// The structure gathering MSDF generation parameters meant to be same for all
|
||||
/// rendered glyphs
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub struct MsdfParameters {
|
||||
pub width : usize,
|
||||
pub height : usize,
|
||||
@ -97,6 +101,7 @@ pub struct MsdfParameters {
|
||||
pub overlap_support : bool
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct MultichannelSignedDistanceField {
|
||||
handle : JsValue,
|
||||
pub advance : f64,
|
||||
|
@ -4,6 +4,7 @@ use std::future::Future;
|
||||
use crate::{ is_emscripten_runtime_initialized, run_once_initialized };
|
||||
|
||||
/// The future for running test after initialization
|
||||
#[derive(Debug)]
|
||||
pub struct TestAfterInit<F:Fn()> {
|
||||
test : F
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ impl AnimatorData {
|
||||
|
||||
/// This struct which runs a callback once per frame with a time difference from the last frame
|
||||
/// as its input.
|
||||
#[derive(Debug)]
|
||||
pub struct Animator {
|
||||
_continuous_animator: ContinuousAnimator
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
//! This module implements `ContinuousAnimator`, an object used to run a callback with a continuous
|
||||
//! time in milliseconds as its input. It can be used to implement a playback mechanism.
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
use crate::control::EventLoop;
|
||||
use crate::control::callback::CallbackHandle;
|
||||
use super::AnimationCallback;
|
||||
@ -13,7 +15,10 @@ use std::cell::RefCell;
|
||||
// === ContinuousTimeAnimatorProperties ===
|
||||
// ========================================
|
||||
|
||||
#[derive(Derivative)]
|
||||
#[derivative(Debug)]
|
||||
struct ContinuousTimeAnimatorProperties {
|
||||
#[derivative(Debug="ignore")]
|
||||
callback : Box<dyn AnimationCallback>,
|
||||
relative_start_ms : f64,
|
||||
absolute_start_ms : Option<f64>,
|
||||
@ -26,6 +31,7 @@ struct ContinuousTimeAnimatorProperties {
|
||||
// === ContinuousTimeAnimatorData ===
|
||||
// ==================================
|
||||
|
||||
#[derive(Debug)]
|
||||
struct ContinuousAnimatorData {
|
||||
properties : RefCell<ContinuousTimeAnimatorProperties>
|
||||
}
|
||||
@ -96,6 +102,7 @@ impl ContinuousAnimatorData {
|
||||
|
||||
/// `ContinuousAnimator` calls `AnimationCallback` with the playback time in millisecond as its
|
||||
/// input once per frame.
|
||||
#[derive(Debug)]
|
||||
pub struct ContinuousAnimator {
|
||||
data : Rc<ContinuousAnimatorData>,
|
||||
event_loop : EventLoop
|
||||
|
@ -25,10 +25,11 @@ pub trait EasingAnimationCallback<T> = FnMut(T) + 'static;
|
||||
// === EasingAnimatorData ===
|
||||
// ==========================
|
||||
|
||||
#[derive(Debug)]
|
||||
struct EasingAnimatorData<T:Interpolable<T>> {
|
||||
initial_value : T,
|
||||
final_value : T,
|
||||
duration_ms: f64,
|
||||
duration_ms : f64,
|
||||
continuous_animator : Option<ContinuousAnimator>
|
||||
}
|
||||
|
||||
@ -42,6 +43,7 @@ struct EasingAnimatorData<T:Interpolable<T>> {
|
||||
pub trait InterpolableArgument<T:Copy> = Interpolable<T> + 'static;
|
||||
|
||||
/// This struct animates from `origin_position` to `target_position` using easing functions.
|
||||
#[derive(Debug)]
|
||||
pub struct EasingAnimator<T:Interpolable<T>> {
|
||||
data : Rc<RefCell<EasingAnimatorData<T>>>
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ use nalgebra::zero;
|
||||
// =======================
|
||||
|
||||
/// This struct counts the intervals in a time period.
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub struct IntervalCounter {
|
||||
/// Interval duration.
|
||||
pub interval_duration : f64,
|
||||
@ -72,6 +72,7 @@ impl FixedStepAnimatorData {
|
||||
/// (AnimationCallback(delta_ms)) will be 1000ms. But keep in mind that if the actual frame
|
||||
/// takes longer, say 2000ms, AnimationCallback will be called twice in the same moment, but
|
||||
/// its delta_ms parameter will always be fixed to 1 second.
|
||||
#[derive(Debug)]
|
||||
pub struct FixedStepAnimator {
|
||||
_animator: Animator
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ pub trait PhysicsForce {
|
||||
// ======================
|
||||
|
||||
/// This structure contains air dragging properties.
|
||||
#[derive(Default, Clone, Copy)]
|
||||
#[derive(Default,Clone,Copy,Debug)]
|
||||
pub struct DragProperties {
|
||||
/// Drag`s coefficient.
|
||||
pub coefficient: f32
|
||||
@ -175,6 +175,7 @@ impl KinematicsProperties {
|
||||
// === PhysicsPropertiesData ===
|
||||
// =============================
|
||||
|
||||
#[derive(Debug)]
|
||||
struct PhysicsPropertiesData {
|
||||
kinematics : KinematicsProperties,
|
||||
spring : SpringProperties,
|
||||
@ -195,7 +196,7 @@ impl PhysicsPropertiesData {
|
||||
// =========================
|
||||
|
||||
/// A structure including kinematics, drag and spring properties.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone,Debug)]
|
||||
pub struct PhysicsProperties {
|
||||
data : Rc<RefCell<PhysicsPropertiesData>>
|
||||
}
|
||||
@ -272,6 +273,7 @@ impl PhysicsProperties {
|
||||
pub trait PhysicsCallback = FnMut(Vector3<f32>) + 'static;
|
||||
|
||||
/// A fixed step physics simulator used to simulate `PhysicsProperties`.
|
||||
#[derive(Debug)]
|
||||
pub struct PhysicsSimulator {
|
||||
_animator : Animator
|
||||
}
|
||||
|
@ -48,8 +48,7 @@ pub type XCallbackMut1<T> = Box<dyn XCallbackMut1Fn<T>>;
|
||||
// ======================
|
||||
|
||||
/// Handle to a callback. When the handle is dropped, the callback is removed.
|
||||
#[derive(Derivative)]
|
||||
#[derivative(Debug, Default)]
|
||||
#[derive(Debug,Default)]
|
||||
pub struct CallbackHandle {
|
||||
rc: Rc<()>
|
||||
}
|
||||
@ -75,6 +74,7 @@ impl CallbackHandle {
|
||||
}
|
||||
|
||||
/// CallbackHandle's guard. Used to check if the handle is still valid.
|
||||
#[derive(Debug)]
|
||||
pub struct Guard {
|
||||
weak: Weak<()>
|
||||
}
|
||||
|
@ -34,8 +34,7 @@ pub trait EventLoopCallback = FnMut(f64) + 'static;
|
||||
/// removed as soon as the handle is dropped. You can also use the `forget`
|
||||
/// method on the handle to make the callback registered forever, but beware
|
||||
/// that it can easily lead to memory leaks.
|
||||
#[derive(Derivative)]
|
||||
#[derivative(Debug, Default, Clone)]
|
||||
#[derive(Debug,Default,Clone)]
|
||||
pub struct EventLoop {
|
||||
rc: Rc<RefCell<EventLoopData>>,
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
//! This module contains the `MouseManager` implementation, its associated structs such as
|
||||
//! `MousePositionEvent`, `MouseClickEvent` and `MouseWheelEvent`.
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
pub mod event;
|
||||
pub mod button;
|
||||
|
||||
@ -28,6 +30,7 @@ use std::cell::RefCell;
|
||||
// =====================
|
||||
|
||||
/// This struct keeps the register of the event listener and unregisters it when it's dropped.
|
||||
#[derive(Debug)]
|
||||
pub struct EventListener<T:?Sized> {
|
||||
target : EventTarget,
|
||||
name : String,
|
||||
@ -69,19 +72,9 @@ pub type WheelEventListener = EventListener<dyn FnMut(WheelEvent)>;
|
||||
// FIXME: this does not handle all buttons (js defines 5 buttons) and assumes mouses for
|
||||
// FIXME: right hand people.
|
||||
/// An enumeration representing the mouse buttons.
|
||||
pub enum MouseButton {
|
||||
/// Left mouse button.
|
||||
LEFT,
|
||||
|
||||
/// Middle mouse button.
|
||||
MIDDLE,
|
||||
|
||||
/// Right mouse button.
|
||||
RIGHT,
|
||||
|
||||
/// For unknown mouse buttons IDs.
|
||||
UNKNOWN
|
||||
}
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum MouseButton {LEFT,MIDDLE,RIGHT,UNKNOWN}
|
||||
|
||||
|
||||
|
||||
@ -94,6 +87,7 @@ pub trait MouseClickCallback = FnMut(MouseClickEvent) + 'static;
|
||||
|
||||
// FIXME: "click" means mouse down and then up. This is misleading.
|
||||
/// A struct storing information about mouse down and mouse up events.
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub struct MouseClickEvent {
|
||||
/// The position where the MouseClickEvent occurred.
|
||||
pub position : Vector2<f32>,
|
||||
@ -131,6 +125,7 @@ impl MouseClickEvent {
|
||||
pub trait MousePositionCallback = FnMut(MousePositionEvent) + 'static;
|
||||
|
||||
/// A struct storing information about mouse move, mouse enter and mouse leave events.
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub struct MousePositionEvent {
|
||||
/// The previous position where the mouse was.
|
||||
pub previous_position : Vector2<f32>,
|
||||
@ -163,6 +158,7 @@ impl MousePositionEvent {
|
||||
pub trait MouseWheelCallback = FnMut(MouseWheelEvent) + 'static;
|
||||
|
||||
/// A struct storing information about mouse wheel events.
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub struct MouseWheelEvent {
|
||||
/// A boolean indicating if the keyboard ctrl button is pressed.
|
||||
pub is_ctrl_pressed : bool,
|
||||
@ -193,10 +189,13 @@ impl MouseWheelEvent {
|
||||
// === MouseManagerProperties ===
|
||||
// ==============================
|
||||
|
||||
#[derive(Derivative)]
|
||||
#[derivative(Debug)]
|
||||
struct MouseManagerProperties {
|
||||
dom : DomContainer,
|
||||
mouse_position : Option<Vector2<f32>>,
|
||||
target : EventTarget,
|
||||
#[derivative(Debug="ignore")]
|
||||
stop_tracking_listener : Option<MouseEventListener>
|
||||
}
|
||||
|
||||
@ -207,8 +206,8 @@ struct MouseManagerProperties {
|
||||
// ========================
|
||||
|
||||
/// A struct used for storing shared MouseManager's mutable data.
|
||||
#[derive(Debug)]
|
||||
struct MouseManagerData {
|
||||
// FIXME: naked refcell
|
||||
properties : RefCell<MouseManagerProperties>
|
||||
}
|
||||
|
||||
@ -299,6 +298,7 @@ macro_rules! add_callback {
|
||||
// ====================
|
||||
|
||||
/// This structs manages mouse events in a specified DOM object.
|
||||
#[derive(Debug)]
|
||||
pub struct MouseManager {
|
||||
data : Rc<MouseManagerData>
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ pub trait AddMut<T> {
|
||||
/// The item type is `(Option<T>, T)` where the second tuple element is
|
||||
/// a current value and first element is a previous one `None` on the first
|
||||
/// iteration.
|
||||
#[derive(Debug)]
|
||||
pub struct CachingIterator<T:Clone, It:Iterator<Item=T>> {
|
||||
last : Option<T>,
|
||||
iter : It
|
||||
|
@ -311,7 +311,7 @@ pub type Bool <OnMut=()> = DirtyFlag <BoolData,OnMut>;
|
||||
pub type SharedBool <OnMut=()> = SharedDirtyFlag <BoolData,OnMut>;
|
||||
pub trait BoolCtx <OnMut> = where OnMut:Function0;
|
||||
|
||||
#[derive(Debug,Display,Default)]
|
||||
#[derive(Clone,Copy,Debug,Display,Default)]
|
||||
pub struct BoolData { is_dirty: bool }
|
||||
impl HasCheckAll for BoolData { fn check_all (&self) -> bool { self.is_dirty } }
|
||||
impl HasUnsetAll for BoolData { fn unset_all (&mut self) { self.is_dirty = false } }
|
||||
|
@ -43,7 +43,7 @@ fn performance() -> Performance {
|
||||
// ==============
|
||||
|
||||
/// Look and feel configuration for the performance monitor.
|
||||
#[derive(Clone,Debug)]
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
#[allow(missing_docs)]
|
||||
pub struct ConfigTemplate<Str,Num> {
|
||||
pub background_color : Str,
|
||||
@ -585,7 +585,7 @@ impl PanelData {
|
||||
// =================
|
||||
|
||||
/// Sampler measuring the time for a given operation.
|
||||
#[derive(Debug,Default)]
|
||||
#[derive(Clone,Copy,Debug,Default)]
|
||||
pub struct FrameTime {
|
||||
begin_time : f64,
|
||||
value : f64,
|
||||
@ -620,7 +620,7 @@ impl Sampler for FrameTime {
|
||||
// ===========
|
||||
|
||||
/// Sampler measuring the frames per second count for a given operation.
|
||||
#[derive(Debug,Default)]
|
||||
#[derive(Clone,Copy,Debug,Default)]
|
||||
pub struct Fps {
|
||||
begin_time : f64,
|
||||
value : f64,
|
||||
@ -657,7 +657,7 @@ impl Sampler for Fps {
|
||||
// ==================
|
||||
|
||||
/// Sampler measuring the memory usage of the WebAssembly part of the program.
|
||||
#[derive(Debug,Default)]
|
||||
#[derive(Clone,Copy,Debug,Default)]
|
||||
pub struct WasmMemory {
|
||||
value : f64,
|
||||
value_check : ValueCheck,
|
||||
|
@ -14,7 +14,7 @@ use crate::data::dirty::traits::*;
|
||||
// =================
|
||||
|
||||
/// Camera alignment. It describes where the origin of the camera should be aligned to.
|
||||
#[derive(Clone,Debug)]
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub struct Alignment {
|
||||
/// Horizontal alignment.
|
||||
pub horizontal : HorizontalAlignment,
|
||||
@ -24,12 +24,12 @@ pub struct Alignment {
|
||||
}
|
||||
|
||||
/// Horizontal alignments.
|
||||
#[derive(Clone,Debug)]
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum HorizontalAlignment {Left,Center,Right}
|
||||
|
||||
/// Vertical alignments.
|
||||
#[derive(Clone,Debug)]
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum VerticalAlignment {Top,Center,Bottom}
|
||||
|
||||
@ -50,7 +50,7 @@ impl Default for Alignment {
|
||||
// ==============
|
||||
|
||||
/// Camera's frustum screen dimensions.
|
||||
#[derive(Clone,Debug)]
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub struct Screen {
|
||||
/// Screen's width.
|
||||
pub width : f32,
|
||||
@ -66,7 +66,7 @@ impl Screen {
|
||||
}
|
||||
|
||||
/// Gets Screen's aspect ratio.
|
||||
pub fn aspect(&self) -> f32 {
|
||||
pub fn aspect(self) -> f32 {
|
||||
self.width / self.height
|
||||
}
|
||||
}
|
||||
@ -78,7 +78,7 @@ impl Screen {
|
||||
// ==================
|
||||
|
||||
/// Camera's projection type.
|
||||
#[derive(Clone,Debug,Copy)]
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub enum Projection {
|
||||
/// Perspective projection.
|
||||
Perspective {
|
||||
@ -103,7 +103,7 @@ impl Default for Projection {
|
||||
// ================
|
||||
|
||||
/// Camera's frustum clipping range.
|
||||
#[derive(Clone,Debug)]
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub struct Clipping {
|
||||
/// Near clipping limit.
|
||||
pub near : f32,
|
||||
@ -373,12 +373,12 @@ impl Camera2d {
|
||||
impl Camera2d {
|
||||
/// Gets `Clipping`.
|
||||
pub fn clipping(&self) -> Clipping {
|
||||
self.rc.borrow().clipping.clone()
|
||||
self.rc.borrow().clipping
|
||||
}
|
||||
|
||||
/// Gets `Screen`.
|
||||
pub fn screen(&self) -> Screen {
|
||||
self.rc.borrow().screen.clone()
|
||||
self.rc.borrow().screen
|
||||
}
|
||||
|
||||
/// Gets zoom.
|
||||
|
@ -24,6 +24,7 @@ use nalgebra::clamp;
|
||||
// =================
|
||||
|
||||
/// Navigator enables camera navigation with mouse interactions.
|
||||
#[derive(Debug)]
|
||||
pub struct Navigator {
|
||||
_events : NavigatorEvents,
|
||||
_simulator : PhysicsSimulator,
|
||||
|
@ -1,3 +1,5 @@
|
||||
use crate::prelude::*;
|
||||
|
||||
use crate::control::io::mouse::MouseManager;
|
||||
use crate::control::io::mouse::MouseClickEvent;
|
||||
use crate::control::io::mouse::MouseWheelEvent;
|
||||
@ -78,7 +80,7 @@ impl PanEvent {
|
||||
// === MovementType ===
|
||||
// ====================
|
||||
|
||||
#[derive(PartialEq, Clone, Copy)]
|
||||
#[derive(PartialEq,Clone,Copy,Debug)]
|
||||
enum MovementType {
|
||||
Pan,
|
||||
Zoom { focus : Vector2<f32> }
|
||||
@ -90,10 +92,14 @@ enum MovementType {
|
||||
// === NavigatorEventsProperties ===
|
||||
// =================================
|
||||
|
||||
#[derive(Derivative)]
|
||||
#[derivative(Debug)]
|
||||
struct NavigatorEventsProperties {
|
||||
movement_type : Option<MovementType>,
|
||||
mouse_position : Vector2<f32>,
|
||||
#[derivative(Debug="ignore")]
|
||||
pan_callback : Box<dyn FnPanEvent>,
|
||||
#[derivative(Debug="ignore")]
|
||||
zoom_callback : Box<dyn FnZoomEvent>,
|
||||
zoom_speed : f32
|
||||
}
|
||||
@ -104,6 +110,7 @@ struct NavigatorEventsProperties {
|
||||
// === NavigatorEventsData ===
|
||||
// ===========================
|
||||
|
||||
#[derive(Debug)]
|
||||
struct NavigatorEventsData {
|
||||
properties : RefCell<NavigatorEventsProperties>
|
||||
}
|
||||
@ -171,14 +178,22 @@ impl NavigatorEventsData {
|
||||
// =======================
|
||||
|
||||
/// Struct used to handle pan and zoom events from mouse interactions.
|
||||
#[derive(Derivative)]
|
||||
#[derivative(Debug)]
|
||||
pub struct NavigatorEvents {
|
||||
data : Rc<NavigatorEventsData>,
|
||||
mouse_manager : MouseManager,
|
||||
#[derivative(Debug="ignore")]
|
||||
mouse_down : Option<MouseEventListener>,
|
||||
#[derivative(Debug="ignore")]
|
||||
mouse_move : Option<MouseEventListener>,
|
||||
#[derivative(Debug="ignore")]
|
||||
mouse_up : Option<MouseEventListener>,
|
||||
#[derivative(Debug="ignore")]
|
||||
mouse_leave : Option<MouseEventListener>,
|
||||
#[derivative(Debug="ignore")]
|
||||
disable_context_menu : Option<MouseEventListener>,
|
||||
#[derivative(Debug="ignore")]
|
||||
wheel_zoom : Option<WheelEventListener>
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ use crate::data::dirty::traits::*;
|
||||
|
||||
/// Defines the order in which particular axis coordinates are processed. Used for example to define
|
||||
/// the rotation order in `DisplayObject`.
|
||||
#[derive(Clone,Debug)]
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub enum AxisOrder {XYZ,XZY,YXZ,YZX,ZXY,ZYX}
|
||||
|
||||
impl Default for AxisOrder {
|
||||
@ -34,7 +34,7 @@ impl Default for AxisOrder {
|
||||
|
||||
/// Defines the order in which transformations (scale, rotate, translate) are applied to a
|
||||
/// particular object.
|
||||
#[derive(Clone,Debug)]
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub enum TransformOrder {
|
||||
ScaleRotateTranslate,
|
||||
ScaleTranslateRotate,
|
||||
@ -58,7 +58,7 @@ impl Default for TransformOrder {
|
||||
/// You can use methods like `matrix` to get a combined transformation matrix. Bear in mind that
|
||||
/// the matrix will always be recomputed from scratch. This structure does not contain any caching
|
||||
/// mechanisms.
|
||||
#[derive(Clone,Debug)]
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub struct Transform {
|
||||
pub position : Vector3<f32>,
|
||||
pub scale : Vector3<f32>,
|
||||
|
@ -48,6 +48,7 @@ impl<Pass:RenderPass> Add<Pass> for RenderPipeline {
|
||||
|
||||
/// An output definition of a render pass. The output describes a format of framebuffer attachment,
|
||||
/// which will be the result of running the current pass.
|
||||
#[derive(Debug)]
|
||||
pub struct RenderPassOutput {
|
||||
/// Name of the pass.
|
||||
pub name : String,
|
||||
|
@ -73,7 +73,7 @@ impl Shape {
|
||||
|
||||
|
||||
pub fn screen_shape(&self) -> ShapeData {
|
||||
self.rc.borrow().clone()
|
||||
*self.rc.borrow()
|
||||
}
|
||||
|
||||
pub fn canvas_shape(&self) -> ShapeData {
|
||||
@ -97,7 +97,7 @@ impl CloneRef for Shape {}
|
||||
|
||||
// === ShapeData ===
|
||||
|
||||
#[derive(Clone,Debug)]
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub struct ShapeData {
|
||||
pub width : f32,
|
||||
pub height : f32,
|
||||
|
@ -79,6 +79,7 @@ macro_rules! _define_compound_shape_data {
|
||||
|
||||
/// Shape type definition.
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Debug)]
|
||||
pub struct $name<$($shape_field),*> {
|
||||
$(pub $shape_field : $shape_field),*,
|
||||
$(pub $field : Glsl),*
|
||||
|
@ -27,6 +27,7 @@ const FRAGMENT_RUNNER :&str = include_str!("../glsl/fragment_runner.glsl");
|
||||
|
||||
// TODO: Consider removing this struct and moving the utils to functions.
|
||||
/// GLSL code builder.
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub struct Builder {}
|
||||
|
||||
impl Builder {
|
||||
|
@ -8,8 +8,10 @@ use wasm_bindgen::prelude::*;
|
||||
extern "C" {
|
||||
/// Returns GLSL code which redirects mangled function names to their original primitive
|
||||
/// definitions.
|
||||
#[allow(unsafe_code)]
|
||||
pub fn builtin_redirections() -> String;
|
||||
|
||||
/// Mangles the provided GLSL code to allow primitive definitions overloading.
|
||||
#[allow(unsafe_code)]
|
||||
pub fn allow_overloading(s:&str) -> String;
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ impl TextComponent {
|
||||
pub fn navigate_cursors(&mut self, step:Step, selecting:bool, fonts:&mut Fonts) {
|
||||
let content = &mut self.content;
|
||||
let mut navigation = CursorNavigation {content,fonts,selecting};
|
||||
self.cursors.navigate_all_cursors(&mut navigation,&step);
|
||||
self.cursors.navigate_all_cursors(&mut navigation,step);
|
||||
}
|
||||
|
||||
fn refresh_content_buffers(&mut self, fonts:&mut Fonts) {
|
||||
@ -248,6 +248,7 @@ impl TextComponent {
|
||||
// ============================
|
||||
|
||||
/// Text component builder
|
||||
#[derive(Debug)]
|
||||
pub struct TextComponentBuilder<'a, 'b, Str:AsRef<str>> {
|
||||
pub scene : &'a Scene,
|
||||
pub fonts : &'b mut Fonts,
|
||||
|
@ -92,6 +92,7 @@ impl RenderedFragment {
|
||||
/// Builder of buffer data of some consecutive buffer fragments
|
||||
///
|
||||
/// The result is stored in `vertex_position_data` and `texture_coords_data` fields.
|
||||
#[derive(Debug)]
|
||||
pub struct FragmentsDataBuilder<'a> {
|
||||
pub vertex_position_data : Vec<f32>,
|
||||
pub texture_coords_data : Vec<f32>,
|
||||
@ -176,7 +177,7 @@ impl<'a> FragmentsDataBuilder<'a> {
|
||||
/// During x scrolling we don't immediately refresh all the lines, but pick only one which is
|
||||
/// "centered" on current scroll - the rest of lines should still have data in buffers for
|
||||
/// shown glyphs.
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub struct NextFragmentToRefreshAfterXScrolling {
|
||||
pub fragments_count : usize,
|
||||
pub next_fragment : usize
|
||||
|
@ -43,8 +43,7 @@ pub fn point_to_iterable<T:Scalar>(p:Point2<T>) -> SmallVec<[T;2]> {
|
||||
/// The pen is a font-specific term (see
|
||||
/// [freetype documentation](https://www.freetype.org/freetype2/docs/glyphs/glyphs-3.html#section-1)
|
||||
/// for details). The structure keeps pen position _before_ rendering the `current_char`.
|
||||
#[derive(Clone)]
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub struct Pen {
|
||||
pub position : Point2<f64>,
|
||||
pub current_char : Option<char>,
|
||||
@ -126,6 +125,7 @@ pub trait GlyphAttributeBuilder {
|
||||
/// Builder for glyph square vertex positions
|
||||
///
|
||||
/// `pen` field points to the position of last built glyph.
|
||||
#[derive(Debug)]
|
||||
pub struct GlyphVertexPositionBuilder<'a,'b> {
|
||||
pub font : &'a mut FontRenderInfo,
|
||||
pub pen : &'b mut Pen,
|
||||
@ -173,6 +173,7 @@ impl<'a,'b> GlyphAttributeBuilder for GlyphVertexPositionBuilder<'a,'b> {
|
||||
// ======================================
|
||||
|
||||
/// Builder for glyph MSDF texture coordinates
|
||||
#[derive(Debug)]
|
||||
pub struct GlyphTextureCoordsBuilder<'a> {
|
||||
pub font : &'a mut FontRenderInfo
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ use crate::display::shape::text::buffer::glyph_square::GlyphTextureCoordsBuilder
|
||||
/// texture coordinates) for one line. If line is longer than `max_line_size`, it is
|
||||
/// cut. When line is shorter, the buffer is padded with empty values (obtained from
|
||||
/// `GlyphAttributeBuilder::empty()`).
|
||||
#[derive(Debug)]
|
||||
pub struct LineAttributeBuilder<'a,GlyphBuilder:GlyphAttributeBuilder> {
|
||||
max_line_size : usize,
|
||||
squares_produced : usize,
|
||||
|
@ -76,11 +76,13 @@ impl DirtyLines {
|
||||
///
|
||||
/// A change is simple if it's replace a fragment of one line with text without new lines. Otherwise
|
||||
/// its a multiline change.
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub enum ChangeType {
|
||||
Simple, Multiline
|
||||
}
|
||||
|
||||
/// A structure describing a text operation in one place.
|
||||
#[derive(Debug)]
|
||||
pub struct TextChange {
|
||||
replaced : Range<TextLocation>,
|
||||
lines : Vec<Vec<char>>,
|
||||
@ -175,6 +177,7 @@ pub struct TextComponentContent {
|
||||
}
|
||||
|
||||
/// References to all needed stuff for generating buffer's data.
|
||||
#[derive(Debug)]
|
||||
pub struct RefreshInfo<'a, 'b> {
|
||||
pub lines : &'a mut [Line],
|
||||
pub dirty_lines : DirtyLines,
|
||||
|
@ -14,8 +14,7 @@ use std::ops::Range;
|
||||
/// position of the char in a _text space_ (where value of 1.0 is equal to lines height). The cache
|
||||
/// is initially empty and is load on demand - so the `char_x_position` vector will be often shorter
|
||||
/// than number of characters in line.
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone,Debug)]
|
||||
pub struct Line {
|
||||
chars : Vec<char>,
|
||||
char_x_positions : Vec<f32>,
|
||||
@ -143,7 +142,7 @@ impl Line {
|
||||
}
|
||||
|
||||
/// A line reference with it's index.
|
||||
#[derive(Shrinkwrap)]
|
||||
#[derive(Shrinkwrap,Debug)]
|
||||
#[shrinkwrap(mutable)]
|
||||
pub struct LineRef<'a> {
|
||||
#[shrinkwrap(main_field)]
|
||||
|
@ -23,7 +23,7 @@ use web_sys::WebGlBuffer;
|
||||
// ==============
|
||||
|
||||
/// Cursor in TextComponent with its selection
|
||||
#[derive(Clone,Debug,Eq,PartialEq)]
|
||||
#[derive(Clone,Copy,Debug,Eq,PartialEq)]
|
||||
pub struct Cursor {
|
||||
pub position : TextLocation,
|
||||
pub selected_to : TextLocation,
|
||||
@ -102,10 +102,11 @@ impl Cursor {
|
||||
|
||||
/// An enum representing cursor moving step. The steps are based of possible keystrokes (arrows,
|
||||
/// Home, End, Ctrl+Home, etc.)
|
||||
#[derive(Debug,Eq,Hash,PartialEq)]
|
||||
#[derive(Clone,Copy,Debug,Eq,Hash,PartialEq)]
|
||||
pub enum Step {Left,Right,Up,Down,LineBegin,LineEnd,DocBegin,DocEnd}
|
||||
|
||||
/// A struct for cursor navigation process
|
||||
#[derive(Debug)]
|
||||
pub struct CursorNavigation<'a,'b> {
|
||||
pub content : &'a mut TextComponentContent,
|
||||
pub fonts : &'b mut Fonts,
|
||||
@ -122,8 +123,8 @@ impl<'a,'b> CursorNavigation<'a,'b> {
|
||||
}
|
||||
|
||||
/// Move cursor by given step.
|
||||
pub fn move_cursor(&mut self, cursor:&mut Cursor, step:&Step) {
|
||||
let new_position = self.new_position(cursor.position,&step);
|
||||
pub fn move_cursor(&mut self, cursor:&mut Cursor, step:Step) {
|
||||
let new_position = self.new_position(cursor.position,step);
|
||||
self.move_cursor_to_position(cursor,new_position);
|
||||
}
|
||||
|
||||
@ -183,7 +184,7 @@ impl<'a,'b> CursorNavigation<'a,'b> {
|
||||
}
|
||||
|
||||
/// New position of cursor at `position` after applying `step`.
|
||||
fn new_position(&mut self, position: TextLocation, step:&Step) -> TextLocation {
|
||||
fn new_position(&mut self, position: TextLocation, step:Step) -> TextLocation {
|
||||
match step {
|
||||
Step::Left => self.prev_char_position(&position).unwrap_or(position),
|
||||
Step::Right => self.next_char_position(&position).unwrap_or(position),
|
||||
@ -291,8 +292,8 @@ impl Cursors {
|
||||
///
|
||||
/// If after this operation some of the cursors occupies the same position, or their selected
|
||||
/// area overlap, they are irreversibly merged.
|
||||
pub fn navigate_all_cursors(&mut self, navigaton:&mut CursorNavigation, step:&Step) {
|
||||
self.cursors.iter_mut().for_each(|cursor| navigaton.move_cursor(cursor,&step));
|
||||
pub fn navigate_all_cursors(&mut self, navigaton:&mut CursorNavigation, step:Step) {
|
||||
self.cursors.iter_mut().for_each(|cursor| navigaton.move_cursor(cursor,step));
|
||||
self.merge_overlapping_cursors();
|
||||
self.dirty = true;
|
||||
}
|
||||
@ -411,7 +412,7 @@ mod test {
|
||||
for step in &[Left,Right,Up,Down,LineBegin,LineEnd,DocBegin,DocEnd] {
|
||||
let mut cursors = Cursors::mock(initial_cursors.clone());
|
||||
|
||||
cursors.navigate_all_cursors(&mut navigation,step);
|
||||
cursors.navigate_all_cursors(&mut navigation,*step);
|
||||
let expected = expected_positions.get(step).unwrap();
|
||||
let current = cursors.cursors.iter().map(|c| (c.position.line, c.position.column));
|
||||
assert_eq!(expected,¤t.collect_vec(), "Error for step {:?}", step);
|
||||
@ -439,7 +440,7 @@ mod test {
|
||||
selecting: false
|
||||
};
|
||||
let mut cursors = Cursors::mock(initial_cursors.clone());
|
||||
cursors.navigate_all_cursors(&mut navigation,&LineEnd);
|
||||
cursors.navigate_all_cursors(&mut navigation,LineEnd);
|
||||
assert_eq!(new_position, cursors.cursors.first().unwrap().position);
|
||||
assert_eq!(new_position, cursors.cursors.first().unwrap().selected_to);
|
||||
})
|
||||
@ -462,7 +463,7 @@ mod test {
|
||||
selecting: true
|
||||
};
|
||||
let mut cursors = Cursors::mock(initial_cursors.clone());
|
||||
cursors.navigate_all_cursors(&mut navigation,&LineEnd);
|
||||
cursors.navigate_all_cursors(&mut navigation,LineEnd);
|
||||
assert_eq!(new_loc , cursors.cursors.first().unwrap().position);
|
||||
assert_eq!(initial_loc, cursors.cursors.first().unwrap().selected_to);
|
||||
})
|
||||
|
@ -108,11 +108,11 @@ pub struct AttributeQualifier {
|
||||
impl AttributeQualifier {
|
||||
pub fn to_input_var<Name:Into<glsl::Identifier>>
|
||||
(&self, name:Name) -> glsl::GlobalVar {
|
||||
let storage = self.storage.clone();
|
||||
let storage = self.storage;
|
||||
glsl::GlobalVar {
|
||||
layout : None,
|
||||
storage : Some(glsl::GlobalVarStorage::InStorage(storage)),
|
||||
prec : self.prec.clone(),
|
||||
prec : self.prec,
|
||||
typ : self.typ.clone(),
|
||||
ident : name.into()
|
||||
}
|
||||
@ -120,11 +120,11 @@ impl AttributeQualifier {
|
||||
|
||||
pub fn to_output_var<Name:Into<glsl::Identifier>>
|
||||
(&self, name:Name) -> glsl::GlobalVar {
|
||||
let storage = self.storage.clone();
|
||||
let storage = self.storage;
|
||||
glsl::GlobalVar {
|
||||
layout : None,
|
||||
storage : Some(glsl::GlobalVarStorage::OutStorage(storage)),
|
||||
prec : self.prec.clone(),
|
||||
prec : self.prec,
|
||||
typ : self.typ.clone(),
|
||||
ident : name.into()
|
||||
}
|
||||
@ -175,7 +175,7 @@ impl UniformQualifier {
|
||||
glsl::GlobalVar{
|
||||
layout : None,
|
||||
storage : Some(glsl::GlobalVarStorage::UniformStorage),
|
||||
prec : self.prec.clone(),
|
||||
prec : self.prec,
|
||||
typ : self.typ.clone(),
|
||||
ident : name.into()
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ pub use stats::*;
|
||||
static mut SCENE: Option<Scene> = None;
|
||||
|
||||
/// Very unsafe function. Do not use. See documentation of `WORLD` to learn more.
|
||||
#[allow(unsafe_code)]
|
||||
pub(crate) fn get_scene() -> Scene {
|
||||
unsafe {
|
||||
SCENE.as_ref().unwrap_or_else(|| panic!("World not initialized.")).clone_ref()
|
||||
@ -58,6 +59,7 @@ pub(crate) fn get_scene() -> Scene {
|
||||
}
|
||||
|
||||
/// Very unsafe function. Do not use. See documentation of `WORLD` to learn more.
|
||||
#[allow(unsafe_code)]
|
||||
fn init_global_variables(world:&World) {
|
||||
unsafe {
|
||||
SCENE = Some(world.rc.borrow().scene.clone_ref());
|
||||
|
@ -23,14 +23,14 @@ use js_sys::Math;
|
||||
use std::rc::Rc;
|
||||
use std::cell::RefCell;
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone,Debug)]
|
||||
/// A simplified Canvas object used in the EasingAnimator example.
|
||||
pub struct Canvas {
|
||||
canvas : HtmlCanvasElement,
|
||||
context : CanvasRenderingContext2d
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
/// Interpolable properties for our example code.
|
||||
pub struct Properties {
|
||||
/// Position property.
|
||||
|
@ -4,6 +4,9 @@
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
#![warn(unsafe_code)]
|
||||
#![warn(missing_copy_implementations)]
|
||||
#![warn(missing_debug_implementations)]
|
||||
#![warn(missing_docs)]
|
||||
#![warn(trivial_casts)]
|
||||
#![warn(trivial_numeric_casts)]
|
||||
|
@ -231,6 +231,7 @@ impl<T: BufferItem> BufferData<T> {
|
||||
}
|
||||
|
||||
/// Replaces the whole GPU buffer by the local data.
|
||||
#[allow(unsafe_code)]
|
||||
fn replace_gpu_buffer(&mut self) {
|
||||
let data = self.as_slice();
|
||||
let gl_enum = self.usage.into_gl_enum().into();
|
||||
@ -251,6 +252,7 @@ impl<T: BufferItem> BufferData<T> {
|
||||
}
|
||||
|
||||
/// Updates the GPU sub-buffer data by the provided index range.
|
||||
#[allow(unsafe_code)]
|
||||
fn update_gpu_sub_buffer(&mut self, range:&RangeInclusive<usize>) {
|
||||
let data = self.as_slice();
|
||||
let item_byte_size = T::item_gpu_byte_size() as u32;
|
||||
@ -323,7 +325,7 @@ use crate::system::gpu::data::AttributeInstanceIndex;
|
||||
// === Macros ===
|
||||
|
||||
/// Variant mismatch error type.
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub struct BadVariant;
|
||||
|
||||
macro_rules! define_any_buffer {
|
||||
|
@ -177,6 +177,7 @@ impl<T:BufferItem<Item=T>,R,C> BufferItem for MatrixMN<T,R,C>
|
||||
type Rows = R;
|
||||
type Cols = C;
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn slice_from_items(buffer: &[Self::Item]) -> &[Self] {
|
||||
// This code casts slice to matrix. This is safe because `MatrixMN`
|
||||
// uses `nalgebra::Owned` allocator, which resolves to array defined as
|
||||
@ -185,6 +186,7 @@ impl<T:BufferItem<Item=T>,R,C> BufferItem for MatrixMN<T,R,C>
|
||||
unsafe { std::slice::from_raw_parts(buffer.as_ptr().cast(), len) }
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn slice_from_items_mut(buffer: &mut [Self::Item]) -> &mut [Self] {
|
||||
// This code casts slice to matrix. This is safe because `MatrixMN`
|
||||
// uses `nalgebra::Owned` allocator, which resolves to array defined as
|
||||
@ -193,6 +195,7 @@ impl<T:BufferItem<Item=T>,R,C> BufferItem for MatrixMN<T,R,C>
|
||||
unsafe { std::slice::from_raw_parts_mut(buffer.as_mut_ptr().cast(), len) }
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn slice_to_items(buffer: &[Self]) -> &[Self::Item] {
|
||||
// This code casts slice to matrix. This is safe because `MatrixMN`
|
||||
// uses `nalgebra::Owned` allocator, which resolves to array defined as
|
||||
@ -201,6 +204,7 @@ impl<T:BufferItem<Item=T>,R,C> BufferItem for MatrixMN<T,R,C>
|
||||
unsafe { std::slice::from_raw_parts(buffer.as_ptr().cast(), len) }
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn slice_to_items_mut(buffer: &mut [Self]) -> &mut [Self::Item] {
|
||||
// This code casts slice to matrix. This is safe because `MatrixMN`
|
||||
// uses `nalgebra::Owned` allocator, which resolves to array defined as
|
||||
@ -217,6 +221,7 @@ impl<T:BufferItem<Item=T>,R,C> BufferItem for MatrixMN<T,R,C>
|
||||
// ====================
|
||||
|
||||
/// Extension method for viewing into wasm's linear memory.
|
||||
#[allow(unsafe_code)]
|
||||
pub trait JsBufferView {
|
||||
/// Creates a JS typed array which is a view into wasm's linear memory at the slice specified.
|
||||
///
|
||||
@ -240,6 +245,7 @@ pub trait JsBufferView {
|
||||
|
||||
// === Instances ===
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl JsBufferView for [bool] {
|
||||
unsafe fn js_buffer_view(&self) -> js_sys::Object {
|
||||
let i32arr = self.iter().cloned().map(|t| if t {1} else {0}).collect::<Vec<i32>>();
|
||||
@ -247,30 +253,35 @@ impl JsBufferView for [bool] {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl JsBufferView for [i32] {
|
||||
unsafe fn js_buffer_view(&self) -> js_sys::Object {
|
||||
js_sys::Int32Array::view(self).into()
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl JsBufferView for [u32] {
|
||||
unsafe fn js_buffer_view(&self) -> js_sys::Object {
|
||||
js_sys::Uint32Array::view(self).into()
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl JsBufferView for [f32] {
|
||||
unsafe fn js_buffer_view(&self) -> js_sys::Object {
|
||||
js_sys::Float32Array::view(self).into()
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl JsBufferView for [u8] {
|
||||
unsafe fn js_buffer_view(&self) -> js_sys::Object {
|
||||
js_sys::Uint8Array::view(self).into()
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl<T: BufferItem<Item=T>,R,C> JsBufferView for [MatrixMN<T,R,C>]
|
||||
where Self : MatrixCtx<T,R,C>,
|
||||
T : ItemBounds,
|
||||
@ -281,6 +292,7 @@ impl<T: BufferItem<Item=T>,R,C> JsBufferView for [MatrixMN<T,R,C>]
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl<T: BufferItem<Item=T>,R,C> JsBufferView for MatrixMN<T,R,C>
|
||||
where Self:MatrixCtx<T,R,C>, T:ItemBounds {
|
||||
unsafe fn js_buffer_view(&self) -> js_sys::Object {
|
||||
|
@ -27,6 +27,7 @@ pub struct TextureUnit(u32);
|
||||
// ========================
|
||||
|
||||
/// Guard which unbinds texture in specific texture unit on drop.
|
||||
#[derive(Debug)]
|
||||
pub struct TextureBindGuard {
|
||||
context : Context,
|
||||
target : u32,
|
||||
|
@ -15,7 +15,7 @@ use crate::system::gpu::data::texture::types::*;
|
||||
// ===============
|
||||
|
||||
/// Sized, uninitialized texture.
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub struct GpuOnlyData {
|
||||
/// Texture width.
|
||||
pub width : i32,
|
||||
|
@ -43,6 +43,7 @@ impl<T> OwnedData<T> {
|
||||
|
||||
impl<I:InternalFormat,T:ItemType+JsBufferViewArr>
|
||||
TextureReload for Texture<Owned,I,T> {
|
||||
#[allow(unsafe_code)]
|
||||
fn reload(&self) {
|
||||
let width = self.storage().width;
|
||||
let height = self.storage().height;
|
||||
|
@ -249,6 +249,7 @@ impl<T> WithContent for Uniform<T> {
|
||||
// === AnyPrimUniform ===
|
||||
// ======================
|
||||
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub struct TypeMismatch;
|
||||
|
||||
macro_rules! define_any_prim_uniform {
|
||||
|
@ -172,6 +172,7 @@ pub fn set_buffer_data(gl_context:&Context, buffer:&WebGlBuffer, data:&[f32]) {
|
||||
/// until it is destroyed. This way of creating buffers were taken from
|
||||
/// wasm-bindgen examples
|
||||
/// (https://rustwasm.github.io/wasm-bindgen/examples/webgl.html)
|
||||
#[allow(unsafe_code)]
|
||||
fn set_bound_buffer_data(gl_context:&Context, target:u32, data:&[f32]) {
|
||||
let usage = Context::STATIC_DRAW;
|
||||
unsafe {
|
||||
@ -194,6 +195,7 @@ pub fn set_buffer_subdata(gl_context:&Context, buffer:&WebGlBuffer, offset:usize
|
||||
/// until it is destroyed. This way of creating buffers were taken from
|
||||
/// wasm-bindgen examples
|
||||
/// (https://rustwasm.github.io/wasm-bindgen/examples/webgl.html)
|
||||
#[allow(unsafe_code)]
|
||||
fn set_bound_buffer_subdata(gl_context:&Context, target:u32, offset:i32, data:&[f32]) {
|
||||
unsafe {
|
||||
let float_array = Float32Array::view(&data);
|
||||
|
@ -113,6 +113,7 @@ where Self:MatrixCtx<T,R,C>, PhantomData<MatrixMN<T,R,C>>:Into<PrimType> {
|
||||
// === Wrong Conversions ===
|
||||
|
||||
/// Error indicating that a value cannot be converted to Glsl.
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub struct NotGlslError;
|
||||
|
||||
|
||||
@ -539,13 +540,13 @@ pub struct GlobalVar {
|
||||
}
|
||||
|
||||
/// Global variable layout definition.
|
||||
#[derive(Clone,Debug,Default)]
|
||||
#[derive(Clone,Copy,Debug,Default)]
|
||||
pub struct Layout {
|
||||
pub location: usize,
|
||||
}
|
||||
|
||||
/// Global variable storage definition.
|
||||
#[derive(Clone,Debug)]
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub enum GlobalVarStorage {
|
||||
ConstStorage,
|
||||
InStorage(LinkageStorage),
|
||||
@ -554,14 +555,14 @@ pub enum GlobalVarStorage {
|
||||
}
|
||||
|
||||
/// Storage definition for in- and out- attributes.
|
||||
#[derive(Clone,Debug,Default)]
|
||||
#[derive(Clone,Copy,Debug,Default)]
|
||||
pub struct LinkageStorage {
|
||||
pub centroid : bool,
|
||||
pub interpolation : Option<InterpolationStorage>,
|
||||
}
|
||||
|
||||
/// Interpolation storage type for attributes.
|
||||
#[derive(Clone,Debug)]
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub enum InterpolationStorage {Smooth, Flat}
|
||||
|
||||
|
||||
@ -638,7 +639,7 @@ impl HasCodeRepr for LocalVar {
|
||||
// =================
|
||||
|
||||
/// Type precision definition.
|
||||
#[derive(Clone,Debug)]
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub enum Precision { Low, Medium, High }
|
||||
|
||||
impl Display for Precision {
|
||||
@ -665,7 +666,7 @@ impl HasCodeRepr for Precision {
|
||||
|
||||
impl From<&Precision> for Precision {
|
||||
fn from(t: &Precision) -> Self {
|
||||
t.clone()
|
||||
*t
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,9 +31,16 @@ mod js {
|
||||
use super::*;
|
||||
#[wasm_bindgen(module = "/src/system/web/dom/html/snippets.js")]
|
||||
extern "C" {
|
||||
#[allow(unsafe_code)]
|
||||
pub fn set_object_transform(dom:&JsValue, matrix_array:&Object);
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub fn setup_perspective(dom: &JsValue, znear: &JsValue);
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub fn setup_camera_orthographic(dom:&JsValue, matrix_array:&JsValue);
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub fn setup_camera_perspective
|
||||
( dom : &JsValue
|
||||
, near : &JsValue
|
||||
@ -55,6 +62,7 @@ pub fn invert_y(mut m: Matrix4<f32>) -> Matrix4<f32> {
|
||||
m
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn set_object_transform(dom: &JsValue, matrix: &Matrix4<f32>) {
|
||||
// Views to WASM memory are only valid as long the backing buffer isn't
|
||||
// resized. Check documentation of IntoFloat32ArrayView trait for more
|
||||
@ -65,6 +73,7 @@ fn set_object_transform(dom: &JsValue, matrix: &Matrix4<f32>) {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn setup_camera_perspective
|
||||
(dom:&JsValue, near:f32, matrix:&Matrix4<f32>) { // Views to WASM memory are only valid as long the backing buffer isn't
|
||||
// resized. Check documentation of IntoFloat32ArrayView trait for more
|
||||
@ -79,6 +88,7 @@ fn setup_camera_perspective
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn setup_camera_orthographic(dom:&JsValue, matrix:&Matrix4<f32>) {
|
||||
// Views to WASM memory are only valid as long the backing buffer isn't
|
||||
// resized. Check documentation of IntoFloat32ArrayView trait for more
|
||||
|
@ -13,6 +13,7 @@ use data::opt_vec::*;
|
||||
// =================
|
||||
|
||||
/// A collection for holding 3D `Object`s.
|
||||
#[derive(Debug)]
|
||||
pub struct HtmlScene {
|
||||
display_object : DisplayObjectData,
|
||||
objects : OptVec<HtmlObject>
|
||||
|
@ -1,3 +1,7 @@
|
||||
#![warn(unsafe_code)]
|
||||
#![warn(missing_copy_implementations)]
|
||||
#![warn(missing_debug_implementations)]
|
||||
|
||||
pub mod opt_vec;
|
||||
|
||||
pub use basegl_prelude as prelude;
|
@ -27,6 +27,10 @@
|
||||
//! evaluated. This is just because the implementation is not finished and
|
||||
//! there are comments in code where it should be added.
|
||||
|
||||
#![warn(unsafe_code)]
|
||||
#![warn(missing_copy_implementations)]
|
||||
#![warn(missing_debug_implementations)]
|
||||
|
||||
// ============
|
||||
// === Eval ===
|
||||
// ============
|
||||
|
@ -1,5 +1,8 @@
|
||||
#![feature(trait_alias)]
|
||||
#![feature(set_stdio)]
|
||||
#![warn(unsafe_code)]
|
||||
#![warn(missing_copy_implementations)]
|
||||
#![warn(missing_debug_implementations)]
|
||||
|
||||
use std::fmt::Debug;
|
||||
use wasm_bindgen::JsValue;
|
||||
|
@ -1,3 +1,6 @@
|
||||
#![warn(unsafe_code)]
|
||||
#![warn(missing_copy_implementations)]
|
||||
#![warn(missing_debug_implementations)]
|
||||
#![allow(non_snake_case)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(dead_code)]
|
||||
|
@ -3,6 +3,9 @@
|
||||
//! defines several aliases and utils which may find their place in new
|
||||
//! libraries in the future.
|
||||
|
||||
#![warn(unsafe_code)]
|
||||
#![warn(missing_copy_implementations)]
|
||||
#![warn(missing_debug_implementations)]
|
||||
#![feature(specialization)]
|
||||
#![feature(trait_alias)]
|
||||
|
||||
@ -443,9 +446,11 @@ pub trait Value {
|
||||
// =======================
|
||||
|
||||
/// Type level `true` value.
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub struct True {}
|
||||
|
||||
/// Type level `false` value.
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub struct False {}
|
||||
|
||||
impl Value for True {
|
||||
|
@ -5,6 +5,9 @@
|
||||
// This library is in a very early stage. It will be refactored and improved
|
||||
// soon. It should not be reviewed now.
|
||||
|
||||
#![warn(unsafe_code)]
|
||||
#![warn(missing_copy_implementations)]
|
||||
#![warn(missing_debug_implementations)]
|
||||
#![feature(generators, generator_trait)]
|
||||
#![feature(specialization)]
|
||||
#![feature(overlapping_marker_traits)]
|
||||
@ -85,6 +88,7 @@ macro_rules! derive_clone_plus {
|
||||
// === IterForGenerator ===
|
||||
// ========================
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct IterForGenerator<G: Generator>(pub G);
|
||||
|
||||
impl<G> Iterator for IterForGenerator<G>
|
||||
@ -104,7 +108,7 @@ where G: Generator<Return = ()> + Unpin {
|
||||
// ======================
|
||||
|
||||
#[derive(Derivative)]
|
||||
#[derivative(Default(bound=""))]
|
||||
#[derivative(Debug,Default(bound=""))]
|
||||
pub struct EmptyGenerator<T>(PhantomData<T>);
|
||||
|
||||
impl<T> EmptyGenerator<T> {
|
||||
|
@ -20,7 +20,7 @@
|
||||
/// ```compile_fail
|
||||
/// shared! { Uniform
|
||||
///
|
||||
/// #[derive(Clone,Debug)]
|
||||
/// #[derive(Clone,Copy,Debug)]
|
||||
/// pub struct UniformData<Value> {
|
||||
/// value: Value,
|
||||
/// dirty: bool,
|
||||
@ -49,7 +49,7 @@
|
||||
/// The following output will be generated:
|
||||
///
|
||||
/// ```compile_fail
|
||||
/// #[derive(Clone,Debug)]
|
||||
/// #[derive(Clone,Copy,Debug)]
|
||||
/// pub struct UniformData<Value> {
|
||||
/// value: Value,
|
||||
/// dirty: bool,
|
||||
@ -74,7 +74,7 @@
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// #[derive(Clone,Debug)]
|
||||
/// #[derive(Clone,Copy,Debug)]
|
||||
/// pub struct Uniform<Value> {
|
||||
/// rc: Rc<RefCell<UniformData<Value>>>
|
||||
/// }
|
||||
|
@ -1,3 +1,7 @@
|
||||
#![warn(unsafe_code)]
|
||||
#![warn(missing_copy_implementations)]
|
||||
#![warn(missing_debug_implementations)]
|
||||
|
||||
extern crate proc_macro;
|
||||
|
||||
use basegl_prelude::*;
|
||||
@ -7,7 +11,6 @@ use proc_macro2::{TokenStream, Ident, Span};
|
||||
use quote::quote;
|
||||
use syn;
|
||||
|
||||
|
||||
////////////////////////////////////////////////
|
||||
|
||||
/// In order to make the definition easier to read, an example expansion of the
|
||||
|
@ -1,3 +1,6 @@
|
||||
#![warn(unsafe_code)]
|
||||
#![warn(missing_copy_implementations)]
|
||||
#![warn(missing_debug_implementations)]
|
||||
#![feature(trait_alias)]
|
||||
#![feature(set_stdio)]
|
||||
|
||||
@ -241,6 +244,7 @@ impl NodeRemover for Node {
|
||||
|
||||
#[wasm_bindgen(inline_js = "export function request_animation_frame2(f) { requestAnimationFrame(f) }")]
|
||||
extern "C" {
|
||||
#[allow(unsafe_code)]
|
||||
pub fn request_animation_frame2(closure: &Closure<dyn FnMut()>) -> i32;
|
||||
}
|
||||
|
||||
@ -324,6 +328,7 @@ export function set_stack_trace_limit() {
|
||||
}
|
||||
")]
|
||||
extern "C" {
|
||||
#[allow(unsafe_code)]
|
||||
pub fn set_stack_trace_limit();
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,10 @@ pub type Listener = Closure<dyn FnMut(f64,f64)>;
|
||||
|
||||
#[wasm_bindgen(module = "/js/resize_observer.js")]
|
||||
extern "C" {
|
||||
#[allow(unsafe_code)]
|
||||
fn resize_observe(target: &JsValue, closure: &Listener) -> usize;
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn resize_unobserve(id: usize);
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
#![warn(unsafe_code)]
|
||||
#![warn(missing_copy_implementations)]
|
||||
#![warn(missing_debug_implementations)]
|
||||
|
||||
extern crate proc_macro;
|
||||
|
||||
use proc_macro::TokenStream;
|
||||
|
@ -14,7 +14,7 @@ use web_sys::HtmlElement;
|
||||
// ======================
|
||||
|
||||
/// Html container displaying benchmark results.
|
||||
#[derive(Shrinkwrap)]
|
||||
#[derive(Shrinkwrap,Debug)]
|
||||
pub struct BenchContainer {
|
||||
#[shrinkwrap(main_field)]
|
||||
container : Container,
|
||||
|
@ -16,7 +16,10 @@ use std::cell::RefCell;
|
||||
// =========================
|
||||
|
||||
/// Cell, used to hold Bencher's data
|
||||
#[derive(Derivative)]
|
||||
#[derivative(Debug)]
|
||||
pub struct BencherProperties {
|
||||
#[derivative(Debug="ignore")]
|
||||
callback : Box<dyn FnMut()>,
|
||||
container : BenchContainer,
|
||||
iterations : usize,
|
||||
@ -54,7 +57,7 @@ impl BencherProperties {
|
||||
// === BencherData ===
|
||||
// ===================
|
||||
|
||||
#[derive(Shrinkwrap)]
|
||||
#[derive(Shrinkwrap,Debug)]
|
||||
pub struct BencherData {
|
||||
properties: RefCell<BencherProperties>
|
||||
}
|
||||
@ -119,7 +122,7 @@ impl BencherData {
|
||||
// ===============
|
||||
|
||||
/// The Bencher struct with an API compatible to Rust's test Bencher.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone,Debug)]
|
||||
pub struct Bencher {
|
||||
data : Rc<BencherData>
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ use web_sys::HtmlElement;
|
||||
// =================
|
||||
|
||||
/// A container to hold tests in `wasm-pack test`.
|
||||
#[derive(Clone,Debug)]
|
||||
pub struct Container {
|
||||
pub div : HtmlElement,
|
||||
pub header : HtmlElement,
|
||||
|
@ -14,6 +14,7 @@ use web_sys::HtmlElement;
|
||||
// =============
|
||||
|
||||
/// Helper to group test containers
|
||||
#[derive(Clone,Debug)]
|
||||
pub struct Group {
|
||||
pub div : HtmlElement,
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
#![feature(arbitrary_self_types)]
|
||||
#![warn(unsafe_code)]
|
||||
#![warn(missing_copy_implementations)]
|
||||
#![warn(missing_debug_implementations)]
|
||||
|
||||
mod system {
|
||||
pub use basegl_system_web as web;
|
||||
|
Loading…
Reference in New Issue
Block a user