aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs15
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs67
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs63
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs36
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs9
5 files changed, 175 insertions, 15 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs b/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs
index cc7885a..d7907e3 100644
--- a/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs
@@ -31,6 +31,16 @@ using OpenMetaverse;
31 31
32namespace OpenSim.Region.Framework.Interfaces 32namespace OpenSim.Region.Framework.Interfaces
33{ 33{
34 // these could be expanded at some point to provide more type information
35 // for now value accounts for all base types
36 public enum JsonStoreNodeType
37 {
38 Undefined = 0,
39 Object = 1,
40 Array = 2,
41 Value = 3
42 }
43
34 public delegate void TakeValueCallback(string s); 44 public delegate void TakeValueCallback(string s);
35 45
36 public interface IJsonStoreModule 46 public interface IJsonStoreModule
@@ -38,13 +48,18 @@ namespace OpenSim.Region.Framework.Interfaces
38 bool AttachObjectStore(UUID objectID); 48 bool AttachObjectStore(UUID objectID);
39 bool CreateStore(string value, ref UUID result); 49 bool CreateStore(string value, ref UUID result);
40 bool DestroyStore(UUID storeID); 50 bool DestroyStore(UUID storeID);
51
52 JsonStoreNodeType PathType(UUID storeID, string path);
41 bool TestStore(UUID storeID); 53 bool TestStore(UUID storeID);
42 bool TestPath(UUID storeID, string path, bool useJson); 54 bool TestPath(UUID storeID, string path, bool useJson);
55
43 bool SetValue(UUID storeID, string path, string value, bool useJson); 56 bool SetValue(UUID storeID, string path, string value, bool useJson);
44 bool RemoveValue(UUID storeID, string path); 57 bool RemoveValue(UUID storeID, string path);
45 bool GetValue(UUID storeID, string path, bool useJson, out string value); 58 bool GetValue(UUID storeID, string path, bool useJson, out string value);
46 59
47 void TakeValue(UUID storeID, string path, bool useJson, TakeValueCallback cback); 60 void TakeValue(UUID storeID, string path, bool useJson, TakeValueCallback cback);
48 void ReadValue(UUID storeID, string path, bool useJson, TakeValueCallback cback); 61 void ReadValue(UUID storeID, string path, bool useJson, TakeValueCallback cback);
62
63 int ArrayLength(UUID storeID, string path);
49 } 64 }
50} 65}
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs
index 3bad06c..ca3989a 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs
@@ -68,14 +68,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
68 protected List<TakeValueCallbackClass> m_TakeStore; 68 protected List<TakeValueCallbackClass> m_TakeStore;
69 protected List<TakeValueCallbackClass> m_ReadStore; 69 protected List<TakeValueCallbackClass> m_ReadStore;
70 70
71 // add separators for quoted paths 71 // add separators for quoted paths and array references
72 protected static Regex m_ParsePassOne = new Regex("{[^}]+}"); 72 protected static Regex m_ParsePassOne = new Regex("({[^}]+}|\\[[0-9]+\\]|\\[\\+\\])");
73
74 // add separators for array references
75 protected static Regex m_ParsePassTwo = new Regex("(\\[[0-9]+\\]|\\[\\+\\])");
76 73
77 // add quotes to bare identifiers which are limited to alphabetic characters 74 // add quotes to bare identifiers which are limited to alphabetic characters
78 protected static Regex m_ParsePassThree = new Regex("\\.([a-zA-Z]+)"); 75 protected static Regex m_ParsePassThree = new Regex("(?<!{[^}]*)\\.([a-zA-Z]+)(?=\\.)");
79 76
80 // remove extra separator characters 77 // remove extra separator characters
81 protected static Regex m_ParsePassFour = new Regex("\\.+"); 78 protected static Regex m_ParsePassFour = new Regex("\\.+");
@@ -84,7 +81,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
84 protected static Regex m_ValidatePath = new Regex("^\\.(({[^}]+}|\\[[0-9]+\\]|\\[\\+\\])\\.)*$"); 81 protected static Regex m_ValidatePath = new Regex("^\\.(({[^}]+}|\\[[0-9]+\\]|\\[\\+\\])\\.)*$");
85 82
86 // expression used to match path components 83 // expression used to match path components
87 protected static Regex m_PathComponent = new Regex("\\.({[^}]+}|\\[[0-9]+\\]|\\[\\+\\]+)"); 84 protected static Regex m_PathComponent = new Regex("\\.({[^}]+}|\\[[0-9]+\\]|\\[\\+\\])");
88 85
89 // extract the internals of an array reference 86 // extract the internals of an array reference
90 protected static Regex m_SimpleArrayPattern = new Regex("\\[([0-9]+)\\]"); 87 protected static Regex m_SimpleArrayPattern = new Regex("\\[([0-9]+)\\]");
@@ -148,6 +145,34 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
148 /// 145 ///
149 /// </summary> 146 /// </summary>
150 // ----------------------------------------------------------------- 147 // -----------------------------------------------------------------
148 public JsonStoreNodeType PathType(string expr)
149 {
150 Stack<string> path;
151 if (! ParsePathExpression(expr,out path))
152 return JsonStoreNodeType.Undefined;
153
154 OSD result = ProcessPathExpression(ValueStore,path);
155
156 if (result == null)
157 return JsonStoreNodeType.Undefined;
158
159 if (result is OSDMap)
160 return JsonStoreNodeType.Object;
161
162 if (result is OSDArray)
163 return JsonStoreNodeType.Array;
164
165 if (OSDBaseType(result.Type))
166 return JsonStoreNodeType.Value;
167
168 return JsonStoreNodeType.Undefined;
169 }
170
171 // -----------------------------------------------------------------
172 /// <summary>
173 ///
174 /// </summary>
175 // -----------------------------------------------------------------
151 public bool TestPath(string expr, bool useJson) 176 public bool TestPath(string expr, bool useJson)
152 { 177 {
153 Stack<string> path; 178 Stack<string> path;
@@ -170,6 +195,27 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
170 /// 195 ///
171 /// </summary> 196 /// </summary>
172 // ----------------------------------------------------------------- 197 // -----------------------------------------------------------------
198 public int ArrayLength(string expr)
199 {
200 Stack<string> path;
201 if (! ParsePathExpression(expr,out path))
202 return -1;
203
204 OSD result = ProcessPathExpression(ValueStore,path);
205 if (result != null && result.Type == OSDType.Array)
206 {
207 OSDArray arr = result as OSDArray;
208 return arr.Count;
209 }
210
211 return -1;
212 }
213
214 // -----------------------------------------------------------------
215 /// <summary>
216 ///
217 /// </summary>
218 // -----------------------------------------------------------------
173 public bool GetValue(string expr, out string value, bool useJson) 219 public bool GetValue(string expr, out string value, bool useJson)
174 { 220 {
175 Stack<string> path; 221 Stack<string> path;
@@ -465,11 +511,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
465 // add front and rear separators 511 // add front and rear separators
466 expr = "." + expr + "."; 512 expr = "." + expr + ".";
467 513
468 // add separators for quoted exprs 514 // add separators for quoted exprs and array references
469 expr = m_ParsePassOne.Replace(expr,".$0.",-1,0); 515 expr = m_ParsePassOne.Replace(expr,".$1.",-1,0);
470
471 // add separators for array references
472 expr = m_ParsePassTwo.Replace(expr,".$0.",-1,0);
473 516
474 // add quotes to bare identifier 517 // add quotes to bare identifier
475 expr = m_ParsePassThree.Replace(expr,".{$1}",-1,0); 518 expr = m_ParsePassThree.Replace(expr,".{$1}",-1,0);
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs
index cc13661..eec86ef 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs
@@ -270,6 +270,38 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
270 /// 270 ///
271 /// </summary> 271 /// </summary>
272 // ----------------------------------------------------------------- 272 // -----------------------------------------------------------------
273 public JsonStoreNodeType PathType(UUID storeID, string path)
274 {
275 if (! m_enabled) return JsonStoreNodeType.Undefined;
276
277 JsonStore map = null;
278 lock (m_JsonValueStore)
279 {
280 if (! m_JsonValueStore.TryGetValue(storeID,out map))
281 {
282 m_log.InfoFormat("[JsonStore] Missing store {0}",storeID);
283 return JsonStoreNodeType.Undefined;
284 }
285 }
286
287 try
288 {
289 lock (map)
290 return map.PathType(path);
291 }
292 catch (Exception e)
293 {
294 m_log.Error(string.Format("[JsonStore]: Path test failed for {0} in {1}", path, storeID), e);
295 }
296
297 return JsonStoreNodeType.Undefined;
298 }
299
300 // -----------------------------------------------------------------
301 /// <summary>
302 ///
303 /// </summary>
304 // -----------------------------------------------------------------
273 public bool TestPath(UUID storeID, string path, bool useJson) 305 public bool TestPath(UUID storeID, string path, bool useJson)
274 { 306 {
275 if (! m_enabled) return false; 307 if (! m_enabled) return false;
@@ -375,6 +407,37 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
375 /// 407 ///
376 /// </summary> 408 /// </summary>
377 // ----------------------------------------------------------------- 409 // -----------------------------------------------------------------
410 public int ArrayLength(UUID storeID, string path)
411 {
412 if (! m_enabled) return -1;
413
414 JsonStore map = null;
415 lock (m_JsonValueStore)
416 {
417 if (! m_JsonValueStore.TryGetValue(storeID,out map))
418 return -1;
419 }
420
421 try
422 {
423 lock (map)
424 {
425 return map.ArrayLength(path);
426 }
427 }
428 catch (Exception e)
429 {
430 m_log.Error("[JsonStore]: unable to retrieve value", e);
431 }
432
433 return -1;
434 }
435
436 // -----------------------------------------------------------------
437 /// <summary>
438 ///
439 /// </summary>
440 // -----------------------------------------------------------------
378 public bool GetValue(UUID storeID, string path, bool useJson, out string value) 441 public bool GetValue(UUID storeID, string path, bool useJson, out string value)
379 { 442 {
380 value = String.Empty; 443 value = String.Empty;
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
index e436304..3955bff 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
@@ -167,7 +167,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
167 try 167 try
168 { 168 {
169 m_comms.RegisterScriptInvocations(this); 169 m_comms.RegisterScriptInvocations(this);
170 170 m_comms.RegisterConstants(this);
171
171 // m_comms.RegisterScriptInvocation(this, "JsonCreateStore"); 172 // m_comms.RegisterScriptInvocation(this, "JsonCreateStore");
172 // m_comms.RegisterScriptInvocation(this, "JsonAttachObjectStore"); 173 // m_comms.RegisterScriptInvocation(this, "JsonAttachObjectStore");
173 // m_comms.RegisterScriptInvocation(this, "JsonDestroyStore"); 174 // m_comms.RegisterScriptInvocation(this, "JsonDestroyStore");
@@ -214,6 +215,22 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
214 215
215#endregion 216#endregion
216 217
218#region ScriptConstantInteface
219
220 [ScriptConstant]
221 public static readonly int JSONTYPEUNDEF = (int)JsonStoreNodeType.Undefined;
222
223 [ScriptConstant]
224 public static readonly int JSONTYPEOBJECT = (int)JsonStoreNodeType.Object;
225
226 [ScriptConstant]
227 public static readonly int JSONTYPEARRAY = (int)JsonStoreNodeType.Array;
228
229 [ScriptConstant]
230 public static readonly int JSONTYPEVALUE = (int)JsonStoreNodeType.Value;
231
232#endregion
233
217#region ScriptInvocationInteface 234#region ScriptInvocationInteface
218 // ----------------------------------------------------------------- 235 // -----------------------------------------------------------------
219 /// <summary> 236 /// <summary>
@@ -319,6 +336,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
319 /// </summary> 336 /// </summary>
320 // ----------------------------------------------------------------- 337 // -----------------------------------------------------------------
321 [ScriptInvocation] 338 [ScriptInvocation]
339 public int JsonPathType(UUID hostID, UUID scriptID, UUID storeID, string path)
340 {
341 return (int)m_store.PathType(storeID,path);
342 }
343
344 [ScriptInvocation]
322 public int JsonTestPath(UUID hostID, UUID scriptID, UUID storeID, string path) 345 public int JsonTestPath(UUID hostID, UUID scriptID, UUID storeID, string path)
323 { 346 {
324 return m_store.TestPath(storeID,path,false) ? 1 : 0; 347 return m_store.TestPath(storeID,path,false) ? 1 : 0;
@@ -364,6 +387,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
364 /// </summary> 387 /// </summary>
365 // ----------------------------------------------------------------- 388 // -----------------------------------------------------------------
366 [ScriptInvocation] 389 [ScriptInvocation]
390 public int JsonArrayLength(UUID hostID, UUID scriptID, UUID storeID, string path)
391 {
392 return m_store.ArrayLength(storeID,path);
393 }
394
395 // -----------------------------------------------------------------
396 /// <summary>
397 ///
398 /// </summary>
399 // -----------------------------------------------------------------
400 [ScriptInvocation]
367 public string JsonGetValue(UUID hostID, UUID scriptID, UUID storeID, string path) 401 public string JsonGetValue(UUID hostID, UUID scriptID, UUID storeID, string path)
368 { 402 {
369 string value = String.Empty; 403 string value = String.Empty;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index f9ee590..4c6950d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -4888,6 +4888,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4888 } 4888 }
4889 } 4889 }
4890 } 4890 }
4891
4891 if (pushAllowed) 4892 if (pushAllowed)
4892 { 4893 {
4893 float distance = (PusheePos - m_host.AbsolutePosition).Length(); 4894 float distance = (PusheePos - m_host.AbsolutePosition).Length();
@@ -4917,17 +4918,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4917 applied_linear_impulse *= scaling_factor; 4918 applied_linear_impulse *= scaling_factor;
4918 4919
4919 } 4920 }
4921
4920 if (pusheeIsAvatar) 4922 if (pusheeIsAvatar)
4921 { 4923 {
4922 if (pusheeav != null) 4924 if (pusheeav != null)
4923 { 4925 {
4924 if (pusheeav.PhysicsActor != null) 4926 PhysicsActor pa = pusheeav.PhysicsActor;
4927
4928 if (pa != null)
4925 { 4929 {
4926 if (local != 0) 4930 if (local != 0)
4927 { 4931 {
4928 applied_linear_impulse *= m_host.GetWorldRotation(); 4932 applied_linear_impulse *= m_host.GetWorldRotation();
4929 } 4933 }
4930 pusheeav.PhysicsActor.AddForce(applied_linear_impulse, true); 4934
4935 pa.AddForce(applied_linear_impulse, true);
4931 } 4936 }
4932 } 4937 }
4933 } 4938 }