-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
78 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
module Stubs | ||
|
||
module Random | ||
let Random_PkgID = Base.PkgId(Base.UUID(0x9a3f8284_a2c9_5f02_9a11_845980a1fd5c), "Random") | ||
RANDOM_MODULE_REF = Ref{Module}() | ||
|
||
global delay_initialize | ||
function delay_initialize() | ||
if !isassigned(RANDOM_MODULE_REF) | ||
RANDOM_MODULE_REF[] = require(Random_PkgID) | ||
end | ||
return ccall(:jl_module_world, Csize_t, (Any,), RANDOM_MODULE_REF[]) | ||
end | ||
end | ||
|
||
function Base.rand(args...) | ||
Base.invoke_in_world(delay_initialize(), rand, args...) | ||
end | ||
|
||
function Base.randn(args...) | ||
Base.invoke_in_world(delay_initialize(), rand, args...) | ||
end | ||
end | ||
|
||
function delete_stubs(mod) | ||
for name in names(mod) | ||
if name == :delay_initialize | ||
continue | ||
end | ||
obj = getglobal(Base.Stubs.Randomod, name) | ||
if obj isa Function | ||
ms = Base.methods(obj, mod) | ||
for m in ms | ||
Base.delete_method(m) | ||
end | ||
end | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters