mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 831702 - 0001.Add data size calculation function. r=yoshi.
This commit is contained in:
parent
a02186b10c
commit
bd8e1038d1
@ -143,6 +143,55 @@ let Buf = {
|
||||
|
||||
// This is the token of last solicited response.
|
||||
this.lastSolicitedToken = 0;
|
||||
|
||||
// Queue for storing outgoing override points
|
||||
this.outgoingBufferCalSizeQueue = [];
|
||||
},
|
||||
|
||||
/**
|
||||
* Mark current outgoingIndex as start point for calculation length of data
|
||||
* written to outgoingBuffer.
|
||||
* Mark can be nested for here uses queue to remember marks.
|
||||
*
|
||||
* @param writeFunction
|
||||
* Function to write data length into outgoingBuffer, this function is
|
||||
* also used to allocate buffer for data length.
|
||||
* Raw data size(in Uint8) is provided as parameter calling writeFunction.
|
||||
* If raw data size is not in proper unit for writing, user can adjust
|
||||
* the length value in writeFunction before writing.
|
||||
**/
|
||||
startCalOutgoingSize: function startCalOutgoingSize(writeFunction) {
|
||||
let sizeInfo = {index: this.outgoingIndex,
|
||||
write: writeFunction};
|
||||
|
||||
// Allocate buffer for data lemgtj.
|
||||
writeFunction.call(0);
|
||||
|
||||
// Get size of data length buffer for it is not counted into data size.
|
||||
sizeInfo.size = this.outgoingIndex - sizeInfo.index;
|
||||
|
||||
// Enqueue size calculation information.
|
||||
this.outgoingBufferCalSizeQueue.push(sizeInfo);
|
||||
},
|
||||
|
||||
/**
|
||||
* Calculate data length since last mark, and write it into mark position.
|
||||
**/
|
||||
stopCalOutgoingSize: function stopCalOutgoingSize() {
|
||||
let sizeInfo = this.outgoingBufferCalSizeQueue.pop();
|
||||
|
||||
// Remember current outgoingIndex.
|
||||
let currentOutgoingIndex = this.outgoingIndex;
|
||||
// Calculate data length, in uint8.
|
||||
let writeSize = this.outgoingIndex - sizeInfo.index - sizeInfo.size;
|
||||
|
||||
// Write data length to mark, use same function for allocating buffer to make
|
||||
// sure there is no buffer overloading.
|
||||
this.outgoingIndex = sizeInfo.index;
|
||||
sizeInfo.write(writeSize);
|
||||
|
||||
// Restore outgoingIndex.
|
||||
this.outgoingIndex = currentOutgoingIndex;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -2547,6 +2596,7 @@ let RIL = {
|
||||
debug("Stk Envelope " + JSON.stringify(options));
|
||||
}
|
||||
let token = Buf.newParcel(REQUEST_STK_SEND_ENVELOPE_COMMAND);
|
||||
|
||||
let berLen = TLV_DEVICE_ID_SIZE + /* Size of Device Identifier TLV */
|
||||
(options.itemIdentifier ? TLV_ITEM_ID_SIZE : 0) +
|
||||
(options.helpRequested ? TLV_HELP_REQUESTED_SIZE : 0) +
|
||||
|
Loading…
Reference in New Issue
Block a user