diff options
Diffstat (limited to 'priv/templates/basicnif.erl')
-rw-r--r-- | priv/templates/basicnif.erl | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/priv/templates/basicnif.erl b/priv/templates/basicnif.erl new file mode 100644 index 0000000..5f1ce11 --- /dev/null +++ b/priv/templates/basicnif.erl @@ -0,0 +1,36 @@ +-module({{module}}). + +-export([new/0, + myfunction/1]). + +-on_load(init/0). + +-ifdef(TEST). +-include_lib("eunit/include/eunit.hrl"). +-endif. + +init() -> + case code:priv_dir({{module}}) of + {error, bad_name} -> + SoName = filename:join("../priv", {{module}}); + Dir -> + SoName = filename:join(Dir, {{module}}) + end, + erlang:load_nif(SoName, 0). + +new() -> + "NIF library not loaded". + +myfunction(Ref) -> + "NIF library not loaded". + +%% =================================================================== +%% EUnit tests +%% =================================================================== +-ifdef(TEST). + +basic_test() -> + {ok, Ref} = new(), + ok = myfunction(Ref). + +-endif. |