Hi,
I am looking for a way to generate a module using a type which is not imported in the generated module, meaning i need the full path to the type.
How can i get this done?
Here is an example:
module DF
is_module(a) = false
is_module(e::Expr) = e.head == :module
make_top_level(e::Expr) =
if e.head == :block && any( is_module.(e.args) )
Expr(:toplevel, e.args...)
elseif e.head == :block
Expr(:block, make_top_level.(e.args)...)
else
e
end
end
struct MM
x::Int
end
macro cm(amod,typ)
esc(make_top_level(quote
module $amod
export mms
struct mms
x::$typ
end
end
end))
end
@cm ESS MM
end
the generated code is as follows:
:($(Expr(:toplevel, :( # REPL[5], line 3:), :(module ESS # REPL[5], line 3: # REPL[5], line 4:
export mms # REPL[5], line 5:
struct mms # REPL[5], line 6:
x::MM
end
end))))
However i want it to be like
:($(Expr(:toplevel, :( # REPL[5], line 3:), :(module ESS # REPL[5], line 3: # REPL[5], line 4:
export mms # REPL[5], line 5:
struct mms # REPL[5], line 6:
x::DF.MM
end
end))))
Thanks