Skip to content
Browse files

browser version again

  • Loading branch information...
1 parent 74730dd commit b0cbbe5113dc3ad46dc4b08b6bfc894134275a75 @Benvie committed Apr 8, 2012
Showing with 9 additions and 15 deletions.
  1. +8 −14 reified-browser.js
  2. +1 −1 reified-browser.min.js
View
22 reified-browser.js
@@ -416,6 +416,10 @@ copy({
}
return iface;
},
+ initializer: function initializer(handler){
+ this.prototype.init = handler;
+ return this;
+ },
reifier: function reifier(handler){
var oldReifier = this.prototype.reify;
if (!handler) {
@@ -464,7 +468,7 @@ function createInterface(name, ctor, type){
var count = name.match(/^[*]+/)[0].length;
fnName = Array(count + 1).join('Ptr_') + fnName;
}
- var src = 'return function '+fnName+'(data, offset, values){ return Ctor.call(Object.create('+fnName+'.prototype), data, offset, values) }';
+ var src = 'return function '+fnName+'(data, offset, values){ return Ctor.call(Object.create('+fnName+'.prototype), data, offset, values).init() }';
var iface = Function('Ctor', src)(ctor);
ifaceMap.set(iface, ctor);
@@ -1232,12 +1236,7 @@ var PointerSubtype = genesis.Subtype.bind(PointerType);
module.exports = PointerType;
-
-
-var AbsoluteAddress = numeric.Uint32.typeDef('AbsoluteAddress');
-var RelativeAddress = numeric.Uint32.typeDef('RelativeAddress', function(reify){
- return this._offset.view.byteOffset - this._offset + +reify();
-});
+var Address = numeric.Uint32.typeDef('Address');
// ###############################
@@ -1258,13 +1257,9 @@ function PointerType(name, pointeeType, addressType){
}
if (typeof addressType === 'string') {
- switch (addressType ){
- case 'absolute': addressType = AbsoluteAddress; break;
- case 'relative': addressType = RelativeAddress; break;
- default: addressType = genesis.lookupType(addressType);
- }
+ addressType = genesis.lookupType(addressType);
} else if (typeof addressType === 'undefined') {
- addressType = AbsoluteAddress;
+ addressType = Address;
}
name = '*'+name;
@@ -1346,7 +1341,6 @@ function initPointee(target, Type, pointee){
}
-
// ########################
// ### PointerType Data ###
// ########################
View
2 reified-browser.min.js
@@ -1 +1 @@
-var reified=function(global,imports){return!function(a,b){function c(a){return Object(a)===a}function d(a){return Math.log(a)/Math.LN2}function e(a){return(d(a)/8|0)+1}function f(a,b){var c=Array((b||2)+1).join(" ");return a.split("\n").map(function(a){return c+a}).join("\n")}function g(a,b){return b-=h(a||"")+1,a+Array(b>1?b:1).join(" ")}function h(a){return a.replace(/\033\[(?:\d+;)*\d+m/g,"").length}function i(a){if(!Array.isArray(a)){if(!c(a))throw new TypeError("Max length called on non-object "+a);a=Object.keys(a)}return a.reduce(function(a,b){return Math.max(a,h(""+b))},0)}function j(a){return Object.keys(a.reduce(function(a,b){return a[b]=1,a},{}))}imports["./utility"]={},Object.defineProperty(a,"exports",{get:function(){return imports["./utility"]},set:function(a){imports["./utility"]=a}}),"use strict",a.exports={isObject:c,bytes:e,bits:d,indent:f,pad:g,maxLength:i,unique:j,strlen:h}}({},function(a){return imports[a]}),!function(a,b){function f(a){return a instanceof ArrayBuffer||!!(a&&a.constructor&&a.constructor.name in e)}function g(a,b,c){if(!g.prototype.isPrototypeOf(this))return new g(a,b,c);if(!a)throw new Error("Tried to initialize with no usable length or subject");f(a)&&(this.array=a);if(a){if(a.buffer){b=(a.offset||a.byteOffset||0)+(b||0);while(a.buffer)a=a.buffer}typeof b=="undefined"&&(b=a.offset||a.byteOffset),typeof c=="undefined"&&(c=a.length||a.byteLength)}typeof a=="number"?this.view=new DataView(new d(a)):d.isBuffer(a)?this.view=new DataView(a,b,c):a instanceof DataView?this.view=new DataView(a.buffer,b,c):g.isDataBuffer(a)&&(this.view=new DataView(a.buffer,a.offset+b,c||a.length)),this.length=this.view.byteLength,this.buffer=this.view.buffer,this.offset=this.view.byteOffset}function h(a){return isFinite(a)?+a:0}function i(a){if(isFinite(a))return+a}function j(a){return a>>>0&255}imports["./buffer"]={},Object.defineProperty(a,"exports",{get:function(){return imports["./buffer"]},set:function(a){imports["./buffer"]=a}}),"use strict",a.exports=g;var c=["Int8","Int16","Int32","Uint8","Uint16","Uint32","Float32","Float64"],d=function(a){function b(a,b,c){return new ArrayBuffer(a,b,c)}return"Buffer"in a?a.Buffer:(b.isBuffer=function(a){return a instanceof ArrayBuffer},b)}(Function("return this")()),e={ArrayBuffer:ArrayBuffer};g.isBuffer=d.isBuffer,g.isDataBuffer=function(a){return g.prototype.isPrototypeOf(a)},g.prototype={constructor:g,endianness:"LE",subarray:function(a,b){return a=h(a),b=i(b),new g(this.view,a,b)},typed:function(a,b,c){return a=e[a+"Array"],arguments.length===1?new a(this.view):arguments.length===2?new a(this.view,h(b)):(c=h(c)||this.length/a.BYTES_PER_ELEMENT|0,new a(this.view,h(b),c))},copy:function(a,b,c,e){isFinite(a)&&(e=c,c=b,b=a,a=null),b=h(b),c=h(c),e=e?+e:this.length-1;if(c>e)throw new Error("End less than start");if(c<0)throw new RangeError("Start less than zero");if(e>=this.length)throw new RangeError("End greater than length");var f=e-c;a?b+f>a.length&&(f=a.length):a=new d(f),a=(new g(a,b,f)).typed("Uint8");var i=this.subarray(c,e).typed("Uint8");for(var j=0;j<f;j++)a[j]=i[j];return a},clone:function(){var a=new g(new d(this.length));for(var b=0;b<this.length;b++)a.writeUint8(b,this.readUint8(b));return a},fill:function(a){a=h(a);var b=this.typed("Uint8");for(var c=0;c<this.length;c++)b[c]=a},write:function(a,b,c){c=isFinite(c)?+c:a.length,b=isFinite(b)?+b:0,c=Math.min(this.length,c+b,a.length);var d=this.subarray(b,b.length).typed("Uint8");for(var e=0;e<c;e++)d[e]=a[e];return this},map:function(){return[].map.apply(this.typed("Uint8"),arguments)},slice:function(a,b,c){return this.subarray(a,b).toString(c||"ascii")},toArray:function(a){return[].map.call(this.typed(a||"Uint8"),function(a){return a})},toString:function(a){switch(a){case"ascii":return this.map(function(a){return String.fromCharCode(a)}).join("");default:return this.map(function(a){return("000"+a.toString(10)).slice(-3)}).join(" ").split(/((?:\d\d\d ?){10}(?: ))/).filter(Boolean).map(Function.call.bind("".trim)).join("\n")}}},c.forEach(function(a){e[a+"Array"]=global[a+"Array"],g.prototype["read"+a]=function(b){return this.view["get"+a](h(b),this.endianness==="LE")},g.prototype["write"+a]=function(b,c){return this.view["set"+a](h(b),h(c),this.endianness==="LE")}}),Array.apply(null,Array(20)).forEach(function(a,b){Object.defineProperty(g.prototype,b,{configurable:!0,get:function(){return this.readUint8(b)},set:function(a){return this.writeUint8(b,a)}})})}({},function(a){return imports[a]}),!function(module,require){function isBuffer(a){return exp.DataBuffer.isBuffer(a)||exp.DataBuffer.isDataBuffer(a)}function api(a,b,c){Object(b)===b?Object.keys(b).forEach(function(c){api(a,c,b[c])}):(hidden.value=c,Object.defineProperty(a,b,hidden))}function registerType(a,b){return a in types?types[a]:a.length?types[a]=b:b}function lookupType(a,b){if(typeof a!="string")return a;if(a[0]==="*"){a=a.slice(1);var c=lookupType(a);if(typeof c!="string")return typeof b=="string"&&(a=b),createType("pointer",a,c)}if(a[a.length-1]==="]"){var d=a.match(/(.*)\[(\d+)\]$/);if(!d)return a in types?types[a]:a;a=d[1],d=+d[2];if(a==="Char")return createType("string",d);if(typeof b=="string")return createType("array",b,lookupType(a),d);if(c==="Char")return createType("string",d);var c=lookupType(a);return c===a?createType("array",a,d):(a=c.name+"x"+d,createType("array",a,c,d))}return a in types?types[a]:a}function createType(a,b,c,d){var e=require("./"+a);return new e(b,c,d)}function Type(ctor,proto){ctor.prototype=Super(eval("(function Empty"+ctor.name.replace(/Type$/,"T")+"(){})"),Type),ctor.prototype.Type=ctor.name,ctor.prototype.prototype=copy(proto,Object.create(Data)),types[ctor.name.replace(/Type$/,"")]=ctor,inspectors(ctor.prototype,ctor.name)}function Super(a,b,c){return hasProto?a.__proto__=b:copy(b,a),a.prototype=c||Object.create(b.prototype),a.prototype.constructor=a,a}function inspectors(a,b){typeof imports=="undefined"&&(a.inspect=require("./inspect")("Type",b),a.prototype.inspect=require("./inspect")("Data",b))}function createInterface(a,b,c){var d=a.replace(/[^\w0-9_$]/g,"");if(a[0]==="*"){var e=a.match(/^[*]+/)[0].length;d=Array(e+1).join("Ptr_")+d}var f="return function "+d+"(data, offset, values){ return Ctor.call(Object.create("+d+".prototype), data, offset, values) }",g=Function("Ctor",f)(b);return ifaceMap.set(g,b),c&&(hasProto?g.__proto__=c.prototype:copy(c.prototype,g)),g.prototype=b.prototype,api(g,"displayName",a),a&&registerType(a,g),copy(b,g)}function Subtype(a,b,c){return c.bytes=b,c.prototype.bytes=b,c.prototype=copy(c.prototype,Object.create(this.prototype.prototype)),c.prototype.constructor=createInterface(a,c,this)}function Opaque(a,b,c){if(isFinite(a)){c=a,a=null;if(!isFinite(c))throw new Error("Opaque types must be given a size or buffer")}return this.bytes=c||0,this.rebase(a),api(this,"_offset",+b||0),this}function OpaqueType(a){function b(b,c){Opaque.call(this,b,c,a)}return Super(b,Opaque),b.bytes=a,b}function copy(a,b,c){return Object[c?"getOwnPropertyNames":"keys"](a).forEach(function(c){var d=Object.getOwnPropertyDescriptor(a,c);d.enumerable=!1,Object.defineProperty(b,c,d)}),b}imports["./genesis"]={},Object.defineProperty(module,"exports",{get:function(){return imports["./genesis"]},set:function(a){imports["./genesis"]=a}}),"use strict";var utility=require("./utility"),isObject=utility.isObject,hasProto=!!Function.__proto__,types={},exp=exports=module.exports={Type:Type,Subtype:Subtype,OpaqueType:OpaqueType,lookupType:lookupType,registerType:registerType,DataBuffer:require("./buffer"),types:types,isBuffer:isBuffer,api:api,nullable:function(a,b){Object.defineProperty(a,b,nullable),delete a[b]}},nullable={value:undefined,writable:!0,configurable:!0},hidden={configurable:!0,writable:!0,value:0};copy({Class:"Type",isInstance:function(a){return this.prototype.isPrototypeOf(a)},array:function(a){return createType("array",this,a)},typeDef:function(a,b){var c=Super(createInterface(a,ifaceMap.get(this)),this);return typeof b=="function"&&c.reifier(b),c},reifier:function(a){var b=this.prototype.reify;return a?(this.prototype.reify=function c(){var c=this;return a.call(this,function(){return b.call(c)})},this):b}},Type),Array.apply(null,Array(20)).forEach(function(a,b){Object.defineProperty(Type,b,{configurable:!0,get:function(){return this.array(b)}})}),Object.defineProperty(Type,"ptr",{configurable:!0,get:function(){return createType("pointer",this.displayName,this)}});var ifaceMap=function(){var a=[],b=[];return{set:function(c,d){return a.push(c),b.push(d),c},get:function(c){var d=a.indexOf(c);return~d?b[d]:null}}}(),Data=Type.prototype={Class:"Data",toString:function toString(){return"[object "+this.constructor.displayName+"]"},rebase:function(a){a==null?(a=new exp.DataBuffer(this.bytes),a.fill(0)):a._data?a=a._data:exp.DataBuffer.isBuffer(a)&&(a=new exp.DataBuffer(a)),api(this,"_data",a)},init:function(a){return this},realign:function(a){this._offset=+a||0},clone:function(){return new this.constructor(this._data,this._offset)},copy:function(a,b){return new this.constructor(this._data.clone())},cast:function(a,b){if(typeof (a=lookupType(a))=="string")throw new TypeError('Unknown type "'+a+'"');if(this instanceof Opaque)return new a(this._data,this._offset);if(a.bytes<this.bytes)throw new RangeError('Tried to cast to a smaller size "'+a.name+'"');if(this._data.length<a.bytes)throw new RangeError('Type is bigger than this buffer: "'+a.name+'"');return b=a.bytes===this.bytes||!b?0:b<0?this.bytes-a.bytes:+b,new a(this._data,this._offset+b)},pointer:function(){var a=lookupType("*"+this.constructor.displayName);return new a(this)}};Super(Opaque,Type),ifaceMap.set(Opaque,Opaque),registerType("Opaque",Opaque),inspectors(Opaque,"Opaque"),api(Opaque,"displayName","Opaque"),Opaque.bytes=Opaque.prototype.bytes=0,Opaque.prototype.DataType="opaque",Opaque.prototype.reify=function(){return null},Opaque.prototype.write=function(){throw new Error("Opaque data must be cast to a specific type before it can be written to")},Opaque.prototype.rebase=function(a){a!=null&&Data.rebase.call(this,a)}}({},function(a){return imports[a]}),!function(a,b){function g(a,b){if(b&&b.DataType){if(b.DataType==="numeric"&&b.Subtype==="Int64"||b.Subtype==="Uint64"){if(a==="Int64"||a==="Uint64")return b._data;throw new RangeError(b+" exceeds "+a+" capacity")}if(b.DataType==="array"||b.DataType==="struct"){if(b.bytes>f[a][0])throw new RangeError(b+" exceeds "+a+" capacity");b=b.reify()}else b=b.reify()}b||(b=0),typeof b=="undefined"&&(b=0);if(isFinite(b))b=+b;else throw new TypeError("Invalid value for "+a+": "+b.DataType);if(b&&c(b)/8>f[a][0])throw new RangeError(b+" exceeds "+a+" capacity");return b}function h(a,b){function c(a,b,c){if(typeof a=="number"||!a)c=a,a=null;return this.rebase(a),d.api(this,"_offset",+b||0),c!=null&&this.write(c),this}return c.prototype={Subtype:a},e(a,b,c)}function i(){return this._data["read"+this.Subtype](this._offset)}function j(a){return this._data["write"+this.Subtype](this._offset,g(this.Subtype,a)),this}imports["./numeric"]={},Object.defineProperty(a,"exports",{get:function(){return imports["./numeric"]},set:function(a){imports["./numeric"]=a}}),"use strict";var c=b("./utility").bits,d=b("./genesis"),e=d.Subtype.bind(h);a.exports=h;var f={Int8:1,Uint8:1,Int16:2,Uint16:2,Int32:4,Uint32:4,Float32:4,Float64:8};d.Type(h,{DataType:"numeric",fill:function(a){j.call(this,a||0)},reify:i,write:j,valueOf:i,toString:i}),Object.keys(f).forEach(function(a){h[a]=new h(a,f[a])})}({},function(a){return imports[a]}),!function(a,b){function f(a,b){function j(a,c,e){return d.isBuffer(a)||(e=a,a=null),d.api(this,"_offset",+c||0),this.rebase(a),e&&Object.keys(e).forEach(function(a){if(!a in b)throw new Error('Invalid field "'+a+'"');a in b&&g(this,j,a).write(e[a])},this),this}b||(b=a,a="");var c=0,f={},i=[];return b=Object.keys(b).reduce(function(a,e){return a[e]=d.lookupType(b[e]),i.push(e),f[e]=c,c+=a[e].bytes,a},{}),j.fields=b,j.offsets=f,j.keys=i,h(e(a,c,j))}function g(a,b,c){var e=new b.fields[c](a._data,a._offset+b.offsets[c]);return Object.defineProperty(a,c,{enumerable:!0,configurable:!0,get:function(){return e},set:function(a){a===null?(d.nullable(this,c),e=null):e.write(a)}}),e}function h(a){return a.keys.forEach(function(b){Object.defineProperty(a.prototype,b,{enumerable:!0,configurable:!0,get:function(){return g(this,a,b)},set:function(c){g(this,a,b).write(c)}})}),a}imports["./struct"]={},Object.defineProperty(a,"exports",{get:function(){return imports["./struct"]},set:function(a){imports["./struct"]=a}}),"use strict";var c=b("./utility").isObject,d=b("./genesis"),e=d.Subtype.bind(f);a.exports=f,d.Type(f,{DataType:"struct",reify:function(a){return this.constructor.keys.reduce(function(b,c){return b[c]=this[c]==null?g(this,this.constructor,c).reify(a):this[c].reify(a),a&&(this[c]=null),b}.bind(this),{})},write:function(a){c(a)&&(a.reify&&(a=a.reify()),Object.keys(a).forEach(function(b,c){c=a[b],c!=null?this[b]=c.reify?c.reify():c:c===null&&(this[b]=null)},this))},realign:function(a,b){this._offset=a=+a||0,Object.keys(this).forEach(function(c){b?this[c]=null:this[c].realign(a)},this)},fill:function(a){a=a||0,this.constructor.keys.forEach(function(b){this[b]=a},this)}})}({},function(a){return imports[a]}),!function(a,b){function e(a,b,e){function i(a,b,d){return c.isBuffer(a)||(d=a,a=null),this.rebase(a),c.api(this,"_offset",b||0),d&&Object.keys(d).forEach(function(a){f(this,this.constructor.memberType,a).write(d[a])},this),this}typeof a!="string"||typeof b=="number"?(e=b||0,b=c.lookupType(a),a=b.name+"x"+e):b=c.lookupType(b);if(c.lookupType(a)!==a)return c.lookupType(a);var h=b.bytes*e;return i.memberType=b,i.keys=Array.apply(null,Array(e)).map(Function.call.bind(String)),i.count=e,i.prototype.length=e,g(d(a,h,i))}function f(a,b,d){var e=new b(a._data,a._offset+d*b.bytes);return Object.defineProperty(a,d,{enumerable:!0,configurable:!0,get:function(){return e},set:function(a){a===null?(c.nullable(this,d),e=null):e.write(a)}}),e}function g(a){return Array.apply(null,Array(a.count)).forEach(function(b,c){Object.defineProperty(a.prototype,c,{enumerable:!0,configurable:!0,get:function(){return f(this,a.memberType,c)},set:function(b){f(this,a.memberType,c).write(b)}})}),a}imports["./array"]={},Object.defineProperty(a,"exports",{get:function(){return imports["./array"]},set:function(a){imports["./array"]=a}}),"use strict";var c=b("./genesis"),d=c.Subtype.bind(e);a.exports=e,c.Type(e,{DataType:"array",forEach:Array.prototype.forEach,reduce:Array.prototype.reduce,map:Array.prototype.map,join:Array.prototype.join,reify:function(a){this.reified=[];for(var b=0;b<this.length;b++)this.reified[b]=this[b].reify(a),a&&(this[b]=null);var c=this.reified;return delete this.reified,c},write:function(a,b,c){if(a==null)throw new TypeError("Tried to write nothing");if(isFinite(b)&&typeof c=="undefined"&&!a.length)return this[b]=a;b=+b||0,c=+c||0,a=a.reify?a.reify():a;if(a&&a.length)for(var b;b<this.length&&b+c<a.length;b++)a[c+b]===null?this[b]=null:this[b]=a[c+b];else this[b]=c?a[c]:a},fill:function(a){a=a||0;for(var b=0;b<this.length;b++)this[b]=a},realign:function(a,b){this._offset=a=+a||0,Object.keys(this).forEach(function(c){isFinite(c)&&(b?this[c]=null:this[c].realign(a))},this)}})}({},function(a){return imports[a]}),!function(a,b){function i(a,b,c){function f(a,b,c){return d.isBuffer(a)||(c=a||0,a=null),this.rebase(a),d.api(this,"_offset",+b||0),Array.isArray(c)?c.forEach(function(a){this[a]=!0},this):typeof c=="number"?this.write(c):Object(c)===c&&Object.keys(c).forEach(function(a){this[a]=c[a]},this),this}typeof a!="string"&&(c=b,b=a,a=""),typeof b=="number"&&(c=b,b=[]),Array.isArray(b)&&(b=b.reduce(function(a,b,c){return a[b]=1<<c,a},{})),c>0||(c=e(k(b))),f.keys=b,f.prototype={flags:b,length:c*8,toString:function(){return this===f.prototype?"[object "+a+"]":this.map(function(a){return+a}).join("")}};var h=g(a,c,f);return j(h)}function j(a){var b=0;return Object.keys(a.keys).forEach(function(c){var d=a.keys[c];b=Math.max(b,d),Object.defineProperty(a.prototype,c,{configurable:!0,enumerable:!0,get:function(){return(this.read()&d)>0},set:function(a){this.write(a?this.read()|d:this.read()&~d)}})}),Array.apply(null,Array(a.bytes*8)).forEach(function(c,d){var e=h[d];if(e>b)return;Object.defineProperty(a.prototype,d,{configurable:!0,enumerable:!0,get:function(){return(this.read()&e)>0},set:function(a){this.write(a?this.read()|e:this.read()&~e)}})}),a}function k(a){return Array.isArray(a)?a.reduce(function(a,b){return Math.max(b,a)},0):Object.keys(a).reduce(function(b,c){return Math.max(a[c],b)},0)}imports["./bitfield"]={},Object.defineProperty(a,"exports",{get:function(){return imports["./bitfield"]},set:function(a){imports["./bitfield"]=a}}),"use strict";var c=b("./utility"),d=b("./genesis"),e=c.bytes,f=c.bits,g=d.Subtype.bind(i),h=Array.apply(null,Array(32)).map(Function.call.bind(Number)).map(Math.pow.bind(null,2));a.exports=i,d.Type(i,{DataType:"bitfield",forEach:Array.prototype.forEach,reduce:Array.prototype.reduce,map:Array.prototype.map,get:function(a){return(this.read()&h[a])>0},set:function(a){return this.write(this.read()|h[a]),this},unset:function(a){return this.write(this.read()&~h[a]),this},write:function(a){return this._data["writeUint"+this.length](this._offset,a),this},read:function(){return this._data["readUint"+this.length](this._offset)},reify:function(a){var b=Object.keys(this.flags);if(b.length)var c=b.reduce(function(a,b,c){return this[b]&&a.push(b),a}.bind(this),[]);else var c=this.map(function(a){return a});return a&&(delete this._data,delete this._offset),c}})}({},function(a){return imports[a]}),!function(a,b){function h(a,b,d){function h(a,b,d){return c.isBuffer(a)||(d=a,a=null),this.rebase(a),c.api(this,"_offset",+b||0),this.address=new h.addressType(this._data,this._offset),typeof d=="number"?(this.memory=this._data,this.address.write(d)):d&&d._data?this.pointTo(d):this.memory=this._data,this}typeof a!="string"&&(d=b,b=a,a=b.displayName),typeof b=="string"?b=c.lookupType(b):typeof b=="undefined"&&(b=c.lookupType(a));if(typeof d=="string")switch(d){case"absolute":d=f;break;case"relative":d=g;break;default:d=c.lookupType(d)}else typeof d=="undefined"&&(d=f);return a="*"+a,h.pointeeType=b,h.addressType=d,Object.defineProperty(h.prototype,"pointee",{enumerable:!0,configurable:!0,get:function(){return i(this,b)},set:function(a){i(this,b,a)}}),e(a,d.bytes,h)}function i(a,b,c){var d;return c?(d=a.address.reify(),c=new b(a.memory)):a.memory?c=new b(a.memory,d=a.address.reify()):(c=new b,a.memory=c._data,a.address.write(d=c._offset)),Object.defineProperty(a,"pointee",{enumerable:!0,configurable:!0,get:function(){var b=a.address.reify();return b!==d&&(c.realign(b),d=b),c},set:function(b){var e=a.address.reify();e!==d&&(c.realign(e),d=e),c.write(b)}}),c}imports["./pointer"]={},Object.defineProperty(a,"exports",{get:function(){return imports["./pointer"]},set:function(a){imports["./pointer"]=a}}),"use strict";var c=b("./genesis"),d=b("./numeric"),e=c.Subtype.bind(h);a.exports=h;var f=d.Uint32.typeDef("AbsoluteAddress"),g=d.Uint32.typeDef("RelativeAddress",function(a){return this._offset.view.byteOffset-this._offset+ +a()});c.Type(h,{DataType:"pointer",(get bytes(){return this.constructor.addressType.bytes}),reify:function(a){return this.pointee.reify(a)},write:function(a){this.pointee.write(a)},fill:function(a){this.pointee.fill(a)},pointTo:function(a){if(!a._data)throw new TypeError("Must point to reified <Data>");this.pointee=a,this.address.write(a._offset),this.memory=a._data},cast:function(a){return typeof a=="string"&&(a=c.lookupType(a)),c.nullable(this,"pointee"),this.__proto__=a.ptr.prototype,this}}),Object.defineProperty(h.prototype,"bytes",{configurable:!0,enumerable:!0,get:function(){return this.addressType.bytes}})}({},function(a){return imports[a]}),!function(a,b){function k(a,b,d){var e;if(typeof a=="number")e=a,a=null;else if(typeof a=="string")e=a.length,d=a,a=null;else if(a.bytes||a.byteLength)e=a.bytes||a.byteLength;var g=e;if(g in j)var h=j[g];else{var h=j[g]=f("CharArray"+g,g,function(a,b,d){return a||(a=new c.DataBuffer(this.bytes)),this.rebase(a),c.api(this,"_offset",b||0),d&&this.write(d),this});h.bytes=g,h.prototype.bytes=g,h.prototype.length=g}return a||d?(a||(a=new c.DataBuffer(g||d)),new h(a,b,d)):h}function l(a,b,d){if(typeof a=="string"||typeof a=="number"||!a)d=a,a=null;return this.rebase(a),c.api(this,"_offset",+b||0),d!=null&&this.write(d),this}imports["./string"]={},Object.defineProperty(a,"exports",{get:function(){return imports["./string"]},set:function(a){imports["./string"]=a}}),"use strict";var c=b("./genesis"),d=b("./numeric"),e=b("./array"),f=c.Subtype.bind(k);a.exports=k;var g=String.fromCharCode,h=Function.call.bind("".charCodeAt),i=function(){var a=1023,b=65536,c=b-2048,d=b-9216,e=b-10240;return function f(f){if(typeof f=="string"){var i=h(f,0);return i&c===e?b+((i&a)<<10)+(h(f,1)&a):i}if(isFinite(f))return f>=b?g((f-=b)>>>10&a|e)+g(d|f&a):g(f)}}(),j=[];c.Type(k,{DataType:"string",Subtype:"CharArray",bits:8,join:Array.prototype.join,map:Array.prototype.map,fill:function(a){this.write(0,a||0)},reify:function(){return this._data.subarray(this._offset,this.bytes).map(function(a){return i(a)}).join("")},write:function(a,b){var c=typeof a=="string";if(isFinite(b))c&&(a=i(a)),this._data["writeUint"+this.bits](b,a);else if(typeof a=="string"||a&&"length"in a){var d=this.bits/8;for(var e=0;e<a.length&&e<this.length;e++)this._data["writeUint"+this.bits](this._offset+e*d,i(a[e]))}}}),l.prototype={length:1,Subtype:"CharArray",bytes:1,write:function(a,b){return this._data["writeUint"+this.bits](this._offset,typeof a=="string"?i(a[b||0]):a),this},reify:function(a){return i(this._data["readUint"+this.bits](this._offset,1))},toNumber:function(a){return this._data["readUint"+this.bits](this._offset)}},l.__proto__=k.prototype,l.constructor=k,l.prototype.__proto__=k.prototype.prototype,l.bytes=l.prototype.bytes=l.prototype.length=1,l.prototype.constructor=l,j[1]=l}({},function(a){return imports[a]}),!function(a,b){function k(a,b,d,e){a=c.lookupType(a);if(k.prototype.isPrototypeOf(this))return new a(b,d,e);b=c.lookupType(b);if(!b||a.Class==="Type"&&!b)return a;if(b==="Char")return new h(a);if(typeof b=="string"||b.Class==="Type")return new k.ArrayType(a,b,d);if(typeof a!="undefined")return Array.isArray(b)||typeof b=="number"?new k.BitfieldType(a,b,d):(typeof a!="string"&&typeof b=="undefined"&&(b=a,a=""),b=Object.keys(b).reduce(function(a,c){if(b[c].Class!=="Type"){var d=k(b[c]);if(!d)return a;typeof d=="string"||d.Class!=="Type"?a[c]=k(c,b[c]):a[c]=d}else a[c]=b[c];return a},{}),new k.StructType(a,b))}function m(a,b){return!n(a,b).length}function n(a,b){return a.filter(function(a){return!~b.indexOf(a)})}function p(){return new o(this._data,this._offset)}imports["./index"]={},Object.defineProperty(a,"exports",{get:function(){return imports["./index"]},set:function(a){imports["./index"]=a}}),"use strict";var c=b("./genesis"),d=b("./numeric"),e=b("./struct"),f=b("./array"),g=b("./bitfield"),h=b("./string"),i=b("./pointer"),j=c.OpaqueType;a.exports=k,k.data=function(a,b,d,e){a=c.lookupType(a);if(typeof a=="string")throw new TypeError('Type not found "'+a+'"');return new a(b,d,e)},k.reify=function(a){if(a.Class==="Data")var b=Object.getPrototypeOf(a.constructor).prototype;return b.reify.call(a)},k.reifier=function(a,b){return a=k(a),a.reifier(b),a},k.isType=function(a){return c.Type.isPrototypeOf(a)},k.isData=function(a){return c.Type.prototype.isPrototypeOf(a)},Object.defineProperty(k,"defaultEndian",{enumerable:!0,configurable:!0,get:function(){return c.DataBuffer.prototype.endianness},set:function(a){if(a!=="LE"&&a!=="BE")throw new Error('Endianness must be "BE" or "LE"');c.DataBuffer.prototype.endianness=a}});var l=k("Opaque").ptr.typeDef("VoidPtr");l.prototype.reify=function(){return{type:l,address:this.address.reify()}},d.Uint64=new f("Uint64","Uint32",2),d.Int64=new f("Int64","Int32",2);var o=new f("EightByteOctetString","Uint8",8);d.Uint64.prototype.octets=p,d.Int64.prototype.octets=p,c.api(k,{Type:c.Type,NumericType:d,StructType:e,ArrayType:f,BitfieldType:g,DataBuffer:c.DataBuffer,CharType:h,PointerType:i,OpaqueType:j,VoidPtr:l,toString:function(){return"◤▼▼▼▼▼▼▼◥\n▶reified◀\n◣▲▲▲▲▲▲▲◢"}})}({},function(a){return imports[a]}),imports["./index"]}(this,{});typeof module!="undefined"&&(module.exports=reified),"use strict",function(a){function d(a,d,e,g,h){g===undefined&&f("Missing required offset argument"),(g<0||g+e>a.byteLength)&&f("Invalid index: "+g);if(e===1||!!h===b){if((a.byteOffset+g)%e===0)return(new d(a.buffer,a.byteOffset+g,1))[0];for(var i=0;i<e;i++)c[i]=a._bytes[g+i];return(new d(c.buffer))[0]}for(var i=0;i<e;i++)c[e-i-1]=a._bytes[g+i];return(new d(c.buffer))[0]}function e(a,d,e,g,h,i){g===undefined&&f("Missing required offset argument"),h===undefined&&f("Missing required value argument"),(g<0||g+e>a.byteLength)&&f("Invalid index: "+g);if(e===1||!!i===b)if((a.byteOffset+g)%e===0)(new d(a.buffer,a.byteOffset+g,1))[0]=h;else{(new d(c.buffer))[0]=h;for(var j=0;j<e;j++)a._bytes[j+g]=c[j]}else{(new d(c.buffer))[0]=h;for(var j=0;j<e;j++)a._bytes[g+j]=c[e-1-j]}}function f(a){throw new Error(a)}if(a.DataView)return;a.ArrayBuffer||f("ArrayBuffer not supported"),Object.defineProperties||f("This module requires ECMAScript 5");var b=(new Int8Array((new Int32Array([1])).buffer))[0]===1,c=new Uint8Array(8);a.DataView=function(a,b,c){a instanceof ArrayBuffer||f("Bad ArrayBuffer"),b=b||0,c=c||a.byteLength-b,(b<0||c<0||b+c>a.byteLength)&&f("Illegal offset and/or length"),Object.defineProperties(this,{buffer:{value:a,enumerable:!1,writable:!1,configurable:!1},byteOffset:{value:b,enumerable:!1,writable:!1,configurable:!1},byteLength:{value:c,enumerable:!1,writable:!1,configurable:!1},_bytes:{value:new Uint8Array(a,b,c),enumerable:!1,writable:!1,configurable:!1}})},a.DataView.prototype={constructor:DataView,getInt8:function(a){return d(this,Int8Array,1,a)},getUint8:function(a){return d(this,Uint8Array,1,a)},getInt16:function(a,b){return d(this,Int16Array,2,a,b)},getUint16:function(a,b){return d(this,Uint16Array,2,a,b)},getInt32:function(a,b){return d(this,Int32Array,4,a,b)},getUint32:function(a,b){return d(this,Uint32Array,4,a,b)},getFloat32:function(a,b){return d(this,Float32Array,4,a,b)},getFloat64:function(a,b){return d(this,Float64Array,8,a,b)},setInt8:function(a,b){e(this,Int8Array,1,a,b)},setUint8:function(a,b){e(this,Uint8Array,1,a,b)},setInt16:function(a,b,c){e(this,Int16Array,2,a,b,c)},setUint16:function(a,b,c){e(this,Uint16Array,2,a,b,c)},setInt32:function(a,b,c){e(this,Int32Array,4,a,b,c)},setUint32:function(a,b,c){e(this,Uint32Array,4,a,b,c)},setFloat32:function(a,b,c){e(this,Float32Array,4,a,b,c)},setFloat64:function(a,b,c){e(this,Float64Array,8,a,b,c)}}}(this)
+var reified=function(global,imports){return!function(a,b){function c(a){return Object(a)===a}function d(a){return Math.log(a)/Math.LN2}function e(a){return(d(a)/8|0)+1}function f(a,b){var c=Array((b||2)+1).join(" ");return a.split("\n").map(function(a){return c+a}).join("\n")}function g(a,b){return b-=h(a||"")+1,a+Array(b>1?b:1).join(" ")}function h(a){return a.replace(/\033\[(?:\d+;)*\d+m/g,"").length}function i(a){if(!Array.isArray(a)){if(!c(a))throw new TypeError("Max length called on non-object "+a);a=Object.keys(a)}return a.reduce(function(a,b){return Math.max(a,h(""+b))},0)}function j(a){return Object.keys(a.reduce(function(a,b){return a[b]=1,a},{}))}imports["./utility"]={},Object.defineProperty(a,"exports",{get:function(){return imports["./utility"]},set:function(a){imports["./utility"]=a}}),"use strict",a.exports={isObject:c,bytes:e,bits:d,indent:f,pad:g,maxLength:i,unique:j,strlen:h}}({},function(a){return imports[a]}),!function(a,b){function f(a){return a instanceof ArrayBuffer||!!(a&&a.constructor&&a.constructor.name in e)}function g(a,b,c){if(!g.prototype.isPrototypeOf(this))return new g(a,b,c);if(!a)throw new Error("Tried to initialize with no usable length or subject");f(a)&&(this.array=a);if(a){if(a.buffer){b=(a.offset||a.byteOffset||0)+(b||0);while(a.buffer)a=a.buffer}typeof b=="undefined"&&(b=a.offset||a.byteOffset),typeof c=="undefined"&&(c=a.length||a.byteLength)}typeof a=="number"?this.view=new DataView(new d(a)):d.isBuffer(a)?this.view=new DataView(a,b,c):a instanceof DataView?this.view=new DataView(a.buffer,b,c):g.isDataBuffer(a)&&(this.view=new DataView(a.buffer,a.offset+b,c||a.length)),this.length=this.view.byteLength,this.buffer=this.view.buffer,this.offset=this.view.byteOffset}function h(a){return isFinite(a)?+a:0}function i(a){if(isFinite(a))return+a}function j(a){return a>>>0&255}imports["./buffer"]={},Object.defineProperty(a,"exports",{get:function(){return imports["./buffer"]},set:function(a){imports["./buffer"]=a}}),"use strict",a.exports=g;var c=["Int8","Int16","Int32","Uint8","Uint16","Uint32","Float32","Float64"],d=function(a){function b(a,b,c){return new ArrayBuffer(a,b,c)}return"Buffer"in a?a.Buffer:(b.isBuffer=function(a){return a instanceof ArrayBuffer},b)}(Function("return this")()),e={ArrayBuffer:ArrayBuffer};g.isBuffer=d.isBuffer,g.isDataBuffer=function(a){return g.prototype.isPrototypeOf(a)},g.prototype={constructor:g,endianness:"LE",subarray:function(a,b){return a=h(a),b=i(b),new g(this.view,a,b)},typed:function(a,b,c){return a=e[a+"Array"],arguments.length===1?new a(this.view):arguments.length===2?new a(this.view,h(b)):(c=h(c)||this.length/a.BYTES_PER_ELEMENT|0,new a(this.view,h(b),c))},copy:function(a,b,c,e){isFinite(a)&&(e=c,c=b,b=a,a=null),b=h(b),c=h(c),e=e?+e:this.length-1;if(c>e)throw new Error("End less than start");if(c<0)throw new RangeError("Start less than zero");if(e>=this.length)throw new RangeError("End greater than length");var f=e-c;a?b+f>a.length&&(f=a.length):a=new d(f),a=(new g(a,b,f)).typed("Uint8");var i=this.subarray(c,e).typed("Uint8");for(var j=0;j<f;j++)a[j]=i[j];return a},clone:function(){var a=new g(new d(this.length));for(var b=0;b<this.length;b++)a.writeUint8(b,this.readUint8(b));return a},fill:function(a){a=h(a);var b=this.typed("Uint8");for(var c=0;c<this.length;c++)b[c]=a},write:function(a,b,c){c=isFinite(c)?+c:a.length,b=isFinite(b)?+b:0,c=Math.min(this.length,c+b,a.length);var d=this.subarray(b,b.length).typed("Uint8");for(var e=0;e<c;e++)d[e]=a[e];return this},map:function(){return[].map.apply(this.typed("Uint8"),arguments)},slice:function(a,b,c){return this.subarray(a,b).toString(c||"ascii")},toArray:function(a){return[].map.call(this.typed(a||"Uint8"),function(a){return a})},toString:function(a){switch(a){case"ascii":return this.map(function(a){return String.fromCharCode(a)}).join("");default:return this.map(function(a){return("000"+a.toString(10)).slice(-3)}).join(" ").split(/((?:\d\d\d ?){10}(?: ))/).filter(Boolean).map(Function.call.bind("".trim)).join("\n")}}},c.forEach(function(a){e[a+"Array"]=global[a+"Array"],g.prototype["read"+a]=function(b){return this.view["get"+a](h(b),this.endianness==="LE")},g.prototype["write"+a]=function(b,c){return this.view["set"+a](h(b),h(c),this.endianness==="LE")}}),Array.apply(null,Array(20)).forEach(function(a,b){Object.defineProperty(g.prototype,b,{configurable:!0,get:function(){return this.readUint8(b)},set:function(a){return this.writeUint8(b,a)}})})}({},function(a){return imports[a]}),!function(module,require){function isBuffer(a){return exp.DataBuffer.isBuffer(a)||exp.DataBuffer.isDataBuffer(a)}function api(a,b,c){Object(b)===b?Object.keys(b).forEach(function(c){api(a,c,b[c])}):(hidden.value=c,Object.defineProperty(a,b,hidden))}function registerType(a,b){return a in types?types[a]:a.length?types[a]=b:b}function lookupType(a,b){if(typeof a!="string")return a;if(a[0]==="*"){a=a.slice(1);var c=lookupType(a);if(typeof c!="string")return typeof b=="string"&&(a=b),createType("pointer",a,c)}if(a[a.length-1]==="]"){var d=a.match(/(.*)\[(\d+)\]$/);if(!d)return a in types?types[a]:a;a=d[1],d=+d[2];if(a==="Char")return createType("string",d);if(typeof b=="string")return createType("array",b,lookupType(a),d);if(c==="Char")return createType("string",d);var c=lookupType(a);return c===a?createType("array",a,d):(a=c.name+"x"+d,createType("array",a,c,d))}return a in types?types[a]:a}function createType(a,b,c,d){var e=require("./"+a);return new e(b,c,d)}function Type(ctor,proto){ctor.prototype=Super(eval("(function Empty"+ctor.name.replace(/Type$/,"T")+"(){})"),Type),ctor.prototype.Type=ctor.name,ctor.prototype.prototype=copy(proto,Object.create(Data)),types[ctor.name.replace(/Type$/,"")]=ctor,inspectors(ctor.prototype,ctor.name)}function Super(a,b,c){return hasProto?a.__proto__=b:copy(b,a),a.prototype=c||Object.create(b.prototype),a.prototype.constructor=a,a}function inspectors(a,b){typeof imports=="undefined"&&(a.inspect=require("./inspect")("Type",b),a.prototype.inspect=require("./inspect")("Data",b))}function createInterface(a,b,c){var d=a.replace(/[^\w0-9_$]/g,"");if(a[0]==="*"){var e=a.match(/^[*]+/)[0].length;d=Array(e+1).join("Ptr_")+d}var f="return function "+d+"(data, offset, values){ return Ctor.call(Object.create("+d+".prototype), data, offset, values).init() }",g=Function("Ctor",f)(b);return ifaceMap.set(g,b),c&&(hasProto?g.__proto__=c.prototype:copy(c.prototype,g)),g.prototype=b.prototype,api(g,"displayName",a),a&&registerType(a,g),copy(b,g)}function Subtype(a,b,c){return c.bytes=b,c.prototype.bytes=b,c.prototype=copy(c.prototype,Object.create(this.prototype.prototype)),c.prototype.constructor=createInterface(a,c,this)}function Opaque(a,b,c){if(isFinite(a)){c=a,a=null;if(!isFinite(c))throw new Error("Opaque types must be given a size or buffer")}return this.bytes=c||0,this.rebase(a),api(this,"_offset",+b||0),this}function OpaqueType(a){function b(b,c){Opaque.call(this,b,c,a)}return Super(b,Opaque),b.bytes=a,b}function copy(a,b,c){return Object[c?"getOwnPropertyNames":"keys"](a).forEach(function(c){var d=Object.getOwnPropertyDescriptor(a,c);d.enumerable=!1,Object.defineProperty(b,c,d)}),b}imports["./genesis"]={},Object.defineProperty(module,"exports",{get:function(){return imports["./genesis"]},set:function(a){imports["./genesis"]=a}}),"use strict";var utility=require("./utility"),isObject=utility.isObject,hasProto=!!Function.__proto__,types={},exp=exports=module.exports={Type:Type,Subtype:Subtype,OpaqueType:OpaqueType,lookupType:lookupType,registerType:registerType,DataBuffer:require("./buffer"),types:types,isBuffer:isBuffer,api:api,nullable:function(a,b){Object.defineProperty(a,b,nullable),delete a[b]}},nullable={value:undefined,writable:!0,configurable:!0},hidden={configurable:!0,writable:!0,value:0};copy({Class:"Type",isInstance:function(a){return this.prototype.isPrototypeOf(a)},array:function(a){return createType("array",this,a)},typeDef:function(a,b){var c=Super(createInterface(a,ifaceMap.get(this)),this);return typeof b=="function"&&c.reifier(b),c},initializer:function(a){return this.prototype.init=a,this},reifier:function(a){var b=this.prototype.reify;return a?(this.prototype.reify=function c(){var c=this;return a.call(this,function(){return b.call(c)})},this):b}},Type),Array.apply(null,Array(20)).forEach(function(a,b){Object.defineProperty(Type,b,{configurable:!0,get:function(){return this.array(b)}})}),Object.defineProperty(Type,"ptr",{configurable:!0,get:function(){return createType("pointer",this.displayName,this)}});var ifaceMap=function(){var a=[],b=[];return{set:function(c,d){return a.push(c),b.push(d),c},get:function(c){var d=a.indexOf(c);return~d?b[d]:null}}}(),Data=Type.prototype={Class:"Data",toString:function toString(){return"[object "+this.constructor.displayName+"]"},rebase:function(a){a==null?(a=new exp.DataBuffer(this.bytes),a.fill(0)):a._data?a=a._data:exp.DataBuffer.isBuffer(a)&&(a=new exp.DataBuffer(a)),api(this,"_data",a)},init:function(a){return this},realign:function(a){this._offset=+a||0},clone:function(){return new this.constructor(this._data,this._offset)},copy:function(a,b){return new this.constructor(this._data.clone())},cast:function(a,b){if(typeof (a=lookupType(a))=="string")throw new TypeError('Unknown type "'+a+'"');if(this instanceof Opaque)return new a(this._data,this._offset);if(a.bytes<this.bytes)throw new RangeError('Tried to cast to a smaller size "'+a.name+'"');if(this._data.length<a.bytes)throw new RangeError('Type is bigger than this buffer: "'+a.name+'"');return b=a.bytes===this.bytes||!b?0:b<0?this.bytes-a.bytes:+b,new a(this._data,this._offset+b)},pointer:function(){var a=lookupType("*"+this.constructor.displayName);return new a(this)}};Super(Opaque,Type),ifaceMap.set(Opaque,Opaque),registerType("Opaque",Opaque),inspectors(Opaque,"Opaque"),api(Opaque,"displayName","Opaque"),Opaque.bytes=Opaque.prototype.bytes=0,Opaque.prototype.DataType="opaque",Opaque.prototype.reify=function(){return null},Opaque.prototype.write=function(){throw new Error("Opaque data must be cast to a specific type before it can be written to")},Opaque.prototype.rebase=function(a){a!=null&&Data.rebase.call(this,a)}}({},function(a){return imports[a]}),!function(a,b){function g(a,b){if(b&&b.DataType){if(b.DataType==="numeric"&&b.Subtype==="Int64"||b.Subtype==="Uint64"){if(a==="Int64"||a==="Uint64")return b._data;throw new RangeError(b+" exceeds "+a+" capacity")}if(b.DataType==="array"||b.DataType==="struct"){if(b.bytes>f[a][0])throw new RangeError(b+" exceeds "+a+" capacity");b=b.reify()}else b=b.reify()}b||(b=0),typeof b=="undefined"&&(b=0);if(isFinite(b))b=+b;else throw new TypeError("Invalid value for "+a+": "+b.DataType);if(b&&c(b)/8>f[a][0])throw new RangeError(b+" exceeds "+a+" capacity");return b}function h(a,b){function c(a,b,c){if(typeof a=="number"||!a)c=a,a=null;return this.rebase(a),d.api(this,"_offset",+b||0),c!=null&&this.write(c),this}return c.prototype={Subtype:a},e(a,b,c)}function i(){return this._data["read"+this.Subtype](this._offset)}function j(a){return this._data["write"+this.Subtype](this._offset,g(this.Subtype,a)),this}imports["./numeric"]={},Object.defineProperty(a,"exports",{get:function(){return imports["./numeric"]},set:function(a){imports["./numeric"]=a}}),"use strict";var c=b("./utility").bits,d=b("./genesis"),e=d.Subtype.bind(h);a.exports=h;var f={Int8:1,Uint8:1,Int16:2,Uint16:2,Int32:4,Uint32:4,Float32:4,Float64:8};d.Type(h,{DataType:"numeric",fill:function(a){j.call(this,a||0)},reify:i,write:j,valueOf:i,toString:i}),Object.keys(f).forEach(function(a){h[a]=new h(a,f[a])})}({},function(a){return imports[a]}),!function(a,b){function f(a,b){function j(a,c,e){return d.isBuffer(a)||(e=a,a=null),d.api(this,"_offset",+c||0),this.rebase(a),e&&Object.keys(e).forEach(function(a){if(!a in b)throw new Error('Invalid field "'+a+'"');a in b&&g(this,j,a).write(e[a])},this),this}b||(b=a,a="");var c=0,f={},i=[];return b=Object.keys(b).reduce(function(a,e){return a[e]=d.lookupType(b[e]),i.push(e),f[e]=c,c+=a[e].bytes,a},{}),j.fields=b,j.offsets=f,j.keys=i,h(e(a,c,j))}function g(a,b,c){var e=new b.fields[c](a._data,a._offset+b.offsets[c]);return Object.defineProperty(a,c,{enumerable:!0,configurable:!0,get:function(){return e},set:function(a){a===null?(d.nullable(this,c),e=null):e.write(a)}}),e}function h(a){return a.keys.forEach(function(b){Object.defineProperty(a.prototype,b,{enumerable:!0,configurable:!0,get:function(){return g(this,a,b)},set:function(c){g(this,a,b).write(c)}})}),a}imports["./struct"]={},Object.defineProperty(a,"exports",{get:function(){return imports["./struct"]},set:function(a){imports["./struct"]=a}}),"use strict";var c=b("./utility").isObject,d=b("./genesis"),e=d.Subtype.bind(f);a.exports=f,d.Type(f,{DataType:"struct",reify:function(a){return this.constructor.keys.reduce(function(b,c){return b[c]=this[c]==null?g(this,this.constructor,c).reify(a):this[c].reify(a),a&&(this[c]=null),b}.bind(this),{})},write:function(a){c(a)&&(a.reify&&(a=a.reify()),Object.keys(a).forEach(function(b,c){c=a[b],c!=null?this[b]=c.reify?c.reify():c:c===null&&(this[b]=null)},this))},realign:function(a,b){this._offset=a=+a||0,Object.keys(this).forEach(function(c){b?this[c]=null:this[c].realign(a)},this)},fill:function(a){a=a||0,this.constructor.keys.forEach(function(b){this[b]=a},this)}})}({},function(a){return imports[a]}),!function(a,b){function e(a,b,e){function i(a,b,d){return c.isBuffer(a)||(d=a,a=null),this.rebase(a),c.api(this,"_offset",b||0),d&&Object.keys(d).forEach(function(a){f(this,this.constructor.memberType,a).write(d[a])},this),this}typeof a!="string"||typeof b=="number"?(e=b||0,b=c.lookupType(a),a=b.name+"x"+e):b=c.lookupType(b);if(c.lookupType(a)!==a)return c.lookupType(a);var h=b.bytes*e;return i.memberType=b,i.keys=Array.apply(null,Array(e)).map(Function.call.bind(String)),i.count=e,i.prototype.length=e,g(d(a,h,i))}function f(a,b,d){var e=new b(a._data,a._offset+d*b.bytes);return Object.defineProperty(a,d,{enumerable:!0,configurable:!0,get:function(){return e},set:function(a){a===null?(c.nullable(this,d),e=null):e.write(a)}}),e}function g(a){return Array.apply(null,Array(a.count)).forEach(function(b,c){Object.defineProperty(a.prototype,c,{enumerable:!0,configurable:!0,get:function(){return f(this,a.memberType,c)},set:function(b){f(this,a.memberType,c).write(b)}})}),a}imports["./array"]={},Object.defineProperty(a,"exports",{get:function(){return imports["./array"]},set:function(a){imports["./array"]=a}}),"use strict";var c=b("./genesis"),d=c.Subtype.bind(e);a.exports=e,c.Type(e,{DataType:"array",forEach:Array.prototype.forEach,reduce:Array.prototype.reduce,map:Array.prototype.map,join:Array.prototype.join,reify:function(a){this.reified=[];for(var b=0;b<this.length;b++)this.reified[b]=this[b].reify(a),a&&(this[b]=null);var c=this.reified;return delete this.reified,c},write:function(a,b,c){if(a==null)throw new TypeError("Tried to write nothing");if(isFinite(b)&&typeof c=="undefined"&&!a.length)return this[b]=a;b=+b||0,c=+c||0,a=a.reify?a.reify():a;if(a&&a.length)for(var b;b<this.length&&b+c<a.length;b++)a[c+b]===null?this[b]=null:this[b]=a[c+b];else this[b]=c?a[c]:a},fill:function(a){a=a||0;for(var b=0;b<this.length;b++)this[b]=a},realign:function(a,b){this._offset=a=+a||0,Object.keys(this).forEach(function(c){isFinite(c)&&(b?this[c]=null:this[c].realign(a))},this)}})}({},function(a){return imports[a]}),!function(a,b){function i(a,b,c){function f(a,b,c){return d.isBuffer(a)||(c=a||0,a=null),this.rebase(a),d.api(this,"_offset",+b||0),Array.isArray(c)?c.forEach(function(a){this[a]=!0},this):typeof c=="number"?this.write(c):Object(c)===c&&Object.keys(c).forEach(function(a){this[a]=c[a]},this),this}typeof a!="string"&&(c=b,b=a,a=""),typeof b=="number"&&(c=b,b=[]),Array.isArray(b)&&(b=b.reduce(function(a,b,c){return a[b]=1<<c,a},{})),c>0||(c=e(k(b))),f.keys=b,f.prototype={flags:b,length:c*8,toString:function(){return this===f.prototype?"[object "+a+"]":this.map(function(a){return+a}).join("")}};var h=g(a,c,f);return j(h)}function j(a){var b=0;return Object.keys(a.keys).forEach(function(c){var d=a.keys[c];b=Math.max(b,d),Object.defineProperty(a.prototype,c,{configurable:!0,enumerable:!0,get:function(){return(this.read()&d)>0},set:function(a){this.write(a?this.read()|d:this.read()&~d)}})}),Array.apply(null,Array(a.bytes*8)).forEach(function(c,d){var e=h[d];if(e>b)return;Object.defineProperty(a.prototype,d,{configurable:!0,enumerable:!0,get:function(){return(this.read()&e)>0},set:function(a){this.write(a?this.read()|e:this.read()&~e)}})}),a}function k(a){return Array.isArray(a)?a.reduce(function(a,b){return Math.max(b,a)},0):Object.keys(a).reduce(function(b,c){return Math.max(a[c],b)},0)}imports["./bitfield"]={},Object.defineProperty(a,"exports",{get:function(){return imports["./bitfield"]},set:function(a){imports["./bitfield"]=a}}),"use strict";var c=b("./utility"),d=b("./genesis"),e=c.bytes,f=c.bits,g=d.Subtype.bind(i),h=Array.apply(null,Array(32)).map(Function.call.bind(Number)).map(Math.pow.bind(null,2));a.exports=i,d.Type(i,{DataType:"bitfield",forEach:Array.prototype.forEach,reduce:Array.prototype.reduce,map:Array.prototype.map,get:function(a){return(this.read()&h[a])>0},set:function(a){return this.write(this.read()|h[a]),this},unset:function(a){return this.write(this.read()&~h[a]),this},write:function(a){return this._data["writeUint"+this.length](this._offset,a),this},read:function(){return this._data["readUint"+this.length](this._offset)},reify:function(a){var b=Object.keys(this.flags);if(b.length)var c=b.reduce(function(a,b,c){return this[b]&&a.push(b),a}.bind(this),[]);else var c=this.map(function(a){return a});return a&&(delete this._data,delete this._offset),c}})}({},function(a){return imports[a]}),!function(a,b){function g(a,b,d){function g(a,b,d){return c.isBuffer(a)||(d=a,a=null),this.rebase(a),c.api(this,"_offset",+b||0),this.address=new g.addressType(this._data,this._offset),typeof d=="number"?(this.memory=this._data,this.address.write(d)):d&&d._data?this.pointTo(d):this.memory=this._data,this}return typeof a!="string"&&(d=b,b=a,a=b.displayName),typeof b=="string"?b=c.lookupType(b):typeof b=="undefined"&&(b=c.lookupType(a)),typeof d=="string"?d=c.lookupType(d):typeof d=="undefined"&&(d=f),a="*"+a,g.pointeeType=b,g.addressType=d,Object.defineProperty(g.prototype,"pointee",{enumerable:!0,configurable:!0,get:function(){return h(this,b)},set:function(a){h(this,b,a)}}),e(a,d.bytes,g)}function h(a,b,c){var d;return c?(d=a.address.reify(),c=new b(a.memory)):a.memory?c=new b(a.memory,d=a.address.reify()):(c=new b,a.memory=c._data,a.address.write(d=c._offset)),Object.defineProperty(a,"pointee",{enumerable:!0,configurable:!0,get:function(){var b=a.address.reify();return b!==d&&(c.realign(b),d=b),c},set:function(b){var e=a.address.reify();e!==d&&(c.realign(e),d=e),c.write(b)}}),c}imports["./pointer"]={},Object.defineProperty(a,"exports",{get:function(){return imports["./pointer"]},set:function(a){imports["./pointer"]=a}}),"use strict";var c=b("./genesis"),d=b("./numeric"),e=c.Subtype.bind(g);a.exports=g;var f=d.Uint32.typeDef("Address");c.Type(g,{DataType:"pointer",(get bytes(){return this.constructor.addressType.bytes}),reify:function(a){return this.pointee.reify(a)},write:function(a){this.pointee.write(a)},fill:function(a){this.pointee.fill(a)},pointTo:function(a){if(!a._data)throw new TypeError("Must point to reified <Data>");this.pointee=a,this.address.write(a._offset),this.memory=a._data},cast:function(a){return typeof a=="string"&&(a=c.lookupType(a)),c.nullable(this,"pointee"),this.__proto__=a.ptr.prototype,this}}),Object.defineProperty(g.prototype,"bytes",{configurable:!0,enumerable:!0,get:function(){return this.addressType.bytes}})}({},function(a){return imports[a]}),!function(a,b){function k(a,b,d){var e;if(typeof a=="number")e=a,a=null;else if(typeof a=="string")e=a.length,d=a,a=null;else if(a.bytes||a.byteLength)e=a.bytes||a.byteLength;var g=e;if(g in j)var h=j[g];else{var h=j[g]=f("CharArray"+g,g,function(a,b,d){return a||(a=new c.DataBuffer(this.bytes)),this.rebase(a),c.api(this,"_offset",b||0),d&&this.write(d),this});h.bytes=g,h.prototype.bytes=g,h.prototype.length=g}return a||d?(a||(a=new c.DataBuffer(g||d)),new h(a,b,d)):h}function l(a,b,d){if(typeof a=="string"||typeof a=="number"||!a)d=a,a=null;return this.rebase(a),c.api(this,"_offset",+b||0),d!=null&&this.write(d),this}imports["./string"]={},Object.defineProperty(a,"exports",{get:function(){return imports["./string"]},set:function(a){imports["./string"]=a}}),"use strict";var c=b("./genesis"),d=b("./numeric"),e=b("./array"),f=c.Subtype.bind(k);a.exports=k;var g=String.fromCharCode,h=Function.call.bind("".charCodeAt),i=function(){var a=1023,b=65536,c=b-2048,d=b-9216,e=b-10240;return function f(f){if(typeof f=="string"){var i=h(f,0);return i&c===e?b+((i&a)<<10)+(h(f,1)&a):i}if(isFinite(f))return f>=b?g((f-=b)>>>10&a|e)+g(d|f&a):g(f)}}(),j=[];c.Type(k,{DataType:"string",Subtype:"CharArray",bits:8,join:Array.prototype.join,map:Array.prototype.map,fill:function(a){this.write(0,a||0)},reify:function(){return this._data.subarray(this._offset,this.bytes).map(function(a){return i(a)}).join("")},write:function(a,b){var c=typeof a=="string";if(isFinite(b))c&&(a=i(a)),this._data["writeUint"+this.bits](b,a);else if(typeof a=="string"||a&&"length"in a){var d=this.bits/8;for(var e=0;e<a.length&&e<this.length;e++)this._data["writeUint"+this.bits](this._offset+e*d,i(a[e]))}}}),l.prototype={length:1,Subtype:"CharArray",bytes:1,write:function(a,b){return this._data["writeUint"+this.bits](this._offset,typeof a=="string"?i(a[b||0]):a),this},reify:function(a){return i(this._data["readUint"+this.bits](this._offset,1))},toNumber:function(a){return this._data["readUint"+this.bits](this._offset)}},l.__proto__=k.prototype,l.constructor=k,l.prototype.__proto__=k.prototype.prototype,l.bytes=l.prototype.bytes=l.prototype.length=1,l.prototype.constructor=l,j[1]=l}({},function(a){return imports[a]}),!function(a,b){function k(a,b,d,e){a=c.lookupType(a);if(k.prototype.isPrototypeOf(this))return new a(b,d,e);b=c.lookupType(b);if(!b||a.Class==="Type"&&!b)return a;if(b==="Char")return new h(a);if(typeof b=="string"||b.Class==="Type")return new k.ArrayType(a,b,d);if(typeof a!="undefined")return Array.isArray(b)||typeof b=="number"?new k.BitfieldType(a,b,d):(typeof a!="string"&&typeof b=="undefined"&&(b=a,a=""),b=Object.keys(b).reduce(function(a,c){if(b[c].Class!=="Type"){var d=k(b[c]);if(!d)return a;typeof d=="string"||d.Class!=="Type"?a[c]=k(c,b[c]):a[c]=d}else a[c]=b[c];return a},{}),new k.StructType(a,b))}function m(a,b){return!n(a,b).length}function n(a,b){return a.filter(function(a){return!~b.indexOf(a)})}function p(){return new o(this._data,this._offset)}imports["./index"]={},Object.defineProperty(a,"exports",{get:function(){return imports["./index"]},set:function(a){imports["./index"]=a}}),"use strict";var c=b("./genesis"),d=b("./numeric"),e=b("./struct"),f=b("./array"),g=b("./bitfield"),h=b("./string"),i=b("./pointer"),j=c.OpaqueType;a.exports=k,k.data=function(a,b,d,e){a=c.lookupType(a);if(typeof a=="string")throw new TypeError('Type not found "'+a+'"');return new a(b,d,e)},k.reify=function(a){if(a.Class==="Data")var b=Object.getPrototypeOf(a.constructor).prototype;return b.reify.call(a)},k.reifier=function(a,b){return a=k(a),a.reifier(b),a},k.isType=function(a){return c.Type.isPrototypeOf(a)},k.isData=function(a){return c.Type.prototype.isPrototypeOf(a)},Object.defineProperty(k,"defaultEndian",{enumerable:!0,configurable:!0,get:function(){return c.DataBuffer.prototype.endianness},set:function(a){if(a!=="LE"&&a!=="BE")throw new Error('Endianness must be "BE" or "LE"');c.DataBuffer.prototype.endianness=a}});var l=k("Opaque").ptr.typeDef("VoidPtr");l.prototype.reify=function(){return{type:l,address:this.address.reify()}},d.Uint64=new f("Uint64","Uint32",2),d.Int64=new f("Int64","Int32",2);var o=new f("EightByteOctetString","Uint8",8);d.Uint64.prototype.octets=p,d.Int64.prototype.octets=p,c.api(k,{Type:c.Type,NumericType:d,StructType:e,ArrayType:f,BitfieldType:g,DataBuffer:c.DataBuffer,CharType:h,PointerType:i,OpaqueType:j,VoidPtr:l,toString:function(){return"◤▼▼▼▼▼▼▼◥\n▶reified◀\n◣▲▲▲▲▲▲▲◢"}})}({},function(a){return imports[a]}),imports["./index"]}(this,{});typeof module!="undefined"&&(module.exports=reified),"use strict",function(a){function d(a,d,e,g,h){g===undefined&&f("Missing required offset argument"),(g<0||g+e>a.byteLength)&&f("Invalid index: "+g);if(e===1||!!h===b){if((a.byteOffset+g)%e===0)return(new d(a.buffer,a.byteOffset+g,1))[0];for(var i=0;i<e;i++)c[i]=a._bytes[g+i];return(new d(c.buffer))[0]}for(var i=0;i<e;i++)c[e-i-1]=a._bytes[g+i];return(new d(c.buffer))[0]}function e(a,d,e,g,h,i){g===undefined&&f("Missing required offset argument"),h===undefined&&f("Missing required value argument"),(g<0||g+e>a.byteLength)&&f("Invalid index: "+g);if(e===1||!!i===b)if((a.byteOffset+g)%e===0)(new d(a.buffer,a.byteOffset+g,1))[0]=h;else{(new d(c.buffer))[0]=h;for(var j=0;j<e;j++)a._bytes[j+g]=c[j]}else{(new d(c.buffer))[0]=h;for(var j=0;j<e;j++)a._bytes[g+j]=c[e-1-j]}}function f(a){throw new Error(a)}if(a.DataView)return;a.ArrayBuffer||f("ArrayBuffer not supported"),Object.defineProperties||f("This module requires ECMAScript 5");var b=(new Int8Array((new Int32Array([1])).buffer))[0]===1,c=new Uint8Array(8);a.DataView=function(a,b,c){a instanceof ArrayBuffer||f("Bad ArrayBuffer"),b=b||0,c=c||a.byteLength-b,(b<0||c<0||b+c>a.byteLength)&&f("Illegal offset and/or length"),Object.defineProperties(this,{buffer:{value:a,enumerable:!1,writable:!1,configurable:!1},byteOffset:{value:b,enumerable:!1,writable:!1,configurable:!1},byteLength:{value:c,enumerable:!1,writable:!1,configurable:!1},_bytes:{value:new Uint8Array(a,b,c),enumerable:!1,writable:!1,configurable:!1}})},a.DataView.prototype={constructor:DataView,getInt8:function(a){return d(this,Int8Array,1,a)},getUint8:function(a){return d(this,Uint8Array,1,a)},getInt16:function(a,b){return d(this,Int16Array,2,a,b)},getUint16:function(a,b){return d(this,Uint16Array,2,a,b)},getInt32:function(a,b){return d(this,Int32Array,4,a,b)},getUint32:function(a,b){return d(this,Uint32Array,4,a,b)},getFloat32:function(a,b){return d(this,Float32Array,4,a,b)},getFloat64:function(a,b){return d(this,Float64Array,8,a,b)},setInt8:function(a,b){e(this,Int8Array,1,a,b)},setUint8:function(a,b){e(this,Uint8Array,1,a,b)},setInt16:function(a,b,c){e(this,Int16Array,2,a,b,c)},setUint16:function(a,b,c){e(this,Uint16Array,2,a,b,c)},setInt32:function(a,b,c){e(this,Int32Array,4,a,b,c)},setUint32:function(a,b,c){e(this,Uint32Array,4,a,b,c)},setFloat32:function(a,b,c){e(this,Float32Array,4,a,b,c)},setFloat64:function(a,b,c){e(this,Float64Array,8,a,b,c)}}}(this)

0 comments on commit b0cbbe5

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