couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [40/54] jiffy commit: updated refs/heads/master to ef77de4
Date Tue, 28 Jul 2015 22:43:05 GMT
Add Dialyzer types and specs

Thanks to @joedevivo for the contribution.

Fixes #85


Project: http://git-wip-us.apache.org/repos/asf/couchdb-jiffy/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-jiffy/commit/e371ec10
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-jiffy/tree/e371ec10
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-jiffy/diff/e371ec10

Branch: refs/heads/master
Commit: e371ec1075266240ec88a744cda036e8fddefd1c
Parents: 43d9516
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Wed Jul 15 15:45:23 2015 -0500
Committer: Paul J. Davis <paul.joseph.davis@gmail.com>
Committed: Wed Jul 15 15:45:23 2015 -0500

----------------------------------------------------------------------
 src/jiffy.erl | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-jiffy/blob/e371ec10/src/jiffy.erl
----------------------------------------------------------------------
diff --git a/src/jiffy.erl b/src/jiffy.erl
index 23a0c9d..39c3aeb 100644
--- a/src/jiffy.erl
+++ b/src/jiffy.erl
@@ -8,10 +8,42 @@
 -on_load(init/0).
 
 
+-type json_value() :: null
+                    | true
+                    | false
+                    | json_string()
+                    | json_number()
+                    | json_object()
+                    | json_array().
+
+-type json_array()  :: [json_value()].
+-type json_string() :: binary().
+-type json_number() :: integer() | float().
+-type json_object() :: {[{json_string(),json_value()}]}.
+
+-type decode_option() :: return_maps
+                        | use_nil
+                        | {null_term, any()}
+                        | {bytes_per_iter, non_neg_integer()}.
+
+-type encode_option() :: uescape
+                        | pretty
+                        | force_utf8
+                        | escape_forward_slashes
+                        | {bytes_per_iter, non_neg_integer()}.
+
+-type decode_options() :: [decode_option()].
+-type encode_options() :: [encode_option()].
+
+-export_type([json_value/0]).
+
+
+-spec decode(iolist() | binary()) -> json_value().
 decode(Data) ->
     decode(Data, []).
 
 
+-spec decode(iolist() | binary(), decode_options()) -> json_value().
 decode(Data, Opts) when is_binary(Data), is_list(Opts) ->
     case nif_decode_init(Data, Opts) of
         {error, _} = Error ->
@@ -27,10 +59,12 @@ decode(Data, Opts) when is_list(Data) ->
     decode(iolist_to_binary(Data), Opts).
 
 
+-spec encode(json_value()) -> iolist().
 encode(Data) ->
     encode(Data, []).
 
 
+-spec encode(json_value(), encode_options()) -> iolist().
 encode(Data, Options) ->
     ForceUTF8 = lists:member(force_utf8, Options),
     case nif_encode_init(Data, Options) of


Mime
View raw message