-
-
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
68 additions
and
6 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,44 @@ | ||
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[] = Base.require(Random_PkgID) | ||
end | ||
return ccall(:jl_module_world, Csize_t, (Any,), RANDOM_MODULE_REF[]) | ||
end | ||
end | ||
|
||
import Base: rand, randn | ||
function rand(args...) | ||
Base.invoke_in_world(delay_initialize(), rand, args...) | ||
end | ||
|
||
function randn(args...) | ||
Base.invoke_in_world(delay_initialize(), randn, args...) | ||
end | ||
end | ||
|
||
Base.Docs.getdoc(::typeof(Base.rand)) = (Random.delay_initialize(); nothing) | ||
Base.Docs.getdoc(::typeof(Base.randn)) = (Random.delay_initialize(); nothing) | ||
|
||
function delete_stubs(mod) | ||
for name in names(mod, imported=true) | ||
if name == :delay_initialize | ||
continue | ||
end | ||
obj = getglobal(mod, 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