diff --git a/dist/ProtoBuf.js b/dist/ProtoBuf.js index b0e64f558..b08fafaa6 100644 --- a/dist/ProtoBuf.js +++ b/dist/ProtoBuf.js @@ -2438,13 +2438,6 @@ return $1.toUpperCase(); }); } - - /** - * Scope used to resolve the type. - * @type {!ProtoBuf.Reflect.Message} - * @expose - */ - this.scope = message; }; // Extends T @@ -3005,6 +2998,13 @@ */ var ExtensionField = function(message, rule, type, name, id, options) { Field.call(this, message, rule, type, name, id, options); + + /** + * Extension reference. + * @type {!ProtoBuf.Reflect.Extension} + * @expose + */ + this.extension; }; // Extends Field @@ -3655,12 +3655,11 @@ 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 use their fully qualified name as their runtime key, ... + // see #161: Extensions use their fully qualified name as their runtime key and... 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... + // ...are added on top of the current namespace as an extension which is used for resolving their type later on var ext = new Reflect.Extension(this.ptr, def["fields"][i]["name"], fld); - // ...use the current namespace to resolve types. - fld.scope = this.ptr; + fld.extension = ext; this.ptr.addChild(ext); obj.addChild(fld); } @@ -3837,7 +3836,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.scope.resolve(this.ptr.type, true); // this.ptr.parent + res = (this.ptr instanceof Reflect.Message.ExtensionField ? this.ptr.extension.parent : this.ptr.parent).resolve(this.ptr.type, true); if (!res) throw Error("Unresolvable type reference in "+this.ptr.toString(true)+": "+this.ptr.type); this.ptr.resolvedType = res; diff --git a/dist/ProtoBuf.min.js b/dist/ProtoBuf.min.js index 4b1802245..686932ed4 100644 --- a/dist/ProtoBuf.min.js +++ b/dist/ProtoBuf.min.js @@ -58,12 +58,12 @@ function(a,b){"string"===typeof a&&(a=k.wrap(a,b?b:"base64"));a=a instanceof k?a c[f].encode(g,b);if(null!==e)throw c=Error("Missing at least one required field for "+this.toString(!0)+": "+e),c.encoded=b,c;return b};a.prototype.calculate=function(b){for(var d=this.getChildren(a.Field),c=0,e=0,f;e>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?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)+ @@ -87,16 +87,17 @@ c.id)))return!1;if("undefined"!==typeof c.options){if("object"!==typeof c.option e.name+": "+a.fields[h].id);if(a.fields[h].options)for(k=Object.keys(a.fields[h].options),p=0;pd.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 "+ +e.name+": "+a.fields[h].id);if(a.fields[h].ide.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.extension=p;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 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 use their fully qualified name as their runtime key, ... + // see #161: Extensions use their fully qualified name as their runtime key and... 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... + // ...are added on top of the current namespace as an extension which is used for resolving their type later on var ext = new Reflect.Extension(this.ptr, def["fields"][i]["name"], fld); - // ...use the current namespace to resolve types. - fld.scope = this.ptr; + fld.extension = ext; this.ptr.addChild(ext); obj.addChild(fld); } @@ -2967,7 +2966,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.scope.resolve(this.ptr.type, true); // this.ptr.parent + res = (this.ptr instanceof Reflect.Message.ExtensionField ? this.ptr.extension.parent : this.ptr.parent).resolve(this.ptr.type, true); if (!res) throw Error("Unresolvable type reference in "+this.ptr.toString(true)+": "+this.ptr.type); this.ptr.resolvedType = res; diff --git a/dist/ProtoBuf.noparse.min.js b/dist/ProtoBuf.noparse.min.js index d77625136..401c7c266 100644 --- a/dist/ProtoBuf.noparse.min.js +++ b/dist/ProtoBuf.noparse.min.js @@ -29,8 +29,8 @@ typeof a&&(a=k.wrap(a,c?c:"base64"));a=a instanceof k?a:k.wrap(a);var l=a.little a};d.prototype.encode=function(a,c){for(var b=this.getChildren(d.Field),e=null,g=0,h;g>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;ec.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 "+ +g.name+": "+d.fields[h].id);if(d.fields[h].idg.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.extension=n;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&&0Index

