]> gerrit.simantics Code Review - simantics/platform.git/blob - 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
1 include "Simantics/DB"\r
2 include "Simantics/Variables"\r
3 include "Simantics/Ontologies"\r
4 \r
5 include "http://www.simantics.org/Modeling-1.2/SCLQuery" as SCLQuery\r
6 \r
7 importJava "org.simantics.scl.compiler.errors.CompilationError" where\r
8     data CompilationError\r
9 \r
10 importJava "org.simantics.scl.ui.editor.TextAndErrors" where\r
11     data TextAndErrors\r
12     createTextAndErrors :: String -> [CompilationError] -> TextAndErrors\r
13 \r
14 createSCLModuleAction :: Resource -> <Proc> ()\r
15 createSCLModuleAction res = do\r
16   syncWrite (\() -> createSCLModuleDefault res)\r
17   ()\r
18 \r
19 createPGraphAction :: Resource -> <Proc> ()\r
20 createPGraphAction res = do\r
21   syncWrite (\() -> createPGraphDefault res)\r
22   ()\r
23 \r
24 createSCLValueIndependent :: Resource -> String -> <WriteGraph> Resource\r
25 createSCLValueIndependent valueType expression = do\r
26     value = newResource ()\r
27     claim value L0.InstanceOf valueType\r
28     claimRelatedValue value L0.SCLValue.expression expression\r
29     value\r
30 \r
31 createSCLValue :: Resource -> Resource -> Resource -> String -> <WriteGraph> Resource\r
32 createSCLValue container predicate valueType expression = do\r
33     value = createSCLValueIndependent valueType expression\r
34     claim container predicate value\r
35     value\r
36 \r
37 setExpression :: Variable -> String -> <WriteGraph> ()\r
38 setExpression self expression = do\r
39     res = represents self\r
40     claimRelatedValue res L0.SCLValue.expression expression\r
41 \r
42 importJava "org.simantics.modeling.ModelingUtils" where\r
43     createSCLModuleDefault :: Resource -> <WriteGraph> ()\r
44     createPGraphDefault :: Resource -> <WriteGraph> ()\r
45     createSCLModule :: Resource -> String -> <WriteGraph> ()\r
46 \r
47 effect SCL \r
48     "scl" \r
49     "org.simantics.scl.compiler.commands.CommandSession"\r
50 \r
51 importJava "org.simantics.modeling.scl.SCLRealm" where\r
52     data SCLRealm\r
53     syncExec :: SCLRealm -> (<SCL, Proc> a) -> <Proc> a\r
54     @JavaName refreshVariablesSync\r
55     refreshVariables :: SCLRealm -> <Proc> ()\r
56     \r
57 readSCLRealm :: Resource -> <ReadGraph,Proc> SCLRealm\r
58 readSCLRealm r = let\r
59     id = relatedValue r L0.HasName\r
60   in match sclRealmById id with\r
61     Just realm -> realm\r
62     Nothing -> getOrCreateSCLRealm id\r
63 \r
64 importJava "org.simantics.modeling.scl.SCLSessionManager" where\r
65     getOrCreateSCLRealm :: String -> <Proc> SCLRealm\r
66     sclRealmById :: String -> <Proc> Maybe SCLRealm\r
67     \r
68 importJava "org.simantics.scl.compiler.top.CommandResponse" where\r
69     data CommandResponse = \r
70         @FieldNames [message, error]\r
71         CommandResponse String Boolean\r
72 \r
73 isSuccessful :: CommandResponse -> Boolean\r
74 isSuccessful (CommandResponse _ error) = not error\r
75 \r
76 instance Show CommandResponse where\r
77     show (CommandResponse message _) = message\r
78 \r
79 importJava "org.simantics.scl.compiler.commands.CommandSession" where\r
80     execute :: String -> <SCL, Proc> ()\r
81     \r
82     @JavaName getVariableValue\r
83     variableValue :: String -> <SCL> a\r
84     setVariable :: String -> Type -> a -> <SCL> ()