From: Hannu Niemistö Date: Mon, 12 Mar 2018 09:08:38 +0000 (+0200) Subject: (refs #7811) Some new functions for SCL reflection X-Git-Tag: v1.43.0~136^2~548^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=commitdiff_plain;h=23e46c2b019eeb71a911f6d0837b2de20da28196;ds=sidebyside (refs #7811) Some new functions for SCL reflection Change-Id: I80b7091a59b0446b1b3d066056b1473d9ec74c56 --- 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