Classes

  • diff --git a/docs/ProtoBuf.Builder.Service.html b/docs/ProtoBuf.Builder.Service.html index 249aea52d..7ded56d90 100644 --- a/docs/ProtoBuf.Builder.Service.html +++ b/docs/ProtoBuf.Builder.Service.html @@ -619,7 +619,7 @@

    Index

    Classes

    • diff --git a/docs/ProtoBuf.Builder.html b/docs/ProtoBuf.Builder.html index dc38cb8f3..574d87549 100644 --- a/docs/ProtoBuf.Builder.html +++ b/docs/ProtoBuf.Builder.html @@ -777,7 +777,7 @@
      Parameters:
      Source:
      @@ -1200,7 +1200,7 @@
      Parameters:
      Source:
      @@ -1387,7 +1387,7 @@
      Parameters:
      Source:
      @@ -1568,7 +1568,7 @@
      Parameters:
      Source:
      @@ -2126,7 +2126,7 @@
      Parameters:
      Source:
      @@ -2290,7 +2290,7 @@

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

      toStringSource:
      @@ -2459,7 +2459,7 @@

      Index

      Classes

      • diff --git a/docs/ProtoBuf.DotProto.Parser.html b/docs/ProtoBuf.DotProto.Parser.html index 089dc1eb6..76c4c556b 100644 --- a/docs/ProtoBuf.DotProto.Parser.html +++ b/docs/ProtoBuf.DotProto.Parser.html @@ -480,7 +480,7 @@

        Index

        Classes

        • diff --git a/docs/ProtoBuf.DotProto.Tokenizer.html b/docs/ProtoBuf.DotProto.Tokenizer.html index 293829295..65de7cc62 100644 --- a/docs/ProtoBuf.DotProto.Tokenizer.html +++ b/docs/ProtoBuf.DotProto.Tokenizer.html @@ -934,7 +934,7 @@

          Index

          Classes

          • diff --git a/docs/ProtoBuf.DotProto.html b/docs/ProtoBuf.DotProto.html index 797346d80..1b2ca6acb 100644 --- a/docs/ProtoBuf.DotProto.html +++ b/docs/ProtoBuf.DotProto.html @@ -127,7 +127,7 @@

            Index

            Classes

            • diff --git a/docs/ProtoBuf.Reflect.Enum.Value.html b/docs/ProtoBuf.Reflect.Enum.Value.html index 62fd4725b..73a3594af 100644 --- a/docs/ProtoBuf.Reflect.Enum.Value.html +++ b/docs/ProtoBuf.Reflect.Enum.Value.html @@ -865,7 +865,7 @@

              Index

              Classes

              • diff --git a/docs/ProtoBuf.Reflect.Enum.html b/docs/ProtoBuf.Reflect.Enum.html index 7f4827a93..92501af4c 100644 --- a/docs/ProtoBuf.Reflect.Enum.html +++ b/docs/ProtoBuf.Reflect.Enum.html @@ -2078,7 +2078,7 @@

                Index

                Classes

                • diff --git a/docs/ProtoBuf.Reflect.Extension.html b/docs/ProtoBuf.Reflect.Extension.html index 903b58f05..746067e48 100644 --- a/docs/ProtoBuf.Reflect.Extension.html +++ b/docs/ProtoBuf.Reflect.Extension.html @@ -311,7 +311,7 @@

                  Index

                  Classes

                  • diff --git a/docs/ProtoBuf.Reflect.Message.ExtensionField.html b/docs/ProtoBuf.Reflect.Message.ExtensionField.html index b4a9991a8..cfb30af8b 100644 --- a/docs/ProtoBuf.Reflect.Message.ExtensionField.html +++ b/docs/ProtoBuf.Reflect.Message.ExtensionField.html @@ -297,7 +297,7 @@
                    Parameters:
                    Source:
                    @@ -408,14 +408,14 @@

                    className -

                    id :number

                    +

                    (non-null) extension :ProtoBuf.Reflect.Extension

                    -

                    Unique message field id.

                    +

                    Extension reference.

                    @@ -424,7 +424,7 @@
                    Type:
                    • -number +ProtoBuf.Reflect.Extension
                    • @@ -440,11 +440,6 @@
                      Type:
                      -
                      Inherited From:
                      -
                      - @@ -459,7 +454,7 @@
                      Type:
                      Source:
                      @@ -479,14 +474,14 @@
                      Type:
                      -

                      name :string

                      +

                      id :number

                      -

                      Object name in namespace.

                      +

                      Unique message field id.

                      @@ -495,7 +490,7 @@
                      Type:
                      • -string +number
                      • @@ -513,7 +508,7 @@
                        Type:
                        Inherited From:
                        @@ -530,7 +525,7 @@
                        Type:
                        Source:
                        @@ -550,14 +545,14 @@
                        Type:
                        -

                        (non-null) options :Object.<string, *>

                        +

                        name :string

                        -

                        Message field options.

                        +

                        Object name in namespace.

                        @@ -566,7 +561,7 @@
                        Type:
                        • -Object.<string, *> +string
                        • @@ -584,7 +579,7 @@
                          Type:
                          Inherited From:
                          @@ -601,7 +596,7 @@
                          Type:
                          Source:
                          @@ -621,14 +616,14 @@
                          Type:
                          -

                          originalName :string

                          +

                          (non-null) options :Object.<string, *>

                          -

                          Original field name.

                          +

                          Message field options.

                          @@ -637,7 +632,7 @@
                          Type:
                          • -string +Object.<string, *>
                          • @@ -655,7 +650,7 @@
                            Type:
                            Inherited From:
                            @@ -672,7 +667,7 @@
                            Type:
                            Source:
                            @@ -692,14 +687,14 @@
                            Type:
                            -

                            parent :ProtoBuf.Reflect.T|null

                            +

                            originalName :string

                            -

                            Parent object.

                            +

                            Original field name.

                            @@ -708,10 +703,7 @@
                            Type:
                            • -ProtoBuf.Reflect.T -| - -null +string
                            • @@ -729,7 +721,7 @@
                              Type:
                              Inherited From:
                              @@ -746,7 +738,7 @@
                              Type:
                              Source:
                              @@ -766,14 +758,14 @@
                              Type:
                              -

                              repeated :boolean

                              +

                              parent :ProtoBuf.Reflect.T|null

                              -

                              Message field repeated flag.

                              +

                              Parent object.

                              @@ -782,7 +774,10 @@
                              Type:
                              • -boolean +ProtoBuf.Reflect.T +| + +null
                              • @@ -800,7 +795,7 @@
                                Type:
                                Inherited From:
                                @@ -817,7 +812,7 @@
                                Type:
                                Source:
                                @@ -837,14 +832,14 @@
                                Type:
                                -

                                required :boolean

                                +

                                repeated :boolean

                                -

                                Message field required flag.

                                +

                                Message field repeated flag.

                                @@ -871,7 +866,7 @@
                                Type:
                                Inherited From:
                                @@ -888,7 +883,7 @@
                                Type:
                                Source:
                                @@ -908,14 +903,14 @@
                                Type:
                                -

                                resolvedType :ProtoBuf.Reflect.T|null

                                +

                                required :boolean

                                -

                                Resolved type reference inside the global namespace.

                                +

                                Message field required flag.

                                @@ -924,10 +919,7 @@
                                Type:
                                • -ProtoBuf.Reflect.T -| - -null +boolean
                                • @@ -945,7 +937,7 @@
                                  Type:
                                  Inherited From:
                                  @@ -962,7 +954,7 @@
                                  Type:
                                  Source:
                                  @@ -982,14 +974,14 @@
                                  Type:
                                  -

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

                                  +

                                  resolvedType :ProtoBuf.Reflect.T|null

                                  -

                                  Scope used to resolve the type.

                                  +

                                  Resolved type reference inside the global namespace.

                                  @@ -998,7 +990,10 @@
                                  Type:
                                  - - - -
                                  -

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

                                  - - -
                                  -
                                  - -
                                  -

                                  Scope used to resolve the type.

                                  -
                                  - - - -
                                  Type:
                                  - - - - -
                                  - - - - - - - - - - - - - - - - - - - -
                                  Source:
                                  -
                                  - - - - - - -
                                  @@ -1280,7 +1214,7 @@
                                  Parameters:
                                  Source:
                                  @@ -1421,7 +1355,7 @@
                                  Parameters:
                                  Source:
                                  @@ -1663,7 +1597,7 @@
                                  Parameters:
                                  Source:
                                  @@ -1854,7 +1788,7 @@
                                  Parameters:
                                  Source:
                                  @@ -2045,7 +1979,7 @@
                                  Parameters:
                                  Source:
                                  @@ -2500,7 +2434,7 @@
                                  Parameters:
                                  Source:
                                  @@ -2598,7 +2532,7 @@

                                  Index

                                  Classes

                                  • diff --git a/docs/ProtoBuf.Reflect.Message.html b/docs/ProtoBuf.Reflect.Message.html index 0e45d8936..409a54171 100644 --- a/docs/ProtoBuf.Reflect.Message.html +++ b/docs/ProtoBuf.Reflect.Message.html @@ -2942,7 +2942,7 @@

                                    Index

                                    Classes

                                    • diff --git a/docs/ProtoBuf.Reflect.Namespace.html b/docs/ProtoBuf.Reflect.Namespace.html index 15abdc833..c2bf63c4c 100644 --- a/docs/ProtoBuf.Reflect.Namespace.html +++ b/docs/ProtoBuf.Reflect.Namespace.html @@ -1936,7 +1936,7 @@

                                      Index

                                      Classes

                                      • diff --git a/docs/ProtoBuf.Reflect.Service.Method.html b/docs/ProtoBuf.Reflect.Service.Method.html index 2cc68d5a1..396862349 100644 --- a/docs/ProtoBuf.Reflect.Service.Method.html +++ b/docs/ProtoBuf.Reflect.Service.Method.html @@ -982,7 +982,7 @@

                                        Index

                                        Classes

                                        • diff --git a/docs/ProtoBuf.Reflect.Service.RPCMethod.html b/docs/ProtoBuf.Reflect.Service.RPCMethod.html index 804ce99fa..ef3e4b0af 100644 --- a/docs/ProtoBuf.Reflect.Service.RPCMethod.html +++ b/docs/ProtoBuf.Reflect.Service.RPCMethod.html @@ -1318,7 +1318,7 @@

                                          Index

                                          Classes

                                          • diff --git a/docs/ProtoBuf.Reflect.Service.html b/docs/ProtoBuf.Reflect.Service.html index 30e679e61..69b52f529 100644 --- a/docs/ProtoBuf.Reflect.Service.html +++ b/docs/ProtoBuf.Reflect.Service.html @@ -2176,7 +2176,7 @@

                                            Index

                                            Classes

                                            • diff --git a/docs/ProtoBuf.Reflect.T.html b/docs/ProtoBuf.Reflect.T.html index da3be5ff1..c6804ec90 100644 --- a/docs/ProtoBuf.Reflect.T.html +++ b/docs/ProtoBuf.Reflect.T.html @@ -759,7 +759,7 @@

                                              Index

                                              Classes

                                              • diff --git a/docs/ProtoBuf.Reflect.html b/docs/ProtoBuf.Reflect.html index ec8931d04..41f34f19b 100644 --- a/docs/ProtoBuf.Reflect.html +++ b/docs/ProtoBuf.Reflect.html @@ -139,7 +139,7 @@

                                                Index

                                                Classes

                                                • diff --git a/docs/ProtoBuf.Util.html b/docs/ProtoBuf.Util.html index d0334b8b8..f7642fc79 100644 --- a/docs/ProtoBuf.Util.html +++ b/docs/ProtoBuf.Util.html @@ -636,7 +636,7 @@

                                                  Index

                                                  Classes

                                                  • diff --git a/docs/ProtoBuf.html b/docs/ProtoBuf.html index 917bd50fb..ad27bb45b 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:
                                                    @@ -2886,7 +2886,7 @@

                                                    Index

                                                    Classes

                                                    • diff --git a/docs/ProtoBuf.js.html b/docs/ProtoBuf.js.html index 1bf5369b9..e6477d33c 100644 --- a/docs/ProtoBuf.js.html +++ b/docs/ProtoBuf.js.html @@ -2465,13 +2465,6 @@

                                                      Source: ProtoBuf.js

                                                      return $1.toUpperCase(); }); } - - /** - * Scope used to resolve the type. - * @type {!ProtoBuf.Reflect.Message} - * @expose - */ - this.scope = message; }; // Extends T @@ -3032,6 +3025,13 @@

                                                      Source: ProtoBuf.js

                                                      */ var ExtensionField = function(message, rule, type, name, id, options) { Field.call(this, message, rule, type, name, id, options); + + /** + * Extension reference. + * @type {!ProtoBuf.Reflect.Extension} + * @expose + */ + this.extension; }; // Extends Field @@ -3682,12 +3682,11 @@

                                                      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 use their fully qualified name as their runtime key, ... + // see #161: Extensions use their fully qualified name as their runtime key and... 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... + // ...are added on top of the current namespace as an extension which is used for resolving their type later on var ext = new Reflect.Extension(this.ptr, def["fields"][i]["name"], fld); - // ...use the current namespace to resolve types. - fld.scope = this.ptr; + fld.extension = ext; this.ptr.addChild(ext); obj.addChild(fld); } @@ -3864,7 +3863,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.scope.resolve(this.ptr.type, true); // this.ptr.parent + res = (this.ptr instanceof Reflect.Message.ExtensionField ? this.ptr.extension.parent : this.ptr.parent).resolve(this.ptr.type, true); if (!res) throw Error("Unresolvable type reference in "+this.ptr.toString(true)+": "+this.ptr.type); this.ptr.resolvedType = res; @@ -4137,7 +4136,7 @@

                                                      Index

                                                      Classes

                                                      • diff --git a/docs/index.html b/docs/index.html index 599e9fec0..32293fb64 100644 --- a/docs/index.html +++ b/docs/index.html @@ -54,7 +54,7 @@

                                                        Index

                                                        Classes

                                                        • diff --git a/src/ProtoBuf/Builder.js b/src/ProtoBuf/Builder.js index b63bf72fa..bec1b2c80 100644 --- a/src/ProtoBuf/Builder.js +++ b/src/ProtoBuf/Builder.js @@ -279,12 +279,11 @@ 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 use their fully qualified name as their runtime key, ... + // see #161: Extensions use their fully qualified name as their runtime key and... 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... + // ...are added on top of the current namespace as an extension which is used for resolving their type later on var ext = new Reflect.Extension(this.ptr, def["fields"][i]["name"], fld); - // ...use the current namespace to resolve types. - fld.scope = this.ptr; + fld.extension = ext; this.ptr.addChild(ext); obj.addChild(fld); } @@ -461,7 +460,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.scope.resolve(this.ptr.type, true); // this.ptr.parent + res = (this.ptr instanceof Reflect.Message.ExtensionField ? this.ptr.extension.parent : this.ptr.parent).resolve(this.ptr.type, true); if (!res) throw Error("Unresolvable type reference in "+this.ptr.toString(true)+": "+this.ptr.type); this.ptr.resolvedType = res; diff --git a/src/ProtoBuf/Reflect/Message/ExtensionField.js b/src/ProtoBuf/Reflect/Message/ExtensionField.js index f2c4e8260..a89152932 100644 --- a/src/ProtoBuf/Reflect/Message/ExtensionField.js +++ b/src/ProtoBuf/Reflect/Message/ExtensionField.js @@ -12,6 +12,13 @@ */ var ExtensionField = function(message, rule, type, name, id, options) { Field.call(this, message, rule, type, name, id, options); + + /** + * Extension reference. + * @type {!ProtoBuf.Reflect.Extension} + * @expose + */ + this.extension; }; // Extends Field diff --git a/src/ProtoBuf/Reflect/Message/Field.js b/src/ProtoBuf/Reflect/Message/Field.js index af33379ec..d88efdebc 100644 --- a/src/ProtoBuf/Reflect/Message/Field.js +++ b/src/ProtoBuf/Reflect/Message/Field.js @@ -74,13 +74,6 @@ var Field = function(message, rule, type, name, id, options) { return $1.toUpperCase(); }); } - - /** - * Scope used to resolve the type. - * @type {!ProtoBuf.Reflect.Message} - * @expose - */ - this.scope = message; }; // Extends T