chiark / gitweb /
Move outline into its own file
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 14 May 2022 22:11:56 +0000 (23:11 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 14 May 2022 22:11:56 +0000 (23:11 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/imports.rs
src/lib.rs
src/outline.rs [new file with mode: 0644]
src/spec.rs

index f1aa955b58e7443896f89a50cc54d6e17488d7bd..cf03b4446cf4303f572bd96eed0285aeb8eca6ab 100644 (file)
@@ -96,6 +96,7 @@ pub use crate::materials_format;
 pub use crate::mgmtchannel::*;
 pub use crate::occultilks::*;
 pub use crate::organise;
+pub use crate::outline::*;
 pub use crate::pcaliases::*;
 pub use crate::pcrender::*;
 pub use crate::pieces::*;
index f601e92d4d6c4da6f75463766e3671d1cb5a9034..ad74d08c25768ef368818e7f9b6d8c166e3b34a0 100644 (file)
@@ -41,6 +41,7 @@ pub mod mgmtchannel;
 pub mod nwtemplates;
 pub mod occultilks;
 pub mod organise;
+pub mod outline;
 pub mod pcaliases;
 pub mod pcrender;
 pub mod pieces;
diff --git a/src/outline.rs b/src/outline.rs
new file mode 100644 (file)
index 0000000..ebe2512
--- /dev/null
@@ -0,0 +1,56 @@
+// Copyright 2020-2021 Ian Jackson and contributors to Otter
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// There is NO WARRANTY.
+
+// Copyright 2020-2021 Ian Jackson and contributors to Otter
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// There is NO WARRANTY.
+
+use crate::prelude::*;
+
+//================ principal definitions of both shapes ================
+
+macro_rules! shape_defns { {
+  $( $Shape:ident  $serde:literal  ;)*
+} => { paste!{
+
+
+  $( use crate::shapelib::[< $Shape Outline >]; )*
+
+  #[dyn_upcast(OutlineTrait)]
+  #[enum_dispatch(OutlineTrait)]
+  #[derive(Clone,Debug,Serialize,Deserialize)]
+  #[serde(tag="type")]
+  pub enum Outline { $(
+    #[serde(rename=$serde)] [< $Shape Outline >],
+  )* }
+
+
+  #[derive(Deserialize,Debug,Copy,Clone,Eq,PartialEq)]
+  pub enum Shape { $(
+    #[serde(rename=$serde)] [< $Shape >],
+  )* }
+
+
+  $(
+  #[derive(Deserialize,Debug)]
+  pub struct [< $Shape ShapeIndicator >];
+  )*
+
+
+  impl Shape {
+    pub fn shapelib_loadable(self)
+        -> &'static dyn shapelib::ShapeLoadableTrait
+    {
+      match self { $(
+        Self::$Shape => &[< $Shape ShapeIndicator >] as _,
+      )* }
+    }
+  }
+
+} } }
+
+shape_defns! {
+  Circle "Circle";
+  Rect   "Rect"  ;
+}
index ab0c5c820631d52b3956269ee4cac43bbf40129d..07929b0da3a118c0a333011bdf8b03eb7d31994f 100644 (file)
@@ -5,6 +5,7 @@
 // game specs
 
 use crate::crates::*;
+use crate::outline::*;
 use otter_support::crates::*;
 use otter_base::crates::*;
 
@@ -256,51 +257,6 @@ pub struct ItemSpec {
   pub item: String,
 }
 
-mod outline {
-  use crate::prelude::*;
-
-  macro_rules! shape_defns { {
-    $( $Shape:ident  $serde:literal  ;)*
-  } => { paste!{
-    $( use crate::shapelib::[< $Shape Outline >]; )*
-
-    #[dyn_upcast(OutlineTrait)]
-    #[enum_dispatch(OutlineTrait)]
-    #[derive(Clone,Debug,Serialize,Deserialize)]
-    #[serde(tag="type")]
-    pub enum Outline { $(
-      #[serde(rename=$serde)] [< $Shape Outline >],
-    )* }
-
-    #[derive(Deserialize,Debug,Copy,Clone,Eq,PartialEq)]
-    pub enum Shape { $(
-      #[serde(rename=$serde)] [< $Shape >],
-    )* }
-
-    $(
-    #[derive(Deserialize,Debug)]
-    pub struct [< $Shape ShapeIndicator >];
-    )*
-
-    impl Shape {
-      pub fn shapelib_loadable(self)
-          -> &'static dyn shapelib::ShapeLoadableTrait
-      {
-        match self { $(
-          Self::$Shape => &[< $Shape ShapeIndicator >] as _,
-        )* }
-      }
-    }
-    
-  } } }
-
-  shape_defns! {
-    Circle "Circle";
-    Rect   "Rect"  ;
-  }
-}
-pub use outline::*;
-
 pub mod piece_specs {
   use super::*;