X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.scl.runtime%2Fsrc-isv%2FExtendingSCLEnvironment.mediawiki;h=2bedeb16c0056ca97f63943a7bf7af266d216ba9;hb=refs%2Fchanges%2F75%2F3375%2F1;hp=4772b0ce542be82ce5952fad4e1453c3a63bfe23;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.runtime/src-isv/ExtendingSCLEnvironment.mediawiki b/bundles/org.simantics.scl.runtime/src-isv/ExtendingSCLEnvironment.mediawiki index 4772b0ce5..2bedeb16c 100644 --- a/bundles/org.simantics.scl.runtime/src-isv/ExtendingSCLEnvironment.mediawiki +++ b/bundles/org.simantics.scl.runtime/src-isv/ExtendingSCLEnvironment.mediawiki @@ -1,88 +1,88 @@ -== Extending SCL environment == - -The SCL values, data types etc. that are available in expressions and commands are defined in SCL modules. Currently all SCL modules must be part of the product plugins (in the future, you can also write modules inside the models). Each module is identified by a URI. - -SCL module is a text file ending with extension ".scl". The recommended place for modules is scl/ folder under plugin root, but also other directories can be used: - -scl/Test1.scl: -
-fib :: Integer -> Integer -fib x | x <= 1 = 1 - | otherwise = fib (x-1) + fib (x-2) -- - -A directory is declared as a SCL package with the following kind of extension points defined in org.simantics.scl.runtime: -
-- -The module is not automatically available in the console, but you must run an import declaration: -- --
-> import "http://www.simantics.org/Tests/Test1" as Test1 -> Test1.fib 13 -377 -- -Import declaration can also be used in modules to refer other modules. Cyclic module dependencies are not allowed. - -== Importing functionality from Java == - -Java interfaces and classes can be imported from Java by declaring them inside importJava block: -
-importJava "java.util.regex.Pattern" where - data Pattern - -importJava "java.util.List" where - data List a -- -Java methods, constructors and fields can be similarly imported by giving -their type annotations in importJava block: -
-importJava "java.util.regex.Pattern.compile" where - @JavaName compile - compilePattern :: String -> Pattern - - @JavaName matcher - createMatcher :: Pattern -> String ->- -Another example: -Matcher - -importJava "java.util.regex.Matcher" where - data Matcher - - @JavaName matches - matcherMatches :: Matcher -> Boolean - -matches : Pattern -> String -> Boolean -matches pattern text = do - matcherMatches (createMatcher pattern text) -
-importJava "java.util.ArrayList" where - @JavaName "- -Java constructor is referred with "" - createArrayList :: () -> List a - - @JavaName " " - createArrayListWithCapacity :: Integer -> List a - - @JavaName size - sizeList :: List a -> Integer - - @JavaName get - getList :: List a -> Integer -> a - - @JavaName set - setList :: List a -> Integer -> a -> () - - @JavaName add - addList :: List a -> a -> Boolean -
+fib :: Integer -> Integer +fib x | x <= 1 = 1 + | otherwise = fib (x-1) + fib (x-2) ++ + +A directory is declared as a SCL package with the following kind of extension points defined in org.simantics.scl.runtime: +
++ +The module is not automatically available in the console, but you must run an import declaration: ++ ++
+> import "http://www.simantics.org/Tests/Test1" as Test1 +> Test1.fib 13 +377 ++ +Import declaration can also be used in modules to refer other modules. Cyclic module dependencies are not allowed. + +== Importing functionality from Java == + +Java interfaces and classes can be imported from Java by declaring them inside importJava block: +
+importJava "java.util.regex.Pattern" where + data Pattern + +importJava "java.util.List" where + data List a ++ +Java methods, constructors and fields can be similarly imported by giving +their type annotations in importJava block: +
+importJava "java.util.regex.Pattern.compile" where + @JavaName compile + compilePattern :: String -> Pattern + + @JavaName matcher + createMatcher :: Pattern -> String ->+ +Another example: +Matcher + +importJava "java.util.regex.Matcher" where + data Matcher + + @JavaName matches + matcherMatches :: Matcher -> Boolean + +matches : Pattern -> String -> Boolean +matches pattern text = do + matcherMatches (createMatcher pattern text) +
+importJava "java.util.ArrayList" where + @JavaName "+ +Java constructor is referred with "" + createArrayList :: () -> List a + + @JavaName " " + createArrayListWithCapacity :: Integer -> List a + + @JavaName size + sizeList :: List a -> Integer + + @JavaName get + getList :: List a -> Integer -> a + + @JavaName set + setList :: List a -> Integer -> a -> () + + @JavaName add + addList :: List a -> a -> Boolean +