[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Public WebGL] Typed arrays and network data



I've seen a few comments about the typed array proposal and some
missing features for parsing data from the network. If we add one more
type of view, I think we can cover a large number of additional use
cases and improve the chances of widespread acceptance of the
proposal.

Consider adding a type called DataStream, which has a cursor and gets
or sets data at that point.

[
  Constructor(in ArrayBuffer buffer,
      optional in unsigned long byteOffset,
      optional in unsigned long length)
]
interface DataStream : TypedArray {
  const object BIG_ENDIAN;
  const object LITTLE_ENDIAN;
  // Takes either BIG_ENDIAN or LITTLE_ENDIAN as argument
  void setEndianness(object endianness);
  // Fetches the given type at the cursor with the current endianness.
  // Increments the cursor by the size in bytes of the type.
  // Throws an exception if the operation would read past the end of the view.
  unsigned byte getUint8();
  byte getInt8();
  unsigned short getUint16();
  short getInt16();
  unsigned long getUint32();
  long getInt32();
  unsigned long long getUint64();
  long long getInt64();
  float getFloat();
  double getDouble();
  // Sets the given type at the cursor with the current endianness.
  // Increments the cursor by the size in bytes of the type.
  // Throws an exception if the operation would read past the end of the view.
  void setUint8(in unsigned byte value);
  void setInt8(in byte value);
  void setUint16(in unsigned short value);
  void setInt16(in short value);
  void setUint32(in unsigned long value);
  void setInt32(in long value);
  void setUint64(in unsigned long long value);
  void setInt64(in long long value);
  void setFloat(in float value);
  void setDouble(in double value);
  // Gets the current position of the cursor, in bytes, from the
beginning of the view.
  unsigned long getCursorPosition();
  // Sets the current position of the cursor, in bytes, from the
beginning of the view.
  void setCursorPosition(in unsigned long byteOffset);
};

Note that this wouldn't perturb any of the other interfaces in the spec.

What do you think?

-Ken
-----------------------------------------------------------
You are currently subscribe to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email: