Paul J. Davis [Fri, 17 Jul 2015 17:31:11 +0000 (12:31 -0500)]
Add latest Erlang VMs to the test matrix
Paul J. Davis [Fri, 17 Jul 2015 17:18:21 +0000 (12:18 -0500)]
Remove flaky test case
This test has proved its point and now just exists to randomly fail some
builds depending on race conditions with the garbage collector.
Paul J. Davis [Fri, 17 Jul 2015 17:16:48 +0000 (12:16 -0500)]
Fix map type spec
I was being lazy and relying on Travis. This fixes up the map spec for
newer VMs.
Paul J. Davis [Fri, 17 Jul 2015 16:59:50 +0000 (11:59 -0500)]
Add map typespec for dialyzer
This obviously only exists on VMs that support it.
Paul J. Davis [Fri, 17 Jul 2015 16:59:39 +0000 (11:59 -0500)]
Strings can be atoms or binaries
Paul J. Davis [Wed, 15 Jul 2015 23:43:06 +0000 (18:43 -0500)]
Fix dialyzer type specs
Paul J. Davis [Wed, 15 Jul 2015 22:00:42 +0000 (17:00 -0500)]
Revamp yields back to Erlang
In the original PR for `return_trailer` @vlm pointed out that I wasn't
using enif_consume_timeslice correctly. This fixes that by changing out
its called.
Previously we attempted to define the total number of bytes to decode or
encode in a single NIF call and then would consume as much of the
timeslice as we processed. This is wrong because we may start the NIF
call with less than an entire timeslice left.
The new approach is to define the number of bytes to encode or decode
per reduction and then iteratively call enif_consume_timeslice until it
indicates that we should return.
Paul J. Davis [Wed, 15 Jul 2015 21:18:13 +0000 (16:18 -0500)]
Add new return_trailer option
Previously Jiffy would throw an error about trailing data if there is
any non-whitespace character encounter after the first term had been
decoded.
This patch adds a decoder option `return_trailer` that will instead
return a sub-binary starting at the first non-whitespace character. This
allows users to be able to decode multiple terms from a single iodata()
term.
Thanks to @vlm for the original patch.
Paul J. Davis [Wed, 15 Jul 2015 22:53:57 +0000 (17:53 -0500)]
Ignore test XML files
Paul J. Davis [Wed, 15 Jul 2015 20:49:37 +0000 (15:49 -0500)]
Merge pull request #65 from lpgauth/no_native
Add compile option no_native
Paul J. Davis [Wed, 15 Jul 2015 20:45:23 +0000 (15:45 -0500)]
Add Dialyzer types and specs
Thanks to @joedevivo for the contribution.
Fixes #85
Paul J. Davis [Wed, 15 Jul 2015 20:44:18 +0000 (15:44 -0500)]
Squash to new double-conversion
Paul J. Davis [Wed, 15 Jul 2015 20:35:51 +0000 (15:35 -0500)]
Document new encoding and decoding options
Paul J. Davis [Wed, 15 Jul 2015 20:27:04 +0000 (15:27 -0500)]
Update double-conversion to latest master
Paul J. Davis [Wed, 15 Jul 2015 20:19:29 +0000 (15:19 -0500)]
Fix typo in README.md
Thanks to @dvliman and @kxepal for noticing.
Paul J. Davis [Wed, 15 Jul 2015 20:18:30 +0000 (15:18 -0500)]
Merge pull request #93 from ratelle/master
Add replace_undefined and escape_forward_slashes
Jeremie Lasalle Ratelle [Wed, 20 May 2015 22:20:17 +0000 (18:20 -0400)]
Add an option to escape forward slashes
This brings back escaping forward slashes as an option during encoding.
Default is still not to escape.
Jeremie Lasalle Ratelle [Fri, 24 Apr 2015 16:35:32 +0000 (12:35 -0400)]
Add an option to control null value decoding atom
This is pretty much a generalisation of the use_nil option to support an
arbitrary atom.
Paul J. Davis [Fri, 29 May 2015 19:35:26 +0000 (14:35 -0500)]
Merge pull request #92 from emfa/master
Changed pos to unsigned int to prevent warning from happening.
Emil Falk [Fri, 29 May 2015 14:03:31 +0000 (16:03 +0200)]
Changed pos to unsigned int to prevent warning from happening.
Paul J. Davis [Fri, 22 May 2015 20:18:54 +0000 (15:18 -0500)]
Merge pull request #86 from clonejo/patch-1
update README.md fixing typo in maps example
Feiko Nanninga [Fri, 24 Apr 2015 14:15:05 +0000 (16:15 +0200)]
update README.md fixing typo in maps example
Paul J. Davis [Tue, 3 Feb 2015 20:00:12 +0000 (14:00 -0600)]
Merge pull request #78 from tuncer/rebar.config-windows
rebar.config: fix Windows support (CFLAGS, CXXFLAGS)
Tuncer Ayaz [Wed, 14 Jan 2015 14:50:56 +0000 (15:50 +0100)]
rebar.config: fix Windows support (CFLAGS, CXXFLAGS)
Paul J. Davis [Thu, 13 Nov 2014 00:46:06 +0000 (18:46 -0600)]
Account for char possibly being unsigned
This sounds rather insane to me but I've managed to show that `(char)
-1` is converted to 255 on some platforms. This was reproduced on
ppc64el via Qemu on OS X. A simple program that does `fprintf(stderr,
"%d\r\n", (char) -1);` prints 255 to the console. Rather than rely on
the signedness of a char I've just updated things to use an unsigned
char (which hopefully is never signed) and replaced -1 with 255 for the
sentinel value when converting hex values.
Thanks to Balint Reczey (@rbalint) for the report.
Fixes #74
Paul J. Davis [Fri, 3 Oct 2014 20:54:26 +0000 (15:54 -0500)]
Travis.ci added support for Erlang 17.1
Paul J. Davis [Tue, 30 Sep 2014 22:03:37 +0000 (17:03 -0500)]
Fix memory leak when encoding bare bignums
This fixes a leak when encoding a bare bignum. Technically it would be
possible to hit this memory leak randomly with bignums in objects but
the chances are highly unlikely.
Thanks to @miriampena for the issue.
Fixes #69
Paul J. Davis [Fri, 19 Sep 2014 19:28:55 +0000 (14:28 -0500)]
Remove unnecessary inclusion of proper.hrl
Paul J. Davis [Sat, 23 Aug 2014 12:20:37 +0000 (07:20 -0500)]
Persist the `val` register across yield
The `val` variable is a register value that we need to be able to return
at any time from `decode_iter`. If it happened that a yield was
triggered while processing trailing whitespace the lack of persistance
caused decode to return a term intialized from a random integer value.
Obviously the Erlang VM did not enjoy this.
Thanks to @michalpalka for the report.
Fixes #66
Paul J. Davis [Sat, 23 Aug 2014 10:47:59 +0000 (05:47 -0500)]
Improved encoder errors
This updates encoder errors to report the actual Erlang value that
caused the error. This should make it easier to debug errors when
generating JSON.
Paul J. Davis [Sat, 23 Aug 2014 10:49:12 +0000 (05:49 -0500)]
Tweak the nil encoding logic
I must've managed to miss the PR update from Stanislav the other day
when merging this.
Stanislav Vishnevskiy [Tue, 19 Aug 2014 18:44:49 +0000 (11:44 -0700)]
Improved Elixir compatibility
This implements the `use_nil` option as discussed on issue #64. Passing
the atom `use_nil` as an option to both encode and decode will replace
the atom `null` with `nil` when decoding and encode `nil` as `null` when
encoding values.
Fixes #64
Fixes #68
Louis-Philippe Gauthier [Wed, 16 Jul 2014 00:43:33 +0000 (20:43 -0400)]
Add compile option no_native
Paul J. Davis [Fri, 20 Jun 2014 20:30:17 +0000 (15:30 -0500)]
Avoid uint64 for 32bit compatibility
Rather than worry about truncation casting from a possibly 64bit value
down to a possibly 32bit size_t we just limit the total bytes per
invocation to 4G using an unsigned integer.
Thanks to @seriyps for the report.
Fixes #61
Paul J. Davis [Tue, 17 Jun 2014 19:48:40 +0000 (14:48 -0500)]
Disable strict aliasing
This is motivated by issue #60 to see if we can get away with `-O3`
while still handling the cast of a `Decoder**` to `void**`.
Fixes #60
Paul J. Davis [Tue, 17 Jun 2014 07:58:27 +0000 (02:58 -0500)]
Be explicit on the stdlib dependency
Paul J. Davis [Tue, 17 Jun 2014 07:57:50 +0000 (02:57 -0500)]
Update optimization flags
Paul J. Davis [Tue, 17 Jun 2014 02:52:32 +0000 (21:52 -0500)]
Include documentation on the maps feature
Paul J. Davis [Tue, 17 Jun 2014 02:39:49 +0000 (21:39 -0500)]
Fix timeouts for short doubles
Timeouts apparently don't actually work unless you use a test generator.
Which makes sense in hindsight.
Paul J. Davis [Tue, 17 Jun 2014 02:23:39 +0000 (21:23 -0500)]
Silence unused function compiler warnings
Paul J. Davis [Tue, 17 Jun 2014 02:19:23 +0000 (21:19 -0500)]
Include the Travis-CI status badge in the README
Paul J. Davis [Tue, 17 Jun 2014 02:14:57 +0000 (21:14 -0500)]
Adjust timeouts to a sane cutoff
Paul J. Davis [Tue, 17 Jun 2014 02:14:39 +0000 (21:14 -0500)]
Remove etap target from the Makefile
Paul J. Davis [Tue, 17 Jun 2014 02:09:49 +0000 (21:09 -0500)]
Make sure to update the config for Travis-CI
Paul J. Davis [Tue, 17 Jun 2014 02:06:22 +0000 (21:06 -0500)]
Enable Travis-CI builds
Paul J. Davis [Tue, 17 Jun 2014 01:58:26 +0000 (20:58 -0500)]
Replace etap with eunit for the test suite
Finally got off my butt and started using EUnit.
Paul J. Davis [Tue, 17 Jun 2014 01:55:19 +0000 (20:55 -0500)]
Be specific enough that =:= returns true
Refactoring the test suite I found that the old etap was only as strict
as the `==` operator where as EUnit uses the `=:=` operator.
Paul J. Davis [Mon, 16 Jun 2014 21:17:51 +0000 (16:17 -0500)]
Initial support for the new map type
This patch adds initial support for decoding/encoding to/from the new
maps data type.
I'd like to thank Jihyun Yu (yjh0502) for the initial versions of this
work.
Paul J. Davis [Fri, 13 Jun 2014 22:16:14 +0000 (17:16 -0500)]
Expand the README to cover the API more clearly
Paul J. Davis [Fri, 13 Jun 2014 22:05:48 +0000 (17:05 -0500)]
Minor README.md grammar correction.
Paul J. Davis [Fri, 13 Jun 2014 21:49:39 +0000 (16:49 -0500)]
Yield back to Erlang while encoding JSON
This adds a configurable limit on the number of bytes produced by
the encoder before yielding back to the Erlang VM. This is to avoid the
infamous scheduler collapse issues.
The `jiffy:encode/2` now takes an option `{bytes_per_iter,
pos_integer()}` that controls the yield frequency. The default value is
2048.
Paul J. Davis [Fri, 13 Jun 2014 21:25:06 +0000 (16:25 -0500)]
Yield back to Erlang while decoding JSON
This adds a configurable limit on the number of bytes consumed by
the decoder before yielding back to the Erlang VM. This is to avoid the
infamous scheduler collapse issues.
The `jiffy:decode/2` now takes an option `{bytes_per_iter,
pos_integer()}` that controls the yield frequency. The default value is
2048.
Paul J. Davis [Thu, 12 Jun 2014 21:58:19 +0000 (16:58 -0500)]
Use a resource for the encoder structure
This is ground work to allow Jiffy to yield back to the scheduler.
Creating an encoder resource will allow for the necessary state to be
carried across NIF function invocations.
Paul J. Davis [Thu, 12 Jun 2014 19:46:01 +0000 (14:46 -0500)]
Use a resource for the decoder structure
This is ground work to allow Jiffy to yield back to the scheduler.
Creating a decoder resource will allow for the necessary state to be
carried across NIF function invocations.
Paul J. Davis [Thu, 12 Jun 2014 21:58:34 +0000 (16:58 -0500)]
Allow the use of GDB/LLDB for debugging
If the environment variable USE_GDB exists this plugin will pause
before the EUNIT tests so that you can attach a debugger to the VM.
Paul J. Davis [Fri, 13 Jun 2014 21:20:19 +0000 (16:20 -0500)]
Silence the dev marker command
Paul J. Davis [Thu, 12 Jun 2014 21:59:15 +0000 (16:59 -0500)]
Ignore erln8.config
Paul Guyot [Tue, 22 Apr 2014 10:07:53 +0000 (12:07 +0200)]
Noncharacters U+FFFF and U+FFFE are not invalid.
Properly decode them and accept to encode them.
This was clarified by Unicode Technical Committee:
http://www.unicode.org/versions/corrigendum9.html
Nobuhiro Iwamatsu [Tue, 2 Jul 2013 04:38:49 +0000 (13:38 +0900)]
Add check for below array bounds
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Nobuhiro Iwamatsu [Tue, 2 Jul 2013 03:45:55 +0000 (12:45 +0900)]
__GNUC__ is a better choice than __GCC__
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Nobuhiro Iwamatsu [Tue, 2 Jul 2013 04:05:54 +0000 (13:05 +0900)]
Fix typo in utils.h
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Paul J. Davis [Wed, 5 Jun 2013 15:02:30 +0000 (10:02 -0500)]
Prevent segfaults on unterminated strings
A single quote input was causing segfaults due to sneaking past the
string termination logic. This patch corrects that lapse in conditional
by only parsing strings where a closing quote was found. All other
strings are rejected as invalid.
Big thanks to Jean-Charles Campagne (@jccampagne) for reporting the
issue.
Paul J. Davis [Wed, 24 Apr 2013 20:27:59 +0000 (15:27 -0500)]
Fix compilation on GCC 4.8
Paul J. Davis [Fri, 29 Mar 2013 18:10:37 +0000 (13:10 -0500)]
Minor change for building on Windows
Paul J. Davis [Mon, 25 Feb 2013 05:01:19 +0000 (23:01 -0600)]
Turn on compiler optimizations
Because reasons.
Paul J. Davis [Mon, 25 Feb 2013 04:24:20 +0000 (22:24 -0600)]
Forgot to refactor the roundtrip tests
I removed some columns to try and minimize the amount of test data I'm
requiring and forgot to update the test code.
Paul J. Davis [Mon, 25 Feb 2013 04:11:54 +0000 (22:11 -0600)]
Add tests from double-conversion library
I pulled in a lot of tests from the double-conversion test suite to make
sure we don't accidentally break behavior in the future.
Paul J. Davis [Mon, 25 Feb 2013 04:10:27 +0000 (22:10 -0600)]
Bug fix for large doubles with a fraction
My truth table was a bit busted for extreme value doubles.
Paul J. Davis [Sun, 24 Feb 2013 21:10:33 +0000 (15:10 -0600)]
Check in the double-conversion dependency
While using rebar's dependency management was surprisingly easy it
broke apps that tried to build Jiffy as a dependency due to relative
path #includes.
This also fixes a few other issues. Most notably it removes the use of
the ECMAScript compatible encoding due to JSON's lack of support for +/-
Inf and NaN.
Volker Mische [Sun, 24 Feb 2013 15:34:48 +0000 (16:34 +0100)]
Encode floating point numbers as short as possible
Floating point numbers are no longer encoded as a one to one mapping
of their binary representation, but as short as possible (while still
being acurate). The double-conversion library [1] is used to do the
hard work.
The ECMAScript compatible conversion is used.
[1] https://code.google.com/p/double-conversion/
Paul J. Davis [Sun, 10 Feb 2013 22:00:52 +0000 (16:00 -0600)]
Remove some old cruft from rebar.config
I must've originally copied this config from Emonk.
Paul J. Davis [Mon, 21 Jan 2013 17:14:05 +0000 (11:14 -0600)]
No longer escape forward slashes
After a few requests and some reflection I've decided to stop escaping
forward slashes in strings while still accepting the escaped version
through the decoder. This appears to mimic the behavior of other popular
JSON libraries I've checked (Ruby and Python).
Paul J. Davis [Mon, 21 Jan 2013 17:08:54 +0000 (11:08 -0600)]
Remove stray while loop
Apparently I missed this when refactoring a do/while loop into a
standard while loop. It was a harmless extra invocation to check if the
stack was empty.
Dave Cottlehuber [Wed, 24 Oct 2012 14:13:52 +0000 (16:13 +0200)]
Adjust rebar.config to support rebar v2.0
- Include Windows preprocessor definitions that rebar is missing
- Minor changes to optimisation flags
Paul J. Davis [Mon, 29 Oct 2012 21:01:08 +0000 (16:01 -0500)]
Make PropEr a soft dependency
This prevents applications that depend on Jiffy from requiring PropEr as
a dependency just to run Jiffy's full test suite. If you want to run the
full test suite you'll have to run Jiffy's Makefile directly which
creates a `.jiffy.dev` marker that enables the full test suite.
Paul J. Davis [Tue, 23 Oct 2012 19:21:53 +0000 (14:21 -0500)]
Normalize whitespace in Makefile
Paul J. Davis [Tue, 23 Oct 2012 19:20:52 +0000 (14:20 -0500)]
Add PHONY targets for safety
Just trying to be a bit more thorough in the Makefile targets.
Paul J. Davis [Tue, 23 Oct 2012 19:18:49 +0000 (14:18 -0500)]
Add a distclean target for Make
This runs a `git clean -fxd` to revert to a pristine Git clone.
Paul J. Davis [Tue, 23 Oct 2012 19:15:44 +0000 (14:15 -0500)]
Use the Git protocol for PropEr
I've had reports that HTTPS seems to fail a bit more often than the Git
URLs. I've seen this before as well so I've gone ahead and switched
protocols for the clone.
Paul J. Davis [Thu, 7 Jun 2012 18:15:38 +0000 (13:15 -0500)]
Fix code reloading for Jiffy
As it turns out I did not understand the documenation for
load/upgrade/unload correctly. load/upgrade are called conditionally if
there's code in the VM for the NIF. Ie, no code means load is called,
where as if code exists, upgrade is called.
unload is called regardless once per load/unload. This means that
load/upgrade in Jiffy's case will each create a state object and unload
will free it each time. I was missing the fact that unload is called
every time and hence I don't need to clear the state in upgrade.
Paul J. Davis [Thu, 7 Jun 2012 00:24:53 +0000 (19:24 -0500)]
Be paranoid about the values sent to upgrade
The docs aren't entirely clear on the order of calls for upgrades so
this is mostly just in case old_priv ever happens to not be what load
returned in priv.
Paul J. Davis [Thu, 7 Jun 2012 00:18:11 +0000 (19:18 -0500)]
Fix hot code upgrades
Paul J. Davis [Tue, 5 Jun 2012 19:13:38 +0000 (14:13 -0500)]
Fix compiler warning for gcc 4.4.3
Paul J. Davis [Tue, 5 Jun 2012 19:13:28 +0000 (14:13 -0500)]
Update rebar to 2.0.0
Paul J. Davis [Fri, 1 Jun 2012 14:53:41 +0000 (09:53 -0500)]
Add an option to ignore UTF-8 encoding errors
By default Jiffy is quite strict in what it encodes. By default it will
not allow invalid UTF-8 to be produced. This can cause issues when
attempting to encode JSON that was decoded by other libraries as UTF-8
semantics are not uniformly enforced.
This patch adds an option 'force_utf8' to the encoder. If encoding hits
an error for an invalid string it will forcefully mutate the object to
contain only valid UTF-8 and return the resulting encoded JSON.
For the most part this means it will strip any garbage data from
binaries replacing it replacement codepoint U+FFFD. Although, it will
also try and the common error of encoding surrogate pairs as three-byte
sequences and reencode them into UTF-8 properly.
Benoit Chesneau [Fri, 20 Apr 2012 15:09:49 +0000 (17:09 +0200)]
Update rebar and the Makefile
* Update rebar to a more recent version
* Update rebar.config for deprecation warnings
* Allow people to export the REBAR environment variable to use
their own version of rebar
* Fixed `make clean`
Dave Cottlehuber [Sun, 8 Apr 2012 14:54:42 +0000 (10:54 -0400)]
Windows: MSVC compatibility
Paul J. Davis [Wed, 25 Apr 2012 19:13:12 +0000 (14:13 -0500)]
Fix segfaul when encoding with the uescape option
There was a bug that was resetting the extra amount of space needed when
encoding unicode characters with the `uescape` option enabled.
Paul J. Davis [Mon, 23 Apr 2012 18:05:40 +0000 (13:05 -0500)]
Cleanup Makefile
Paul J. Davis [Wed, 21 Mar 2012 23:10:50 +0000 (18:10 -0500)]
Fix silly error in the README
Paul J. Davis [Thu, 15 Mar 2012 22:33:15 +0000 (17:33 -0500)]
Fix uescapes for combining characters
I had a silly direction mistake in a bit shift that was causing the high
portion of all combining characters to be printed as \uD800 which is
obviously wrong. This bug only affects people using the non-default
uescape option during encoding.
Paul J. Davis [Sat, 25 Feb 2012 16:39:32 +0000 (10:39 -0600)]
Updated rebar to latest master
Paul J. Davis [Sun, 12 Feb 2012 17:27:55 +0000 (11:27 -0600)]
Ensure that encoded doubles have a decimal point
Numbers like 1.0 were being encoded as <<"1">> which can lead to a bit
of confusion. This merely checks if a decimial point exists and if not
it appends ".0" to the value.
Paul J. Davis [Tue, 10 Jan 2012 16:28:07 +0000 (10:28 -0600)]
Allow iolists to be passed directly to decode/1
Fixes #15
Sergey Urbanovich [Sun, 11 Dec 2011 14:11:56 +0000 (18:11 +0400)]
Add pretty print
jiffy:encode/2 now accepts a 'pretty' option that will format the JSON
output using two-space indents.
Paul J. Davis [Sun, 8 Jan 2012 22:07:39 +0000 (16:07 -0600)]
Reduce PropEr test size for speed
I need to fix this so that object sizes don't explode when generating
larger values. Basically, as the type generator recurses is should be
adjusting the size value.
Jeremy Raymond [Fri, 6 Jan 2012 18:17:21 +0000 (13:17 -0500)]
Avoid false dialyzer warnings by using erlang:nif_error/1
benoitc [Tue, 3 Jan 2012 22:54:21 +0000 (23:54 +0100)]
clean test/*.beam
Paul J. Davis [Sun, 8 Jan 2012 20:59:48 +0000 (14:59 -0600)]
Adjust number ranges to show bignum support
Looks like there's a slight difference in the number of significant
digits supported across platforms in strtod. This just adds a couple to
force it into the bignum code.
Paul J. Davis [Sun, 8 Jan 2012 20:43:47 +0000 (14:43 -0600)]
Limit test case in the interest of speed