google / flatbuffers

FlatBuffers: Memory Efficient Serialization Library
https://flatbuffers.dev/
Apache License 2.0
23.26k stars 3.24k forks source link

sending bigInt as ulong (Javascript) #4922

Closed DrYSG closed 5 years ago

DrYSG commented 6 years ago

I have no problem with doing this in a C++ program, but I am stuck on writing a ulong in JS.

FB has no issue if I used the 32bit process.hrtime() value.

But how does do a createLong() for a 64bit ?

see: [ https://nodejs.org/api/process.html#process_process_hrtime_bigint ]

# commented line does not work
# let timeStamp = process.hrtime.bigint()
        let timeStamp = process.hrtime()
        let ts = builder.createLong(0, timeStamp)
        PNT.Telemetry.startTelemetry(builder)
        PNT.Telemetry.addSystemTime(builder, ts)

FB template file

// Simple Telemetry data from/to Sim and Sensor
namespace PNT;
enum DeviceType:byte { IMU, VAN, GPS, MAGNAV, SOOP }
struct PosVector {
  lat:double;
  lon:double;
  alt:double;
}
table Telemetry {
  source: string;
  systemTime:ulong = 0;
  systemTimeString: string;
  description: string;
  position: PosVector; 
}

root_type Telemetry;
aardappel commented 6 years ago

Already responded here: https://stackoverflow.com/questions/52192977/in-javascript-google-flatbuffers-how-does-one-write-a-ulong/52193251?noredirect=1

Bigints are pretty new to JS, but it would be awesome to have direct support for them in FlatBuffers.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had activity for 1 year. It will be automatically closed if no further activity occurs. To keep it open, simply post a new comment. Maintainers will re-open on new activity. Thank you for your contributions.