From 2045a1670acd046d97a09fc0dc57f1bd0986c85c Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Thu, 6 Sep 2018 03:39:10 +0000 Subject: [PATCH] temporarily not using {-# SOURCE #-} pragma for *.Template in the same module when importing them in *.Interface. --- fficxx/lib/FFICXX/Generate/Builder.hs | 1 + fficxx/lib/FFICXX/Generate/Code/HsFrontEnd.hs | 20 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/fficxx/lib/FFICXX/Generate/Builder.hs b/fficxx/lib/FFICXX/Generate/Builder.hs index 2c4460ca..18920fa2 100644 --- a/fficxx/lib/FFICXX/Generate/Builder.hs +++ b/fficxx/lib/FFICXX/Generate/Builder.hs @@ -124,6 +124,7 @@ simpleBuilder topLevelMod mumap (cabal,classes,toplevelfunctions,templates) extr -- + -- TODO: Template.hs-boot need to be generated as well putStrLn "hs-boot file generation" mapM_ (\m -> gen (m <.> "Interface" <.> "hs-boot") (prettyPrint (buildInterfaceHSBOOT m))) hsbootlst -- diff --git a/fficxx/lib/FFICXX/Generate/Code/HsFrontEnd.hs b/fficxx/lib/FFICXX/Generate/Code/HsFrontEnd.hs index e279eb17..e4ad6aff 100644 --- a/fficxx/lib/FFICXX/Generate/Code/HsFrontEnd.hs +++ b/fficxx/lib/FFICXX/Generate/Code/HsFrontEnd.hs @@ -268,9 +268,23 @@ genImportInInterface m = modlstparent = cmImportedModulesHighNonSource m modlsthigh = cmImportedModulesHighSource m in [mkImport (cmModule m <.> "RawType")] - <> map (\case Left t -> mkImport (getTClassModuleBase t <.> "Template"); Right c -> mkImport (getClassModuleBase c <.>"RawType")) modlstraw - <> map (\case Left t -> mkImport (getTClassModuleBase t <.> "Template"); Right c -> mkImport (getClassModuleBase c <.>"Interface")) modlstparent - <> map (\case Left t -> mkImportSrc (getTClassModuleBase t <.> "Template"); Right c -> mkImportSrc (getClassModuleBase c<.>"Interface")) modlsthigh + <> flip map modlstraw + (\case + Left t -> mkImport (getTClassModuleBase t <.> "Template") + Right c -> mkImport (getClassModuleBase c <.>"RawType") + ) + <> flip map modlstparent + (\case + Left t -> mkImport (getTClassModuleBase t <.> "Template") + Right c -> mkImport (getClassModuleBase c <.>"Interface") + ) + <> flip map modlsthigh + (\case + Left t -> -- TODO: *.Template in the same package needs to have hs-boot. + -- Currently, we do not have it yet. + mkImport (getTClassModuleBase t <.> "Template") + Right c -> mkImportSrc (getClassModuleBase c<.>"Interface") + ) -- | genImportInCast :: ClassModule -> [ImportDecl ()]