Skip to content

Commit

Permalink
Use @struct macro
Browse files Browse the repository at this point in the history
  • Loading branch information
aviks committed Dec 9, 2017
1 parent 6b8e65a commit 5912e56
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
5 changes: 2 additions & 3 deletions src/StrPack.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module StrPack

Base.warn_once("Using v0.2.0 of StrPack, which is incompatible with previous versions")
export @str
export @struct
export pack, unpack, sizeof
export DataAlign
export align_default, align_packed, align_packmax, align_structpack, align_table
Expand Down Expand Up @@ -31,7 +30,7 @@ immutable Str
endianness::Symbol
end

macro str(xpr...)
@eval macro $(Symbol("struct"))(xpr...)
(typname, typ, asize) = extract_annotations(xpr[1])
if length(xpr) > 3
error("too many arguments supplied to @str")
Expand Down
18 changes: 9 additions & 9 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
using Base.Test
using StrPack

@str type A
@struct type A
a::UInt8
end

@str type B
@struct type B
a::Array{UInt8,2}(2,2)
end

@str type C
@struct type C
a::String(5)
end

@str type D
@struct type D
a::C
end

@str type E
@struct type E
a::Array{C,1}(2)
end

@str immutable F
@struct immutable F
a::Array{Float64,2}(3,2)
end

abstract type abstractG; end

@str type G1 <: abstractG
@struct type G1 <: abstractG
a::UInt8
end

@str immutable G2 <: abstractG
@struct immutable G2 <: abstractG
a::UInt8
end

@str type Hvl_t
@struct type Hvl_t
len::Csize_t
p::Ptr{Void}
end
Expand Down

0 comments on commit 5912e56

Please sign in to comment.