aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ScriptEngine/Shared
diff options
context:
space:
mode:
authorTedd Hansen2008-11-08 17:35:48 +0000
committerTedd Hansen2008-11-08 17:35:48 +0000
commit9511a8c76370f21e839114007dcd2b25c69b009a (patch)
treeb63323dfd96ecd1cc3cd560939bd66bb43ec9c1c /OpenSim/ScriptEngine/Shared
parent* Added IClientIM to IClientCore interfaces (diff)
downloadopensim-SC_OLD-9511a8c76370f21e839114007dcd2b25c69b009a.zip
opensim-SC_OLD-9511a8c76370f21e839114007dcd2b25c69b009a.tar.gz
opensim-SC_OLD-9511a8c76370f21e839114007dcd2b25c69b009a.tar.bz2
opensim-SC_OLD-9511a8c76370f21e839114007dcd2b25c69b009a.tar.xz
Work in progress on SECS stuff. Have been holding it off until after 0.6 release. Still messy as hell and doesn't really work yet. Will undergo dramatic changes. AND MOST IMPORTANTLY: Will be conformed to work in coop with todays DNE and XEngine, hopefully one day providing a common interface for all components.
Diffstat (limited to 'OpenSim/ScriptEngine/Shared')
-rw-r--r--OpenSim/ScriptEngine/Shared/EventParams.cs47
-rw-r--r--OpenSim/ScriptEngine/Shared/IScriptCommandProvider.cs10
-rw-r--r--OpenSim/ScriptEngine/Shared/IScriptCompiler.cs40
-rw-r--r--OpenSim/ScriptEngine/Shared/IScriptEngine.cs49
-rw-r--r--OpenSim/ScriptEngine/Shared/IScriptEngineComponent.cs36
-rw-r--r--OpenSim/ScriptEngine/Shared/IScriptEngineRegionComponent.cs7
-rw-r--r--OpenSim/ScriptEngine/Shared/IScriptEventProvider.cs11
-rw-r--r--OpenSim/ScriptEngine/Shared/IScriptExecutor.cs39
-rw-r--r--OpenSim/ScriptEngine/Shared/IScriptLoader.cs9
-rw-r--r--OpenSim/ScriptEngine/Shared/IScriptScheduler.cs41
-rw-r--r--OpenSim/ScriptEngine/Shared/Properties/AssemblyInfo.cs36
-rw-r--r--OpenSim/ScriptEngine/Shared/RegionInfoStructure.cs94
-rw-r--r--OpenSim/ScriptEngine/Shared/ScriptMetaData.cs95
-rw-r--r--OpenSim/ScriptEngine/Shared/ScriptStructure.cs109
14 files changed, 623 insertions, 0 deletions
diff --git a/OpenSim/ScriptEngine/Shared/EventParams.cs b/OpenSim/ScriptEngine/Shared/EventParams.cs
new file mode 100644
index 0000000..661086e
--- /dev/null
+++ b/OpenSim/ScriptEngine/Shared/EventParams.cs
@@ -0,0 +1,47 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenMetaverse;
5using OpenSim.Region.ScriptEngine.Shared;
6
7namespace OpenSim.ScriptEngine.Shared
8{
9 /// <summary>
10 /// Holds all the data required to execute a scripting event.
11 /// </summary>
12 public class EventParams
13 {
14 public string EventName;
15 public Object[] Params;
16 public Region.ScriptEngine.Shared.DetectParams[] DetectParams;
17 public uint LocalID;
18 public UUID ItemID;
19
20 public EventParams(uint localID, UUID itemID, string eventName, Object[] eventParams, DetectParams[] detectParams)
21 {
22 LocalID = localID;
23 ItemID = itemID;
24 EventName = eventName;
25 Params = eventParams;
26 DetectParams = detectParams;
27 }
28 public EventParams(uint localID, string eventName, Object[] eventParams, DetectParams[] detectParams)
29 {
30 LocalID = localID;
31 EventName = eventName;
32 Params = eventParams;
33 DetectParams = detectParams;
34 }
35 public void test(params object[] args)
36 {
37 string functionName = "test";
38 test2(functionName, args);
39 }
40 public void test2(string functionName, params object[] args)
41 {
42 System.Console.WriteLine(functionName, args);
43 }
44
45
46 }
47} \ No newline at end of file
diff --git a/OpenSim/ScriptEngine/Shared/IScriptCommandProvider.cs b/OpenSim/ScriptEngine/Shared/IScriptCommandProvider.cs
new file mode 100644
index 0000000..f37fcaf
--- /dev/null
+++ b/OpenSim/ScriptEngine/Shared/IScriptCommandProvider.cs
@@ -0,0 +1,10 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.ScriptEngine.Shared
6{
7 public interface IScriptCommandProvider : ScriptAssemblies.ICommandProvider
8 {
9 }
10}
diff --git a/OpenSim/ScriptEngine/Shared/IScriptCompiler.cs b/OpenSim/ScriptEngine/Shared/IScriptCompiler.cs
new file mode 100644
index 0000000..3bc0c03
--- /dev/null
+++ b/OpenSim/ScriptEngine/Shared/IScriptCompiler.cs
@@ -0,0 +1,40 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.Reflection;
30using System.Text;
31using ScriptAssemblies;
32
33namespace OpenSim.ScriptEngine.Shared
34{
35 public interface IScriptCompiler : IScriptEngineComponent
36 {
37 string Compile(ScriptMetaData scriptMetaData, ref string script);
38 string PreProcessScript(ref string script);
39 }
40} \ No newline at end of file
diff --git a/OpenSim/ScriptEngine/Shared/IScriptEngine.cs b/OpenSim/ScriptEngine/Shared/IScriptEngine.cs
new file mode 100644
index 0000000..6148d8d
--- /dev/null
+++ b/OpenSim/ScriptEngine/Shared/IScriptEngine.cs
@@ -0,0 +1,49 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.Text;
30using Nini.Config;
31using OpenSim.Region.Environment.Interfaces;
32using OpenSim.Region.Environment.Scenes;
33
34namespace OpenSim.ScriptEngine.Shared
35{
36 public interface IScriptEngine
37 {
38 //string[] ComponentNames { get; }
39 //Dictionary<string, IScriptEngineComponent> Components { get; }
40 //void InitializeComponents();
41 void Initialise(Scene scene, IConfigSource source);
42 void PostInitialise();
43 void Close();
44 string Name { get; }
45 // string Name { get; }
46 //void Initialize();
47 //void Close();
48 }
49} \ No newline at end of file
diff --git a/OpenSim/ScriptEngine/Shared/IScriptEngineComponent.cs b/OpenSim/ScriptEngine/Shared/IScriptEngineComponent.cs
new file mode 100644
index 0000000..3c977a5
--- /dev/null
+++ b/OpenSim/ScriptEngine/Shared/IScriptEngineComponent.cs
@@ -0,0 +1,36 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.Text;
30
31namespace OpenSim.ScriptEngine.Shared
32{
33 public interface IScriptEngineComponent
34 {
35 }
36} \ No newline at end of file
diff --git a/OpenSim/ScriptEngine/Shared/IScriptEngineRegionComponent.cs b/OpenSim/ScriptEngine/Shared/IScriptEngineRegionComponent.cs
new file mode 100644
index 0000000..a8d779d
--- /dev/null
+++ b/OpenSim/ScriptEngine/Shared/IScriptEngineRegionComponent.cs
@@ -0,0 +1,7 @@
1namespace OpenSim.ScriptEngine.Shared
2{
3 public interface IScriptEngineRegionComponent
4 {
5 void Initialize(RegionInfoStructure currentRegion);
6 }
7}
diff --git a/OpenSim/ScriptEngine/Shared/IScriptEventProvider.cs b/OpenSim/ScriptEngine/Shared/IScriptEventProvider.cs
new file mode 100644
index 0000000..a290ba4
--- /dev/null
+++ b/OpenSim/ScriptEngine/Shared/IScriptEventProvider.cs
@@ -0,0 +1,11 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.ScriptEngine.Shared
6{
7 public interface IScriptEventProvider : IScriptEngineComponent, IScriptEngineRegionComponent
8 {
9
10 }
11} \ No newline at end of file
diff --git a/OpenSim/ScriptEngine/Shared/IScriptExecutor.cs b/OpenSim/ScriptEngine/Shared/IScriptExecutor.cs
new file mode 100644
index 0000000..77bea13
--- /dev/null
+++ b/OpenSim/ScriptEngine/Shared/IScriptExecutor.cs
@@ -0,0 +1,39 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.Text;
30using OpenSim.ScriptEngine.Shared;
31
32namespace OpenSim.ScriptEngine.Shared
33{
34 public interface IScriptExecutor : IScriptEngineComponent, IScriptEngineRegionComponent
35 {
36 void ExecuteCommand(ref ScriptStructure scriptContainer, EventParams p);
37 void ExecuteCommand(EventParams p);
38 }
39} \ No newline at end of file
diff --git a/OpenSim/ScriptEngine/Shared/IScriptLoader.cs b/OpenSim/ScriptEngine/Shared/IScriptLoader.cs
new file mode 100644
index 0000000..15f7443
--- /dev/null
+++ b/OpenSim/ScriptEngine/Shared/IScriptLoader.cs
@@ -0,0 +1,9 @@
1using OpenSim.ScriptEngine.Shared;
2
3namespace OpenSim.ScriptEngine.Shared
4{
5 public interface IScriptLoader: IScriptEngineComponent
6 {
7 ScriptAssemblies.IScript LoadScript(ScriptStructure script);
8 }
9} \ No newline at end of file
diff --git a/OpenSim/ScriptEngine/Shared/IScriptScheduler.cs b/OpenSim/ScriptEngine/Shared/IScriptScheduler.cs
new file mode 100644
index 0000000..3e56c12
--- /dev/null
+++ b/OpenSim/ScriptEngine/Shared/IScriptScheduler.cs
@@ -0,0 +1,41 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.Text;
30using OpenMetaverse;
31using OpenSim.ScriptEngine.Shared;
32
33namespace OpenSim.ScriptEngine.Shared
34{
35 public interface IScriptScheduler : IScriptEngineComponent
36 {
37 void AddScript(ScriptStructure script);
38 void Removecript(uint id, UUID itemID);
39 void Close();
40 }
41} \ No newline at end of file
diff --git a/OpenSim/ScriptEngine/Shared/Properties/AssemblyInfo.cs b/OpenSim/ScriptEngine/Shared/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..06a3461
--- /dev/null
+++ b/OpenSim/ScriptEngine/Shared/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.ScriptEngine.Shared")]
9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("Microsoft")]
12[assembly: AssemblyProduct("OpenSim.ScriptEngine.Shared")]
13[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")]
16
17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)]
21
22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("ea77002b-c967-4368-ace9-6533f8147d4b")]
24
25// Version information for an assembly consists of the following four values:
26//
27// Major Version
28// Minor Version
29// Build Number
30// Revision
31//
32// You can specify all the values or you can default the Build and Revision Numbers
33// by using the '*' as shown below:
34// [assembly: AssemblyVersion("1.0.*")]
35[assembly: AssemblyVersion("1.0.0.0")]
36[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/ScriptEngine/Shared/RegionInfoStructure.cs b/OpenSim/ScriptEngine/Shared/RegionInfoStructure.cs
new file mode 100644
index 0000000..834fac3
--- /dev/null
+++ b/OpenSim/ScriptEngine/Shared/RegionInfoStructure.cs
@@ -0,0 +1,94 @@
1using System;
2using System.Collections.Generic;
3using System.Reflection;
4using log4net;
5using Nini.Config;
6using OpenSim.Region.Environment.Scenes;
7using OpenSim.Region.ScriptEngine.Shared;
8using OpenSim.ScriptEngine.Shared;
9using EventParams=OpenSim.ScriptEngine.Shared.EventParams;
10
11namespace OpenSim.ScriptEngine.Shared
12{
13 public struct RegionInfoStructure
14 {
15 public Scene Scene;
16 public IConfigSource ConfigSource;
17
18 public IScriptLoader ScriptLoader;
19 public Dictionary<string, IScriptEventProvider> EventProviders;
20 public Dictionary<string, IScriptExecutor> Executors;
21 public Dictionary<string, IScriptCompiler> Compilers;
22 public Dictionary<string, IScriptScheduler> Schedulers;
23 public Dictionary<string, IScriptCommandProvider> CommandProviders;
24 public ILog Logger;
25
26 public void Executors_Execute(EventParams p)
27 {
28 // Execute a command on all executors
29 lock (Executors)
30 {
31 foreach (IScriptExecutor exec in Executors.Values)
32 {
33 exec.ExecuteCommand(p);
34 }
35 }
36 }
37 public void Executors_Execute(ScriptStructure scriptContainer, EventParams p)
38 {
39 // Execute a command on all executors
40 lock (Executors)
41 {
42 foreach (IScriptExecutor exec in Executors.Values)
43 {
44 exec.ExecuteCommand(ref scriptContainer, p);
45 }
46 }
47 }
48
49 public IScriptCompiler FindCompiler(ScriptMetaData scriptMetaData)
50 {
51 string compiler = "Compiler_LSL";
52 if (scriptMetaData.ContainsKey("Compiler"))
53 compiler = scriptMetaData["Compiler"];
54
55 lock (Compilers)
56 {
57 if (!Compilers.ContainsKey(compiler))
58 throw new Exception("Requested script compiler \"" + compiler + "\" does not exist.");
59
60 return Compilers[compiler];
61 }
62 }
63
64 public IScriptScheduler FindScheduler(ScriptMetaData scriptMetaData)
65 {
66 string scheduler = "Scheduler";
67 if (scriptMetaData.ContainsKey("Scheduler"))
68 scheduler = scriptMetaData["Scheduler"];
69
70 lock (Schedulers)
71 {
72 if (!Schedulers.ContainsKey(scheduler))
73 throw new Exception("Requested script scheduler \"" + scheduler + "\" does not exist.");
74
75 return Schedulers[scheduler];
76 }
77 }
78
79 //public Assembly[] GetCommandProviderAssemblies()
80 //{
81 // lock (CommandProviders)
82 // {
83 // Assembly[] ass = new Assembly[CommandProviders.Count];
84 // int i = 0;
85 // foreach (string key in CommandProviders.Keys)
86 // {
87 // ass[i] = CommandProviders[key].GetType().Assembly;
88 // i++;
89 // }
90 // return ass;
91 // }
92 //}
93 }
94} \ No newline at end of file
diff --git a/OpenSim/ScriptEngine/Shared/ScriptMetaData.cs b/OpenSim/ScriptEngine/Shared/ScriptMetaData.cs
new file mode 100644
index 0000000..462f2d4
--- /dev/null
+++ b/OpenSim/ScriptEngine/Shared/ScriptMetaData.cs
@@ -0,0 +1,95 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29
30namespace OpenSim.ScriptEngine.Shared
31{
32 public class ScriptMetaData: Dictionary<string, string>
33 {
34 private static readonly char[] LineSeparator = "\r\n".ToCharArray();
35 private static readonly char[] Separator = { ':' };
36 public static ScriptMetaData Extract(ref string Script)
37 {
38 ScriptMetaData ret = new ScriptMetaData();
39 if (string.IsNullOrEmpty(Script))
40 return ret;
41
42 // Process it line by line
43 string Line = "";
44 for (int i = 0; i < Script.Length + 1; i++)
45 {
46 // Found a line separator?
47 if (i < Script.Length
48 && Script[i] != LineSeparator[0]
49 && Script[i] != LineSeparator[1])
50 {
51 // No, not end of line. Add to current line
52 Line += Script[i];
53 }
54 else
55 {
56 // Extract MetaData from this line. Returns False if not found.
57 if (!_GetMetaFromLine(ret, Line))
58 continue;
59 // Empty for next round
60 Line = "";
61 }
62 }
63 return ret;
64 }
65
66 private static bool _GetMetaFromLine(ScriptMetaData ret, string line)
67 {
68 line = line.Trim();
69
70 // Empty line? We may find more later
71 if (line == "")
72 return true;
73
74 // Is this a comment? If not, then return false
75 if (!line.StartsWith("//"))
76 return false;
77
78 // It is a comment
79 string[] keyval = line.Split(Separator, 2, StringSplitOptions.None);
80 keyval[0] = keyval[0].Substring(2, keyval[0].Length - 2).Trim();
81 keyval[1] = keyval[1].Trim();
82
83 // Add it
84 if (keyval[0] != "")
85 if (!ret.ContainsKey(keyval[0]))
86 {
87 //m_log.DebugFormat("[DotNetEngine] Script metadata: Key: \"{0}\", Value: \"{1}\".", keyval[0], keyval[1]);
88 ret.Add(keyval[0], keyval[1]);
89 }
90
91 return true;
92 }
93
94 }
95} \ No newline at end of file
diff --git a/OpenSim/ScriptEngine/Shared/ScriptStructure.cs b/OpenSim/ScriptEngine/Shared/ScriptStructure.cs
new file mode 100644
index 0000000..cbf333b
--- /dev/null
+++ b/OpenSim/ScriptEngine/Shared/ScriptStructure.cs
@@ -0,0 +1,109 @@
1using System;
2using System.Collections.Generic;
3using System.Reflection;
4using System.Text;
5using OpenMetaverse;
6using OpenSim.Region.ScriptEngine.Interfaces;
7using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
8using OpenSim.ScriptEngine.Shared;
9
10namespace OpenSim.ScriptEngine.Shared
11{
12 public struct ScriptStructure
13 {
14 public RegionInfoStructure RegionInfo;
15 public ScriptMetaData ScriptMetaData;
16
17 public ScriptAssemblies.IScript ScriptObject;
18 public string State;
19 public bool Running;
20 public bool Disabled;
21 public string Source;
22 public int StartParam;
23 public AppDomain AppDomain;
24 public Dictionary<string, IScriptApi> Apis;
25 public Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> LineMap;
26 public uint LocalID;
27 public UUID ItemID;
28 public string AssemblyFileName;
29
30 public string ScriptID { get { return LocalID.ToString() + "." + ItemID.ToString(); } }
31 public string Name { get { return "Script:" + ScriptID; } }
32 private bool Initialized;
33 private Dictionary<string, Delegate> InternalFunctions;
34 public string AssemblyName;
35
36 public void ExecuteEvent(EventParams p)
37 {
38 ExecuteMethod(p, true);
39 }
40
41 public void ExecuteMethod(EventParams p)
42 {
43 ExecuteMethod(p, false);
44 }
45 private void ExecuteMethod(EventParams p, bool isEvent)
46 {
47 // First time initialization?
48 if (!Initialized)
49 {
50 Initialized = true;
51 CacheInternalFunctions();
52 }
53
54 lock (InternalFunctions)
55 {
56 // Make function name
57 string FunctionName;
58 if (isEvent)
59 FunctionName = State + "_event_" + p.EventName;
60 else
61 FunctionName = p.EventName;
62
63 // Check if this function exist
64 if (!InternalFunctions.ContainsKey(FunctionName))
65 {
66 // TODO: Send message in-world
67 //RegionInfo.Scene.
68 RegionInfo.Logger.ErrorFormat("[{0}] Script function \"{1}\" was not found.", Name, FunctionName);
69 return;
70 }
71
72 // Execute script function
73 try
74 {
75 InternalFunctions[FunctionName].DynamicInvoke(p.Params);
76 }
77 catch (Exception e)
78 {
79 RegionInfo.Logger.ErrorFormat("[{0}] Execute \"{1}\" failed: {2}", Name, FunctionName, e.ToString());
80 }
81 }
82 }
83
84 /// <summary>
85 /// Cache functions into a dictionary with delegates. Should be faster than reflection.
86 /// </summary>
87 private void CacheInternalFunctions()
88 {
89 Type scriptObjectType = ScriptObject.GetType();
90 InternalFunctions = new Dictionary<string, Delegate>();
91
92 MethodInfo[] methods = scriptObjectType.GetMethods();
93 lock (InternalFunctions)
94 {
95 // Read all methods into a dictionary
96 foreach (MethodInfo mi in methods)
97 {
98 // TODO: We don't support overloading
99 if (!InternalFunctions.ContainsKey(mi.Name))
100 InternalFunctions.Add(mi.Name, Delegate.CreateDelegate(scriptObjectType, ScriptObject, mi));
101 else
102 RegionInfo.Logger.ErrorFormat("[{0}] Error: Script function \"{1}\" is already added. We do not support overloading.",
103 Name, mi.Name);
104 }
105 }
106 }
107
108 }
109} \ No newline at end of file