OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 define("mojo/public/js/codec", [ | 5 define("mojo/public/js/codec", [ |
6 "mojo/public/js/unicode", | 6 "mojo/public/js/unicode", |
7 "mojo/public/js/buffer", | 7 "mojo/public/js/buffer", |
8 ], function(unicode, buffer) { | 8 ], function(unicode, buffer) { |
9 | 9 |
10 var kErrorUnsigned = "Passing negative value to unsigned"; | 10 var kErrorUnsigned = "Passing negative value to unsigned"; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 if (!offset) | 118 if (!offset) |
119 return 0; | 119 return 0; |
120 return offsetPointer + offset; | 120 return offsetPointer + offset; |
121 }; | 121 }; |
122 | 122 |
123 Decoder.prototype.decodeAndCreateDecoder = function(pointer) { | 123 Decoder.prototype.decodeAndCreateDecoder = function(pointer) { |
124 return new Decoder(this.buffer, this.handles, pointer); | 124 return new Decoder(this.buffer, this.handles, pointer); |
125 }; | 125 }; |
126 | 126 |
127 Decoder.prototype.decodeHandle = function() { | 127 Decoder.prototype.decodeHandle = function() { |
128 return this.handles[this.readUint32()]; | 128 return this.handles[this.readUint32()] || null; |
129 }; | 129 }; |
130 | 130 |
131 Decoder.prototype.decodeString = function() { | 131 Decoder.prototype.decodeString = function() { |
132 var numberOfBytes = this.readUint32(); | 132 var numberOfBytes = this.readUint32(); |
133 var numberOfElements = this.readUint32(); | 133 var numberOfElements = this.readUint32(); |
134 var base = this.next; | 134 var base = this.next; |
135 this.next += numberOfElements; | 135 this.next += numberOfElements; |
136 return unicode.decodeUtf8String( | 136 return unicode.decodeUtf8String( |
137 new Uint8Array(this.buffer.arrayBuffer, base, numberOfElements)); | 137 new Uint8Array(this.buffer.arrayBuffer, base, numberOfElements)); |
138 }; | 138 }; |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 exports.NullablePointerTo = NullablePointerTo; | 820 exports.NullablePointerTo = NullablePointerTo; |
821 exports.ArrayOf = ArrayOf; | 821 exports.ArrayOf = ArrayOf; |
822 exports.NullableArrayOf = NullableArrayOf; | 822 exports.NullableArrayOf = NullableArrayOf; |
823 exports.PackedBool = PackedBool; | 823 exports.PackedBool = PackedBool; |
824 exports.Handle = Handle; | 824 exports.Handle = Handle; |
825 exports.NullableHandle = NullableHandle; | 825 exports.NullableHandle = NullableHandle; |
826 exports.MapOf = MapOf; | 826 exports.MapOf = MapOf; |
827 exports.NullableMapOf = NullableMapOf; | 827 exports.NullableMapOf = NullableMapOf; |
828 return exports; | 828 return exports; |
829 }); | 829 }); |
OLD | NEW |