diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs | 110 |
1 files changed, 58 insertions, 52 deletions
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 |