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

Unified Diff: mojo/public/js/bindings/codec.js

Issue 250253002: Mojo: Add String, Float, and Double types to codec.js. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 8 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/bindings/js/codec_unittests.js ('k') | mojo/public/tools/bindings/generators/mojom_js_generator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/js/bindings/codec.js
diff --git a/mojo/public/js/bindings/codec.js b/mojo/public/js/bindings/codec.js
index d9786967624c544adc2db610f9515fe674db545f..0b680172c2ddedc562e289f499ced46515c78c99 100644
--- a/mojo/public/js/bindings/codec.js
+++ b/mojo/public/js/bindings/codec.js
@@ -229,6 +229,10 @@ define("mojo/public/js/bindings/codec", [
return val;
};
+ Decoder.prototype.decodeStruct = function(cls) {
+ return cls.decode(this);
+ };
+
Decoder.prototype.decodeStructPointer = function(cls) {
return cls.decode(this.decodeAndCreateDecoder());
};
@@ -358,6 +362,10 @@ define("mojo/public/js/bindings/codec", [
}
};
+ Encoder.prototype.encodeStruct = function(cls, val) {
+ return cls.encode(this, val);
+ };
+
Encoder.prototype.encodeStructPointer = function(cls, val) {
var encoder = this.createAndEncodeEncoder(cls.encodedSize);
cls.encode(encoder, val);
@@ -488,6 +496,10 @@ define("mojo/public/js/bindings/codec", [
return decoder.readInt8();
};
+ Int8.encode = function(encoder, val) {
+ encoder.writeInt8(val);
+ };
+
Uint8.encode = function(encoder, val) {
encoder.writeUint8(val);
};
@@ -583,8 +595,19 @@ define("mojo/public/js/bindings/codec", [
encoder.writeUint64(val);
};
- // TODO(abarth): Add missing types:
- // * String
+ function String() {
+ };
+
+ String.encodedSize = 8;
+
+ String.decode = function(decoder) {
+ return decoder.decodeStringPointer();
+ };
+
+ String.encode = function(encoder, val) {
+ encoder.encodeStringPointer(val);
+ };
+
function Float() {
}
@@ -634,11 +657,11 @@ define("mojo/public/js/bindings/codec", [
ArrayOf.prototype.encodedSize = 8;
ArrayOf.prototype.decode = function(decoder) {
- return decoder.decodeArrayPointer(self.cls);
+ return decoder.decodeArrayPointer(this.cls);
};
ArrayOf.prototype.encode = function(encoder, val) {
- encoder.encodeArrayPointer(self.cls, val);
+ encoder.encodeArrayPointer(this.cls, val);
};
function Handle() {
@@ -676,6 +699,7 @@ define("mojo/public/js/bindings/codec", [
exports.Uint64 = Uint64;
exports.Float = Float;
exports.Double = Double;
+ exports.String = String;
exports.PointerTo = PointerTo;
exports.ArrayOf = ArrayOf;
exports.Handle = Handle;
« no previous file with comments | « mojo/bindings/js/codec_unittests.js ('k') | mojo/public/tools/bindings/generators/mojom_js_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698