Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Apr 26, 2020
1 parent 8a667b5 commit 44942f1
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions lib/js/jsarrays.nim
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@ proc toArrayBuffer*(a: string): ArrayBuffer =
const view = new Uint8Array(`result`);
for(i=0;i<`n`;i++){
view[i] = `a`[i];
// view[i] = str.charCodeAt(i); // ? for cstring i guess
}
""".}

# proc `[]=`(a: ArrayBuffer, index: int, val: char) =
# {.emit: """`a`[`index`] = `val`;""".}

template genGetSet(T, funGet, funSet): untyped =
proc funGet(a: DataView, byteOffset: int, littleEndian: bool): T {.importcpp.}
proc funSet(a: DataView, byteOffset: int, value: T, littleEndian: bool): T {.importcpp.}
Expand All @@ -45,28 +41,33 @@ proc getTyped*(a: DataView, T: typedesc, offset: int, littleEndian: bool): T =
elif T is int32: getInt32(a, offset, littleEndian)
else: static doAssert false, $T # add as needed

# DataView.prototype.getBigInt64()
# DataView.prototype.getBigUint64()
# DataView.prototype.getFloat32()
# DataView.prototype.getFloat64()
# DataView.prototype.getInt16()
# DataView.prototype.getInt32()
# DataView.prototype.getInt8()
# DataView.prototype.getUint16()
# DataView.prototype.getUint32()
# DataView.prototype.getUint8()
# DataView.prototype.setBigInt64()
# DataView.prototype.setBigUint64()
# DataView.prototype.setFloat32()
# DataView.prototype.setFloat64()
# DataView.prototype.setInt16()
# DataView.prototype.setInt32()
# DataView.prototype.setInt8()
# DataView.prototype.setUint16()
# DataView.prototype.setUint32()
# DataView.prototype.setUint8()
when false: ## scratch below
# view[i] = str.charCodeAt(i); // check whether would be needed for cstring

# proc `[]=`(a: ArrayBuffer, index: int, val: char) =
# {.emit: """`a`[`index`] = `val`;""".}

# DataView.prototype.getBigInt64()
# DataView.prototype.getBigUint64()
# DataView.prototype.getFloat32()
# DataView.prototype.getFloat64()
# DataView.prototype.getInt16()
# DataView.prototype.getInt32()
# DataView.prototype.getInt8()
# DataView.prototype.getUint16()
# DataView.prototype.getUint32()
# DataView.prototype.getUint8()
# DataView.prototype.setBigInt64()
# DataView.prototype.setBigUint64()
# DataView.prototype.setFloat32()
# DataView.prototype.setFloat64()
# DataView.prototype.setInt16()
# DataView.prototype.setInt32()
# DataView.prototype.setInt8()
# DataView.prototype.setUint16()
# DataView.prototype.setUint32()
# DataView.prototype.setUint8()

when false:
proc decode() =
case bufLen
of int32.sizeof:
Expand Down

0 comments on commit 44942f1

Please sign in to comment.