Navigation Menu

Skip to content

Commit

Permalink
added i8 datatype support (64-bit integer) using floats due to V8 lim…
Browse files Browse the repository at this point in the history
…itation. closes baalexander#21
  • Loading branch information
Jorge Israel Peña committed Oct 21, 2011
1 parent 2b4edab commit 22c3534
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/xmlrpc-parser.js
@@ -1,6 +1,5 @@
var xmlParser = require('node-xml')
, dateFormatter = require('./date-formatter.js')

var xmlrpcParser = exports

/**
Expand Down Expand Up @@ -151,7 +150,7 @@ function deserializeParam(parser, callback) {

parser.onStartElementNS(function(element, attributes, prefix, uri, namespaces) {
// Checks if element is an XML-RPC data type
var flatParams = ['boolean', 'dateTime.iso8601', 'double', 'int', 'i4', 'string', 'nil']
var flatParams = ['boolean', 'dateTime.iso8601', 'double', 'int', 'i4', 'i8', 'string', 'nil']
var isFlatParam = ~flatParams.indexOf(element);

// A non-nested parameter. These simple values can be returned immediately.
Expand Down Expand Up @@ -183,6 +182,7 @@ function deserializeParam(parser, callback) {
param = dateFormatter.decodeIso8601(message)
break
case 'double':
case 'i8':
param = parseFloat(message)
break
case 'i4':
Expand Down
39 changes: 39 additions & 0 deletions test/xmlrpc-parser-test.js
Expand Up @@ -173,6 +173,19 @@ vows.describe('XML-RPC Parser').addBatch({
assert.strictEqual(value, 6)
}
}
, 'with a positive I8 param' : {
topic: function() {
var xml = '<methodResponse><params>'
+ '<param><value><i8>6</i8></value></param>'
+ '</params></methodResponse>'
xmlrpcParser.parseMethodResponse(null, xml, this.callback)
}
, 'contains the positive integer' : function (error, value) {
assert.isNull(error)
assert.isNumber(value)
assert.strictEqual(value, 6)
}
}
, 'with a negative Int param' : {
topic: function() {
var xml = '<methodResponse><params>'
Expand All @@ -199,6 +212,19 @@ vows.describe('XML-RPC Parser').addBatch({
assert.strictEqual(value, -26)
}
}
, 'with a negative I8 param' : {
topic: function() {
var xml = '<methodResponse><params>'
+ '<param><value><i8>-26</i8></value></param>'
+ '</params></methodResponse>'
xmlrpcParser.parseMethodResponse(null, xml, this.callback)
}
, 'contains the negative integer' : function (error, value) {
assert.isNull(error)
assert.isNumber(value)
assert.strictEqual(value, -26)
}
}
, 'with a Int param of 0' : {
topic: function() {
var xml = '<methodResponse><params>'
Expand All @@ -225,6 +251,19 @@ vows.describe('XML-RPC Parser').addBatch({
assert.deepEqual(value, 0)
}
}
, 'with a I8 param of 0' : {
topic: function() {
var xml = '<methodResponse><params>'
+ '<param><value><i8>0</i8></value></param>'
+ '</params></methodResponse>'
xmlrpcParser.parseMethodResponse(null, xml, this.callback)
}
, 'contains the value 0' : function (error, value) {
assert.isNull(error)
assert.isNumber(value)
assert.deepEqual(value, 0)
}
}
// Test String
, 'with a String param' : {
topic: function() {
Expand Down

0 comments on commit 22c3534

Please sign in to comment.