From 3c6b1ddaf567226672fd057e0e6af4256133e422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Fri, 25 Jan 2013 02:56:34 +0100 Subject: [PATCH] Use erlang:nif_error to make dialyzer happy And mark some of the NIF functions --- src/geef.erl | 9 +++++++-- src/geef_records.hlr | 4 +++- src/geef_repo.erl | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/geef.erl b/src/geef.erl index cae42b9..485053f 100644 --- a/src/geef.erl +++ b/src/geef.erl @@ -13,23 +13,28 @@ -on_load(load_enif/0). hex_to_raw(_Val) -> - nif_error(?LINE). + nif_error(?LINE). +-spec repository_open(iolist()) -> {ok, term()} | {error, term()}. repository_open(_Val) -> nif_error(?LINE). +-spec repository_is_bare(term()) -> boolean(). repository_is_bare(_Handle) -> nif_error(?LINE). +-spec repository_get_path(term()) -> binary(). repository_get_path(_Val) -> nif_error(?LINE). +-spec repository_get_workdir(term()) -> binary(). repository_get_workdir(_Handle) -> nif_error(?LINE). repository_get_odb(_Val) -> nif_error(?LINE). +-spec repository_init(iolist(), boolean()) -> term(). repository_init(_Path, _Bare) -> nif_error(?LINE). @@ -64,7 +69,7 @@ oid_parse(_Sha) -> nif_error(?LINE). nif_error(Line) -> - exit({nif_not_loaded,module,?MODULE,line,Line}). + erlang:nif_error({nif_not_loaded,module,?MODULE,line,Line}). load_enif() -> case code:priv_dir(geef) of diff --git a/src/geef_records.hlr b/src/geef_records.hlr index 6226336..f462633 100644 --- a/src/geef_records.hlr +++ b/src/geef_records.hlr @@ -1,3 +1,5 @@ --record(ref, {handle, type}). +-record(ref, {handle, type :: atom()}). -record(repo, {handle}). -record(odb, {handle}). + +-type repo() :: repo. diff --git a/src/geef_repo.erl b/src/geef_repo.erl index d903dcc..2315b1d 100644 --- a/src/geef_repo.erl +++ b/src/geef_repo.erl @@ -25,7 +25,7 @@ open(Path) -> Other end. --spec init(iolist(), boolean()) -> {ok, term()} | {error, term()}. +-spec init(iolist(), boolean()) -> {ok, repo()} | {error, term()}. init(Path, Bare) -> case geef:repository_init(Path, Bare) of {ok, Handle} ->