Skip to content
Browse files

Move Int64 and Uint64 to genesis

  • Loading branch information...
1 parent 23357d1 commit bfd38fb0525d74a216178db3942b627be8ba3bee @Benvie committed Mar 23, 2012
Showing with 7 additions and 19 deletions.
  1. +7 −8 lib/genesis.js
  2. +0 −11 lib/numeric.js
View
15 lib/genesis.js
@@ -3,7 +3,6 @@
var DataBuffer = require('./buffer');
var utility = require('./utility');
var isObject = utility.isObject;
-var inspectors = utility.inspectors;
var EventEmitter = require('events').EventEmitter;
var hasProto = !!Function.__proto__;
@@ -86,17 +85,17 @@ function Type(ctor, proto){
copy(Type, ctor.prototype);
}
ctor.prototype.Type = ctor.name;
- ctor.prototype.constructor = ctor,
- ctor.prototype.inspect = inspectors('Type', ctor.name);
- proto.inspect = inspectors('Data', ctor.name);
+ ctor.prototype.constructor = ctor;
+ if (typeof imports === 'undefined') {
+ ctor.prototype.inspect = require('./inspect')('Type', ctor.name);
+ proto.inspect = require('./inspect')('Data', ctor.name);
+ }
ctor.prototype.prototype = copy(proto, Object.create(Data));
}
-//Type.__proto__ = EventEmitter.prototype;
-
copy({
Class: 'Type',
- toString: function toString(){ return '[object Type]' },
+ toString: function toString(){ return '[object '+this.name+'Type]' },
array: function array(n){ return new (require('./array'))(this, n) },
isInstance: function isInstance(o){ return this.prototype.isPrototypeOf(o) },
}, Type);
@@ -143,7 +142,7 @@ function Subtype(name, bytes, ctor){
var Data = Type.prototype = {
__proto__: EventEmitter.prototype,
Class: 'Data',
- toString: function toString(){ return '[object Data]' },
+ toString: function toString(){ return '[object '+this.constructor.name+'Data]' },
rebase: function rebase(data){
if (data == null) {
data = new DataBuffer(this.bytes);
View
11 lib/numeric.js
@@ -115,14 +115,3 @@ genesis.Type(NumericType, {
Object.keys(types).forEach(function(name){
NumericType[name] = new NumericType(name, types[name]);
});
-
-var ArrayType = require('./array');
-
-NumericType.Uint64 = new ArrayType('Uint64', 'Uint32', 2);
-NumericType.Int64 = new ArrayType('Int64', 'Int32', 2);
-
-var OctetString = new ArrayType('EightByteOctetString', 'Uint8', 8);
-
-function octets(){ return new OctetString(this._data, this._offset) }
-NumericType.Uint64.prototype.octets = octets;
-NumericType.Int64.prototype.octets = octets;

0 comments on commit bfd38fb

Please sign in to comment.
Something went wrong with that request. Please try again.