-
Notifications
You must be signed in to change notification settings - Fork 102
Fix 32 bit support #389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix 32 bit support #389
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -204,7 +204,7 @@ StructUtils.nulllike(::StructUtils.StructStyle, x::LazyValues) = gettype(x) == J | |
|
|
||
| # core method that detects what JSON value is at the current position | ||
| # and immediately returns an appropriate LazyValue instance | ||
| function _lazy(buf, pos, len, b, opts, isroot=false) | ||
| function _lazy(buf, pos::Int, len, b, opts, isroot=false) | ||
| if opts.jsonlines | ||
| return LazyValue(buf, pos, JSONTypes.ARRAY, opts, isroot) | ||
| elseif b == UInt8('{') | ||
|
|
@@ -256,7 +256,7 @@ end | |
| # returns a `pos` value that notes the next position where parsing should continue | ||
| # this is essentially the `StructUtils.applyeach` implementation for LazyValues w/ type OBJECT | ||
| function applyobject(keyvalfunc, x::LazyValues) | ||
| pos = getpos(x) | ||
| pos::Int = getpos(x) | ||
nhz2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| buf = getbuf(x) | ||
| len = getlength(buf) | ||
| opts = getopts(x) | ||
|
|
@@ -356,7 +356,7 @@ end | |
| # returns a `pos` value that notes the next position where parsing should continue | ||
| # this is essentially the `StructUtils.applyeach` implementation for LazyValues w/ type ARRAY | ||
| function applyarray(keyvalfunc, x::LazyValues) | ||
| pos = getpos(x) | ||
| pos::Int = getpos(x) | ||
| buf = getbuf(x) | ||
| len = getlength(buf) | ||
| opts = getopts(x) | ||
|
|
@@ -544,7 +544,7 @@ isbigfloat(x::NumberResult) = x.tag == BIGFLOAT | |
|
|
||
| @inline function parsenumber(x::LazyValue) | ||
| buf = getbuf(x) | ||
| pos = getpos(x) | ||
| pos::Int = getpos(x) | ||
| len = getlength(buf) | ||
| opts = getopts(x) | ||
| b = getbyte(buf, pos) | ||
|
|
@@ -627,14 +627,14 @@ isbigfloat(x::NumberResult) = x.tag == BIGFLOAT | |
| # if we overflowed, then let's try BigFloat | ||
| bres = Parsers.xparse2(BigFloat, buf, startpos, len) | ||
| if !Parsers.invalid(bres.code) | ||
| return NumberResult(bres.val), startpos + bres.tlen | ||
| return NumberResult(bres.val), startpos + Int(bres.tlen) | ||
| end | ||
| end | ||
| if Parsers.invalid(res.code) | ||
| error = InvalidNumber | ||
| @goto invalid | ||
| end | ||
| return NumberResult(res.val), startpos + res.tlen | ||
| return NumberResult(res.val), Int(startpos + res.tlen) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Somewhat tangential: but what if this overflows to a negative position? I guess this means that on 32-bit systems we can't read files larger than 2 GB? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but with the current design, the whole file needs to be loaded into memory before parsing. Though maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doing the |
||
| else | ||
| if overflow | ||
| return NumberResult(isneg ? -bval : bval), pos | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -214,7 +214,7 @@ parse!(x::LazyValue, obj::T; dicttype::Type{O}=DEFAULT_OBJECT_TYPE, null=nothing | |
| # for LazyValue, if x started at the beginning of the JSON input, | ||
| # then we want to ensure that the entire input was consumed | ||
| # and error if there are any trailing invalid JSON characters | ||
| function checkendpos(x::LazyValue, ::Type{T}, pos) where {T} | ||
| function checkendpos(x::LazyValue, ::Type{T}, pos::Int) where {T} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
| buf = getbuf(x) | ||
| len = getlength(buf) | ||
| if pos <= len | ||
|
|
@@ -427,7 +427,7 @@ end | |
| @generated function StructUtils.maketuple(st::StructStyle, ::Type{T}, x::LazyValues) where {T<:Tuple} | ||
| N = fieldcount(T) | ||
| ex = quote | ||
| pos = getpos(x) | ||
| pos::Int = getpos(x) | ||
| buf = getbuf(x) | ||
| len = getlength(buf) | ||
| opts = getopts(x) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't necessary, right? (prefer to remove from a code style perspective)