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

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

Issue 2394873003: [Mojo] Make javascript enums extensible. (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | mojo/public/js/validation_unittests.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/js/codec.js
diff --git a/mojo/public/js/codec.js b/mojo/public/js/codec.js
index 4003b510c5ec25f2a39f5c873b5ca9b906e870cd..70df758559967e150a117267d196d6a3303b436c 100644
--- a/mojo/public/js/codec.js
+++ b/mojo/public/js/codec.js
@@ -711,6 +711,20 @@ define("mojo/public/js/codec", [
encoder.writeDouble(val);
};
+ function Enum(cls) {
+ this.cls = cls;
+ }
+
+ Enum.prototype.encodedSize = 4;
+
+ Enum.prototype.decode = function(decoder) {
+ return decoder.readInt32();
+ };
+
+ Enum.prototype.encode = function(encoder, val) {
+ encoder.writeInt32(val);
+ };
+
function PointerTo(cls) {
this.cls = cls;
}
@@ -863,6 +877,7 @@ define("mojo/public/js/codec", [
exports.Float = Float;
exports.Double = Double;
exports.String = String;
+ exports.Enum = Enum;
exports.NullableString = NullableString;
exports.PointerTo = PointerTo;
exports.NullablePointerTo = NullablePointerTo;
« no previous file with comments | « no previous file | mojo/public/js/validation_unittests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698