From 0206b80086cf568f4d1f76bec4fa165ec6b3020e Mon Sep 17 00:00:00 2001 From: Leandro Martinez Date: Mon, 31 Aug 2020 16:15:55 -0300 Subject: [PATCH] changed eval to macro in Atom --- Project.toml | 2 +- src/Atom.jl | 41 ++++++++++++++++++++++------------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/Project.toml b/Project.toml index a0a54a41..ca344596 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PDBTools" uuid = "e29189f1-7114-4dbd-93d0-c5673a921a58" authors = ["Leandro Martinez "] -version = "0.8.0" +version = "0.8.1" [deps] Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" diff --git a/src/Atom.jl b/src/Atom.jl index e26913ab..059313d7 100644 --- a/src/Atom.jl +++ b/src/Atom.jl @@ -1,32 +1,35 @@ -AtomData = quote - index :: Int64 # The sequential index of the atoms in the file - index_pdb :: Int64 # The index as written in the PDB file (might be anything) - name :: String - resname :: String - chain :: String - resnum :: Int64 # Number of residue as written in PDB file - residue :: Int64 # Sequential residue (molecule) number in file - x :: Float64 - y :: Float64 - z :: Float64 - b :: Float64 - occup :: Float64 - model :: Int64 - segname :: String # Segment name (cols 73:76) +macro SharedAtomData() + ex = quote + index :: Int64 # The sequential index of the atoms in the file + index_pdb :: Int64 # The index as written in the PDB file (might be anything) + name :: String + resname :: String + chain :: String + resnum :: Int64 # Number of residue as written in PDB file + residue :: Int64 # Sequential residue (molecule) number in file + x :: Float64 + y :: Float64 + z :: Float64 + b :: Float64 + occup :: Float64 + model :: Int64 + segname :: String # Segment name (cols 73:76) + end + esc(ex) end # Mutable structure used to read data only -@eval mutable struct MutableAtom - $AtomData +mutable struct MutableAtom + @SharedAtomData() end MutableAtom() = empty_struct(MutableAtom) # Immutable structure used for critical code -@eval struct Atom - $AtomData +struct Atom + @SharedAtomData() end # Initialize mutable from immutable and vice-versa