File tree Expand file tree Collapse file tree 2 files changed +56
-10
lines changed
Expand file tree Collapse file tree 2 files changed +56
-10
lines changed Original file line number Diff line number Diff line change @@ -10,18 +10,30 @@ function isModuleDefined(names)
1010 return true
1111end
1212
13+ # function ensureModuleDefined(namespace)
14+ # # ensure the module is defined, and return the module
15+ # # 1. split with /
16+ # names = split(namespace, "/", keepempty=false)
17+ # mod = :(Main)
18+ # for name in names
19+ # name = Symbol(name)
20+ # if !isdefined(eval(mod), name)
21+ # include_string(eval(mod), "module $name using Reexport end")
22+ # end
23+ # mod = :($mod.$name)
24+ # end
25+ # return mod, eval(mod)
26+ # end
27+
28+
1329function ensureModuleDefined (namespace)
14- # ensure the module is defined, and return the module
15- # 1. split with /
16- names = split (namespace, " /" , keepempty= false )
17- mod = :(Main)
18- for name in names
19- name = Symbol (name)
20- if ! isdefined (eval (mod), name)
21- include_string (eval (mod), " module $name using Reexport end" )
22- end
23- mod = :($ mod.$ name)
30+ if ! isdefined (eval (:Main ), Symbol (namespace))
31+ expr = :(module $ (Symbol (namespace))
32+ using Reexport
33+ end )
34+ eval (expr)
2435 end
36+ mod = :($ (:Main ). $ (Symbol (namespace)))
2537 return mod, eval (mod)
2638end
2739
Original file line number Diff line number Diff line change @@ -189,6 +189,40 @@ ${nses
189189 ${ names . length > 0 ? `export ${ names . join ( "," ) } ` : "" }
190190
191191 ` ;
192+
193+ // FIXME optimize this logic. Probably construct several CODEPOD_ADD_IMPORT here
194+ code = `
195+ ${ nses . map (
196+ ( ns ) => `
197+ include_string(eval(:($(:Main).$(Symbol("${ pod . ns } ")))), "using $(:($(:Main).$(Symbol("${ ns } "))))")`
198+ ) }
199+ ${ exported_decks . map (
200+ ( ns ) => `
201+ include_string(eval(:($(:Main).$(Symbol("${ pod . ns } ")))), "@reexport using $(:($(:Main).$(Symbol("${ ns } "))))")`
202+ ) }
203+
204+ ${ names . length > 0 ? `export ${ names . join ( "," ) } ` : "" }
205+ ` ;
206+
207+ // DEBUG Much better!!!
208+ code = `
209+ ${ nses
210+ . map (
211+ ( ns ) => `
212+ eval(:(using $(:Main).$(Symbol("${ ns } "))))
213+ `
214+ )
215+ . join ( "\n" ) }
216+ ${ exported_decks
217+ . map (
218+ ( ns ) => `
219+ eval(:(@reexport using $(:Main).$(Symbol("${ ns } "))))
220+ `
221+ )
222+ . join ( "\n" ) }
223+
224+ ${ names . length > 0 ? `export ${ names . join ( "," ) } ` : "" }
225+ ` ;
192226 // console.log("code:", code);
193227 // ${struct_names.map((name) => `(struct ${name} ())`) }
194228
You can’t perform that action at this time.
0 commit comments