diff --git a/bower.json b/bower.json index 30288cf7c..c549d6d9b 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "protobuf", "description": "Protocol Buffers for JavaScript. Finally.", - "version": "3.5.1", + "version": "3.5.2", "main": "dist/ProtoBuf.js", "license": "Apache-2.0", "homepage": "http://dcode.io/", diff --git a/dist/ProtoBuf.js b/dist/ProtoBuf.js index 1aadb99ac..b0e64f558 100644 --- a/dist/ProtoBuf.js +++ b/dist/ProtoBuf.js @@ -38,7 +38,7 @@ * @const * @expose */ - ProtoBuf.VERSION = "3.5.1"; + ProtoBuf.VERSION = "3.5.2"; /** * Wire types. @@ -1464,7 +1464,7 @@ */ Namespace.prototype._indexOf = function(nameOrId) { var key = typeof nameOrId === 'number' ? 'id' : 'name'; - for (var i=0; i} */ Namespace.prototype.buildOpt = function() { - var opt = {}; - var keys = Object.keys(this.options); - for (var i=0; i obj.extensions[1]) throw Error("Illegal extended field id in message "+obj.name+": "+def['fields'][i]['id']+" ("+obj.extensions.join(' to ')+" expected)"); - // see #161: Extensions are referenced by their fully qualified name - var fqn = this.ptr.fqn()+'.'+def["fields"][i]["name"]; - obj.addChild(new Reflect.Message.ExtensionField(obj, def["fields"][i]["rule"], def["fields"][i]["type"], fqn, def["fields"][i]["id"], def["fields"][i]["options"])); + // see #161: Extensions use their fully qualified name as their runtime key, ... + var fld = new Reflect.Message.ExtensionField(obj, def["fields"][i]["rule"], def["fields"][i]["type"], this.ptr.fqn()+'.'+def["fields"][i]["name"], def["fields"][i]["id"], def["fields"][i]["options"]); + // ...are added on top of the current namespace as an extension and... + var ext = new Reflect.Extension(this.ptr, def["fields"][i]["name"], fld); + // ...use the current namespace to resolve types. + fld.scope = this.ptr; + this.ptr.addChild(ext); + obj.addChild(fld); } } else if (!/\.?google\.protobuf\./.test(def["ref"])) // Silently skip internal extensions throw Error("Extended message "+def["ref"]+" is not defined"); @@ -3790,7 +3837,7 @@ if (!Lang.TYPE.test(this.ptr.type)) { // Resolve type... if (!Lang.TYPEREF.test(this.ptr.type)) throw Error("Illegal type reference in "+this.ptr.toString(true)+": "+this.ptr.type); - res = this.ptr.parent.resolve(this.ptr.type, true); + res = this.ptr.scope.resolve(this.ptr.type, true); // this.ptr.parent if (!res) throw Error("Unresolvable type reference in "+this.ptr.toString(true)+": "+this.ptr.type); this.ptr.resolvedType = res; @@ -3818,6 +3865,8 @@ // Should not happen as nothing else is implemented throw Error("Illegal service type in "+this.ptr.toString(true)); } + } else if (this.ptr instanceof ProtoBuf.Reflect.Extension) { + // There are no runtime counterparts to extensions } else throw Error("Illegal object in namespace: "+typeof(this.ptr)+":"+this.ptr); this.reset(); diff --git a/dist/ProtoBuf.min.js b/dist/ProtoBuf.min.js index 937714e1b..4b1802245 100644 --- a/dist/ProtoBuf.min.js +++ b/dist/ProtoBuf.min.js @@ -3,7 +3,7 @@ Released under the Apache License, Version 2.0 see: https://github.com/dcodeIO/ProtoBuf.js for details */ -(function(q){function r(k){var g={VERSION:"3.5.1",WIRE_TYPES:{}};g.WIRE_TYPES.VARINT=0;g.WIRE_TYPES.BITS64=1;g.WIRE_TYPES.LDELIM=2;g.WIRE_TYPES.STARTGROUP=3;g.WIRE_TYPES.ENDGROUP=4;g.WIRE_TYPES.BITS32=5;g.PACKABLE_WIRE_TYPES=[g.WIRE_TYPES.VARINT,g.WIRE_TYPES.BITS64,g.WIRE_TYPES.BITS32];g.TYPES={int32:{name:"int32",wireType:g.WIRE_TYPES.VARINT},uint32:{name:"uint32",wireType:g.WIRE_TYPES.VARINT},sint32:{name:"sint32",wireType:g.WIRE_TYPES.VARINT},int64:{name:"int64",wireType:g.WIRE_TYPES.VARINT},uint64:{name:"uint64", +(function(r){function s(k){var g={VERSION:"3.5.2",WIRE_TYPES:{}};g.WIRE_TYPES.VARINT=0;g.WIRE_TYPES.BITS64=1;g.WIRE_TYPES.LDELIM=2;g.WIRE_TYPES.STARTGROUP=3;g.WIRE_TYPES.ENDGROUP=4;g.WIRE_TYPES.BITS32=5;g.PACKABLE_WIRE_TYPES=[g.WIRE_TYPES.VARINT,g.WIRE_TYPES.BITS64,g.WIRE_TYPES.BITS32];g.TYPES={int32:{name:"int32",wireType:g.WIRE_TYPES.VARINT},uint32:{name:"uint32",wireType:g.WIRE_TYPES.VARINT},sint32:{name:"sint32",wireType:g.WIRE_TYPES.VARINT},int64:{name:"int64",wireType:g.WIRE_TYPES.VARINT},uint64:{name:"uint64", wireType:g.WIRE_TYPES.VARINT},sint64:{name:"sint64",wireType:g.WIRE_TYPES.VARINT},bool:{name:"bool",wireType:g.WIRE_TYPES.VARINT},"double":{name:"double",wireType:g.WIRE_TYPES.BITS64},string:{name:"string",wireType:g.WIRE_TYPES.LDELIM},bytes:{name:"bytes",wireType:g.WIRE_TYPES.LDELIM},fixed32:{name:"fixed32",wireType:g.WIRE_TYPES.BITS32},sfixed32:{name:"sfixed32",wireType:g.WIRE_TYPES.BITS32},fixed64:{name:"fixed64",wireType:g.WIRE_TYPES.BITS64},sfixed64:{name:"sfixed64",wireType:g.WIRE_TYPES.BITS64}, "float":{name:"float",wireType:g.WIRE_TYPES.BITS32},"enum":{name:"enum",wireType:g.WIRE_TYPES.VARINT},message:{name:"message",wireType:g.WIRE_TYPES.LDELIM},group:{name:"group",wireType:g.WIRE_TYPES.STARTGROUP}};g.ID_MIN=1;g.ID_MAX=536870911;g.ByteBuffer=k;g.Long=k.Long||null;g.convertFieldsToCamelCase=!1;g.populateAccessors=!0;g.Util=function(){Object.create||(Object.create=function(e){function d(){}if(1a.remaining())return null;var c=a.offset,e=a.readVarint32();if(a.remaining()>3;if(l===d.WIRE_TYPES.ENDGROUP){if(k!==c)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+k+" ("+(c?c+" expected":"not a group")+")");break}if(h=this.getChild(k))h.repeated&&!h.options.packed?g.$add(h.name,h.decode(l,a),!0):g.$set(h.name,h.decode(l,a),!0);else switch(l){case d.WIRE_TYPES.VARINT:a.readVarint32();break;case d.WIRE_TYPES.BITS32:a.offset+=4;break;case d.WIRE_TYPES.BITS64:a.offset+=8;break;case d.WIRE_TYPES.LDELIM:h= +"$options",{value:d.buildOpt()});return e}(d,this);for(var c=this.getChildren(),e,f=0,g=c.length;f>3;if(l===d.WIRE_TYPES.ENDGROUP){if(k!==c)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+k+" ("+(c?c+" expected":"not a group")+")");break}if(h=this.getChild(k))h.repeated&&!h.options.packed?g.$add(h.name,h.decode(l,a),!0):g.$set(h.name,h.decode(l,a),!0);else switch(l){case d.WIRE_TYPES.VARINT:a.readVarint32();break;case d.WIRE_TYPES.BITS32:a.offset+=4;break;case d.WIRE_TYPES.BITS64:a.offset+=8;break;case d.WIRE_TYPES.LDELIM:h= a.readVarint32();a.offset+=h;break;case d.WIRE_TYPES.STARTGROUP:for(;e(k,a););break;default:throw Error("Illegal wire type for unknown field "+k+" in "+this.toString(!0)+"#decode: "+l);}}a=this.getChildren(d.Reflect.Field);for(b=0;ba?a>>>0:a;case d.TYPES.int64:case d.TYPES.sint64:case d.TYPES.sfixed64:if(d.Long)try{return g(a,!1)}catch(f){c(typeof a,f.message)}else c(typeof a,"requires Long.js");case d.TYPES.uint64:case d.TYPES.fixed64:if(d.Long)try{return g(a,!0)}catch(l){c(typeof a,l.message)}else c(typeof a,"requires Long.js");case d.TYPES.bool:return"boolean"!==typeof a&&c(typeof a,"not a boolean"),a;case d.TYPES["float"]:case d.TYPES["double"]:return"number"!== -typeof a&&c(typeof a,"not a number"),a;case d.TYPES.string:return"string"===typeof a||a&&a instanceof String||c(typeof a,"not a string"),""+a;case d.TYPES.bytes:return a&&a instanceof k?a:k.wrap(a);case d.TYPES["enum"]:var n=this.resolvedType.getChildren(h.Value);for(e=0;ea?b.writeVarint64(a):b.writeVarint32(a);break;case d.TYPES.uint32:b.writeVarint32(a);break;case d.TYPES.sint32:b.writeVarint32ZigZag(a);break;case d.TYPES.fixed32:b.writeUint32(a);break;case d.TYPES.sfixed32:b.writeInt32(a);break;case d.TYPES.int64:case d.TYPES.uint64:b.writeVarint64(a);break;case d.TYPES.sint64:b.writeVarint64ZigZag(a);break;case d.TYPES.fixed64:b.writeUint64(a); -break;case d.TYPES.sfixed64:b.writeInt64(a);break;case d.TYPES.bool:"string"===typeof a?b.writeVarint32("false"===a.toLowerCase()?0:!!a):b.writeVarint32(a?1:0);break;case d.TYPES["enum"]:b.writeVarint32(a);break;case d.TYPES["float"]:b.writeFloat32(a);break;case d.TYPES["double"]:b.writeFloat64(a);break;case d.TYPES.string:b.writeVString(a);break;case d.TYPES.bytes:if(0>a.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+a.remaining()+" bytes remaining");var c=a.offset;b.writeVarint32(a.remaining()); -b.append(a);a.offset=c;break;case d.TYPES.message:c=(new k).LE();this.resolvedType.encode(a,c);b.writeVarint32(c.offset);b.append(c.flip());break;case d.TYPES.group:this.resolvedType.encode(a,b);b.writeVarint32(this.id<<3|d.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+a+" (unknown type)");}return b};f.prototype.calculate=function(a){a=this.verifyValue(a);if(null===this.type||"object"!==typeof this.type)throw Error("[INTERNAL] Unresolved type in "+ -this.toString(!0)+": "+this.type);if(null===a||this.repeated&&0==a.length)return 0;var b=0;try{if(this.repeated){var c,e;if(this.options.packed&&0<=d.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)){b+=k.calculateVarint32(this.id<<3|d.WIRE_TYPES.LDELIM);for(c=e=0;ca?k.calculateVarint64(a):k.calculateVarint32(a);case d.TYPES.uint32:return k.calculateVarint32(a);case d.TYPES.sint32:return k.calculateVarint32(k.zigZagEncode32(a));case d.TYPES.fixed32:case d.TYPES.sfixed32:case d.TYPES["float"]:return 4;case d.TYPES.int64:case d.TYPES.uint64:return k.calculateVarint64(a); -case d.TYPES.sint64:return k.calculateVarint64(k.zigZagEncode64(a));case d.TYPES.fixed64:case d.TYPES.sfixed64:return 8;case d.TYPES.bool:return 1;case d.TYPES["enum"]:return k.calculateVarint32(a);case d.TYPES["double"]:return 8;case d.TYPES.string:return a=k.calculateUTF8Bytes(a),k.calculateVarint32(a)+a;case d.TYPES.bytes:if(0>a.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+a.remaining()+" bytes remaining");return k.calculateVarint32(a.remaining())+a.remaining();case d.TYPES.message:return a= -this.resolvedType.calculate(a),k.calculateVarint32(a)+a;case d.TYPES.group:return a=this.resolvedType.calculate(a),a+k.calculateVarint32(this.id<<3|d.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+a+" (unknown type)");};f.prototype.decode=function(a,b,c){if(a!=this.type.wireType&&(c||a!=d.WIRE_TYPES.LDELIM||!this.repeated))throw Error("Illegal wire type for field "+this.toString(!0)+": "+a+" ("+this.type.wireType+" expected)");if(a==d.WIRE_TYPES.LDELIM&& -this.repeated&&this.options.packed&&0<=d.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)&&!c){a=b.readVarint32();a=b.offset+a;for(c=[];b.offset>>0;case d.TYPES.sint32:return b.readVarint32ZigZag()|0;case d.TYPES.fixed32:return b.readUint32()>>>0;case d.TYPES.sfixed32:return b.readInt32()|0;case d.TYPES.int64:return b.readVarint64();case d.TYPES.uint64:return b.readVarint64().toUnsigned(); -case d.TYPES.sint64:return b.readVarint64ZigZag();case d.TYPES.fixed64:return b.readUint64();case d.TYPES.sfixed64:return b.readInt64();case d.TYPES.bool:return!!b.readVarint32();case d.TYPES["enum"]:return b.readVarint32();case d.TYPES["float"]:return b.readFloat();case d.TYPES["double"]:return b.readDouble();case d.TYPES.string:return b.readVString();case d.TYPES.bytes:a=b.readVarint32();if(b.remaining()d.ID_MAX&&(e.extensions[1]=d.ID_MAX));this.ptr.addChild(e);0e.extensions[1])throw Error("Illegal extended field id in message "+ -e.name+": "+a.fields[h].id+" ("+e.extensions.join(" to ")+" expected)");k=this.ptr.fqn()+"."+a.fields[h].name;e.addChild(new g.Message.ExtensionField(e,a.fields[h].rule,a.fields[h].type,k,a.fields[h].id,a.fields[h].options))}else{if(!/\.?google\.protobuf\./.test(a.ref))throw Error("Extended message "+a.ref+" is not defined");}else throw Error("Not a valid definition: "+JSON.stringify(a));else throw Error("Not a valid namespace: "+JSON.stringify(c));this.ptr=this.ptr.parent}this.resolved=!1;this.result= -null;return this};l.prototype["import"]=function(c,b){if("string"===typeof b){d.Util.IS_NODE&&(b=require("path").resolve(b));if(!0===this.files[b])return this.reset(),this;this.files[b]=!0}if(c.imports&&0a?a>>>0:a;case d.TYPES.int64:case d.TYPES.sint64:case d.TYPES.sfixed64:if(d.Long)try{return g(a,!1)}catch(f){c(typeof a,f.message)}else c(typeof a,"requires Long.js");case d.TYPES.uint64:case d.TYPES.fixed64:if(d.Long)try{return g(a,!0)}catch(l){c(typeof a,l.message)}else c(typeof a,"requires Long.js");case d.TYPES.bool:return"boolean"!== +typeof a&&c(typeof a,"not a boolean"),a;case d.TYPES["float"]:case d.TYPES["double"]:return"number"!==typeof a&&c(typeof a,"not a number"),a;case d.TYPES.string:return"string"===typeof a||a&&a instanceof String||c(typeof a,"not a string"),""+a;case d.TYPES.bytes:return a&&a instanceof k?a:k.wrap(a);case d.TYPES["enum"]:var n=this.resolvedType.getChildren(h.Value);for(e=0;ea?b.writeVarint64(a):b.writeVarint32(a);break;case d.TYPES.uint32:b.writeVarint32(a);break;case d.TYPES.sint32:b.writeVarint32ZigZag(a);break;case d.TYPES.fixed32:b.writeUint32(a);break;case d.TYPES.sfixed32:b.writeInt32(a); +break;case d.TYPES.int64:case d.TYPES.uint64:b.writeVarint64(a);break;case d.TYPES.sint64:b.writeVarint64ZigZag(a);break;case d.TYPES.fixed64:b.writeUint64(a);break;case d.TYPES.sfixed64:b.writeInt64(a);break;case d.TYPES.bool:"string"===typeof a?b.writeVarint32("false"===a.toLowerCase()?0:!!a):b.writeVarint32(a?1:0);break;case d.TYPES["enum"]:b.writeVarint32(a);break;case d.TYPES["float"]:b.writeFloat32(a);break;case d.TYPES["double"]:b.writeFloat64(a);break;case d.TYPES.string:b.writeVString(a); +break;case d.TYPES.bytes:if(0>a.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+a.remaining()+" bytes remaining");var c=a.offset;b.writeVarint32(a.remaining());b.append(a);a.offset=c;break;case d.TYPES.message:c=(new k).LE();this.resolvedType.encode(a,c);b.writeVarint32(c.offset);b.append(c.flip());break;case d.TYPES.group:this.resolvedType.encode(a,b);b.writeVarint32(this.id<<3|d.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+ +": "+a+" (unknown type)");}return b};f.prototype.calculate=function(a){a=this.verifyValue(a);if(null===this.type||"object"!==typeof this.type)throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===a||this.repeated&&0==a.length)return 0;var b=0;try{if(this.repeated){var c,e;if(this.options.packed&&0<=d.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)){b+=k.calculateVarint32(this.id<<3|d.WIRE_TYPES.LDELIM);for(c=e=0;ca?k.calculateVarint64(a):k.calculateVarint32(a);case d.TYPES.uint32:return k.calculateVarint32(a);case d.TYPES.sint32:return k.calculateVarint32(k.zigZagEncode32(a)); +case d.TYPES.fixed32:case d.TYPES.sfixed32:case d.TYPES["float"]:return 4;case d.TYPES.int64:case d.TYPES.uint64:return k.calculateVarint64(a);case d.TYPES.sint64:return k.calculateVarint64(k.zigZagEncode64(a));case d.TYPES.fixed64:case d.TYPES.sfixed64:return 8;case d.TYPES.bool:return 1;case d.TYPES["enum"]:return k.calculateVarint32(a);case d.TYPES["double"]:return 8;case d.TYPES.string:return a=k.calculateUTF8Bytes(a),k.calculateVarint32(a)+a;case d.TYPES.bytes:if(0>a.remaining())throw Error("Illegal value for "+ +this.toString(!0)+": "+a.remaining()+" bytes remaining");return k.calculateVarint32(a.remaining())+a.remaining();case d.TYPES.message:return a=this.resolvedType.calculate(a),k.calculateVarint32(a)+a;case d.TYPES.group:return a=this.resolvedType.calculate(a),a+k.calculateVarint32(this.id<<3|d.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+a+" (unknown type)");};f.prototype.decode=function(a,b,c){if(a!=this.type.wireType&&(c||a!=d.WIRE_TYPES.LDELIM|| +!this.repeated))throw Error("Illegal wire type for field "+this.toString(!0)+": "+a+" ("+this.type.wireType+" expected)");if(a==d.WIRE_TYPES.LDELIM&&this.repeated&&this.options.packed&&0<=d.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)&&!c){a=b.readVarint32();a=b.offset+a;for(c=[];b.offset>>0;case d.TYPES.sint32:return b.readVarint32ZigZag()| +0;case d.TYPES.fixed32:return b.readUint32()>>>0;case d.TYPES.sfixed32:return b.readInt32()|0;case d.TYPES.int64:return b.readVarint64();case d.TYPES.uint64:return b.readVarint64().toUnsigned();case d.TYPES.sint64:return b.readVarint64ZigZag();case d.TYPES.fixed64:return b.readUint64();case d.TYPES.sfixed64:return b.readInt64();case d.TYPES.bool:return!!b.readVarint32();case d.TYPES["enum"]:return b.readVarint32();case d.TYPES["float"]:return b.readFloat();case d.TYPES["double"]:return b.readDouble(); +case d.TYPES.string:return b.readVString();case d.TYPES.bytes:a=b.readVarint32();if(b.remaining()d.ID_MAX&&(e.extensions[1]=d.ID_MAX));this.ptr.addChild(e);0e.extensions[1])throw Error("Illegal extended field id in message "+e.name+": "+a.fields[h].id+" ("+e.extensions.join(" to ")+" expected)");k=new g.Message.ExtensionField(e,a.fields[h].rule,a.fields[h].type,this.ptr.fqn()+"."+a.fields[h].name,a.fields[h].id,a.fields[h].options);p=new g.Extension(this.ptr,a.fields[h].name,k);k.scope=this.ptr;this.ptr.addChild(p);e.addChild(k)}else{if(!/\.?google\.protobuf\./.test(a.ref))throw Error("Extended message "+ +a.ref+" is not defined");}else throw Error("Not a valid definition: "+JSON.stringify(a));else throw Error("Not a valid namespace: "+JSON.stringify(c));this.ptr=this.ptr.parent}this.resolved=!1;this.result=null;return this};l.prototype["import"]=function(c,b){if("string"===typeof b){d.Util.IS_NODE&&(b=require("path").resolve(b));if(!0===this.files[b])return this.reset(),this;this.files[b]=!0}if(c.imports&&0} */ Namespace.prototype.buildOpt = function() { - var opt = {}; - var keys = Object.keys(this.options); - for (var i=0; i obj.extensions[1]) throw Error("Illegal extended field id in message "+obj.name+": "+def['fields'][i]['id']+" ("+obj.extensions.join(' to ')+" expected)"); - // see #161: Extensions are referenced by their fully qualified name - var fqn = this.ptr.fqn()+'.'+def["fields"][i]["name"]; - obj.addChild(new Reflect.Message.ExtensionField(obj, def["fields"][i]["rule"], def["fields"][i]["type"], fqn, def["fields"][i]["id"], def["fields"][i]["options"])); + // see #161: Extensions use their fully qualified name as their runtime key, ... + var fld = new Reflect.Message.ExtensionField(obj, def["fields"][i]["rule"], def["fields"][i]["type"], this.ptr.fqn()+'.'+def["fields"][i]["name"], def["fields"][i]["id"], def["fields"][i]["options"]); + // ...are added on top of the current namespace as an extension and... + var ext = new Reflect.Extension(this.ptr, def["fields"][i]["name"], fld); + // ...use the current namespace to resolve types. + fld.scope = this.ptr; + this.ptr.addChild(ext); + obj.addChild(fld); } } else if (!/\.?google\.protobuf\./.test(def["ref"])) // Silently skip internal extensions throw Error("Extended message "+def["ref"]+" is not defined"); @@ -2920,7 +2967,7 @@ if (!Lang.TYPE.test(this.ptr.type)) { // Resolve type... if (!Lang.TYPEREF.test(this.ptr.type)) throw Error("Illegal type reference in "+this.ptr.toString(true)+": "+this.ptr.type); - res = this.ptr.parent.resolve(this.ptr.type, true); + res = this.ptr.scope.resolve(this.ptr.type, true); // this.ptr.parent if (!res) throw Error("Unresolvable type reference in "+this.ptr.toString(true)+": "+this.ptr.type); this.ptr.resolvedType = res; @@ -2948,6 +2995,8 @@ // Should not happen as nothing else is implemented throw Error("Illegal service type in "+this.ptr.toString(true)); } + } else if (this.ptr instanceof ProtoBuf.Reflect.Extension) { + // There are no runtime counterparts to extensions } else throw Error("Illegal object in namespace: "+typeof(this.ptr)+":"+this.ptr); this.reset(); diff --git a/dist/ProtoBuf.noparse.min.js b/dist/ProtoBuf.noparse.min.js index 6d6f10f83..d77625136 100644 --- a/dist/ProtoBuf.noparse.min.js +++ b/dist/ProtoBuf.noparse.min.js @@ -3,70 +3,70 @@ Released under the Apache License, Version 2.0 see: https://github.com/dcodeIO/ProtoBuf.js for details */ -(function(s){function t(k){var g={VERSION:"3.5.1",WIRE_TYPES:{}};g.WIRE_TYPES.VARINT=0;g.WIRE_TYPES.BITS64=1;g.WIRE_TYPES.LDELIM=2;g.WIRE_TYPES.STARTGROUP=3;g.WIRE_TYPES.ENDGROUP=4;g.WIRE_TYPES.BITS32=5;g.PACKABLE_WIRE_TYPES=[g.WIRE_TYPES.VARINT,g.WIRE_TYPES.BITS64,g.WIRE_TYPES.BITS32];g.TYPES={int32:{name:"int32",wireType:g.WIRE_TYPES.VARINT},uint32:{name:"uint32",wireType:g.WIRE_TYPES.VARINT},sint32:{name:"sint32",wireType:g.WIRE_TYPES.VARINT},int64:{name:"int64",wireType:g.WIRE_TYPES.VARINT},uint64:{name:"uint64", -wireType:g.WIRE_TYPES.VARINT},sint64:{name:"sint64",wireType:g.WIRE_TYPES.VARINT},bool:{name:"bool",wireType:g.WIRE_TYPES.VARINT},"double":{name:"double",wireType:g.WIRE_TYPES.BITS64},string:{name:"string",wireType:g.WIRE_TYPES.LDELIM},bytes:{name:"bytes",wireType:g.WIRE_TYPES.LDELIM},fixed32:{name:"fixed32",wireType:g.WIRE_TYPES.BITS32},sfixed32:{name:"sfixed32",wireType:g.WIRE_TYPES.BITS32},fixed64:{name:"fixed64",wireType:g.WIRE_TYPES.BITS64},sfixed64:{name:"sfixed64",wireType:g.WIRE_TYPES.BITS64}, -"float":{name:"float",wireType:g.WIRE_TYPES.BITS32},"enum":{name:"enum",wireType:g.WIRE_TYPES.VARINT},message:{name:"message",wireType:g.WIRE_TYPES.LDELIM},group:{name:"group",wireType:g.WIRE_TYPES.STARTGROUP}};g.ID_MIN=1;g.ID_MAX=536870911;g.ByteBuffer=k;g.Long=k.Long||null;g.convertFieldsToCamelCase=!1;g.populateAccessors=!0;g.Util=function(){Object.create||(Object.create=function(c){function m(){}if(1>3;switch(d){case c.WIRE_TYPES.VARINT:do b=f.readUint8();while(128===(b&128));break;case c.WIRE_TYPES.BITS64:f.offset+=8;break;case c.WIRE_TYPES.LDELIM:b=f.readVarint32();f.offset+=b;break;case c.WIRE_TYPES.STARTGROUP:g(b,f);break;case c.WIRE_TYPES.ENDGROUP:if(b===a)return!1;throw Error("Illegal GROUPEND after unknown group: "+ -b+" ("+a+" expected)");case c.WIRE_TYPES.BITS32:f.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+a+": "+d);}return!0}function r(a,f){if(a&&"number"===typeof a.low&&"number"===typeof a.high&&"boolean"===typeof a.unsigned&&a.low===a.low&&a.high===a.high)return new c.Long(a.low,a.high,"undefined"===typeof f?a.unsigned:f);if("string"===typeof a)return c.Long.fromString(a,f||!1,10);if("number"===typeof a)return c.Long.fromNumber(a,f||!1);throw Error("not convertible to Long"); -}var m={},b=function(a,f){this.parent=a;this.name=f};b.prototype.fqn=function(){var a=this.name,f=this;do{f=f.parent;if(null==f)break;a=f.name+"."+a}while(1);return a};b.prototype.toString=function(a){return(a?this.className+" ":"")+this.fqn()};b.prototype.build=function(){throw Error(this.toString(!0)+" cannot be built directly");};m.T=b;var e=function(a,f,c){b.call(this,a,f);this.className="Namespace";this.children=[];this.options=c||{}};e.prototype=Object.create(b.prototype);e.prototype.getChildren= -function(a){a=a||null;if(null==a)return this.children.slice();for(var f=[],c=0,b=this.children.length;c>3;switch(d){case c.WIRE_TYPES.VARINT:do b=l.readUint8();while(128===(b&128));break;case c.WIRE_TYPES.BITS64:l.offset+=8;break;case c.WIRE_TYPES.LDELIM:b=l.readVarint32();l.offset+=b;break;case c.WIRE_TYPES.STARTGROUP:f(b,l);break;case c.WIRE_TYPES.ENDGROUP:if(b===a)return!1;throw Error("Illegal GROUPEND after unknown group: "+ +b+" ("+a+" expected)");case c.WIRE_TYPES.BITS32:l.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+a+": "+d);}return!0}function r(a,l){if(a&&"number"===typeof a.low&&"number"===typeof a.high&&"boolean"===typeof a.unsigned&&a.low===a.low&&a.high===a.high)return new c.Long(a.low,a.high,"undefined"===typeof l?a.unsigned:l);if("string"===typeof a)return c.Long.fromString(a,l||!1,10);if("number"===typeof a)return c.Long.fromNumber(a,l||!1);throw Error("not convertible to Long"); +}var m={},b=function(a,l){this.parent=a;this.name=l};b.prototype.fqn=function(){var a=this.name,l=this;do{l=l.parent;if(null==l)break;a=l.name+"."+a}while(1);return a};b.prototype.toString=function(a){return(a?this.className+" ":"")+this.fqn()};b.prototype.build=function(){throw Error(this.toString(!0)+" cannot be built directly");};m.T=b;var e=function(a,l,c){b.call(this,a,l);this.className="Namespace";this.children=[];this.options=c||{}};e.prototype=Object.create(b.prototype);e.prototype.getChildren= +function(a){a=a||null;if(null==a)return this.children.slice();for(var l=[],b=0,c=this.children.length;ba.remaining())return null;var f=a.offset,d=a.readVarint32();if(a.remaining()>3;if(m===c.WIRE_TYPES.ENDGROUP){if(k!==d)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+k+" ("+(d?d+" expected":"not a group")+")");break}if(h=this.getChild(k))h.repeated&&!h.options.packed?l.$add(h.name,h.decode(m,a),!0):l.$set(h.name,h.decode(m,a),!0);else switch(m){case c.WIRE_TYPES.VARINT:a.readVarint32(); -break;case c.WIRE_TYPES.BITS32:a.offset+=4;break;case c.WIRE_TYPES.BITS64:a.offset+=8;break;case c.WIRE_TYPES.LDELIM:h=a.readVarint32();a.offset+=h;break;case c.WIRE_TYPES.STARTGROUP:for(;g(k,a););break;default:throw Error("Illegal wire type for unknown field "+k+" in "+this.toString(!0)+"#decode: "+m);}}a=this.getChildren(c.Reflect.Field);for(b=0;ba?a>>>0:a;case c.TYPES.int64:case c.TYPES.sint64:case c.TYPES.sfixed64:if(c.Long)try{return r(a,!1)}catch(l){d(typeof a,l.message)}else d(typeof a,"requires Long.js");case c.TYPES.uint64:case c.TYPES.fixed64:if(c.Long)try{return r(a,!0)}catch(m){d(typeof a,m.message)}else d(typeof a,"requires Long.js");case c.TYPES.bool:return"boolean"!== -typeof a&&d(typeof a,"not a boolean"),a;case c.TYPES["float"]:case c.TYPES["double"]:return"number"!==typeof a&&d(typeof a,"not a number"),a;case c.TYPES.string:return"string"===typeof a||a&&a instanceof String||d(typeof a,"not a string"),""+a;case c.TYPES.bytes:return a&&a instanceof k?a:k.wrap(a);case c.TYPES["enum"]:var g=this.resolvedType.getChildren(h.Value);for(e=0;ea?b.writeVarint64(a):b.writeVarint32(a);break;case c.TYPES.uint32:b.writeVarint32(a);break;case c.TYPES.sint32:b.writeVarint32ZigZag(a);break;case c.TYPES.fixed32:b.writeUint32(a);break;case c.TYPES.sfixed32:b.writeInt32(a); +typeof a&&(a=k.wrap(a,c?c:"base64"));a=a instanceof k?a:k.wrap(a);var l=a.littleEndian;try{var d=b.decode(a.LE());a.LE(l);return d}catch(e){throw a.LE(l),e;}};d.decodeDelimited=function(a,c){"string"===typeof a&&(a=k.wrap(a,c?c:"base64"));a=a instanceof k?a:k.wrap(a);if(1>a.remaining())return null;var l=a.offset,d=a.readVarint32();if(a.remaining()>3;if(m===c.WIRE_TYPES.ENDGROUP){if(k!==d)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+k+" ("+(d?d+" expected":"not a group")+")");break}if(h=this.getChild(k))h.repeated&&!h.options.packed?g.$add(h.name,h.decode(m,a),!0):g.$set(h.name,h.decode(m,a),!0);else switch(m){case c.WIRE_TYPES.VARINT:a.readVarint32(); +break;case c.WIRE_TYPES.BITS32:a.offset+=4;break;case c.WIRE_TYPES.BITS64:a.offset+=8;break;case c.WIRE_TYPES.LDELIM:h=a.readVarint32();a.offset+=h;break;case c.WIRE_TYPES.STARTGROUP:for(;f(k,a););break;default:throw Error("Illegal wire type for unknown field "+k+" in "+this.toString(!0)+"#decode: "+m);}}a=this.getChildren(c.Reflect.Field);for(b=0;ba?a>>>0:a;case c.TYPES.int64:case c.TYPES.sint64:case c.TYPES.sfixed64:if(c.Long)try{return r(a,!1)}catch(g){d(typeof a,g.message)}else d(typeof a,"requires Long.js");case c.TYPES.uint64:case c.TYPES.fixed64:if(c.Long)try{return r(a,!0)}catch(m){d(typeof a,m.message)}else d(typeof a,"requires Long.js");case c.TYPES.bool:return"boolean"!== +typeof a&&d(typeof a,"not a boolean"),a;case c.TYPES["float"]:case c.TYPES["double"]:return"number"!==typeof a&&d(typeof a,"not a number"),a;case c.TYPES.string:return"string"===typeof a||a&&a instanceof String||d(typeof a,"not a string"),""+a;case c.TYPES.bytes:return a&&a instanceof k?a:k.wrap(a);case c.TYPES["enum"]:var f=this.resolvedType.getChildren(h.Value);for(e=0;ea?b.writeVarint64(a):b.writeVarint32(a);break;case c.TYPES.uint32:b.writeVarint32(a);break;case c.TYPES.sint32:b.writeVarint32ZigZag(a);break;case c.TYPES.fixed32:b.writeUint32(a);break;case c.TYPES.sfixed32:b.writeInt32(a); break;case c.TYPES.int64:case c.TYPES.uint64:b.writeVarint64(a);break;case c.TYPES.sint64:b.writeVarint64ZigZag(a);break;case c.TYPES.fixed64:b.writeUint64(a);break;case c.TYPES.sfixed64:b.writeInt64(a);break;case c.TYPES.bool:"string"===typeof a?b.writeVarint32("false"===a.toLowerCase()?0:!!a):b.writeVarint32(a?1:0);break;case c.TYPES["enum"]:b.writeVarint32(a);break;case c.TYPES["float"]:b.writeFloat32(a);break;case c.TYPES["double"]:b.writeFloat64(a);break;case c.TYPES.string:b.writeVString(a); break;case c.TYPES.bytes:if(0>a.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+a.remaining()+" bytes remaining");var d=a.offset;b.writeVarint32(a.remaining());b.append(a);a.offset=d;break;case c.TYPES.message:d=(new k).LE();this.resolvedType.encode(a,d);b.writeVarint32(d.offset);b.append(d.flip());break;case c.TYPES.group:this.resolvedType.encode(a,b);b.writeVarint32(this.id<<3|c.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+ -": "+a+" (unknown type)");}return b};l.prototype.calculate=function(a){a=this.verifyValue(a);if(null===this.type||"object"!==typeof this.type)throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===a||this.repeated&&0==a.length)return 0;var b=0;try{if(this.repeated){var d,e;if(this.options.packed&&0<=c.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)){b+=k.calculateVarint32(this.id<<3|c.WIRE_TYPES.LDELIM);for(d=e=0;da?k.calculateVarint64(a):k.calculateVarint32(a);case c.TYPES.uint32:return k.calculateVarint32(a);case c.TYPES.sint32:return k.calculateVarint32(k.zigZagEncode32(a)); +": "+a+" (unknown type)");}return b};g.prototype.calculate=function(a){a=this.verifyValue(a);if(null===this.type||"object"!==typeof this.type)throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===a||this.repeated&&0==a.length)return 0;var b=0;try{if(this.repeated){var d,e;if(this.options.packed&&0<=c.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)){b+=k.calculateVarint32(this.id<<3|c.WIRE_TYPES.LDELIM);for(d=e=0;da?k.calculateVarint64(a):k.calculateVarint32(a);case c.TYPES.uint32:return k.calculateVarint32(a);case c.TYPES.sint32:return k.calculateVarint32(k.zigZagEncode32(a)); case c.TYPES.fixed32:case c.TYPES.sfixed32:case c.TYPES["float"]:return 4;case c.TYPES.int64:case c.TYPES.uint64:return k.calculateVarint64(a);case c.TYPES.sint64:return k.calculateVarint64(k.zigZagEncode64(a));case c.TYPES.fixed64:case c.TYPES.sfixed64:return 8;case c.TYPES.bool:return 1;case c.TYPES["enum"]:return k.calculateVarint32(a);case c.TYPES["double"]:return 8;case c.TYPES.string:return a=k.calculateUTF8Bytes(a),k.calculateVarint32(a)+a;case c.TYPES.bytes:if(0>a.remaining())throw Error("Illegal value for "+ -this.toString(!0)+": "+a.remaining()+" bytes remaining");return k.calculateVarint32(a.remaining())+a.remaining();case c.TYPES.message:return a=this.resolvedType.calculate(a),k.calculateVarint32(a)+a;case c.TYPES.group:return a=this.resolvedType.calculate(a),a+k.calculateVarint32(this.id<<3|c.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+a+" (unknown type)");};l.prototype.decode=function(a,b,d){if(a!=this.type.wireType&&(d||a!=c.WIRE_TYPES.LDELIM|| +this.toString(!0)+": "+a.remaining()+" bytes remaining");return k.calculateVarint32(a.remaining())+a.remaining();case c.TYPES.message:return a=this.resolvedType.calculate(a),k.calculateVarint32(a)+a;case c.TYPES.group:return a=this.resolvedType.calculate(a),a+k.calculateVarint32(this.id<<3|c.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+a+" (unknown type)");};g.prototype.decode=function(a,b,d){if(a!=this.type.wireType&&(d||a!=c.WIRE_TYPES.LDELIM|| !this.repeated))throw Error("Illegal wire type for field "+this.toString(!0)+": "+a+" ("+this.type.wireType+" expected)");if(a==c.WIRE_TYPES.LDELIM&&this.repeated&&this.options.packed&&0<=c.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)&&!d){a=b.readVarint32();a=b.offset+a;for(d=[];b.offset>>0;case c.TYPES.sint32:return b.readVarint32ZigZag()| 0;case c.TYPES.fixed32:return b.readUint32()>>>0;case c.TYPES.sfixed32:return b.readInt32()|0;case c.TYPES.int64:return b.readVarint64();case c.TYPES.uint64:return b.readVarint64().toUnsigned();case c.TYPES.sint64:return b.readVarint64ZigZag();case c.TYPES.fixed64:return b.readUint64();case c.TYPES.sfixed64:return b.readInt64();case c.TYPES.bool:return!!b.readVarint32();case c.TYPES["enum"]:return b.readVarint32();case c.TYPES["float"]:return b.readFloat();case c.TYPES["double"]:return b.readDouble(); -case c.TYPES.string:return b.readVString();case c.TYPES.bytes:a=b.readVarint32();if(b.remaining()c.ID_MAX&&(l.extensions[1]=c.ID_MAX));this.ptr.addChild(l);0l.extensions[1])throw Error("Illegal extended field id in message "+l.name+": "+d.fields[h].id+" ("+l.extensions.join(" to ")+" expected)");g=this.ptr.fqn()+"."+d.fields[h].name;l.addChild(new k.Message.ExtensionField(l,d.fields[h].rule,d.fields[h].type,g,d.fields[h].id,d.fields[h].options))}else{if(!/\.?google\.protobuf\./.test(d.ref))throw Error("Extended message "+d.ref+" is not defined");}else throw Error("Not a valid definition: "+ -JSON.stringify(d));else throw Error("Not a valid namespace: "+JSON.stringify(b));this.ptr=this.ptr.parent}this.resolved=!1;this.result=null;return this};m.prototype["import"]=function(b,e){if("string"===typeof e){c.Util.IS_NODE&&(e=require("path").resolve(e));if(!0===this.files[e])return this.reset(),this;this.files[e]=!0}if(b.imports&&0c.ID_MAX&&(g.extensions[1]=c.ID_MAX));this.ptr.addChild(g);0g.extensions[1])throw Error("Illegal extended field id in message "+g.name+": "+d.fields[h].id+" ("+g.extensions.join(" to ")+" expected)");f=new k.Message.ExtensionField(g,d.fields[h].rule,d.fields[h].type,this.ptr.fqn()+"."+d.fields[h].name,d.fields[h].id,d.fields[h].options);n=new k.Extension(this.ptr,d.fields[h].name,f);f.scope=this.ptr;this.ptr.addChild(n);g.addChild(f)}else{if(!/\.?google\.protobuf\./.test(d.ref))throw Error("Extended message "+ +d.ref+" is not defined");}else throw Error("Not a valid definition: "+JSON.stringify(d));else throw Error("Not a valid namespace: "+JSON.stringify(b));this.ptr=this.ptr.parent}this.resolved=!1;this.result=null;return this};m.prototype["import"]=function(b,e){if("string"===typeof e){c.Util.IS_NODE&&(e=require("path").resolve(e));if(!0===this.files[e])return this.reset(),this;this.files[e]=!0}if(b.imports&&0Parameters:
Source:
@@ -299,7 +299,7 @@
Type:
Source:
@@ -365,7 +365,7 @@
Type:
Source:
@@ -532,7 +532,7 @@
Parameters:
Source:
@@ -709,7 +709,7 @@
Parameters:
Source:
@@ -929,7 +929,7 @@
Parameters:
Source:
@@ -1097,7 +1097,7 @@
Parameters:
Source:
@@ -1339,7 +1339,7 @@
Parameters:
Source:
@@ -1500,7 +1500,7 @@
Parameters:
Source:
@@ -1679,7 +1679,7 @@
Parameters:
Source:
@@ -1921,7 +1921,7 @@
Parameters:
Source:
@@ -2141,7 +2141,7 @@
Parameters:
Source:
@@ -2239,7 +2239,7 @@

calculateSource:
@@ -2359,7 +2359,7 @@

encode64Source:
@@ -2479,7 +2479,7 @@

encodeABSource:
@@ -2662,7 +2662,7 @@
Parameters:
Source:
@@ -2782,7 +2782,7 @@

encodeHexSource:
@@ -2902,7 +2902,7 @@

encodeNBSource:
@@ -3066,7 +3066,7 @@
Parameters:
Source:
@@ -3187,7 +3187,7 @@

(abstract) Source:
@@ -3281,7 +3281,7 @@

(abstract) <
Source:
@@ -3496,7 +3496,7 @@
Parameters:
Source:
@@ -3643,7 +3643,7 @@
Parameters:
Source:
@@ -3790,7 +3790,7 @@
Parameters:
Source:
@@ -3888,7 +3888,7 @@

toArrayB
Source:
@@ -4008,7 +4008,7 @@

toBase64Source:
@@ -4128,7 +4128,7 @@

toBufferSource:
@@ -4244,7 +4244,7 @@

toHexSource:
@@ -4364,7 +4364,7 @@

toStringSource:
@@ -4429,13 +4429,13 @@
Returns:

- Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 21:39:47 GMT+0200 (Mitteleuropäische Sommerzeit) + Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 23:39:42 GMT+0200 (Mitteleuropäische Sommerzeit)
diff --git a/docs/ProtoBuf.Builder.Service.html b/docs/ProtoBuf.Builder.Service.html index 50ec7d602..249aea52d 100644 --- a/docs/ProtoBuf.Builder.Service.html +++ b/docs/ProtoBuf.Builder.Service.html @@ -144,7 +144,7 @@
Parameters:
Source:
@@ -265,7 +265,7 @@
Type:
Source:
@@ -427,7 +427,7 @@
Parameters:
Source:
@@ -570,7 +570,7 @@
Parameters:
Source:
@@ -613,13 +613,13 @@
Parameters:

- Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 21:39:47 GMT+0200 (Mitteleuropäische Sommerzeit) + Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 23:39:42 GMT+0200 (Mitteleuropäische Sommerzeit)
diff --git a/docs/ProtoBuf.Builder.html b/docs/ProtoBuf.Builder.html index e6c24ea29..dc38cb8f3 100644 --- a/docs/ProtoBuf.Builder.html +++ b/docs/ProtoBuf.Builder.html @@ -84,7 +84,7 @@

new BuilderSource:
@@ -188,7 +188,7 @@
Type:
Source:
@@ -254,7 +254,7 @@
Type:
Source:
@@ -320,7 +320,7 @@
Type:
Source:
@@ -386,7 +386,7 @@
Type:
Source:
@@ -452,7 +452,7 @@
Type:
Source:
@@ -521,7 +521,7 @@
Type:
Source:
@@ -636,7 +636,7 @@
Parameters:
Source:
@@ -777,7 +777,7 @@
Parameters:
Source:
@@ -918,7 +918,7 @@
Parameters:
Source:
@@ -1059,7 +1059,7 @@
Parameters:
Source:
@@ -1200,7 +1200,7 @@
Parameters:
Source:
@@ -1387,7 +1387,7 @@
Parameters:
Source:
@@ -1568,7 +1568,7 @@
Parameters:
Source:
@@ -1735,7 +1735,7 @@
Parameters:
Source:
@@ -1946,7 +1946,7 @@
Parameters:
Source:
@@ -2126,7 +2126,7 @@
Parameters:
Source:
@@ -2219,7 +2219,7 @@

resetSource:
@@ -2290,7 +2290,7 @@

resolveAll<
Source:
@@ -2388,7 +2388,7 @@

toStringSource:
@@ -2453,13 +2453,13 @@
Returns:

- Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 21:39:47 GMT+0200 (Mitteleuropäische Sommerzeit) + Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 23:39:42 GMT+0200 (Mitteleuropäische Sommerzeit)
diff --git a/docs/ProtoBuf.DotProto.Parser.html b/docs/ProtoBuf.DotProto.Parser.html index 3387b8e79..089dc1eb6 100644 --- a/docs/ProtoBuf.DotProto.Parser.html +++ b/docs/ProtoBuf.DotProto.Parser.html @@ -474,13 +474,13 @@
Returns:

- Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 21:39:47 GMT+0200 (Mitteleuropäische Sommerzeit) + Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 23:39:42 GMT+0200 (Mitteleuropäische Sommerzeit)
diff --git a/docs/ProtoBuf.DotProto.Tokenizer.html b/docs/ProtoBuf.DotProto.Tokenizer.html index fa4919fd5..293829295 100644 --- a/docs/ProtoBuf.DotProto.Tokenizer.html +++ b/docs/ProtoBuf.DotProto.Tokenizer.html @@ -928,13 +928,13 @@
Returns:

- Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 21:39:47 GMT+0200 (Mitteleuropäische Sommerzeit) + Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 23:39:42 GMT+0200 (Mitteleuropäische Sommerzeit)
diff --git a/docs/ProtoBuf.DotProto.html b/docs/ProtoBuf.DotProto.html index 96a1a92bb..797346d80 100644 --- a/docs/ProtoBuf.DotProto.html +++ b/docs/ProtoBuf.DotProto.html @@ -121,13 +121,13 @@

Classes


- Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 21:39:47 GMT+0200 (Mitteleuropäische Sommerzeit) + Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 23:39:42 GMT+0200 (Mitteleuropäische Sommerzeit)
diff --git a/docs/ProtoBuf.Reflect.Enum.Value.html b/docs/ProtoBuf.Reflect.Enum.Value.html index f0b673091..62fd4725b 100644 --- a/docs/ProtoBuf.Reflect.Enum.Value.html +++ b/docs/ProtoBuf.Reflect.Enum.Value.html @@ -176,7 +176,7 @@
Parameters:
Source:
@@ -262,7 +262,7 @@

classNameSource:
@@ -328,7 +328,7 @@
Type:
Source:
@@ -859,13 +859,13 @@
Returns:

- Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 21:39:47 GMT+0200 (Mitteleuropäische Sommerzeit) + Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 23:39:42 GMT+0200 (Mitteleuropäische Sommerzeit)
diff --git a/docs/ProtoBuf.Reflect.Enum.html b/docs/ProtoBuf.Reflect.Enum.html index 7bd79911a..7f4827a93 100644 --- a/docs/ProtoBuf.Reflect.Enum.html +++ b/docs/ProtoBuf.Reflect.Enum.html @@ -204,7 +204,7 @@
Parameters:
Source:
@@ -368,7 +368,7 @@

classNameSource:
@@ -508,7 +508,7 @@
Type:
Source:
@@ -871,7 +871,7 @@

buildSource:
@@ -965,7 +965,7 @@

buildOptSource:
@@ -1520,7 +1520,7 @@
Parameters:
Source:
@@ -1724,7 +1724,7 @@
Returns:
-

resolve(qn, excludeFieldsopt) → {ProtoBuf.Reflect.Namespace|null}

+

resolve(qn, excludeFieldsopt) → (nullable) {ProtoBuf.Reflect.Namespace}

@@ -1900,9 +1900,6 @@
Returns:
ProtoBuf.Reflect.Namespace -| - -null
@@ -2075,13 +2072,13 @@
Returns:

- Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 21:39:47 GMT+0200 (Mitteleuropäische Sommerzeit) + Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 23:39:42 GMT+0200 (Mitteleuropäische Sommerzeit)
diff --git a/docs/ProtoBuf.Reflect.Extension.html b/docs/ProtoBuf.Reflect.Extension.html new file mode 100644 index 000000000..903b58f05 --- /dev/null +++ b/docs/ProtoBuf.Reflect.Extension.html @@ -0,0 +1,320 @@ + + + + + JSDoc: Class: Extension + + + + + + + + + + +
+ +

Class: Extension

+ + + + + +
+ +
+

+ ProtoBuf.Reflect. + + Extension +

+ +
+ +
+
+ + + + +
+

new Extension(parent, name, fieldnon-null)

+ + +
+
+ + +
+

An extension (field).

+
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
parent + + +ProtoBuf.Reflect.T + + + +

Parent object

name + + +string + + + +

Object name

field + + +ProtoBuf.Reflect.Message.Field + + + +

Extension field

+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Members

+ +
+ +
+

(non-null) field :ProtoBuf.Reflect.Message.Field

+ + +
+
+ +
+

Extended message field.

+
+ + + +
Type:
+ + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + +
+ +
+ + + + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 23:39:42 GMT+0200 (Mitteleuropäische Sommerzeit) +
+ + + + + \ No newline at end of file diff --git a/docs/ProtoBuf.Reflect.Message.ExtensionField.html b/docs/ProtoBuf.Reflect.Message.ExtensionField.html index 445d6576d..b4a9991a8 100644 --- a/docs/ProtoBuf.Reflect.Message.ExtensionField.html +++ b/docs/ProtoBuf.Reflect.Message.ExtensionField.html @@ -297,7 +297,7 @@
Parameters:
Source:
@@ -388,7 +388,7 @@

classNameSource:
@@ -459,7 +459,7 @@
Type:
Source:
@@ -601,7 +601,7 @@
Type:
Source:
@@ -672,7 +672,7 @@
Type:
Source:
@@ -817,7 +817,7 @@
Type:
Source:
@@ -888,7 +888,7 @@
Type:
Source:
@@ -962,7 +962,78 @@
Type:
Source:
+ + + + + + + + + + + + + + + + + +
+

(non-null) scope :ProtoBuf.Reflect.Message

+ + +
+
+ +
+

Scope used to resolve the type.

+
+ + + +
Type:
+ + + + +
+ + + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + +
Source:
+
@@ -1036,7 +1107,7 @@
Type:
Source:
@@ -1259,7 +1330,7 @@
Parameters:
Source:
@@ -1405,7 +1476,7 @@
Parameters:
Source:
@@ -1652,7 +1723,7 @@
Parameters:
Source:
@@ -1848,7 +1919,7 @@
Parameters:
Source:
@@ -2044,7 +2115,7 @@
Parameters:
Source:
@@ -2504,7 +2575,7 @@
Parameters:
Source:
@@ -2596,13 +2667,13 @@
Returns:

- Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 21:39:47 GMT+0200 (Mitteleuropäische Sommerzeit) + Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 23:39:42 GMT+0200 (Mitteleuropäische Sommerzeit)
diff --git a/docs/ProtoBuf.Reflect.Message.Field.html b/docs/ProtoBuf.Reflect.Message.Field.html index 9972212fb..7c375f4a8 100644 --- a/docs/ProtoBuf.Reflect.Message.Field.html +++ b/docs/ProtoBuf.Reflect.Message.Field.html @@ -297,7 +297,7 @@
Parameters:
Source:
@@ -383,7 +383,7 @@

classNameSource:
@@ -449,7 +449,7 @@
Type:
Source:
@@ -586,7 +586,7 @@
Type:
Source:
@@ -652,7 +652,7 @@
Type:
Source:
@@ -792,7 +792,7 @@
Type:
Source:
@@ -858,7 +858,7 @@
Type:
Source:
@@ -927,7 +927,73 @@
Type:
Source:
+ + + + + + + +

+ + + + + +
+ + + +
+

(non-null) scope :ProtoBuf.Reflect.Message

+ + +
+
+ +
+

Scope used to resolve the type.

+
+ + + +
Type:
+ + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
@@ -996,7 +1062,7 @@
Type:
Source:
@@ -1214,7 +1280,7 @@
Parameters:
Source:
@@ -1355,7 +1421,7 @@
Parameters:
Source:
@@ -1597,7 +1663,7 @@
Parameters:
Source:
@@ -1788,7 +1854,7 @@
Parameters:
Source:
@@ -1979,7 +2045,7 @@
Parameters:
Source:
@@ -2434,7 +2500,7 @@
Parameters:
Source:
@@ -2526,13 +2592,13 @@
Returns:

- Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 21:39:47 GMT+0200 (Mitteleuropäische Sommerzeit) + Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 23:39:42 GMT+0200 (Mitteleuropäische Sommerzeit)
diff --git a/docs/ProtoBuf.Reflect.Message.html b/docs/ProtoBuf.Reflect.Message.html index ba2083058..0e45d8936 100644 --- a/docs/ProtoBuf.Reflect.Message.html +++ b/docs/ProtoBuf.Reflect.Message.html @@ -235,7 +235,7 @@
Parameters:
Source:
@@ -402,7 +402,7 @@

classNameSource:
@@ -468,7 +468,7 @@
Type:
Source:
@@ -534,7 +534,7 @@
Type:
Source:
@@ -600,7 +600,7 @@
Type:
Source:
@@ -1094,7 +1094,7 @@
Parameters:
Source:
@@ -1226,7 +1226,7 @@

buildOptSource:
@@ -1363,7 +1363,7 @@
Parameters:
Source:
@@ -1607,7 +1607,7 @@
Parameters:
Source:
@@ -1798,7 +1798,7 @@
Parameters:
Source:
@@ -2384,7 +2384,7 @@
Parameters:
Source:
@@ -2588,7 +2588,7 @@
Returns:
-

resolve(qn, excludeFieldsopt) → {ProtoBuf.Reflect.Namespace|null}

+

resolve(qn, excludeFieldsopt) → (nullable) {ProtoBuf.Reflect.Namespace}

@@ -2764,9 +2764,6 @@
Returns:
ProtoBuf.Reflect.Namespace -| - -null
@@ -2939,13 +2936,13 @@
Returns:

- Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 21:39:47 GMT+0200 (Mitteleuropäische Sommerzeit) + Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 23:39:42 GMT+0200 (Mitteleuropäische Sommerzeit)
diff --git a/docs/ProtoBuf.Reflect.Namespace.html b/docs/ProtoBuf.Reflect.Namespace.html index 7ea457201..15abdc833 100644 --- a/docs/ProtoBuf.Reflect.Namespace.html +++ b/docs/ProtoBuf.Reflect.Namespace.html @@ -755,7 +755,7 @@

buildSource:
@@ -848,7 +848,7 @@

buildOptSource:
@@ -1388,7 +1388,7 @@
Parameters:
Source:
@@ -1587,7 +1587,7 @@
Returns:
-

resolve(qn, excludeFieldsopt) → {ProtoBuf.Reflect.Namespace|null}

+

resolve(qn, excludeFieldsopt) → (nullable) {ProtoBuf.Reflect.Namespace}

@@ -1758,9 +1758,6 @@
Returns:
ProtoBuf.Reflect.Namespace -| - -null
@@ -1933,13 +1930,13 @@
Returns:

- Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 21:39:47 GMT+0200 (Mitteleuropäische Sommerzeit) + Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 23:39:42 GMT+0200 (Mitteleuropäische Sommerzeit)
diff --git a/docs/ProtoBuf.Reflect.Service.Method.html b/docs/ProtoBuf.Reflect.Service.Method.html index 42181f969..2cc68d5a1 100644 --- a/docs/ProtoBuf.Reflect.Service.Method.html +++ b/docs/ProtoBuf.Reflect.Service.Method.html @@ -204,7 +204,7 @@
Parameters:
Source:
@@ -290,7 +290,7 @@

classNameSource:
@@ -427,7 +427,7 @@
Type:
Source:
@@ -671,7 +671,7 @@

buildOptSource:
@@ -976,13 +976,13 @@
Returns:

- Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 21:39:47 GMT+0200 (Mitteleuropäische Sommerzeit) + Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 23:39:42 GMT+0200 (Mitteleuropäische Sommerzeit)
diff --git a/docs/ProtoBuf.Reflect.Service.RPCMethod.html b/docs/ProtoBuf.Reflect.Service.RPCMethod.html index 22ab6e422..804ce99fa 100644 --- a/docs/ProtoBuf.Reflect.Service.RPCMethod.html +++ b/docs/ProtoBuf.Reflect.Service.RPCMethod.html @@ -266,7 +266,7 @@
Parameters:
Source:
@@ -352,7 +352,7 @@

classNameSource:
@@ -494,7 +494,7 @@
Type:
Source:
@@ -634,7 +634,7 @@
Type:
Source:
@@ -700,7 +700,7 @@
Type:
Source:
@@ -766,7 +766,7 @@
Type:
Source:
@@ -832,7 +832,7 @@
Type:
Source:
@@ -1007,7 +1007,7 @@

buildOptSource:
@@ -1312,13 +1312,13 @@
Returns:

- Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 21:39:47 GMT+0200 (Mitteleuropäische Sommerzeit) + Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 23:39:42 GMT+0200 (Mitteleuropäische Sommerzeit)
diff --git a/docs/ProtoBuf.Reflect.Service.html b/docs/ProtoBuf.Reflect.Service.html index 017dc85b4..30e679e61 100644 --- a/docs/ProtoBuf.Reflect.Service.html +++ b/docs/ProtoBuf.Reflect.Service.html @@ -204,7 +204,7 @@
Parameters:
Source:
@@ -371,7 +371,7 @@

classNameSource:
@@ -437,7 +437,7 @@
Type:
Source:
@@ -931,7 +931,7 @@
Parameters:
Source:
@@ -1063,7 +1063,7 @@

buildOptSource:
@@ -1618,7 +1618,7 @@
Parameters:
Source:
@@ -1822,7 +1822,7 @@
Returns:
-

resolve(qn, excludeFieldsopt) → {ProtoBuf.Reflect.Namespace|null}

+

resolve(qn, excludeFieldsopt) → (nullable) {ProtoBuf.Reflect.Namespace}

@@ -1998,9 +1998,6 @@
Returns:
ProtoBuf.Reflect.Namespace -| - -null
@@ -2173,13 +2170,13 @@
Returns:

- Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 21:39:47 GMT+0200 (Mitteleuropäische Sommerzeit) + Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 23:39:42 GMT+0200 (Mitteleuropäische Sommerzeit)
diff --git a/docs/ProtoBuf.Reflect.T.html b/docs/ProtoBuf.Reflect.T.html index 308466e95..da3be5ff1 100644 --- a/docs/ProtoBuf.Reflect.T.html +++ b/docs/ProtoBuf.Reflect.T.html @@ -753,13 +753,13 @@
Returns:

- Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 21:39:47 GMT+0200 (Mitteleuropäische Sommerzeit) + Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 23:39:42 GMT+0200 (Mitteleuropäische Sommerzeit)
diff --git a/docs/ProtoBuf.Reflect.html b/docs/ProtoBuf.Reflect.html index 84fd4541d..ec8931d04 100644 --- a/docs/ProtoBuf.Reflect.html +++ b/docs/ProtoBuf.Reflect.html @@ -95,6 +95,9 @@

Classes

Enum
+
Extension
+
+
Message
@@ -130,13 +133,13 @@

Classes


- Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 21:39:47 GMT+0200 (Mitteleuropäische Sommerzeit) + Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 23:39:42 GMT+0200 (Mitteleuropäische Sommerzeit)
diff --git a/docs/ProtoBuf.Util.html b/docs/ProtoBuf.Util.html index 576540399..d0334b8b8 100644 --- a/docs/ProtoBuf.Util.html +++ b/docs/ProtoBuf.Util.html @@ -630,13 +630,13 @@
Returns:

- Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 21:39:47 GMT+0200 (Mitteleuropäische Sommerzeit) + Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 23:39:42 GMT+0200 (Mitteleuropäische Sommerzeit)
diff --git a/docs/ProtoBuf.html b/docs/ProtoBuf.html index 6f889a62f..917bd50fb 100644 --- a/docs/ProtoBuf.html +++ b/docs/ProtoBuf.html @@ -1417,7 +1417,7 @@
Parameters:
Source:
@@ -1667,7 +1667,7 @@
Parameters:
Source:
@@ -1897,7 +1897,7 @@
Parameters:
Source:
@@ -2147,7 +2147,7 @@
Parameters:
Source:
@@ -2338,7 +2338,7 @@
Parameters:
Source:
@@ -2561,7 +2561,7 @@
Parameters:
Source:
@@ -2788,7 +2788,7 @@
Parameters:
Source:
@@ -2880,13 +2880,13 @@
Returns:

- Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 21:39:47 GMT+0200 (Mitteleuropäische Sommerzeit) + Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 23:39:42 GMT+0200 (Mitteleuropäische Sommerzeit)
diff --git a/docs/ProtoBuf.js.html b/docs/ProtoBuf.js.html index b9960f45a..1bf5369b9 100644 --- a/docs/ProtoBuf.js.html +++ b/docs/ProtoBuf.js.html @@ -65,7 +65,7 @@

Source: ProtoBuf.js

* @const * @expose */ - ProtoBuf.VERSION = "3.5.1"; + ProtoBuf.VERSION = "3.5.2"; /** * Wire types. @@ -1491,7 +1491,7 @@

Source: ProtoBuf.js

*/ Namespace.prototype._indexOf = function(nameOrId) { var key = typeof nameOrId === 'number' ? 'id' : 'name'; - for (var i=0; i<this.children.length; i++) + for (var i= 0, k=this.children.length; i<k; ++i) if (typeof this.children[i][key] !== 'undefined' && this.children[i][key] == nameOrId) return i; return -1; @@ -1501,14 +1501,15 @@

Source: ProtoBuf.js

* Resolves a reflect object inside of this namespace. * @param {string} qn Qualified name to resolve * @param {boolean=} excludeFields Excludes fields, defaults to `false` - * @return {ProtoBuf.Reflect.Namespace|null} The resolved type or null if not found + * @return {?ProtoBuf.Reflect.Namespace} The resolved type or null if not found * @expose */ Namespace.prototype.resolve = function(qn, excludeFields) { - var part = qn.split("."); - var ptr = this, i=0; - if (part[i] == "") { // Fully qualified name, e.g. ".My.Message' - while (ptr.parent != null) + var part = qn.split("."), + ptr = this, + i = 0; + if (part[i] === "") { // Fully qualified name, e.g. ".My.Message' + while (ptr.parent !== null) ptr = ptr.parent; i++; } @@ -1556,9 +1557,9 @@

Source: ProtoBuf.js

* @return {Object.<string,*>} */ Namespace.prototype.buildOpt = function() { - var opt = {}; - var keys = Object.keys(this.options); - for (var i=0; i<keys.length; i++) { + var opt = {}, + keys = Object.keys(this.options); + for (var i=0, k=keys.length; i<k; ++i) { var key = keys[i], val = this.options[keys[i]]; // TODO: Options are not resolved, yet. @@ -1640,9 +1641,10 @@

Source: ProtoBuf.js

* @expose */ Message.prototype.build = function(rebuild) { - if (this.clazz && !rebuild) return this.clazz; + if (this.clazz && !rebuild) + return this.clazz; - // We need to create a prototyped Message class in an isolated scope + // Create the runtime Message class in its own scope var clazz = (function(ProtoBuf, T) { var fields = T.getChildren(ProtoBuf.Reflect.Message.Field); @@ -2203,13 +2205,15 @@

Source: ProtoBuf.js

})(ProtoBuf, this); // Static enums and prototyped sub-messages - var children = this.getChildren(); - for (var i=0; i<children.length; i++) { - if (children[i] instanceof Enum) - clazz[children[i]['name']] = children[i].build(); - else if (children[i] instanceof Message) - clazz[children[i]['name']] = children[i].build(); - else if (children[i] instanceof Message.Field) { + var children = this.getChildren(), + child; + for (var i=0, k=children.length; i<k; i++) { + child = children[i]; + if (child instanceof Enum) + clazz[child['name']] = child.build(); + else if (child instanceof Message) + clazz[child['name']] = child.build(); + else if (child instanceof Message.Field || child instanceof Extension) { // Ignore } else throw Error("Illegal reflect child of "+this.toString(true)+": "+children[i].toString(true)); @@ -2410,14 +2414,14 @@

Source: ProtoBuf.js

* @type {boolean} * @expose */ - this.required = rule == "required"; + this.required = rule === "required"; /** * Message field repeated flag. * @type {boolean} * @expose */ - this.repeated = rule == "repeated"; + this.repeated = rule === "repeated"; /** * Message field type. Type reference string if unresolved, protobuf type if resolved. @@ -2456,11 +2460,18 @@

Source: ProtoBuf.js

this.originalName = this.name; // Used to revert camelcase transformation on naming collisions // Convert field names to camel case notation if the override is set - if (ProtoBuf.convertFieldsToCamelCase) { + if (ProtoBuf.convertFieldsToCamelCase && !(this instanceof Message.ExtensionField)) { this.name = this.name.replace(/_([a-zA-Z])/g, function($0, $1) { return $1.toUpperCase(); }); } + + /** + * Scope used to resolve the type. + * @type {!ProtoBuf.Reflect.Message} + * @expose + */ + this.scope = message; }; // Extends T @@ -3066,9 +3077,9 @@

Source: ProtoBuf.js

* @expose */ Enum.prototype.build = function() { - var enm = {}; - var values = this.getChildren(Enum.Value); - for (var i=0; i<values.length; i++) + var enm = {}, + values = this.getChildren(Enum.Value); + for (var i=0, k=values.length; i<k; ++i) enm[values[i]['name']] = values[i]['id']; if (Object.defineProperty) Object.defineProperty(enm, '$options', { "value": this.buildOpt() }); @@ -3115,6 +3126,34 @@

Source: ProtoBuf.js

*/ Reflect.Enum.Value = Value; + /** + * An extension (field). + * @exports ProtoBuf.Reflect.Extension + * @constructor + * @param {ProtoBuf.Reflect.T} parent Parent object + * @param {string} name Object name + * @param {!ProtoBuf.Reflect.Message.Field} field Extension field + */ + var Extension = function(parent, name, field) { + T.call(this, parent, name); + + /** + * Extended message field. + * @type {!ProtoBuf.Reflect.Message.Field} + * @expose + */ + this.field = field; + }; + + // Extends T + Extension.prototype = Object.create(T.prototype); + + /** + * @alias ProtoBuf.Reflect.Extension + * @expose + */ + Reflect.Extension = Extension; + /** * Constructs a new Service. * @exports ProtoBuf.Reflect.Service @@ -3151,7 +3190,10 @@

Source: ProtoBuf.js

* @expose */ Service.prototype.build = function(rebuild) { - if (this.clazz && !rebuild) return this.clazz; + if (this.clazz && !rebuild) + return this.clazz; + + // Create the runtime Service class in its own scope return this.clazz = (function(ProtoBuf, T) { /** @@ -3640,9 +3682,14 @@

Source: ProtoBuf.js

throw Error("Duplicate extended field id in message "+obj.name+": "+def['fields'][i]['id']); if (def['fields'][i]['id'] < obj.extensions[0] || def['fields'][i]['id'] > obj.extensions[1]) throw Error("Illegal extended field id in message "+obj.name+": "+def['fields'][i]['id']+" ("+obj.extensions.join(' to ')+" expected)"); - // see #161: Extensions are referenced by their fully qualified name - var fqn = this.ptr.fqn()+'.'+def["fields"][i]["name"]; - obj.addChild(new Reflect.Message.ExtensionField(obj, def["fields"][i]["rule"], def["fields"][i]["type"], fqn, def["fields"][i]["id"], def["fields"][i]["options"])); + // see #161: Extensions use their fully qualified name as their runtime key, ... + var fld = new Reflect.Message.ExtensionField(obj, def["fields"][i]["rule"], def["fields"][i]["type"], this.ptr.fqn()+'.'+def["fields"][i]["name"], def["fields"][i]["id"], def["fields"][i]["options"]); + // ...are added on top of the current namespace as an extension and... + var ext = new Reflect.Extension(this.ptr, def["fields"][i]["name"], fld); + // ...use the current namespace to resolve types. + fld.scope = this.ptr; + this.ptr.addChild(ext); + obj.addChild(fld); } } else if (!/\.?google\.protobuf\./.test(def["ref"])) // Silently skip internal extensions throw Error("Extended message "+def["ref"]+" is not defined"); @@ -3817,7 +3864,7 @@

Source: ProtoBuf.js

if (!Lang.TYPE.test(this.ptr.type)) { // Resolve type... if (!Lang.TYPEREF.test(this.ptr.type)) throw Error("Illegal type reference in "+this.ptr.toString(true)+": "+this.ptr.type); - res = this.ptr.parent.resolve(this.ptr.type, true); + res = this.ptr.scope.resolve(this.ptr.type, true); // this.ptr.parent if (!res) throw Error("Unresolvable type reference in "+this.ptr.toString(true)+": "+this.ptr.type); this.ptr.resolvedType = res; @@ -3845,6 +3892,8 @@

Source: ProtoBuf.js

// Should not happen as nothing else is implemented throw Error("Illegal service type in "+this.ptr.toString(true)); } + } else if (this.ptr instanceof ProtoBuf.Reflect.Extension) { + // There are no runtime counterparts to extensions } else throw Error("Illegal object in namespace: "+typeof(this.ptr)+":"+this.ptr); this.reset(); @@ -4082,13 +4131,13 @@

Source: ProtoBuf.js


- Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 21:39:47 GMT+0200 (Mitteleuropäische Sommerzeit) + Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 23:39:42 GMT+0200 (Mitteleuropäische Sommerzeit)
diff --git a/docs/index.html b/docs/index.html index 9113526a8..599e9fec0 100644 --- a/docs/index.html +++ b/docs/index.html @@ -48,13 +48,13 @@


- Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 21:39:47 GMT+0200 (Mitteleuropäische Sommerzeit) + Documentation generated by JSDoc 3.3.0-alpha9 on Sun Aug 24 2014 23:39:42 GMT+0200 (Mitteleuropäische Sommerzeit)
diff --git a/package.json b/package.json index 6a4cf0c12..83571925c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "protobufjs", - "version": "3.5.1", + "version": "3.5.2", "description": "Protocol Buffers for JavaScript. Finally.", "author": "Daniel Wirtz ", "contributors": [ diff --git a/src/ProtoBuf/Builder.js b/src/ProtoBuf/Builder.js index e46203f31..b63bf72fa 100644 --- a/src/ProtoBuf/Builder.js +++ b/src/ProtoBuf/Builder.js @@ -279,9 +279,14 @@ ProtoBuf.Builder = (function(ProtoBuf, Lang, Reflect) { throw Error("Duplicate extended field id in message "+obj.name+": "+def['fields'][i]['id']); if (def['fields'][i]['id'] < obj.extensions[0] || def['fields'][i]['id'] > obj.extensions[1]) throw Error("Illegal extended field id in message "+obj.name+": "+def['fields'][i]['id']+" ("+obj.extensions.join(' to ')+" expected)"); - // see #161: Extensions are referenced by their fully qualified name - var fqn = this.ptr.fqn()+'.'+def["fields"][i]["name"]; - obj.addChild(new Reflect.Message.ExtensionField(obj, def["fields"][i]["rule"], def["fields"][i]["type"], fqn, def["fields"][i]["id"], def["fields"][i]["options"])); + // see #161: Extensions use their fully qualified name as their runtime key, ... + var fld = new Reflect.Message.ExtensionField(obj, def["fields"][i]["rule"], def["fields"][i]["type"], this.ptr.fqn()+'.'+def["fields"][i]["name"], def["fields"][i]["id"], def["fields"][i]["options"]); + // ...are added on top of the current namespace as an extension and... + var ext = new Reflect.Extension(this.ptr, def["fields"][i]["name"], fld); + // ...use the current namespace to resolve types. + fld.scope = this.ptr; + this.ptr.addChild(ext); + obj.addChild(fld); } } else if (!/\.?google\.protobuf\./.test(def["ref"])) // Silently skip internal extensions throw Error("Extended message "+def["ref"]+" is not defined"); @@ -456,7 +461,7 @@ ProtoBuf.Builder = (function(ProtoBuf, Lang, Reflect) { if (!Lang.TYPE.test(this.ptr.type)) { // Resolve type... if (!Lang.TYPEREF.test(this.ptr.type)) throw Error("Illegal type reference in "+this.ptr.toString(true)+": "+this.ptr.type); - res = this.ptr.parent.resolve(this.ptr.type, true); + res = this.ptr.scope.resolve(this.ptr.type, true); // this.ptr.parent if (!res) throw Error("Unresolvable type reference in "+this.ptr.toString(true)+": "+this.ptr.type); this.ptr.resolvedType = res; @@ -484,6 +489,8 @@ ProtoBuf.Builder = (function(ProtoBuf, Lang, Reflect) { // Should not happen as nothing else is implemented throw Error("Illegal service type in "+this.ptr.toString(true)); } + } else if (this.ptr instanceof ProtoBuf.Reflect.Extension) { + // There are no runtime counterparts to extensions } else throw Error("Illegal object in namespace: "+typeof(this.ptr)+":"+this.ptr); this.reset(); diff --git a/src/ProtoBuf/Reflect.js b/src/ProtoBuf/Reflect.js index b88d0e06e..010ffe443 100644 --- a/src/ProtoBuf/Reflect.js +++ b/src/ProtoBuf/Reflect.js @@ -68,6 +68,14 @@ ProtoBuf.Reflect = (function(ProtoBuf) { */ Reflect.Enum.Value = Value; + //? include("Reflect/Extension.js"); + + /** + * @alias ProtoBuf.Reflect.Extension + * @expose + */ + Reflect.Extension = Extension; + //? include("Reflect/Service.js"); /** diff --git a/src/ProtoBuf/Reflect/Enum.js b/src/ProtoBuf/Reflect/Enum.js index 2c45d8233..0038373e1 100644 --- a/src/ProtoBuf/Reflect/Enum.js +++ b/src/ProtoBuf/Reflect/Enum.js @@ -32,9 +32,9 @@ Enum.prototype = Object.create(Namespace.prototype); * @expose */ Enum.prototype.build = function() { - var enm = {}; - var values = this.getChildren(Enum.Value); - for (var i=0; i} */ Namespace.prototype.buildOpt = function() { - var opt = {}; - var keys = Object.keys(this.options); - for (var i=0; i"); } catch (e) { fail(e);