aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs
diff options
context:
space:
mode:
authorSean Dague2007-09-17 12:52:03 +0000
committerSean Dague2007-09-17 12:52:03 +0000
commitb8d9737a47696952bedec33dface8f18df47341f (patch)
tree9279f45510f8a9285ac5b9c9165ab6c741009eac /OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs
parentI think this is the last bits for a consistant pristine (diff)
downloadopensim-SC-b8d9737a47696952bedec33dface8f18df47341f.zip
opensim-SC-b8d9737a47696952bedec33dface8f18df47341f.tar.gz
opensim-SC-b8d9737a47696952bedec33dface8f18df47341f.tar.bz2
opensim-SC-b8d9737a47696952bedec33dface8f18df47341f.tar.xz
fixing me some line endings
Diffstat (limited to 'OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs')
-rw-r--r--OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs342
1 files changed, 171 insertions, 171 deletions
diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs
index 2abb3b7..5d4d4ab 100644
--- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs
+++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs
@@ -1,171 +1,171 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31using System.IO; 31using System.IO;
32using System.Threading; 32using System.Threading;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Interfaces; 34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Utilities; 35using OpenSim.Framework.Utilities;
36using OpenSim.Region.Environment.Scenes; 36using OpenSim.Region.Environment.Scenes;
37using OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM; 37using OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM;
38using Thread = OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM.Thread; 38using Thread = OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM.Thread;
39 39
40namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine 40namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine
41{ 41{
42 public class JVMScript : IScript 42 public class JVMScript : IScript
43 { 43 {
44 private List<Thread> _threads = new List<Thread>(); 44 private List<Thread> _threads = new List<Thread>();
45 private BlockingQueue<CompileInfo> CompileScripts = new BlockingQueue<CompileInfo>(); 45 private BlockingQueue<CompileInfo> CompileScripts = new BlockingQueue<CompileInfo>();
46 private MainMemory _mainMemory; 46 private MainMemory _mainMemory;
47 47
48 ScriptInfo scriptInfo; 48 ScriptInfo scriptInfo;
49 49
50 public void Initialise(ScriptInfo info) 50 public void Initialise(ScriptInfo info)
51 { 51 {
52 scriptInfo = info; 52 scriptInfo = info;
53 53
54 _mainMemory = new MainMemory(); 54 _mainMemory = new MainMemory();
55 Thread.GlobalMemory = this._mainMemory; 55 Thread.GlobalMemory = this._mainMemory;
56 Thread.World = info.world; 56 Thread.World = info.world;
57 CompileScript(); 57 CompileScript();
58 58
59 scriptInfo.events.OnFrame += new EventManager.OnFrameDelegate(events_OnFrame); 59 scriptInfo.events.OnFrame += new EventManager.OnFrameDelegate(events_OnFrame);
60 scriptInfo.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence); 60 scriptInfo.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence);
61 } 61 }
62 62
63 void events_OnNewPresence(ScenePresence presence) 63 void events_OnNewPresence(ScenePresence presence)
64 { 64 {
65 for (int i = 0; i < this._threads.Count; i++) 65 for (int i = 0; i < this._threads.Count; i++)
66 { 66 {
67 if (!this._threads[i].running) 67 if (!this._threads[i].running)
68 { 68 {
69 this._threads[i].StartMethod("OnNewPresence"); 69 this._threads[i].StartMethod("OnNewPresence");
70 bool run = true; 70 bool run = true;
71 while (run) 71 while (run)
72 { 72 {
73 run = this._threads[i].Excute(); 73 run = this._threads[i].Excute();
74 } 74 }
75 } 75 }
76 } 76 }
77 } 77 }
78 78
79 void events_OnFrame() 79 void events_OnFrame()
80 { 80 {
81 for (int i = 0; i < this._threads.Count; i++) 81 for (int i = 0; i < this._threads.Count; i++)
82 { 82 {
83 if (!this._threads[i].running) 83 if (!this._threads[i].running)
84 { 84 {
85 this._threads[i].StartMethod("OnFrame"); 85 this._threads[i].StartMethod("OnFrame");
86 bool run = true; 86 bool run = true;
87 while (run) 87 while (run)
88 { 88 {
89 run = this._threads[i].Excute(); 89 run = this._threads[i].Excute();
90 } 90 }
91 } 91 }
92 } 92 }
93 } 93 }
94 94
95 public string Name 95 public string Name
96 { 96 {
97 get { return "JVM Scripting Engine"; } 97 get { return "JVM Scripting Engine"; }
98 } 98 }
99 99
100 public void LoadScript(string script) 100 public void LoadScript(string script)
101 { 101 {
102 Console.WriteLine("OpenSimJVM - loading new script: " + script); 102 Console.WriteLine("OpenSimJVM - loading new script: " + script);
103 CompileInfo comp = new CompileInfo(); 103 CompileInfo comp = new CompileInfo();
104 comp.script = script; 104 comp.script = script;
105 comp.scriptName = script; 105 comp.scriptName = script;
106 this.CompileScripts.Enqueue(comp); 106 this.CompileScripts.Enqueue(comp);
107 } 107 }
108 108
109 public void CompileScript() 109 public void CompileScript()
110 { 110 {
111 CompileInfo comp = this.CompileScripts.Dequeue(); 111 CompileInfo comp = this.CompileScripts.Dequeue();
112 string script = comp.script; 112 string script = comp.script;
113 string scriptName = comp.scriptName; 113 string scriptName = comp.scriptName;
114 try 114 try
115 { 115 {
116 //need to compile the script into a java class file 116 //need to compile the script into a java class file
117 117
118 //first save it to a java source file 118 //first save it to a java source file
119 TextWriter tw = new StreamWriter(scriptName + ".java"); 119 TextWriter tw = new StreamWriter(scriptName + ".java");
120 tw.WriteLine(script); 120 tw.WriteLine(script);
121 tw.Close(); 121 tw.Close();
122 122
123 //now compile 123 //now compile
124 System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("javac.exe", "*.java"); 124 System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("javac.exe", "*.java");
125 // psi.RedirectStandardOutput = true; 125 // psi.RedirectStandardOutput = true;
126 psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; 126 psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
127 psi.UseShellExecute = false; 127 psi.UseShellExecute = false;
128 128
129 System.Diagnostics.Process javacomp; 129 System.Diagnostics.Process javacomp;
130 javacomp = System.Diagnostics.Process.Start(psi); 130 javacomp = System.Diagnostics.Process.Start(psi);
131 javacomp.WaitForExit(); 131 javacomp.WaitForExit();
132 132
133 133
134 //now load in class file 134 //now load in class file
135 ClassRecord class1 = new ClassRecord(); 135 ClassRecord class1 = new ClassRecord();
136 class1.LoadClassFromFile(scriptName + ".class"); 136 class1.LoadClassFromFile(scriptName + ".class");
137 class1.PrintToConsole(); 137 class1.PrintToConsole();
138 //Console.WriteLine(); 138 //Console.WriteLine();
139 this._mainMemory.MethodArea.Classes.Add(class1); 139 this._mainMemory.MethodArea.Classes.Add(class1);
140 class1.AddMethodsToMemory(this._mainMemory.MethodArea); 140 class1.AddMethodsToMemory(this._mainMemory.MethodArea);
141 141
142 Thread newThread = new Thread(); 142 Thread newThread = new Thread();
143 this._threads.Add(newThread); 143 this._threads.Add(newThread);
144 newThread.currentClass = class1; 144 newThread.currentClass = class1;
145 newThread.scriptInfo = scriptInfo; 145 newThread.scriptInfo = scriptInfo;
146 146
147 //now delete the created files 147 //now delete the created files
148 System.IO.File.Delete(scriptName + ".java"); 148 System.IO.File.Delete(scriptName + ".java");
149 System.IO.File.Delete(scriptName + ".class"); 149 System.IO.File.Delete(scriptName + ".class");
150 //this.OnFrame(); 150 //this.OnFrame();
151 } 151 }
152 catch (Exception e) 152 catch (Exception e)
153 { 153 {
154 Console.WriteLine("exception"); 154 Console.WriteLine("exception");
155 Console.WriteLine(e.StackTrace); 155 Console.WriteLine(e.StackTrace);
156 Console.WriteLine(e.Message); 156 Console.WriteLine(e.Message);
157 } 157 }
158 } 158 }
159 159
160 private class CompileInfo 160 private class CompileInfo
161 { 161 {
162 public string script; 162 public string script;
163 public string scriptName; 163 public string scriptName;
164 164
165 public CompileInfo() 165 public CompileInfo()
166 { 166 {
167 167
168 } 168 }
169 } 169 }
170 } 170 }
171} 171}