Revert "Master"

This commit is contained in:
alisdair sullivan 2015-08-04 10:18:06 -07:00
parent 0bba0df858
commit 400d046746
6 changed files with 16 additions and 39 deletions

2
.gitignore vendored
View file

@ -6,5 +6,3 @@ ebin
*.plt
erl_crash.dump
.DS_Store
doc
.rebar

View file

@ -1,5 +1,6 @@
{erl_opts, [
% uncomment to always decode to maps
% {d, maps_always},
]}.
{edoc_opts, [{preprocess, true}]}.
{platform_define, "R14|R15", 'no_binary_to_whatever'},
{platform_define, "^((?!R1[456]).)*$", 'maps_support'}
]}.

View file

@ -1,11 +0,0 @@
Def0 = case erlang:is_builtin(erlang, binary_to_integer, 1) andalso
erlang:is_builtin(erlang, binary_to_float, 1) of
true -> [];
false -> [{d, no_binary_to_whatever}]
end,
Defs = case erlang:is_builtin(erlang, is_map, 1) of
true -> [{d, maps_support}|Def0];
false -> Def0
end,
lists:keystore(erl_opts, 1, CONFIG,
{erl_opts, proplists:get_value(erl_opts, CONFIG, []) ++ Defs}).

View file

@ -67,29 +67,23 @@
-type config() :: jsx_config:config().
-spec encode(Source::json_term()) -> json_text().
encode(Source) -> encode(Source, []).
-spec encode(Source::json_term(), Config::jsx_to_json:config()) -> json_text() | {incomplete, encoder()}.
encode(Source) -> encode(Source, []).
encode(Source, Config) -> jsx_to_json:to_json(Source, Config).
-spec decode(Source::json_text()) -> json_term().
-spec decode(Source::json_text(), Config::jsx_to_term:config()) -> json_term() | {incomplete, decoder()}.
decode(Source) -> decode(Source, []).
-spec decode(Source::json_text(), Config::jsx_to_term:config()) -> json_term() | {incomplete, decoder()}.
decode(Source, Config) -> jsx_to_term:to_term(Source, Config).
-spec format(Source::json_text()) -> json_text().
format(Source) -> format(Source, []).
-spec format(Source::json_text(), Config::jsx_to_json:config()) -> json_text() | {incomplete, decoder()}.
format(Source) -> format(Source, []).
format(Source, Config) -> jsx_to_json:format(Source, Config).
@ -103,30 +97,24 @@ minify(Source) -> format(Source, []).
prettify(Source) -> format(Source, [space, {indent, 2}]).
-spec is_json(Source::any()) -> boolean().
-spec is_json(Source::any()) -> true | false.
-spec is_json(Source::any(), Config::jsx_verify:config()) -> true | false | {incomplete, decoder()}.
is_json(Source) -> is_json(Source, []).
-spec is_json(Source::any(), Config::jsx_verify:config()) -> boolean() | {incomplete, decoder()}.
is_json(Source, Config) -> jsx_verify:is_json(Source, Config).
-spec is_term(Source::any()) -> boolean().
-spec is_term(Source::any()) -> true | false.
-spec is_term(Source::any(), Config::jsx_verify:config()) -> true | false | {incomplete, encoder()}.
is_term(Source) -> is_term(Source, []).
-spec is_term(Source::any(), Config::jsx_verify:config()) -> boolean() | {incomplete, encoder()}.
is_term(Source, Config) -> jsx_verify:is_term(Source, Config).
-spec consult(File::file:name_all()) -> list(json_term()).
consult(File) -> consult(File, []).
-spec consult(File::file:name_all(), Config::jsx_to_term:config()) -> list(json_term()).
consult(File) -> consult(File, []).
consult(File, Config) -> jsx_consult:consult(File, Config).
@ -182,7 +170,7 @@ resume(Term, {parser, State, Handler, Stack}, Config) ->
jsx_parser:resume(Term, State, Handler, Stack, jsx_config:parse_config(Config)).
-spec maps_support() -> boolean().
-spec maps_support() -> true | false.
-ifndef(maps_support).
maps_support() -> false.

View file

@ -58,6 +58,8 @@
-endif.
-spec consult(File::file:name_all(), Config::config()) -> [json_value()].
-ifdef(maps_always).
opts(Opts) -> [return_maps, multi_term] ++ Opts.
-endif.
@ -65,8 +67,6 @@ opts(Opts) -> [return_maps, multi_term] ++ Opts.
opts(Opts) -> [multi_term] ++ Opts.
-endif.
-spec consult(File::file:name_all(), Config::config()) -> [json_value()].
consult(File, Config) when is_list(Config) ->
case file:read_file(File) of
{ok, Bin} ->

View file

@ -1010,7 +1010,8 @@ finish_number(Rest, Handler, Acc, Stack, Config) ->
-ifndef(no_binary_to_whatever).
format_number({integer, Acc}) -> {integer, binary_to_integer(Acc)};
format_number({float, Acc}) -> {float, binary_to_float(Acc)}.
-else.
-endif.
-ifdef(no_binary_to_whatever).
format_number({integer, Acc}) -> {integer, list_to_integer(unicode:characters_to_list(Acc))};
format_number({float, Acc}) -> {float, list_to_float(unicode:characters_to_list(Acc))}.
-endif.