Skip to content

Commit

Permalink
Add implementation for deprecated hex().
Browse files Browse the repository at this point in the history
Also move code around a bit.
  • Loading branch information
ma-laforge committed Jul 21, 2020
1 parent 0807f4e commit 0882e19
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "SpiceData"
uuid = "8ca2a67e-f683-5b14-a319-732e1d1d8f2e"
version = "0.3.1"
version = "0.3.2"

[deps]

Expand Down
36 changes: 20 additions & 16 deletions src/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,25 @@ mutable struct DataReader
end


#==Helper Functions
===============================================================================#

hex(x::Integer) = string(x, base=16)
printable(v::String) = isprint(v) ? v : ""
_reorder(v::T, ::BigEndian) where T = ntoh(v)
_reorder(v::T, ::LittleEndian) where T = ltoh(v)

#Debug: show block header info
function _show(io::IO, hdr::BlockHeader, pos::Int)
print(io, "Block: 0x", hex(WRITEBLOCK_SYNCWORD))
print(io, " 0x", hex(hdr.typeid))
print(io, " 0x", hex(WRITEBLOCK_SYNCWORD))
print(io, " 0x", hex(hdr._size))
print(io, " (start 0x", hex(pos), ")")
println(io)
end


#==Exceptions
===============================================================================#
function corruptword_exception(io::IO, w::DataWord, expected::DataWord)
Expand All @@ -101,21 +120,9 @@ function stringboundary_exception(io::IO, )
end


#==Helper Functions
#==
===============================================================================#

printable(v::String) = isprint(v) ? v : ""

#Debug: show block header info
function _show(io::IO, hdr::BlockHeader, pos::Int)
print(io, "Block: 0x", hex(WRITEBLOCK_SYNCWORD))
print(io, " 0x", hex(hdr.typeid))
print(io, " 0x", hex(WRITEBLOCK_SYNCWORD))
print(io, " 0x", hex(hdr._size))
print(io, " (start 0x", hex(pos), ")")
println(io)
end

#-------------------------------------------------------------------------------
xtype(::Format_9601) = Float32
ytype(::Format_9601) = Float32
Expand All @@ -129,9 +136,6 @@ ytype(::Format_2001) = Float64
xtype(::Format_2013) = Float64
ytype(::Format_2013) = Float32

#-------------------------------------------------------------------------------
_reorder(v::T, ::BigEndian) where T = ntoh(v)
_reorder(v::T, ::LittleEndian) where T = ltoh(v)

#IO reads
#-------------------------------------------------------------------------------
Expand Down

2 comments on commit 0882e19

@ma-laforge
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

Release notes:

Add implementation for deprecated hex().

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/18540

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.2 -m "<description of version>" 0882e19ae28bb58a52b3457e7962eb9d869b01a7
git push origin v0.3.2

Please sign in to comment.