-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathA01$libSetReplace.m
More file actions
60 lines (48 loc) · 1.94 KB
/
Copy pathA01$libSetReplace.m
File metadata and controls
60 lines (48 loc) · 1.94 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Package["SetReplace`"]
PackageImport["GeneralUtilities`"]
PackageScope["$libSetReplaceAvailable"]
PackageScope["unloadLibrary"]
PackageScope["importLibSetReplaceFunction"]
(* All functions loaded from C++ should go in this file. This is the counterpart of libSetReplace/SetReplace.hpp *)
(* this function is defined now, but only run the *next* time Kernel/init.m is called, before all symbols
are cleared. *)
unloadLibrary[] := If[StringQ[$libraryFile],
Scan[LibraryFunctionUnload, $libraryFunctions];
$libraryFunctions = Null;
Quiet @ LibraryUnload[$libraryFile];
];
SetReplace::nolibsetreplace = "libSetReplace (``) could not be found, some functionality will not be available.";
$libraryFile = $SetReplaceLibraryPath;
If[!StringQ[$libraryFile] || !FileExistsQ[$libraryFile],
Message[SetReplace::nolibsetreplace, $libraryFile];
$libraryFile = $Failed;
];
$libraryFunctions = {};
$cppRedistributableURL =
"https://support.microsoft.com/en-us/topic/" <>
"the-latest-supported-visual-c-downloads-2647da03-1eea-4433-9aff-95f26a218cc0";
SetReplace::cppRedistributable =
"Check that " <>
"\!\(\*TemplateBox[" <>
"{\"Microsoft Visual C++ Redistributable\", " <>
"{URL[\"" <> $cppRedistributableURL <> "\"], None}, " <>
"\"" <> $cppRedistributableURL <> "\", " <>
"\"HyperlinkActionRecycled\", " <>
"{\"HyperlinkActive\"}, " <>
"BaseStyle -> {\"URL\"}, " <>
"HyperlinkAction -> \"Recycled\"}, " <>
"\"HyperlinkTemplate\"]\)" <>
" is installed.";
importLibSetReplaceFunction[cppFunctionName_ -> symbol_, argumentTypes_, outputType_] := (
symbol = If[$libraryFile =!= $Failed,
Check[
LibraryFunctionLoad[$libraryFile, cppFunctionName, argumentTypes, outputType],
If[$SystemID === "Windows-x86-64", Message[SetReplace::cppRedistributable]]; $Failed,
{LibraryFunction::libload}
]
,
$Failed
];
AppendTo[$libraryFunctions, symbol];
);
$libSetReplaceAvailable := FreeQ[$libraryFunctions, $Failed];