diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs | 63 |
1 files changed, 52 insertions, 11 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index f17711c..7155b09 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs | |||
@@ -31,8 +31,10 @@ using System.Collections.Generic; | |||
31 | using System.Text; | 31 | using System.Text; |
32 | using System.Threading; | 32 | using System.Threading; |
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using System.Runtime.Remoting; | ||
34 | using OpenSim.Region.Environment.Scenes; | 35 | using OpenSim.Region.Environment.Scenes; |
35 | using OpenSim.Region.Environment.Scenes.Scripting; | 36 | using OpenSim.Region.Environment.Scenes.Scripting; |
37 | using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL; | ||
36 | 38 | ||
37 | namespace OpenSim.Region.ScriptEngine.DotNetEngine | 39 | namespace OpenSim.Region.ScriptEngine.DotNetEngine |
38 | { | 40 | { |
@@ -41,6 +43,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
41 | /// Compiles them if necessary | 43 | /// Compiles them if necessary |
42 | /// Execute functions for EventQueueManager | 44 | /// Execute functions for EventQueueManager |
43 | /// </summary> | 45 | /// </summary> |
46 | [Serializable] | ||
44 | public class ScriptManager | 47 | public class ScriptManager |
45 | { | 48 | { |
46 | 49 | ||
@@ -49,6 +52,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
49 | { | 52 | { |
50 | m_scriptEngine = scriptEngine; | 53 | m_scriptEngine = scriptEngine; |
51 | m_scriptEngine.Log.Verbose("ScriptEngine", "ScriptManager Start"); | 54 | m_scriptEngine.Log.Verbose("ScriptEngine", "ScriptManager Start"); |
55 | AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); | ||
56 | } | ||
57 | |||
58 | private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) | ||
59 | { | ||
60 | |||
61 | Console.WriteLine("CurrentDomain_AssemblyResolve: " + args.Name); | ||
62 | return Assembly.GetExecutingAssembly().FullName == args.Name ? Assembly.GetExecutingAssembly() : null; | ||
63 | |||
52 | } | 64 | } |
53 | 65 | ||
54 | 66 | ||
@@ -158,13 +170,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
158 | FileName = ProcessYield(FileName); | 170 | FileName = ProcessYield(FileName); |
159 | 171 | ||
160 | // * Find next available AppDomain to put it in | 172 | // * Find next available AppDomain to put it in |
161 | AppDomain FreeAppDomain = GetFreeAppDomain(); | 173 | AppDomain FreeAppDomain = m_scriptEngine.myAppDomainManager.GetFreeAppDomain(); |
162 | 174 | ||
163 | // * Load and start script, for now with dummy host | 175 | // * Load and start script, for now with dummy host |
164 | 176 | ||
165 | //OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO.LSL_BaseClass Script = LoadAndInitAssembly(FreeAppDomain, FileName); | 177 | //OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO.LSL_BaseClass Script = LoadAndInitAssembly(FreeAppDomain, FileName); |
166 | 178 | ||
179 | //OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script = LoadAndInitAssembly(FreeAppDomain, FileName, ObjectID); | ||
167 | OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script = LoadAndInitAssembly(FreeAppDomain, FileName, ObjectID); | 180 | OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script = LoadAndInitAssembly(FreeAppDomain, FileName, ObjectID); |
181 | |||
168 | //string FullScriptID = ScriptID + "." + ObjectID; | 182 | //string FullScriptID = ScriptID + "." + ObjectID; |
169 | // Add it to our temporary active script keeper | 183 | // Add it to our temporary active script keeper |
170 | //Scripts.Add(FullScriptID, Script); | 184 | //Scripts.Add(FullScriptID, Script); |
@@ -175,8 +189,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
175 | 189 | ||
176 | // Start the script - giving it BuiltIns | 190 | // Start the script - giving it BuiltIns |
177 | //myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager initializing script, handing over private builtin command interface"); | 191 | //myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager initializing script, handing over private builtin command interface"); |
178 | 192 | ||
179 | Script.Start( ScriptID ); | 193 | Script.Start(new OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL_BuiltIn_Commands(this, ObjectID)); |
180 | 194 | ||
181 | } | 195 | } |
182 | catch (Exception e) | 196 | catch (Exception e) |
@@ -193,11 +207,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
193 | return FileName; | 207 | return FileName; |
194 | } | 208 | } |
195 | 209 | ||
196 | private AppDomain GetFreeAppDomain() | 210 | //private AppDomain GetFreeAppDomain() |
197 | { | 211 | //{ |
198 | // TODO: Find an available AppDomain - if none, create one and add default security | 212 | // // TODO: Find an available AppDomain - if none, create one and add default security |
199 | return Thread.GetDomain(); | 213 | // return Thread.GetDomain(); |
200 | } | 214 | //} |
201 | 215 | ||
202 | /// <summary> | 216 | /// <summary> |
203 | /// Does actual loading and initialization of script Assembly | 217 | /// Does actual loading and initialization of script Assembly |
@@ -207,6 +221,33 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
207 | /// <returns></returns> | 221 | /// <returns></returns> |
208 | private OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass LoadAndInitAssembly(AppDomain FreeAppDomain, string FileName, IScriptHost host) | 222 | private OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass LoadAndInitAssembly(AppDomain FreeAppDomain, string FileName, IScriptHost host) |
209 | { | 223 | { |
224 | //object[] ADargs = new object[] | ||
225 | // { | ||
226 | // this, | ||
227 | // host | ||
228 | // }; | ||
229 | |||
230 | ////LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CreateInstanceAndUnwrap(FileName, "SecondLife.Script"); | ||
231 | //Console.WriteLine("Base directory: " + AppDomain.CurrentDomain.BaseDirectory); | ||
232 | |||
233 | //LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); | ||
234 | |||
235 | //Type mytype = mbrt.GetType(); | ||
236 | |||
237 | |||
238 | |||
239 | |||
240 | //Console.WriteLine("is proxy={0}", RemotingServices.IsTransparentProxy(mbrt)); | ||
241 | |||
242 | |||
243 | ////mbrt.Start(); | ||
244 | //return mbrt; | ||
245 | |||
246 | |||
247 | |||
248 | |||
249 | |||
250 | |||
210 | //myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager Loading Assembly " + FileName); | 251 | //myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager Loading Assembly " + FileName); |
211 | // Load .Net Assembly (.dll) | 252 | // Load .Net Assembly (.dll) |
212 | // Initialize and return it | 253 | // Initialize and return it |
@@ -242,13 +283,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
242 | //} | 283 | //} |
243 | //catch (Exception e) | 284 | //catch (Exception e) |
244 | //{ | 285 | //{ |
245 | //} | 286 | //} |
246 | 287 | ||
247 | // Create constructor arguments | 288 | // Create constructor arguments |
248 | object[] args = new object[] | 289 | object[] args = new object[] |
249 | { | 290 | { |
250 | this, | 291 | // this, |
251 | host | 292 | // host |
252 | }; | 293 | }; |
253 | 294 | ||
254 | return (OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass)Activator.CreateInstance(t, args ); | 295 | return (OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass)Activator.CreateInstance(t, args ); |