Removed the DotNetEngine scripting engine. You will need to create a fresh checkout or clean out all *DotNet*.dll assemblies from the bin/ directory to run OpenSim moving forward

This commit is contained in:
John Hurliman
2009-10-27 13:31:04 -07:00
parent fefe767476
commit 2525810e2a
37 changed files with 1 additions and 5907 deletions

View File

@@ -1,40 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.ScriptEngine.Shared;
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Commands_LSL
{
public class Commands_LSL : IScriptEngineComponent
{
}
}

View File

@@ -1,56 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using log4net;
using OpenSim.ScriptEngine.Shared;
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Commands_LSL
{
public class Script : IScriptCommandProvider
{
internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public void llSay(int channelID, string text)
{
m_log.InfoFormat("[{0}] llSay({1}, \"{2}\")", "(Commands_LSL)OpenSim.ScriptEngine.Components.DotNetEngine.Commands_LSL.Script", channelID, text);
}
public void ExecuteCommand(string functionName, params object[] args)
{
}
public string Name
{
get { return "SECS.DotNetEngine.Commands_LSL.Script"; }
}
}
}

View File

@@ -1,63 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
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.ScriptEngine.Components.DotNetEngine.Commands_LSL")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("http://opensimulator.org")]
[assembly: AssemblyProduct("OpenSim.ScriptEngine.Components.DotNetEngine.Commands_LSL")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
[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("ea77002b-c967-4368-ace9-6533f8147d4b")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("0.6.5.*")]
[assembly: AssemblyVersion("0.6.5.*")]
[assembly: AssemblyFileVersion("0.6.5.0")]

View File

@@ -1,44 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.ScriptEngine.Shared;
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Commands_OSSL
{
public class Commands_OSSL : IScriptEngineComponent
{
//private RegionInfoStructure CurrentRegion;
public void Initialize(RegionInfoStructure currentRegion)
{
//CurrentRegion = currentRegion;
}
}
}

View File

@@ -1,63 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
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.ScriptEngine.Components.DotNetEngine.Commands_OSSL")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("http://opensimulator.org")]
[assembly: AssemblyProduct("OpenSim.ScriptEngine.Components.DotNetEngine.Commands_OSSL")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
[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("ea77002b-c967-4368-ace9-6533f8147d4b")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("0.6.5.*")]
[assembly: AssemblyVersion("0.6.5.*")]
[assembly: AssemblyFileVersion("0.6.5.0")]

View File

@@ -1,187 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
using log4net;
using OpenSim.ScriptEngine.Shared;
using ScriptAssemblies;
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers
{
public abstract class CILCompiler
{
internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private string ScriptEnginesPath = "ScriptEngines";
private string Name { get { return "SECS.DotNetEngine.CILCompiler"; } }
private string m_scriptAssemblyName;
internal string ScriptAssemblyName { get { return m_scriptAssemblyName; } set { m_scriptAssemblyName = value; } }
// Default inherit
protected string ScriptInheritFrom = typeof(ScriptAssemblies.ScriptBase).Name;
private readonly System.Security.Cryptography.MD5CryptoServiceProvider MD5Sum = new System.Security.Cryptography.MD5CryptoServiceProvider();
protected CodeDomProvider CompileProvider;
//private string[] AppDomainAssemblies = new string[] { "OpenSim.Region.ScriptEngine.Shared.dll", "OpenSim.Region.ScriptEngine.Shared.Script.dll", "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll" };
private readonly string[] AppDomainAssemblies = new string[] {
Assembly.GetAssembly(typeof(Int32)).Location,
"OpenSim.ScriptEngine.Shared.dll",
"OpenSim.ScriptEngine.Shared.Script.dll",
Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine.Shared.dll")
};
public abstract string PreProcessScript(ref string script);
public CILCompiler()
{
}
private static readonly Regex FileNameFixer = new Regex(@"[^a-zA-Z0-9\.\-]", RegexOptions.Compiled | RegexOptions.Singleline);
public string Compile(ScriptMetaData data, ref string _script)
{
// Add "using", "inherit", default constructor, etc around script.
string script = PreProcessScript(ref _script);
// Get filename based on content
string md5Sum = System.Convert.ToBase64String(
MD5Sum.ComputeHash(
System.Text.Encoding.ASCII.GetBytes(script)
));
// Unique name for this assembly
ScriptAssemblyName = "SECS_Script_" + FileNameFixer.Replace(md5Sum, "_");
string OutFile = Path.Combine(ScriptEnginesPath, ScriptAssemblyName + ".dll");
// Make sure target dir exist
if (!Directory.Exists(ScriptEnginesPath))
try { Directory.CreateDirectory(ScriptEnginesPath); }
catch { }
// Already exist? No point in recompiling
if (File.Exists(OutFile))
return OutFile;
//
// Dump source code
//
string dumpFile = OutFile + ".txt";
try
{
if (File.Exists(dumpFile))
File.Delete(dumpFile);
File.WriteAllText(dumpFile, script);
}
catch (Exception e)
{
m_log.DebugFormat("[{0}] Exception trying to dump script source code to file \"{1}\": {2}", Name, dumpFile, e.ToString());
}
//
// COMPILE
//
CompilerParameters parameters = new CompilerParameters();
parameters.IncludeDebugInformation = true;
//string rootPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
foreach (string file in AppDomainAssemblies)
{
parameters.ReferencedAssemblies.Add(file);
m_log.DebugFormat("[{0}] Adding reference for compile: \"{1}\".", Name, file);
}
//lock (commandProvider)
//{
// foreach (string key in commandProvider.Keys)
// {
// IScriptCommandProvider cp = commandProvider[key];
// string
// file = cp.GetType().Assembly.Location;
// parameters.ReferencedAssemblies.Add(file);
// m_log.DebugFormat("[{0}] Loading command provider assembly \"{1}\" into AppDomain: \"{2}\".", Name,
// key, file);
// }
//}
parameters.GenerateExecutable = false;
parameters.OutputAssembly = OutFile;
parameters.IncludeDebugInformation = true;
//parameters.WarningLevel = 1; // Should be 4?
parameters.TreatWarningsAsErrors = false;
// Do compile
CompilerResults results = CompileProvider.CompileAssemblyFromSource(parameters, script);
//
// WARNINGS AND ERRORS
//
//TODO
int display = 5;
if (results.Errors.Count > 0)
{
string errtext = String.Empty;
foreach (CompilerError CompErr in results.Errors)
{
// Show 5 errors max
//
if (display <= 0)
break;
display--;
string severity = "Error";
if (CompErr.IsWarning)
severity = "Warning";
//TODO: Implement
KeyValuePair<int, int> lslPos = new KeyValuePair<int, int>();
//lslPos = "NOT IMPLEMENTED";// FindErrorPosition(CompErr.Line, CompErr.Column);
string text = CompErr.ErrorText;
// The Second Life viewer's script editor begins
// countingn lines and columns at 0, so we subtract 1.
errtext += String.Format("Line ({0},{1}): {4} {2}: {3}\n",
lslPos.Key - 1, lslPos.Value - 1,
CompErr.ErrorNumber, text, severity);
}
if (!File.Exists(OutFile))
{
throw new Exception(errtext);
}
}
// TODO: Process errors
return OutFile;
}
}
}

View File

@@ -1,70 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Text;
using Microsoft.CSharp;
using OpenSim.ScriptEngine.Shared;
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers
{
public class Compiler_CS : CILCompiler, IScriptCompiler
{
private string[] ScriptUsing = new string[]
{
"System",
"OpenSim.ScriptEngine.Shared",
"OpenSim.Region.ScriptEngine.Shared",
"System.Collections.Generic"
};
public Compiler_CS()
{
CompileProvider = new CSharpCodeProvider();
}
public override string PreProcessScript(ref string script)
{
string s = "";
foreach (string u in ScriptUsing)
{
s += "using " + u + ";";
}
s += "\r\n"
+ String.Empty + "namespace ScriptAssemblies { "
+ String.Empty + "public class UserScript" + " : " + ScriptInheritFrom + " { \r\n" +
@"public Script() { } " +
script +
"} }\r\n";
return s;
}
}
}

View File

@@ -1,56 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Text;
using Microsoft.JScript;
using OpenSim.ScriptEngine.Shared;
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers
{
public class Compiler_JS : CILCompiler, IScriptCompiler
{
public Compiler_JS()
{
CompileProvider = new JScriptCodeProvider() as CodeDomProvider;
}
public override string PreProcessScript(ref string script)
{
return
"import OpenSim.Region.ScriptEngine.Shared; import System.Collections.Generic;\r\n" +
"package SecondLife {\r\n" +
"class Script extends OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass { \r\n" +
script +
"} }\r\n";
}
}
}

View File

@@ -1,57 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using OpenSim.ScriptEngine.Components.DotNetEngine.Compilers.LSL;
using OpenSim.ScriptEngine.Shared;
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers
{
public class Compiler_LSL : IScriptCompiler
{
private readonly Compiler_CS m_Compiler_CS = new Compiler_CS();
private readonly LSL2CS m_LSL2CS = new LSL2CS();
public string Compile(ScriptMetaData scriptMetaData, ref string script)
{
// Convert script to CS
string scriptCS = m_LSL2CS.Convert(ref script);
// Use CS compiler to compile it
return m_Compiler_CS.Compile(scriptMetaData, ref scriptCS);
}
public string PreProcessScript(ref string script)
{
// This is handled by our converter
return script;
}
}
}

View File

@@ -1,56 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Text;
using Microsoft.VisualBasic;
using OpenSim.ScriptEngine.Shared;
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers
{
public class Compiler_VB : CILCompiler, IScriptCompiler
{
public Compiler_VB()
{
CompileProvider = new VBCodeProvider() as CodeDomProvider;
}
public override string PreProcessScript(ref string script)
{
return
"Imports OpenSim.Region.ScriptEngine.Shared: Imports System.Collections.Generic: " +
String.Empty + "NameSpace SecondLife:" +
String.Empty + "Public Class Script: Inherits OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass: " +
"\r\nPublic Sub New()\r\nEnd Sub: " +
script +
":End Class :End Namespace\r\n";
}
}
}

View File

@@ -1,55 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using OpenSim.ScriptEngine.Components.DotNetEngine.Compilers.YP;
using OpenSim.ScriptEngine.Shared;
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers
{
public class Compiler_YP: IScriptCompiler
{
private readonly Compiler_CS m_Compiler_CS = new Compiler_CS();
public string Compile(ScriptMetaData scriptMetaData, ref string script)
{
// Convert script to CS
string scriptCS = YP2CS.Convert(ref script);
// Use CS compiler to compile it
return m_Compiler_CS.Compile(scriptMetaData, ref scriptCS);
}
public string PreProcessScript(ref string script)
{
// This is handled by our converter
return script;
}
}
}

View File

@@ -1,44 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Region.ScriptEngine.Shared.CodeTools;
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers.LSL
{
public class LSL2CS
{
private ICodeConverter Converter = new CSCodeGenerator();
public string Convert(ref string script)
{
//m_positionMap = ((CSCodeGenerator) LSL_Converter).PositionMap;
return Converter.Convert(script);
}
}
}

View File

@@ -1,63 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
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.ScriptEngine.Components.DotNetEngine.Compilers")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("http://opensimulator.org")]
[assembly: AssemblyProduct("OpenSim.ScriptEngine.Components.DotNetEngine.Compilers")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
[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("ea77002b-c967-4368-ace9-6533f8147d4b")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("0.6.5.*")]
[assembly: AssemblyVersion("0.6.5.*")]
[assembly: AssemblyFileVersion("0.6.5.0")]

View File

@@ -1,54 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers.YP
{
public class YP2CS
{
public static string Convert(ref string script)
{
return script;
}
public string PreProcessScript(ref string script)
{
return
"using OpenSim.Region.ScriptEngine.Shared.YieldProlog; " +
"using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;\r\n" +
String.Empty + "namespace SecondLife { " +
String.Empty + "public class Script : OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass { \r\n" +
//@"public Script() { } " +
@"static OpenSim.Region.ScriptEngine.Shared.YieldProlog.YP YP=null; " +
@"public Script() { YP= new OpenSim.Region.ScriptEngine.Shared.YieldProlog.YP(); } " +
script +
"} }\r\n";
}
}
}

View File

@@ -1,121 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.ScriptEngine.Shared;
using OpenSim.ScriptEngine.Shared;
using EventParams = OpenSim.ScriptEngine.Shared.EventParams;
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Events
{
public class LSLEventProvider : IScriptEventProvider
{
public delegate void RezScriptDelegate(uint localID, UUID itemID, string script, int startParam, bool postOnRez,
string engine);
public event RezScriptDelegate RezScript;
public delegate void RemoveScriptDelegate(uint localID, UUID itemID);
public event RemoveScriptDelegate RemoveScript;
public delegate void ScriptChangedDelegate(uint localID, uint change);
public event ScriptChangedDelegate ScriptChanged;
private RegionInfoStructure CurrentRegion;
public void Initialize(RegionInfoStructure currentRegion)
{
CurrentRegion = currentRegion;
HookupEvents();
}
private void HookupEvents()
{
CurrentRegion.Scene.EventManager.OnObjectGrab += OnObjectGrab;
CurrentRegion.Scene.EventManager.OnRezScript += OnRezScript;
CurrentRegion.Scene.EventManager.OnRemoveScript += OnRemoveScript;
CurrentRegion.Scene.EventManager.OnScriptChangedEvent += OnScriptChangedEvent;
}
private void OnScriptChangedEvent(uint localID, uint change)
{
// Script is being changed, fire event
if (ScriptChanged != null)
ScriptChanged(localID, change);
}
private void OnRemoveScript(uint localID, UUID itemID)
{
// Script is being removed, fire event
if (RemoveScript != null)
RemoveScript(localID, itemID);
}
private void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource)
{
// New script being created, fire event
if (RezScript != null)
RezScript(localID, itemID, script, startParam, postOnRez, engine);
}
private void OnObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
{
// Add to queue for all scripts in ObjectID object
DetectParams[] det = new DetectParams[1];
det[0] = new DetectParams();
det[0].Key = remoteClient.AgentId;
//det[0].Populate(World);
if (originalID == 0)
{
SceneObjectPart part =
CurrentRegion.Scene.GetSceneObjectPart(localID);
if (part == null)
return;
det[0].LinkNum = part.LinkNum;
}
else
{
SceneObjectPart originalPart =
CurrentRegion.Scene.GetSceneObjectPart(originalID);
det[0].LinkNum = originalPart.LinkNum;
}
if (surfaceArgs != null)
{
det[0].SurfaceTouchArgs = surfaceArgs;
}
Shared.EventParams ep =
new Shared.EventParams(localID, "touch_start", new Object[] {new LSL_Types.LSLInteger(1)}, det);
CurrentRegion.Executors_Execute(ep);
}
}
}

View File

@@ -1,63 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
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.ScriptEngine.Components.DotNetEngine.Scheduler")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("http://opensimulator.org")]
[assembly: AssemblyProduct("OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
[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("ea77002b-c967-4368-ace9-6533f8147d4b")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("0.6.5.*")]
[assembly: AssemblyVersion("0.6.5.*")]
[assembly: AssemblyFileVersion("0.6.5.0")]

View File

@@ -1,240 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
using OpenSim.ScriptEngine.Shared;
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler
{
public class BaseClassFactory
{
public static void MakeBaseClass(ScriptStructure script)
{
string asmName = "ScriptAssemblies";
string ModuleID = asmName;
string ClassID = "Script";
string moveToDir = "ScriptEngines";
string asmFileName = ModuleID + "_" + ClassID + ".dll";
if (!Directory.Exists(moveToDir))
Directory.CreateDirectory(moveToDir);
ILGenerator ilgen;
AssemblyBuilder asmBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(
new AssemblyName(asmName), AssemblyBuilderAccess.RunAndSave);
// The module builder
ModuleBuilder modBuilder = asmBuilder.DefineDynamicModule(ModuleID, asmFileName);
// The class builder
TypeBuilder classBuilder = modBuilder.DefineType(ClassID, TypeAttributes.Class | TypeAttributes.Public);
// The default constructor
//ConstructorBuilder ctorBuilder = classBuilder.DefineDefaultConstructor(MethodAttributes.Public);
Type[] paramsTypeArray = new Type[] {typeof (System.ParamArrayAttribute)};
Type[] executeFunctionTypeArray = new Type[] {typeof (string), typeof (System.ParamArrayAttribute)};
foreach (IScriptCommandProvider cp in script.RegionInfo.CommandProviders.Values)
{
Type t = cp.GetType();
foreach (MethodInfo mi in t.GetMethods())
{
MethodBuilder methodBuilder = classBuilder.DefineMethod(mi.Name, mi.Attributes, mi.GetType(), Type.EmptyTypes);
methodBuilder.SetParameters(paramsTypeArray);
//ParameterBuilder paramBuilder = methodBuilder.DefineParameter(1, ParameterAttributes.None, "args");
ilgen = methodBuilder.GetILGenerator();
//ilgen.Emit(OpCodes.Nop);
//ilgen.Emit(OpCodes.Ldarg_0);
//ilgen.Emit(OpCodes.Ldc_I4_0);
//ilgen.Emit(OpCodes.Ldelem_Ref);
//ilgen.MarkSequencePoint(doc, 6, 1, 6, 100);
//MethodInfo ExecuteFunction = typeof(ScriptAssemblies.IScript).GetMethod(
// "ExecuteFunction",
// executeFunctionTypeArray);
ilgen.DeclareLocal(typeof(string));
ilgen.Emit(OpCodes.Nop);
ilgen.Emit(OpCodes.Ldstr, mi.Name);
ilgen.Emit(OpCodes.Stloc_0);
ilgen.Emit(OpCodes.Ldarg_0);
ilgen.Emit(OpCodes.Ldloc_0);
ilgen.Emit(OpCodes.Ldarg_1);
// FieldInfo testInfo = classBuilder.
//BindingFlags.NonPublic | BindingFlags.Instance);
//ilgen.Emit(OpCodes.Ldfld, testInfo);
//ilgen.EmitCall(OpCodes.Call, ExecuteFunction, executeFunctionTypeArray);
ilgen.EmitCall(OpCodes.Call, typeof(System.Console).GetMethod("WriteLine"), executeFunctionTypeArray);
// // string.Format("Hello, {0} World!", toWhom)
// //
// ilgen.Emit(OpCodes.Ldstr, "Hello, {0} World!");
// ilgen.Emit(OpCodes.Ldarg_1);
// ilgen.Emit(OpCodes.Call, typeof(string).GetMethod
//("Format", new Type[] { typeof(string), typeof(object) }));
// // m_log.Debug("Hello, World!");
// //
// ilgen.Emit(OpCodes.Call, typeof(Console).GetMethod
// ("WriteLine", new Type[] { typeof(string) }));
ilgen.Emit(OpCodes.Ret);
//Label eom = ilgen.DefineLabel();
//ilgen.Emit(OpCodes.Br_S, eom);
//ilgen.MarkLabel(eom);
//ilgen.Emit(OpCodes.Ret);
//Type test = methodBuilder.SetParameters();
//methodBuilder.SetParameters(typeof (object[]));
}
}
//// Two fields: m_firstname, m_lastname
//FieldBuilder fBuilderFirstName = classBuilder.DefineField("m_firstname", typeof(string), FieldAttributes.Private);
//FieldBuilder fBuilderLastName = classBuilder.DefineField("m_lastname", typeof(string), FieldAttributes.Private);
//// Two properties for this object: FirstName, LastName
//PropertyBuilder pBuilderFirstName = classBuilder.DefineProperty("FirstName", System.Reflection.PropertyAttributes.HasDefault, typeof(string), null);
//PropertyBuilder pBuilderLastName = classBuilder.DefineProperty("LastName", System.Reflection.PropertyAttributes.HasDefault, typeof(string), null);
//// Custom attributes for get, set accessors
//MethodAttributes getSetAttr = MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName;
//// get,set accessors for FirstName
//MethodBuilder mGetFirstNameBuilder = classBuilder.DefineMethod("get_FirstName", getSetAttr, typeof(string), Type.EmptyTypes);
//// Code generation
//ilgen = mGetFirstNameBuilder.GetILGenerator();
//ilgen.Emit(OpCodes.Ldarg_0);
//ilgen.Emit(OpCodes.Ldfld, fBuilderFirstName); // returning the firstname field
//ilgen.Emit(OpCodes.Ret);
//MethodBuilder mSetFirstNameBuilder = classBuilder.DefineMethod("set_FirstName", getSetAttr, null, new Type[] { typeof(string) });
//// Code generation
//ilgen = mSetFirstNameBuilder.GetILGenerator();
//ilgen.Emit(OpCodes.Ldarg_0);
//ilgen.Emit(OpCodes.Ldarg_1);
//ilgen.Emit(OpCodes.Stfld, fBuilderFirstName); // setting the firstname field from the first argument (1)
//ilgen.Emit(OpCodes.Ret);
//// get,set accessors for LastName
//MethodBuilder mGetLastNameBuilder = classBuilder.DefineMethod("get_LastName", getSetAttr, typeof(string), Type.EmptyTypes);
//// Code generation
//ilgen = mGetLastNameBuilder.GetILGenerator();
//ilgen.Emit(OpCodes.Ldarg_0);
//ilgen.Emit(OpCodes.Ldfld, fBuilderLastName); // returning the firstname field
//ilgen.Emit(OpCodes.Ret);
//MethodBuilder mSetLastNameBuilder = classBuilder.DefineMethod("set_LastName", getSetAttr, null, new Type[] { typeof(string) });
//// Code generation
//ilgen = mSetLastNameBuilder.GetILGenerator();
//ilgen.Emit(OpCodes.Ldarg_0);
//ilgen.Emit(OpCodes.Ldarg_1);
//ilgen.Emit(OpCodes.Stfld, fBuilderLastName); // setting the firstname field from the first argument (1)
//ilgen.Emit(OpCodes.Ret);
//// Assigning get/set accessors
//pBuilderFirstName.SetGetMethod(mGetFirstNameBuilder);
//pBuilderFirstName.SetSetMethod(mSetFirstNameBuilder);
//pBuilderLastName.SetGetMethod(mGetLastNameBuilder);
//pBuilderLastName.SetSetMethod(mSetLastNameBuilder);
//// Now, a custom method named GetFullName that concatenates FirstName and LastName properties
//MethodBuilder mGetFullNameBuilder = classBuilder.DefineMethod("GetFullName", MethodAttributes.Public, typeof(string), Type.EmptyTypes);
//// Code generation
//ilgen = mGetFullNameBuilder.GetILGenerator();
//ilgen.Emit(OpCodes.Ldarg_0);
//ilgen.Emit(OpCodes.Call, mGetFirstNameBuilder); // getting the firstname
//ilgen.Emit(OpCodes.Ldstr, " "); // an space
//ilgen.Emit(OpCodes.Ldarg_0);
//ilgen.Emit(OpCodes.Call, mGetLastNameBuilder); // getting the lastname
//// We need the 'Concat' method from string type
//MethodInfo concatMethod = typeof(String).GetMethod("Concat", new Type[] { typeof(string), typeof(string), typeof(string) });
//ilgen.Emit(OpCodes.Call, concatMethod); // calling concat and returning the result
//ilgen.Emit(OpCodes.Ret);
//// Another constructor that initializes firstname and lastname
//ConstructorBuilder ctorBuilder2 = classBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, new Type[] { typeof(string), typeof(string) });
//ctorBuilder2.DefineParameter(1, ParameterAttributes.In, "firstname");
//ctorBuilder2.DefineParameter(2, ParameterAttributes.In, "lastname");
//// Code generation
//ilgen = ctorBuilder2.GetILGenerator();
//// First of all, we need to call the base constructor,
//// the Object's constructor in this sample
//Type objType = Type.GetType("System.Object");
//ConstructorInfo objCtor = objType.GetConstructor(Type.EmptyTypes);
//ilgen.Emit(OpCodes.Ldarg_0);
//ilgen.Emit(OpCodes.Call, objCtor); // calling the Object's constructor
//ilgen.Emit(OpCodes.Ldarg_0);
//ilgen.Emit(OpCodes.Ldarg_1);
//ilgen.Emit(OpCodes.Call, mSetFirstNameBuilder); // setting the firstname field from the first argument (1)
//ilgen.Emit(OpCodes.Ldarg_0);
//ilgen.Emit(OpCodes.Ldarg_2);
//ilgen.Emit(OpCodes.Call, mSetLastNameBuilder); // setting the lastname field from the second argument (2)
//ilgen.Emit(OpCodes.Ret);
// Finally, create the type and save the assembly
classBuilder.CreateType();
asmBuilder.Save(asmFileName);
string toFile = Path.Combine(moveToDir, asmFileName);
if (File.Exists(toFile))
File.Delete(toFile);
File.Move(asmFileName, toFile);
//string a = "";
}
}
}

View File

@@ -1,49 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.ScriptEngine.Shared;
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler
{
public struct LoadUnloadStructure
{
public ScriptStructure Script;
public LUType Action;
public bool PostOnRez;
public int StartParam;
public enum LUType
{
Unknown = 0,
Load = 1,
Unload = 2
}
}
}

View File

@@ -1,63 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
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.Grid.ScriptEngine.Components.DefaultScheduler")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("http://opensimulator.org")]
[assembly: AssemblyProduct("OpenSim.Grid.ScriptEngine.Components.DefaultScheduler")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
[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("ea77002b-c967-4368-ace9-6533f8147d4b")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("0.6.5.*")]
[assembly: AssemblyVersion("0.6.5.*")]
[assembly: AssemblyFileVersion("0.6.5.0")]

View File

@@ -1,55 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse;
using OpenSim.ScriptEngine.Shared;
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler
{
public class Scheduler : IScriptScheduler
{
private ScriptManager m_ScriptManager = new ScriptManager();
public void AddScript(ScriptStructure scriptStructure)
{
m_ScriptManager.AddScript(scriptStructure);
}
public void Removecript(uint id, UUID itemID)
{
m_ScriptManager.RemoveScript(id, itemID);
}
public void Close()
{
m_ScriptManager.Close();
}
}
}

View File

@@ -1,216 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using log4net;
using OpenSim.ScriptEngine.Shared;
using IScript=OpenSim.Region.ScriptEngine.Shared.ScriptBase.IScript;
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler
{
public class ScriptLoader : IScriptLoader
{
//
// This class does AppDomain handling and loading/unloading of
// scripts in it. It is instanced in "ScriptEngine" and controlled
// from "ScriptManager"
//
// 1. Create a new AppDomain if old one is full (or doesn't exist)
// 2. Load scripts into AppDomain
// 3. Unload scripts from AppDomain (stopping them and marking
// them as inactive)
// 4. Unload AppDomain completely when all scripts in it has stopped
//
public string Name { get { return "SECS.DotNetEngine.Scheduler.ScriptLoader"; } }
private int maxScriptsPerAppDomain = 10;
// Internal list of all AppDomains
private List<AppDomainStructure> appDomains =
new List<AppDomainStructure>();
private Dictionary<string, AppDomainStructure> AppDomainFiles = new Dictionary<string, AppDomainStructure>();
public readonly string[] AssembliesInAppDomain = new string[] { "OpenSim.ScriptEngine.Shared.Script.dll", "OpenSim.Region.ScriptEngine.Shared.dll" };
internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// Structure to keep track of data around AppDomain
private class AppDomainStructure
{
public AppDomain CurrentAppDomain; // The AppDomain itself
public int ScriptsLoaded; // Number of scripts loaded into AppDomain
public int ScriptsWaitingUnload; // Number of dead scripts
}
// Current AppDomain
private AppDomainStructure currentAD;
private object getLock = new object(); // Mutex
private object freeLock = new object(); // Mutex
// Find a free AppDomain, creating one if necessary
private AppDomainStructure GetFreeAppDomain()
{
lock (getLock)
{
// Current full?
if (currentAD != null &&
currentAD.ScriptsLoaded >= maxScriptsPerAppDomain)
{
// Add it to AppDomains list and empty current
appDomains.Add(currentAD);
currentAD = null;
}
// No current
if (currentAD == null)
{
// Create a new current AppDomain
currentAD = new AppDomainStructure();
currentAD.CurrentAppDomain = PrepareNewAppDomain();
}
return currentAD;
}
}
private int AppDomainNameCount;
public ScriptAssemblies.IScript LoadScript(ScriptStructure script)
{
// Find next available AppDomain to put it in
AppDomainStructure FreeAppDomain;
// If we already have loaded file, then reuse that AppDomains
if (AppDomainFiles.ContainsKey(script.AssemblyFileName))
FreeAppDomain = AppDomainFiles[script.AssemblyFileName];
else
FreeAppDomain = GetFreeAppDomain();
// Set script object AppDomain
script.AppDomain = FreeAppDomain.CurrentAppDomain;
// Create instance of script
ScriptAssemblies.IScript mbrt = (ScriptAssemblies.IScript)
FreeAppDomain.CurrentAppDomain.CreateInstanceFromAndUnwrap(
script.AssemblyFileName, "ScriptAssemblies.Script");
//, true, BindingFlags.CreateInstance, null);
FreeAppDomain.ScriptsLoaded++;
return mbrt;
}
// Create and prepare a new AppDomain for scripts
private AppDomain PrepareNewAppDomain()
{
// Create and prepare a new AppDomain
AppDomainNameCount++;
// TODO: Currently security match current appdomain
// Construct and initialize settings for a second AppDomain.
AppDomainSetup ads = new AppDomainSetup();
ads.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
ads.DisallowBindingRedirects = true;
ads.DisallowCodeDownload = true;
ads.LoaderOptimization = LoaderOptimization.MultiDomainHost;
ads.ShadowCopyFiles = "false"; // Disable shadowing
ads.ConfigurationFile =
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
AppDomain AD = AppDomain.CreateDomain("ScriptAppDomain_" +
AppDomainNameCount, null, ads);
foreach (string file in AssembliesInAppDomain)
{
m_log.InfoFormat("[{0}] AppDomain Loading: \"{1}\"->\"{2}\".", Name, file,
AssemblyName.GetAssemblyName(file).ToString());
AD.Load(AssemblyName.GetAssemblyName(file));
}
// Return the new AppDomain
return AD;
}
// Unload appdomains that are full and have only dead scripts
private void UnloadAppDomains()
{
lock (freeLock)
{
// Go through all
foreach (AppDomainStructure ads in new ArrayList(appDomains))
{
// Don't process current AppDomain
if (ads.CurrentAppDomain != currentAD.CurrentAppDomain)
{
// Not current AppDomain
// Is number of unloaded bigger or equal to number of loaded?
if (ads.ScriptsLoaded <= ads.ScriptsWaitingUnload)
{
// Remove from internal list
appDomains.Remove(ads);
// Unload
AppDomain.Unload(ads.CurrentAppDomain);
}
}
}
}
}
// Increase "dead script" counter for an AppDomain
public void StopScript(AppDomain ad)
{
lock (freeLock)
{
// Check if it is current AppDomain
if (currentAD.CurrentAppDomain == ad)
{
// Yes - increase
currentAD.ScriptsWaitingUnload++;
return;
}
// Lopp through all AppDomains
foreach (AppDomainStructure ads in new ArrayList(appDomains))
{
if (ads.CurrentAppDomain == ad)
{
// Found it
ads.ScriptsWaitingUnload++;
break;
}
}
}
UnloadAppDomains(); // Outsite lock, has its own GetLock
}
}
}

View File

@@ -1,203 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Text;
using System.Threading;
using log4net;
using OpenMetaverse;
using OpenSim.Region.ScriptEngine.Shared;
using OpenSim.ScriptEngine.Shared;
using EventParams=OpenSim.ScriptEngine.Shared.EventParams;
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler
{
public partial class ScriptManager: IScriptExecutor
{
private const int NoWorkSleepMs = 50;
private const int NoWorkSleepMsInc = 1; // How much time to increase wait with on every iteration
private const int NoWorkSleepMsIncMax = 300; // Max time to wait
internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public string Name { get { return "SECS.DotNetEngine.ScriptManager"; } }
private static Thread ScriptLoadUnloadThread;
public Dictionary<uint, Dictionary<UUID, ScriptStructure>> Scripts = new Dictionary<uint, Dictionary<UUID, ScriptStructure>>();
private RegionInfoStructure CurrentRegion;
public void Initialize(RegionInfoStructure currentRegion)
{
CurrentRegion = currentRegion;
}
public ScriptManager()
{
ScriptLoadUnloadThread = new Thread(LoadUnloadLoop);
ScriptLoadUnloadThread.Name = "ScriptLoadUnloadThread";
ScriptLoadUnloadThread.IsBackground = true;
ScriptLoadUnloadThread.Start();
}
public void Close() { }
private void LoadUnloadLoop ()
{
int _NoWorkSleepMsInc = 0;
while (true)
{
if (DoScriptLoadUnload())
{
// We found work, reset counter
_NoWorkSleepMsInc = NoWorkSleepMs;
} else
{
// We didn't find work
// Sleep
Thread.Sleep(NoWorkSleepMs + NoWorkSleepMsInc);
// Increase sleep delay
_NoWorkSleepMsInc += NoWorkSleepMsInc;
// Make sure we don't exceed max
if (_NoWorkSleepMsInc > NoWorkSleepMsIncMax)
_NoWorkSleepMsInc = NoWorkSleepMsIncMax;
}
}
}
#region Add/Remove/Find script functions for our Script memory structure
private void MemAddScript(ScriptStructure script)
{
lock (scriptLock)
{
// Create object if it doesn't exist
if (!Scripts.ContainsKey(script.LocalID))
Scripts.Add(script.LocalID, new Dictionary<UUID, ScriptStructure>());
// Delete script if it exists
Dictionary<UUID, ScriptStructure> Obj;
if (Scripts.TryGetValue(script.LocalID, out Obj))
if (Obj.ContainsKey(script.ItemID) == true)
Obj.Remove(script.ItemID);
// Add to object
Obj.Add(script.ItemID, script);
}
}
private void MemRemoveScript(uint LocalID, UUID ItemID)
{
// TODO: Also clean up command queue and async commands for object
lock (scriptLock)
{
// Create object if it doesn't exist
if (!Scripts.ContainsKey(LocalID))
return;
// Delete script if it exists
Dictionary<UUID, ScriptStructure> Obj;
if (Scripts.TryGetValue(LocalID, out Obj))
if (Obj.ContainsKey(ItemID) == true)
Obj.Remove(ItemID);
// Empty?
if (Obj.Count == 0)
Scripts.Remove(LocalID);
}
}
public bool TryGetScript(uint localID, UUID itemID, ref ScriptStructure script)
{
lock (scriptLock)
{
if (Scripts.ContainsKey(localID) == false)
return false;
Dictionary<UUID, ScriptStructure> Obj;
if (Scripts.TryGetValue(localID, out Obj))
if (Obj.ContainsKey(itemID) == false)
return false;
// Get script
return Obj.TryGetValue(itemID, out script);
}
}
public ScriptStructure GetScript(uint localID, UUID itemID)
{
lock (scriptLock)
{
if (Scripts.ContainsKey(localID) == false)
throw new Exception("No script with LocalID " + localID + " was found.");
Dictionary<UUID, ScriptStructure> Obj;
if (Scripts.TryGetValue(localID, out Obj))
if (Obj.ContainsKey(itemID) == false)
throw new Exception("No script with ItemID " + itemID + " was found.");
// Get script
return Obj[itemID];
}
}
public bool TryGetScripts(uint localID, ref Dictionary<UUID, ScriptStructure> returnList)
{
Dictionary<UUID, ScriptStructure> getList = GetScripts(localID);
if (getList != null)
{
returnList = getList;
return true;
}
return false;
}
public Dictionary<UUID, ScriptStructure> GetScripts(uint localID)
{
lock (scriptLock)
{
if (Scripts.ContainsKey(localID) == false)
return null;
return Scripts[localID];
}
}
#endregion
public void ExecuteCommand(EventParams p)
{
ScriptStructure ss = new ScriptStructure();
if (TryGetScript(p.LocalID, p.ItemID, ref ss))
ExecuteCommand(ref ss, p);
}
public void ExecuteCommand(ref ScriptStructure scriptContainer, EventParams p)
{
m_log.DebugFormat("[{0}] ######################################################", Name);
m_log.DebugFormat("[{0}] Command execution ItemID {1}: \"{2}\".", Name, scriptContainer.ItemID, p.EventName);
scriptContainer.ExecuteEvent(p);
m_log.DebugFormat("[{0}] ######################################################", Name);
}
}
}

View File

@@ -1,287 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using System.Text;
using System.Threading;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.ScriptEngine.Interfaces;
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
using OpenSim.ScriptEngine.Shared;
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler
{
public partial class ScriptManager
{
private Queue<LoadUnloadStructure> LUQueue = new Queue<LoadUnloadStructure>();
private int LoadUnloadMaxQueueSize = 500;
private Object scriptLock = new Object();
//private Dictionary<InstanceData, DetectParams[]> detparms = new Dictionary<InstanceData, DetectParams[]>();
// Load/Unload structure
public void AddScript(ScriptStructure script)
{
lock (LUQueue)
{
if ((LUQueue.Count >= LoadUnloadMaxQueueSize))
{
m_log.ErrorFormat("[{0}] ERROR: Load queue count is at {1} of max {2}. Ignoring load request for script LocalID: {3}, ItemID: {4}.",
Name, LUQueue.Count, LoadUnloadMaxQueueSize, script.LocalID, script.ItemID);
return;
}
LoadUnloadStructure ls = new LoadUnloadStructure();
ls.Script = script;
ls.Action = LoadUnloadStructure.LUType.Load;
LUQueue.Enqueue(ls);
}
}
public void RemoveScript(uint localID, UUID itemID)
{
LoadUnloadStructure ls = new LoadUnloadStructure();
// See if we can find script
if (!TryGetScript(localID, itemID, ref ls.Script))
{
// Set manually
ls.Script.LocalID = localID;
ls.Script.ItemID = itemID;
}
ls.Script.StartParam = 0;
ls.Action = LoadUnloadStructure.LUType.Unload;
ls.PostOnRez = false;
lock (LUQueue)
{
LUQueue.Enqueue(ls);
}
}
internal bool DoScriptLoadUnload()
{
bool ret = false;
// if (!m_started)
// return;
lock (LUQueue)
{
if (LUQueue.Count > 0)
{
LoadUnloadStructure item = LUQueue.Dequeue();
ret = true;
if (item.Action == LoadUnloadStructure.LUType.Unload)
{
_StopScript(item.Script.LocalID, item.Script.ItemID);
RemoveScript(item.Script.LocalID, item.Script.ItemID);
}
else if (item.Action == LoadUnloadStructure.LUType.Load)
{
m_log.DebugFormat("[{0}] Loading script", Name);
_StartScript(item);
}
}
}
return ret;
}
//public void _StartScript(uint localID, UUID itemID, string Script, int startParam, bool postOnRez)
private void _StartScript(LoadUnloadStructure ScriptObject)
{
m_log.DebugFormat(
"[{0}]: ScriptManager StartScript: localID: {1}, itemID: {2}",
Name, ScriptObject.Script.LocalID, ScriptObject.Script.ItemID);
// We will initialize and start the script.
// It will be up to the script itself to hook up the correct events.
SceneObjectPart m_host = ScriptObject.Script.RegionInfo.Scene.GetSceneObjectPart(ScriptObject.Script.LocalID);
if (null == m_host)
{
m_log.ErrorFormat(
"[{0}]: Could not find scene object part corresponding " +
"to localID {1} to start script",
Name, ScriptObject.Script.LocalID);
return;
}
//UUID assetID = UUID.Zero;
TaskInventoryItem taskInventoryItem = new TaskInventoryItem();
//if (m_host.TaskInventory.TryGetValue(ScriptObject.Script.ItemID, out taskInventoryItem))
// assetID = taskInventoryItem.AssetID;
ScenePresence presence =
ScriptObject.Script.RegionInfo.Scene.GetScenePresence(taskInventoryItem.OwnerID);
CultureInfo USCulture = new CultureInfo("en-US");
Thread.CurrentThread.CurrentCulture = USCulture;
try
{
//
// Compile script to an assembly
//
//TODO: DEBUG
BaseClassFactory.MakeBaseClass(ScriptObject.Script);
m_log.DebugFormat("[{0}] Compiling script {1}", Name, ScriptObject.Script.Name);
string fileName = "";
try
{
IScriptCompiler compiler =
ScriptObject.Script.RegionInfo.FindCompiler(ScriptObject.Script.ScriptMetaData);
//RegionInfoStructure currentRegionInfo = ScriptObject.Script.RegionInfo;
fileName = compiler.Compile(ScriptObject.Script.ScriptMetaData,
ref ScriptObject.Script.Source);
ScriptObject.Script.AssemblyFileName = fileName;
}
catch (Exception e)
{
m_log.ErrorFormat("[{0}] Internal error while compiling \"{1}\": {2}", Name, ScriptObject.Script.Name, e.ToString());
}
m_log.DebugFormat("[{0}] Compiled \"{1}\" to assembly: \"{2}\".", Name, ScriptObject.Script.Name, fileName);
// Add it to our script memstruct
MemAddScript(ScriptObject.Script);
ScriptAssemblies.IScript CompiledScript;
CompiledScript = CurrentRegion.ScriptLoader.LoadScript(ScriptObject.Script);
ScriptObject.Script.State = "default";
ScriptObject.Script.ScriptObject = CompiledScript;
ScriptObject.Script.Disabled = false;
ScriptObject.Script.Running = true;
//id.LineMap = LSLCompiler.LineMap();
//id.Script = CompiledScript;
//id.Source = item.Script.Script;
//item.StartParam = startParam;
// TODO: Fire the first start-event
//int eventFlags =
// m_scriptEngine.m_ScriptManager.GetStateEventFlags(
// localID, itemID);
//m_host.SetScriptEvents(itemID, eventFlags);
ScriptObject.Script.RegionInfo.Executors_Execute(ScriptObject.Script,
new EventParams(ScriptObject.Script.LocalID, ScriptObject.Script.ItemID, "state_entry", new object[] { }, new Region.ScriptEngine.Shared.DetectParams[0])
);
if (ScriptObject.PostOnRez)
{
ScriptObject.Script.RegionInfo.Executors_Execute(ScriptObject.Script,
new EventParams(ScriptObject.Script.LocalID, "on_rez", new object[]
{new Region.ScriptEngine.Shared.LSL_Types.LSLInteger(ScriptObject.StartParam)
}, new Region.ScriptEngine.Shared.DetectParams[0]));
}
}
catch (Exception e) // LEGIT: User Scripting
{
if (presence != null && (!ScriptObject.PostOnRez))
presence.ControllingClient.SendAgentAlertMessage(
"Script saved with errors, check debug window!",
false);
try
{
// DISPLAY ERROR INWORLD
string text = "Error compiling script:\n" +
e.Message.ToString();
if (text.Length > 1100)
text = text.Substring(0, 1099);
ScriptObject.Script.RegionInfo.Scene.SimChat(Utils.StringToBytes(text),
ChatTypeEnum.DebugChannel, 2147483647,
m_host.AbsolutePosition, m_host.Name, m_host.UUID,
false);
}
catch (Exception e2) // LEGIT: User Scripting
{
m_log.Error("[" +
Name +
"]: Error displaying error in-world: " +
e2.ToString());
m_log.Error("[" +
Name + "]: " +
"Errormessage: Error compiling script:\r\n" +
e2.Message.ToString());
}
}
}
public void _StopScript(uint localID, UUID itemID)
{
ScriptStructure ss = new ScriptStructure();
if (!TryGetScript(localID, itemID, ref ss))
return;
m_log.DebugFormat("[{0}] Unloading script", Name);
// Stop long command on script
//AsyncCommandManager.RemoveScript(ss);
try
{
// Get AppDomain
// Tell script not to accept new requests
ss.Running = false;
ss.Disabled = true;
//AppDomain ad = ss.AppDomain;
// Remove from internal structure
MemRemoveScript(localID, itemID);
// TODO: Tell AppDomain that we have stopped script
}
catch (Exception e) // LEGIT: User Scripting
{
m_log.Error("[" +
Name +
"]: Exception stopping script localID: " +
localID + " LLUID: " + itemID.ToString() +
": " + e.ToString());
}
}
}
}

View File

@@ -1,196 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenSim.ApplicationPlugins.ScriptEngine;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.ScriptEngine.Components.DotNetEngine.Events;
using OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler;
using OpenSim.ScriptEngine.Shared;
using ComponentFactory = OpenSim.ApplicationPlugins.ScriptEngine.ComponentFactory;
namespace OpenSim.ScriptEngine.Engines.DotNetEngine
{
// This is a sample engine
public partial class DotNetEngine : IScriptEngine
{
//private string[] _ComponentNames = new string[] {
// "Commands_LSL",
// "Commands_OSSL",
// "Compiler_CS",
// "Compiler_JS",
// "Compiler_LSL",
// "Compiler_VB",
// "LSLEventProvider",
// "Scheduler"
// };
internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public string Name { get { return "SECS.DotNetEngine"; } }
//public bool IsSharedModule { get { return true; } }
internal RegionInfoStructure RegionInfo;
private string[] commandNames = new string[]
{
"Commands_LSL"
};
private string[] compilerNames = new string[]
{
"Compiler_CS",
"Compiler_JS",
"Compiler_LSL",
"Compiler_YP",
"Compiler_VB"
};
private string[] schedulerNames = new string[]
{
"Scheduler"
};
//internal IScriptLoader m_ScriptLoader;
internal LSLEventProvider m_LSLEventProvider;
//internal IScriptExecutor m_Executor;
//internal Dictionary<string, IScriptCompiler> Compilers = new Dictionary<string, IScriptCompiler>();
internal Dictionary<string, IScriptScheduler> Schedulers = new Dictionary<string, IScriptScheduler>();
public static Dictionary<string, IScriptCompiler> Compilers = new Dictionary<string, IScriptCompiler>();
// private static bool haveInitialized = false;
public DotNetEngine()
{
RegionInfo = new RegionInfoStructure();
RegionInfo.Compilers = Compilers;
RegionInfo.Schedulers = Schedulers;
RegionInfo.Executors = new Dictionary<string, IScriptExecutor>();
RegionInfo.CommandProviders = new Dictionary<string, IScriptCommandProvider>();
RegionInfo.EventProviders = new Dictionary<string, IScriptEventProvider>();
}
public void Initialise(Scene scene, IConfigSource source)
{
RegionInfo.Scene = scene;
RegionInfo.ConfigSource = source;
m_log.DebugFormat("[{0}] Initializing components", Name);
InitializeComponents();
}
public void PostInitialise() { }
/// <summary>
/// Called on region close
/// </summary>
public void Close()
{
ComponentClose();
}
#region Initialize the Script Engine Components we need
public void InitializeComponents()
{
string cname = "";
m_log.DebugFormat("[{0}] Component initialization", Name);
// Initialize an instance of all module we want
try
{
cname = "ScriptManager";
m_log.DebugFormat("[{0}] Executor: {1}", Name, cname);
RegionInfo.Executors.Add(cname,
ComponentFactory.GetComponentInstance(RegionInfo, cname) as IScriptExecutor);
cname = "ScriptLoader";
m_log.DebugFormat("[{0}] ScriptLoader: {1}", Name, cname);
RegionInfo.ScriptLoader =
ComponentFactory.GetComponentInstance(RegionInfo, cname) as IScriptExecutor as ScriptLoader;
// CommandProviders
foreach (string cn in commandNames)
{
cname = cn;
m_log.DebugFormat("[{0}] CommandProvider: {1}", Name, cname);
RegionInfo.CommandProviders.Add(cname,
ComponentFactory.GetComponentInstance(RegionInfo, cname) as
IScriptCommandProvider);
}
// Compilers
foreach (string cn in compilerNames)
{
cname = cn;
m_log.DebugFormat("[{0}] Compiler: {1}", Name, cname);
RegionInfo.Compilers.Add(cname,
ComponentFactory.GetComponentInstance(RegionInfo, cname) as
IScriptCompiler);
}
// Schedulers
foreach (string cn in schedulerNames)
{
cname = cn;
m_log.DebugFormat("[{0}] Scheduler: {1}", Name, cname);
RegionInfo.Schedulers.Add(cname,
ComponentFactory.GetComponentInstance(RegionInfo, cname) as
IScriptScheduler);
}
// Event provider
cname = "LSLEventProvider";
m_log.DebugFormat("[{0}] EventProvider: {1}", Name, cname);
IScriptEventProvider sep = ComponentFactory.GetComponentInstance(RegionInfo, cname) as IScriptEventProvider;
RegionInfo.EventProviders.Add(cname, sep);
m_LSLEventProvider = sep as LSLEventProvider;
// Hook up events
m_LSLEventProvider.RezScript += Events_RezScript;
m_LSLEventProvider.RemoveScript += Events_RemoveScript;
}
catch (Exception e)
{
m_log.ErrorFormat("[{0}] Exception while loading \"{1}\": {2}", Name, cname, e.ToString());
}
}
private void ComponentClose()
{
// Close schedulers
foreach (IScriptScheduler scheduler in RegionInfo.Schedulers.Values)
{
scheduler.Close();
}
}
#endregion
}
}

View File

@@ -1,95 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse;
using OpenSim.ScriptEngine.Components.DotNetEngine.Events;
using OpenSim.ScriptEngine.Shared;
namespace OpenSim.ScriptEngine.Engines.DotNetEngine
{
public partial class DotNetEngine
{
//internal Dictionary<int, IScriptScheduler> ScriptMapping = new Dictionary<int, IScriptScheduler>();
//
// HANDLE EVENTS FROM SCRIPTS
// We will handle script add, change and remove events outside of command pipeline
//
#region Script Add/Change/Remove
void Events_RezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine)
{
// ###
// # New script created
// ###
m_log.DebugFormat(
"[{0}] NEW SCRIPT: localID: {1}, itemID: {2}, startParam: {3}, postOnRez: {4}, engine: {5}",
Name, localID, itemID, startParam, postOnRez, engine);
// Make a script object
ScriptStructure scriptObject = new ScriptStructure();
scriptObject.RegionInfo = RegionInfo;
scriptObject.LocalID = localID;
scriptObject.ItemID = itemID;
scriptObject.Source = script;
//
// Get MetaData from script header
//
ScriptMetaData scriptMetaData = ScriptMetaData.Extract(ref script);
scriptObject.ScriptMetaData = scriptMetaData;
foreach (string key in scriptObject.ScriptMetaData.Keys)
{
m_log.DebugFormat("[{0}] Script metadata: Key: \"{1}\", Value: \"{2}\".", Name, key, scriptObject.ScriptMetaData[key]);
}
//
// Load this assembly
//
// TODO: Use Executor to send a command instead?
m_log.DebugFormat("[{0}] Adding script to scheduler", Name);
RegionInfo.FindScheduler(scriptObject.ScriptMetaData).AddScript(scriptObject);
// Add to our internal mapping
//ScriptMapping.Add(itemID, Schedulers[scheduler]);
}
private void Events_RemoveScript(uint localID, UUID itemID)
{
// Tell all schedulers to remove this item
foreach (IScriptScheduler scheduler in RegionInfo.Schedulers.Values)
{
scheduler.Removecript(localID, itemID);
}
}
#endregion
}
}

View File

@@ -1,63 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
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.ScriptEngine.Engines.DotNetEngine")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("http://opensimulator.org")]
[assembly: AssemblyProduct("OpenSim.ScriptEngine.Engines.DotNetEngine")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
[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("1d1c68a7-026f-4556-a060-4af69f488d2a")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("0.6.5.*")]
[assembly: AssemblyVersion("0.6.5.*")]
[assembly: AssemblyFileVersion("0.6.5.0")]