From 17275f3ab7db6bbcea54c1e88eb05664189af0a6 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 28 Jun 2007 08:35:41 +0000 Subject: [PATCH] * More removing stuff. Tortoise SVN I hate you. --- .../Scenes/scripting/CSharpScriptEngine.cs | 77 ------------------- .../OpenSim.Region/Scenes/scripting/Script.cs | 44 ----------- .../Scenes/scripting/ScriptInfo.cs | 31 -------- .../Scenes/scripting/ScriptManager.cs | 66 ---------------- 4 files changed, 218 deletions(-) delete mode 100644 OpenSim/OpenSim.Region/Scenes/scripting/CSharpScriptEngine.cs delete mode 100644 OpenSim/OpenSim.Region/Scenes/scripting/Script.cs delete mode 100644 OpenSim/OpenSim.Region/Scenes/scripting/ScriptInfo.cs delete mode 100644 OpenSim/OpenSim.Region/Scenes/scripting/ScriptManager.cs diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/CSharpScriptEngine.cs b/OpenSim/OpenSim.Region/Scenes/scripting/CSharpScriptEngine.cs deleted file mode 100644 index d5622b8cd8..0000000000 --- a/OpenSim/OpenSim.Region/Scenes/scripting/CSharpScriptEngine.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -// Compilation stuff -using System.CodeDom; -using System.CodeDom.Compiler; -using Microsoft.CSharp; - -namespace OpenSim.Scripting -{ - public class CSharpScriptEngine : IScriptCompiler - { - public string fileExt() - { - return ".cs"; - } - - private Dictionary LoadDotNetScript(ICodeCompiler compiler, string filename) - { - CompilerParameters compilerParams = new CompilerParameters(); - CompilerResults compilerResults; - compilerParams.GenerateExecutable = false; - compilerParams.GenerateInMemory = true; - compilerParams.IncludeDebugInformation = false; - compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll"); - compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll"); - compilerParams.ReferencedAssemblies.Add("libsecondlife.dll"); - compilerParams.ReferencedAssemblies.Add("System.dll"); - - compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename); - - if (compilerResults.Errors.Count > 0) - { - OpenSim.Framework.Console.MainLog.Instance.Error("Compile errors"); - foreach (CompilerError error in compilerResults.Errors) - { - OpenSim.Framework.Console.MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString()); - } - } - else - { - Dictionary scripts = new Dictionary(); - - foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes()) - { - Type testInterface = pluginType.GetInterface("IScript", true); - - if (testInterface != null) - { - IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); - - string scriptName = "C#/" + script.getName(); - Console.WriteLine("Script: " + scriptName + " loaded."); - - if (!scripts.ContainsKey(scriptName)) - { - scripts.Add(scriptName, script); - } - else - { - scripts[scriptName] = script; - } - } - } - return scripts; - } - return null; - } - - public Dictionary compile(string filename) - { - CSharpCodeProvider csharpProvider = new CSharpCodeProvider(); - return LoadDotNetScript(csharpProvider.CreateCompiler(), filename); - } - } -} diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/Script.cs b/OpenSim/OpenSim.Region/Scenes/scripting/Script.cs deleted file mode 100644 index 57390bc7b4..0000000000 --- a/OpenSim/OpenSim.Region/Scenes/scripting/Script.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using OpenSim.Framework.Console; -using OpenSim.Framework; -using OpenSim.Region; -using OpenSim.Region.Scenes; - -namespace OpenSim.Scripting -{ - public interface IScript - { - void Initialise(ScriptInfo scriptInfo); - string getName(); - } - - public class TestScript : IScript - { - ScriptInfo script; - - public string getName() - { - return "TestScript 0.1"; - } - - public void Initialise(ScriptInfo scriptInfo) - { - script = scriptInfo; - script.events.OnFrame += new OpenSim.Region.Scenes.EventManager.OnFrameDelegate(events_OnFrame); - script.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence); - } - - void events_OnNewPresence(ScenePresence presence) - { - script.logger.Verbose("Hello " + presence.firstname.ToString() + "!"); - } - - void events_OnFrame() - { - //script.logger.Verbose("Hello World!"); - } - } -} diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/ScriptInfo.cs b/OpenSim/OpenSim.Region/Scenes/scripting/ScriptInfo.cs deleted file mode 100644 index a9fede5739..0000000000 --- a/OpenSim/OpenSim.Region/Scenes/scripting/ScriptInfo.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using OpenSim.Region.Scenes; -using OpenSim.Framework.Console; - -namespace OpenSim.Scripting -{ - /// - /// Class which provides access to the world - /// - public class ScriptInfo - { - // Reference to world.eventsManager provided for convenience - public EventManager events; - - // The main world - public Scene world; - - // The console - public LogBase logger; - - public ScriptInfo(Scene scene) - { - world = scene; - events = world.eventManager; - logger = OpenSim.Framework.Console.MainLog.Instance; - } - } -} diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/ScriptManager.cs b/OpenSim/OpenSim.Region/Scenes/scripting/ScriptManager.cs deleted file mode 100644 index ff5c11517f..0000000000 --- a/OpenSim/OpenSim.Region/Scenes/scripting/ScriptManager.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Scripting -{ - public class ScriptManager - { - List scripts = new List(); - OpenSim.Region.Scenes.Scene scene; - Dictionary compilers = new Dictionary(); - - private void LoadFromCompiler(Dictionary compiledscripts) - { - foreach (KeyValuePair script in compiledscripts) - { - ScriptInfo scriptInfo = new ScriptInfo(scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. - OpenSim.Framework.Console.MainLog.Instance.Verbose("Loading " + script.Key); - script.Value.Initialise(scriptInfo); - scripts.Add(script.Value); - } - OpenSim.Framework.Console.MainLog.Instance.Verbose("Finished loading " + compiledscripts.Count.ToString() + " script(s)"); - } - - public ScriptManager(OpenSim.Region.Scenes.Scene world) - { - scene = world; - - // Defualt Engines - CSharpScriptEngine csharpCompiler = new CSharpScriptEngine(); - compilers.Add(csharpCompiler.fileExt(),csharpCompiler); - } - - public void Compile(string filename) - { - foreach (KeyValuePair compiler in compilers) - { - if (filename.EndsWith(compiler.Key)) - { - LoadFromCompiler(compiler.Value.compile(filename)); - break; - } - } - } - - public void RunScriptCmd(string[] args) - { - switch (args[0]) - { - case "load": - Compile(args[1]); - break; - - default: - OpenSim.Framework.Console.MainLog.Instance.Error("Unknown script command"); - break; - } - } - } - - interface IScriptCompiler - { - Dictionary compile(string filename); - string fileExt(); - } -}