Skip to content

Commit

Permalink
Merge pull request #15 from matwey/export_type
Browse files Browse the repository at this point in the history
Make rfc4627.erl more dialyzer friendly
  • Loading branch information
tonyg committed Jul 23, 2013
2 parents 5e67120 + 02f788a commit a961af4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Makefile
Expand Up @@ -5,7 +5,7 @@ INCLUDE_DIR=include
INCLUDES=$(wildcard $(INCLUDE_DIR)/*.hrl)
SOURCES=$(wildcard $(SOURCE_DIR)/*.erl)
TARGETS=$(patsubst $(SOURCE_DIR)/%.erl, $(EBIN_DIR)/%.beam,$(SOURCES))
ERLC_OPTS=-I $(INCLUDE_DIR) -o $(EBIN_DIR) $(INETS_DEF) -Wall +debug_info # +native -v
ERLC_OPTS=-I $(INCLUDE_DIR) -o $(EBIN_DIR) $(INETS_DEF) -Wall +debug_info $(if $(filter true,$(USE_SPECS)),-Duse_specs) # +native -v
DIST_DIR=dist
SIGNING_KEY_ID=F8D7D525
VERSION=HEAD
Expand All @@ -30,6 +30,11 @@ INETS_DEF=
endif
endif

ifndef USE_SPECS
# let use specs in sync with rabbitmq (starting from R15B)
USE_SPECS:=$(shell erl -noshell -eval 'io:format([list_to_integer(X) || X <- string:tokens(erlang:system_info(version), ".")] >= [5,9]), halt().')
endif

all: $(TARGETS)

$(EBIN_DIR)/%.beam: $(SOURCE_DIR)/%.erl $(INCLUDES)
Expand Down
11 changes: 11 additions & 0 deletions src/rfc4627.erl
Expand Up @@ -89,6 +89,17 @@

-module(rfc4627).

-ifdef(use_specs).
-type json() :: jsonobj() | jsonarray() | jsonnum() | jsonstr() | true | false | null.
-type jsonobj() :: {obj, [{jsonkey(), json()}]}.
-type jsonkey() :: string().
-type jsonarray() :: [json()].
-type jsonnum() :: integer() | float().
-type jsonstr() :: binary().

-export_type([json/0,jsonobj/0,jsonkey/0,jsonarray/0,jsonnum/0,jsonstr/0]).
-endif. % use_specs

-export([mime_type/0, encode/1, decode/1]).
-export([encode_noauto/1, encode_noauto/2, decode_noauto/1]).
-export([unicode_decode/1, unicode_encode/1]).
Expand Down

0 comments on commit a961af4

Please sign in to comment.