From 1d41fd4984308a4b811f40aca18a90a79f243020 Mon Sep 17 00:00:00 2001 From: Tedd Hansen Date: Sat, 18 Aug 2007 19:54:04 +0000 Subject: Working on AppDomains. Scripting is now officially broken. :] --- .../Common/LSL_BuiltIn_Commands_Interface.cs | 2 ++ .../ScriptEngine/Common/Properties/AssemblyInfo.cs | 33 +++++++++++++++++++++ .../DotNetEngine/Compiler/LSL/Compiler.cs | 11 ++++--- .../DotNetEngine/Compiler/LSL/LSL2CSConverter.cs | 2 +- .../DotNetEngine/Compiler/LSL/LSL_BaseClass.cs | 11 +++---- .../Compiler/Server_API/LSL_BuiltIn_Commands.cs | 6 ++-- .../ScriptEngine/DotNetEngine/MarshalByRefType.cs | 34 ---------------------- .../ScriptEngine/DotNetEngine/ScriptManager.cs | 25 +++++++--------- 8 files changed, 64 insertions(+), 60 deletions(-) create mode 100644 OpenSim/Region/ScriptEngine/Common/Properties/AssemblyInfo.cs delete mode 100644 OpenSim/Region/ScriptEngine/DotNetEngine/MarshalByRefType.cs (limited to 'OpenSim/Region/ScriptEngine') diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs index 58ade0b..c56ff2f 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs @@ -34,6 +34,8 @@ namespace OpenSim.Region.ScriptEngine.Common { public interface LSL_BuiltIn_Commands_Interface { + string State(); + double llSin(double f); double llCos(double f); double llTan(double f); diff --git a/OpenSim/Region/ScriptEngine/Common/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/Common/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..def3910 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Common/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Region.ScriptEngine.Common")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OpenSim.Region.ScriptEngine.Common")] +[assembly: AssemblyCopyright("Copyright © 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("0bf07c53-ae51-487f-a907-e9b30c251602")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs index 6e992be..4c2ceb0 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs @@ -52,10 +52,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters(); parameters.IncludeDebugInformation = true; // Add all available assemblies - foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) - { - parameters.ReferencedAssemblies.Add(asm.Location); - } + //foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) + //{ + // Console.WriteLine("Adding assembly: " + asm.Location); + // parameters.ReferencedAssemblies.Add(asm.Location); + //} + + parameters.ReferencedAssemblies.Add(this.GetType().Assembly.CodeBase); //parameters.ReferencedAssemblies.Add("OpenSim.Region.Environment"); parameters.GenerateExecutable = false; parameters.OutputAssembly = OutFile; diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs index 2427cc2..81f8e2d 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs @@ -228,7 +228,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL // Add namespace, class name and inheritance Return = "namespace SecondLife {\r\n"; - Return += "public class Script : OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass {\r\n"; + Return += "[Serializable] public class Script : OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass {\r\n"; Return += @"public Script() { }"+"\r\n"; Return += Script; Return += "} }\r\n"; diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs index bdae95d..eb3d871 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs @@ -7,21 +7,22 @@ using System.Threading; namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL { - public class LSL_BaseClass : MarshalByRefObject, LSL_BuiltIn_Commands_Interface + [Serializable] + public class LSL_BaseClass : LSL_BuiltIn_Commands_Interface { - public LSL_BuiltIn_Commands m_LSL_Functions; + public LSL_BuiltIn_Commands_Interface m_LSL_Functions; public LSL_BaseClass() { } - public string State + public string State() { - get { return m_LSL_Functions.State; } + return m_LSL_Functions.State(); } - public void Start(LSL_BuiltIn_Commands LSL_Functions) + public void Start(LSL_BuiltIn_Commands_Interface LSL_Functions) { m_LSL_Functions = LSL_Functions; diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs index 8c2e799..6401163 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs @@ -14,7 +14,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler /// /// Contains all LSL ll-functions. This class will be in Default AppDomain. /// - [Serializable] public class LSL_BuiltIn_Commands: LSL_BuiltIn_Commands_Interface { private System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); @@ -30,7 +29,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler } - public string State = "default"; + private string m_state = "default"; + public string State() { + return m_state; + } public Scene World { diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/MarshalByRefType.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/MarshalByRefType.cs deleted file mode 100644 index 36bb146..0000000 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/MarshalByRefType.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; - -namespace OpenSim.Region.ScriptEngine.DotNetEngine -{ - // Because this class is derived from MarshalByRefObject, a proxy - // to a MarshalByRefType object can be returned across an AppDomain - // boundary. - public class MarshalByRefType : MarshalByRefObject - { - // Call this method via a proxy. - public void SomeMethod(string callingDomainName) - { - // Get this AppDomain's settings and display some of them. - AppDomainSetup ads = AppDomain.CurrentDomain.SetupInformation; - Console.WriteLine("AppName={0}, AppBase={1}, ConfigFile={2}", - ads.ApplicationName, - ads.ApplicationBase, - ads.ConfigurationFile - ); - - // Display the name of the calling AppDomain and the name - // of the second domain. - // NOTE: The application's thread has transitioned between - // AppDomains. - Console.WriteLine("Calling from '{0}' to '{1}'.", - callingDomainName, - Thread.GetDomain().FriendlyName - ); - } - } -} diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index 1d2689d..2cbdfd3 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs @@ -65,6 +65,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine // Object> + // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. + // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! internal Dictionary> Scripts = new Dictionary>(); public Scene World { @@ -221,23 +223,18 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine /// private OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass LoadAndInitAssembly(AppDomain FreeAppDomain, string FileName, IScriptHost host) { - //object[] ADargs = new object[] - // { - // this, - // host - // }; - ////LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CreateInstanceAndUnwrap(FileName, "SecondLife.Script"); - //Console.WriteLine("Base directory: " + AppDomain.CurrentDomain.BaseDirectory); + //LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CreateInstanceAndUnwrap(FileName, "SecondLife.Script"); + Console.WriteLine("Base directory: " + AppDomain.CurrentDomain.BaseDirectory); - //LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); - //Type mytype = mbrt.GetType(); + LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); + Type mytype = mbrt.GetType(); - //Console.WriteLine("is proxy={0}", RemotingServices.IsTransparentProxy(mbrt)); + Console.WriteLine("is proxy={0}", RemotingServices.IsTransparentProxy(mbrt)); - ////mbrt.Start(); - //return mbrt; + //mbrt.Start(); + return mbrt; @@ -301,11 +298,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine Type type = Script.GetType(); - m_scriptEngine.Log.Verbose("ScriptEngine", "Invoke: \"" + Script.State + "_event_" + FunctionName + "\""); + m_scriptEngine.Log.Verbose("ScriptEngine", "Invoke: \"" + Script.State() + "_event_" + FunctionName + "\""); try { - type.InvokeMember(Script.State + "_event_" + FunctionName, BindingFlags.InvokeMethod, null, Script, args); + type.InvokeMember(Script.State() + "_event_" + FunctionName, BindingFlags.InvokeMethod, null, Script, args); } catch (Exception e) { -- cgit v1.1