Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(545)

Side by Side Diff: mojo/public/js/codec.js

Issue 807873002: Correct 'string literal' to 'primitive strings' (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 var encoder = this.createAndEncodeEncoder(encodedSize); 364 var encoder = this.createAndEncodeEncoder(encodedSize);
365 encoder.encodeArray(cls, val, numberOfElements, encodedSize); 365 encoder.encodeArray(cls, val, numberOfElements, encodedSize);
366 }; 366 };
367 367
368 Encoder.prototype.encodeStringPointer = function(val) { 368 Encoder.prototype.encodeStringPointer = function(val) {
369 if (val == null) { 369 if (val == null) {
370 // Also handles undefined, since undefined == null. 370 // Also handles undefined, since undefined == null.
371 this.encodePointer(val); 371 this.encodePointer(val);
372 return; 372 return;
373 } 373 }
374 // This only accepts string literals, not objects like new String("foo"). 374 // Only accepts string primivites, not String Objects like new String("foo")
375 if (typeof(val) !== "string") { 375 if (typeof(val) !== "string") {
376 throw new Error(kErrorString); 376 throw new Error(kErrorString);
377 } 377 }
378 var encodedSize = kArrayHeaderSize + unicode.utf8Length(val); 378 var encodedSize = kArrayHeaderSize + unicode.utf8Length(val);
379 var encoder = this.createAndEncodeEncoder(encodedSize); 379 var encoder = this.createAndEncodeEncoder(encodedSize);
380 encoder.encodeString(val); 380 encoder.encodeString(val);
381 }; 381 };
382 382
383 Encoder.prototype.encodeMap = function(keyClass, valueClass, val) { 383 Encoder.prototype.encodeMap = function(keyClass, valueClass, val) {
384 var keys = new Array(val.size); 384 var keys = new Array(val.size);
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 exports.NullablePointerTo = NullablePointerTo; 819 exports.NullablePointerTo = NullablePointerTo;
820 exports.ArrayOf = ArrayOf; 820 exports.ArrayOf = ArrayOf;
821 exports.NullableArrayOf = NullableArrayOf; 821 exports.NullableArrayOf = NullableArrayOf;
822 exports.PackedBool = PackedBool; 822 exports.PackedBool = PackedBool;
823 exports.Handle = Handle; 823 exports.Handle = Handle;
824 exports.NullableHandle = NullableHandle; 824 exports.NullableHandle = NullableHandle;
825 exports.MapOf = MapOf; 825 exports.MapOf = MapOf;
826 exports.NullableMapOf = NullableMapOf; 826 exports.NullableMapOf = NullableMapOf;
827 return exports; 827 return exports;
828 }); 828 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698