| Index: mojo/apps/js/bindings/codec.js
|
| diff --git a/mojo/apps/js/bindings/codec.js b/mojo/apps/js/bindings/codec.js
|
| index edaa005eafed9a9cdacc6c8aa855bc9d48f7d650..5df5803b2bee13f9479489c73b6b90a484797acb 100644
|
| --- a/mojo/apps/js/bindings/codec.js
|
| +++ b/mojo/apps/js/bindings/codec.js
|
| @@ -95,6 +95,9 @@ define(function() {
|
| this.viewU32 = new Uint32Array(
|
| this.memory.buffer, 0,
|
| Math.floor(this.memory.length / Uint32Array.BYTES_PER_ELEMENT));
|
| + this.viewFloat = new Float32Array(
|
| + this.memory.buffer, 0,
|
| + Math.floor(this.memory.length / Float32Array.BYTES_PER_ELEMENT));
|
| }
|
|
|
| Decoder.prototype.skip = function(offset) {
|
| @@ -119,6 +122,12 @@ define(function() {
|
| return low + high * 0x100000000;
|
| };
|
|
|
| + Decoder.prototype.decodeFloat = function() {
|
| + var result = this.viewFloat[this.next / this.viewFloat.BYTES_PER_ELEMENT];
|
| + this.next += this.viewFloat.BYTES_PER_ELEMENT;
|
| + return result;
|
| + };
|
| +
|
| Decoder.prototype.decodePointer = function() {
|
| // TODO(abarth): To correctly decode a pointer, we need to know the real
|
| // base address of the array buffer.
|
| @@ -203,6 +212,14 @@ define(function() {
|
| this.next += 8;
|
| };
|
|
|
| + Encoder.prototype.encodeFloat = function(val) {
|
| + var floatBuffer = new Float32Array(1);
|
| + floatBuffer[0] = val;
|
| + var buffer = new Uint8Array(floatBuffer.buffer, 0);
|
| + for (var i = 0; i < buffer.length; ++i)
|
| + this.buffer.memory[this.next++] = buffer[i];
|
| + };
|
| +
|
| Encoder.prototype.encodePointer = function(pointer) {
|
| if (!pointer)
|
| return this.write64(0);
|
|
|