2010-03-26 04:32:53 +00:00
|
|
|
-module({{module}}).
|
|
|
|
|
|
|
|
-export([new/0,
|
|
|
|
myfunction/1]).
|
|
|
|
|
|
|
|
-on_load(init/0).
|
|
|
|
|
2011-07-17 16:38:33 +00:00
|
|
|
-define(nif_stub, nif_stub_error(?LINE)).
|
|
|
|
nif_stub_error(Line) ->
|
|
|
|
erlang:nif_error({nif_not_loaded,module,?MODULE,line,Line}).
|
|
|
|
|
2010-03-26 04:32:53 +00:00
|
|
|
-ifdef(TEST).
|
|
|
|
-include_lib("eunit/include/eunit.hrl").
|
|
|
|
-endif.
|
|
|
|
|
|
|
|
init() ->
|
2011-07-17 16:38:33 +00:00
|
|
|
PrivDir = case code:priv_dir(?MODULE) of
|
|
|
|
{error, bad_name} ->
|
|
|
|
EbinDir = filename:dirname(code:which(?MODULE)),
|
|
|
|
AppPath = filename:dirname(EbinDir),
|
|
|
|
filename:join(AppPath, "priv");
|
|
|
|
Path ->
|
|
|
|
Path
|
|
|
|
end,
|
|
|
|
erlang:load_nif(filename:join(PrivDir, ?MODULE), 0).
|
2010-03-26 04:32:53 +00:00
|
|
|
|
|
|
|
new() ->
|
2011-07-17 16:38:33 +00:00
|
|
|
?nif_stub.
|
2010-03-26 04:32:53 +00:00
|
|
|
|
|
|
|
myfunction(Ref) ->
|
2011-07-17 16:38:33 +00:00
|
|
|
?nif_stub.
|
2010-03-26 04:32:53 +00:00
|
|
|
|
|
|
|
%% ===================================================================
|
|
|
|
%% EUnit tests
|
|
|
|
%% ===================================================================
|
|
|
|
-ifdef(TEST).
|
|
|
|
|
|
|
|
basic_test() ->
|
|
|
|
{ok, Ref} = new(),
|
2011-07-17 16:38:33 +00:00
|
|
|
?assertEqual(ok, myfunction(Ref)).
|
2010-03-26 04:32:53 +00:00
|
|
|
|
|
|
|
-endif.
|