From 00b7058e000d7871df2ae40075ead1042e8e81ac Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 11 Apr 2007 13:32:50 +0000 Subject: Attempt to rearrange some of the directories --- OpenSim.Scripting.EmbeddedJVM/OpenSimJVM.cs | 134 ---------------------------- 1 file changed, 134 deletions(-) delete mode 100644 OpenSim.Scripting.EmbeddedJVM/OpenSimJVM.cs (limited to 'OpenSim.Scripting.EmbeddedJVM/OpenSimJVM.cs') diff --git a/OpenSim.Scripting.EmbeddedJVM/OpenSimJVM.cs b/OpenSim.Scripting.EmbeddedJVM/OpenSimJVM.cs deleted file mode 100644 index b47bb50..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/OpenSimJVM.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.IO; -using System.Threading; -using OpenSim.Framework; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Utilities; - -namespace OpenSim.Scripting.EmbeddedJVM -{ - public class OpenSimJVM : IScriptEngine - { - private List _threads = new List(); - private BlockingQueue CompileScripts = new BlockingQueue(); - private MainMemory _mainMemory; - private System.Threading.Thread compileThread; - - public OpenSimJVM() - { - - } - - public bool Init(IScriptAPI api) - { - Console.WriteLine("Creating OpenSim JVM scripting engine"); - _mainMemory = new MainMemory(); - Thread.GlobalMemory = this._mainMemory; - Thread.OpenSimScriptAPI = api; - compileThread = new System.Threading.Thread(new ThreadStart(CompileScript)); - compileThread.IsBackground = true; - compileThread.Start(); - return true; - } - - public string GetName() - { - return "OpenSimJVM"; - } - - public void LoadScript(string script, string scriptName, uint entityID) - { - Console.WriteLine("OpenSimJVM - loading new script: " + scriptName); - CompileInfo comp = new CompileInfo(); - comp.entityId = entityID; - comp.script = script; - comp.scriptName = scriptName; - this.CompileScripts.Enqueue(comp); - } - - public void CompileScript() - { - while (true) - { - CompileInfo comp = this.CompileScripts.Dequeue(); - string script = comp.script; - string scriptName = comp.scriptName; - uint entityID = comp.entityId; - try - { - //need to compile the script into a java class file - - //first save it to a java source file - TextWriter tw = new StreamWriter(scriptName + ".java"); - tw.WriteLine(script); - tw.Close(); - - //now compile - System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("javac.exe", "*.java"); - // psi.RedirectStandardOutput = true; - psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; - psi.UseShellExecute = false; - - System.Diagnostics.Process javacomp; - javacomp = System.Diagnostics.Process.Start(psi); - javacomp.WaitForExit(); - - - //now load in class file - ClassRecord class1 = new ClassRecord(); - class1.LoadClassFromFile(scriptName + ".class"); - class1.PrintToConsole(); - //Console.WriteLine(); - this._mainMemory.MethodArea.Classes.Add(class1); - class1.AddMethodsToMemory(this._mainMemory.MethodArea); - - Thread newThread = new Thread(); - this._threads.Add(newThread); - newThread.EntityId = entityID; - newThread.currentClass = class1; - - //now delete the created files - System.IO.File.Delete(scriptName + ".java"); - System.IO.File.Delete(scriptName + ".class"); - //this.OnFrame(); - } - catch (Exception e) - { - Console.WriteLine("exception"); - Console.WriteLine(e.StackTrace); - Console.WriteLine(e.Message); - } - } - } - - public void OnFrame() - { - for (int i = 0; i < this._threads.Count; i++) - { - if (!this._threads[i].running) - { - this._threads[i].StartMethod("OnFrame"); - bool run = true; - while (run) - { - run = this._threads[i].Excute(); - } - } - } - } - - private class CompileInfo - { - public string script; - public string scriptName; - public uint entityId; - - public CompileInfo() - { - - } - } - } -} -- cgit v1.1