]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/scl/SCL/Reflection.scl
(refs #7595) Started SCL/Reflection module
[simantics/platform.git] / bundles / org.simantics.scl.compiler / scl / SCL / Reflection.scl
diff --git a/bundles/org.simantics.scl.compiler/scl/SCL/Reflection.scl b/bundles/org.simantics.scl.compiler/scl/SCL/Reflection.scl
new file mode 100644 (file)
index 0000000..cf8b88e
--- /dev/null
@@ -0,0 +1,27 @@
+module {
+    export = [possibleUnsafeSclValueByName, unsafeSclValueByName, sclModuleNames]
+}
+
+include "SCL/ReflectionJava"
+
+importJava "org.simantics.scl.compiler.module.repository.ModuleRepository" where
+    @JavaName getValue
+    unsafeSclValueByName_ :: ModuleRepository -> String -> <Proc> a
+    
+    @JavaName getSourceRepository
+    moduleSourceRepositoryOf :: ModuleRepository -> ModuleSourceRepository
+    
+importJava "org.simantics.scl.compiler.source.repository.ModuleSourceRepository" where
+    data ModuleSourceRepository
+    
+    @JavaName getModuleNames
+    sclModuleNames_ :: ModuleSourceRepository -> [String]
+    
+unsafeSclValueByName :: String -> <Proc> a
+unsafeSclValueByName = unsafeSclValueByName_ MODULE_REPOSITORY
+
+possibleUnsafeSclValueByName :: String -> <Proc> Maybe a
+possibleUnsafeSclValueByName name = Just (unsafeSclValueByName name) `catch` \(_ :: Exception) -> Nothing
+
+sclModuleNames :: <Proc> [String]
+sclModuleNames = sclModuleNames_ (moduleSourceRepositoryOf MODULE_REPOSITORY)