Merge branch 'master' into careminster
commit
9d55a2298d
|
@ -31,6 +31,16 @@ using OpenMetaverse;
|
|||
|
||||
namespace OpenSim.Region.Framework.Interfaces
|
||||
{
|
||||
// these could be expanded at some point to provide more type information
|
||||
// for now value accounts for all base types
|
||||
public enum JsonStoreNodeType
|
||||
{
|
||||
Undefined = 0,
|
||||
Object = 1,
|
||||
Array = 2,
|
||||
Value = 3
|
||||
}
|
||||
|
||||
public delegate void TakeValueCallback(string s);
|
||||
|
||||
public interface IJsonStoreModule
|
||||
|
@ -38,13 +48,18 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
bool AttachObjectStore(UUID objectID);
|
||||
bool CreateStore(string value, ref UUID result);
|
||||
bool DestroyStore(UUID storeID);
|
||||
|
||||
JsonStoreNodeType PathType(UUID storeID, string path);
|
||||
bool TestStore(UUID storeID);
|
||||
bool TestPath(UUID storeID, string path, bool useJson);
|
||||
|
||||
bool SetValue(UUID storeID, string path, string value, bool useJson);
|
||||
bool RemoveValue(UUID storeID, string path);
|
||||
bool GetValue(UUID storeID, string path, bool useJson, out string value);
|
||||
|
||||
void TakeValue(UUID storeID, string path, bool useJson, TakeValueCallback cback);
|
||||
void ReadValue(UUID storeID, string path, bool useJson, TakeValueCallback cback);
|
||||
|
||||
int ArrayLength(UUID storeID, string path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,14 +68,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
|||
protected List<TakeValueCallbackClass> m_TakeStore;
|
||||
protected List<TakeValueCallbackClass> m_ReadStore;
|
||||
|
||||
// add separators for quoted paths
|
||||
protected static Regex m_ParsePassOne = new Regex("{[^}]+}");
|
||||
|
||||
// add separators for array references
|
||||
protected static Regex m_ParsePassTwo = new Regex("(\\[[0-9]+\\]|\\[\\+\\])");
|
||||
// add separators for quoted paths and array references
|
||||
protected static Regex m_ParsePassOne = new Regex("({[^}]+}|\\[[0-9]+\\]|\\[\\+\\])");
|
||||
|
||||
// add quotes to bare identifiers which are limited to alphabetic characters
|
||||
protected static Regex m_ParsePassThree = new Regex("\\.([a-zA-Z]+)");
|
||||
protected static Regex m_ParsePassThree = new Regex("(?<!{[^}]*)\\.([a-zA-Z]+)(?=\\.)");
|
||||
|
||||
// remove extra separator characters
|
||||
protected static Regex m_ParsePassFour = new Regex("\\.+");
|
||||
|
@ -84,7 +81,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
|||
protected static Regex m_ValidatePath = new Regex("^\\.(({[^}]+}|\\[[0-9]+\\]|\\[\\+\\])\\.)*$");
|
||||
|
||||
// expression used to match path components
|
||||
protected static Regex m_PathComponent = new Regex("\\.({[^}]+}|\\[[0-9]+\\]|\\[\\+\\]+)");
|
||||
protected static Regex m_PathComponent = new Regex("\\.({[^}]+}|\\[[0-9]+\\]|\\[\\+\\])");
|
||||
|
||||
// extract the internals of an array reference
|
||||
protected static Regex m_SimpleArrayPattern = new Regex("\\[([0-9]+)\\]");
|
||||
|
@ -143,6 +140,34 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
|||
ValueStore = OSDParser.DeserializeJson(value);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
// -----------------------------------------------------------------
|
||||
public JsonStoreNodeType PathType(string expr)
|
||||
{
|
||||
Stack<string> path;
|
||||
if (! ParsePathExpression(expr,out path))
|
||||
return JsonStoreNodeType.Undefined;
|
||||
|
||||
OSD result = ProcessPathExpression(ValueStore,path);
|
||||
|
||||
if (result == null)
|
||||
return JsonStoreNodeType.Undefined;
|
||||
|
||||
if (result is OSDMap)
|
||||
return JsonStoreNodeType.Object;
|
||||
|
||||
if (result is OSDArray)
|
||||
return JsonStoreNodeType.Array;
|
||||
|
||||
if (OSDBaseType(result.Type))
|
||||
return JsonStoreNodeType.Value;
|
||||
|
||||
return JsonStoreNodeType.Undefined;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
/// <summary>
|
||||
///
|
||||
|
@ -165,6 +190,27 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
|||
return false;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
// -----------------------------------------------------------------
|
||||
public int ArrayLength(string expr)
|
||||
{
|
||||
Stack<string> path;
|
||||
if (! ParsePathExpression(expr,out path))
|
||||
return -1;
|
||||
|
||||
OSD result = ProcessPathExpression(ValueStore,path);
|
||||
if (result != null && result.Type == OSDType.Array)
|
||||
{
|
||||
OSDArray arr = result as OSDArray;
|
||||
return arr.Count;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
/// <summary>
|
||||
///
|
||||
|
@ -465,11 +511,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
|||
// add front and rear separators
|
||||
expr = "." + expr + ".";
|
||||
|
||||
// add separators for quoted exprs
|
||||
expr = m_ParsePassOne.Replace(expr,".$0.",-1,0);
|
||||
|
||||
// add separators for array references
|
||||
expr = m_ParsePassTwo.Replace(expr,".$0.",-1,0);
|
||||
// add separators for quoted exprs and array references
|
||||
expr = m_ParsePassOne.Replace(expr,".$1.",-1,0);
|
||||
|
||||
// add quotes to bare identifier
|
||||
expr = m_ParsePassThree.Replace(expr,".{$1}",-1,0);
|
||||
|
|
|
@ -265,6 +265,38 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
|||
return m_JsonValueStore.ContainsKey(storeID);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
// -----------------------------------------------------------------
|
||||
public JsonStoreNodeType PathType(UUID storeID, string path)
|
||||
{
|
||||
if (! m_enabled) return JsonStoreNodeType.Undefined;
|
||||
|
||||
JsonStore map = null;
|
||||
lock (m_JsonValueStore)
|
||||
{
|
||||
if (! m_JsonValueStore.TryGetValue(storeID,out map))
|
||||
{
|
||||
m_log.InfoFormat("[JsonStore] Missing store {0}",storeID);
|
||||
return JsonStoreNodeType.Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
lock (map)
|
||||
return map.PathType(path);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error(string.Format("[JsonStore]: Path test failed for {0} in {1}", path, storeID), e);
|
||||
}
|
||||
|
||||
return JsonStoreNodeType.Undefined;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
/// <summary>
|
||||
///
|
||||
|
@ -370,6 +402,37 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
|||
return false;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
// -----------------------------------------------------------------
|
||||
public int ArrayLength(UUID storeID, string path)
|
||||
{
|
||||
if (! m_enabled) return -1;
|
||||
|
||||
JsonStore map = null;
|
||||
lock (m_JsonValueStore)
|
||||
{
|
||||
if (! m_JsonValueStore.TryGetValue(storeID,out map))
|
||||
return -1;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
lock (map)
|
||||
{
|
||||
return map.ArrayLength(path);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[JsonStore]: unable to retrieve value", e);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
/// <summary>
|
||||
///
|
||||
|
|
|
@ -167,7 +167,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
|||
try
|
||||
{
|
||||
m_comms.RegisterScriptInvocations(this);
|
||||
|
||||
m_comms.RegisterConstants(this);
|
||||
|
||||
// m_comms.RegisterScriptInvocation(this, "JsonCreateStore");
|
||||
// m_comms.RegisterScriptInvocation(this, "JsonAttachObjectStore");
|
||||
// m_comms.RegisterScriptInvocation(this, "JsonDestroyStore");
|
||||
|
@ -214,6 +215,22 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
|||
|
||||
#endregion
|
||||
|
||||
#region ScriptConstantInteface
|
||||
|
||||
[ScriptConstant]
|
||||
public static readonly int JSONTYPEUNDEF = (int)JsonStoreNodeType.Undefined;
|
||||
|
||||
[ScriptConstant]
|
||||
public static readonly int JSONTYPEOBJECT = (int)JsonStoreNodeType.Object;
|
||||
|
||||
[ScriptConstant]
|
||||
public static readonly int JSONTYPEARRAY = (int)JsonStoreNodeType.Array;
|
||||
|
||||
[ScriptConstant]
|
||||
public static readonly int JSONTYPEVALUE = (int)JsonStoreNodeType.Value;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ScriptInvocationInteface
|
||||
// -----------------------------------------------------------------
|
||||
/// <summary>
|
||||
|
@ -318,6 +335,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
|||
///
|
||||
/// </summary>
|
||||
// -----------------------------------------------------------------
|
||||
[ScriptInvocation]
|
||||
public int JsonPathType(UUID hostID, UUID scriptID, UUID storeID, string path)
|
||||
{
|
||||
return (int)m_store.PathType(storeID,path);
|
||||
}
|
||||
|
||||
[ScriptInvocation]
|
||||
public int JsonTestPath(UUID hostID, UUID scriptID, UUID storeID, string path)
|
||||
{
|
||||
|
@ -358,6 +381,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
|||
return m_store.RemoveValue(storeID,path) ? 1 : 0;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
// -----------------------------------------------------------------
|
||||
[ScriptInvocation]
|
||||
public int JsonArrayLength(UUID hostID, UUID scriptID, UUID storeID, string path)
|
||||
{
|
||||
return m_store.ArrayLength(storeID,path);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
/// <summary>
|
||||
///
|
||||
|
|
|
@ -4888,6 +4888,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pushAllowed)
|
||||
{
|
||||
float distance = (PusheePos - m_host.AbsolutePosition).Length();
|
||||
|
@ -4917,17 +4918,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
applied_linear_impulse *= scaling_factor;
|
||||
|
||||
}
|
||||
|
||||
if (pusheeIsAvatar)
|
||||
{
|
||||
if (pusheeav != null)
|
||||
{
|
||||
if (pusheeav.PhysicsActor != null)
|
||||
PhysicsActor pa = pusheeav.PhysicsActor;
|
||||
|
||||
if (pa != null)
|
||||
{
|
||||
if (local != 0)
|
||||
{
|
||||
applied_linear_impulse *= m_host.GetWorldRotation();
|
||||
}
|
||||
pusheeav.PhysicsActor.AddForce(applied_linear_impulse, true);
|
||||
|
||||
pa.AddForce(applied_linear_impulse, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue