aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/DotNetEngine
diff options
context:
space:
mode:
authorTedd Hansen2007-08-18 22:09:07 +0000
committerTedd Hansen2007-08-18 22:09:07 +0000
commit240712ca9fc726653e2a03b944baa8b6f8155b07 (patch)
tree6fd919d0983ba3d108aee5adeec0a9a751dff760 /OpenSim/Region/ScriptEngine/DotNetEngine
parentScript loads into separate AppDomain without errors. Events and llFunctions n... (diff)
downloadopensim-SC-240712ca9fc726653e2a03b944baa8b6f8155b07.zip
opensim-SC-240712ca9fc726653e2a03b944baa8b6f8155b07.tar.gz
opensim-SC-240712ca9fc726653e2a03b944baa8b6f8155b07.tar.bz2
opensim-SC-240712ca9fc726653e2a03b944baa8b6f8155b07.tar.xz
Scripts are working again. Scripts are now loaded into limited AppDomains (no security yet).
*phew* that only took me 12 hours of coding...
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs29
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs110
3 files changed, 88 insertions, 53 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs
index 435ee08..ad2717c 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs
@@ -61,7 +61,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
61 61
62 string rootPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); 62 string rootPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
63 string rootPathSE = Path.GetDirectoryName(this.GetType().Assembly.Location); 63 string rootPathSE = Path.GetDirectoryName(this.GetType().Assembly.Location);
64 Console.WriteLine("Assembly location: " + rootPath); 64 //Console.WriteLine("Assembly location: " + rootPath);
65 parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Common.dll")); 65 parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Common.dll"));
66 parameters.ReferencedAssemblies.Add(Path.Combine(rootPathSE, "OpenSim.Region.ScriptEngine.DotNetEngine.dll")); 66 parameters.ReferencedAssemblies.Add(Path.Combine(rootPathSE, "OpenSim.Region.ScriptEngine.DotNetEngine.dll"));
67 67
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs
index 84fa9eb..7334e6f 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs
@@ -4,6 +4,8 @@ using System.Text;
4using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler; 4using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler;
5using OpenSim.Region.ScriptEngine.Common; 5using OpenSim.Region.ScriptEngine.Common;
6using System.Threading; 6using System.Threading;
7using System.Reflection;
8
7 9
8namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL 10namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
9{ 11{
@@ -46,6 +48,33 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
46 return; 48 return;
47 } 49 }
48 50
51 public void ExecuteEvent(string FunctionName, object[] args)
52 {
53 //foreach (MemberInfo mi in this.GetType().GetMembers())
54 //{
55 //if (mi.ToString().ToLower().Contains("default"))
56 //{
57 // Console.WriteLine("Member found: " + mi.ToString());
58 //}
59 //}
60
61 Type type = this.GetType();
62
63 Console.WriteLine("ScriptEngine Invoke: \"" + this.State() + "_event_" + FunctionName + "\"");
64
65 try
66 {
67 type.InvokeMember(this.State() + "_event_" + FunctionName, BindingFlags.InvokeMethod, null, this, args);
68 }
69 catch (Exception e)
70 {
71 // TODO: Send to correct place
72 Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString());
73 }
74
75
76 }
77
49 78
50 79
51 // 80 //
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
index 8e0b277..602ac9f 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
@@ -226,97 +226,103 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
226 { 226 {
227 227
228 //LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CreateInstanceAndUnwrap(FileName, "SecondLife.Script"); 228 //LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CreateInstanceAndUnwrap(FileName, "SecondLife.Script");
229 Console.WriteLine("Base directory: " + AppDomain.CurrentDomain.BaseDirectory); 229 //Console.WriteLine("Base directory: " + AppDomain.CurrentDomain.BaseDirectory);
230 230
231 //LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); 231 LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script");
232 LSL_BuiltIn_Commands_Interface mbrt = (LSL_BuiltIn_Commands_Interface)FreeAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); 232 //LSL_BuiltIn_Commands_Interface mbrt = (LSL_BuiltIn_Commands_Interface)FreeAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script");
233 Type mytype = mbrt.GetType(); 233 Type mytype = mbrt.GetType();
234 234
235 Console.WriteLine("is proxy={0}", RemotingServices.IsTransparentProxy(mbrt)); 235 Console.WriteLine("is proxy={0}", RemotingServices.IsTransparentProxy(mbrt));
236 236
237 237
238 //mbrt.Start(); 238 //mbrt.Start();
239 return (LSL_BaseClass)mbrt; 239 return mbrt;
240 //return (LSL_BaseClass)mbrt;
240 241
241 242
242 243
243 244
244 245
245 246
246 //myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager Loading Assembly " + FileName); 247// //myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager Loading Assembly " + FileName);
247 // Load .Net Assembly (.dll) 248// // Load .Net Assembly (.dll)
248 // Initialize and return it 249// // Initialize and return it
249 250
250 // TODO: Add error handling 251// // TODO: Add error handling
251 // Script might not follow our rules since users can upload -anything- 252// // Script might not follow our rules since users can upload -anything-
252 253
253 Assembly a; 254// Assembly a;
254 //try 255// //try
255 //{ 256// //{
256 257
257 258
258 // Load to default appdomain (temporary) 259// // Load to default appdomain (temporary)
259 a = Assembly.LoadFrom(FileName); 260// a = Assembly.LoadFrom(FileName);
260 // Load to specified appdomain 261// // Load to specified appdomain
261 // TODO: Insert security 262// // TODO: Insert security
262 //a = FreeAppDomain.Load(FileName); 263// //a = FreeAppDomain.Load(FileName);
263 //} 264// //}
264 //catch (Exception e) 265// //catch (Exception e)
265 //{ 266// //{
266 //} 267// //}
267 268
268 269
269 //foreach (Type _t in a.GetTypes()) 270// //foreach (Type _t in a.GetTypes())
270 //{ 271// //{
271 // Console.WriteLine("Type: " + _t.ToString()); 272// // Console.WriteLine("Type: " + _t.ToString());
272 //} 273// //}
273 274
274 Type t; 275// Type t;
275 //try 276// //try
276 //{ 277// //{
277 t = a.GetType("SecondLife.Script", true); 278// t = a.GetType("SecondLife.Script", true);
278 //} 279// //}
279 //catch (Exception e) 280// //catch (Exception e)
280 //{ 281// //{
281 //} 282// //}
282 283
283 // Create constructor arguments 284// // Create constructor arguments
284 object[] args = new object[] 285// object[] args = new object[]
285 { 286// {
286// this, 287//// this,
287// host 288//// host
288 }; 289// };
289 290
290 return (OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass)Activator.CreateInstance(t, args ); 291// return (OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass)Activator.CreateInstance(t, args );
291 292
292 293
293 } 294 }
294 295
295 internal void ExecuteFunction(IScriptHost ObjectID, string ScriptID, string FunctionName, object[] args) 296 internal void ExecuteFunction(IScriptHost ObjectID, string ScriptID, string FunctionName, object[] args)
296 { 297 {
298
299 // Execute a function in the script
297 m_scriptEngine.Log.Verbose("ScriptEngine", "Executing Function ObjectID: " + ObjectID + ", ScriptID: " + ScriptID + ", FunctionName: " + FunctionName); 300 m_scriptEngine.Log.Verbose("ScriptEngine", "Executing Function ObjectID: " + ObjectID + ", ScriptID: " + ScriptID + ", FunctionName: " + FunctionName);
298 OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script = m_scriptEngine.myScriptManager.GetScript(ObjectID, ScriptID); 301 OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script = m_scriptEngine.myScriptManager.GetScript(ObjectID, ScriptID);
299 302
300 Type type = Script.GetType(); 303 Script.ExecuteEvent(FunctionName, args);
301 304
305 //Type type = Script.GetType();
302 306
303 m_scriptEngine.Log.Verbose("ScriptEngine", "Invoke: \"" + Script.State() + "_event_" + FunctionName + "\"");
304 307
305 try 308 ////foreach (MemberInfo mi in type.GetMembers())
306 { 309 ////{
307 type.InvokeMember(Script.State() + "_event_" + FunctionName, BindingFlags.InvokeMethod, null, Script, args); 310 //// Common.SendToDebug("Member found: " + mi.ToString());
308 } 311 ////}
309 catch (Exception e)
310 {
311 m_scriptEngine.Log.Error("ScriptEngine", "Exception attempting to executing script function: " + e.ToString());
312 }
313 312
313 //m_scriptEngine.Log.Verbose("ScriptEngine", "Invoke: \"" + Script.State() + "_event_" + FunctionName + "\"");
314 314
315 //foreach (MemberInfo mi in type.GetMembers()) 315 //try
316 //{
317 // type.InvokeMember(Script.State() + "_event_" + FunctionName, BindingFlags.InvokeMethod, null, Script, args);
318 //}
319 //catch (Exception e)
316 //{ 320 //{
317 // Common.SendToDebug("Member found: " + mi.ToString()); 321 // m_scriptEngine.Log.Error("ScriptEngine", "Exception attempting to executing script function: " + e.ToString());
318 //} 322 //}
319 323
324
325
320 } 326 }
321 327
322 public string RegionName 328 public string RegionName