Created
February 27, 2010 08:33
-
-
Save bentomas/316574 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From b3453495dec74897a36941c2b94f70861dd1deae Mon Sep 17 00:00:00 2001 | |
From: Benjamin Thomas <benjamin@benjaminthomas.org> | |
Date: Sat, 27 Feb 2010 08:32:55 +0000 | |
Subject: [PATCH] Stop sys.inspect from adding extra new lines for deep objects that are elements in an array. | |
A couple other small fixes: | |
If the keys of an object were all numeric they should be quoted. This | |
way, you can now hypothetically copy and paste the output into your code | |
(if the object doesn't contain any circular objects, deeply nested | |
objects, Dates, RegExps or functions. I think). | |
If a nested object isn't being recursed into, output "[Object]" as | |
opposed to "[object Object]". | |
If an object is longer than the max width but it is one line no matter | |
what, then don't put the closing brace on a new line. | |
Fix some formatting issues to try and match Node's style guidelines. | |
--- | |
lib/sys.js | 27 +++++++++++++++++++-------- | |
test/simple/test-sys.js | 6 +++--- | |
2 files changed, 22 insertions(+), 11 deletions(-) | |
diff --git a/lib/sys.js b/lib/sys.js | |
index 9c05342..17322e0 100644 | |
--- a/lib/sys.js | |
+++ b/lib/sys.js | |
@@ -95,11 +95,11 @@ exports.inspect = function (obj, showHidden, depth) { | |
return braces[0] + base + braces[1]; | |
} | |
- if( recurseTimes < 0 ) { | |
+ if (recurseTimes < 0) { | |
if (value instanceof RegExp) { | |
return '' + value; | |
} else { | |
- return "[object Object]"; | |
+ return "[Object]"; | |
} | |
} | |
@@ -129,10 +129,17 @@ exports.inspect = function (obj, showHidden, depth) { | |
else { | |
str = format(value[key], recurseTimes - 1); | |
} | |
- if( str.indexOf('\n') > -1 ) { | |
- str = '\n' + str.split('\n').map(function(line) { | |
+ if (str.indexOf('\n') > -1) { | |
+ if (value instanceof Array) { | |
+ str = str.split('\n').map(function(line) { | |
+ return ' ' + line; | |
+ }).join('\n').substr(2); | |
+ } | |
+ else { | |
+ str = '\n' + str.split('\n').map(function(line) { | |
return ' ' + line; | |
}).join('\n'); | |
+ } | |
} | |
} else { | |
str = '[Circular]'; | |
@@ -143,7 +150,7 @@ exports.inspect = function (obj, showHidden, depth) { | |
return str; | |
} | |
name = JSON.stringify('' + key); | |
- if( name.match(/^"([a-zA-Z_0-9]+)"$/) ) { | |
+ if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { | |
name = name.substr(1, name.length-2); | |
} | |
else { | |
@@ -154,13 +161,17 @@ exports.inspect = function (obj, showHidden, depth) { | |
return name + ": " + str; | |
}); | |
- | |
+ var numLinesEst = 0; | |
var length = output.reduce(function(prev, cur) { | |
+ numLinesEst++; | |
+ if( cur.indexOf('\n') >= 0 ) { | |
+ numLinesEst++; | |
+ } | |
return prev + cur.length + 1; | |
},0); | |
- if( length > 50 ) { | |
- output = braces[0] + (base === '' ? '' : base + '\n,') + ' ' + output.join('\n, ') + '\n' +braces[1]; | |
+ if (length > 50) { | |
+ output = braces[0] + (base === '' ? '' : base + '\n,') + ' ' + output.join('\n, ') + (numLinesEst > 1 ? '\n' : ' ') + braces[1]; | |
} | |
else { | |
output = braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; | |
diff --git a/test/simple/test-sys.js b/test/simple/test-sys.js | |
index 06fd694..d2b50a3 100644 | |
--- a/test/simple/test-sys.js | |
+++ b/test/simple/test-sys.js | |
@@ -26,11 +26,11 @@ assert.equal('{ a: [Function] }', inspect({a: function() {}})); | |
assert.equal('{ a: 1, b: 2 }', inspect({a: 1, b: 2})); | |
assert.equal('{ a: {} }', inspect({'a': {}})); | |
assert.equal('{ a: { b: 2 } }', inspect({'a': {'b': 2}})); | |
-assert.equal('{ a: { b: { c: [object Object] } } }', inspect({'a': {'b': { 'c': { 'd': 2 }}}})); | |
+assert.equal('{ a: { b: { c: [Object] } } }', inspect({'a': {'b': { 'c': { 'd': 2 }}}})); | |
assert.equal('{ a: { b: { c: { d: 2 } } } }', inspect({'a': {'b': { 'c': { 'd': 2 }}}}, false, null)); | |
assert.equal('[ 1, 2, 3, [length]: 3 ]', inspect([1,2,3], true)); | |
-assert.equal('{ a: [object Object] }', inspect({'a': {'b': { 'c': 2}}},false,0)); | |
-assert.equal('{ a: { b: [object Object] } }', inspect({'a': {'b': { 'c': 2}}},false,1)); | |
+assert.equal('{ a: [Object] }', inspect({'a': {'b': { 'c': 2}}},false,0)); | |
+assert.equal('{ a: { b: [Object] } }', inspect({'a': {'b': { 'c': 2}}},false,1)); | |
assert.equal("{ visible: 1 }", | |
inspect(Object.create({}, {visible:{value:1,enumerable:true},hidden:{value:2}})) | |
); | |
-- | |
1.6.3.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.constants = | |
[ [ 1, 'frameMethod' ] | |
, [ 2, 'frameHeader' ] | |
, [ 3, 'frameBody' ] | |
, [ 4, 'frameOobMethod' ] | |
, [ 5, 'frameOobHeader' ] | |
, [ 6, 'frameOobBody' ] | |
, [ 7, 'frameTrace' ] | |
, [ 8, 'frameHeartbeat' ] | |
, [ 200, 'replySuccess' ] | |
, [ 206, 'frameEnd' ] | |
, [ 310, 'notDelivered' ] | |
, [ 311, 'contentTooLarge' ] | |
, [ 320, 'connectionForced' ] | |
, [ 402, 'invalidPath' ] | |
, [ 403, 'accessRefused' ] | |
, [ 404, 'notFound' ] | |
, [ 405, 'resourceLocked' ] | |
, [ 501, 'frameError' ] | |
, [ 502, 'syntaxError' ] | |
, [ 503, 'commandInvalid' ] | |
, [ 504, 'channelError' ] | |
, [ 506, 'resourceError' ] | |
, [ 530, 'notAllowed' ] | |
, [ 540, 'notImplemented' ] | |
, [ 541, 'internalError' ] | |
, [ 4096, 'frameMinSize' ] | |
]; | |
exports.classes = | |
[ { name: 'connection' | |
, index: 10 | |
, fields: [] | |
, methods: | |
[ { name: 'start' | |
, index: 10 | |
, fields: | |
[ { name: 'versionMajor', domain: 'octet' } | |
, { name: 'versionMinor', domain: 'octet' } | |
, { name: 'serverProperties', domain: 'table' } | |
, { name: 'mechanisms', domain: 'longstr' } | |
, { name: 'locales', domain: 'longstr' } | |
] | |
} | |
, { name: 'startOk' | |
, index: 11 | |
, fields: | |
[ { name: 'clientProperties', domain: 'table' } | |
, { name: 'mechanism', domain: 'shortstr' } | |
, { name: 'response', domain: 'longstr' } | |
, { name: 'locale', domain: 'shortstr' } | |
] | |
} | |
, { name: 'secure' | |
, index: 20 | |
, fields: [ { name: 'challenge', domain: 'longstr' } ] | |
} | |
, { name: 'secureOk' | |
, index: 21 | |
, fields: [ { name: 'response', domain: 'longstr' } ] | |
} | |
, { name: 'tune' | |
, index: 30 | |
, fields: | |
[ { name: 'channelMax', domain: 'short' } | |
, { name: 'frameMax', domain: 'long' } | |
, { name: 'heartbeat', domain: 'short' } | |
] | |
} | |
, { name: 'tuneOk' | |
, index: 31 | |
, fields: | |
[ { name: 'channelMax', domain: 'short' } | |
, { name: 'frameMax', domain: 'long' } | |
, { name: 'heartbeat', domain: 'short' } | |
] | |
} | |
, { name: 'open' | |
, index: 40 | |
, fields: | |
[ { name: 'virtualHost', domain: 'shortstr' } | |
, { name: 'capabilities', domain: 'shortstr' } | |
, { name: 'insist', domain: 'bit' } | |
] | |
} | |
, { name: 'openOk' | |
, index: 41 | |
, fields: [ { name: 'knownHosts', domain: 'shortstr' } ] | |
} | |
, { name: 'redirect' | |
, index: 50 | |
, fields: | |
[ { name: 'host', domain: 'shortstr' } | |
, { name: 'knownHosts', domain: 'shortstr' } | |
] | |
} | |
, { name: 'close' | |
, index: 60 | |
, fields: | |
[ { name: 'replyCode', domain: 'short' } | |
, { name: 'replyText', domain: 'shortstr' } | |
, { name: 'classId', domain: 'short' } | |
, { name: 'methodId', domain: 'short' } | |
] | |
} | |
, { name: 'closeOk', index: 61, fields: [] } | |
] | |
} | |
, { name: 'channel' | |
, index: 20 | |
, fields: [] | |
, methods: | |
[ { name: 'open' | |
, index: 10 | |
, fields: [ { name: 'outOfBand', domain: 'shortstr' } ] | |
} | |
, { name: 'openOk', index: 11, fields: [] } | |
, { name: 'flow' | |
, index: 20 | |
, fields: [ { name: 'active', domain: 'bit' } ] | |
} | |
, { name: 'flowOk' | |
, index: 21 | |
, fields: [ { name: 'active', domain: 'bit' } ] | |
} | |
, { name: 'alert' | |
, index: 30 | |
, fields: | |
[ { name: 'replyCode', domain: 'short' } | |
, { name: 'replyText', domain: 'shortstr' } | |
, { name: 'details', domain: 'table' } | |
] | |
} | |
, { name: 'close' | |
, index: 40 | |
, fields: | |
[ { name: 'replyCode', domain: 'short' } | |
, { name: 'replyText', domain: 'shortstr' } | |
, { name: 'classId', domain: 'short' } | |
, { name: 'methodId', domain: 'short' } | |
] | |
} | |
, { name: 'closeOk', index: 41, fields: [] } | |
] | |
} | |
, { name: 'access' | |
, index: 30 | |
, fields: [] | |
, methods: | |
[ { name: 'request' | |
, index: 10 | |
, fields: | |
[ { name: 'realm', domain: 'shortstr' } | |
, { name: 'exclusive', domain: 'bit' } | |
, { name: 'passive', domain: 'bit' } | |
, { name: 'active', domain: 'bit' } | |
, { name: 'write', domain: 'bit' } | |
, { name: 'read', domain: 'bit' } | |
] | |
} | |
, { name: 'requestOk' | |
, index: 11 | |
, fields: [ { name: 'ticket', domain: 'short' } ] | |
} | |
] | |
} | |
, { name: 'exchange' | |
, index: 40 | |
, fields: [] | |
, methods: | |
[ { name: 'declare' | |
, index: 10 | |
, fields: | |
[ { name: 'ticket', domain: 'short' } | |
, { name: 'exchange', domain: 'shortstr' } | |
, { name: 'type', domain: 'shortstr' } | |
, { name: 'passive', domain: 'bit' } | |
, { name: 'durable', domain: 'bit' } | |
, { name: 'autoDelete', domain: 'bit' } | |
, { name: 'internal', domain: 'bit' } | |
, { name: 'nowait', domain: 'bit' } | |
, { name: 'arguments', domain: 'table' } | |
] | |
} | |
, { name: 'declareOk', index: 11, fields: [] } | |
, { name: 'delete' | |
, index: 20 | |
, fields: | |
[ { name: 'ticket', domain: 'short' } | |
, { name: 'exchange', domain: 'shortstr' } | |
, { name: 'ifUnused', domain: 'bit' } | |
, { name: 'nowait', domain: 'bit' } | |
] | |
} | |
, { name: 'deleteOk', index: 21, fields: [] } | |
] | |
} | |
, { name: 'queue' | |
, index: 50 | |
, fields: [] | |
, methods: | |
[ { name: 'declare' | |
, index: 10 | |
, fields: | |
[ { name: 'ticket', domain: 'short' } | |
, { name: 'queue', domain: 'shortstr' } | |
, { name: 'passive', domain: 'bit' } | |
, { name: 'durable', domain: 'bit' } | |
, { name: 'exclusive', domain: 'bit' } | |
, { name: 'autoDelete', domain: 'bit' } | |
, { name: 'nowait', domain: 'bit' } | |
, { name: 'arguments', domain: 'table' } | |
] | |
} | |
, { name: 'declareOk' | |
, index: 11 | |
, fields: | |
[ { name: 'queue', domain: 'shortstr' } | |
, { name: 'messageCount', domain: 'long' } | |
, { name: 'consumerCount', domain: 'long' } | |
] | |
} | |
, { name: 'bind' | |
, index: 20 | |
, fields: | |
[ { name: 'ticket', domain: 'short' } | |
, { name: 'queue', domain: 'shortstr' } | |
, { name: 'exchange', domain: 'shortstr' } | |
, { name: 'routingKey', domain: 'shortstr' } | |
, { name: 'nowait', domain: 'bit' } | |
, { name: 'arguments', domain: 'table' } | |
] | |
} | |
, { name: 'bindOk', index: 21, fields: [] } | |
, { name: 'purge' | |
, index: 30 | |
, fields: | |
[ { name: 'ticket', domain: 'short' } | |
, { name: 'queue', domain: 'shortstr' } | |
, { name: 'nowait', domain: 'bit' } | |
] | |
} | |
, { name: 'purgeOk' | |
, index: 31 | |
, fields: [ { name: 'messageCount', domain: 'long' } ] | |
} | |
, { name: 'delete' | |
, index: 40 | |
, fields: | |
[ { name: 'ticket', domain: 'short' } | |
, { name: 'queue', domain: 'shortstr' } | |
, { name: 'ifUnused', domain: 'bit' } | |
, { name: 'ifEmpty', domain: 'bit' } | |
, { name: 'nowait', domain: 'bit' } | |
] | |
} | |
, { name: 'deleteOk' | |
, index: 41 | |
, fields: [ { name: 'messageCount', domain: 'long' } ] | |
} | |
, { name: 'unbind' | |
, index: '50' | |
, fields: | |
[ { name: 'ticket', domain: 'short' } | |
, { name: 'queue', domain: 'shortstr' } | |
, { name: 'exchange', domain: 'shortstr' } | |
, { name: 'routing_key', domain: 'shortstr' } | |
, { name: 'arguments', domain: 'table' } | |
] | |
} | |
, { name: 'unbind-ok', index: '51', fields: [] } | |
] | |
} | |
, { name: 'basic' | |
, index: 60 | |
, fields: | |
[ { name: 'contentType', domain: 'shortstr' } | |
, { name: 'contentEncoding', domain: 'shortstr' } | |
, { name: 'headers', domain: 'table' } | |
, { name: 'deliveryMode', domain: 'octet' } | |
, { name: 'priority', domain: 'octet' } | |
, { name: 'correlationId', domain: 'shortstr' } | |
, { name: 'replyTo', domain: 'shortstr' } | |
, { name: 'expiration', domain: 'shortstr' } | |
, { name: 'messageId', domain: 'shortstr' } | |
, { name: 'timestamp', domain: 'timestamp' } | |
, { name: 'type', domain: 'shortstr' } | |
, { name: 'userId', domain: 'shortstr' } | |
, { name: 'appId', domain: 'shortstr' } | |
, { name: 'clusterId', domain: 'shortstr' } | |
] | |
, methods: | |
[ { name: 'qos' | |
, index: 10 | |
, fields: | |
[ { name: 'prefetchSize', domain: 'long' } | |
, { name: 'prefetchCount', domain: 'short' } | |
, { name: 'global', domain: 'bit' } | |
] | |
} | |
, { name: 'qosOk', index: 11, fields: [] } | |
, { name: 'consume' | |
, index: 20 | |
, fields: | |
[ { name: 'ticket', domain: 'short' } | |
, { name: 'queue', domain: 'shortstr' } | |
, { name: 'consumerTag', domain: 'shortstr' } | |
, { name: 'noLocal', domain: 'bit' } | |
, { name: 'noAck', domain: 'bit' } | |
, { name: 'exclusive', domain: 'bit' } | |
, { name: 'nowait', domain: 'bit' } | |
] | |
} | |
, { name: 'consumeOk' | |
, index: 21 | |
, fields: [ { name: 'consumerTag', domain: 'shortstr' } ] | |
} | |
, { name: 'cancel' | |
, index: 30 | |
, fields: | |
[ { name: 'consumerTag', domain: 'shortstr' } | |
, { name: 'nowait', domain: 'bit' } | |
] | |
} | |
, { name: 'cancelOk' | |
, index: 31 | |
, fields: [ { name: 'consumerTag', domain: 'shortstr' } ] | |
} | |
, { name: 'publish' | |
, index: 40 | |
, fields: | |
[ { name: 'ticket', domain: 'short' } | |
, { name: 'exchange', domain: 'shortstr' } | |
, { name: 'routingKey', domain: 'shortstr' } | |
, { name: 'mandatory', domain: 'bit' } | |
, { name: 'immediate', domain: 'bit' } | |
] | |
} | |
, { name: 'return' | |
, index: 50 | |
, fields: | |
[ { name: 'replyCode', domain: 'short' } | |
, { name: 'replyText', domain: 'shortstr' } | |
, { name: 'exchange', domain: 'shortstr' } | |
, { name: 'routingKey', domain: 'shortstr' } | |
] | |
} | |
, { name: 'deliver' | |
, index: 60 | |
, fields: | |
[ { name: 'consumerTag', domain: 'shortstr' } | |
, { name: 'deliveryTag', domain: 'longlong' } | |
, { name: 'redelivered', domain: 'bit' } | |
, { name: 'exchange', domain: 'shortstr' } | |
, { name: 'routingKey', domain: 'shortstr' } | |
] | |
} | |
, { name: 'get' | |
, index: 70 | |
, fields: | |
[ { name: 'ticket', domain: 'short' } | |
, { name: 'queue', domain: 'shortstr' } | |
, { name: 'noAck', domain: 'bit' } | |
] | |
} | |
, { name: 'getOk' | |
, index: 71 | |
, fields: | |
[ { name: 'deliveryTag', domain: 'longlong' } | |
, { name: 'redelivered', domain: 'bit' } | |
, { name: 'exchange', domain: 'shortstr' } | |
, { name: 'routingKey', domain: 'shortstr' } | |
, { name: 'messageCount', domain: 'long' } | |
] | |
} | |
, { name: 'getEmpty' | |
, index: 72 | |
, fields: [ { name: 'clusterId', domain: 'shortstr' } ] | |
} | |
, { name: 'ack' | |
, index: 80 | |
, fields: | |
[ { name: 'deliveryTag', domain: 'longlong' } | |
, { name: 'multiple', domain: 'bit' } | |
] | |
} | |
, { name: 'reject' | |
, index: 90 | |
, fields: | |
[ { name: 'deliveryTag', domain: 'longlong' } | |
, { name: 'requeue', domain: 'bit' } | |
] | |
} | |
, { name: 'recover' | |
, index: 100 | |
, fields: [ { name: 'requeue', domain: 'bit' } ] | |
} | |
] | |
} | |
, { name: 'file' | |
, index: 70 | |
, fields: | |
[ { name: 'contentType', domain: 'shortstr' } | |
, { name: 'contentEncoding', domain: 'shortstr' } | |
, { name: 'headers', domain: 'table' } | |
, { name: 'priority', domain: 'octet' } | |
, { name: 'replyTo', domain: 'shortstr' } | |
, { name: 'messageId', domain: 'shortstr' } | |
, { name: 'filename', domain: 'shortstr' } | |
, { name: 'timestamp', domain: 'timestamp' } | |
, { name: 'clusterId', domain: 'shortstr' } | |
] | |
, methods: | |
[ { name: 'qos' | |
, index: 10 | |
, fields: | |
[ { name: 'prefetchSize', domain: 'long' } | |
, { name: 'prefetchCount', domain: 'short' } | |
, { name: 'global', domain: 'bit' } | |
] | |
} | |
, { name: 'qosOk', index: 11, fields: [] } | |
, { name: 'consume' | |
, index: 20 | |
, fields: | |
[ { name: 'ticket', domain: 'short' } | |
, { name: 'queue', domain: 'shortstr' } | |
, { name: 'consumerTag', domain: 'shortstr' } | |
, { name: 'noLocal', domain: 'bit' } | |
, { name: 'noAck', domain: 'bit' } | |
, { name: 'exclusive', domain: 'bit' } | |
, { name: 'nowait', domain: 'bit' } | |
] | |
} | |
, { name: 'consumeOk' | |
, index: 21 | |
, fields: [ { name: 'consumerTag', domain: 'shortstr' } ] | |
} | |
, { name: 'cancel' | |
, index: 30 | |
, fields: | |
[ { name: 'consumerTag', domain: 'shortstr' } | |
, { name: 'nowait', domain: 'bit' } | |
] | |
} | |
, { name: 'cancelOk' | |
, index: 31 | |
, fields: [ { name: 'consumerTag', domain: 'shortstr' } ] | |
} | |
, { name: 'open' | |
, index: 40 | |
, fields: | |
[ { name: 'identifier', domain: 'shortstr' } | |
, { name: 'contentSize', domain: 'longlong' } | |
] | |
} | |
, { name: 'openOk' | |
, index: 41 | |
, fields: [ { name: 'stagedSize', domain: 'longlong' } ] | |
} | |
, { name: 'stage', index: 50, fields: [] } | |
, { name: 'publish' | |
, index: 60 | |
, fields: | |
[ { name: 'ticket', domain: 'short' } | |
, { name: 'exchange', domain: 'shortstr' } | |
, { name: 'routingKey', domain: 'shortstr' } | |
, { name: 'mandatory', domain: 'bit' } | |
, { name: 'immediate', domain: 'bit' } | |
, { name: 'identifier', domain: 'shortstr' } | |
] | |
} | |
, { name: 'return' | |
, index: 70 | |
, fields: | |
[ { name: 'replyCode', domain: 'short' } | |
, { name: 'replyText', domain: 'shortstr' } | |
, { name: 'exchange', domain: 'shortstr' } | |
, { name: 'routingKey', domain: 'shortstr' } | |
] | |
} | |
, { name: 'deliver' | |
, index: 80 | |
, fields: | |
[ { name: 'consumerTag', domain: 'shortstr' } | |
, { name: 'deliveryTag', domain: 'longlong' } | |
, { name: 'redelivered', domain: 'bit' } | |
, { name: 'exchange', domain: 'shortstr' } | |
, { name: 'routingKey', domain: 'shortstr' } | |
, { name: 'identifier', domain: 'shortstr' } | |
] | |
} | |
, { name: 'ack' | |
, index: 90 | |
, fields: | |
[ { name: 'deliveryTag', domain: 'longlong' } | |
, { name: 'multiple', domain: 'bit' } | |
] | |
} | |
, { name: 'reject' | |
, index: 100 | |
, fields: | |
[ { name: 'deliveryTag', domain: 'longlong' } | |
, { name: 'requeue', domain: 'bit' } | |
] | |
} | |
] | |
} | |
, { name: 'stream' | |
, index: 80 | |
, fields: | |
[ { name: 'contentType', domain: 'shortstr' } | |
, { name: 'contentEncoding', domain: 'shortstr' } | |
, { name: 'headers', domain: 'table' } | |
, { name: 'priority', domain: 'octet' } | |
, { name: 'timestamp', domain: 'timestamp' } | |
] | |
, methods: | |
[ { name: 'qos' | |
, index: 10 | |
, fields: | |
[ { name: 'prefetchSize', domain: 'long' } | |
, { name: 'prefetchCount', domain: 'short' } | |
, { name: 'consumeRate', domain: 'long' } | |
, { name: 'global', domain: 'bit' } | |
] | |
} | |
, { name: 'qosOk', index: 11, fields: [] } | |
, { name: 'consume' | |
, index: 20 | |
, fields: | |
[ { name: 'ticket', domain: 'short' } | |
, { name: 'queue', domain: 'shortstr' } | |
, { name: 'consumerTag', domain: 'shortstr' } | |
, { name: 'noLocal', domain: 'bit' } | |
, { name: 'exclusive', domain: 'bit' } | |
, { name: 'nowait', domain: 'bit' } | |
] | |
} | |
, { name: 'consumeOk' | |
, index: 21 | |
, fields: [ { name: 'consumerTag', domain: 'shortstr' } ] | |
} | |
, { name: 'cancel' | |
, index: 30 | |
, fields: | |
[ { name: 'consumerTag', domain: 'shortstr' } | |
, { name: 'nowait', domain: 'bit' } | |
] | |
} | |
, { name: 'cancelOk' | |
, index: 31 | |
, fields: [ { name: 'consumerTag', domain: 'shortstr' } ] | |
} | |
, { name: 'publish' | |
, index: 40 | |
, fields: | |
[ { name: 'ticket', domain: 'short' } | |
, { name: 'exchange', domain: 'shortstr' } | |
, { name: 'routingKey', domain: 'shortstr' } | |
, { name: 'mandatory', domain: 'bit' } | |
, { name: 'immediate', domain: 'bit' } | |
] | |
} | |
, { name: 'return' | |
, index: 50 | |
, fields: | |
[ { name: 'replyCode', domain: 'short' } | |
, { name: 'replyText', domain: 'shortstr' } | |
, { name: 'exchange', domain: 'shortstr' } | |
, { name: 'routingKey', domain: 'shortstr' } | |
] | |
} | |
, { name: 'deliver' | |
, index: 60 | |
, fields: | |
[ { name: 'consumerTag', domain: 'shortstr' } | |
, { name: 'deliveryTag', domain: 'longlong' } | |
, { name: 'exchange', domain: 'shortstr' } | |
, { name: 'queue', domain: 'shortstr' } | |
] | |
} | |
] | |
} | |
, { name: 'tx' | |
, index: 90 | |
, fields: [] | |
, methods: | |
[ { name: 'select', index: 10, fields: [] } | |
, { name: 'selectOk', index: 11, fields: [] } | |
, { name: 'commit', index: 20, fields: [] } | |
, { name: 'commitOk', index: 21, fields: [] } | |
, { name: 'rollback', index: 30, fields: [] } | |
, { name: 'rollbackOk', index: 31, fields: [] } | |
] | |
} | |
, { name: 'dtx' | |
, index: 100 | |
, fields: [] | |
, methods: | |
[ { name: 'select', index: 10, fields: [] } | |
, { name: 'selectOk', index: 11, fields: [] } | |
, { name: 'start' | |
, index: 20 | |
, fields: [ { name: 'dtxIdentifier', domain: 'shortstr' } ] | |
} | |
, { name: 'startOk', index: 21, fields: [] } | |
] | |
} | |
, { name: 'tunnel' | |
, index: 110 | |
, fields: | |
[ { name: 'headers', domain: 'table' } | |
, { name: 'proxyName', domain: 'shortstr' } | |
, { name: 'dataName', domain: 'shortstr' } | |
, { name: 'durable', domain: 'octet' } | |
, { name: 'broadcast', domain: 'octet' } | |
] | |
, methods: | |
[ { name: 'request' | |
, index: 10 | |
, fields: [ { name: 'metaData', domain: 'table' } ] | |
} | |
] | |
} | |
, { name: 'test' | |
, index: 120 | |
, fields: [] | |
, methods: | |
[ { name: 'integer' | |
, index: 10 | |
, fields: | |
[ { name: 'integer1', domain: 'octet' } | |
, { name: 'integer2', domain: 'short' } | |
, { name: 'integer3', domain: 'long' } | |
, { name: 'integer4', domain: 'longlong' } | |
, { name: 'operation', domain: 'octet' } | |
] | |
} | |
, { name: 'integerOk' | |
, index: 11 | |
, fields: [ { name: 'result', domain: 'longlong' } ] | |
} | |
, { name: 'string' | |
, index: 20 | |
, fields: | |
[ { name: 'string1', domain: 'shortstr' } | |
, { name: 'string2', domain: 'longstr' } | |
, { name: 'operation', domain: 'octet' } | |
] | |
} | |
, { name: 'stringOk' | |
, index: 21 | |
, fields: [ { name: 'result', domain: 'longstr' } ] | |
} | |
, { name: 'table' | |
, index: 30 | |
, fields: | |
[ { name: 'table', domain: 'table' } | |
, { name: 'integerOp', domain: 'octet' } | |
, { name: 'stringOp', domain: 'octet' } | |
] | |
} | |
, { name: 'tableOk' | |
, index: 31 | |
, fields: | |
[ { name: 'integerResult', domain: 'longlong' } | |
, { name: 'stringResult', domain: 'longstr' } | |
] | |
} | |
, { name: 'content', index: 40, fields: [] } | |
, { name: 'contentOk' | |
, index: 41 | |
, fields: [ { name: 'contentChecksum', domain: 'long' } ] | |
} | |
] | |
} | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constants = [[1,"frameMethod"],[2,"frameHeader"],[3,"frameBody"],[4,"frameOobMethod"],[5,"frameOobHeader"],[6,"frameOobBody"],[7,"frameTrace"],[8,"frameHeartbeat"],[200,"replySuccess"],[206,"frameEnd"],[310,"notDelivered"],[311,"contentTooLarge"],[320,"connectionForced"],[402,"invalidPath"],[403,"accessRefused"],[404,"notFound"],[405,"resourceLocked"],[501,"frameError"],[502,"syntaxError"],[503,"commandInvalid"],[504,"channelError"],[506,"resourceError"],[530,"notAllowed"],[540,"notImplemented"],[541,"internalError"],[4096,"frameMinSize"]]; | |
classes = [{"name":"connection","index":10,"fields":[],"methods":[{"name":"start","index":10,"fields":[{"name":"versionMajor","domain":"octet"},{"name":"versionMinor","domain":"octet"},{"name":"serverProperties","domain":"table"},{"name":"mechanisms","domain":"longstr"},{"name":"locales","domain":"longstr"}]},{"name":"startOk","index":11,"fields":[{"name":"clientProperties","domain":"table"},{"name":"mechanism","domain":"shortstr"},{"name":"response","domain":"longstr"},{"name":"locale","domain":"shortstr"}]},{"name":"secure","index":20,"fields":[{"name":"challenge","domain":"longstr"}]},{"name":"secureOk","index":21,"fields":[{"name":"response","domain":"longstr"}]},{"name":"tune","index":30,"fields":[{"name":"channelMax","domain":"short"},{"name":"frameMax","domain":"long"},{"name":"heartbeat","domain":"short"}]},{"name":"tuneOk","index":31,"fields":[{"name":"channelMax","domain":"short"},{"name":"frameMax","domain":"long"},{"name":"heartbeat","domain":"short"}]},{"name":"open","index":40,"fields":[{"name":"virtualHost","domain":"shortstr"},{"name":"capabilities","domain":"shortstr"},{"name":"insist","domain":"bit"}]},{"name":"openOk","index":41,"fields":[{"name":"knownHosts","domain":"shortstr"}]},{"name":"redirect","index":50,"fields":[{"name":"host","domain":"shortstr"},{"name":"knownHosts","domain":"shortstr"}]},{"name":"close","index":60,"fields":[{"name":"replyCode","domain":"short"},{"name":"replyText","domain":"shortstr"},{"name":"classId","domain":"short"},{"name":"methodId","domain":"short"}]},{"name":"closeOk","index":61,"fields":[]}]},{"name":"channel","index":20,"fields":[],"methods":[{"name":"open","index":10,"fields":[{"name":"outOfBand","domain":"shortstr"}]},{"name":"openOk","index":11,"fields":[]},{"name":"flow","index":20,"fields":[{"name":"active","domain":"bit"}]},{"name":"flowOk","index":21,"fields":[{"name":"active","domain":"bit"}]},{"name":"alert","index":30,"fields":[{"name":"replyCode","domain":"short"},{"name":"replyText","domain":"shortstr"},{"name":"details","domain":"table"}]},{"name":"close","index":40,"fields":[{"name":"replyCode","domain":"short"},{"name":"replyText","domain":"shortstr"},{"name":"classId","domain":"short"},{"name":"methodId","domain":"short"}]},{"name":"closeOk","index":41,"fields":[]}]},{"name":"access","index":30,"fields":[],"methods":[{"name":"request","index":10,"fields":[{"name":"realm","domain":"shortstr"},{"name":"exclusive","domain":"bit"},{"name":"passive","domain":"bit"},{"name":"active","domain":"bit"},{"name":"write","domain":"bit"},{"name":"read","domain":"bit"}]},{"name":"requestOk","index":11,"fields":[{"name":"ticket","domain":"short"}]}]},{"name":"exchange","index":40,"fields":[],"methods":[{"name":"declare","index":10,"fields":[{"name":"ticket","domain":"short"},{"name":"exchange","domain":"shortstr"},{"name":"type","domain":"shortstr"},{"name":"passive","domain":"bit"},{"name":"durable","domain":"bit"},{"name":"autoDelete","domain":"bit"},{"name":"internal","domain":"bit"},{"name":"nowait","domain":"bit"},{"name":"arguments","domain":"table"}]},{"name":"declareOk","index":11,"fields":[]},{"name":"delete","index":20,"fields":[{"name":"ticket","domain":"short"},{"name":"exchange","domain":"shortstr"},{"name":"ifUnused","domain":"bit"},{"name":"nowait","domain":"bit"}]},{"name":"deleteOk","index":21,"fields":[]}]},{"name":"queue","index":50,"fields":[],"methods":[{"name":"declare","index":10,"fields":[{"name":"ticket","domain":"short"},{"name":"queue","domain":"shortstr"},{"name":"passive","domain":"bit"},{"name":"durable","domain":"bit"},{"name":"exclusive","domain":"bit"},{"name":"autoDelete","domain":"bit"},{"name":"nowait","domain":"bit"},{"name":"arguments","domain":"table"}]},{"name":"declareOk","index":11,"fields":[{"name":"queue","domain":"shortstr"},{"name":"messageCount","domain":"long"},{"name":"consumerCount","domain":"long"}]},{"name":"bind","index":20,"fields":[{"name":"ticket","domain":"short"},{"name":"queue","domain":"shortstr"},{"name":"exchange","domain":"shortstr"},{"name":"routingKey","domain":"shortstr"},{"name":"nowait","domain":"bit"},{"name":"arguments","domain":"table"}]},{"name":"bindOk","index":21,"fields":[]},{"name":"purge","index":30,"fields":[{"name":"ticket","domain":"short"},{"name":"queue","domain":"shortstr"},{"name":"nowait","domain":"bit"}]},{"name":"purgeOk","index":31,"fields":[{"name":"messageCount","domain":"long"}]},{"name":"delete","index":40,"fields":[{"name":"ticket","domain":"short"},{"name":"queue","domain":"shortstr"},{"name":"ifUnused","domain":"bit"},{"name":"ifEmpty","domain":"bit"},{"name":"nowait","domain":"bit"}]},{"name":"deleteOk","index":41,"fields":[{"name":"messageCount","domain":"long"}]},{"name":"unbind","index":"50","fields":[{"name":"ticket","domain":"short"},{"name":"queue","domain":"shortstr"},{"name":"exchange","domain":"shortstr"},{"name":"routing_key","domain":"shortstr"},{"name":"arguments","domain":"table"}]},{"name":"unbind-ok","index":"51","fields":[]}]},{"name":"basic","index":60,"fields":[{"name":"contentType","domain":"shortstr"},{"name":"contentEncoding","domain":"shortstr"},{"name":"headers","domain":"table"},{"name":"deliveryMode","domain":"octet"},{"name":"priority","domain":"octet"},{"name":"correlationId","domain":"shortstr"},{"name":"replyTo","domain":"shortstr"},{"name":"expiration","domain":"shortstr"},{"name":"messageId","domain":"shortstr"},{"name":"timestamp","domain":"timestamp"},{"name":"type","domain":"shortstr"},{"name":"userId","domain":"shortstr"},{"name":"appId","domain":"shortstr"},{"name":"clusterId","domain":"shortstr"}],"methods":[{"name":"qos","index":10,"fields":[{"name":"prefetchSize","domain":"long"},{"name":"prefetchCount","domain":"short"},{"name":"global","domain":"bit"}]},{"name":"qosOk","index":11,"fields":[]},{"name":"consume","index":20,"fields":[{"name":"ticket","domain":"short"},{"name":"queue","domain":"shortstr"},{"name":"consumerTag","domain":"shortstr"},{"name":"noLocal","domain":"bit"},{"name":"noAck","domain":"bit"},{"name":"exclusive","domain":"bit"},{"name":"nowait","domain":"bit"}]},{"name":"consumeOk","index":21,"fields":[{"name":"consumerTag","domain":"shortstr"}]},{"name":"cancel","index":30,"fields":[{"name":"consumerTag","domain":"shortstr"},{"name":"nowait","domain":"bit"}]},{"name":"cancelOk","index":31,"fields":[{"name":"consumerTag","domain":"shortstr"}]},{"name":"publish","index":40,"fields":[{"name":"ticket","domain":"short"},{"name":"exchange","domain":"shortstr"},{"name":"routingKey","domain":"shortstr"},{"name":"mandatory","domain":"bit"},{"name":"immediate","domain":"bit"}]},{"name":"return","index":50,"fields":[{"name":"replyCode","domain":"short"},{"name":"replyText","domain":"shortstr"},{"name":"exchange","domain":"shortstr"},{"name":"routingKey","domain":"shortstr"}]},{"name":"deliver","index":60,"fields":[{"name":"consumerTag","domain":"shortstr"},{"name":"deliveryTag","domain":"longlong"},{"name":"redelivered","domain":"bit"},{"name":"exchange","domain":"shortstr"},{"name":"routingKey","domain":"shortstr"}]},{"name":"get","index":70,"fields":[{"name":"ticket","domain":"short"},{"name":"queue","domain":"shortstr"},{"name":"noAck","domain":"bit"}]},{"name":"getOk","index":71,"fields":[{"name":"deliveryTag","domain":"longlong"},{"name":"redelivered","domain":"bit"},{"name":"exchange","domain":"shortstr"},{"name":"routingKey","domain":"shortstr"},{"name":"messageCount","domain":"long"}]},{"name":"getEmpty","index":72,"fields":[{"name":"clusterId","domain":"shortstr"}]},{"name":"ack","index":80,"fields":[{"name":"deliveryTag","domain":"longlong"},{"name":"multiple","domain":"bit"}]},{"name":"reject","index":90,"fields":[{"name":"deliveryTag","domain":"longlong"},{"name":"requeue","domain":"bit"}]},{"name":"recover","index":100,"fields":[{"name":"requeue","domain":"bit"}]}]},{"name":"file","index":70,"fields":[{"name":"contentType","domain":"shortstr"},{"name":"contentEncoding","domain":"shortstr"},{"name":"headers","domain":"table"},{"name":"priority","domain":"octet"},{"name":"replyTo","domain":"shortstr"},{"name":"messageId","domain":"shortstr"},{"name":"filename","domain":"shortstr"},{"name":"timestamp","domain":"timestamp"},{"name":"clusterId","domain":"shortstr"}],"methods":[{"name":"qos","index":10,"fields":[{"name":"prefetchSize","domain":"long"},{"name":"prefetchCount","domain":"short"},{"name":"global","domain":"bit"}]},{"name":"qosOk","index":11,"fields":[]},{"name":"consume","index":20,"fields":[{"name":"ticket","domain":"short"},{"name":"queue","domain":"shortstr"},{"name":"consumerTag","domain":"shortstr"},{"name":"noLocal","domain":"bit"},{"name":"noAck","domain":"bit"},{"name":"exclusive","domain":"bit"},{"name":"nowait","domain":"bit"}]},{"name":"consumeOk","index":21,"fields":[{"name":"consumerTag","domain":"shortstr"}]},{"name":"cancel","index":30,"fields":[{"name":"consumerTag","domain":"shortstr"},{"name":"nowait","domain":"bit"}]},{"name":"cancelOk","index":31,"fields":[{"name":"consumerTag","domain":"shortstr"}]},{"name":"open","index":40,"fields":[{"name":"identifier","domain":"shortstr"},{"name":"contentSize","domain":"longlong"}]},{"name":"openOk","index":41,"fields":[{"name":"stagedSize","domain":"longlong"}]},{"name":"stage","index":50,"fields":[]},{"name":"publish","index":60,"fields":[{"name":"ticket","domain":"short"},{"name":"exchange","domain":"shortstr"},{"name":"routingKey","domain":"shortstr"},{"name":"mandatory","domain":"bit"},{"name":"immediate","domain":"bit"},{"name":"identifier","domain":"shortstr"}]},{"name":"return","index":70,"fields":[{"name":"replyCode","domain":"short"},{"name":"replyText","domain":"shortstr"},{"name":"exchange","domain":"shortstr"},{"name":"routingKey","domain":"shortstr"}]},{"name":"deliver","index":80,"fields":[{"name":"consumerTag","domain":"shortstr"},{"name":"deliveryTag","domain":"longlong"},{"name":"redelivered","domain":"bit"},{"name":"exchange","domain":"shortstr"},{"name":"routingKey","domain":"shortstr"},{"name":"identifier","domain":"shortstr"}]},{"name":"ack","index":90,"fields":[{"name":"deliveryTag","domain":"longlong"},{"name":"multiple","domain":"bit"}]},{"name":"reject","index":100,"fields":[{"name":"deliveryTag","domain":"longlong"},{"name":"requeue","domain":"bit"}]}]},{"name":"stream","index":80,"fields":[{"name":"contentType","domain":"shortstr"},{"name":"contentEncoding","domain":"shortstr"},{"name":"headers","domain":"table"},{"name":"priority","domain":"octet"},{"name":"timestamp","domain":"timestamp"}],"methods":[{"name":"qos","index":10,"fields":[{"name":"prefetchSize","domain":"long"},{"name":"prefetchCount","domain":"short"},{"name":"consumeRate","domain":"long"},{"name":"global","domain":"bit"}]},{"name":"qosOk","index":11,"fields":[]},{"name":"consume","index":20,"fields":[{"name":"ticket","domain":"short"},{"name":"queue","domain":"shortstr"},{"name":"consumerTag","domain":"shortstr"},{"name":"noLocal","domain":"bit"},{"name":"exclusive","domain":"bit"},{"name":"nowait","domain":"bit"}]},{"name":"consumeOk","index":21,"fields":[{"name":"consumerTag","domain":"shortstr"}]},{"name":"cancel","index":30,"fields":[{"name":"consumerTag","domain":"shortstr"},{"name":"nowait","domain":"bit"}]},{"name":"cancelOk","index":31,"fields":[{"name":"consumerTag","domain":"shortstr"}]},{"name":"publish","index":40,"fields":[{"name":"ticket","domain":"short"},{"name":"exchange","domain":"shortstr"},{"name":"routingKey","domain":"shortstr"},{"name":"mandatory","domain":"bit"},{"name":"immediate","domain":"bit"}]},{"name":"return","index":50,"fields":[{"name":"replyCode","domain":"short"},{"name":"replyText","domain":"shortstr"},{"name":"exchange","domain":"shortstr"},{"name":"routingKey","domain":"shortstr"}]},{"name":"deliver","index":60,"fields":[{"name":"consumerTag","domain":"shortstr"},{"name":"deliveryTag","domain":"longlong"},{"name":"exchange","domain":"shortstr"},{"name":"queue","domain":"shortstr"}]}]},{"name":"tx","index":90,"fields":[],"methods":[{"name":"select","index":10,"fields":[]},{"name":"selectOk","index":11,"fields":[]},{"name":"commit","index":20,"fields":[]},{"name":"commitOk","index":21,"fields":[]},{"name":"rollback","index":30,"fields":[]},{"name":"rollbackOk","index":31,"fields":[]}]},{"name":"dtx","index":100,"fields":[],"methods":[{"name":"select","index":10,"fields":[]},{"name":"selectOk","index":11,"fields":[]},{"name":"start","index":20,"fields":[{"name":"dtxIdentifier","domain":"shortstr"}]},{"name":"startOk","index":21,"fields":[]}]},{"name":"tunnel","index":110,"fields":[{"name":"headers","domain":"table"},{"name":"proxyName","domain":"shortstr"},{"name":"dataName","domain":"shortstr"},{"name":"durable","domain":"octet"},{"name":"broadcast","domain":"octet"}],"methods":[{"name":"request","index":10,"fields":[{"name":"metaData","domain":"table"}]}]},{"name":"test","index":120,"fields":[],"methods":[{"name":"integer","index":10,"fields":[{"name":"integer1","domain":"octet"},{"name":"integer2","domain":"short"},{"name":"integer3","domain":"long"},{"name":"integer4","domain":"longlong"},{"name":"operation","domain":"octet"}]},{"name":"integerOk","index":11,"fields":[{"name":"result","domain":"longlong"}]},{"name":"string","index":20,"fields":[{"name":"string1","domain":"shortstr"},{"name":"string2","domain":"longstr"},{"name":"operation","domain":"octet"}]},{"name":"stringOk","index":21,"fields":[{"name":"result","domain":"longstr"}]},{"name":"table","index":30,"fields":[{"name":"table","domain":"table"},{"name":"integerOp","domain":"octet"},{"name":"stringOp","domain":"octet"}]},{"name":"tableOk","index":31,"fields":[{"name":"integerResult","domain":"longlong"},{"name":"stringResult","domain":"longstr"}]},{"name":"content","index":40,"fields":[]},{"name":"contentOk","index":41,"fields":[{"name":"contentChecksum","domain":"long"}]}]}]; | |
sys=require('sys'); | |
sys.puts('exports.constants = \n' + sys.inspect(constants, false, null) + ';\n\n'); | |
sys.puts('exports.classes = \n' + sys.inspect(classes, false, null) + ';'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment