[banshee] [JavaScriptCore] Modify JSValue.ToString behavior
- From: Aaron Bockover <abock src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [JavaScriptCore] Modify JSValue.ToString behavior
- Date: Mon, 25 Oct 2010 19:12:28 +0000 (UTC)
commit 5bacc455c02042b5ca665c6f30e4fc494d8ee6fe
Author: Aaron Bockover <abockover novell com>
Date: Mon Oct 25 13:22:47 2010 -0400
[JavaScriptCore] Modify JSValue.ToString behavior
Only call ToJsonString if the value is an object that is not
a function; otherwise return the StringValue, which works better
for function objects.
.../Ossifer.JavaScriptCore/JSValue.cs | 6 +++---
.../Ossifer.JavaScriptCore/Tests/JSValueTests.cs | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/src/Core/Banshee.WebBrowser/Ossifer.JavaScriptCore/JSValue.cs b/src/Core/Banshee.WebBrowser/Ossifer.JavaScriptCore/JSValue.cs
index 8bf3342..a684c6f 100644
--- a/src/Core/Banshee.WebBrowser/Ossifer.JavaScriptCore/JSValue.cs
+++ b/src/Core/Banshee.WebBrowser/Ossifer.JavaScriptCore/JSValue.cs
@@ -31,7 +31,7 @@ namespace Ossifer.JavaScriptCore
{
public class JSValue
{
- public IntPtr Raw { get; private set; }
+ public IntPtr Raw { get; protected set; }
public JSContext Context { get; private set; }
public JSValue (IntPtr raw)
@@ -254,7 +254,7 @@ namespace Ossifer.JavaScriptCore
public string ToJsonString ()
{
- return ToJsonString (0);
+ return ToJsonString (2);
}
[DllImport (JSContext.NATIVE_IMPORT)]
@@ -275,7 +275,7 @@ namespace Ossifer.JavaScriptCore
public override string ToString ()
{
- return ToJsonString (2);
+ return IsObject ? ToJsonString (0) ?? StringValue : StringValue;
}
}
}
diff --git a/src/Core/Banshee.WebBrowser/Ossifer.JavaScriptCore/Tests/JSValueTests.cs b/src/Core/Banshee.WebBrowser/Ossifer.JavaScriptCore/Tests/JSValueTests.cs
index 78f5a5a..16f60c7 100644
--- a/src/Core/Banshee.WebBrowser/Ossifer.JavaScriptCore/Tests/JSValueTests.cs
+++ b/src/Core/Banshee.WebBrowser/Ossifer.JavaScriptCore/Tests/JSValueTests.cs
@@ -230,7 +230,7 @@ namespace Ossifer.JavaScriptCore.Tests
[Test]
public void JsonRoundTrip ()
{
- Assert.AreEqual ("[1,2,3]", JSValue.FromJson (context, "[1,2,3]").ToJsonString ());
+ Assert.AreEqual ("[1,2,3]", JSValue.FromJson (context, "[1,2,3]").ToJsonString (0));
Assert.AreEqual ("{\n \"x\": 4,\n \"y\": \"z\"\n}",
JSValue.FromJson (context, "{\"x\":4,\"y\":\"z\"}").ToJsonString (2));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]