Skip to content

Commit

Permalink
adds fieldoffset, fixes #218 (#260)
Browse files Browse the repository at this point in the history
* adds fieldoffset, fixes #218

* fixes fieldoffset to return a UInt

* fixes fieldoffset on v0.3
  • Loading branch information
ssfrr authored and stevengj committed Jul 28, 2016
1 parent 29ab7eb commit 97a8849
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ Currently, the `@compat` macro supports the following syntaxes:

* `slice` is now `view`[#16972](https://github.com/JuliaLang/julia/pull/16972) do `import Compat.view` and then use `view` normally without the `@compat` macro.

* `fieldoffsets` has been deprecated in favor of `fieldoffset`[#14777](https://github.com/JuliaLang/julia/pull/14777).

## New macros

* `@static` has been added [#16219](https://github.com/JuliaLang/julia/pull/16219).
Expand Down
5 changes: 5 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,11 @@ else
end
end

if VERSION < v"0.5.0-dev+2285"
fieldoffset(T, i) = @compat UInt(fieldoffsets(T)[i])
export fieldoffset
end

if !isdefined(Base, :view)
const view = slice
end
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ if VERSION < v"0.4.0-dev+3609"
end
end

@test fieldoffset(Complex{Float32}, 2) === @compat UInt(4)

@test parse(Int8, '9') == convert(Int8, 9)
@test parse(Int, 'a', 16) == 10
@test parse(Int, "200") == 200
Expand Down

0 comments on commit 97a8849

Please sign in to comment.