{-# LANGUAGE Haskell2010 #-} {-# OPTIONS -Wall #-} -- | Functions for generating glue code between Haskell and Java. module Bindings ( -- * Create Haskell glue code from Java definitions printJavaPackageModule, printJavaClassModule, printJavaClassBootfile, printJavaClassModule', printJavaClassBootfile', ) where import Translate import Foreign.Java.Utils import Language.Java.Reflect.Types import Data.Map (Map) imports :: String -- ^ Imports of all auto generated java code files. imports = ((\_ -> let { __ = {-# LINE 24 "Bindings.hss" #-} concat ["import qualified Foreign.Java as JNI\nimport Foreign.Java ((-->))\nimport qualified Prelude as Prelude\nimport Prelude ((.), ($), (>>=), (>>), return)\nimport qualified Foreign.Java.Bindings as JNIS\nimport Data.Functor ((<$>))\n"] {-# LINE 31 "Bindings.hss" #-} } in __) undefined) classInfoSignature :: String -- ^ classInfoSignature = "Prelude.String" classInfo' :: JavaClass -> String -- ^ classInfo' clazz = className clazz packageInfo' :: String -> a -> String packageInfo' packageName classes = packageName printJavaPackageModule :: String -- The Java package name -> String -- The Haskell module name of the Java package -> Map String JavaClass -- Info about all other classes -> [JavaClass] -- The Java classes contained in the Java package -> String -- ^ printJavaPackageModule packageName modName classInfo classes = ((\_ -> let { __ = {-# LINE 50 "Bindings.hss" #-} concat ["{-# LANGUAGE Haskell2010 #-}\n-- | Package @", (packageName), "@\nmodule ", (modName), " (\n", (moduleExports), " info'\n) where\n", (imports), "\n", (moduleImports), "\n-- Information about this package.\ninfo' = ", (show $ packageInfo' packageName classes), "\n", (moduleDeclarations), "\n"] {-# LINE 62 "Bindings.hss" #-} } in __) undefined) where moduleDeclarations = pkgModDecl classInfo classes moduleImports = pkgModImports classInfo classes moduleExports = pkgModExports classInfo classes printJavaClassModule :: JavaClass -- The Java class -> String -- The Haskell module name of the Java class -> Map String JavaClass -- Info about all classes -> String -- ^ printJavaClassModule clazz modName classInfo = ((\_ -> let { __ = {-# LINE 73 "Bindings.hss" #-} concat ["{-# LANGUAGE Haskell2010 #-}\n-- | ", (show $ classType clazz), " @", (classFullName clazz), "@\nmodule ", (modName), " (\n", (moduleExports), " -- * Information about this class.\n info'\n) where\n", (imports), "\n", (bootfileImports), "\n", (moduleImports), "\ninfo' = ", (show $ classInfo' clazz), "\n", (bootfileDeclarations), "\n", (moduleDeclarations), "\n"] {-# LINE 87 "Bindings.hss" #-} } in __) undefined) where bootfileDeclarations = classBootDecl classInfo clazz bootfileImports = classBootImports classInfo clazz moduleDeclarations = classModDecl classInfo clazz moduleImports = classModImports classInfo clazz moduleExports = classModExports classInfo clazz printJavaClassBootfile :: JavaClass -- The Java class -> String -- The Haskell module name of the Java class -> Map String JavaClass -- Info about all classes -> String -- ^ printJavaClassBootfile clazz modName classInfo = ((\_ -> let { __ = {-# LINE 100 "Bindings.hss" #-} concat ["{-# LANGUAGE Haskell2010 #-}\n-- Bootfile for class ", (className clazz), "\nmodule ", (modName), " (\n", (bootfileExports), " info'\n) where\n", (imports), "\n", (bootfileImports), "\ninfo' :: ", (classInfoSignature), "\n", (bootfileDeclarations), "\n"] {-# LINE 111 "Bindings.hss" #-} } in __) undefined) where bootfileDeclarations = classBootDecl classInfo clazz bootfileImports = classBootImports classInfo clazz bootfileExports = classBootExports classInfo clazz printJavaClassModule' :: JavaClass -- The Java class -> String -- The Haskell module name of the Java class -> Map String JavaClass -- Info about all classes -> String -- ^ printJavaClassModule' clazz modName classInfo = ((\_ -> let { __ = {-# LINE 122 "Bindings.hss" #-} concat ["{-# LANGUAGE Haskell2010, TypeFamilies #-}\n-- hidden @", (className clazz), "@\nmodule ", (modName), "__ (\n", (moduleExports), " info'\n) where\n", (imports), "\n", (bootfileImports), "\n", (moduleImports), "\ninfo' = ", (show $ classInfo' clazz), "\n", (bootfileDeclarations), "\n", (moduleDeclarations), "\n"] {-# LINE 135 "Bindings.hss" #-} } in __) undefined) where bootfileDeclarations = classBootDecl' classInfo clazz bootfileImports = classBootImports' classInfo clazz moduleDeclarations = classModDecl' classInfo clazz moduleImports = classModImports' classInfo clazz moduleExports = classModExports' classInfo clazz printJavaClassBootfile' :: JavaClass -- The Java class -> String -- The Haskell module name of the Java class -> Map String JavaClass -- Info about all classes -> String -- ^ printJavaClassBootfile' clazz modName classInfo = ((\_ -> let { __ = {-# LINE 148 "Bindings.hss" #-} concat ["{-# LANGUAGE Haskell2010 #-}\n-- hidden Bootfile for class ", (className clazz), "\nmodule ", (modName), "__ (\n", (bootfileExports), " info'\n) where\n", (imports), "\n", (bootfileImports), "\ninfo' :: ", (classInfoSignature), "\n", (bootfileDeclarations), "\n"] {-# LINE 159 "Bindings.hss" #-} } in __) undefined) where bootfileDeclarations = classBootDecl' classInfo clazz bootfileImports = classBootImports' classInfo clazz bootfileExports = classBootExports' classInfo clazz