Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
|
scriptstack [2025/12/16 17:02] jango |
scriptstack [2025/12/30 17:42] (aktuell) admin [Models] |
||
|---|---|---|---|
| Zeile 7: | Zeile 7: | ||
| Lexer.cs:: | Lexer.cs:: | ||
| - | Parser.cs:: | + | Parser.cs:: |
| - | Parser.cs:: | + | Parser.cs:: |
| Interpreter.cd:: | Interpreter.cd:: | ||
| + | |||
| + | Routine:: | ||
| =====Manager===== | =====Manager===== | ||
| Zeile 222: | Zeile 224: | ||
| <code csharp> | <code csharp> | ||
| - | public class TrigonometryModule | + | using ScriptStack.Runtime; |
| - | : HostModule | + | using System; |
| - | { | + | |
| - | // list of functions stored statically for one-off creation | + | namespace ScriptStack { |
| - | | + | |
| - | s_listHostFunctionPrototypes; | + | |
| - | // module constructor | + | |
| - | | + | private static ReadOnlyCollection < Routine |
| - | { | + | |
| - | // if list created, don't do anything else | + | public |
| - | if (s_listHostFunctionPrototypes | + | |
| - | + | if (exportedRoutines | |
| - | // create list of function prototypes | + | |
| - | | + | |
| - | new List<hostfunctionprototype />(); | + | var r = new List<Routine>(); |
| - | HostFunctionPrototype hostFunctionPrototype = null; | + | |
| - | // add Sine prototype to list | + | |
| - | | + | r.Add(new |
| - | | + | r.Add(new |
| - | listHostFunctionPrototypes.Add(hostFunctionPrototype); | + | |
| - | // add Cosine prototype to list | + | |
| - | | + | |
| - | new HostFunctionPrototype(typeof(float), "Cos", | + | |
| - | listHostFunctionPrototypes.Add(hostFunctionPrototype); | + | |
| - | // add Tangent prototype to list | + | public ReadOnlyCollection < Routine |
| - | | + | |
| - | new HostFunctionPrototype(typeof(float), "Tan", | + | public object |
| - | listHostFunctionPrototypes.Add(hostFunctionPrototype); | + | |
| - | s_listHostFunctionPrototypes | + | |
| - | | + | |
| - | } | + | |
| - | // returns list of available functions | + | } |
| - | | + | |
| - | { | + | |
| - | get { return s_listHostFunctionPrototypes; } | + | return (int) System.Console.ReadKey().Key; |
| - | } | + | |
| - | // implements functions | + | |
| - | | + | return |
| - | List< | + | |
| - | { | + | |
| - | if (strFunctionName | + | } |
| - | // implement Sine | + | } |
| - | | + | |
| - | else if (strFunctionName | + | |
| - | // implement Cosine | + | |
| - | return (float)Math.Cos((float)listParameters[0]); | + | |
| - | else if (strFunctionName | + | |
| - | // implement Tangent | + | |
| - | return | + | |
| - | // unknown function (should not happen) | + | |
| - | throw new ExecutionException( | + | |
| - | " | + | |
| - | } | + | |
| } | } | ||
| </ | </ | ||
| Zeile 282: | Zeile 273: | ||
| <code csharp> | <code csharp> | ||
| // create module instance | // create module instance | ||
| - | TrigonometryModule trigonometryModule | + | Model example |
| // register module | // register module | ||
| - | m_scriptManager.RegisterHostModule(trigonometryModule) | + | Manager.Register(example) |
| </ | </ | ||