Broaden the internal OSD type checks to parse JSON that has
non string values.0.7.4-extended
parent
5393ecfa75
commit
9ee6c06ec8
|
@ -127,7 +127,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
|||
if (result == null)
|
||||
return false;
|
||||
|
||||
if (useJson || result.Type == OSDType.String)
|
||||
if (useJson || OSDBaseType(result.Type))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -498,7 +498,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
|||
return true;
|
||||
}
|
||||
|
||||
if (result.Type == OSDType.String)
|
||||
if (OSDBaseType(result.Type))
|
||||
{
|
||||
value = result.AsString();
|
||||
return true;
|
||||
|
@ -523,5 +523,47 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
|||
|
||||
return pkey;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
// -----------------------------------------------------------------
|
||||
protected static bool OSDBaseType(OSDType type)
|
||||
{
|
||||
// Should be the list of base types for which AsString() returns
|
||||
// something useful
|
||||
if (type == OSDType.Boolean)
|
||||
return true;
|
||||
if (type == OSDType.Integer)
|
||||
return true;
|
||||
if (type == OSDType.Real)
|
||||
return true;
|
||||
if (type == OSDType.String)
|
||||
return true;
|
||||
if (type == OSDType.UUID)
|
||||
return true;
|
||||
if (type == OSDType.Date)
|
||||
return true;
|
||||
if (type == OSDType.URI)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
// -----------------------------------------------------------------
|
||||
protected static int ComputeSizeOf(OSD value)
|
||||
{
|
||||
string sval;
|
||||
|
||||
if (ConvertOutputValue(value,out sval,true))
|
||||
return sval.Length;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -144,8 +144,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
|
|||
|
||||
int dsrv = (int)InvokeOp("JsonDestroyStore", fakeStoreId);
|
||||
|
||||
// XXX: Current returns 'true' even though no such store existed. Need to ask if this is best behaviour.
|
||||
Assert.That(dsrv, Is.EqualTo(1));
|
||||
Assert.That(dsrv, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -211,9 +210,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
|
|||
|
||||
// Test remove of non-existing value
|
||||
int fakeValueRemove = (int)InvokeOp("JsonRemoveValue", storeId, "Hello");
|
||||
|
||||
// XXX: Is this the best response to removing a value that isn't there?
|
||||
Assert.That(fakeValueRemove, Is.EqualTo(1));
|
||||
Assert.That(fakeValueRemove, Is.EqualTo(0));
|
||||
|
||||
// Test get from non-existing store
|
||||
UUID fakeStoreId = TestHelpers.ParseTail(0x500);
|
||||
|
|
Loading…
Reference in New Issue