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

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

Issue 247013008: Add support for Float/Double types for JS Mojo bindings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: M_PI not present on some of the windows platforms. 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
Index: mojo/public/js/bindings/codec.js
diff --git a/mojo/public/js/bindings/codec.js b/mojo/public/js/bindings/codec.js
index ef2060e5169f0708578ccdf8383aa0324b349cf8..d9786967624c544adc2db610f9515fe674db545f 100644
--- a/mojo/public/js/bindings/codec.js
+++ b/mojo/public/js/bindings/codec.js
@@ -178,15 +178,15 @@ define("mojo/public/js/bindings/codec", [
return result;
};
- Decoder.prototype.readFloat32 = function() {
- var result = this.buffer.dataView.readFloat32(
+ Decoder.prototype.readFloat = function() {
+ var result = this.buffer.dataView.getFloat32(
this.next, kHostIsLittleEndian);
this.next += 4;
return result;
};
- Decoder.prototype.readFloat64 = function() {
- var result = this.buffer.dataView.readFloat64(
+ Decoder.prototype.readDouble = function() {
+ var result = this.buffer.dataView.getFloat64(
this.next, kHostIsLittleEndian);
this.next += 8;
return result;
@@ -308,13 +308,13 @@ define("mojo/public/js/bindings/codec", [
this.next += 8;
};
- Encoder.prototype.writeFloat32 = function(val) {
- this.buffer.dataView.setFloat32(val, kHostIsLittleEndian);
+ Encoder.prototype.writeFloat = function(val) {
+ this.buffer.dataView.setFloat32(this.next, val, kHostIsLittleEndian);
this.next += 4;
};
- Encoder.prototype.writeFloat64 = function(val) {
- this.buffer.dataView.setFloat64(val, kHostIsLittleEndian);
+ Encoder.prototype.writeDouble = function(val) {
+ this.buffer.dataView.setFloat64(this.next, val, kHostIsLittleEndian);
this.next += 8;
};
@@ -558,7 +558,7 @@ define("mojo/public/js/bindings/codec", [
};
function Int64() {
- };
+ }
Int64.encodedSize = 8;
@@ -571,7 +571,7 @@ define("mojo/public/js/bindings/codec", [
};
function Uint64() {
- };
+ }
Uint64.encodedSize = 8;
@@ -583,15 +583,38 @@ define("mojo/public/js/bindings/codec", [
encoder.writeUint64(val);
};
- function PointerTo(cls) {
- this.cls = cls;
- };
-
// TODO(abarth): Add missing types:
// * String
- // * Float
- // * Double
- // * Signed integers
+
+ function Float() {
+ }
+
+ Float.encodedSize = 4;
+
+ Float.decode = function(decoder) {
+ return decoder.readFloat();
+ };
+
+ Float.encode = function(encoder, val) {
+ encoder.writeFloat(val);
+ };
+
+ function Double() {
+ }
+
+ Double.encodedSize = 8;
+
+ Double.decode = function(decoder) {
+ return decoder.readDouble();
+ };
+
+ Double.encode = function(encoder, val) {
+ encoder.writeDouble(val);
+ };
+
+ function PointerTo(cls) {
+ this.cls = cls;
+ }
PointerTo.prototype.encodedSize = 8;
@@ -606,7 +629,7 @@ define("mojo/public/js/bindings/codec", [
function ArrayOf(cls) {
this.cls = cls;
- };
+ }
ArrayOf.prototype.encodedSize = 8;
@@ -651,6 +674,8 @@ define("mojo/public/js/bindings/codec", [
exports.Uint32 = Uint32;
exports.Int64 = Int64;
exports.Uint64 = Uint64;
+ exports.Float = Float;
+ exports.Double = Double;
exports.PointerTo = PointerTo;
exports.ArrayOf = ArrayOf;
exports.Handle = Handle;
« no previous file with comments | « content/test/data/web_ui_test_mojo_bindings.mojom ('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