diff --git a/src/common.js b/src/common.js index 0a7f3ea6c..65760abd3 100644 --- a/src/common.js +++ b/src/common.js @@ -51,7 +51,15 @@ common("any", { type: "bytes", id: 2 } - } + }/*, + options: Object.create({ + __fromObject: function(object) { + return this.fromObject(object); + }, + __toObject: function(options) { + return this.toObject(options); + } + })*/ } }); diff --git a/src/type.js b/src/type.js index 6cd75b66f..215609083 100644 --- a/src/type.js +++ b/src/type.js @@ -446,14 +446,18 @@ Type.prototype.setup = function setup() { types : types, util : util }); - this.fromObject = this.from = converter.fromObject(this).eof(fullName + "$fromObject", { + this.fromObject = converter.fromObject(this).eof(fullName + "$fromObject", { types : types, util : util }); + if (this.options && this.options.__formObject) + this.fromObject = this.options.__formObject.bind({ fromObject: this.fromObject }); this.toObject = converter.toObject(this).eof(fullName + "$toObject", { types : types, util : util }); + if (this.options && this.options.__toObject) + this.toObject = this.options.__toObject.bind({ toObject: this.toObject }); return this; };