Skip to content

Commit 8b86a28

Browse files
committed
move load/unload stuff to private functions
* PKG_ADD, PKG_DEL: remove script body and call provate function * private/sqlite_pkg_add.m, private/sqlite_pkg_del.m: new file
1 parent 5c9c096 commit 8b86a28

File tree

4 files changed

+92
-28
lines changed

4 files changed

+92
-28
lines changed

inst/PKG_ADD

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
# on package load, attempt to load docs
2-
try
3-
pkg_dir = fileparts (fullfile (mfilename ("fullpath")));
4-
doc_file = fullfile (pkg_dir, "doc", "octave-aqlite.qch");
5-
if exist(doc_file, "file")
6-
if exist("__event_manager_register_documentation__")
7-
__event_manager_register_documentation__ (doc_file);
8-
elseif exist("__event_manager_register_doc__")
9-
__event_manager_register_doc__ (doc_file);
10-
endif
11-
endif
12-
catch
13-
# do nothing
14-
end_try_catch
1+
# on package load, call private add
2+
3+
sqlite_pkg_add();

inst/PKG_DEL

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,2 @@
1-
# on package unload, attempt to unload docs
2-
try
3-
pkg_dir = fileparts (fullfile (mfilename ("fullpath")));
4-
doc_file = fullfile (pkg_dir, "doc", "octave-sqlite.qch");
5-
if exist(doc_file, "file")
6-
if exist("__event_manager_unregister_documentation__")
7-
__event_manager_unregister_documentation__ (doc_file);
8-
elseif exist("__event_manager_unregister_doc__")
9-
__event_manager_unregister_doc__ (doc_file);
10-
endif
11-
endif
12-
catch
13-
# do nothing
14-
end_try_catch
1+
# on unload, call private del
2+
sqlite_pkg_del ();

inst/private/sqlite_pkg_add.m

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
## Copyright (C) 2022 John Donoghue <john.donoghue@ieee.org>
2+
##
3+
## This program is free software: you can redistribute it and/or modify it
4+
## under the terms of the GNU General Public License as published by
5+
## the Free Software Foundation, either version 3 of the License, or
6+
## (at your option) any later version.
7+
##
8+
## This program is distributed in the hope that it will be useful, but
9+
## WITHOUT ANY WARRANTY; without even the implied warranty of
10+
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
## GNU General Public License for more details.
12+
##
13+
## You should have received a copy of the GNU General Public License
14+
## along with this program. If not, see
15+
## <https://www.gnu.org/licenses/>.
16+
17+
## -*- texinfo -*-
18+
## @deftypefn {} {} sqlite_pkg_add()
19+
## private function
20+
## @end deftypefn
21+
function sqlite_pkg_add ()
22+
# on package load, attempt to load docs
23+
try
24+
pkg_dir = fileparts (fullfile (mfilename ("fullpath")));
25+
doc_file = fullfile (pkg_dir, "..", "doc", "octave-aqlite.qch");
26+
if exist(doc_file, "file")
27+
if exist("__event_manager_register_documentation__")
28+
__event_manager_register_documentation__ (doc_file);
29+
elseif exist("__event_manager_register_doc__")
30+
__event_manager_register_doc__ (doc_file);
31+
endif
32+
endif
33+
catch
34+
# do nothing
35+
end_try_catch
36+
37+
# if table type exists, use it, otherwise use dbtable
38+
if exist ("table") == 0
39+
assignin("base", "table", @dbtable);
40+
endif
41+
42+
endfunction

inst/private/sqlite_pkg_del.m

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
## Copyright (C) 2022 John Donoghue <john.donoghue@ieee.org>
2+
##
3+
## This program is free software: you can redistribute it and/or modify it
4+
## under the terms of the GNU General Public License as published by
5+
## the Free Software Foundation, either version 3 of the License, or
6+
## (at your option) any later version.
7+
##
8+
## This program is distributed in the hope that it will be useful, but
9+
## WITHOUT ANY WARRANTY; without even the implied warranty of
10+
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
## GNU General Public License for more details.
12+
##
13+
## You should have received a copy of the GNU General Public License
14+
## along with this program. If not, see
15+
## <https://www.gnu.org/licenses/>.
16+
17+
## -*- texinfo -*-
18+
## @deftypefn {} {} sqlite_pkg_del()
19+
## private function
20+
## @end deftypefn
21+
function sqlite_pkg_del ()
22+
23+
# on package unload, attempt to unload docs
24+
try
25+
pkg_dir = fileparts (fullfile (mfilename ("fullpath")));
26+
doc_file = fullfile (pkg_dir, "..", "doc", "octave-sqlite.qch");
27+
if exist(doc_file, "file")
28+
if exist("__event_manager_unregister_documentation__")
29+
__event_manager_unregister_documentation__ (doc_file);
30+
elseif exist("__event_manager_unregister_doc__")
31+
__event_manager_unregister_doc__ (doc_file);
32+
endif
33+
endif
34+
catch
35+
# do nothing
36+
end_try_catch
37+
38+
try
39+
if exist ("table") == 1 && (table == @dbtable)
40+
evalin("base", "clear table");
41+
endif
42+
catch
43+
# do nothing
44+
end_try_catch
45+
endfunction

0 commit comments

Comments
 (0)