summaryrefslogtreecommitdiff
path: root/priv/templates/basicnif.erl
blob: 5f1ce11a688a5be45d679ba10bc712db90431345 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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.