X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.modeling%2Fscl%2FSimantics%2FSCL.scl;h=d636ca8eff2a1c99574ec15125c5691f7ab0f852;hp=7298004aa6cf1241ceb35f467a2a352cc48a4046;hb=3edbf85ff8a7f1bd596857a24b1bdebd66943d6b;hpb=969bd23cab98a79ca9101af33334000879fb60c5 diff --git a/bundles/org.simantics.modeling/scl/Simantics/SCL.scl b/bundles/org.simantics.modeling/scl/Simantics/SCL.scl index 7298004aa..d636ca8ef 100644 --- a/bundles/org.simantics.modeling/scl/Simantics/SCL.scl +++ b/bundles/org.simantics.modeling/scl/Simantics/SCL.scl @@ -1,84 +1,135 @@ -include "Simantics/DB" -include "Simantics/Variables" -include "Simantics/Ontologies" - -include "http://www.simantics.org/Modeling-1.2/SCLQuery" as SCLQuery - -importJava "org.simantics.scl.compiler.errors.CompilationError" where - data CompilationError - -importJava "org.simantics.scl.ui.editor.TextAndErrors" where - data TextAndErrors - createTextAndErrors :: String -> [CompilationError] -> TextAndErrors - -createSCLModuleAction :: Resource -> () -createSCLModuleAction res = do - syncWrite (\() -> createSCLModuleDefault res) - () - -createPGraphAction :: Resource -> () -createPGraphAction res = do - syncWrite (\() -> createPGraphDefault res) - () - -createSCLValueIndependent :: Resource -> String -> Resource -createSCLValueIndependent valueType expression = do - value = newResource () - claim value L0.InstanceOf valueType - claimRelatedValue value L0.SCLValue.expression expression - value - -createSCLValue :: Resource -> Resource -> Resource -> String -> Resource -createSCLValue container predicate valueType expression = do - value = createSCLValueIndependent valueType expression - claim container predicate value - value - -setExpression :: Variable -> String -> () -setExpression self expression = do - res = represents self - claimRelatedValue res L0.SCLValue.expression expression - -importJava "org.simantics.modeling.ModelingUtils" where - createSCLModuleDefault :: Resource -> () - createPGraphDefault :: Resource -> () - createSCLModule :: Resource -> String -> () - -effect SCL - "scl" - "org.simantics.scl.compiler.commands.CommandSession" - -importJava "org.simantics.modeling.scl.SCLRealm" where - data SCLRealm - syncExec :: SCLRealm -> ( a) -> a - @JavaName refreshVariablesSync - refreshVariables :: SCLRealm -> () - -readSCLRealm :: Resource -> SCLRealm -readSCLRealm r = let - id = relatedValue r L0.HasName - in match sclRealmById id with - Just realm -> realm - Nothing -> getOrCreateSCLRealm id - -importJava "org.simantics.modeling.scl.SCLSessionManager" where - getOrCreateSCLRealm :: String -> SCLRealm - sclRealmById :: String -> Maybe SCLRealm - -importJava "org.simantics.scl.compiler.top.CommandResponse" where - data CommandResponse = - @FieldNames [message, error] - CommandResponse String Boolean - -isSuccessful :: CommandResponse -> Boolean -isSuccessful (CommandResponse _ error) = not error - -instance Show CommandResponse where - show (CommandResponse message _) = message - -importJava "org.simantics.scl.compiler.commands.CommandSession" where - execute :: String -> () - - @JavaName getVariableValue - variableValue :: String -> a +include "Simantics/DB" +include "Simantics/Variables" +include "Simantics/Ontologies" + +include "http://www.simantics.org/Modeling-1.2/SCLQuery" as SCLQuery + +importJava "org.simantics.scl.compiler.errors.CompilationError" where + data CompilationError + +importJava "org.simantics.scl.ui.editor.TextAndErrors" where + data TextAndErrors + createTextAndErrors :: String -> [CompilationError] -> TextAndErrors + +createSCLModuleAction :: Resource -> () +createSCLModuleAction res = ignore $ syncWrite (\() -> createSCLModuleDefault res) + +createSCLScriptAction :: Resource -> () +createSCLScriptAction res = ignore $ syncWrite (\() -> createSCLScriptDefault res) + +createPGraphAction :: Resource -> () +createPGraphAction res = ignore $ syncWrite (\() -> createPGraphDefault res) + +createSCLValueIndependent :: Resource -> String -> Resource +createSCLValueIndependent valueType expression = do + value = newResource () + claim value L0.InstanceOf valueType + claimRelatedValue value L0.SCLValue.expression expression + value + +createSCLValue :: Resource -> Resource -> Resource -> String -> Resource +createSCLValue container predicate valueType expression = do + value = createSCLValueIndependent valueType expression + claim container predicate value + value + +setExpression :: Variable -> String -> () +setExpression self expression = do + res = represents self + claimRelatedValue res L0.SCLValue.expression expression + +importJava "org.simantics.modeling.ModelingUtils" where + createSCLModuleDefault :: Resource -> () + createSCLScriptDefault :: Resource -> () + createPGraphDefault :: Resource -> () + "Use [createSCLModuleR](#createSCLModuleR) instead." + @deprecated + createSCLModule :: Resource -> String -> () + "Use [createSCLScriptR](#createSCLScriptR) instead." + @deprecated + createSCLScript :: Resource -> String -> () + "Use [createPGraphR](#createPGraphR) instead." + @deprecated + createPGraph :: Resource -> String -> () + """ + `createSCLModuleR container name` creates a new empty SCL module under + the specified `container` with the specified `name` and returns the created + module's Resource. + """ + @JavaName createSCLModule + createSCLModuleR :: Resource -> String -> Resource + """ + `createSCLScriptR container name` creates a new empty SCL script under + the specified `container` with the specified `name` and returns the created + script's Resource. + """ + @JavaName createSCLScript + createSCLScriptR :: Resource -> String -> Resource + """ + `createPGraphR container name` creates a new empty partial graph + ontology definition (PGraph) under the specified `container` with + the specified `name` and returns the created ontology definition's + Resource. + """ + @JavaName createPGraph + createPGraphR :: Resource -> String -> Resource + "`setSCLModuleDefinition module definition` sets the textual `definition` of the specified SCL `module`." + setSCLModuleDefinition :: Resource -> String -> Resource + "`setSCLScriptDefinition module definition` sets the textual `definition` of the specified SCL `module`." + setSCLScriptDefinition :: Resource -> String -> Resource + setPGraphDefinition :: Resource -> String -> Resource + +""" +`createSCLModuleWithDefinition container name definition` creates a new SCL module under +the specified `container` with the specified `name` and `definition` and returns +the created module's Resource. +""" +createSCLModuleWithDefinition :: Resource -> String -> String -> Resource +createSCLModuleWithDefinition container name definition = setSCLModuleDefinition (createSCLModuleR container name) definition + +""" +`createSCLScriptWithDefinition container name definition` creates a new SCL script under +the specified `container` with the specified `name` and `definition` and returns +the created script's Resource. +""" +createSCLScriptWithDefinition :: Resource -> String -> String -> Resource +createSCLScriptWithDefinition container name definition = setSCLScriptDefinition (createSCLScriptR container name) definition + +effect SCL + "scl" + "org.simantics.scl.compiler.commands.CommandSession" + +importJava "org.simantics.modeling.scl.SCLRealm" where + data SCLRealm + syncExec :: SCLRealm -> ( a) -> a + @JavaName refreshVariablesSync + refreshVariables :: SCLRealm -> () + +readSCLRealm :: Resource -> SCLRealm +readSCLRealm r = let + id = relatedValue r L0.HasName + in match sclRealmById id with + Just realm -> realm + Nothing -> getOrCreateSCLRealm id + +importJava "org.simantics.modeling.scl.SCLSessionManager" where + getOrCreateSCLRealm :: String -> SCLRealm + sclRealmById :: String -> Maybe SCLRealm + +importJava "org.simantics.scl.compiler.top.CommandResponse" where + data CommandResponse = + @FieldNames [message, error] + CommandResponse String Boolean + +isSuccessful :: CommandResponse -> Boolean +isSuccessful (CommandResponse _ error) = not error + +instance Show CommandResponse where + show (CommandResponse message _) = message + +importJava "org.simantics.scl.compiler.commands.CommandSession" where + execute :: String -> () + + @JavaName getVariableValue + variableValue :: String -> a setVariable :: String -> Type -> a -> () \ No newline at end of file