summaryrefslogtreecommitdiff
path: root/jsonrpc
diff options
context:
space:
mode:
Diffstat (limited to 'jsonrpc')
-rw-r--r--jsonrpc/json.esp4
-rw-r--r--jsonrpc/jsondate.esp21
-rw-r--r--jsonrpc/qooxdoo/test.esp8
-rw-r--r--jsonrpc/request.esp15
4 files changed, 25 insertions, 23 deletions
diff --git a/jsonrpc/json.esp b/jsonrpc/json.esp
index 32f0fa776a..8234ad7be3 100644
--- a/jsonrpc/json.esp
+++ b/jsonrpc/json.esp
@@ -112,6 +112,10 @@ function _encode(o)
}
buf = buf + "]";
}
+ else if (o["__type"] == "_JSON_Date")
+ {
+ buf = "" + o.encoding();
+ }
else
{
/* No length field, so it must be an ordinary object */
diff --git a/jsonrpc/jsondate.esp b/jsonrpc/jsondate.esp
index b2f2b9ec11..42418eaef2 100644
--- a/jsonrpc/jsondate.esp
+++ b/jsonrpc/jsondate.esp
@@ -16,6 +16,7 @@
function _JSON_Date_create(secondsSinceEpoch)
{
var o = new Object();
+ o.__type = "_JSON_Date";
function _setUtcDateTimeFields(year, month, day, hour, minute, second, millisecond)
{
@@ -137,7 +138,7 @@ function _JSON_Date_create(secondsSinceEpoch)
}
o.getUtcMillisecond = _getUtcMillisecond;
- function getEpochTime()
+ function _getEpochTime()
{
var tm = new Object();
tm.tm_sec = this.second;
@@ -151,8 +152,9 @@ function _JSON_Date_create(secondsSinceEpoch)
tm.isdst = 0;
return gmmktime(tm);
}
+ o.getEpochTime = _getEpochTime;
- function encoding()
+ function _encoding()
{
/* Encode the date in a well-documented fashion */
return sprintf("new Date(Date.UTC(%d,%d,%d,%d,%d,%d,%d))",
@@ -164,6 +166,7 @@ function _JSON_Date_create(secondsSinceEpoch)
this.second,
this.millisecond);
}
+ o.encoding = _encoding;
if (! secondsSinceEpoch)
{
@@ -174,13 +177,13 @@ function _JSON_Date_create(secondsSinceEpoch)
{
o.setEpochTime(secondsSinceEpoch);
}
- o.year = null;
- o.month = null;
- o.day = null;
- o.hour = null;
- o.minute = null;
- o.second = null;
- o.millisecond = null;
+ o.year = 0;
+ o.month = 0;
+ o.day = 0;
+ o.hour = 0;
+ o.minute = 0;
+ o.second = 0;
+ o.millisecond = 0;
return o;
}
diff --git a/jsonrpc/qooxdoo/test.esp b/jsonrpc/qooxdoo/test.esp
index 5fd893c217..03c2d824ba 100644
--- a/jsonrpc/qooxdoo/test.esp
+++ b/jsonrpc/qooxdoo/test.esp
@@ -31,7 +31,7 @@ function _echo(params, error)
{
if (params.length != 1)
{
- error.SetError(JsonRpcError_ParameterMismatch,
+ error.setError(JsonRpcError_ParameterMismatch,
"Expected 1 parameter; got " + params.length);
return error;
}
@@ -75,9 +75,9 @@ function _sleep(params, error)
{
if (params.length != 1)
{
- error.SetError(JsonRpcError_ParameterMismatch,
+ error.setError(JsonRpcError_ParameterMismatch,
"Expected 1 parameter; got " + params.length);
- return null;
+ return error;
}
sleep(params[0]);
@@ -222,7 +222,7 @@ jsonrpc.method.getCurrentTimestamp = _getCurrentTimestamp;
function _getError(params, error)
{
- error.SetError(23, "This is an application-provided error");
+ error.setError(23, "This is an application-provided error");
return error;
}
jsonrpc.method.getError = _getError;
diff --git a/jsonrpc/request.esp b/jsonrpc/request.esp
index 984ee4663e..5a1408df62 100644
--- a/jsonrpc/request.esp
+++ b/jsonrpc/request.esp
@@ -209,14 +209,14 @@ function _JsonRpcError_create(origin, code, message)
function _origin(origin)
{
- this.origin = origin;
+ this.data.origin = origin;
}
o.setOrigin = _origin;
function _setError(code, message)
{
- this.code = code;
- this.message = message;
+ this.data.code = code;
+ this.data.message = message;
}
o.setError = _setError;
@@ -236,7 +236,7 @@ function _JsonRpcError_create(origin, code, message)
{
var error = this;
var id = this.id;
- var ret = new Array(2);
+ var ret = new Object();
ret.error = this.data;
ret.id = this.id;
sendReply(Json.encode(ret), this.scriptTransportId);
@@ -444,12 +444,7 @@ error.setOrigin(jsonrpc.Constant.ErrorOrigin.Application);
var retval = method(jsonInput.params, error);
/* See if the result of the function was actually an error object */
-var wasError = (retval["__type"] != undefined);
-if (wasError)
-{
- wasError = retval.__type == "_JsonRpcError";
-}
-if (wasError)
+if (retval["__type"] == "_JsonRpcError")
{
/* Yup, it was. Return the error */
retval.Send();