From 23e46c2b019eeb71a911f6d0837b2de20da28196 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Hannu=20Niemist=C3=B6?= Date: Mon, 12 Mar 2018 11:08:38 +0200 Subject: [PATCH] (refs #7811) Some new functions for SCL reflection Change-Id: I80b7091a59b0446b1b3d066056b1473d9ec74c56 --- .../scl/SCL/ModuleRepository.scl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/bundles/org.simantics.scl.compiler/scl/SCL/ModuleRepository.scl b/bundles/org.simantics.scl.compiler/scl/SCL/ModuleRepository.scl index eceb418be..7d035d8cf 100644 --- a/bundles/org.simantics.scl.compiler/scl/SCL/ModuleRepository.scl +++ b/bundles/org.simantics.scl.compiler/scl/SCL/ModuleRepository.scl @@ -1,10 +1,19 @@ module { - export = [possibleUnsafeSclValueByName, unsafeSclValueByName, sclModuleNames, moduleByName] + export = [possibleUnsafeSclValueByName, unsafeSclValueByName, sclModuleNames, moduleByName, + documentationOfSCLValue, sclValueRef] } include "./CurrentModuleRepository" include "./Module" +importJava "org.simantics.scl.compiler.elaboration.modules.SCLValue" where + data SCLValue + + @JavaName getDocumentation + documentationOfSCLValue_ :: SCLValue -> Maybe String + +documentationOfSCLValue value = fromMaybe "" (documentationOfSCLValue_ value) + importJava "org.simantics.scl.compiler.module.repository.ModuleRepository" where // data ModuleRepository // defined in CurrentModuleRepository @@ -12,6 +21,9 @@ importJava "org.simantics.scl.compiler.module.repository.ModuleRepository" where @JavaName getValue unsafeSclValueByName_ :: ModuleRepository -> String -> a + @JavaName getValueRef + sclValueRef_ :: ModuleRepository -> String -> Maybe SCLValue + @JavaName getSourceRepository moduleSourceRepositoryOf :: ModuleRepository -> ModuleSourceRepository @@ -33,6 +45,8 @@ importJava "org.simantics.scl.compiler.errors.Failable" where unsafeSclValueByName :: String -> a unsafeSclValueByName = unsafeSclValueByName_ MODULE_REPOSITORY +sclValueRef name = sclValueRef_ MODULE_REPOSITORY name + possibleUnsafeSclValueByName :: String -> Maybe a possibleUnsafeSclValueByName name = Just (unsafeSclValueByName name) `catch` \(_ :: Exception) -> Nothing -- 2.47.1