diff --git a/OpenSim/Region/ScriptEngine/Common/Executor.cs b/OpenSim/Region/ScriptEngine/Common/Executor.cs new file mode 100644 index 0000000000..2ae6a60a18 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Common/Executor.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.ScriptEngine.Common +{ + class Executor + { + } +} diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs index 435ee08895..ad2717cf18 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 string rootPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); string rootPathSE = Path.GetDirectoryName(this.GetType().Assembly.Location); - Console.WriteLine("Assembly location: " + rootPath); + //Console.WriteLine("Assembly location: " + rootPath); parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Common.dll")); parameters.ReferencedAssemblies.Add(Path.Combine(rootPathSE, "OpenSim.Region.ScriptEngine.DotNetEngine.dll")); diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs index 84fa9eb65f..7334e6fb24 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; using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler; using OpenSim.Region.ScriptEngine.Common; using System.Threading; +using System.Reflection; + namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL { @@ -46,6 +48,33 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL return; } + public void ExecuteEvent(string FunctionName, object[] args) + { + //foreach (MemberInfo mi in this.GetType().GetMembers()) + //{ + //if (mi.ToString().ToLower().Contains("default")) + //{ + // Console.WriteLine("Member found: " + mi.ToString()); + //} + //} + + Type type = this.GetType(); + + Console.WriteLine("ScriptEngine Invoke: \"" + this.State() + "_event_" + FunctionName + "\""); + + try + { + type.InvokeMember(this.State() + "_event_" + FunctionName, BindingFlags.InvokeMethod, null, this, args); + } + catch (Exception e) + { + // TODO: Send to correct place + Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString()); + } + + + } + // diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index 8e0b2771dc..602ac9fa56 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs @@ -226,96 +226,102 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine { //LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CreateInstanceAndUnwrap(FileName, "SecondLife.Script"); - Console.WriteLine("Base directory: " + AppDomain.CurrentDomain.BaseDirectory); + //Console.WriteLine("Base directory: " + AppDomain.CurrentDomain.BaseDirectory); - //LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); - LSL_BuiltIn_Commands_Interface mbrt = (LSL_BuiltIn_Commands_Interface)FreeAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); + LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); + //LSL_BuiltIn_Commands_Interface mbrt = (LSL_BuiltIn_Commands_Interface)FreeAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); Type mytype = mbrt.GetType(); Console.WriteLine("is proxy={0}", RemotingServices.IsTransparentProxy(mbrt)); //mbrt.Start(); - return (LSL_BaseClass)mbrt; + return mbrt; + //return (LSL_BaseClass)mbrt; - //myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager Loading Assembly " + FileName); - // Load .Net Assembly (.dll) - // Initialize and return it +// //myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager Loading Assembly " + FileName); +// // Load .Net Assembly (.dll) +// // Initialize and return it - // TODO: Add error handling - // Script might not follow our rules since users can upload -anything- +// // TODO: Add error handling +// // Script might not follow our rules since users can upload -anything- - Assembly a; - //try - //{ +// Assembly a; +// //try +// //{ - // Load to default appdomain (temporary) - a = Assembly.LoadFrom(FileName); - // Load to specified appdomain - // TODO: Insert security - //a = FreeAppDomain.Load(FileName); - //} - //catch (Exception e) - //{ - //} +// // Load to default appdomain (temporary) +// a = Assembly.LoadFrom(FileName); +// // Load to specified appdomain +// // TODO: Insert security +// //a = FreeAppDomain.Load(FileName); +// //} +// //catch (Exception e) +// //{ +// //} - //foreach (Type _t in a.GetTypes()) - //{ - // Console.WriteLine("Type: " + _t.ToString()); - //} +// //foreach (Type _t in a.GetTypes()) +// //{ +// // Console.WriteLine("Type: " + _t.ToString()); +// //} - Type t; - //try - //{ - t = a.GetType("SecondLife.Script", true); - //} - //catch (Exception e) - //{ - //} +// Type t; +// //try +// //{ +// t = a.GetType("SecondLife.Script", true); +// //} +// //catch (Exception e) +// //{ +// //} - // Create constructor arguments - object[] args = new object[] - { -// this, -// host - }; +// // Create constructor arguments +// object[] args = new object[] +// { +//// this, +//// host +// }; - return (OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass)Activator.CreateInstance(t, args ); +// return (OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass)Activator.CreateInstance(t, args ); } internal void ExecuteFunction(IScriptHost ObjectID, string ScriptID, string FunctionName, object[] args) { + + // Execute a function in the script m_scriptEngine.Log.Verbose("ScriptEngine", "Executing Function ObjectID: " + ObjectID + ", ScriptID: " + ScriptID + ", FunctionName: " + FunctionName); OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script = m_scriptEngine.myScriptManager.GetScript(ObjectID, ScriptID); - Type type = Script.GetType(); + Script.ExecuteEvent(FunctionName, args); + + //Type type = Script.GetType(); - m_scriptEngine.Log.Verbose("ScriptEngine", "Invoke: \"" + Script.State() + "_event_" + FunctionName + "\""); + ////foreach (MemberInfo mi in type.GetMembers()) + ////{ + //// Common.SendToDebug("Member found: " + mi.ToString()); + ////} - try - { - type.InvokeMember(Script.State() + "_event_" + FunctionName, BindingFlags.InvokeMethod, null, Script, args); - } - catch (Exception e) - { - m_scriptEngine.Log.Error("ScriptEngine", "Exception attempting to executing script function: " + e.ToString()); - } + //m_scriptEngine.Log.Verbose("ScriptEngine", "Invoke: \"" + Script.State() + "_event_" + FunctionName + "\""); - - //foreach (MemberInfo mi in type.GetMembers()) + //try //{ - // Common.SendToDebug("Member found: " + mi.ToString()); + // type.InvokeMember(Script.State() + "_event_" + FunctionName, BindingFlags.InvokeMethod, null, Script, args); //} + //catch (Exception e) + //{ + // m_scriptEngine.Log.Error("ScriptEngine", "Exception attempting to executing script function: " + e.ToString()); + //} + + }