You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 line
1007 B

  1. -module({{module}}).
  2. -export([new/0,
  3. myfunction/1]).
  4. -on_load(init/0).
  5. -define(nif_stub, nif_stub_error(?LINE)).
  6. nif_stub_error(Line) ->
  7. erlang:nif_error({nif_not_loaded,module,?MODULE,line,Line}).
  8. -ifdef(TEST).
  9. -include_lib("eunit/include/eunit.hrl").
  10. -endif.
  11. init() ->
  12. PrivDir = case code:priv_dir(?MODULE) of
  13. {error, bad_name} ->
  14. EbinDir = filename:dirname(code:which(?MODULE)),
  15. AppPath = filename:dirname(EbinDir),
  16. filename:join(AppPath, "priv");
  17. Path ->
  18. Path
  19. end,
  20. erlang:load_nif(filename:join(PrivDir, ?MODULE), 0).
  21. new() ->
  22. ?nif_stub.
  23. myfunction(_Ref) ->
  24. ?nif_stub.
  25. %% ===================================================================
  26. %% EUnit tests
  27. %% ===================================================================
  28. -ifdef(TEST).
  29. basic_test() ->
  30. {ok, Ref} = new(),
  31. ?assertEqual(ok, myfunction(Ref)).
  32. -endif.