aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAdam Frisby2007-06-28 08:35:41 +0000
committerAdam Frisby2007-06-28 08:35:41 +0000
commit17275f3ab7db6bbcea54c1e88eb05664189af0a6 (patch)
tree99fcea504aa969d39b83d44ba00d7b24b20e0719
parent* Removing stuff piecemeal since Tortoise SVN blows. (diff)
downloadopensim-SC_OLD-17275f3ab7db6bbcea54c1e88eb05664189af0a6.zip
opensim-SC_OLD-17275f3ab7db6bbcea54c1e88eb05664189af0a6.tar.gz
opensim-SC_OLD-17275f3ab7db6bbcea54c1e88eb05664189af0a6.tar.bz2
opensim-SC_OLD-17275f3ab7db6bbcea54c1e88eb05664189af0a6.tar.xz
* More removing stuff. Tortoise SVN I hate you.
Diffstat (limited to '')
-rw-r--r--OpenSim/OpenSim.Region/Scenes/scripting/CSharpScriptEngine.cs77
-rw-r--r--OpenSim/OpenSim.Region/Scenes/scripting/Script.cs44
-rw-r--r--OpenSim/OpenSim.Region/Scenes/scripting/ScriptInfo.cs31
-rw-r--r--OpenSim/OpenSim.Region/Scenes/scripting/ScriptManager.cs66
4 files changed, 0 insertions, 218 deletions
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/CSharpScriptEngine.cs b/OpenSim/OpenSim.Region/Scenes/scripting/CSharpScriptEngine.cs
deleted file mode 100644
index d5622b8..0000000
--- a/OpenSim/OpenSim.Region/Scenes/scripting/CSharpScriptEngine.cs
+++ /dev/null
@@ -1,77 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5// Compilation stuff
6using System.CodeDom;
7using System.CodeDom.Compiler;
8using Microsoft.CSharp;
9
10namespace OpenSim.Scripting
11{
12 public class CSharpScriptEngine : IScriptCompiler
13 {
14 public string fileExt()
15 {
16 return ".cs";
17 }
18
19 private Dictionary<string,IScript> LoadDotNetScript(ICodeCompiler compiler, string filename)
20 {
21 CompilerParameters compilerParams = new CompilerParameters();
22 CompilerResults compilerResults;
23 compilerParams.GenerateExecutable = false;
24 compilerParams.GenerateInMemory = true;
25 compilerParams.IncludeDebugInformation = false;
26 compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll");
27 compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll");
28 compilerParams.ReferencedAssemblies.Add("libsecondlife.dll");
29 compilerParams.ReferencedAssemblies.Add("System.dll");
30
31 compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename);
32
33 if (compilerResults.Errors.Count > 0)
34 {
35 OpenSim.Framework.Console.MainLog.Instance.Error("Compile errors");
36 foreach (CompilerError error in compilerResults.Errors)
37 {
38 OpenSim.Framework.Console.MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString());
39 }
40 }
41 else
42 {
43 Dictionary<string,IScript> scripts = new Dictionary<string,IScript>();
44
45 foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes())
46 {
47 Type testInterface = pluginType.GetInterface("IScript", true);
48
49 if (testInterface != null)
50 {
51 IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
52
53 string scriptName = "C#/" + script.getName();
54 Console.WriteLine("Script: " + scriptName + " loaded.");
55
56 if (!scripts.ContainsKey(scriptName))
57 {
58 scripts.Add(scriptName, script);
59 }
60 else
61 {
62 scripts[scriptName] = script;
63 }
64 }
65 }
66 return scripts;
67 }
68 return null;
69 }
70
71 public Dictionary<string,IScript> compile(string filename)
72 {
73 CSharpCodeProvider csharpProvider = new CSharpCodeProvider();
74 return LoadDotNetScript(csharpProvider.CreateCompiler(), filename);
75 }
76 }
77}
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/Script.cs b/OpenSim/OpenSim.Region/Scenes/scripting/Script.cs
deleted file mode 100644
index 57390bc..0000000
--- a/OpenSim/OpenSim.Region/Scenes/scripting/Script.cs
+++ /dev/null
@@ -1,44 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5using OpenSim.Framework.Console;
6using OpenSim.Framework;
7using OpenSim.Region;
8using OpenSim.Region.Scenes;
9
10namespace OpenSim.Scripting
11{
12 public interface IScript
13 {
14 void Initialise(ScriptInfo scriptInfo);
15 string getName();
16 }
17
18 public class TestScript : IScript
19 {
20 ScriptInfo script;
21
22 public string getName()
23 {
24 return "TestScript 0.1";
25 }
26
27 public void Initialise(ScriptInfo scriptInfo)
28 {
29 script = scriptInfo;
30 script.events.OnFrame += new OpenSim.Region.Scenes.EventManager.OnFrameDelegate(events_OnFrame);
31 script.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence);
32 }
33
34 void events_OnNewPresence(ScenePresence presence)
35 {
36 script.logger.Verbose("Hello " + presence.firstname.ToString() + "!");
37 }
38
39 void events_OnFrame()
40 {
41 //script.logger.Verbose("Hello World!");
42 }
43 }
44}
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/ScriptInfo.cs b/OpenSim/OpenSim.Region/Scenes/scripting/ScriptInfo.cs
deleted file mode 100644
index a9fede5..0000000
--- a/OpenSim/OpenSim.Region/Scenes/scripting/ScriptInfo.cs
+++ /dev/null
@@ -1,31 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5using OpenSim.Region.Scenes;
6using OpenSim.Framework.Console;
7
8namespace OpenSim.Scripting
9{
10 /// <summary>
11 /// Class which provides access to the world
12 /// </summary>
13 public class ScriptInfo
14 {
15 // Reference to world.eventsManager provided for convenience
16 public EventManager events;
17
18 // The main world
19 public Scene world;
20
21 // The console
22 public LogBase logger;
23
24 public ScriptInfo(Scene scene)
25 {
26 world = scene;
27 events = world.eventManager;
28 logger = OpenSim.Framework.Console.MainLog.Instance;
29 }
30 }
31}
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/ScriptManager.cs b/OpenSim/OpenSim.Region/Scenes/scripting/ScriptManager.cs
deleted file mode 100644
index ff5c115..0000000
--- a/OpenSim/OpenSim.Region/Scenes/scripting/ScriptManager.cs
+++ /dev/null
@@ -1,66 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Scripting
6{
7 public class ScriptManager
8 {
9 List<IScript> scripts = new List<IScript>();
10 OpenSim.Region.Scenes.Scene scene;
11 Dictionary<string, IScriptCompiler> compilers = new Dictionary<string, IScriptCompiler>();
12
13 private void LoadFromCompiler(Dictionary<string, IScript> compiledscripts)
14 {
15 foreach (KeyValuePair<string, IScript> script in compiledscripts)
16 {
17 ScriptInfo scriptInfo = new ScriptInfo(scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script.
18 OpenSim.Framework.Console.MainLog.Instance.Verbose("Loading " + script.Key);
19 script.Value.Initialise(scriptInfo);
20 scripts.Add(script.Value);
21 }
22 OpenSim.Framework.Console.MainLog.Instance.Verbose("Finished loading " + compiledscripts.Count.ToString() + " script(s)");
23 }
24
25 public ScriptManager(OpenSim.Region.Scenes.Scene world)
26 {
27 scene = world;
28
29 // Defualt Engines
30 CSharpScriptEngine csharpCompiler = new CSharpScriptEngine();
31 compilers.Add(csharpCompiler.fileExt(),csharpCompiler);
32 }
33
34 public void Compile(string filename)
35 {
36 foreach (KeyValuePair<string, IScriptCompiler> compiler in compilers)
37 {
38 if (filename.EndsWith(compiler.Key))
39 {
40 LoadFromCompiler(compiler.Value.compile(filename));
41 break;
42 }
43 }
44 }
45
46 public void RunScriptCmd(string[] args)
47 {
48 switch (args[0])
49 {
50 case "load":
51 Compile(args[1]);
52 break;
53
54 default:
55 OpenSim.Framework.Console.MainLog.Instance.Error("Unknown script command");
56 break;
57 }
58 }
59 }
60
61 interface IScriptCompiler
62 {
63 Dictionary<string,IScript> compile(string filename);
64 string fileExt();
65 }
66}