From 97a8849696cea3459610d28ddd65a290a89fce18 Mon Sep 17 00:00:00 2001 From: Spencer Russell Date: Thu, 28 Jul 2016 11:04:35 -0400 Subject: [PATCH] adds fieldoffset, fixes #218 (#260) * adds fieldoffset, fixes #218 * fixes fieldoffset to return a UInt * fixes fieldoffset on v0.3 --- README.md | 2 ++ src/Compat.jl | 5 +++++ test/runtests.jl | 2 ++ 3 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 864c6c2d50ca8..2582d51ebe9e3 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/src/Compat.jl b/src/Compat.jl index 721e706601a2a..16ef09dc8cf92 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index 2bbbb16e7d638..a6c3104379102 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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