]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/scl/Simantics/SCL.scl
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.modeling / scl / Simantics / SCL.scl
diff --git a/bundles/org.simantics.modeling/scl/Simantics/SCL.scl b/bundles/org.simantics.modeling/scl/Simantics/SCL.scl
new file mode 100644 (file)
index 0000000..7298004
--- /dev/null
@@ -0,0 +1,84 @@
+include "Simantics/DB"\r
+include "Simantics/Variables"\r
+include "Simantics/Ontologies"\r
+\r
+include "http://www.simantics.org/Modeling-1.2/SCLQuery" as SCLQuery\r
+\r
+importJava "org.simantics.scl.compiler.errors.CompilationError" where\r
+    data CompilationError\r
+\r
+importJava "org.simantics.scl.ui.editor.TextAndErrors" where\r
+    data TextAndErrors\r
+    createTextAndErrors :: String -> [CompilationError] -> TextAndErrors\r
+\r
+createSCLModuleAction :: Resource -> <Proc> ()\r
+createSCLModuleAction res = do\r
+  syncWrite (\() -> createSCLModuleDefault res)\r
+  ()\r
+\r
+createPGraphAction :: Resource -> <Proc> ()\r
+createPGraphAction res = do\r
+  syncWrite (\() -> createPGraphDefault res)\r
+  ()\r
+\r
+createSCLValueIndependent :: Resource -> String -> <WriteGraph> Resource\r
+createSCLValueIndependent valueType expression = do\r
+    value = newResource ()\r
+    claim value L0.InstanceOf valueType\r
+    claimRelatedValue value L0.SCLValue.expression expression\r
+    value\r
+\r
+createSCLValue :: Resource -> Resource -> Resource -> String -> <WriteGraph> Resource\r
+createSCLValue container predicate valueType expression = do\r
+    value = createSCLValueIndependent valueType expression\r
+    claim container predicate value\r
+    value\r
+\r
+setExpression :: Variable -> String -> <WriteGraph> ()\r
+setExpression self expression = do\r
+    res = represents self\r
+    claimRelatedValue res L0.SCLValue.expression expression\r
+\r
+importJava "org.simantics.modeling.ModelingUtils" where\r
+    createSCLModuleDefault :: Resource -> <WriteGraph> ()\r
+    createPGraphDefault :: Resource -> <WriteGraph> ()\r
+    createSCLModule :: Resource -> String -> <WriteGraph> ()\r
+\r
+effect SCL \r
+    "scl" \r
+    "org.simantics.scl.compiler.commands.CommandSession"\r
+\r
+importJava "org.simantics.modeling.scl.SCLRealm" where\r
+    data SCLRealm\r
+    syncExec :: SCLRealm -> (<SCL, Proc> a) -> <Proc> a\r
+    @JavaName refreshVariablesSync\r
+    refreshVariables :: SCLRealm -> <Proc> ()\r
+    \r
+readSCLRealm :: Resource -> <ReadGraph,Proc> SCLRealm\r
+readSCLRealm r = let\r
+    id = relatedValue r L0.HasName\r
+  in match sclRealmById id with\r
+    Just realm -> realm\r
+    Nothing -> getOrCreateSCLRealm id\r
+\r
+importJava "org.simantics.modeling.scl.SCLSessionManager" where\r
+    getOrCreateSCLRealm :: String -> <Proc> SCLRealm\r
+    sclRealmById :: String -> <Proc> Maybe SCLRealm\r
+    \r
+importJava "org.simantics.scl.compiler.top.CommandResponse" where\r
+    data CommandResponse = \r
+        @FieldNames [message, error]\r
+        CommandResponse String Boolean\r
+\r
+isSuccessful :: CommandResponse -> Boolean\r
+isSuccessful (CommandResponse _ error) = not error\r
+\r
+instance Show CommandResponse where\r
+    show (CommandResponse message _) = message\r
+\r
+importJava "org.simantics.scl.compiler.commands.CommandSession" where\r
+    execute :: String -> <SCL, Proc> ()\r
+    \r
+    @JavaName getVariableValue\r
+    variableValue :: String -> <SCL> a\r
+    setVariable :: String -> Type -> a -> <SCL> ()
\ No newline at end of file