* Rex merges, Grid Script Server
parent
ab27cd5513
commit
ce0d1132f8
|
@ -1,139 +1,139 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.Remoting.Lifetime;
|
using System.Runtime.Remoting.Lifetime;
|
||||||
|
|
||||||
namespace OpenSim.Grid.ScriptEngine.Common
|
namespace OpenSim.Grid.ScriptEngine.Common
|
||||||
{
|
{
|
||||||
public class Executor : MarshalByRefObject
|
public class Executor : MarshalByRefObject
|
||||||
{
|
{
|
||||||
// Private instance for each script
|
// Private instance for each script
|
||||||
|
|
||||||
private IScript m_Script;
|
private IScript m_Script;
|
||||||
private Dictionary<string, MethodInfo> Events = new Dictionary<string, MethodInfo>();
|
private Dictionary<string, MethodInfo> Events = new Dictionary<string, MethodInfo>();
|
||||||
private bool m_Running = true;
|
private bool m_Running = true;
|
||||||
//private List<IScript> Scripts = new List<IScript>();
|
//private List<IScript> Scripts = new List<IScript>();
|
||||||
|
|
||||||
public Executor(IScript Script)
|
public Executor(IScript Script)
|
||||||
{
|
{
|
||||||
m_Script = Script;
|
m_Script = Script;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Object never expires
|
// Object never expires
|
||||||
public override Object InitializeLifetimeService()
|
public override Object InitializeLifetimeService()
|
||||||
{
|
{
|
||||||
//Console.WriteLine("Executor: InitializeLifetimeService()");
|
//Console.WriteLine("Executor: InitializeLifetimeService()");
|
||||||
// return null;
|
// return null;
|
||||||
ILease lease = (ILease) base.InitializeLifetimeService();
|
ILease lease = (ILease) base.InitializeLifetimeService();
|
||||||
|
|
||||||
if (lease.CurrentState == LeaseState.Initial)
|
if (lease.CurrentState == LeaseState.Initial)
|
||||||
{
|
{
|
||||||
lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1);
|
lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1);
|
||||||
// lease.SponsorshipTimeout = TimeSpan.FromMinutes(2);
|
// lease.SponsorshipTimeout = TimeSpan.FromMinutes(2);
|
||||||
// lease.RenewOnCallTime = TimeSpan.FromSeconds(2);
|
// lease.RenewOnCallTime = TimeSpan.FromSeconds(2);
|
||||||
}
|
}
|
||||||
return lease;
|
return lease;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AppDomain GetAppDomain()
|
public AppDomain GetAppDomain()
|
||||||
{
|
{
|
||||||
return AppDomain.CurrentDomain;
|
return AppDomain.CurrentDomain;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ExecuteEvent(string FunctionName, object[] args)
|
public void ExecuteEvent(string FunctionName, object[] args)
|
||||||
{
|
{
|
||||||
// IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory.
|
// IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory.
|
||||||
// Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead!
|
// Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead!
|
||||||
//try
|
//try
|
||||||
//{
|
//{
|
||||||
if (m_Running == false)
|
if (m_Running == false)
|
||||||
{
|
{
|
||||||
// Script is inactive, do not execute!
|
// Script is inactive, do not execute!
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string EventName = m_Script.State() + "_event_" + FunctionName;
|
string EventName = m_Script.State() + "_event_" + FunctionName;
|
||||||
|
|
||||||
//type.InvokeMember(EventName, BindingFlags.InvokeMethod, null, m_Script, args);
|
//type.InvokeMember(EventName, BindingFlags.InvokeMethod, null, m_Script, args);
|
||||||
|
|
||||||
//Console.WriteLine("ScriptEngine Executor.ExecuteEvent: \"" + EventName + "\"");
|
//Console.WriteLine("ScriptEngine Executor.ExecuteEvent: \"" + EventName + "\"");
|
||||||
|
|
||||||
if (Events.ContainsKey(EventName) == false)
|
if (Events.ContainsKey(EventName) == false)
|
||||||
{
|
{
|
||||||
// Not found, create
|
// Not found, create
|
||||||
Type type = m_Script.GetType();
|
Type type = m_Script.GetType();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
MethodInfo mi = type.GetMethod(EventName);
|
MethodInfo mi = type.GetMethod(EventName);
|
||||||
Events.Add(EventName, mi);
|
Events.Add(EventName, mi);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
// Event name not found, cache it as not found
|
// Event name not found, cache it as not found
|
||||||
Events.Add(EventName, null);
|
Events.Add(EventName, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get event
|
// Get event
|
||||||
MethodInfo ev = null;
|
MethodInfo ev = null;
|
||||||
Events.TryGetValue(EventName, out ev);
|
Events.TryGetValue(EventName, out ev);
|
||||||
|
|
||||||
if (ev == null) // No event by that name!
|
if (ev == null) // No event by that name!
|
||||||
{
|
{
|
||||||
//Console.WriteLine("ScriptEngine Can not find any event named: \"" + EventName + "\"");
|
//Console.WriteLine("ScriptEngine Can not find any event named: \"" + EventName + "\"");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Found
|
// Found
|
||||||
//try
|
//try
|
||||||
//{
|
//{
|
||||||
// Invoke it
|
// Invoke it
|
||||||
ev.Invoke(m_Script, args);
|
ev.Invoke(m_Script, args);
|
||||||
|
|
||||||
//}
|
//}
|
||||||
//catch (Exception e)
|
//catch (Exception e)
|
||||||
//{
|
//{
|
||||||
// // TODO: Send to correct place
|
// // TODO: Send to correct place
|
||||||
// Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString());
|
// Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString());
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
//}
|
//}
|
||||||
//catch { }
|
//catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void StopScript()
|
public void StopScript()
|
||||||
{
|
{
|
||||||
m_Running = false;
|
m_Running = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,36 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace OpenSim.Grid.ScriptEngine.Common
|
namespace OpenSim.Grid.ScriptEngine.Common
|
||||||
{
|
{
|
||||||
public interface IScript
|
public interface IScript
|
||||||
{
|
{
|
||||||
string State();
|
string State();
|
||||||
Executor Exec { get; }
|
Executor Exec { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,83 +1,83 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace OpenSim.Grid.ScriptEngine.Common
|
namespace OpenSim.Grid.ScriptEngine.Common
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class LSL_Types
|
public class LSL_Types
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public struct Vector3
|
public struct Vector3
|
||||||
{
|
{
|
||||||
public double X;
|
public double X;
|
||||||
public double Y;
|
public double Y;
|
||||||
public double Z;
|
public double Z;
|
||||||
|
|
||||||
public Vector3(Vector3 vector)
|
public Vector3(Vector3 vector)
|
||||||
{
|
{
|
||||||
X = (float) vector.X;
|
X = (float) vector.X;
|
||||||
Y = (float) vector.Y;
|
Y = (float) vector.Y;
|
||||||
Z = (float) vector.Z;
|
Z = (float) vector.Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3(double x, double y, double z)
|
public Vector3(double x, double y, double z)
|
||||||
{
|
{
|
||||||
X = x;
|
X = x;
|
||||||
Y = y;
|
Y = y;
|
||||||
Z = z;
|
Z = z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public struct Quaternion
|
public struct Quaternion
|
||||||
{
|
{
|
||||||
public double X;
|
public double X;
|
||||||
public double Y;
|
public double Y;
|
||||||
public double Z;
|
public double Z;
|
||||||
public double R;
|
public double R;
|
||||||
|
|
||||||
public Quaternion(Quaternion Quat)
|
public Quaternion(Quaternion Quat)
|
||||||
{
|
{
|
||||||
X = (float) Quat.X;
|
X = (float) Quat.X;
|
||||||
Y = (float) Quat.Y;
|
Y = (float) Quat.Y;
|
||||||
Z = (float) Quat.Z;
|
Z = (float) Quat.Z;
|
||||||
R = (float) Quat.R;
|
R = (float) Quat.R;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Quaternion(double x, double y, double z, double r)
|
public Quaternion(double x, double y, double z, double r)
|
||||||
{
|
{
|
||||||
X = x;
|
X = x;
|
||||||
Y = y;
|
Y = y;
|
||||||
Z = z;
|
Z = z;
|
||||||
R = r;
|
R = r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,64 @@
|
||||||
using System.Reflection;
|
/*
|
||||||
using System.Runtime.InteropServices;
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
// General Information about an assembly is controlled through the following
|
*
|
||||||
// set of attributes. Change these attribute values to modify the information
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// associated with an assembly.
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
[assembly : AssemblyTitle("OpenSim.Grid.ScriptEngine.Common")]
|
* notice, this list of conditions and the following disclaimer.
|
||||||
[assembly : AssemblyDescription("")]
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
[assembly : AssemblyConfiguration("")]
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
[assembly : AssemblyCompany("")]
|
* documentation and/or other materials provided with the distribution.
|
||||||
[assembly : AssemblyProduct("OpenSim.Grid.ScriptEngine.Common")]
|
* * Neither the name of the OpenSim Project nor the
|
||||||
[assembly : AssemblyCopyright("Copyright © 2007")]
|
* names of its contributors may be used to endorse or promote products
|
||||||
[assembly : AssemblyTrademark("")]
|
* derived from this software without specific prior written permission.
|
||||||
[assembly : AssemblyCulture("")]
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
// to COM components. If you need to access a type in this assembly from
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
[assembly : ComVisible(false)]
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
* 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
|
||||||
[assembly : Guid("0bf07c53-ae51-487f-a907-e9b30c251602")]
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
// Version information for an assembly consists of the following four values:
|
*/
|
||||||
//
|
|
||||||
// Major Version
|
using System.Reflection;
|
||||||
// Minor Version
|
using System.Runtime.InteropServices;
|
||||||
// Build Number
|
|
||||||
// Revision
|
// 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 : AssemblyVersion("1.0.0.0")]
|
|
||||||
[assembly : AssemblyFileVersion("1.0.0.0")]
|
[assembly : AssemblyTitle("OpenSim.Grid.ScriptEngine.Common")]
|
||||||
|
[assembly : AssemblyDescription("")]
|
||||||
|
[assembly : AssemblyConfiguration("")]
|
||||||
|
[assembly : AssemblyCompany("")]
|
||||||
|
[assembly : AssemblyProduct("OpenSim.Grid.ScriptEngine.Common")]
|
||||||
|
[assembly : AssemblyCopyright("Copyright © 2007")]
|
||||||
|
[assembly : AssemblyTrademark("")]
|
||||||
|
[assembly : AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
|
||||||
|
[assembly : ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
|
||||||
|
[assembly : Guid("0bf07c53-ae51-487f-a907-e9b30c251602")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
|
||||||
|
[assembly : AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly : AssemblyFileVersion("1.0.0.0")]
|
||||||
|
|
|
@ -1,226 +1,224 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL;
|
using OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL;
|
||||||
|
|
||||||
namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||||
{
|
{
|
||||||
public class AppDomainManager
|
public class AppDomainManager
|
||||||
{
|
{
|
||||||
private int maxScriptsPerAppDomain = 1;
|
private int maxScriptsPerAppDomain = 1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Internal list of all AppDomains
|
/// Internal list of all AppDomains
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<AppDomainStructure> appDomains = new List<AppDomainStructure>();
|
private List<AppDomainStructure> appDomains = new List<AppDomainStructure>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Structure to keep track of data around AppDomain
|
/// Structure to keep track of data around AppDomain
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private class AppDomainStructure
|
private class AppDomainStructure
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The AppDomain itself
|
/// The AppDomain itself
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AppDomain CurrentAppDomain;
|
public AppDomain CurrentAppDomain;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of scripts loaded into AppDomain
|
/// Number of scripts loaded into AppDomain
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int ScriptsLoaded;
|
public int ScriptsLoaded;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of dead scripts
|
/// Number of dead scripts
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int ScriptsWaitingUnload;
|
public int ScriptsWaitingUnload;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Current AppDomain
|
/// Current AppDomain
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private AppDomainStructure currentAD;
|
private AppDomainStructure currentAD;
|
||||||
|
|
||||||
private object getLock = new object(); // Mutex
|
private object getLock = new object(); // Mutex
|
||||||
private object freeLock = new object(); // Mutex
|
private object freeLock = new object(); // Mutex
|
||||||
|
|
||||||
//private ScriptEngine m_scriptEngine;
|
//private ScriptEngine m_scriptEngine;
|
||||||
//public AppDomainManager(ScriptEngine scriptEngine)
|
//public AppDomainManager(ScriptEngine scriptEngine)
|
||||||
public AppDomainManager()
|
public AppDomainManager()
|
||||||
{
|
{
|
||||||
//m_scriptEngine = scriptEngine;
|
//m_scriptEngine = scriptEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Find a free AppDomain, creating one if necessary
|
/// Find a free AppDomain, creating one if necessary
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Free AppDomain</returns>
|
/// <returns>Free AppDomain</returns>
|
||||||
private AppDomainStructure GetFreeAppDomain()
|
private AppDomainStructure GetFreeAppDomain()
|
||||||
{
|
{
|
||||||
Console.WriteLine("Finding free AppDomain");
|
Console.WriteLine("Finding free AppDomain");
|
||||||
lock (getLock)
|
lock (getLock)
|
||||||
{
|
{
|
||||||
// Current full?
|
// Current full?
|
||||||
if (currentAD != null && currentAD.ScriptsLoaded >= maxScriptsPerAppDomain)
|
if (currentAD != null && currentAD.ScriptsLoaded >= maxScriptsPerAppDomain)
|
||||||
{
|
{
|
||||||
// Add it to AppDomains list and empty current
|
// Add it to AppDomains list and empty current
|
||||||
appDomains.Add(currentAD);
|
appDomains.Add(currentAD);
|
||||||
currentAD = null;
|
currentAD = null;
|
||||||
}
|
}
|
||||||
// No current
|
// No current
|
||||||
if (currentAD == null)
|
if (currentAD == null)
|
||||||
{
|
{
|
||||||
// Create a new current AppDomain
|
// Create a new current AppDomain
|
||||||
currentAD = new AppDomainStructure();
|
currentAD = new AppDomainStructure();
|
||||||
currentAD.CurrentAppDomain = PrepareNewAppDomain();
|
currentAD.CurrentAppDomain = PrepareNewAppDomain();
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("Scripts loaded in this Appdomain: " + currentAD.ScriptsLoaded);
|
Console.WriteLine("Scripts loaded in this Appdomain: " + currentAD.ScriptsLoaded);
|
||||||
return currentAD;
|
return currentAD;
|
||||||
} // lock
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int AppDomainNameCount;
|
private int AppDomainNameCount;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create and prepare a new AppDomain for scripts
|
/// Create and prepare a new AppDomain for scripts
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The new AppDomain</returns>
|
/// <returns>The new AppDomain</returns>
|
||||||
private AppDomain PrepareNewAppDomain()
|
private AppDomain PrepareNewAppDomain()
|
||||||
{
|
{
|
||||||
// Create and prepare a new AppDomain
|
// Create and prepare a new AppDomain
|
||||||
AppDomainNameCount++;
|
AppDomainNameCount++;
|
||||||
// TODO: Currently security match current appdomain
|
// TODO: Currently security match current appdomain
|
||||||
|
|
||||||
// Construct and initialize settings for a second AppDomain.
|
// Construct and initialize settings for a second AppDomain.
|
||||||
AppDomainSetup ads = new AppDomainSetup();
|
AppDomainSetup ads = new AppDomainSetup();
|
||||||
ads.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
|
ads.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
|
||||||
ads.DisallowBindingRedirects = false;
|
ads.DisallowBindingRedirects = false;
|
||||||
ads.DisallowCodeDownload = true;
|
ads.DisallowCodeDownload = true;
|
||||||
ads.LoaderOptimization = LoaderOptimization.MultiDomain; // Sounds good ;)
|
ads.LoaderOptimization = LoaderOptimization.MultiDomain; // Sounds good ;)
|
||||||
ads.ShadowCopyFiles = "true"; // Enabled shadowing
|
ads.ShadowCopyFiles = "true"; // Enabled shadowing
|
||||||
ads.ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
|
ads.ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
|
||||||
|
|
||||||
AppDomain AD = AppDomain.CreateDomain("ScriptAppDomain_" + AppDomainNameCount, null, ads);
|
AppDomain AD = AppDomain.CreateDomain("ScriptAppDomain_" + AppDomainNameCount, null, ads);
|
||||||
Console.WriteLine("Loading: " +
|
Console.WriteLine("Loading: " +
|
||||||
AssemblyName.GetAssemblyName("OpenSim.Region.ScriptEngine.Common.dll").ToString());
|
AssemblyName.GetAssemblyName("OpenSim.Region.ScriptEngine.Common.dll").ToString());
|
||||||
AD.Load(AssemblyName.GetAssemblyName("OpenSim.Region.ScriptEngine.Common.dll"));
|
AD.Load(AssemblyName.GetAssemblyName("OpenSim.Region.ScriptEngine.Common.dll"));
|
||||||
|
|
||||||
// Return the new AppDomain
|
// Return the new AppDomain
|
||||||
return AD;
|
return AD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unload appdomains that are full and have only dead scripts
|
/// Unload appdomains that are full and have only dead scripts
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void UnloadAppDomains()
|
private void UnloadAppDomains()
|
||||||
{
|
{
|
||||||
lock (freeLock)
|
lock (freeLock)
|
||||||
{
|
{
|
||||||
// Go through all
|
// Go through all
|
||||||
foreach (AppDomainStructure ads in new ArrayList(appDomains))
|
foreach (AppDomainStructure ads in new ArrayList(appDomains))
|
||||||
{
|
{
|
||||||
// Don't process current AppDomain
|
// Don't process current AppDomain
|
||||||
if (ads.CurrentAppDomain != currentAD.CurrentAppDomain)
|
if (ads.CurrentAppDomain != currentAD.CurrentAppDomain)
|
||||||
{
|
{
|
||||||
// Not current AppDomain
|
// Not current AppDomain
|
||||||
// Is number of unloaded bigger or equal to number of loaded?
|
// Is number of unloaded bigger or equal to number of loaded?
|
||||||
if (ads.ScriptsLoaded <= ads.ScriptsWaitingUnload)
|
if (ads.ScriptsLoaded <= ads.ScriptsWaitingUnload)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Found empty AppDomain, unloading");
|
Console.WriteLine("Found empty AppDomain, unloading");
|
||||||
// Remove from internal list
|
// Remove from internal list
|
||||||
appDomains.Remove(ads);
|
appDomains.Remove(ads);
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
long m = GC.GetTotalMemory(true);
|
long m = GC.GetTotalMemory(true);
|
||||||
#endif
|
#endif
|
||||||
// Unload
|
// Unload
|
||||||
AppDomain.Unload(ads.CurrentAppDomain);
|
AppDomain.Unload(ads.CurrentAppDomain);
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Console.WriteLine("AppDomain unload freed " + (m - GC.GetTotalMemory(true)) +
|
Console.WriteLine("AppDomain unload freed " + (m - GC.GetTotalMemory(true)) +
|
||||||
" bytes of memory");
|
" bytes of memory");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // foreach
|
}
|
||||||
} // lock
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LSL_BaseClass LoadScript(string FileName)
|
||||||
public LSL_BaseClass LoadScript(string FileName)
|
{
|
||||||
{
|
// Find next available AppDomain to put it in
|
||||||
// Find next available AppDomain to put it in
|
AppDomainStructure FreeAppDomain = GetFreeAppDomain();
|
||||||
AppDomainStructure FreeAppDomain = GetFreeAppDomain();
|
|
||||||
|
Console.WriteLine("Loading into AppDomain: " + FileName);
|
||||||
Console.WriteLine("Loading into AppDomain: " + FileName);
|
LSL_BaseClass mbrt =
|
||||||
LSL_BaseClass mbrt =
|
(LSL_BaseClass)
|
||||||
(LSL_BaseClass)
|
FreeAppDomain.CurrentAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script");
|
||||||
FreeAppDomain.CurrentAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script");
|
//Console.WriteLine("ScriptEngine AppDomainManager: is proxy={0}", RemotingServices.IsTransparentProxy(mbrt));
|
||||||
//Console.WriteLine("ScriptEngine AppDomainManager: is proxy={0}", RemotingServices.IsTransparentProxy(mbrt));
|
FreeAppDomain.ScriptsLoaded++;
|
||||||
FreeAppDomain.ScriptsLoaded++;
|
|
||||||
|
return mbrt;
|
||||||
return mbrt;
|
}
|
||||||
}
|
|
||||||
|
/// <summary>
|
||||||
|
/// Increase "dead script" counter for an AppDomain
|
||||||
/// <summary>
|
/// </summary>
|
||||||
/// Increase "dead script" counter for an AppDomain
|
/// <param name="ad"></param>
|
||||||
/// </summary>
|
//[Obsolete("Needs fixing, needs a real purpose in life!!!")]
|
||||||
/// <param name="ad"></param>
|
public void StopScript(AppDomain ad)
|
||||||
//[Obsolete("Needs fixing, needs a real purpose in life!!!")]
|
{
|
||||||
public void StopScript(AppDomain ad)
|
lock (freeLock)
|
||||||
{
|
{
|
||||||
lock (freeLock)
|
Console.WriteLine("Stopping script in AppDomain");
|
||||||
{
|
// Check if it is current AppDomain
|
||||||
Console.WriteLine("Stopping script in AppDomain");
|
if (currentAD.CurrentAppDomain == ad)
|
||||||
// Check if it is current AppDomain
|
{
|
||||||
if (currentAD.CurrentAppDomain == ad)
|
// Yes - increase
|
||||||
{
|
currentAD.ScriptsWaitingUnload++;
|
||||||
// Yes - increase
|
return;
|
||||||
currentAD.ScriptsWaitingUnload++;
|
}
|
||||||
return;
|
|
||||||
}
|
// Lopp through all AppDomains
|
||||||
|
foreach (AppDomainStructure ads in new ArrayList(appDomains))
|
||||||
// Lopp through all AppDomains
|
{
|
||||||
foreach (AppDomainStructure ads in new ArrayList(appDomains))
|
if (ads.CurrentAppDomain == ad)
|
||||||
{
|
{
|
||||||
if (ads.CurrentAppDomain == ad)
|
// Found it
|
||||||
{
|
ads.ScriptsWaitingUnload++;
|
||||||
// Found it
|
break;
|
||||||
ads.ScriptsWaitingUnload++;
|
}
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
} // foreach
|
|
||||||
} // lock
|
UnloadAppDomains(); // Outsite lock, has its own GetLock
|
||||||
|
}
|
||||||
UnloadAppDomains(); // Outsite lock, has its own GetLock
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,55 +1,58 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/* Original code: Tedd Hansen */
|
/* Original code: Tedd Hansen */
|
||||||
namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
|
||||||
{
|
namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||||
public static class Common
|
{
|
||||||
{
|
public static class Common
|
||||||
public static bool debug = true;
|
{
|
||||||
public static ScriptEngine mySE;
|
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
//public delegate void SendToDebugEventDelegate(string Message);
|
public static bool debug = true;
|
||||||
//public delegate void SendToLogEventDelegate(string Message);
|
public static ScriptEngine mySE;
|
||||||
//static public event SendToDebugEventDelegate SendToDebugEvent;
|
|
||||||
//static public event SendToLogEventDelegate SendToLogEvent;
|
//public delegate void SendToDebugEventDelegate(string Message);
|
||||||
|
//public delegate void SendToLogEventDelegate(string Message);
|
||||||
public static void SendToDebug(string Message)
|
//static public event SendToDebugEventDelegate SendToDebugEvent;
|
||||||
{
|
//static public event SendToLogEventDelegate SendToLogEvent;
|
||||||
//if (Debug == true)
|
|
||||||
mySE.Log.Verbose("ScriptEngine", "Debug: " + Message);
|
public static void SendToDebug(string Message)
|
||||||
//SendToDebugEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message);
|
{
|
||||||
}
|
//if (Debug == true)
|
||||||
|
mySE.m_log.Info("[ScriptEngine]: Debug: " + Message);
|
||||||
public static void SendToLog(string Message)
|
//SendToDebugEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message);
|
||||||
{
|
}
|
||||||
//if (Debug == true)
|
|
||||||
mySE.Log.Verbose("ScriptEngine", "LOG: " + Message);
|
public static void SendToLog(string Message)
|
||||||
//SendToLogEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message);
|
{
|
||||||
}
|
//if (Debug == true)
|
||||||
}
|
mySE.m_log.Info("[ScriptEngine]: LOG: " + Message);
|
||||||
}
|
//SendToLogEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,146 +1,146 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.CodeDom.Compiler;
|
using System.CodeDom.Compiler;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Microsoft.CSharp;
|
using Microsoft.CSharp;
|
||||||
|
|
||||||
namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL
|
namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL
|
||||||
{
|
{
|
||||||
public class Compiler
|
public class Compiler
|
||||||
{
|
{
|
||||||
private LSL2CSConverter LSL_Converter = new LSL2CSConverter();
|
private LSL2CSConverter LSL_Converter = new LSL2CSConverter();
|
||||||
private CSharpCodeProvider codeProvider = new CSharpCodeProvider();
|
private CSharpCodeProvider codeProvider = new CSharpCodeProvider();
|
||||||
private static UInt64 scriptCompileCounter = 0;
|
private static UInt64 scriptCompileCounter = 0;
|
||||||
//private ICodeCompiler icc = codeProvider.CreateCompiler();
|
//private ICodeCompiler icc = codeProvider.CreateCompiler();
|
||||||
public string CompileFromFile(string LSOFileName)
|
public string CompileFromFile(string LSOFileName)
|
||||||
{
|
{
|
||||||
switch (Path.GetExtension(LSOFileName).ToLower())
|
switch (Path.GetExtension(LSOFileName).ToLower())
|
||||||
{
|
{
|
||||||
case ".txt":
|
case ".txt":
|
||||||
case ".lsl":
|
case ".lsl":
|
||||||
Common.SendToDebug("Source code is LSL, converting to CS");
|
Common.SendToDebug("Source code is LSL, converting to CS");
|
||||||
return CompileFromLSLText(File.ReadAllText(LSOFileName));
|
return CompileFromLSLText(File.ReadAllText(LSOFileName));
|
||||||
case ".cs":
|
case ".cs":
|
||||||
Common.SendToDebug("Source code is CS");
|
Common.SendToDebug("Source code is CS");
|
||||||
return CompileFromCSText(File.ReadAllText(LSOFileName));
|
return CompileFromCSText(File.ReadAllText(LSOFileName));
|
||||||
default:
|
default:
|
||||||
throw new Exception("Unknown script type.");
|
throw new Exception("Unknown script type.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts script from LSL to CS and calls CompileFromCSText
|
/// Converts script from LSL to CS and calls CompileFromCSText
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="Script">LSL script</param>
|
/// <param name="Script">LSL script</param>
|
||||||
/// <returns>Filename to .dll assembly</returns>
|
/// <returns>Filename to .dll assembly</returns>
|
||||||
public string CompileFromLSLText(string Script)
|
public string CompileFromLSLText(string Script)
|
||||||
{
|
{
|
||||||
if (Script.Substring(0, 4).ToLower() == "//c#")
|
if (Script.Substring(0, 4).ToLower() == "//c#")
|
||||||
{
|
{
|
||||||
return CompileFromCSText(Script);
|
return CompileFromCSText(Script);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return CompileFromCSText(LSL_Converter.Convert(Script));
|
return CompileFromCSText(LSL_Converter.Convert(Script));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Compile CS script to .Net assembly (.dll)
|
/// Compile CS script to .Net assembly (.dll)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="Script">CS script</param>
|
/// <param name="Script">CS script</param>
|
||||||
/// <returns>Filename to .dll assembly</returns>
|
/// <returns>Filename to .dll assembly</returns>
|
||||||
public string CompileFromCSText(string Script)
|
public string CompileFromCSText(string Script)
|
||||||
{
|
{
|
||||||
// Output assembly name
|
// Output assembly name
|
||||||
scriptCompileCounter++;
|
scriptCompileCounter++;
|
||||||
string OutFile = Path.Combine("ScriptEngines", "Script_" + scriptCompileCounter + ".dll");
|
string OutFile = Path.Combine("ScriptEngines", "Script_" + scriptCompileCounter + ".dll");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.Delete(OutFile);
|
File.Delete(OutFile);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Exception attempting to delete old compiled script: " + e.ToString());
|
Console.WriteLine("Exception attempting to delete old compiled script: " + e.ToString());
|
||||||
}
|
}
|
||||||
//string OutFile = Path.Combine("ScriptEngines", "SecondLife.Script.dll");
|
//string OutFile = Path.Combine("ScriptEngines", "SecondLife.Script.dll");
|
||||||
|
|
||||||
// DEBUG - write source to disk
|
// DEBUG - write source to disk
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.WriteAllText(
|
File.WriteAllText(
|
||||||
Path.Combine("ScriptEngines", "debug_" + Path.GetFileNameWithoutExtension(OutFile) + ".cs"), Script);
|
Path.Combine("ScriptEngines", "debug_" + Path.GetFileNameWithoutExtension(OutFile) + ".cs"), Script);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do actual compile
|
// Do actual compile
|
||||||
CompilerParameters parameters = new CompilerParameters();
|
CompilerParameters parameters = new CompilerParameters();
|
||||||
parameters.IncludeDebugInformation = true;
|
parameters.IncludeDebugInformation = true;
|
||||||
// Add all available assemblies
|
// Add all available assemblies
|
||||||
foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
|
foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
{
|
{
|
||||||
//Console.WriteLine("Adding assembly: " + asm.Location);
|
//Console.WriteLine("Adding assembly: " + asm.Location);
|
||||||
//parameters.ReferencedAssemblies.Add(asm.Location);
|
//parameters.ReferencedAssemblies.Add(asm.Location);
|
||||||
}
|
}
|
||||||
|
|
||||||
string rootPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
|
string rootPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
|
||||||
string rootPathSE = Path.GetDirectoryName(GetType().Assembly.Location);
|
string rootPathSE = Path.GetDirectoryName(GetType().Assembly.Location);
|
||||||
//Console.WriteLine("Assembly location: " + rootPath);
|
//Console.WriteLine("Assembly location: " + rootPath);
|
||||||
parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Common.dll"));
|
parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Common.dll"));
|
||||||
parameters.ReferencedAssemblies.Add(Path.Combine(rootPathSE, "OpenSim.Grid.ScriptEngine.DotNetEngine.dll"));
|
parameters.ReferencedAssemblies.Add(Path.Combine(rootPathSE, "OpenSim.Grid.ScriptEngine.DotNetEngine.dll"));
|
||||||
|
|
||||||
//parameters.ReferencedAssemblies.Add("OpenSim.Region.Environment");
|
//parameters.ReferencedAssemblies.Add("OpenSim.Region.Environment");
|
||||||
parameters.GenerateExecutable = false;
|
parameters.GenerateExecutable = false;
|
||||||
parameters.OutputAssembly = OutFile;
|
parameters.OutputAssembly = OutFile;
|
||||||
parameters.IncludeDebugInformation = false;
|
parameters.IncludeDebugInformation = false;
|
||||||
CompilerResults results = codeProvider.CompileAssemblyFromSource(parameters, Script);
|
CompilerResults results = codeProvider.CompileAssemblyFromSource(parameters, Script);
|
||||||
|
|
||||||
// Go through errors
|
// Go through errors
|
||||||
// TODO: Return errors to user somehow
|
// TODO: Return errors to user somehow
|
||||||
if (results.Errors.Count > 0)
|
if (results.Errors.Count > 0)
|
||||||
{
|
{
|
||||||
string errtext = "";
|
string errtext = "";
|
||||||
foreach (CompilerError CompErr in results.Errors)
|
foreach (CompilerError CompErr in results.Errors)
|
||||||
{
|
{
|
||||||
errtext += "Line number " + (CompErr.Line - 1) +
|
errtext += "Line number " + (CompErr.Line - 1) +
|
||||||
", Error Number: " + CompErr.ErrorNumber +
|
", Error Number: " + CompErr.ErrorNumber +
|
||||||
", '" + CompErr.ErrorText + "'\r\n";
|
", '" + CompErr.ErrorText + "'\r\n";
|
||||||
}
|
}
|
||||||
throw new Exception(errtext);
|
throw new Exception(errtext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return OutFile;
|
return OutFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,316 +1,316 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL
|
namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL
|
||||||
{
|
{
|
||||||
public class LSL2CSConverter
|
public class LSL2CSConverter
|
||||||
{
|
{
|
||||||
//private Regex rnw = new Regex(@"[a-zA-Z0-9_\-]", RegexOptions.Compiled);
|
//private Regex rnw = new Regex(@"[a-zA-Z0-9_\-]", RegexOptions.Compiled);
|
||||||
private Dictionary<string, string> dataTypes = new Dictionary<string, string>();
|
private Dictionary<string, string> dataTypes = new Dictionary<string, string>();
|
||||||
private Dictionary<string, string> quotes = new Dictionary<string, string>();
|
private Dictionary<string, string> quotes = new Dictionary<string, string>();
|
||||||
|
|
||||||
public LSL2CSConverter()
|
public LSL2CSConverter()
|
||||||
{
|
{
|
||||||
// Only the types we need to convert
|
// Only the types we need to convert
|
||||||
dataTypes.Add("void", "void");
|
dataTypes.Add("void", "void");
|
||||||
dataTypes.Add("integer", "int");
|
dataTypes.Add("integer", "int");
|
||||||
dataTypes.Add("float", "double");
|
dataTypes.Add("float", "double");
|
||||||
dataTypes.Add("string", "string");
|
dataTypes.Add("string", "string");
|
||||||
dataTypes.Add("key", "string");
|
dataTypes.Add("key", "string");
|
||||||
dataTypes.Add("vector", "LSL_Types.Vector3");
|
dataTypes.Add("vector", "LSL_Types.Vector3");
|
||||||
dataTypes.Add("rotation", "LSL_Types.Quaternion");
|
dataTypes.Add("rotation", "LSL_Types.Quaternion");
|
||||||
dataTypes.Add("list", "list");
|
dataTypes.Add("list", "list");
|
||||||
dataTypes.Add("null", "null");
|
dataTypes.Add("null", "null");
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Convert(string Script)
|
public string Convert(string Script)
|
||||||
{
|
{
|
||||||
string Return = "";
|
string Return = "";
|
||||||
Script = " \r\n" + Script;
|
Script = " \r\n" + Script;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Prepare script for processing
|
// Prepare script for processing
|
||||||
//
|
//
|
||||||
|
|
||||||
// Clean up linebreaks
|
// Clean up linebreaks
|
||||||
Script = Regex.Replace(Script, @"\r\n", "\n");
|
Script = Regex.Replace(Script, @"\r\n", "\n");
|
||||||
Script = Regex.Replace(Script, @"\n", "\r\n");
|
Script = Regex.Replace(Script, @"\n", "\r\n");
|
||||||
|
|
||||||
|
|
||||||
// QUOTE REPLACEMENT
|
// QUOTE REPLACEMENT
|
||||||
// temporarily replace quotes so we can work our magic on the script without
|
// temporarily replace quotes so we can work our magic on the script without
|
||||||
// always considering if we are inside our outside ""'s
|
// always considering if we are inside our outside ""'s
|
||||||
string _Script = "";
|
string _Script = "";
|
||||||
string C;
|
string C;
|
||||||
bool in_quote = false;
|
bool in_quote = false;
|
||||||
bool quote_replaced = false;
|
bool quote_replaced = false;
|
||||||
string quote_replacement_string = "Q_U_O_T_E_REPLACEMENT_";
|
string quote_replacement_string = "Q_U_O_T_E_REPLACEMENT_";
|
||||||
string quote = "";
|
string quote = "";
|
||||||
bool last_was_escape = false;
|
bool last_was_escape = false;
|
||||||
int quote_replaced_count = 0;
|
int quote_replaced_count = 0;
|
||||||
for (int p = 0; p < Script.Length; p++)
|
for (int p = 0; p < Script.Length; p++)
|
||||||
{
|
{
|
||||||
C = Script.Substring(p, 1);
|
C = Script.Substring(p, 1);
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
// found " and last was not \ so this is not an escaped \"
|
// found " and last was not \ so this is not an escaped \"
|
||||||
if (C == "\"" && last_was_escape == false)
|
if (C == "\"" && last_was_escape == false)
|
||||||
{
|
{
|
||||||
// Toggle inside/outside quote
|
// Toggle inside/outside quote
|
||||||
in_quote = !in_quote;
|
in_quote = !in_quote;
|
||||||
if (in_quote)
|
if (in_quote)
|
||||||
{
|
{
|
||||||
quote_replaced_count++;
|
quote_replaced_count++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (quote == "")
|
if (quote == "")
|
||||||
{
|
{
|
||||||
// We didn't replace quote, probably because of empty string?
|
// We didn't replace quote, probably because of empty string?
|
||||||
_Script += quote_replacement_string +
|
_Script += quote_replacement_string +
|
||||||
quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]);
|
quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]);
|
||||||
}
|
}
|
||||||
// We just left a quote
|
// We just left a quote
|
||||||
quotes.Add(
|
quotes.Add(
|
||||||
quote_replacement_string +
|
quote_replacement_string +
|
||||||
quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]), quote);
|
quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]), quote);
|
||||||
quote = "";
|
quote = "";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_quote)
|
if (!in_quote)
|
||||||
{
|
{
|
||||||
// We are not inside a quote
|
// We are not inside a quote
|
||||||
quote_replaced = false;
|
quote_replaced = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// We are inside a quote
|
// We are inside a quote
|
||||||
if (!quote_replaced)
|
if (!quote_replaced)
|
||||||
{
|
{
|
||||||
// Replace quote
|
// Replace quote
|
||||||
_Script += quote_replacement_string +
|
_Script += quote_replacement_string +
|
||||||
quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]);
|
quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]);
|
||||||
quote_replaced = true;
|
quote_replaced = true;
|
||||||
}
|
}
|
||||||
quote += C;
|
quote += C;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_Script += C;
|
_Script += C;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
last_was_escape = false;
|
last_was_escape = false;
|
||||||
if (C == @"\")
|
if (C == @"\")
|
||||||
{
|
{
|
||||||
last_was_escape = true;
|
last_was_escape = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Script = _Script;
|
Script = _Script;
|
||||||
//
|
//
|
||||||
// END OF QUOTE REPLACEMENT
|
// END OF QUOTE REPLACEMENT
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// PROCESS STATES
|
// PROCESS STATES
|
||||||
// Remove state definitions and add state names to start of each event within state
|
// Remove state definitions and add state names to start of each event within state
|
||||||
//
|
//
|
||||||
int ilevel = 0;
|
int ilevel = 0;
|
||||||
int lastlevel = 0;
|
int lastlevel = 0;
|
||||||
string ret = "";
|
string ret = "";
|
||||||
string cache = "";
|
string cache = "";
|
||||||
bool in_state = false;
|
bool in_state = false;
|
||||||
string current_statename = "";
|
string current_statename = "";
|
||||||
for (int p = 0; p < Script.Length; p++)
|
for (int p = 0; p < Script.Length; p++)
|
||||||
{
|
{
|
||||||
C = Script.Substring(p, 1);
|
C = Script.Substring(p, 1);
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
// inc / dec level
|
// inc / dec level
|
||||||
if (C == @"{")
|
if (C == @"{")
|
||||||
ilevel++;
|
ilevel++;
|
||||||
if (C == @"}")
|
if (C == @"}")
|
||||||
ilevel--;
|
ilevel--;
|
||||||
if (ilevel < 0)
|
if (ilevel < 0)
|
||||||
ilevel = 0;
|
ilevel = 0;
|
||||||
cache += C;
|
cache += C;
|
||||||
|
|
||||||
// if level == 0, add to return
|
// if level == 0, add to return
|
||||||
if (ilevel == 1 && lastlevel == 0)
|
if (ilevel == 1 && lastlevel == 0)
|
||||||
{
|
{
|
||||||
// 0 => 1: Get last
|
// 0 => 1: Get last
|
||||||
Match m =
|
Match m =
|
||||||
Regex.Match(cache, @"(?![a-zA-Z_]+)\s*([a-zA-Z_]+)[^a-zA-Z_\(\)]*{",
|
Regex.Match(cache, @"(?![a-zA-Z_]+)\s*([a-zA-Z_]+)[^a-zA-Z_\(\)]*{",
|
||||||
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
||||||
|
|
||||||
in_state = false;
|
in_state = false;
|
||||||
if (m.Success)
|
if (m.Success)
|
||||||
{
|
{
|
||||||
// Go back to level 0, this is not a state
|
// Go back to level 0, this is not a state
|
||||||
in_state = true;
|
in_state = true;
|
||||||
current_statename = m.Groups[1].Captures[0].Value;
|
current_statename = m.Groups[1].Captures[0].Value;
|
||||||
//Console.WriteLine("Current statename: " + current_statename);
|
//Console.WriteLine("Current statename: " + current_statename);
|
||||||
cache =
|
cache =
|
||||||
Regex.Replace(cache,
|
Regex.Replace(cache,
|
||||||
@"(?<s1>(?![a-zA-Z_]+)\s*)" + @"([a-zA-Z_]+)(?<s2>[^a-zA-Z_\(\)]*){",
|
@"(?<s1>(?![a-zA-Z_]+)\s*)" + @"([a-zA-Z_]+)(?<s2>[^a-zA-Z_\(\)]*){",
|
||||||
"${s1}${s2}",
|
"${s1}${s2}",
|
||||||
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
||||||
}
|
}
|
||||||
ret += cache;
|
ret += cache;
|
||||||
cache = "";
|
cache = "";
|
||||||
}
|
}
|
||||||
if (ilevel == 0 && lastlevel == 1)
|
if (ilevel == 0 && lastlevel == 1)
|
||||||
{
|
{
|
||||||
// 1 => 0: Remove last }
|
// 1 => 0: Remove last }
|
||||||
if (in_state == true)
|
if (in_state == true)
|
||||||
{
|
{
|
||||||
cache = cache.Remove(cache.Length - 1, 1);
|
cache = cache.Remove(cache.Length - 1, 1);
|
||||||
//cache = Regex.Replace(cache, "}$", "", RegexOptions.Multiline | RegexOptions.Singleline);
|
//cache = Regex.Replace(cache, "}$", "", RegexOptions.Multiline | RegexOptions.Singleline);
|
||||||
|
|
||||||
//Replace function names
|
//Replace function names
|
||||||
// void dataserver(key query_id, string data) {
|
// void dataserver(key query_id, string data) {
|
||||||
//cache = Regex.Replace(cache, @"([^a-zA-Z_]\s*)((?!if|switch|for)[a-zA-Z_]+\s*\([^\)]*\)[^{]*{)", "$1" + "<STATE>" + "$2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
//cache = Regex.Replace(cache, @"([^a-zA-Z_]\s*)((?!if|switch|for)[a-zA-Z_]+\s*\([^\)]*\)[^{]*{)", "$1" + "<STATE>" + "$2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
||||||
//Console.WriteLine("Replacing using statename: " + current_statename);
|
//Console.WriteLine("Replacing using statename: " + current_statename);
|
||||||
cache =
|
cache =
|
||||||
Regex.Replace(cache,
|
Regex.Replace(cache,
|
||||||
@"^(\s*)((?!(if|switch|for)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)",
|
@"^(\s*)((?!(if|switch|for)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)",
|
||||||
@"$1public " + current_statename + "_event_$2",
|
@"$1public " + current_statename + "_event_$2",
|
||||||
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret += cache;
|
ret += cache;
|
||||||
cache = "";
|
cache = "";
|
||||||
in_state = true;
|
in_state = true;
|
||||||
current_statename = "";
|
current_statename = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
lastlevel = ilevel;
|
lastlevel = ilevel;
|
||||||
}
|
}
|
||||||
ret += cache;
|
ret += cache;
|
||||||
cache = "";
|
cache = "";
|
||||||
|
|
||||||
Script = ret;
|
Script = ret;
|
||||||
ret = "";
|
ret = "";
|
||||||
|
|
||||||
|
|
||||||
foreach (string key in dataTypes.Keys)
|
foreach (string key in dataTypes.Keys)
|
||||||
{
|
{
|
||||||
string val;
|
string val;
|
||||||
dataTypes.TryGetValue(key, out val);
|
dataTypes.TryGetValue(key, out val);
|
||||||
|
|
||||||
// Replace CAST - (integer) with (int)
|
// Replace CAST - (integer) with (int)
|
||||||
Script =
|
Script =
|
||||||
Regex.Replace(Script, @"\(" + key + @"\)", @"(" + val + ")",
|
Regex.Replace(Script, @"\(" + key + @"\)", @"(" + val + ")",
|
||||||
RegexOptions.Compiled | RegexOptions.Multiline);
|
RegexOptions.Compiled | RegexOptions.Multiline);
|
||||||
// Replace return types and function variables - integer a() and f(integer a, integer a)
|
// Replace return types and function variables - integer a() and f(integer a, integer a)
|
||||||
Script =
|
Script =
|
||||||
Regex.Replace(Script, @"(^|;|}|[\(,])(\s*)" + key + @"(\s*)", @"$1$2" + val + "$3",
|
Regex.Replace(Script, @"(^|;|}|[\(,])(\s*)" + key + @"(\s*)", @"$1$2" + val + "$3",
|
||||||
RegexOptions.Compiled | RegexOptions.Multiline);
|
RegexOptions.Compiled | RegexOptions.Multiline);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add "void" in front of functions that needs it
|
// Add "void" in front of functions that needs it
|
||||||
Script =
|
Script =
|
||||||
Regex.Replace(Script,
|
Regex.Replace(Script,
|
||||||
@"^(\s*public\s+)((?!(if|switch|for)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)",
|
@"^(\s*public\s+)((?!(if|switch|for)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)",
|
||||||
@"$1void $2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
@"$1void $2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
||||||
|
|
||||||
// Replace <x,y,z> and <x,y,z,r>
|
// Replace <x,y,z> and <x,y,z,r>
|
||||||
Script =
|
Script =
|
||||||
Regex.Replace(Script, @"<([^,>]*,[^,>]*,[^,>]*,[^,>]*)>", @"new LSL_Types.Quaternion($1)",
|
Regex.Replace(Script, @"<([^,>]*,[^,>]*,[^,>]*,[^,>]*)>", @"new LSL_Types.Quaternion($1)",
|
||||||
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
||||||
Script =
|
Script =
|
||||||
Regex.Replace(Script, @"<([^,>]*,[^,>]*,[^,>]*)>", @"new LSL_Types.Vector3($1)",
|
Regex.Replace(Script, @"<([^,>]*,[^,>]*,[^,>]*)>", @"new LSL_Types.Vector3($1)",
|
||||||
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
||||||
|
|
||||||
// Replace List []'s
|
// Replace List []'s
|
||||||
Script =
|
Script =
|
||||||
Regex.Replace(Script, @"\[([^\]]*)\]", @"List.Parse($1)",
|
Regex.Replace(Script, @"\[([^\]]*)\]", @"List.Parse($1)",
|
||||||
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
||||||
|
|
||||||
|
|
||||||
// Replace (string) to .ToString() //
|
// Replace (string) to .ToString() //
|
||||||
Script =
|
Script =
|
||||||
Regex.Replace(Script, @"\(string\)\s*([a-zA-Z0-9_]+(\s*\([^\)]*\))?)", @"$1.ToString()",
|
Regex.Replace(Script, @"\(string\)\s*([a-zA-Z0-9_]+(\s*\([^\)]*\))?)", @"$1.ToString()",
|
||||||
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
||||||
Script =
|
Script =
|
||||||
Regex.Replace(Script, @"\((float|int)\)\s*([a-zA-Z0-9_]+(\s*\([^\)]*\))?)", @"$1.Parse($2)",
|
Regex.Replace(Script, @"\((float|int)\)\s*([a-zA-Z0-9_]+(\s*\([^\)]*\))?)", @"$1.Parse($2)",
|
||||||
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
|
||||||
|
|
||||||
|
|
||||||
// REPLACE BACK QUOTES
|
// REPLACE BACK QUOTES
|
||||||
foreach (string key in quotes.Keys)
|
foreach (string key in quotes.Keys)
|
||||||
{
|
{
|
||||||
string val;
|
string val;
|
||||||
quotes.TryGetValue(key, out val);
|
quotes.TryGetValue(key, out val);
|
||||||
Script = Script.Replace(key, "\"" + val + "\"");
|
Script = Script.Replace(key, "\"" + val + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Add namespace, class name and inheritance
|
// Add namespace, class name and inheritance
|
||||||
|
|
||||||
Return = "" +
|
Return = "" +
|
||||||
"using OpenSim.Region.ScriptEngine.Common;";
|
"using OpenSim.Region.ScriptEngine.Common;";
|
||||||
//"using System; " +
|
//"using System; " +
|
||||||
//"using System.Collections.Generic; " +
|
//"using System.Collections.Generic; " +
|
||||||
//"using System.Text; " +
|
//"using System.Text; " +
|
||||||
//"using OpenSim.Region.ScriptEngine.Common; " +
|
//"using OpenSim.Region.ScriptEngine.Common; " +
|
||||||
//"using integer = System.Int32; " +
|
//"using integer = System.Int32; " +
|
||||||
//"using key = System.String; ";
|
//"using key = System.String; ";
|
||||||
|
|
||||||
//// Make a Using out of DataTypes
|
//// Make a Using out of DataTypes
|
||||||
//// Using integer = System.Int32;
|
//// Using integer = System.Int32;
|
||||||
//string _val;
|
//string _val;
|
||||||
//foreach (string key in DataTypes.Keys)
|
//foreach (string key in DataTypes.Keys)
|
||||||
//{
|
//{
|
||||||
// DataTypes.TryGetValue(key, out _val);
|
// DataTypes.TryGetValue(key, out _val);
|
||||||
// if (key != _val)
|
// if (key != _val)
|
||||||
// {
|
// {
|
||||||
// Return += "using " + key + " = " + _val + "; ";
|
// Return += "using " + key + " = " + _val + "; ";
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
Return += "" +
|
Return += "" +
|
||||||
"namespace SecondLife { ";
|
"namespace SecondLife { ";
|
||||||
Return += "" +
|
Return += "" +
|
||||||
//"[Serializable] " +
|
//"[Serializable] " +
|
||||||
"public class Script : OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass { ";
|
"public class Script : OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass { ";
|
||||||
Return += @"public Script() { } ";
|
Return += @"public Script() { } ";
|
||||||
Return += Script;
|
Return += Script;
|
||||||
Return += "} }\r\n";
|
Return += "} }\r\n";
|
||||||
|
|
||||||
return Return;
|
return Return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,86 +1,86 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenSim.Region.ScriptEngine.Common;
|
using OpenSim.Region.ScriptEngine.Common;
|
||||||
|
|
||||||
namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
|
namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
|
||||||
{
|
{
|
||||||
public partial class LSL_BaseClass
|
public partial class LSL_BaseClass
|
||||||
{
|
{
|
||||||
//public MemoryStream LSLStack = new MemoryStream();
|
//public MemoryStream LSLStack = new MemoryStream();
|
||||||
public Stack<object> LSLStack = new Stack<object>();
|
public Stack<object> LSLStack = new Stack<object>();
|
||||||
public Dictionary<uint, object> StaticVariables = new Dictionary<uint, object>();
|
public Dictionary<uint, object> StaticVariables = new Dictionary<uint, object>();
|
||||||
public Dictionary<uint, object> GlobalVariables = new Dictionary<uint, object>();
|
public Dictionary<uint, object> GlobalVariables = new Dictionary<uint, object>();
|
||||||
public Dictionary<uint, object> LocalVariables = new Dictionary<uint, object>();
|
public Dictionary<uint, object> LocalVariables = new Dictionary<uint, object>();
|
||||||
//public System.Collections.Generic.List<string> FunctionList = new System.Collections.Generic.List<string>();
|
//public System.Collections.Generic.List<string> FunctionList = new System.Collections.Generic.List<string>();
|
||||||
//public void AddFunction(String x) {
|
//public void AddFunction(String x) {
|
||||||
// FunctionList.Add(x);
|
// FunctionList.Add(x);
|
||||||
//}
|
//}
|
||||||
//public Stack<StackItemStruct> LSLStack = new Stack<StackItemStruct>;
|
//public Stack<StackItemStruct> LSLStack = new Stack<StackItemStruct>;
|
||||||
//public struct StackItemStruct
|
//public struct StackItemStruct
|
||||||
//{
|
//{
|
||||||
// public LSO_Enums.Variable_Type_Codes ItemType;
|
// public LSO_Enums.Variable_Type_Codes ItemType;
|
||||||
// public object Data;
|
// public object Data;
|
||||||
//}
|
//}
|
||||||
public UInt32 State = 0;
|
public UInt32 State = 0;
|
||||||
public LSL_BuiltIn_Commands_Interface LSL_Builtins;
|
public LSL_BuiltIn_Commands_Interface LSL_Builtins;
|
||||||
|
|
||||||
public LSL_BuiltIn_Commands_Interface GetLSL_BuiltIn()
|
public LSL_BuiltIn_Commands_Interface GetLSL_BuiltIn()
|
||||||
{
|
{
|
||||||
return LSL_Builtins;
|
return LSL_Builtins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public LSL_BaseClass()
|
public LSL_BaseClass()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public virtual int OverrideMe()
|
public virtual int OverrideMe()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start(LSL_BuiltIn_Commands_Interface LSLBuiltins)
|
public void Start(LSL_BuiltIn_Commands_Interface LSLBuiltins)
|
||||||
{
|
{
|
||||||
LSL_Builtins = LSLBuiltins;
|
LSL_Builtins = LSLBuiltins;
|
||||||
|
|
||||||
Common.SendToLog("OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO.LSL_BaseClass.Start() called");
|
Common.SendToLog("OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO.LSL_BaseClass.Start() called");
|
||||||
//LSL_Builtins.llSay(0, "Test");
|
//LSL_Builtins.llSay(0, "Test");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddToStatic(UInt32 index, object obj)
|
public void AddToStatic(UInt32 index, object obj)
|
||||||
{
|
{
|
||||||
Common.SendToDebug("AddToStatic: " + index + " type: " + obj.GetType());
|
Common.SendToDebug("AddToStatic: " + index + " type: " + obj.GetType());
|
||||||
StaticVariables.Add(index, obj);
|
StaticVariables.Add(index, obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,401 +1,401 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//using System;
|
//using System;
|
||||||
//using System.Collections.Generic;
|
//using System.Collections.Generic;
|
||||||
//using System.Text;
|
//using System.Text;
|
||||||
|
|
||||||
//namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
|
//namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
|
||||||
//{
|
//{
|
||||||
// public partial class LSL_BaseClass
|
// public partial class LSL_BaseClass
|
||||||
// {
|
// {
|
||||||
|
|
||||||
|
|
||||||
// public float llSin() {
|
// public float llSin() {
|
||||||
// float f = (float)LSLStack.Pop();
|
// float f = (float)LSLStack.Pop();
|
||||||
// return LSL_Builtins.llSin(f);
|
// return LSL_Builtins.llSin(f);
|
||||||
// }
|
// }
|
||||||
// public float llCos() {
|
// public float llCos() {
|
||||||
// float f = (float)LSLStack.Pop();
|
// float f = (float)LSLStack.Pop();
|
||||||
// return LSL_Builtins.llCos(f);
|
// return LSL_Builtins.llCos(f);
|
||||||
// }
|
// }
|
||||||
// public float llTan() {
|
// public float llTan() {
|
||||||
// float f = (float)LSLStack.Pop();
|
// float f = (float)LSLStack.Pop();
|
||||||
// return LSL_Builtins.llTan(f);
|
// return LSL_Builtins.llTan(f);
|
||||||
// }
|
// }
|
||||||
// public float llAtan2() {
|
// public float llAtan2() {
|
||||||
// float x = (float)LSLStack.Pop();
|
// float x = (float)LSLStack.Pop();
|
||||||
// float y = (float)LSLStack.Pop();
|
// float y = (float)LSLStack.Pop();
|
||||||
// return LSL_Builtins.llAtan2(x, y);
|
// return LSL_Builtins.llAtan2(x, y);
|
||||||
// }
|
// }
|
||||||
// public float llSqrt() {
|
// public float llSqrt() {
|
||||||
// float f = (float)LSLStack.Pop();
|
// float f = (float)LSLStack.Pop();
|
||||||
// return LSL_Builtins.llSqrt(f);
|
// return LSL_Builtins.llSqrt(f);
|
||||||
// }
|
// }
|
||||||
// float llPow()
|
// float llPow()
|
||||||
// {
|
// {
|
||||||
// float fexponent = (float)LSLStack.Pop();
|
// float fexponent = (float)LSLStack.Pop();
|
||||||
// float fbase = (float)LSLStack.Pop();
|
// float fbase = (float)LSLStack.Pop();
|
||||||
// return LSL_Builtins.llPow(fbase, fexponent);
|
// return LSL_Builtins.llPow(fbase, fexponent);
|
||||||
// }
|
// }
|
||||||
// //UInt32 llAbs(UInt32 i){ return; }
|
// //UInt32 llAbs(UInt32 i){ return; }
|
||||||
// //float llFabs(float f){ return; }
|
// //float llFabs(float f){ return; }
|
||||||
// //float llFrand(float mag){ return; }
|
// //float llFrand(float mag){ return; }
|
||||||
// //UInt32 llFloor(float f){ return; }
|
// //UInt32 llFloor(float f){ return; }
|
||||||
// //UInt32 llCeil(float f){ return; }
|
// //UInt32 llCeil(float f){ return; }
|
||||||
// //UInt32 llRound(float f){ return; }
|
// //UInt32 llRound(float f){ return; }
|
||||||
// //float llVecMag(LSO_Enums.Vector v){ return; }
|
// //float llVecMag(LSO_Enums.Vector v){ return; }
|
||||||
// //LSO_Enums.Vector llVecNorm(LSO_Enums.Vector v){ return; }
|
// //LSO_Enums.Vector llVecNorm(LSO_Enums.Vector v){ return; }
|
||||||
// //float llVecDist(LSO_Enums.Vector a, LSO_Enums.Vector b){ return; }
|
// //float llVecDist(LSO_Enums.Vector a, LSO_Enums.Vector b){ return; }
|
||||||
// //LSO_Enums.Vector llRot2Euler(LSO_Enums.Rotation r){ return; }
|
// //LSO_Enums.Vector llRot2Euler(LSO_Enums.Rotation r){ return; }
|
||||||
// //LSO_Enums.Rotation llEuler2Rot(LSO_Enums.Vector v){ return; }
|
// //LSO_Enums.Rotation llEuler2Rot(LSO_Enums.Vector v){ return; }
|
||||||
// //LSO_Enums.Rotation llAxes2Rot(LSO_Enums.Vector fwd, LSO_Enums.Vector left, LSO_Enums.Vector up){ return; }
|
// //LSO_Enums.Rotation llAxes2Rot(LSO_Enums.Vector fwd, LSO_Enums.Vector left, LSO_Enums.Vector up){ return; }
|
||||||
// //LSO_Enums.Vector llRot2Fwd(LSO_Enums.Rotation r){ return; }
|
// //LSO_Enums.Vector llRot2Fwd(LSO_Enums.Rotation r){ return; }
|
||||||
// //LSO_Enums.Vector llRot2Left(LSO_Enums.Rotation r){ return; }
|
// //LSO_Enums.Vector llRot2Left(LSO_Enums.Rotation r){ return; }
|
||||||
// //LSO_Enums.Vector llRot2Up(LSO_Enums.Rotation r){ return; }
|
// //LSO_Enums.Vector llRot2Up(LSO_Enums.Rotation r){ return; }
|
||||||
// //LSO_Enums.Rotation llRotBetween(LSO_Enums.Vector start, LSO_Enums.Vector end){ return; }
|
// //LSO_Enums.Rotation llRotBetween(LSO_Enums.Vector start, LSO_Enums.Vector end){ return; }
|
||||||
// public void llWhisper()
|
// public void llWhisper()
|
||||||
// {
|
// {
|
||||||
// UInt16 i = (UInt16)LSLStack.Pop();
|
// UInt16 i = (UInt16)LSLStack.Pop();
|
||||||
// string s = (string)LSLStack.Pop();
|
// string s = (string)LSLStack.Pop();
|
||||||
// LSL_Builtins.llWhisper(i, s);
|
// LSL_Builtins.llWhisper(i, s);
|
||||||
// }
|
// }
|
||||||
// public void llSay()
|
// public void llSay()
|
||||||
// {
|
// {
|
||||||
// UInt16 i = (UInt16)LSLStack.Pop();
|
// UInt16 i = (UInt16)LSLStack.Pop();
|
||||||
// string s = (string)LSLStack.Pop();
|
// string s = (string)LSLStack.Pop();
|
||||||
// LSL_Builtins.llSay(i, s);
|
// LSL_Builtins.llSay(i, s);
|
||||||
// }
|
// }
|
||||||
// //void llShout(UInt16 channelID, string text);
|
// //void llShout(UInt16 channelID, string text);
|
||||||
// //UInt32 llListen(UInt16 channelID, string name, LSO_Enums.Key ID, string msg);
|
// //UInt32 llListen(UInt16 channelID, string name, LSO_Enums.Key ID, string msg);
|
||||||
// //void llListenControl(UInt32 number, UInt32 active);
|
// //void llListenControl(UInt32 number, UInt32 active);
|
||||||
// //void llListenRemove(UInt32 number);
|
// //void llListenRemove(UInt32 number);
|
||||||
// //void llSensor(string name, LSO_Enums.Key id, UInt32 type, float range, float arc);
|
// //void llSensor(string name, LSO_Enums.Key id, UInt32 type, float range, float arc);
|
||||||
// //void llSensorRepeat(string name, LSO_Enums.Key id, UInt32 type, float range, float arc, float rate);
|
// //void llSensorRepeat(string name, LSO_Enums.Key id, UInt32 type, float range, float arc, float rate);
|
||||||
// //void llSensorRemove();
|
// //void llSensorRemove();
|
||||||
// //string llDetectedName(UInt32 number);
|
// //string llDetectedName(UInt32 number);
|
||||||
// //LSO_Enums.Key llDetectedKey(UInt32 number);
|
// //LSO_Enums.Key llDetectedKey(UInt32 number);
|
||||||
// //LSO_Enums.Key llDetectedOwner(UInt32 number);
|
// //LSO_Enums.Key llDetectedOwner(UInt32 number);
|
||||||
// //UInt32 llDetectedType(UInt32 number);
|
// //UInt32 llDetectedType(UInt32 number);
|
||||||
// //LSO_Enums.Vector llDetectedPos(UInt32 number);
|
// //LSO_Enums.Vector llDetectedPos(UInt32 number);
|
||||||
// //LSO_Enums.Vector llDetectedVel(UInt32 number);
|
// //LSO_Enums.Vector llDetectedVel(UInt32 number);
|
||||||
// //LSO_Enums.Vector llDetectedGrab(UInt32 number);
|
// //LSO_Enums.Vector llDetectedGrab(UInt32 number);
|
||||||
// //LSO_Enums.Rotation llDetectedRot(UInt32 number);
|
// //LSO_Enums.Rotation llDetectedRot(UInt32 number);
|
||||||
// //UInt32 llDetectedGroup(UInt32 number);
|
// //UInt32 llDetectedGroup(UInt32 number);
|
||||||
// //UInt32 llDetectedLinkNumber(UInt32 number);
|
// //UInt32 llDetectedLinkNumber(UInt32 number);
|
||||||
// //void llDie();
|
// //void llDie();
|
||||||
// //float llGround(LSO_Enums.Vector offset);
|
// //float llGround(LSO_Enums.Vector offset);
|
||||||
// //float llCloud(LSO_Enums.Vector offset);
|
// //float llCloud(LSO_Enums.Vector offset);
|
||||||
// //LSO_Enums.Vector llWind(LSO_Enums.Vector offset);
|
// //LSO_Enums.Vector llWind(LSO_Enums.Vector offset);
|
||||||
// //void llSetStatus(UInt32 status, UInt32 value);
|
// //void llSetStatus(UInt32 status, UInt32 value);
|
||||||
// //UInt32 llGetStatus(UInt32 status);
|
// //UInt32 llGetStatus(UInt32 status);
|
||||||
// //void llSetScale(LSO_Enums.Vector scale);
|
// //void llSetScale(LSO_Enums.Vector scale);
|
||||||
// //LSO_Enums.Vector llGetScale();
|
// //LSO_Enums.Vector llGetScale();
|
||||||
// //void llSetColor();
|
// //void llSetColor();
|
||||||
// //float llGetAlpha();
|
// //float llGetAlpha();
|
||||||
// //void llSetAlpha();
|
// //void llSetAlpha();
|
||||||
// //LSO_Enums.Vector llGetColor();
|
// //LSO_Enums.Vector llGetColor();
|
||||||
// //void llSetTexture();
|
// //void llSetTexture();
|
||||||
// //void llScaleTexture();
|
// //void llScaleTexture();
|
||||||
// //void llOffsetTexture();
|
// //void llOffsetTexture();
|
||||||
// //void llRotateTexture();
|
// //void llRotateTexture();
|
||||||
// //string llGetTexture();
|
// //string llGetTexture();
|
||||||
// //void llSetPos();
|
// //void llSetPos();
|
||||||
|
|
||||||
// public void llGetPos() { }
|
// public void llGetPos() { }
|
||||||
// public void llGetLocalPos() { }
|
// public void llGetLocalPos() { }
|
||||||
// public void llSetRot() { }
|
// public void llSetRot() { }
|
||||||
// public void llGetRot() { }
|
// public void llGetRot() { }
|
||||||
// public void llGetLocalRot() { }
|
// public void llGetLocalRot() { }
|
||||||
// public void llSetForce() { }
|
// public void llSetForce() { }
|
||||||
// public void llGetForce() { }
|
// public void llGetForce() { }
|
||||||
// public void llTarget() { }
|
// public void llTarget() { }
|
||||||
// public void llTargetRemove() { }
|
// public void llTargetRemove() { }
|
||||||
// public void llRotTarget() { }
|
// public void llRotTarget() { }
|
||||||
// public void llRotTargetRemove() { }
|
// public void llRotTargetRemove() { }
|
||||||
// public void llMoveToTarget() { }
|
// public void llMoveToTarget() { }
|
||||||
// public void llStopMoveToTarget() { }
|
// public void llStopMoveToTarget() { }
|
||||||
// public void llApplyImpulse() { }
|
// public void llApplyImpulse() { }
|
||||||
// public void llApplyRotationalImpulse() { }
|
// public void llApplyRotationalImpulse() { }
|
||||||
// public void llSetTorque() { }
|
// public void llSetTorque() { }
|
||||||
// public void llGetTorque() { }
|
// public void llGetTorque() { }
|
||||||
// public void llSetForceAndTorque() { }
|
// public void llSetForceAndTorque() { }
|
||||||
// public void llGetVel() { }
|
// public void llGetVel() { }
|
||||||
// public void llGetAccel() { }
|
// public void llGetAccel() { }
|
||||||
// public void llGetOmega() { }
|
// public void llGetOmega() { }
|
||||||
// public void llGetTimeOfDay() { }
|
// public void llGetTimeOfDay() { }
|
||||||
// public void llGetWallclock() { }
|
// public void llGetWallclock() { }
|
||||||
// public void llGetTime() { }
|
// public void llGetTime() { }
|
||||||
// public void llResetTime() { }
|
// public void llResetTime() { }
|
||||||
// public void llGetAndResetTime() { }
|
// public void llGetAndResetTime() { }
|
||||||
// public void llSound() { }
|
// public void llSound() { }
|
||||||
// public void llPlaySound() { }
|
// public void llPlaySound() { }
|
||||||
// public void llLoopSound() { }
|
// public void llLoopSound() { }
|
||||||
// public void llLoopSoundMaster() { }
|
// public void llLoopSoundMaster() { }
|
||||||
// public void llLoopSoundSlave() { }
|
// public void llLoopSoundSlave() { }
|
||||||
// public void llPlaySoundSlave() { }
|
// public void llPlaySoundSlave() { }
|
||||||
// public void llTriggerSound() { }
|
// public void llTriggerSound() { }
|
||||||
// public void llStopSound() { }
|
// public void llStopSound() { }
|
||||||
// public void llPreloadSound() { }
|
// public void llPreloadSound() { }
|
||||||
// public void llGetSubString() { }
|
// public void llGetSubString() { }
|
||||||
// public void llDeleteSubString() { }
|
// public void llDeleteSubString() { }
|
||||||
// public void llInsertString() { }
|
// public void llInsertString() { }
|
||||||
// public void llToUpper() { }
|
// public void llToUpper() { }
|
||||||
// public void llToLower() { }
|
// public void llToLower() { }
|
||||||
// public void llGiveMoney() { }
|
// public void llGiveMoney() { }
|
||||||
// public void llMakeExplosion() { }
|
// public void llMakeExplosion() { }
|
||||||
// public void llMakeFountain() { }
|
// public void llMakeFountain() { }
|
||||||
// public void llMakeSmoke() { }
|
// public void llMakeSmoke() { }
|
||||||
// public void llMakeFire() { }
|
// public void llMakeFire() { }
|
||||||
// public void llRezObject() { }
|
// public void llRezObject() { }
|
||||||
// public void llLookAt() { }
|
// public void llLookAt() { }
|
||||||
// public void llStopLookAt() { }
|
// public void llStopLookAt() { }
|
||||||
// public void llSetTimerEvent() { }
|
// public void llSetTimerEvent() { }
|
||||||
// public void llSleep() { }
|
// public void llSleep() { }
|
||||||
// public void llGetMass() { }
|
// public void llGetMass() { }
|
||||||
// public void llCollisionFilter() { }
|
// public void llCollisionFilter() { }
|
||||||
// public void llTakeControls() { }
|
// public void llTakeControls() { }
|
||||||
// public void llReleaseControls() { }
|
// public void llReleaseControls() { }
|
||||||
// public void llAttachToAvatar() { }
|
// public void llAttachToAvatar() { }
|
||||||
// public void llDetachFromAvatar() { }
|
// public void llDetachFromAvatar() { }
|
||||||
// public void llTakeCamera() { }
|
// public void llTakeCamera() { }
|
||||||
// public void llReleaseCamera() { }
|
// public void llReleaseCamera() { }
|
||||||
// public void llGetOwner() { }
|
// public void llGetOwner() { }
|
||||||
// public void llInstantMessage() { }
|
// public void llInstantMessage() { }
|
||||||
// public void llEmail() { }
|
// public void llEmail() { }
|
||||||
// public void llGetNextEmail() { }
|
// public void llGetNextEmail() { }
|
||||||
// public void llGetKey() { }
|
// public void llGetKey() { }
|
||||||
// public void llSetBuoyancy() { }
|
// public void llSetBuoyancy() { }
|
||||||
// public void llSetHoverHeight() { }
|
// public void llSetHoverHeight() { }
|
||||||
// public void llStopHover() { }
|
// public void llStopHover() { }
|
||||||
// public void llMinEventDelay() { }
|
// public void llMinEventDelay() { }
|
||||||
// public void llSoundPreload() { }
|
// public void llSoundPreload() { }
|
||||||
// public void llRotLookAt() { }
|
// public void llRotLookAt() { }
|
||||||
// public void llStringLength() { }
|
// public void llStringLength() { }
|
||||||
// public void llStartAnimation() { }
|
// public void llStartAnimation() { }
|
||||||
// public void llStopAnimation() { }
|
// public void llStopAnimation() { }
|
||||||
// public void llPointAt() { }
|
// public void llPointAt() { }
|
||||||
// public void llStopPointAt() { }
|
// public void llStopPointAt() { }
|
||||||
// public void llTargetOmega() { }
|
// public void llTargetOmega() { }
|
||||||
// public void llGetStartParameter() { }
|
// public void llGetStartParameter() { }
|
||||||
// public void llGodLikeRezObject() { }
|
// public void llGodLikeRezObject() { }
|
||||||
// public void llRequestPermissions() { }
|
// public void llRequestPermissions() { }
|
||||||
// public void llGetPermissionsKey() { }
|
// public void llGetPermissionsKey() { }
|
||||||
// public void llGetPermissions() { }
|
// public void llGetPermissions() { }
|
||||||
// public void llGetLinkNumber() { }
|
// public void llGetLinkNumber() { }
|
||||||
// public void llSetLinkColor() { }
|
// public void llSetLinkColor() { }
|
||||||
// public void llCreateLink() { }
|
// public void llCreateLink() { }
|
||||||
// public void llBreakLink() { }
|
// public void llBreakLink() { }
|
||||||
// public void llBreakAllLinks() { }
|
// public void llBreakAllLinks() { }
|
||||||
// public void llGetLinkKey() { }
|
// public void llGetLinkKey() { }
|
||||||
// public void llGetLinkName() { }
|
// public void llGetLinkName() { }
|
||||||
// public void llGetInventoryNumber() { }
|
// public void llGetInventoryNumber() { }
|
||||||
// public void llGetInventoryName() { }
|
// public void llGetInventoryName() { }
|
||||||
// public void llSetScriptState() { }
|
// public void llSetScriptState() { }
|
||||||
// public void llGetEnergy() { }
|
// public void llGetEnergy() { }
|
||||||
// public void llGiveInventory() { }
|
// public void llGiveInventory() { }
|
||||||
// public void llRemoveInventory() { }
|
// public void llRemoveInventory() { }
|
||||||
// public void llSetText() { }
|
// public void llSetText() { }
|
||||||
// public void llWater() { }
|
// public void llWater() { }
|
||||||
// public void llPassTouches() { }
|
// public void llPassTouches() { }
|
||||||
// public void llRequestAgentData() { }
|
// public void llRequestAgentData() { }
|
||||||
// public void llRequestInventoryData() { }
|
// public void llRequestInventoryData() { }
|
||||||
// public void llSetDamage() { }
|
// public void llSetDamage() { }
|
||||||
// public void llTeleportAgentHome() { }
|
// public void llTeleportAgentHome() { }
|
||||||
// public void llModifyLand() { }
|
// public void llModifyLand() { }
|
||||||
// public void llCollisionSound() { }
|
// public void llCollisionSound() { }
|
||||||
// public void llCollisionSprite() { }
|
// public void llCollisionSprite() { }
|
||||||
// public void llGetAnimation() { }
|
// public void llGetAnimation() { }
|
||||||
// public void llResetScript() { }
|
// public void llResetScript() { }
|
||||||
// public void llMessageLinked() { }
|
// public void llMessageLinked() { }
|
||||||
// public void llPushObject() { }
|
// public void llPushObject() { }
|
||||||
// public void llPassCollisions() { }
|
// public void llPassCollisions() { }
|
||||||
// public void llGetScriptName() { }
|
// public void llGetScriptName() { }
|
||||||
// public void llGetNumberOfSides() { }
|
// public void llGetNumberOfSides() { }
|
||||||
// public void llAxisAngle2Rot() { }
|
// public void llAxisAngle2Rot() { }
|
||||||
// public void llRot2Axis() { }
|
// public void llRot2Axis() { }
|
||||||
// public void llRot2Angle() { }
|
// public void llRot2Angle() { }
|
||||||
// public void llAcos() { }
|
// public void llAcos() { }
|
||||||
// public void llAsin() { }
|
// public void llAsin() { }
|
||||||
// public void llAngleBetween() { }
|
// public void llAngleBetween() { }
|
||||||
// public void llGetInventoryKey() { }
|
// public void llGetInventoryKey() { }
|
||||||
// public void llAllowInventoryDrop() { }
|
// public void llAllowInventoryDrop() { }
|
||||||
// public void llGetSunDirection() { }
|
// public void llGetSunDirection() { }
|
||||||
// public void llGetTextureOffset() { }
|
// public void llGetTextureOffset() { }
|
||||||
// public void llGetTextureScale() { }
|
// public void llGetTextureScale() { }
|
||||||
// public void llGetTextureRot() { }
|
// public void llGetTextureRot() { }
|
||||||
// public void llSubStringIndex() { }
|
// public void llSubStringIndex() { }
|
||||||
// public void llGetOwnerKey() { }
|
// public void llGetOwnerKey() { }
|
||||||
// public void llGetCenterOfMass() { }
|
// public void llGetCenterOfMass() { }
|
||||||
// public void llListSort() { }
|
// public void llListSort() { }
|
||||||
// public void llGetListLength() { }
|
// public void llGetListLength() { }
|
||||||
// public void llList2Integer() { }
|
// public void llList2Integer() { }
|
||||||
// public void llList2Float() { }
|
// public void llList2Float() { }
|
||||||
// public void llList2String() { }
|
// public void llList2String() { }
|
||||||
// public void llList2Key() { }
|
// public void llList2Key() { }
|
||||||
// public void llList2Vector() { }
|
// public void llList2Vector() { }
|
||||||
// public void llList2Rot() { }
|
// public void llList2Rot() { }
|
||||||
// public void llList2List() { }
|
// public void llList2List() { }
|
||||||
// public void llDeleteSubList() { }
|
// public void llDeleteSubList() { }
|
||||||
// public void llGetListEntryType() { }
|
// public void llGetListEntryType() { }
|
||||||
// public void llList2CSV() { }
|
// public void llList2CSV() { }
|
||||||
// public void llCSV2List() { }
|
// public void llCSV2List() { }
|
||||||
// public void llListRandomize() { }
|
// public void llListRandomize() { }
|
||||||
// public void llList2ListStrided() { }
|
// public void llList2ListStrided() { }
|
||||||
// public void llGetRegionCorner() { }
|
// public void llGetRegionCorner() { }
|
||||||
// public void llListInsertList() { }
|
// public void llListInsertList() { }
|
||||||
// public void llListFindList() { }
|
// public void llListFindList() { }
|
||||||
// public void llGetObjectName() { }
|
// public void llGetObjectName() { }
|
||||||
// public void llSetObjectName() { }
|
// public void llSetObjectName() { }
|
||||||
// public void llGetDate() { }
|
// public void llGetDate() { }
|
||||||
// public void llEdgeOfWorld() { }
|
// public void llEdgeOfWorld() { }
|
||||||
// public void llGetAgentInfo() { }
|
// public void llGetAgentInfo() { }
|
||||||
// public void llAdjustSoundVolume() { }
|
// public void llAdjustSoundVolume() { }
|
||||||
// public void llSetSoundQueueing() { }
|
// public void llSetSoundQueueing() { }
|
||||||
// public void llSetSoundRadius() { }
|
// public void llSetSoundRadius() { }
|
||||||
// public void llKey2Name() { }
|
// public void llKey2Name() { }
|
||||||
// public void llSetTextureAnim() { }
|
// public void llSetTextureAnim() { }
|
||||||
// public void llTriggerSoundLimited() { }
|
// public void llTriggerSoundLimited() { }
|
||||||
// public void llEjectFromLand() { }
|
// public void llEjectFromLand() { }
|
||||||
// public void llParseString2List() { }
|
// public void llParseString2List() { }
|
||||||
// public void llOverMyLand() { }
|
// public void llOverMyLand() { }
|
||||||
// public void llGetLandOwnerAt() { }
|
// public void llGetLandOwnerAt() { }
|
||||||
// public void llGetNotecardLine() { }
|
// public void llGetNotecardLine() { }
|
||||||
// public void llGetAgentSize() { }
|
// public void llGetAgentSize() { }
|
||||||
// public void llSameGroup() { }
|
// public void llSameGroup() { }
|
||||||
// public void llUnSit() { }
|
// public void llUnSit() { }
|
||||||
// public void llGroundSlope() { }
|
// public void llGroundSlope() { }
|
||||||
// public void llGroundNormal() { }
|
// public void llGroundNormal() { }
|
||||||
// public void llGroundContour() { }
|
// public void llGroundContour() { }
|
||||||
// public void llGetAttached() { }
|
// public void llGetAttached() { }
|
||||||
// public void llGetFreeMemory() { }
|
// public void llGetFreeMemory() { }
|
||||||
// public void llGetRegionName() { }
|
// public void llGetRegionName() { }
|
||||||
// public void llGetRegionTimeDilation() { }
|
// public void llGetRegionTimeDilation() { }
|
||||||
// public void llGetRegionFPS() { }
|
// public void llGetRegionFPS() { }
|
||||||
// public void llParticleSystem() { }
|
// public void llParticleSystem() { }
|
||||||
// public void llGroundRepel() { }
|
// public void llGroundRepel() { }
|
||||||
// public void llGiveInventoryList() { }
|
// public void llGiveInventoryList() { }
|
||||||
// public void llSetVehicleType() { }
|
// public void llSetVehicleType() { }
|
||||||
// public void llSetVehicleFloatParam() { }
|
// public void llSetVehicleFloatParam() { }
|
||||||
// public void llSetVehicleVectorParam() { }
|
// public void llSetVehicleVectorParam() { }
|
||||||
// public void llSetVehicleRotationParam() { }
|
// public void llSetVehicleRotationParam() { }
|
||||||
// public void llSetVehicleFlags() { }
|
// public void llSetVehicleFlags() { }
|
||||||
// public void llRemoveVehicleFlags() { }
|
// public void llRemoveVehicleFlags() { }
|
||||||
// public void llSitTarget() { }
|
// public void llSitTarget() { }
|
||||||
// public void llAvatarOnSitTarget() { }
|
// public void llAvatarOnSitTarget() { }
|
||||||
// public void llAddToLandPassList() { }
|
// public void llAddToLandPassList() { }
|
||||||
// public void llSetTouchText() { }
|
// public void llSetTouchText() { }
|
||||||
// public void llSetSitText() { }
|
// public void llSetSitText() { }
|
||||||
// public void llSetCameraEyeOffset() { }
|
// public void llSetCameraEyeOffset() { }
|
||||||
// public void llSetCameraAtOffset() { }
|
// public void llSetCameraAtOffset() { }
|
||||||
// public void llDumpList2String() { }
|
// public void llDumpList2String() { }
|
||||||
// public void llScriptDanger() { }
|
// public void llScriptDanger() { }
|
||||||
// public void llDialog() { }
|
// public void llDialog() { }
|
||||||
// public void llVolumeDetect() { }
|
// public void llVolumeDetect() { }
|
||||||
// public void llResetOtherScript() { }
|
// public void llResetOtherScript() { }
|
||||||
// public void llGetScriptState() { }
|
// public void llGetScriptState() { }
|
||||||
// public void llRemoteLoadScript() { }
|
// public void llRemoteLoadScript() { }
|
||||||
// public void llSetRemoteScriptAccessPin() { }
|
// public void llSetRemoteScriptAccessPin() { }
|
||||||
// public void llRemoteLoadScriptPin() { }
|
// public void llRemoteLoadScriptPin() { }
|
||||||
// public void llOpenRemoteDataChannel() { }
|
// public void llOpenRemoteDataChannel() { }
|
||||||
// public void llSendRemoteData() { }
|
// public void llSendRemoteData() { }
|
||||||
// public void llRemoteDataReply() { }
|
// public void llRemoteDataReply() { }
|
||||||
// public void llCloseRemoteDataChannel() { }
|
// public void llCloseRemoteDataChannel() { }
|
||||||
// public void llMD5String() { }
|
// public void llMD5String() { }
|
||||||
// public void llSetPrimitiveParams() { }
|
// public void llSetPrimitiveParams() { }
|
||||||
// public void llStringToBase64() { }
|
// public void llStringToBase64() { }
|
||||||
// public void llBase64ToString() { }
|
// public void llBase64ToString() { }
|
||||||
// public void llXorBase64Strings() { }
|
// public void llXorBase64Strings() { }
|
||||||
// public void llRemoteDataSetRegion() { }
|
// public void llRemoteDataSetRegion() { }
|
||||||
// public void llLog10() { }
|
// public void llLog10() { }
|
||||||
// public void llLog() { }
|
// public void llLog() { }
|
||||||
// public void llGetAnimationList() { }
|
// public void llGetAnimationList() { }
|
||||||
// public void llSetParcelMusicURL() { }
|
// public void llSetParcelMusicURL() { }
|
||||||
// public void llGetRootPosition() { }
|
// public void llGetRootPosition() { }
|
||||||
// public void llGetRootRotation() { }
|
// public void llGetRootRotation() { }
|
||||||
// public void llGetObjectDesc() { }
|
// public void llGetObjectDesc() { }
|
||||||
// public void llSetObjectDesc() { }
|
// public void llSetObjectDesc() { }
|
||||||
// public void llGetCreator() { }
|
// public void llGetCreator() { }
|
||||||
// public void llGetTimestamp() { }
|
// public void llGetTimestamp() { }
|
||||||
// public void llSetLinkAlpha() { }
|
// public void llSetLinkAlpha() { }
|
||||||
// public void llGetNumberOfPrims() { }
|
// public void llGetNumberOfPrims() { }
|
||||||
// public void llGetNumberOfNotecardLines() { }
|
// public void llGetNumberOfNotecardLines() { }
|
||||||
// public void llGetBoundingBox() { }
|
// public void llGetBoundingBox() { }
|
||||||
// public void llGetGeometricCenter() { }
|
// public void llGetGeometricCenter() { }
|
||||||
// public void llGetPrimitiveParams() { }
|
// public void llGetPrimitiveParams() { }
|
||||||
// public void llIntegerToBase64() { }
|
// public void llIntegerToBase64() { }
|
||||||
// public void llBase64ToInteger() { }
|
// public void llBase64ToInteger() { }
|
||||||
// public void llGetGMTclock() { }
|
// public void llGetGMTclock() { }
|
||||||
// public void llGetSimulatorHostname() { }
|
// public void llGetSimulatorHostname() { }
|
||||||
// public void llSetLocalRot() { }
|
// public void llSetLocalRot() { }
|
||||||
// public void llParseStringKeepNulls() { }
|
// public void llParseStringKeepNulls() { }
|
||||||
// public void llRezAtRoot() { }
|
// public void llRezAtRoot() { }
|
||||||
// public void llGetObjectPermMask() { }
|
// public void llGetObjectPermMask() { }
|
||||||
// public void llSetObjectPermMask() { }
|
// public void llSetObjectPermMask() { }
|
||||||
// public void llGetInventoryPermMask() { }
|
// public void llGetInventoryPermMask() { }
|
||||||
// public void llSetInventoryPermMask() { }
|
// public void llSetInventoryPermMask() { }
|
||||||
// public void llGetInventoryCreator() { }
|
// public void llGetInventoryCreator() { }
|
||||||
// public void llOwnerSay() { }
|
// public void llOwnerSay() { }
|
||||||
// public void llRequestSimulatorData() { }
|
// public void llRequestSimulatorData() { }
|
||||||
// public void llForceMouselook() { }
|
// public void llForceMouselook() { }
|
||||||
// public void llGetObjectMass() { }
|
// public void llGetObjectMass() { }
|
||||||
// public void llListReplaceList() { }
|
// public void llListReplaceList() { }
|
||||||
// public void llLoadURL() { }
|
// public void llLoadURL() { }
|
||||||
// public void llParcelMediaCommandList() { }
|
// public void llParcelMediaCommandList() { }
|
||||||
// public void llParcelMediaQuery() { }
|
// public void llParcelMediaQuery() { }
|
||||||
// public void llModPow() { }
|
// public void llModPow() { }
|
||||||
// public void llGetInventoryType() { }
|
// public void llGetInventoryType() { }
|
||||||
// public void llSetPayPrice() { }
|
// public void llSetPayPrice() { }
|
||||||
// public void llGetCameraPos() { }
|
// public void llGetCameraPos() { }
|
||||||
// public void llGetCameraRot() { }
|
// public void llGetCameraRot() { }
|
||||||
// public void llSetPrimURL() { }
|
// public void llSetPrimURL() { }
|
||||||
// public void llRefreshPrimURL() { }
|
// public void llRefreshPrimURL() { }
|
||||||
// public void llEscapeURL() { }
|
// public void llEscapeURL() { }
|
||||||
// public void llUnescapeURL() { }
|
// public void llUnescapeURL() { }
|
||||||
// public void llMapDestination() { }
|
// public void llMapDestination() { }
|
||||||
// public void llAddToLandBanList() { }
|
// public void llAddToLandBanList() { }
|
||||||
// public void llRemoveFromLandPassList() { }
|
// public void llRemoveFromLandPassList() { }
|
||||||
// public void llRemoveFromLandBanList() { }
|
// public void llRemoveFromLandBanList() { }
|
||||||
// public void llSetCameraParams() { }
|
// public void llSetCameraParams() { }
|
||||||
// public void llClearCameraParams() { }
|
// public void llClearCameraParams() { }
|
||||||
// public void llListStatistics() { }
|
// public void llListStatistics() { }
|
||||||
// public void llGetUnixTime() { }
|
// public void llGetUnixTime() { }
|
||||||
// public void llGetParcelFlags() { }
|
// public void llGetParcelFlags() { }
|
||||||
// public void llGetRegionFlags() { }
|
// public void llGetRegionFlags() { }
|
||||||
// public void llXorBase64StringsCorrect() { }
|
// public void llXorBase64StringsCorrect() { }
|
||||||
// public void llHTTPRequest() { }
|
// public void llHTTPRequest() { }
|
||||||
// public void llResetLandBanList() { }
|
// public void llResetLandBanList() { }
|
||||||
// public void llResetLandPassList() { }
|
// public void llResetLandPassList() { }
|
||||||
// public void llGetParcelPrimCount() { }
|
// public void llGetParcelPrimCount() { }
|
||||||
// public void llGetParcelPrimOwners() { }
|
// public void llGetParcelPrimOwners() { }
|
||||||
// public void llGetObjectPrimCount() { }
|
// public void llGetObjectPrimCount() { }
|
||||||
// public void llGetParcelMaxPrims() { }
|
// public void llGetParcelMaxPrims() { }
|
||||||
// public void llGetParcelDetails() { }
|
// public void llGetParcelDetails() { }
|
||||||
|
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
|
@ -1,394 +1,394 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
|
namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
|
||||||
{
|
{
|
||||||
public partial class LSL_BaseClass
|
public partial class LSL_BaseClass
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* OPCODES
|
* OPCODES
|
||||||
*
|
*
|
||||||
* These are internal "assembly" commands,
|
* These are internal "assembly" commands,
|
||||||
* basic operators like "ADD", "PUSH" and "POP"
|
* basic operators like "ADD", "PUSH" and "POP"
|
||||||
*
|
*
|
||||||
* It also contains managed stack and keeps track of internal variables, etc.
|
* It also contains managed stack and keeps track of internal variables, etc.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
public void StoreToLocal(UInt32 index)
|
public void StoreToLocal(UInt32 index)
|
||||||
{
|
{
|
||||||
// TODO: How to determine local?
|
// TODO: How to determine local?
|
||||||
Common.SendToDebug("::StoreToLocal " + index);
|
Common.SendToDebug("::StoreToLocal " + index);
|
||||||
if (LocalVariables.ContainsKey(index))
|
if (LocalVariables.ContainsKey(index))
|
||||||
LocalVariables.Remove(index);
|
LocalVariables.Remove(index);
|
||||||
LocalVariables.Add(index, LSLStack.Peek());
|
LocalVariables.Add(index, LSLStack.Peek());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StoreToGlobal(UInt32 index)
|
public void StoreToGlobal(UInt32 index)
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::StoreToGlobal " + index);
|
Common.SendToDebug("::StoreToGlobal " + index);
|
||||||
if (GlobalVariables.ContainsKey(index))
|
if (GlobalVariables.ContainsKey(index))
|
||||||
GlobalVariables.Remove(index);
|
GlobalVariables.Remove(index);
|
||||||
GlobalVariables.Add(index, LSLStack.Peek());
|
GlobalVariables.Add(index, LSLStack.Peek());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StoreToStatic(UInt32 index)
|
public void StoreToStatic(UInt32 index)
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::StoreToStatic " + index);
|
Common.SendToDebug("::StoreToStatic " + index);
|
||||||
//if (StaticVariables.ContainsKey(index))
|
//if (StaticVariables.ContainsKey(index))
|
||||||
// StaticVariables.Remove(index);
|
// StaticVariables.Remove(index);
|
||||||
StaticVariables.Add(index, LSLStack.Peek());
|
StaticVariables.Add(index, LSLStack.Peek());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetFromLocal(UInt32 index)
|
public void GetFromLocal(UInt32 index)
|
||||||
{
|
{
|
||||||
// TODO: How to determine local?
|
// TODO: How to determine local?
|
||||||
Common.SendToDebug("::GetFromLocal " + index);
|
Common.SendToDebug("::GetFromLocal " + index);
|
||||||
object ret;
|
object ret;
|
||||||
LocalVariables.TryGetValue(index, out ret);
|
LocalVariables.TryGetValue(index, out ret);
|
||||||
LSLStack.Push(ret);
|
LSLStack.Push(ret);
|
||||||
//return ret;
|
//return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetFromGlobal(UInt32 index)
|
public void GetFromGlobal(UInt32 index)
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::GetFromGlobal " + index);
|
Common.SendToDebug("::GetFromGlobal " + index);
|
||||||
object ret;
|
object ret;
|
||||||
GlobalVariables.TryGetValue(index, out ret);
|
GlobalVariables.TryGetValue(index, out ret);
|
||||||
LSLStack.Push(ret);
|
LSLStack.Push(ret);
|
||||||
//return ret;
|
//return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetFromStatic(UInt32 index)
|
public void GetFromStatic(UInt32 index)
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::GetFromStatic " + index);
|
Common.SendToDebug("::GetFromStatic " + index);
|
||||||
object ret;
|
object ret;
|
||||||
StaticVariables.TryGetValue(index, out ret);
|
StaticVariables.TryGetValue(index, out ret);
|
||||||
Common.SendToDebug("::GetFromStatic - ObjectType: " + ret.GetType().ToString());
|
Common.SendToDebug("::GetFromStatic - ObjectType: " + ret.GetType().ToString());
|
||||||
LSLStack.Push(ret);
|
LSLStack.Push(ret);
|
||||||
//return ret;
|
//return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object POPToStack()
|
public object POPToStack()
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::POPToStack");
|
Common.SendToDebug("::POPToStack");
|
||||||
//return LSLStack.Pop();
|
//return LSLStack.Pop();
|
||||||
object p = LSLStack.Pop();
|
object p = LSLStack.Pop();
|
||||||
if (p.GetType() == typeof (UInt32))
|
if (p.GetType() == typeof (UInt32))
|
||||||
return (UInt32) p;
|
return (UInt32) p;
|
||||||
if (p.GetType() == typeof (string))
|
if (p.GetType() == typeof (string))
|
||||||
return (string) p;
|
return (string) p;
|
||||||
if (p.GetType() == typeof (Int32))
|
if (p.GetType() == typeof (Int32))
|
||||||
return (Int32) p;
|
return (Int32) p;
|
||||||
if (p.GetType() == typeof (UInt16))
|
if (p.GetType() == typeof (UInt16))
|
||||||
return (UInt16) p;
|
return (UInt16) p;
|
||||||
if (p.GetType() == typeof (float))
|
if (p.GetType() == typeof (float))
|
||||||
return (float) p;
|
return (float) p;
|
||||||
if (p.GetType() == typeof (LSO_Enums.Vector))
|
if (p.GetType() == typeof (LSO_Enums.Vector))
|
||||||
return (LSO_Enums.Vector) p;
|
return (LSO_Enums.Vector) p;
|
||||||
if (p.GetType() == typeof (LSO_Enums.Rotation))
|
if (p.GetType() == typeof (LSO_Enums.Rotation))
|
||||||
return (LSO_Enums.Rotation) p;
|
return (LSO_Enums.Rotation) p;
|
||||||
if (p.GetType() == typeof (LSO_Enums.Key))
|
if (p.GetType() == typeof (LSO_Enums.Key))
|
||||||
return (LSO_Enums.Key) p;
|
return (LSO_Enums.Key) p;
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
//public object POPToStack(UInt32 count)
|
//public object POPToStack(UInt32 count)
|
||||||
//{
|
//{
|
||||||
// // POP NUMBER FROM TOP OF STACK
|
// // POP NUMBER FROM TOP OF STACK
|
||||||
// //LSLStack.SetLength(LSLStack.Length - 4);
|
// //LSLStack.SetLength(LSLStack.Length - 4);
|
||||||
// Common.SendToDebug("::POPToStack " + count);
|
// Common.SendToDebug("::POPToStack " + count);
|
||||||
// if (count < 2)
|
// if (count < 2)
|
||||||
// return LSLStack.Pop();
|
// return LSLStack.Pop();
|
||||||
|
|
||||||
// Stack<object> s = new Stack<object>();
|
// Stack<object> s = new Stack<object>();
|
||||||
// for (int i = 0; i < count; i++)
|
// for (int i = 0; i < count; i++)
|
||||||
// {
|
// {
|
||||||
// s.Push(LSLStack.Pop);
|
// s.Push(LSLStack.Pop);
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
public void POP()
|
public void POP()
|
||||||
{
|
{
|
||||||
// POP NUMBER FROM TOP OF STACK
|
// POP NUMBER FROM TOP OF STACK
|
||||||
//LSLStack.SetLength(LSLStack.Length - 4);
|
//LSLStack.SetLength(LSLStack.Length - 4);
|
||||||
Common.SendToDebug("::POP");
|
Common.SendToDebug("::POP");
|
||||||
if (LSLStack.Count < 1)
|
if (LSLStack.Count < 1)
|
||||||
{
|
{
|
||||||
//TODO: Temporary fix
|
//TODO: Temporary fix
|
||||||
Common.SendToDebug("ERROR: TRYING TO POP EMPTY STACK!");
|
Common.SendToDebug("ERROR: TRYING TO POP EMPTY STACK!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LSLStack.Pop();
|
LSLStack.Pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PUSH(object Param)
|
public void PUSH(object Param)
|
||||||
{
|
{
|
||||||
if (Param == null)
|
if (Param == null)
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::PUSH: <null>");
|
Common.SendToDebug("::PUSH: <null>");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Common.SendToDebug("::PUSH: " + Param.GetType());
|
//Common.SendToDebug("::PUSH: " + Param.GetType());
|
||||||
}
|
}
|
||||||
|
|
||||||
LSLStack.Push(Param);
|
LSLStack.Push(Param);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ADD(UInt32 Param)
|
public void ADD(UInt32 Param)
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::ADD: " + Param);
|
Common.SendToDebug("::ADD: " + Param);
|
||||||
object o2 = LSLStack.Pop();
|
object o2 = LSLStack.Pop();
|
||||||
object o1 = LSLStack.Pop();
|
object o1 = LSLStack.Pop();
|
||||||
Common.SendToDebug("::ADD: Debug: o1: " + o1.GetType() + " (" + o1.ToString() + "), o2: " + o2.GetType() +
|
Common.SendToDebug("::ADD: Debug: o1: " + o1.GetType() + " (" + o1.ToString() + "), o2: " + o2.GetType() +
|
||||||
" (" + o2.ToString() + ")");
|
" (" + o2.ToString() + ")");
|
||||||
if (o2.GetType() == typeof (string))
|
if (o2.GetType() == typeof (string))
|
||||||
{
|
{
|
||||||
LSLStack.Push((string) o1 + (string) o2);
|
LSLStack.Push((string) o1 + (string) o2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (o2.GetType() == typeof (UInt32))
|
if (o2.GetType() == typeof (UInt32))
|
||||||
{
|
{
|
||||||
LSLStack.Push((UInt32) o1 + (UInt32) o2);
|
LSLStack.Push((UInt32) o1 + (UInt32) o2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SUB(UInt32 Param)
|
public void SUB(UInt32 Param)
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::SUB: " + Param);
|
Common.SendToDebug("::SUB: " + Param);
|
||||||
UInt32 i2 = (UInt32) LSLStack.Pop();
|
UInt32 i2 = (UInt32) LSLStack.Pop();
|
||||||
UInt32 i1 = (UInt32) LSLStack.Pop();
|
UInt32 i1 = (UInt32) LSLStack.Pop();
|
||||||
LSLStack.Push((UInt32) (i1 - i2));
|
LSLStack.Push((UInt32) (i1 - i2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MUL(UInt32 Param)
|
public void MUL(UInt32 Param)
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::SUB: " + Param);
|
Common.SendToDebug("::SUB: " + Param);
|
||||||
UInt32 i2 = (UInt32) LSLStack.Pop();
|
UInt32 i2 = (UInt32) LSLStack.Pop();
|
||||||
UInt32 i1 = (UInt32) LSLStack.Pop();
|
UInt32 i1 = (UInt32) LSLStack.Pop();
|
||||||
LSLStack.Push((UInt32) (i1*i2));
|
LSLStack.Push((UInt32) (i1*i2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DIV(UInt32 Param)
|
public void DIV(UInt32 Param)
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::DIV: " + Param);
|
Common.SendToDebug("::DIV: " + Param);
|
||||||
UInt32 i2 = (UInt32) LSLStack.Pop();
|
UInt32 i2 = (UInt32) LSLStack.Pop();
|
||||||
UInt32 i1 = (UInt32) LSLStack.Pop();
|
UInt32 i1 = (UInt32) LSLStack.Pop();
|
||||||
LSLStack.Push((UInt32) (i1/i2));
|
LSLStack.Push((UInt32) (i1/i2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void MOD(UInt32 Param)
|
public void MOD(UInt32 Param)
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::MOD: " + Param);
|
Common.SendToDebug("::MOD: " + Param);
|
||||||
UInt32 i2 = (UInt32) LSLStack.Pop();
|
UInt32 i2 = (UInt32) LSLStack.Pop();
|
||||||
UInt32 i1 = (UInt32) LSLStack.Pop();
|
UInt32 i1 = (UInt32) LSLStack.Pop();
|
||||||
LSLStack.Push((UInt32) (i1%i2));
|
LSLStack.Push((UInt32) (i1%i2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EQ(UInt32 Param)
|
public void EQ(UInt32 Param)
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::EQ: " + Param);
|
Common.SendToDebug("::EQ: " + Param);
|
||||||
UInt32 i2 = (UInt32) LSLStack.Pop();
|
UInt32 i2 = (UInt32) LSLStack.Pop();
|
||||||
UInt32 i1 = (UInt32) LSLStack.Pop();
|
UInt32 i1 = (UInt32) LSLStack.Pop();
|
||||||
if (i1 == i2)
|
if (i1 == i2)
|
||||||
{
|
{
|
||||||
LSLStack.Push((UInt32) 1);
|
LSLStack.Push((UInt32) 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LSLStack.Push((UInt32) 0);
|
LSLStack.Push((UInt32) 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NEQ(UInt32 Param)
|
public void NEQ(UInt32 Param)
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::NEQ: " + Param);
|
Common.SendToDebug("::NEQ: " + Param);
|
||||||
UInt32 i2 = (UInt32) LSLStack.Pop();
|
UInt32 i2 = (UInt32) LSLStack.Pop();
|
||||||
UInt32 i1 = (UInt32) LSLStack.Pop();
|
UInt32 i1 = (UInt32) LSLStack.Pop();
|
||||||
if (i1 != i2)
|
if (i1 != i2)
|
||||||
{
|
{
|
||||||
LSLStack.Push((UInt32) 1);
|
LSLStack.Push((UInt32) 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LSLStack.Push((UInt32) 0);
|
LSLStack.Push((UInt32) 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LEQ(UInt32 Param)
|
public void LEQ(UInt32 Param)
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::LEQ: " + Param);
|
Common.SendToDebug("::LEQ: " + Param);
|
||||||
UInt32 i2 = (UInt32) LSLStack.Pop();
|
UInt32 i2 = (UInt32) LSLStack.Pop();
|
||||||
UInt32 i1 = (UInt32) LSLStack.Pop();
|
UInt32 i1 = (UInt32) LSLStack.Pop();
|
||||||
if (i1 <= i2)
|
if (i1 <= i2)
|
||||||
{
|
{
|
||||||
LSLStack.Push((UInt32) 1);
|
LSLStack.Push((UInt32) 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LSLStack.Push((UInt32) 0);
|
LSLStack.Push((UInt32) 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GEQ(UInt32 Param)
|
public void GEQ(UInt32 Param)
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::GEQ: " + Param);
|
Common.SendToDebug("::GEQ: " + Param);
|
||||||
UInt32 i2 = (UInt32) LSLStack.Pop();
|
UInt32 i2 = (UInt32) LSLStack.Pop();
|
||||||
UInt32 i1 = (UInt32) LSLStack.Pop();
|
UInt32 i1 = (UInt32) LSLStack.Pop();
|
||||||
if (i1 >= i2)
|
if (i1 >= i2)
|
||||||
{
|
{
|
||||||
LSLStack.Push((UInt32) 1);
|
LSLStack.Push((UInt32) 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LSLStack.Push((UInt32) 0);
|
LSLStack.Push((UInt32) 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LESS(UInt32 Param)
|
public void LESS(UInt32 Param)
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::LESS: " + Param);
|
Common.SendToDebug("::LESS: " + Param);
|
||||||
UInt32 i2 = (UInt32) LSLStack.Pop();
|
UInt32 i2 = (UInt32) LSLStack.Pop();
|
||||||
UInt32 i1 = (UInt32) LSLStack.Pop();
|
UInt32 i1 = (UInt32) LSLStack.Pop();
|
||||||
if (i1 < i2)
|
if (i1 < i2)
|
||||||
{
|
{
|
||||||
LSLStack.Push((UInt32) 1);
|
LSLStack.Push((UInt32) 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LSLStack.Push((UInt32) 0);
|
LSLStack.Push((UInt32) 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GREATER(UInt32 Param)
|
public void GREATER(UInt32 Param)
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::GREATER: " + Param);
|
Common.SendToDebug("::GREATER: " + Param);
|
||||||
UInt32 i2 = (UInt32) LSLStack.Pop();
|
UInt32 i2 = (UInt32) LSLStack.Pop();
|
||||||
UInt32 i1 = (UInt32) LSLStack.Pop();
|
UInt32 i1 = (UInt32) LSLStack.Pop();
|
||||||
if (i1 > i2)
|
if (i1 > i2)
|
||||||
{
|
{
|
||||||
LSLStack.Push((UInt32) 1);
|
LSLStack.Push((UInt32) 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LSLStack.Push((UInt32) 0);
|
LSLStack.Push((UInt32) 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void BITAND()
|
public void BITAND()
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::BITAND");
|
Common.SendToDebug("::BITAND");
|
||||||
UInt32 i2 = (UInt32) LSLStack.Pop();
|
UInt32 i2 = (UInt32) LSLStack.Pop();
|
||||||
UInt32 i1 = (UInt32) LSLStack.Pop();
|
UInt32 i1 = (UInt32) LSLStack.Pop();
|
||||||
LSLStack.Push((UInt32) (i1 & i2));
|
LSLStack.Push((UInt32) (i1 & i2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BITOR()
|
public void BITOR()
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::BITOR");
|
Common.SendToDebug("::BITOR");
|
||||||
UInt32 i2 = (UInt32) LSLStack.Pop();
|
UInt32 i2 = (UInt32) LSLStack.Pop();
|
||||||
UInt32 i1 = (UInt32) LSLStack.Pop();
|
UInt32 i1 = (UInt32) LSLStack.Pop();
|
||||||
LSLStack.Push((UInt32) (i1 | i2));
|
LSLStack.Push((UInt32) (i1 | i2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BITXOR()
|
public void BITXOR()
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::BITXOR");
|
Common.SendToDebug("::BITXOR");
|
||||||
UInt32 i2 = (UInt32) LSLStack.Pop();
|
UInt32 i2 = (UInt32) LSLStack.Pop();
|
||||||
UInt32 i1 = (UInt32) LSLStack.Pop();
|
UInt32 i1 = (UInt32) LSLStack.Pop();
|
||||||
LSLStack.Push((UInt32) (i1 ^ i2));
|
LSLStack.Push((UInt32) (i1 ^ i2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BOOLAND()
|
public void BOOLAND()
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::BOOLAND");
|
Common.SendToDebug("::BOOLAND");
|
||||||
bool b2 = bool.Parse((string) LSLStack.Pop());
|
bool b2 = bool.Parse((string) LSLStack.Pop());
|
||||||
bool b1 = bool.Parse((string) LSLStack.Pop());
|
bool b1 = bool.Parse((string) LSLStack.Pop());
|
||||||
if (b1 && b2)
|
if (b1 && b2)
|
||||||
{
|
{
|
||||||
LSLStack.Push((UInt32) 1);
|
LSLStack.Push((UInt32) 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LSLStack.Push((UInt32) 0);
|
LSLStack.Push((UInt32) 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BOOLOR()
|
public void BOOLOR()
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::BOOLOR");
|
Common.SendToDebug("::BOOLOR");
|
||||||
bool b2 = bool.Parse((string) LSLStack.Pop());
|
bool b2 = bool.Parse((string) LSLStack.Pop());
|
||||||
bool b1 = bool.Parse((string) LSLStack.Pop());
|
bool b1 = bool.Parse((string) LSLStack.Pop());
|
||||||
|
|
||||||
if (b1 || b2)
|
if (b1 || b2)
|
||||||
{
|
{
|
||||||
LSLStack.Push((UInt32) 1);
|
LSLStack.Push((UInt32) 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LSLStack.Push((UInt32) 0);
|
LSLStack.Push((UInt32) 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NEG(UInt32 Param)
|
public void NEG(UInt32 Param)
|
||||||
{
|
{
|
||||||
Common.SendToDebug("::NEG: " + Param);
|
Common.SendToDebug("::NEG: " + Param);
|
||||||
//UInt32 i2 = (UInt32)LSLStack.Pop();
|
//UInt32 i2 = (UInt32)LSLStack.Pop();
|
||||||
UInt32 i1 = (UInt32) LSLStack.Pop();
|
UInt32 i1 = (UInt32) LSLStack.Pop();
|
||||||
LSLStack.Push((UInt32) (i1*-1));
|
LSLStack.Push((UInt32) (i1*-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BITNOT()
|
public void BITNOT()
|
||||||
{
|
{
|
||||||
//Common.SendToDebug("::BITNOT");
|
//Common.SendToDebug("::BITNOT");
|
||||||
//UInt32 i2 = (UInt32)LSLStack.Pop();
|
//UInt32 i2 = (UInt32)LSLStack.Pop();
|
||||||
//UInt32 i1 = (UInt32)LSLStack.Pop();
|
//UInt32 i1 = (UInt32)LSLStack.Pop();
|
||||||
//LSLStack.Push((UInt32)(i1 / i2));
|
//LSLStack.Push((UInt32)(i1 / i2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BOOLNOT()
|
public void BOOLNOT()
|
||||||
{
|
{
|
||||||
//Common.SendToDebug("::BOOLNOT");
|
//Common.SendToDebug("::BOOLNOT");
|
||||||
////UInt32 i2 = (UInt32)LSLStack.Pop();
|
////UInt32 i2 = (UInt32)LSLStack.Pop();
|
||||||
//UInt32 i1 = (UInt32)LSLStack.Pop();
|
//UInt32 i1 = (UInt32)LSLStack.Pop();
|
||||||
//LSLStack.Push((UInt32)(i1));
|
//LSLStack.Push((UInt32)(i1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,220 +1,222 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/* Original code: Tedd Hansen */
|
/* Original code: Tedd Hansen */
|
||||||
using System;
|
using System;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
|
||||||
namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Prepares events so they can be directly executed upon a script by EventQueueManager, then queues it.
|
/// Prepares events so they can be directly executed upon a script by EventQueueManager, then queues it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
internal class EventManager
|
internal class EventManager
|
||||||
{
|
{
|
||||||
private ScriptEngine myScriptEngine;
|
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
//public IScriptHost TEMP_OBJECT_ID;
|
|
||||||
public EventManager(ScriptEngine _ScriptEngine)
|
private ScriptEngine myScriptEngine;
|
||||||
{
|
//public IScriptHost TEMP_OBJECT_ID;
|
||||||
myScriptEngine = _ScriptEngine;
|
public EventManager(ScriptEngine _ScriptEngine)
|
||||||
// TODO: HOOK EVENTS UP TO SERVER!
|
{
|
||||||
//myScriptEngine.m_logger.Verbose("ScriptEngine", "EventManager Start");
|
myScriptEngine = _ScriptEngine;
|
||||||
// TODO: ADD SERVER HOOK TO LOAD A SCRIPT THROUGH myScriptEngine.ScriptManager
|
// TODO: HOOK EVENTS UP TO SERVER!
|
||||||
|
//myScriptEngine.m_log.Info("[ScriptEngine]: EventManager Start");
|
||||||
// Hook up a test event to our test form
|
// TODO: ADD SERVER HOOK TO LOAD A SCRIPT THROUGH myScriptEngine.ScriptManager
|
||||||
myScriptEngine.Log.Verbose("ScriptEngine", "Hooking up to server events");
|
|
||||||
myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
|
// Hook up a test event to our test form
|
||||||
myScriptEngine.World.EventManager.OnRezScript += OnRezScript;
|
myScriptEngine.m_log.Info("[ScriptEngine]: Hooking up to server events");
|
||||||
myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript;
|
myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
|
||||||
}
|
myScriptEngine.World.EventManager.OnRezScript += OnRezScript;
|
||||||
|
myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript;
|
||||||
public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)
|
}
|
||||||
{
|
|
||||||
// Add to queue for all scripts in ObjectID object
|
public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)
|
||||||
//myScriptEngine.m_logger.Verbose("ScriptEngine", "EventManager Event: touch_start");
|
{
|
||||||
//Console.WriteLine("touch_start localID: " + localID);
|
// Add to queue for all scripts in ObjectID object
|
||||||
myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", new object[] {(int) 1});
|
//myScriptEngine.m_log.Info("[ScriptEngine]: EventManager Event: touch_start");
|
||||||
}
|
//Console.WriteLine("touch_start localID: " + localID);
|
||||||
|
myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", new object[] {(int) 1});
|
||||||
public void OnRezScript(uint localID, LLUUID itemID, string script)
|
}
|
||||||
{
|
|
||||||
//myScriptEngine.myScriptManager.StartScript(
|
public void OnRezScript(uint localID, LLUUID itemID, string script)
|
||||||
// Path.Combine("ScriptEngines", "Default.lsl"),
|
{
|
||||||
// new OpenSim.Region.Environment.Scenes.Scripting.NullScriptHost()
|
//myScriptEngine.myScriptManager.StartScript(
|
||||||
//);
|
// Path.Combine("ScriptEngines", "Default.lsl"),
|
||||||
Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " +
|
// new OpenSim.Region.Environment.Scenes.Scripting.NullScriptHost()
|
||||||
script.Length);
|
//);
|
||||||
myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script);
|
Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " +
|
||||||
}
|
script.Length);
|
||||||
|
myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script);
|
||||||
public void OnRemoveScript(uint localID, LLUUID itemID)
|
}
|
||||||
{
|
|
||||||
//myScriptEngine.myScriptManager.StartScript(
|
public void OnRemoveScript(uint localID, LLUUID itemID)
|
||||||
// Path.Combine("ScriptEngines", "Default.lsl"),
|
{
|
||||||
// new OpenSim.Region.Environment.Scenes.Scripting.NullScriptHost()
|
//myScriptEngine.myScriptManager.StartScript(
|
||||||
//);
|
// Path.Combine("ScriptEngines", "Default.lsl"),
|
||||||
Console.WriteLine("OnRemoveScript localID: " + localID + " LLUID: " + itemID.ToString());
|
// new OpenSim.Region.Environment.Scenes.Scripting.NullScriptHost()
|
||||||
myScriptEngine.m_ScriptManager.StopScript(
|
//);
|
||||||
localID,
|
Console.WriteLine("OnRemoveScript localID: " + localID + " LLUID: " + itemID.ToString());
|
||||||
itemID
|
myScriptEngine.m_ScriptManager.StopScript(
|
||||||
);
|
localID,
|
||||||
}
|
itemID
|
||||||
|
);
|
||||||
// TODO: Replace placeholders below
|
}
|
||||||
// These needs to be hooked up to OpenSim during init of this class
|
|
||||||
// then queued in EventQueueManager.
|
// TODO: Replace placeholders below
|
||||||
// When queued in EventQueueManager they need to be LSL compatible (name and params)
|
// These needs to be hooked up to OpenSim during init of this class
|
||||||
|
// then queued in EventQueueManager.
|
||||||
//public void state_entry() { } //
|
// When queued in EventQueueManager they need to be LSL compatible (name and params)
|
||||||
public void state_exit()
|
|
||||||
{
|
//public void state_entry() { }
|
||||||
}
|
public void state_exit()
|
||||||
|
{
|
||||||
//public void touch_start() { }
|
}
|
||||||
public void touch()
|
|
||||||
{
|
//public void touch_start() { }
|
||||||
}
|
public void touch()
|
||||||
|
{
|
||||||
public void touch_end()
|
}
|
||||||
{
|
|
||||||
}
|
public void touch_end()
|
||||||
|
{
|
||||||
public void collision_start()
|
}
|
||||||
{
|
|
||||||
}
|
public void collision_start()
|
||||||
|
{
|
||||||
public void collision()
|
}
|
||||||
{
|
|
||||||
}
|
public void collision()
|
||||||
|
{
|
||||||
public void collision_end()
|
}
|
||||||
{
|
|
||||||
}
|
public void collision_end()
|
||||||
|
{
|
||||||
public void land_collision_start()
|
}
|
||||||
{
|
|
||||||
}
|
public void land_collision_start()
|
||||||
|
{
|
||||||
public void land_collision()
|
}
|
||||||
{
|
|
||||||
}
|
public void land_collision()
|
||||||
|
{
|
||||||
public void land_collision_end()
|
}
|
||||||
{
|
|
||||||
}
|
public void land_collision_end()
|
||||||
|
{
|
||||||
public void timer()
|
}
|
||||||
{
|
|
||||||
}
|
public void timer()
|
||||||
|
{
|
||||||
public void listen()
|
}
|
||||||
{
|
|
||||||
}
|
public void listen()
|
||||||
|
{
|
||||||
public void on_rez()
|
}
|
||||||
{
|
|
||||||
}
|
public void on_rez()
|
||||||
|
{
|
||||||
public void sensor()
|
}
|
||||||
{
|
|
||||||
}
|
public void sensor()
|
||||||
|
{
|
||||||
public void no_sensor()
|
}
|
||||||
{
|
|
||||||
}
|
public void no_sensor()
|
||||||
|
{
|
||||||
public void control()
|
}
|
||||||
{
|
|
||||||
}
|
public void control()
|
||||||
|
{
|
||||||
public void money()
|
}
|
||||||
{
|
|
||||||
}
|
public void money()
|
||||||
|
{
|
||||||
public void email()
|
}
|
||||||
{
|
|
||||||
}
|
public void email()
|
||||||
|
{
|
||||||
public void at_target()
|
}
|
||||||
{
|
|
||||||
}
|
public void at_target()
|
||||||
|
{
|
||||||
public void not_at_target()
|
}
|
||||||
{
|
|
||||||
}
|
public void not_at_target()
|
||||||
|
{
|
||||||
public void at_rot_target()
|
}
|
||||||
{
|
|
||||||
}
|
public void at_rot_target()
|
||||||
|
{
|
||||||
public void not_at_rot_target()
|
}
|
||||||
{
|
|
||||||
}
|
public void not_at_rot_target()
|
||||||
|
{
|
||||||
public void run_time_permissions()
|
}
|
||||||
{
|
|
||||||
}
|
public void run_time_permissions()
|
||||||
|
{
|
||||||
public void changed()
|
}
|
||||||
{
|
|
||||||
}
|
public void changed()
|
||||||
|
{
|
||||||
public void attach()
|
}
|
||||||
{
|
|
||||||
}
|
public void attach()
|
||||||
|
{
|
||||||
public void dataserver()
|
}
|
||||||
{
|
|
||||||
}
|
public void dataserver()
|
||||||
|
{
|
||||||
public void link_message()
|
}
|
||||||
{
|
|
||||||
}
|
public void link_message()
|
||||||
|
{
|
||||||
public void moving_start()
|
}
|
||||||
{
|
|
||||||
}
|
public void moving_start()
|
||||||
|
{
|
||||||
public void moving_end()
|
}
|
||||||
{
|
|
||||||
}
|
public void moving_end()
|
||||||
|
{
|
||||||
public void object_rez()
|
}
|
||||||
{
|
|
||||||
}
|
public void object_rez()
|
||||||
|
{
|
||||||
public void remote_data()
|
}
|
||||||
{
|
|
||||||
}
|
public void remote_data()
|
||||||
|
{
|
||||||
public void http_response()
|
}
|
||||||
{
|
|
||||||
}
|
public void http_response()
|
||||||
}
|
{
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,334 +1,335 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/* Original code: Tedd Hansen */
|
/* Original code: Tedd Hansen */
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL;
|
using OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL;
|
||||||
using OpenSim.Region.Environment.Scenes.Scripting;
|
using OpenSim.Region.Environment.Scenes.Scripting;
|
||||||
|
|
||||||
namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// EventQueueManager handles event queues
|
/// EventQueueManager handles event queues
|
||||||
/// Events are queued and executed in separate thread
|
/// Events are queued and executed in separate thread
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
internal class EventQueueManager
|
internal class EventQueueManager
|
||||||
{
|
{
|
||||||
/// <summary>
|
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
/// List of threads processing event queue
|
|
||||||
/// </summary>
|
/// <summary>
|
||||||
private List<Thread> eventQueueThreads = new List<Thread>();
|
/// List of threads processing event queue
|
||||||
|
/// </summary>
|
||||||
private object queueLock = new object(); // Mutex lock object
|
private List<Thread> eventQueueThreads = new List<Thread>();
|
||||||
|
|
||||||
/// <summary>
|
private object queueLock = new object(); // Mutex lock object
|
||||||
/// How many ms to sleep if queue is empty
|
|
||||||
/// </summary>
|
/// <summary>
|
||||||
private int nothingToDoSleepms = 50;
|
/// How many ms to sleep if queue is empty
|
||||||
|
/// </summary>
|
||||||
/// <summary>
|
private int nothingToDoSleepms = 50;
|
||||||
/// How many threads to process queue with
|
|
||||||
/// </summary>
|
/// <summary>
|
||||||
private int numberOfThreads = 2;
|
/// How many threads to process queue with
|
||||||
|
/// </summary>
|
||||||
/// <summary>
|
private int numberOfThreads = 2;
|
||||||
/// Queue containing events waiting to be executed
|
|
||||||
/// </summary>
|
/// <summary>
|
||||||
private Queue<QueueItemStruct> eventQueue = new Queue<QueueItemStruct>();
|
/// Queue containing events waiting to be executed
|
||||||
|
/// </summary>
|
||||||
/// <summary>
|
private Queue<QueueItemStruct> eventQueue = new Queue<QueueItemStruct>();
|
||||||
/// Queue item structure
|
|
||||||
/// </summary>
|
/// <summary>
|
||||||
private struct QueueItemStruct
|
/// Queue item structure
|
||||||
{
|
/// </summary>
|
||||||
public uint localID;
|
private struct QueueItemStruct
|
||||||
public LLUUID itemID;
|
{
|
||||||
public string functionName;
|
public uint localID;
|
||||||
public object[] param;
|
public LLUUID itemID;
|
||||||
}
|
public string functionName;
|
||||||
|
public object[] param;
|
||||||
/// <summary>
|
}
|
||||||
/// List of localID locks for mutex processing of script events
|
|
||||||
/// </summary>
|
/// <summary>
|
||||||
private List<uint> objectLocks = new List<uint>();
|
/// List of localID locks for mutex processing of script events
|
||||||
|
/// </summary>
|
||||||
private object tryLockLock = new object(); // Mutex lock object
|
private List<uint> objectLocks = new List<uint>();
|
||||||
|
|
||||||
private ScriptEngine m_ScriptEngine;
|
private object tryLockLock = new object(); // Mutex lock object
|
||||||
|
|
||||||
public EventQueueManager(ScriptEngine _ScriptEngine)
|
private ScriptEngine m_ScriptEngine;
|
||||||
{
|
|
||||||
m_ScriptEngine = _ScriptEngine;
|
public EventQueueManager(ScriptEngine _ScriptEngine)
|
||||||
|
{
|
||||||
//
|
m_ScriptEngine = _ScriptEngine;
|
||||||
// Start event queue processing threads (worker threads)
|
|
||||||
//
|
//
|
||||||
for (int ThreadCount = 0; ThreadCount <= numberOfThreads; ThreadCount++)
|
// Start event queue processing threads (worker threads)
|
||||||
{
|
//
|
||||||
Thread EventQueueThread = new Thread(EventQueueThreadLoop);
|
for (int ThreadCount = 0; ThreadCount <= numberOfThreads; ThreadCount++)
|
||||||
eventQueueThreads.Add(EventQueueThread);
|
{
|
||||||
EventQueueThread.IsBackground = true;
|
Thread EventQueueThread = new Thread(EventQueueThreadLoop);
|
||||||
EventQueueThread.Priority = ThreadPriority.BelowNormal;
|
eventQueueThreads.Add(EventQueueThread);
|
||||||
EventQueueThread.Name = "EventQueueManagerThread_" + ThreadCount;
|
EventQueueThread.IsBackground = true;
|
||||||
EventQueueThread.Start();
|
EventQueueThread.Priority = ThreadPriority.BelowNormal;
|
||||||
}
|
EventQueueThread.Name = "EventQueueManagerThread_" + ThreadCount;
|
||||||
}
|
EventQueueThread.Start();
|
||||||
|
}
|
||||||
~EventQueueManager()
|
}
|
||||||
{
|
|
||||||
// Kill worker threads
|
~EventQueueManager()
|
||||||
foreach (Thread EventQueueThread in new ArrayList(eventQueueThreads))
|
{
|
||||||
{
|
// Kill worker threads
|
||||||
if (EventQueueThread != null && EventQueueThread.IsAlive == true)
|
foreach (Thread EventQueueThread in new ArrayList(eventQueueThreads))
|
||||||
{
|
{
|
||||||
try
|
if (EventQueueThread != null && EventQueueThread.IsAlive == true)
|
||||||
{
|
{
|
||||||
EventQueueThread.Abort();
|
try
|
||||||
EventQueueThread.Join();
|
{
|
||||||
}
|
EventQueueThread.Abort();
|
||||||
catch (Exception)
|
EventQueueThread.Join();
|
||||||
{
|
}
|
||||||
//myScriptEngine.Log.Verbose("ScriptEngine", "EventQueueManager Exception killing worker thread: " + e.ToString());
|
catch (Exception)
|
||||||
}
|
{
|
||||||
}
|
//myScriptEngine.m_log.Info("[ScriptEngine]: EventQueueManager Exception killing worker thread: " + e.ToString());
|
||||||
}
|
}
|
||||||
eventQueueThreads.Clear();
|
}
|
||||||
// Todo: Clean up our queues
|
}
|
||||||
eventQueue.Clear();
|
eventQueueThreads.Clear();
|
||||||
}
|
// Todo: Clean up our queues
|
||||||
|
eventQueue.Clear();
|
||||||
/// <summary>
|
}
|
||||||
/// Queue processing thread loop
|
|
||||||
/// </summary>
|
/// <summary>
|
||||||
private void EventQueueThreadLoop()
|
/// Queue processing thread loop
|
||||||
{
|
/// </summary>
|
||||||
//myScriptEngine.m_logger.Verbose("ScriptEngine", "EventQueueManager Worker thread spawned");
|
private void EventQueueThreadLoop()
|
||||||
try
|
{
|
||||||
{
|
//myScriptEngine.m_log.Info("[ScriptEngine]: EventQueueManager Worker thread spawned");
|
||||||
QueueItemStruct BlankQIS = new QueueItemStruct();
|
try
|
||||||
while (true)
|
{
|
||||||
{
|
QueueItemStruct BlankQIS = new QueueItemStruct();
|
||||||
try
|
while (true)
|
||||||
{
|
{
|
||||||
QueueItemStruct QIS = BlankQIS;
|
try
|
||||||
bool GotItem = false;
|
{
|
||||||
|
QueueItemStruct QIS = BlankQIS;
|
||||||
if (eventQueue.Count == 0)
|
bool GotItem = false;
|
||||||
{
|
|
||||||
// Nothing to do? Sleep a bit waiting for something to do
|
if (eventQueue.Count == 0)
|
||||||
Thread.Sleep(nothingToDoSleepms);
|
{
|
||||||
}
|
// Nothing to do? Sleep a bit waiting for something to do
|
||||||
else
|
Thread.Sleep(nothingToDoSleepms);
|
||||||
{
|
}
|
||||||
// Something in queue, process
|
else
|
||||||
//myScriptEngine.m_logger.Verbose("ScriptEngine", "Processing event for localID: " + QIS.localID + ", itemID: " + QIS.itemID + ", FunctionName: " + QIS.FunctionName);
|
{
|
||||||
|
// Something in queue, process
|
||||||
// OBJECT BASED LOCK - TWO THREADS WORKING ON SAME OBJECT IS NOT GOOD
|
//myScriptEngine.m_log.Info("[ScriptEngine]: Processing event for localID: " + QIS.localID + ", itemID: " + QIS.itemID + ", FunctionName: " + QIS.FunctionName);
|
||||||
lock (queueLock)
|
|
||||||
{
|
// OBJECT BASED LOCK - TWO THREADS WORKING ON SAME OBJECT IS NOT GOOD
|
||||||
GotItem = false;
|
lock (queueLock)
|
||||||
for (int qc = 0; qc < eventQueue.Count; qc++)
|
{
|
||||||
{
|
GotItem = false;
|
||||||
// Get queue item
|
for (int qc = 0; qc < eventQueue.Count; qc++)
|
||||||
QIS = eventQueue.Dequeue();
|
{
|
||||||
|
// Get queue item
|
||||||
// Check if object is being processed by someone else
|
QIS = eventQueue.Dequeue();
|
||||||
if (TryLock(QIS.localID) == false)
|
|
||||||
{
|
// Check if object is being processed by someone else
|
||||||
// Object is already being processed, requeue it
|
if (TryLock(QIS.localID) == false)
|
||||||
eventQueue.Enqueue(QIS);
|
{
|
||||||
}
|
// Object is already being processed, requeue it
|
||||||
else
|
eventQueue.Enqueue(QIS);
|
||||||
{
|
}
|
||||||
// We have lock on an object and can process it
|
else
|
||||||
GotItem = true;
|
{
|
||||||
break;
|
// We have lock on an object and can process it
|
||||||
}
|
GotItem = true;
|
||||||
} // go through queue
|
break;
|
||||||
} // lock
|
}
|
||||||
|
}
|
||||||
if (GotItem == true)
|
}
|
||||||
{
|
|
||||||
// Execute function
|
if (GotItem == true)
|
||||||
try
|
{
|
||||||
{
|
// Execute function
|
||||||
m_ScriptEngine.m_ScriptManager.ExecuteEvent(QIS.localID, QIS.itemID,
|
try
|
||||||
QIS.functionName, QIS.param);
|
{
|
||||||
}
|
m_ScriptEngine.m_ScriptManager.ExecuteEvent(QIS.localID, QIS.itemID,
|
||||||
catch (Exception e)
|
QIS.functionName, QIS.param);
|
||||||
{
|
}
|
||||||
// DISPLAY ERROR INWORLD
|
catch (Exception e)
|
||||||
string text = "Error executing script function \"" + QIS.functionName + "\":\r\n";
|
{
|
||||||
if (e.InnerException != null)
|
// DISPLAY ERROR INWORLD
|
||||||
{
|
string text = "Error executing script function \"" + QIS.functionName + "\":\r\n";
|
||||||
// Send inner exception
|
if (e.InnerException != null)
|
||||||
text += e.InnerException.Message.ToString();
|
{
|
||||||
}
|
// Send inner exception
|
||||||
else
|
text += e.InnerException.Message.ToString();
|
||||||
{
|
}
|
||||||
// Send normal
|
else
|
||||||
text += e.Message.ToString();
|
{
|
||||||
}
|
// Send normal
|
||||||
try
|
text += e.Message.ToString();
|
||||||
{
|
}
|
||||||
if (text.Length > 1500)
|
try
|
||||||
text = text.Substring(0, 1500);
|
{
|
||||||
IScriptHost m_host = m_ScriptEngine.World.GetSceneObjectPart(QIS.localID);
|
if (text.Length > 1500)
|
||||||
//if (m_host != null)
|
text = text.Substring(0, 1500);
|
||||||
//{
|
IScriptHost m_host = m_ScriptEngine.World.GetSceneObjectPart(QIS.localID);
|
||||||
m_ScriptEngine.World.SimChat(Helpers.StringToField(text), ChatTypeEnum.Say, 0,
|
//if (m_host != null)
|
||||||
m_host.AbsolutePosition, m_host.Name, m_host.UUID);
|
//{
|
||||||
}
|
m_ScriptEngine.World.SimChat(Helpers.StringToField(text), ChatTypeEnum.Say, 0,
|
||||||
catch
|
m_host.AbsolutePosition, m_host.Name, m_host.UUID);
|
||||||
{
|
}
|
||||||
//}
|
catch
|
||||||
//else
|
{
|
||||||
//{
|
//}
|
||||||
// T oconsole
|
//else
|
||||||
Console.WriteLine("Unable to send text in-world:\r\n" + text);
|
//{
|
||||||
}
|
// T oconsole
|
||||||
}
|
Console.WriteLine("Unable to send text in-world:\r\n" + text);
|
||||||
finally
|
}
|
||||||
{
|
}
|
||||||
ReleaseLock(QIS.localID);
|
finally
|
||||||
}
|
{
|
||||||
}
|
ReleaseLock(QIS.localID);
|
||||||
} // Something in queue
|
}
|
||||||
}
|
}
|
||||||
catch (ThreadAbortException tae)
|
}
|
||||||
{
|
}
|
||||||
throw tae;
|
catch (ThreadAbortException tae)
|
||||||
}
|
{
|
||||||
catch (Exception e)
|
throw tae;
|
||||||
{
|
}
|
||||||
Console.WriteLine("Exception in EventQueueThreadLoop: " + e.ToString());
|
catch (Exception e)
|
||||||
}
|
{
|
||||||
} // while
|
Console.WriteLine("Exception in EventQueueThreadLoop: " + e.ToString());
|
||||||
} // try
|
}
|
||||||
catch (ThreadAbortException)
|
}
|
||||||
{
|
}
|
||||||
//myScriptEngine.Log.Verbose("ScriptEngine", "EventQueueManager Worker thread killed: " + tae.Message);
|
catch (ThreadAbortException)
|
||||||
}
|
{
|
||||||
}
|
//myScriptEngine.m_log.Info("[ScriptEngine]: EventQueueManager Worker thread killed: " + tae.Message);
|
||||||
|
}
|
||||||
/// <summary>
|
}
|
||||||
/// Try to get a mutex lock on localID
|
|
||||||
/// </summary>
|
/// <summary>
|
||||||
/// <param name="localID"></param>
|
/// Try to get a mutex lock on localID
|
||||||
/// <returns></returns>
|
/// </summary>
|
||||||
private bool TryLock(uint localID)
|
/// <param name="localID"></param>
|
||||||
{
|
/// <returns></returns>
|
||||||
lock (tryLockLock)
|
private bool TryLock(uint localID)
|
||||||
{
|
{
|
||||||
if (objectLocks.Contains(localID) == true)
|
lock (tryLockLock)
|
||||||
{
|
{
|
||||||
return false;
|
if (objectLocks.Contains(localID) == true)
|
||||||
}
|
{
|
||||||
else
|
return false;
|
||||||
{
|
}
|
||||||
objectLocks.Add(localID);
|
else
|
||||||
return true;
|
{
|
||||||
}
|
objectLocks.Add(localID);
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
}
|
||||||
/// Release mutex lock on localID
|
|
||||||
/// </summary>
|
/// <summary>
|
||||||
/// <param name="localID"></param>
|
/// Release mutex lock on localID
|
||||||
private void ReleaseLock(uint localID)
|
/// </summary>
|
||||||
{
|
/// <param name="localID"></param>
|
||||||
lock (tryLockLock)
|
private void ReleaseLock(uint localID)
|
||||||
{
|
{
|
||||||
if (objectLocks.Contains(localID) == true)
|
lock (tryLockLock)
|
||||||
{
|
{
|
||||||
objectLocks.Remove(localID);
|
if (objectLocks.Contains(localID) == true)
|
||||||
}
|
{
|
||||||
}
|
objectLocks.Remove(localID);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
|
||||||
/// Add event to event execution queue
|
/// <summary>
|
||||||
/// </summary>
|
/// Add event to event execution queue
|
||||||
/// <param name="localID"></param>
|
/// </summary>
|
||||||
/// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
|
/// <param name="localID"></param>
|
||||||
/// <param name="param">Array of parameters to match event mask</param>
|
/// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
|
||||||
public void AddToObjectQueue(uint localID, string FunctionName, object[] param)
|
/// <param name="param">Array of parameters to match event mask</param>
|
||||||
{
|
public void AddToObjectQueue(uint localID, string FunctionName, object[] param)
|
||||||
// Determine all scripts in Object and add to their queue
|
{
|
||||||
//myScriptEngine.m_logger.Verbose("ScriptEngine", "EventQueueManager Adding localID: " + localID + ", FunctionName: " + FunctionName);
|
// Determine all scripts in Object and add to their queue
|
||||||
|
//myScriptEngine.m_log.Info("[ScriptEngine]: EventQueueManager Adding localID: " + localID + ", FunctionName: " + FunctionName);
|
||||||
|
|
||||||
// Do we have any scripts in this object at all? If not, return
|
|
||||||
if (m_ScriptEngine.m_ScriptManager.Scripts.ContainsKey(localID) == false)
|
// Do we have any scripts in this object at all? If not, return
|
||||||
{
|
if (m_ScriptEngine.m_ScriptManager.Scripts.ContainsKey(localID) == false)
|
||||||
//Console.WriteLine("Event \"" + FunctionName + "\" for localID: " + localID + ". No scripts found on this localID.");
|
{
|
||||||
return;
|
//Console.WriteLine("Event \"" + FunctionName + "\" for localID: " + localID + ". No scripts found on this localID.");
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
Dictionary<LLUUID, LSL_BaseClass>.KeyCollection scriptKeys =
|
|
||||||
m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID);
|
Dictionary<LLUUID, LSL_BaseClass>.KeyCollection scriptKeys =
|
||||||
|
m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID);
|
||||||
foreach (LLUUID itemID in scriptKeys)
|
|
||||||
{
|
foreach (LLUUID itemID in scriptKeys)
|
||||||
// Add to each script in that object
|
{
|
||||||
// TODO: Some scripts may not subscribe to this event. Should we NOT add it? Does it matter?
|
// Add to each script in that object
|
||||||
AddToScriptQueue(localID, itemID, FunctionName, param);
|
// TODO: Some scripts may not subscribe to this event. Should we NOT add it? Does it matter?
|
||||||
}
|
AddToScriptQueue(localID, itemID, FunctionName, param);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
|
||||||
/// Add event to event execution queue
|
/// <summary>
|
||||||
/// </summary>
|
/// Add event to event execution queue
|
||||||
/// <param name="localID"></param>
|
/// </summary>
|
||||||
/// <param name="itemID"></param>
|
/// <param name="localID"></param>
|
||||||
/// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
|
/// <param name="itemID"></param>
|
||||||
/// <param name="param">Array of parameters to match event mask</param>
|
/// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
|
||||||
public void AddToScriptQueue(uint localID, LLUUID itemID, string FunctionName, object[] param)
|
/// <param name="param">Array of parameters to match event mask</param>
|
||||||
{
|
public void AddToScriptQueue(uint localID, LLUUID itemID, string FunctionName, object[] param)
|
||||||
lock (queueLock)
|
{
|
||||||
{
|
lock (queueLock)
|
||||||
// Create a structure and add data
|
{
|
||||||
QueueItemStruct QIS = new QueueItemStruct();
|
// Create a structure and add data
|
||||||
QIS.localID = localID;
|
QueueItemStruct QIS = new QueueItemStruct();
|
||||||
QIS.itemID = itemID;
|
QIS.localID = localID;
|
||||||
QIS.functionName = FunctionName;
|
QIS.itemID = itemID;
|
||||||
QIS.param = param;
|
QIS.functionName = FunctionName;
|
||||||
|
QIS.param = param;
|
||||||
// Add it to queue
|
|
||||||
eventQueue.Enqueue(QIS);
|
// Add it to queue
|
||||||
}
|
eventQueue.Enqueue(QIS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,355 +1,355 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
using OpenSim.Region.Environment.Interfaces;
|
using OpenSim.Region.Environment.Interfaces;
|
||||||
using OpenSim.Region.Environment.Modules;
|
using OpenSim.Region.Environment.Modules;
|
||||||
|
|
||||||
namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc.
|
/// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class LSLLongCmdHandler
|
internal class LSLLongCmdHandler
|
||||||
{
|
{
|
||||||
private Thread cmdHandlerThread;
|
private Thread cmdHandlerThread;
|
||||||
private int cmdHandlerThreadCycleSleepms = 100;
|
private int cmdHandlerThreadCycleSleepms = 100;
|
||||||
|
|
||||||
private ScriptEngine m_ScriptEngine;
|
private ScriptEngine m_ScriptEngine;
|
||||||
|
|
||||||
public LSLLongCmdHandler(ScriptEngine _ScriptEngine)
|
public LSLLongCmdHandler(ScriptEngine _ScriptEngine)
|
||||||
{
|
{
|
||||||
m_ScriptEngine = _ScriptEngine;
|
m_ScriptEngine = _ScriptEngine;
|
||||||
|
|
||||||
// Start the thread that will be doing the work
|
// Start the thread that will be doing the work
|
||||||
cmdHandlerThread = new Thread(CmdHandlerThreadLoop);
|
cmdHandlerThread = new Thread(CmdHandlerThreadLoop);
|
||||||
cmdHandlerThread.Name = "CmdHandlerThread";
|
cmdHandlerThread.Name = "CmdHandlerThread";
|
||||||
cmdHandlerThread.Priority = ThreadPriority.BelowNormal;
|
cmdHandlerThread.Priority = ThreadPriority.BelowNormal;
|
||||||
cmdHandlerThread.IsBackground = true;
|
cmdHandlerThread.IsBackground = true;
|
||||||
cmdHandlerThread.Start();
|
cmdHandlerThread.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
~LSLLongCmdHandler()
|
~LSLLongCmdHandler()
|
||||||
{
|
{
|
||||||
// Shut down thread
|
// Shut down thread
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (cmdHandlerThread != null)
|
if (cmdHandlerThread != null)
|
||||||
{
|
{
|
||||||
if (cmdHandlerThread.IsAlive == true)
|
if (cmdHandlerThread.IsAlive == true)
|
||||||
{
|
{
|
||||||
cmdHandlerThread.Abort();
|
cmdHandlerThread.Abort();
|
||||||
cmdHandlerThread.Join();
|
cmdHandlerThread.Join();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CmdHandlerThreadLoop()
|
private void CmdHandlerThreadLoop()
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
// Check timers
|
// Check timers
|
||||||
CheckTimerEvents();
|
CheckTimerEvents();
|
||||||
Thread.Sleep(25);
|
Thread.Sleep(25);
|
||||||
// Check HttpRequests
|
// Check HttpRequests
|
||||||
CheckHttpRequests();
|
CheckHttpRequests();
|
||||||
Thread.Sleep(25);
|
Thread.Sleep(25);
|
||||||
// Check XMLRPCRequests
|
// Check XMLRPCRequests
|
||||||
CheckXMLRPCRequests();
|
CheckXMLRPCRequests();
|
||||||
Thread.Sleep(25);
|
Thread.Sleep(25);
|
||||||
// Check Listeners
|
// Check Listeners
|
||||||
CheckListeners();
|
CheckListeners();
|
||||||
Thread.Sleep(25);
|
Thread.Sleep(25);
|
||||||
|
|
||||||
// Sleep before next cycle
|
// Sleep before next cycle
|
||||||
//Thread.Sleep(cmdHandlerThreadCycleSleepms);
|
//Thread.Sleep(cmdHandlerThreadCycleSleepms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove a specific script (and all its pending commands)
|
/// Remove a specific script (and all its pending commands)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="m_localID"></param>
|
/// <param name="m_localID"></param>
|
||||||
/// <param name="m_itemID"></param>
|
/// <param name="m_itemID"></param>
|
||||||
public void RemoveScript(uint localID, LLUUID itemID)
|
public void RemoveScript(uint localID, LLUUID itemID)
|
||||||
{
|
{
|
||||||
// Remove a specific script
|
// Remove a specific script
|
||||||
|
|
||||||
// Remove from: Timers
|
// Remove from: Timers
|
||||||
UnSetTimerEvents(localID, itemID);
|
UnSetTimerEvents(localID, itemID);
|
||||||
// Remove from: HttpRequest
|
// Remove from: HttpRequest
|
||||||
StopHttpRequest(localID, itemID);
|
StopHttpRequest(localID, itemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region TIMER
|
#region TIMER
|
||||||
|
|
||||||
//
|
//
|
||||||
// TIMER
|
// TIMER
|
||||||
//
|
//
|
||||||
private class TimerClass
|
private class TimerClass
|
||||||
{
|
{
|
||||||
public uint localID;
|
public uint localID;
|
||||||
public LLUUID itemID;
|
public LLUUID itemID;
|
||||||
public double interval;
|
public double interval;
|
||||||
public DateTime next;
|
public DateTime next;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<TimerClass> Timers = new List<TimerClass>();
|
private List<TimerClass> Timers = new List<TimerClass>();
|
||||||
private object TimerListLock = new object();
|
private object TimerListLock = new object();
|
||||||
|
|
||||||
public void SetTimerEvent(uint m_localID, LLUUID m_itemID, double sec)
|
public void SetTimerEvent(uint m_localID, LLUUID m_itemID, double sec)
|
||||||
{
|
{
|
||||||
Console.WriteLine("SetTimerEvent");
|
Console.WriteLine("SetTimerEvent");
|
||||||
|
|
||||||
// Always remove first, in case this is a re-set
|
// Always remove first, in case this is a re-set
|
||||||
UnSetTimerEvents(m_localID, m_itemID);
|
UnSetTimerEvents(m_localID, m_itemID);
|
||||||
if (sec == 0) // Disabling timer
|
if (sec == 0) // Disabling timer
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Add to timer
|
// Add to timer
|
||||||
TimerClass ts = new TimerClass();
|
TimerClass ts = new TimerClass();
|
||||||
ts.localID = m_localID;
|
ts.localID = m_localID;
|
||||||
ts.itemID = m_itemID;
|
ts.itemID = m_itemID;
|
||||||
ts.interval = sec;
|
ts.interval = sec;
|
||||||
ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
|
ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
|
||||||
lock (TimerListLock)
|
lock (TimerListLock)
|
||||||
{
|
{
|
||||||
Timers.Add(ts);
|
Timers.Add(ts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UnSetTimerEvents(uint m_localID, LLUUID m_itemID)
|
public void UnSetTimerEvents(uint m_localID, LLUUID m_itemID)
|
||||||
{
|
{
|
||||||
// Remove from timer
|
// Remove from timer
|
||||||
lock (TimerListLock)
|
lock (TimerListLock)
|
||||||
{
|
{
|
||||||
List<TimerClass> NewTimers = new List<TimerClass>();
|
List<TimerClass> NewTimers = new List<TimerClass>();
|
||||||
foreach (TimerClass ts in Timers)
|
foreach (TimerClass ts in Timers)
|
||||||
{
|
{
|
||||||
if (ts.localID != m_localID && ts.itemID != m_itemID)
|
if (ts.localID != m_localID && ts.itemID != m_itemID)
|
||||||
{
|
{
|
||||||
NewTimers.Add(ts);
|
NewTimers.Add(ts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Timers.Clear();
|
Timers.Clear();
|
||||||
Timers = NewTimers;
|
Timers = NewTimers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckTimerEvents()
|
public void CheckTimerEvents()
|
||||||
{
|
{
|
||||||
// Nothing to do here?
|
// Nothing to do here?
|
||||||
if (Timers.Count == 0)
|
if (Timers.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lock (TimerListLock)
|
lock (TimerListLock)
|
||||||
{
|
{
|
||||||
// Go through all timers
|
// Go through all timers
|
||||||
foreach (TimerClass ts in Timers)
|
foreach (TimerClass ts in Timers)
|
||||||
{
|
{
|
||||||
// Time has passed?
|
// Time has passed?
|
||||||
if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime())
|
if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime())
|
||||||
{
|
{
|
||||||
// Add it to queue
|
// Add it to queue
|
||||||
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer",
|
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer",
|
||||||
new object[] {});
|
new object[] {});
|
||||||
// set next interval
|
// set next interval
|
||||||
|
|
||||||
|
|
||||||
ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
|
ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // lock
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region HTTP REQUEST
|
#region HTTP REQUEST
|
||||||
|
|
||||||
//
|
//
|
||||||
// HTTP REAQUEST
|
// HTTP REAQUEST
|
||||||
//
|
//
|
||||||
private class HttpClass
|
private class HttpClass
|
||||||
{
|
{
|
||||||
public uint localID;
|
public uint localID;
|
||||||
public LLUUID itemID;
|
public LLUUID itemID;
|
||||||
public string url;
|
public string url;
|
||||||
public List<string> parameters;
|
public List<string> parameters;
|
||||||
public string body;
|
public string body;
|
||||||
public DateTime next;
|
public DateTime next;
|
||||||
|
|
||||||
public string response_request_id;
|
public string response_request_id;
|
||||||
public int response_status;
|
public int response_status;
|
||||||
public List<string> response_metadata;
|
public List<string> response_metadata;
|
||||||
public string response_body;
|
public string response_body;
|
||||||
|
|
||||||
public void SendRequest()
|
public void SendRequest()
|
||||||
{
|
{
|
||||||
// TODO: SEND REQUEST!!!
|
// TODO: SEND REQUEST!!!
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
// TODO: Cancel any ongoing request
|
// TODO: Cancel any ongoing request
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CheckResponse()
|
public bool CheckResponse()
|
||||||
{
|
{
|
||||||
// TODO: Check if we got a response yet, return true if so -- false if not
|
// TODO: Check if we got a response yet, return true if so -- false if not
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// TODO: If we got a response, set the following then return true
|
// TODO: If we got a response, set the following then return true
|
||||||
//response_request_id
|
//response_request_id
|
||||||
//response_status
|
//response_status
|
||||||
//response_metadata
|
//response_metadata
|
||||||
//response_body
|
//response_body
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<HttpClass> HttpRequests = new List<HttpClass>();
|
private List<HttpClass> HttpRequests = new List<HttpClass>();
|
||||||
private object HttpListLock = new object();
|
private object HttpListLock = new object();
|
||||||
|
|
||||||
public void StartHttpRequest(uint localID, LLUUID itemID, string url, List<string> parameters, string body)
|
public void StartHttpRequest(uint localID, LLUUID itemID, string url, List<string> parameters, string body)
|
||||||
{
|
{
|
||||||
Console.WriteLine("StartHttpRequest");
|
Console.WriteLine("StartHttpRequest");
|
||||||
|
|
||||||
HttpClass htc = new HttpClass();
|
HttpClass htc = new HttpClass();
|
||||||
htc.localID = localID;
|
htc.localID = localID;
|
||||||
htc.itemID = itemID;
|
htc.itemID = itemID;
|
||||||
htc.url = url;
|
htc.url = url;
|
||||||
htc.parameters = parameters;
|
htc.parameters = parameters;
|
||||||
htc.body = body;
|
htc.body = body;
|
||||||
lock (HttpListLock)
|
lock (HttpListLock)
|
||||||
{
|
{
|
||||||
//ADD REQUEST
|
//ADD REQUEST
|
||||||
HttpRequests.Add(htc);
|
HttpRequests.Add(htc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StopHttpRequest(uint m_localID, LLUUID m_itemID)
|
public void StopHttpRequest(uint m_localID, LLUUID m_itemID)
|
||||||
{
|
{
|
||||||
// Remove from list
|
// Remove from list
|
||||||
lock (HttpListLock)
|
lock (HttpListLock)
|
||||||
{
|
{
|
||||||
List<HttpClass> NewHttpList = new List<HttpClass>();
|
List<HttpClass> NewHttpList = new List<HttpClass>();
|
||||||
foreach (HttpClass ts in HttpRequests)
|
foreach (HttpClass ts in HttpRequests)
|
||||||
{
|
{
|
||||||
if (ts.localID != m_localID && ts.itemID != m_itemID)
|
if (ts.localID != m_localID && ts.itemID != m_itemID)
|
||||||
{
|
{
|
||||||
// Keeping this one
|
// Keeping this one
|
||||||
NewHttpList.Add(ts);
|
NewHttpList.Add(ts);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Shutting this one down
|
// Shutting this one down
|
||||||
ts.Stop();
|
ts.Stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HttpRequests.Clear();
|
HttpRequests.Clear();
|
||||||
HttpRequests = NewHttpList;
|
HttpRequests = NewHttpList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckHttpRequests()
|
public void CheckHttpRequests()
|
||||||
{
|
{
|
||||||
// Nothing to do here?
|
// Nothing to do here?
|
||||||
if (HttpRequests.Count == 0)
|
if (HttpRequests.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lock (HttpListLock)
|
lock (HttpListLock)
|
||||||
{
|
{
|
||||||
foreach (HttpClass ts in HttpRequests)
|
foreach (HttpClass ts in HttpRequests)
|
||||||
{
|
{
|
||||||
if (ts.CheckResponse() == true)
|
if (ts.CheckResponse() == true)
|
||||||
{
|
{
|
||||||
// Add it to event queue
|
// Add it to event queue
|
||||||
//key request_id, integer status, list metadata, string body
|
//key request_id, integer status, list metadata, string body
|
||||||
object[] resobj =
|
object[] resobj =
|
||||||
new object[]
|
new object[]
|
||||||
{ts.response_request_id, ts.response_status, ts.response_metadata, ts.response_body};
|
{ts.response_request_id, ts.response_status, ts.response_metadata, ts.response_body};
|
||||||
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "http_response",
|
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "http_response",
|
||||||
resobj);
|
resobj);
|
||||||
// Now stop it
|
// Now stop it
|
||||||
StopHttpRequest(ts.localID, ts.itemID);
|
StopHttpRequest(ts.localID, ts.itemID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // lock
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public void CheckXMLRPCRequests()
|
public void CheckXMLRPCRequests()
|
||||||
{
|
{
|
||||||
IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
|
IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
|
||||||
|
|
||||||
while (xmlrpc.hasRequests())
|
while (xmlrpc.hasRequests())
|
||||||
{
|
{
|
||||||
RPCRequestInfo rInfo = xmlrpc.GetNextRequest();
|
RPCRequestInfo rInfo = xmlrpc.GetNextRequest();
|
||||||
Console.WriteLine("PICKED REQUEST");
|
Console.WriteLine("PICKED REQUEST");
|
||||||
|
|
||||||
//Deliver data to prim's remote_data handler
|
//Deliver data to prim's remote_data handler
|
||||||
object[] resobj = new object[]
|
object[] resobj = new object[]
|
||||||
{
|
{
|
||||||
2, rInfo.GetChannelKey().ToString(), rInfo.GetMessageID().ToString(), "", rInfo.GetIntValue(),
|
2, rInfo.GetChannelKey().ToString(), rInfo.GetMessageID().ToString(), "", rInfo.GetIntValue(),
|
||||||
rInfo.GetStrVal()
|
rInfo.GetStrVal()
|
||||||
};
|
};
|
||||||
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
|
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
|
||||||
rInfo.GetLocalID(), rInfo.GetItemID(), "remote_data", resobj
|
rInfo.GetLocalID(), rInfo.GetItemID(), "remote_data", resobj
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckListeners()
|
public void CheckListeners()
|
||||||
{
|
{
|
||||||
IWorldComm comms = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
|
IWorldComm comms = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
|
||||||
|
|
||||||
while (comms.HasMessages())
|
while (comms.HasMessages())
|
||||||
{
|
{
|
||||||
ListenerInfo lInfo = comms.GetNextMessage();
|
ListenerInfo lInfo = comms.GetNextMessage();
|
||||||
Console.WriteLine("PICKED LISTENER");
|
Console.WriteLine("PICKED LISTENER");
|
||||||
|
|
||||||
//Deliver data to prim's listen handler
|
//Deliver data to prim's listen handler
|
||||||
object[] resobj = new object[]
|
object[] resobj = new object[]
|
||||||
{
|
{
|
||||||
lInfo.GetChannel(), lInfo.GetName(), lInfo.GetID().ToString(), lInfo.GetMessage()
|
lInfo.GetChannel(), lInfo.GetName(), lInfo.GetID().ToString(), lInfo.GetMessage()
|
||||||
};
|
};
|
||||||
|
|
||||||
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
|
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
|
||||||
lInfo.GetLocalID(), lInfo.GetItemID(), "listen", resobj
|
lInfo.GetLocalID(), lInfo.GetItemID(), "listen", resobj
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +1,66 @@
|
||||||
using System.Reflection;
|
/*
|
||||||
using System.Runtime.InteropServices;
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
// General Information about an assembly is controlled through the following
|
*
|
||||||
// set of attributes. Change these attribute values to modify the information
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// associated with an assembly.
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
[assembly : AssemblyTitle("OpenSim.Grid.ScriptEngine.DotNetEngine")]
|
* notice, this list of conditions and the following disclaimer.
|
||||||
[assembly : AssemblyDescription("")]
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
[assembly : AssemblyConfiguration("")]
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
[assembly : AssemblyCompany("")]
|
* documentation and/or other materials provided with the distribution.
|
||||||
[assembly : AssemblyProduct("OpenSim.Grid.ScriptEngine.DotNetEngine")]
|
* * Neither the name of the OpenSim Project nor the
|
||||||
[assembly : AssemblyCopyright("Copyright © 2007")]
|
* names of its contributors may be used to endorse or promote products
|
||||||
[assembly : AssemblyTrademark("")]
|
* derived from this software without specific prior written permission.
|
||||||
[assembly : AssemblyCulture("")]
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
// to COM components. If you need to access a type in this assembly from
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
[assembly : ComVisible(false)]
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
* 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
|
||||||
[assembly : Guid("2842257e-6fde-4460-9368-4cde57fa9cc4")]
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
// Version information for an assembly consists of the following four values:
|
*/
|
||||||
//
|
|
||||||
// Major Version
|
using System.Reflection;
|
||||||
// Minor Version
|
using System.Runtime.InteropServices;
|
||||||
// Build Number
|
|
||||||
// Revision
|
// General Information about an assembly is controlled through the following
|
||||||
//
|
// set of attributes. Change these attribute values to modify the information
|
||||||
// You can specify all the values or you can default the Revision and Build Numbers
|
// associated with an assembly.
|
||||||
// by using the '*' as shown below:
|
|
||||||
|
[assembly : AssemblyTitle("OpenSim.Grid.ScriptEngine.DotNetEngine")]
|
||||||
[assembly : AssemblyVersion("1.0.0.0")]
|
[assembly : AssemblyDescription("")]
|
||||||
[assembly : AssemblyFileVersion("1.0.0.0")]
|
[assembly : AssemblyConfiguration("")]
|
||||||
|
[assembly : AssemblyCompany("")]
|
||||||
|
[assembly : AssemblyProduct("OpenSim.Grid.ScriptEngine.DotNetEngine")]
|
||||||
|
[assembly : AssemblyCopyright("Copyright © 2007")]
|
||||||
|
[assembly : AssemblyTrademark("")]
|
||||||
|
[assembly : AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
|
||||||
|
[assembly : ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
|
||||||
|
[assembly : Guid("2842257e-6fde-4460-9368-4cde57fa9cc4")]
|
||||||
|
|
||||||
|
// 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 Revision and Build Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
|
||||||
|
[assembly : AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly : AssemblyFileVersion("1.0.0.0")]
|
||||||
|
|
|
@ -1,124 +1,119 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/* Original code: Tedd Hansen */
|
/* Original code: Tedd Hansen */
|
||||||
using System;
|
using System;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using OpenSim.Framework.Console;
|
using OpenSim.Framework.Console;
|
||||||
using OpenSim.Region.Environment.Interfaces;
|
using OpenSim.Region.Environment.Interfaces;
|
||||||
using OpenSim.Region.Environment.Scenes;
|
using OpenSim.Region.Environment.Scenes;
|
||||||
|
|
||||||
namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is the root object for ScriptEngine
|
/// This is the root object for ScriptEngine
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ScriptEngine : IRegionModule
|
public class ScriptEngine : IRegionModule
|
||||||
{
|
{
|
||||||
internal Scene World;
|
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
internal EventManager m_EventManager; // Handles and queues incoming events from OpenSim
|
|
||||||
internal EventQueueManager m_EventQueueManager; // Executes events
|
internal Scene World;
|
||||||
internal ScriptManager m_ScriptManager; // Load, unload and execute scripts
|
internal EventManager m_EventManager; // Handles and queues incoming events from OpenSim
|
||||||
internal AppDomainManager m_AppDomainManager;
|
internal EventQueueManager m_EventQueueManager; // Executes events
|
||||||
internal LSLLongCmdHandler m_LSLLongCmdHandler;
|
internal ScriptManager m_ScriptManager; // Load, unload and execute scripts
|
||||||
|
internal AppDomainManager m_AppDomainManager;
|
||||||
private LogBase m_log;
|
internal LSLLongCmdHandler m_LSLLongCmdHandler;
|
||||||
|
|
||||||
public ScriptEngine()
|
|
||||||
{
|
public ScriptEngine()
|
||||||
//Common.SendToDebug("ScriptEngine Object Initialized");
|
{
|
||||||
Common.mySE = this;
|
//Common.SendToDebug("ScriptEngine Object Initialized");
|
||||||
}
|
Common.mySE = this;
|
||||||
|
}
|
||||||
public LogBase Log
|
|
||||||
{
|
public void InitializeEngine(Scene Sceneworld)
|
||||||
get { return m_log; }
|
{
|
||||||
}
|
World = Sceneworld;
|
||||||
|
|
||||||
public void InitializeEngine(Scene Sceneworld, LogBase logger)
|
m_log.Info("[ScriptEngine]: DotNet & LSL ScriptEngine initializing");
|
||||||
{
|
|
||||||
World = Sceneworld;
|
//m_log.Info("[ScriptEngine]: InitializeEngine");
|
||||||
m_log = logger;
|
|
||||||
|
// Create all objects we'll be using
|
||||||
Log.Verbose("ScriptEngine", "DotNet & LSL ScriptEngine initializing");
|
m_EventQueueManager = new EventQueueManager(this);
|
||||||
|
m_EventManager = new EventManager(this);
|
||||||
//m_logger.Status("ScriptEngine", "InitializeEngine");
|
m_ScriptManager = new ScriptManager(this);
|
||||||
|
m_AppDomainManager = new AppDomainManager();
|
||||||
// Create all objects we'll be using
|
m_LSLLongCmdHandler = new LSLLongCmdHandler(this);
|
||||||
m_EventQueueManager = new EventQueueManager(this);
|
|
||||||
m_EventManager = new EventManager(this);
|
// Should we iterate the region for scripts that needs starting?
|
||||||
m_ScriptManager = new ScriptManager(this);
|
// Or can we assume we are loaded before anything else so we can use proper events?
|
||||||
m_AppDomainManager = new AppDomainManager();
|
}
|
||||||
m_LSLLongCmdHandler = new LSLLongCmdHandler(this);
|
|
||||||
|
public void Shutdown()
|
||||||
// Should we iterate the region for scripts that needs starting?
|
{
|
||||||
// Or can we assume we are loaded before anything else so we can use proper events?
|
// We are shutting down
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Shutdown()
|
//// !!!FOR DEBUGGING ONLY!!! (for executing script directly from test app)
|
||||||
{
|
//[Obsolete("!!!FOR DEBUGGING ONLY!!!")]
|
||||||
// We are shutting down
|
//public void StartScript(string ScriptID, IScriptHost ObjectID)
|
||||||
}
|
//{
|
||||||
|
// this.myEventManager.TEMP_OBJECT_ID = ObjectID;
|
||||||
//// !!!FOR DEBUGGING ONLY!!! (for executing script directly from test app)
|
// m_log.Info("[ScriptEngine]: DEBUG FUNCTION: StartScript: " + ScriptID);
|
||||||
//[Obsolete("!!!FOR DEBUGGING ONLY!!!")]
|
// myScriptManager.StartScript(ScriptID, ObjectID);
|
||||||
//public void StartScript(string ScriptID, IScriptHost ObjectID)
|
//}
|
||||||
//{
|
|
||||||
// this.myEventManager.TEMP_OBJECT_ID = ObjectID;
|
#region IRegionModule
|
||||||
// Log.Status("ScriptEngine", "DEBUG FUNCTION: StartScript: " + ScriptID);
|
|
||||||
// myScriptManager.StartScript(ScriptID, ObjectID);
|
public void Initialise(Scene scene, IConfigSource config)
|
||||||
//}
|
{
|
||||||
|
InitializeEngine(scene);
|
||||||
#region IRegionModule
|
}
|
||||||
|
|
||||||
public void Initialise(Scene scene, IConfigSource config)
|
public void PostInitialise()
|
||||||
{
|
{
|
||||||
InitializeEngine(scene, MainLog.Instance);
|
}
|
||||||
}
|
|
||||||
|
public void Close()
|
||||||
public void PostInitialise()
|
{
|
||||||
{
|
}
|
||||||
}
|
|
||||||
|
public string Name
|
||||||
public void Close()
|
{
|
||||||
{
|
get { return "LSLScriptingModule"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name
|
public bool IsSharedModule
|
||||||
{
|
{
|
||||||
get { return "LSLScriptingModule"; }
|
get { return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsSharedModule
|
#endregion
|
||||||
{
|
}
|
||||||
get { return false; }
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,419 +1,421 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/* Original code: Tedd Hansen */
|
/* Original code: Tedd Hansen */
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.Serialization.Formatters.Binary;
|
using System.Runtime.Serialization.Formatters.Binary;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler;
|
using OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler;
|
||||||
using OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL;
|
using OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL;
|
||||||
using OpenSim.Region.Environment.Scenes;
|
using OpenSim.Region.Environment.Scenes;
|
||||||
|
|
||||||
namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads scripts
|
/// Loads scripts
|
||||||
/// Compiles them if necessary
|
/// Compiles them if necessary
|
||||||
/// Execute functions for EventQueueManager (Sends them to script on other AppDomain for execution)
|
/// Execute functions for EventQueueManager (Sends them to script on other AppDomain for execution)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ScriptManager
|
public class ScriptManager
|
||||||
{
|
{
|
||||||
#region Declares
|
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private Thread scriptLoadUnloadThread;
|
#region Declares
|
||||||
private int scriptLoadUnloadThread_IdleSleepms = 100;
|
|
||||||
private Queue<LoadStruct> loadQueue = new Queue<LoadStruct>();
|
private Thread scriptLoadUnloadThread;
|
||||||
private Queue<UnloadStruct> unloadQueue = new Queue<UnloadStruct>();
|
private int scriptLoadUnloadThread_IdleSleepms = 100;
|
||||||
|
private Queue<LoadStruct> loadQueue = new Queue<LoadStruct>();
|
||||||
private struct LoadStruct
|
private Queue<UnloadStruct> unloadQueue = new Queue<UnloadStruct>();
|
||||||
{
|
|
||||||
public uint localID;
|
private struct LoadStruct
|
||||||
public LLUUID itemID;
|
{
|
||||||
public string script;
|
public uint localID;
|
||||||
}
|
public LLUUID itemID;
|
||||||
|
public string script;
|
||||||
private struct UnloadStruct
|
}
|
||||||
{
|
|
||||||
public uint localID;
|
private struct UnloadStruct
|
||||||
public LLUUID itemID;
|
{
|
||||||
}
|
public uint localID;
|
||||||
|
public LLUUID itemID;
|
||||||
// Object<string, Script<string, script>>
|
}
|
||||||
// IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory.
|
|
||||||
// Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead!
|
// Object<string, Script<string, script>>
|
||||||
internal Dictionary<uint, Dictionary<LLUUID, LSL_BaseClass>> Scripts =
|
// IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory.
|
||||||
new Dictionary<uint, Dictionary<LLUUID, LSL_BaseClass>>();
|
// Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead!
|
||||||
|
internal Dictionary<uint, Dictionary<LLUUID, LSL_BaseClass>> Scripts =
|
||||||
public Scene World
|
new Dictionary<uint, Dictionary<LLUUID, LSL_BaseClass>>();
|
||||||
{
|
|
||||||
get { return m_scriptEngine.World; }
|
public Scene World
|
||||||
}
|
{
|
||||||
|
get { return m_scriptEngine.World; }
|
||||||
#endregion
|
}
|
||||||
|
|
||||||
#region Object init/shutdown
|
#endregion
|
||||||
|
|
||||||
private ScriptEngine m_scriptEngine;
|
#region Object init/shutdown
|
||||||
|
|
||||||
public ScriptManager(ScriptEngine scriptEngine)
|
private ScriptEngine m_scriptEngine;
|
||||||
{
|
|
||||||
m_scriptEngine = scriptEngine;
|
public ScriptManager(ScriptEngine scriptEngine)
|
||||||
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
|
{
|
||||||
scriptLoadUnloadThread = new Thread(ScriptLoadUnloadThreadLoop);
|
m_scriptEngine = scriptEngine;
|
||||||
scriptLoadUnloadThread.Name = "ScriptLoadUnloadThread";
|
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
|
||||||
scriptLoadUnloadThread.IsBackground = true;
|
scriptLoadUnloadThread = new Thread(ScriptLoadUnloadThreadLoop);
|
||||||
scriptLoadUnloadThread.Priority = ThreadPriority.BelowNormal;
|
scriptLoadUnloadThread.Name = "ScriptLoadUnloadThread";
|
||||||
scriptLoadUnloadThread.Start();
|
scriptLoadUnloadThread.IsBackground = true;
|
||||||
}
|
scriptLoadUnloadThread.Priority = ThreadPriority.BelowNormal;
|
||||||
|
scriptLoadUnloadThread.Start();
|
||||||
~ScriptManager()
|
}
|
||||||
{
|
|
||||||
// Abort load/unload thread
|
~ScriptManager()
|
||||||
try
|
{
|
||||||
{
|
// Abort load/unload thread
|
||||||
if (scriptLoadUnloadThread != null)
|
try
|
||||||
{
|
{
|
||||||
if (scriptLoadUnloadThread.IsAlive == true)
|
if (scriptLoadUnloadThread != null)
|
||||||
{
|
{
|
||||||
scriptLoadUnloadThread.Abort();
|
if (scriptLoadUnloadThread.IsAlive == true)
|
||||||
scriptLoadUnloadThread.Join();
|
{
|
||||||
}
|
scriptLoadUnloadThread.Abort();
|
||||||
}
|
scriptLoadUnloadThread.Join();
|
||||||
}
|
}
|
||||||
catch
|
}
|
||||||
{
|
}
|
||||||
}
|
catch
|
||||||
}
|
{
|
||||||
|
}
|
||||||
#endregion
|
}
|
||||||
|
|
||||||
#region Load / Unload scripts (Thread loop)
|
#endregion
|
||||||
|
|
||||||
private void ScriptLoadUnloadThreadLoop()
|
#region Load / Unload scripts (Thread loop)
|
||||||
{
|
|
||||||
try
|
private void ScriptLoadUnloadThreadLoop()
|
||||||
{
|
{
|
||||||
while (true)
|
try
|
||||||
{
|
{
|
||||||
if (loadQueue.Count == 0 && unloadQueue.Count == 0)
|
while (true)
|
||||||
Thread.Sleep(scriptLoadUnloadThread_IdleSleepms);
|
{
|
||||||
|
if (loadQueue.Count == 0 && unloadQueue.Count == 0)
|
||||||
if (loadQueue.Count > 0)
|
Thread.Sleep(scriptLoadUnloadThread_IdleSleepms);
|
||||||
{
|
|
||||||
LoadStruct item = loadQueue.Dequeue();
|
if (loadQueue.Count > 0)
|
||||||
_StartScript(item.localID, item.itemID, item.script);
|
{
|
||||||
}
|
LoadStruct item = loadQueue.Dequeue();
|
||||||
|
_StartScript(item.localID, item.itemID, item.script);
|
||||||
if (unloadQueue.Count > 0)
|
}
|
||||||
{
|
|
||||||
UnloadStruct item = unloadQueue.Dequeue();
|
if (unloadQueue.Count > 0)
|
||||||
_StopScript(item.localID, item.itemID);
|
{
|
||||||
}
|
UnloadStruct item = unloadQueue.Dequeue();
|
||||||
}
|
_StopScript(item.localID, item.itemID);
|
||||||
}
|
}
|
||||||
catch (ThreadAbortException tae)
|
}
|
||||||
{
|
}
|
||||||
string a = tae.ToString();
|
catch (ThreadAbortException tae)
|
||||||
a = "";
|
{
|
||||||
// Expected
|
string a = tae.ToString();
|
||||||
}
|
a = "";
|
||||||
}
|
// Expected
|
||||||
|
}
|
||||||
#endregion
|
}
|
||||||
|
|
||||||
#region Helper functions
|
#endregion
|
||||||
|
|
||||||
private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
|
#region Helper functions
|
||||||
{
|
|
||||||
//Console.WriteLine("ScriptManager.CurrentDomain_AssemblyResolve: " + args.Name);
|
private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
|
||||||
return Assembly.GetExecutingAssembly().FullName == args.Name ? Assembly.GetExecutingAssembly() : null;
|
{
|
||||||
}
|
//Console.WriteLine("ScriptManager.CurrentDomain_AssemblyResolve: " + args.Name);
|
||||||
|
return Assembly.GetExecutingAssembly().FullName == args.Name ? Assembly.GetExecutingAssembly() : null;
|
||||||
#endregion
|
}
|
||||||
|
|
||||||
#region Internal functions to keep track of script
|
#endregion
|
||||||
|
|
||||||
internal Dictionary<LLUUID, LSL_BaseClass>.KeyCollection GetScriptKeys(uint localID)
|
#region Internal functions to keep track of script
|
||||||
{
|
|
||||||
if (Scripts.ContainsKey(localID) == false)
|
internal Dictionary<LLUUID, LSL_BaseClass>.KeyCollection GetScriptKeys(uint localID)
|
||||||
return null;
|
{
|
||||||
|
if (Scripts.ContainsKey(localID) == false)
|
||||||
Dictionary<LLUUID, LSL_BaseClass> Obj;
|
return null;
|
||||||
Scripts.TryGetValue(localID, out Obj);
|
|
||||||
|
Dictionary<LLUUID, LSL_BaseClass> Obj;
|
||||||
return Obj.Keys;
|
Scripts.TryGetValue(localID, out Obj);
|
||||||
}
|
|
||||||
|
return Obj.Keys;
|
||||||
internal LSL_BaseClass GetScript(uint localID, LLUUID itemID)
|
}
|
||||||
{
|
|
||||||
if (Scripts.ContainsKey(localID) == false)
|
internal LSL_BaseClass GetScript(uint localID, LLUUID itemID)
|
||||||
return null;
|
{
|
||||||
|
if (Scripts.ContainsKey(localID) == false)
|
||||||
Dictionary<LLUUID, LSL_BaseClass> Obj;
|
return null;
|
||||||
Scripts.TryGetValue(localID, out Obj);
|
|
||||||
if (Obj.ContainsKey(itemID) == false)
|
Dictionary<LLUUID, LSL_BaseClass> Obj;
|
||||||
return null;
|
Scripts.TryGetValue(localID, out Obj);
|
||||||
|
if (Obj.ContainsKey(itemID) == false)
|
||||||
// Get script
|
return null;
|
||||||
LSL_BaseClass Script;
|
|
||||||
Obj.TryGetValue(itemID, out Script);
|
// Get script
|
||||||
|
LSL_BaseClass Script;
|
||||||
return Script;
|
Obj.TryGetValue(itemID, out Script);
|
||||||
}
|
|
||||||
|
return Script;
|
||||||
internal void SetScript(uint localID, LLUUID itemID, LSL_BaseClass Script)
|
}
|
||||||
{
|
|
||||||
// Create object if it doesn't exist
|
internal void SetScript(uint localID, LLUUID itemID, LSL_BaseClass Script)
|
||||||
if (Scripts.ContainsKey(localID) == false)
|
{
|
||||||
{
|
// Create object if it doesn't exist
|
||||||
Scripts.Add(localID, new Dictionary<LLUUID, LSL_BaseClass>());
|
if (Scripts.ContainsKey(localID) == false)
|
||||||
}
|
{
|
||||||
|
Scripts.Add(localID, new Dictionary<LLUUID, LSL_BaseClass>());
|
||||||
// Delete script if it exists
|
}
|
||||||
Dictionary<LLUUID, LSL_BaseClass> Obj;
|
|
||||||
Scripts.TryGetValue(localID, out Obj);
|
// Delete script if it exists
|
||||||
if (Obj.ContainsKey(itemID) == true)
|
Dictionary<LLUUID, LSL_BaseClass> Obj;
|
||||||
Obj.Remove(itemID);
|
Scripts.TryGetValue(localID, out Obj);
|
||||||
|
if (Obj.ContainsKey(itemID) == true)
|
||||||
// Add to object
|
Obj.Remove(itemID);
|
||||||
Obj.Add(itemID, Script);
|
|
||||||
}
|
// Add to object
|
||||||
|
Obj.Add(itemID, Script);
|
||||||
internal void RemoveScript(uint localID, LLUUID itemID)
|
}
|
||||||
{
|
|
||||||
// Don't have that object?
|
internal void RemoveScript(uint localID, LLUUID itemID)
|
||||||
if (Scripts.ContainsKey(localID) == false)
|
{
|
||||||
return;
|
// Don't have that object?
|
||||||
|
if (Scripts.ContainsKey(localID) == false)
|
||||||
// Delete script if it exists
|
return;
|
||||||
Dictionary<LLUUID, LSL_BaseClass> Obj;
|
|
||||||
Scripts.TryGetValue(localID, out Obj);
|
// Delete script if it exists
|
||||||
if (Obj.ContainsKey(itemID) == true)
|
Dictionary<LLUUID, LSL_BaseClass> Obj;
|
||||||
Obj.Remove(itemID);
|
Scripts.TryGetValue(localID, out Obj);
|
||||||
}
|
if (Obj.ContainsKey(itemID) == true)
|
||||||
|
Obj.Remove(itemID);
|
||||||
#endregion
|
}
|
||||||
|
|
||||||
#region Start/Stop/Reset script
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
#region Start/Stop/Reset script
|
||||||
/// Fetches, loads and hooks up a script to an objects events
|
|
||||||
/// </summary>
|
/// <summary>
|
||||||
/// <param name="itemID"></param>
|
/// Fetches, loads and hooks up a script to an objects events
|
||||||
/// <param name="localID"></param>
|
/// </summary>
|
||||||
public void StartScript(uint localID, LLUUID itemID, string Script)
|
/// <param name="itemID"></param>
|
||||||
{
|
/// <param name="localID"></param>
|
||||||
LoadStruct ls = new LoadStruct();
|
public void StartScript(uint localID, LLUUID itemID, string Script)
|
||||||
ls.localID = localID;
|
{
|
||||||
ls.itemID = itemID;
|
LoadStruct ls = new LoadStruct();
|
||||||
ls.script = Script;
|
ls.localID = localID;
|
||||||
loadQueue.Enqueue(ls);
|
ls.itemID = itemID;
|
||||||
}
|
ls.script = Script;
|
||||||
|
loadQueue.Enqueue(ls);
|
||||||
/// <summary>
|
}
|
||||||
/// Disables and unloads a script
|
|
||||||
/// </summary>
|
/// <summary>
|
||||||
/// <param name="localID"></param>
|
/// Disables and unloads a script
|
||||||
/// <param name="itemID"></param>
|
/// </summary>
|
||||||
public void StopScript(uint localID, LLUUID itemID)
|
/// <param name="localID"></param>
|
||||||
{
|
/// <param name="itemID"></param>
|
||||||
UnloadStruct ls = new UnloadStruct();
|
public void StopScript(uint localID, LLUUID itemID)
|
||||||
ls.localID = localID;
|
{
|
||||||
ls.itemID = itemID;
|
UnloadStruct ls = new UnloadStruct();
|
||||||
unloadQueue.Enqueue(ls);
|
ls.localID = localID;
|
||||||
}
|
ls.itemID = itemID;
|
||||||
|
unloadQueue.Enqueue(ls);
|
||||||
public void ResetScript(uint localID, LLUUID itemID)
|
}
|
||||||
{
|
|
||||||
string script = GetScript(localID, itemID).SourceCode;
|
public void ResetScript(uint localID, LLUUID itemID)
|
||||||
StopScript(localID, itemID);
|
{
|
||||||
StartScript(localID, itemID, script);
|
string script = GetScript(localID, itemID).SourceCode;
|
||||||
}
|
StopScript(localID, itemID);
|
||||||
|
StartScript(localID, itemID, script);
|
||||||
private void _StartScript(uint localID, LLUUID itemID, string Script)
|
}
|
||||||
{
|
|
||||||
//IScriptHost root = host.GetRoot();
|
private void _StartScript(uint localID, LLUUID itemID, string Script)
|
||||||
Console.WriteLine("ScriptManager StartScript: localID: " + localID + ", itemID: " + itemID);
|
{
|
||||||
|
//IScriptHost root = host.GetRoot();
|
||||||
// We will initialize and start the script.
|
Console.WriteLine("ScriptManager StartScript: localID: " + localID + ", itemID: " + itemID);
|
||||||
// It will be up to the script itself to hook up the correct events.
|
|
||||||
string ScriptSource = "";
|
// We will initialize and start the script.
|
||||||
|
// It will be up to the script itself to hook up the correct events.
|
||||||
SceneObjectPart m_host = World.GetSceneObjectPart(localID);
|
string ScriptSource = "";
|
||||||
|
|
||||||
try
|
SceneObjectPart m_host = World.GetSceneObjectPart(localID);
|
||||||
{
|
|
||||||
// Create a new instance of the compiler (currently we don't want reuse)
|
try
|
||||||
Compiler.LSL.Compiler LSLCompiler = new Compiler.LSL.Compiler();
|
{
|
||||||
// Compile (We assume LSL)
|
// Create a new instance of the compiler (currently we don't want reuse)
|
||||||
ScriptSource = LSLCompiler.CompileFromLSLText(Script);
|
Compiler.LSL.Compiler LSLCompiler = new Compiler.LSL.Compiler();
|
||||||
//Console.WriteLine("Compilation of " + FileName + " done");
|
// Compile (We assume LSL)
|
||||||
// * Insert yield into code
|
ScriptSource = LSLCompiler.CompileFromLSLText(Script);
|
||||||
ScriptSource = ProcessYield(ScriptSource);
|
//Console.WriteLine("Compilation of " + FileName + " done");
|
||||||
|
// * Insert yield into code
|
||||||
|
ScriptSource = ProcessYield(ScriptSource);
|
||||||
#if DEBUG
|
|
||||||
long before;
|
|
||||||
before = GC.GetTotalMemory(true);
|
#if DEBUG
|
||||||
#endif
|
long before;
|
||||||
|
before = GC.GetTotalMemory(true);
|
||||||
LSL_BaseClass CompiledScript;
|
#endif
|
||||||
CompiledScript = m_scriptEngine.m_AppDomainManager.LoadScript(ScriptSource);
|
|
||||||
|
LSL_BaseClass CompiledScript;
|
||||||
#if DEBUG
|
CompiledScript = m_scriptEngine.m_AppDomainManager.LoadScript(ScriptSource);
|
||||||
Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(true) - before);
|
|
||||||
#endif
|
#if DEBUG
|
||||||
|
Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(true) - before);
|
||||||
CompiledScript.SourceCode = ScriptSource;
|
#endif
|
||||||
// Add it to our script memstruct
|
|
||||||
SetScript(localID, itemID, CompiledScript);
|
CompiledScript.SourceCode = ScriptSource;
|
||||||
|
// Add it to our script memstruct
|
||||||
// We need to give (untrusted) assembly a private instance of BuiltIns
|
SetScript(localID, itemID, CompiledScript);
|
||||||
// this private copy will contain Read-Only FullitemID so that it can bring that on to the server whenever needed.
|
|
||||||
|
// We need to give (untrusted) assembly a private instance of BuiltIns
|
||||||
|
// this private copy will contain Read-Only FullitemID so that it can bring that on to the server whenever needed.
|
||||||
LSL_BuiltIn_Commands LSLB = new LSL_BuiltIn_Commands(m_scriptEngine, m_host, localID, itemID);
|
|
||||||
|
|
||||||
// Start the script - giving it BuiltIns
|
LSL_BuiltIn_Commands LSLB = new LSL_BuiltIn_Commands(m_scriptEngine, m_host, localID, itemID);
|
||||||
CompiledScript.Start(LSLB);
|
|
||||||
|
// Start the script - giving it BuiltIns
|
||||||
// Fire the first start-event
|
CompiledScript.Start(LSLB);
|
||||||
m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", new object[] {});
|
|
||||||
}
|
// Fire the first start-event
|
||||||
catch (Exception e)
|
m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", new object[] {});
|
||||||
{
|
}
|
||||||
//m_scriptEngine.Log.Error("ScriptEngine", "Error compiling script: " + e.ToString());
|
catch (Exception e)
|
||||||
try
|
{
|
||||||
{
|
//m_scriptEngine.m_log.Error("[ScriptEngine]: Error compiling script: " + e.ToString());
|
||||||
// DISPLAY ERROR INWORLD
|
try
|
||||||
string text = "Error compiling script:\r\n" + e.Message.ToString();
|
{
|
||||||
if (text.Length > 1500)
|
// DISPLAY ERROR INWORLD
|
||||||
text = text.Substring(0, 1500);
|
string text = "Error compiling script:\r\n" + e.Message.ToString();
|
||||||
World.SimChat(Helpers.StringToField(text), ChatTypeEnum.Say, 0, m_host.AbsolutePosition, m_host.Name, m_host.UUID);
|
if (text.Length > 1500)
|
||||||
}
|
text = text.Substring(0, 1500);
|
||||||
catch (Exception e2)
|
World.SimChat(Helpers.StringToField(text), ChatTypeEnum.Say, 0, m_host.AbsolutePosition, m_host.Name, m_host.UUID);
|
||||||
{
|
}
|
||||||
m_scriptEngine.Log.Error("ScriptEngine", "Error displaying error in-world: " + e2.ToString());
|
catch (Exception e2)
|
||||||
}
|
{
|
||||||
}
|
m_scriptEngine.m_log.Error("[ScriptEngine]: Error displaying error in-world: " + e2.ToString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private void _StopScript(uint localID, LLUUID itemID)
|
}
|
||||||
{
|
|
||||||
// Stop script
|
private void _StopScript(uint localID, LLUUID itemID)
|
||||||
Console.WriteLine("Stop script localID: " + localID + " LLUID: " + itemID.ToString());
|
{
|
||||||
|
// Stop script
|
||||||
|
Console.WriteLine("Stop script localID: " + localID + " LLUID: " + itemID.ToString());
|
||||||
// Stop long command on script
|
|
||||||
m_scriptEngine.m_LSLLongCmdHandler.RemoveScript(localID, itemID);
|
|
||||||
|
// Stop long command on script
|
||||||
LSL_BaseClass LSLBC = GetScript(localID, itemID);
|
m_scriptEngine.m_LSLLongCmdHandler.RemoveScript(localID, itemID);
|
||||||
if (LSLBC == null)
|
|
||||||
return;
|
LSL_BaseClass LSLBC = GetScript(localID, itemID);
|
||||||
|
if (LSLBC == null)
|
||||||
// TEMP: First serialize it
|
return;
|
||||||
//GetSerializedScript(localID, itemID);
|
|
||||||
|
// TEMP: First serialize it
|
||||||
|
//GetSerializedScript(localID, itemID);
|
||||||
try
|
|
||||||
{
|
|
||||||
// Get AppDomain
|
try
|
||||||
AppDomain ad = LSLBC.Exec.GetAppDomain();
|
{
|
||||||
// Tell script not to accept new requests
|
// Get AppDomain
|
||||||
GetScript(localID, itemID).Exec.StopScript();
|
AppDomain ad = LSLBC.Exec.GetAppDomain();
|
||||||
// Remove from internal structure
|
// Tell script not to accept new requests
|
||||||
RemoveScript(localID, itemID);
|
GetScript(localID, itemID).Exec.StopScript();
|
||||||
// Tell AppDomain that we have stopped script
|
// Remove from internal structure
|
||||||
m_scriptEngine.m_AppDomainManager.StopScript(ad);
|
RemoveScript(localID, itemID);
|
||||||
}
|
// Tell AppDomain that we have stopped script
|
||||||
catch (Exception e)
|
m_scriptEngine.m_AppDomainManager.StopScript(ad);
|
||||||
{
|
}
|
||||||
Console.WriteLine("Exception stopping script localID: " + localID + " LLUID: " + itemID.ToString() +
|
catch (Exception e)
|
||||||
": " + e.ToString());
|
{
|
||||||
}
|
Console.WriteLine("Exception stopping script localID: " + localID + " LLUID: " + itemID.ToString() +
|
||||||
}
|
": " + e.ToString());
|
||||||
|
}
|
||||||
private string ProcessYield(string FileName)
|
}
|
||||||
{
|
|
||||||
// TODO: Create a new assembly and copy old but insert Yield Code
|
private string ProcessYield(string FileName)
|
||||||
//return TempDotNetMicroThreadingCodeInjector.TestFix(FileName);
|
{
|
||||||
return FileName;
|
// TODO: Create a new assembly and copy old but insert Yield Code
|
||||||
}
|
//return TempDotNetMicroThreadingCodeInjector.TestFix(FileName);
|
||||||
|
return FileName;
|
||||||
#endregion
|
}
|
||||||
|
|
||||||
#region Perform event execution in script
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
#region Perform event execution in script
|
||||||
/// Execute a LL-event-function in Script
|
|
||||||
/// </summary>
|
/// <summary>
|
||||||
/// <param name="localID">Object the script is located in</param>
|
/// Execute a LL-event-function in Script
|
||||||
/// <param name="itemID">Script ID</param>
|
/// </summary>
|
||||||
/// <param name="FunctionName">Name of function</param>
|
/// <param name="localID">Object the script is located in</param>
|
||||||
/// <param name="args">Arguments to pass to function</param>
|
/// <param name="itemID">Script ID</param>
|
||||||
internal void ExecuteEvent(uint localID, LLUUID itemID, string FunctionName, object[] args)
|
/// <param name="FunctionName">Name of function</param>
|
||||||
{
|
/// <param name="args">Arguments to pass to function</param>
|
||||||
// Execute a function in the script
|
internal void ExecuteEvent(uint localID, LLUUID itemID, string FunctionName, object[] args)
|
||||||
//m_scriptEngine.Log.Verbose("ScriptEngine", "Executing Function localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName);
|
{
|
||||||
LSL_BaseClass Script = m_scriptEngine.m_ScriptManager.GetScript(localID, itemID);
|
// Execute a function in the script
|
||||||
if (Script == null)
|
//m_scriptEngine.m_log.Info("[ScriptEngine]: Executing Function localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName);
|
||||||
return;
|
LSL_BaseClass Script = m_scriptEngine.m_ScriptManager.GetScript(localID, itemID);
|
||||||
|
if (Script == null)
|
||||||
// Must be done in correct AppDomain, so leaving it up to the script itself
|
return;
|
||||||
Script.Exec.ExecuteEvent(FunctionName, args);
|
|
||||||
}
|
// Must be done in correct AppDomain, so leaving it up to the script itself
|
||||||
|
Script.Exec.ExecuteEvent(FunctionName, args);
|
||||||
#endregion
|
}
|
||||||
|
|
||||||
#region Script serialization/deserialization
|
#endregion
|
||||||
|
|
||||||
public void GetSerializedScript(uint localID, LLUUID itemID)
|
#region Script serialization/deserialization
|
||||||
{
|
|
||||||
// Serialize the script and return it
|
public void GetSerializedScript(uint localID, LLUUID itemID)
|
||||||
// Should not be a problem
|
{
|
||||||
FileStream fs = File.Create("SERIALIZED_SCRIPT_" + itemID);
|
// Serialize the script and return it
|
||||||
BinaryFormatter b = new BinaryFormatter();
|
// Should not be a problem
|
||||||
b.Serialize(fs, GetScript(localID, itemID));
|
FileStream fs = File.Create("SERIALIZED_SCRIPT_" + itemID);
|
||||||
fs.Close();
|
BinaryFormatter b = new BinaryFormatter();
|
||||||
}
|
b.Serialize(fs, GetScript(localID, itemID));
|
||||||
|
fs.Close();
|
||||||
public void PutSerializedScript(uint localID, LLUUID itemID)
|
}
|
||||||
{
|
|
||||||
// Deserialize the script and inject it into an AppDomain
|
public void PutSerializedScript(uint localID, LLUUID itemID)
|
||||||
|
{
|
||||||
// How to inject into an AppDomain?
|
// Deserialize the script and inject it into an AppDomain
|
||||||
}
|
|
||||||
|
// How to inject into an AppDomain?
|
||||||
#endregion
|
}
|
||||||
}
|
|
||||||
}
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,69 +1,69 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Rail.Reflect;
|
using Rail.Reflect;
|
||||||
using Rail.Transformation;
|
using Rail.Transformation;
|
||||||
|
|
||||||
namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tedds Sandbox for RAIL/microtrheading. This class is only for testing purposes!
|
/// Tedds Sandbox for RAIL/microtrheading. This class is only for testing purposes!
|
||||||
/// Its offspring will be the actual implementation.
|
/// Its offspring will be the actual implementation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class TempDotNetMicroThreadingCodeInjector
|
internal class TempDotNetMicroThreadingCodeInjector
|
||||||
{
|
{
|
||||||
public static string TestFix(string FileName)
|
public static string TestFix(string FileName)
|
||||||
{
|
{
|
||||||
string ret = Path.GetFileNameWithoutExtension(FileName + "_fixed.dll");
|
string ret = Path.GetFileNameWithoutExtension(FileName + "_fixed.dll");
|
||||||
|
|
||||||
Console.WriteLine("Loading: \"" + FileName + "\"");
|
Console.WriteLine("Loading: \"" + FileName + "\"");
|
||||||
RAssemblyDef rAssembly = RAssemblyDef.LoadAssembly(FileName);
|
RAssemblyDef rAssembly = RAssemblyDef.LoadAssembly(FileName);
|
||||||
|
|
||||||
|
|
||||||
//Get the type of the method to copy from assembly Teste2.exe to assembly Teste.exe
|
//Get the type of the method to copy from assembly Teste2.exe to assembly Teste.exe
|
||||||
RTypeDef type = (RTypeDef) rAssembly.RModuleDef.GetType("SecondLife.Script");
|
RTypeDef type = (RTypeDef) rAssembly.RModuleDef.GetType("SecondLife.Script");
|
||||||
|
|
||||||
//Get the methods in the type
|
//Get the methods in the type
|
||||||
RMethod[] m = type.GetMethods();
|
RMethod[] m = type.GetMethods();
|
||||||
|
|
||||||
//Create a MethodPrologueAdder visitor object with the method to add
|
//Create a MethodPrologueAdder visitor object with the method to add
|
||||||
//and with the flag that enables local variable creation set to true
|
//and with the flag that enables local variable creation set to true
|
||||||
MethodPrologueAdder mpa = new MethodPrologueAdder((RMethodDef) m[0], true);
|
MethodPrologueAdder mpa = new MethodPrologueAdder((RMethodDef) m[0], true);
|
||||||
|
|
||||||
//Apply the changes to the assembly
|
//Apply the changes to the assembly
|
||||||
rAssembly.Accept(mpa);
|
rAssembly.Accept(mpa);
|
||||||
|
|
||||||
//Save the new assembly
|
//Save the new assembly
|
||||||
rAssembly.SaveAssembly(ret);
|
rAssembly.SaveAssembly(ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue