|
91 | 91 | / @see .require.i.load |
92 | 92 | / @see .require.i.init |
93 | 93 | .require.libForce:{[lib] |
94 | | - if[lib in key .require.loadedLibs; |
95 | | - libInfo:.require.loadedLibs lib; |
| 94 | + libInfo:.require.loadedLibs lib; |
| 95 | + |
| 96 | + operations:lib,/:libInfo`loaded`inited; |
96 | 97 |
|
| 98 | + if[libInfo`loaded; |
97 | 99 | .log.if.info ("Force reloading library [ Library: {} ] [ Already Loaded: {} ] [ Already Initialised: {} ]"; lib; `no`yes libInfo`loaded; `no`yes libInfo`inited); |
98 | 100 | ]; |
99 | 101 |
|
100 | | - .require.i[`load`init] .\: (lib; 1b); |
| 102 | + .require.i[`load`init] .' operations; |
101 | 103 | }; |
102 | 104 |
|
103 | 105 | .require.rescanRoot:{ |
|
164 | 166 | / .*lib*.*stack*.init[] and executes if exists (if not present, ignored). |
165 | 167 | / @throws UnknownLibraryException If the library is not loaded |
166 | 168 | / @throws LibraryInitFailedException If the init function throws an exception |
167 | | -.require.i.init:{[lib; force] |
| 169 | +/ @throws RequireReinitialiseAssertionError If 'reinit' is set to false, but the library is already initialised - this should not happen |
| 170 | +.require.i.init:{[lib; reinit] |
168 | 171 | if[not lib in key .require.loadedLibs; |
169 | 172 | '"UnknownLibraryException"; |
170 | 173 | ]; |
171 | 174 |
|
| 175 | + if[not[reinit] & .require.loadedLibs[lib]`inited; |
| 176 | + '"RequireReinitialiseAssertionError"; |
| 177 | + ]; |
| 178 | + |
172 | 179 | initFname:` sv `,lib,`init; |
173 | 180 | initF:@[get;initFname;`NO_INIT_FUNC]; |
174 | | - initArgs:enlist[`force]!enlist force; |
| 181 | + initArgs:enlist[`reinit]!enlist reinit; |
175 | 182 |
|
176 | 183 | if[not `NO_INIT_FUNC~initF; |
177 | 184 | .log.if.info "Library initialisation function detected [ Func: ",string[initFname]," ]"; |
|
188 | 195 | '"LibraryInitFailedException (",string[initFname],")"; |
189 | 196 | ]; |
190 | 197 |
|
191 | | - .require.markLibAsInited[lib; force]; |
| 198 | + .require.markLibAsInited[lib; reinit]; |
192 | 199 |
|
193 | 200 | .log.if.info "Initialised library: ",string lib; |
194 | 201 | ]; |
|
0 commit comments