зеркало из https://github.com/mozilla/pluotsorbet.git
Use Int8Array instead of Uint8Array throughout the codebase
This commit is contained in:
Родитель
9fd0b810bb
Коммит
528d259997
|
@ -66,7 +66,7 @@ DataEncoder.prototype.getData = function() {
|
|||
}
|
||||
|
||||
var DataDecoder = function(data, offset, length) {
|
||||
this.data = JSON.parse(util.decodeUtf8(new Uint8Array(data.buffer, offset, length)));
|
||||
this.data = JSON.parse(util.decodeUtf8(new Int8Array(data.buffer, offset, length)));
|
||||
this.current = [];
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ Native["com/sun/midp/crypto/SHA.nativeFinal.([BII[BI[I[I[I[I)V"] = function(inBu
|
|||
}
|
||||
|
||||
var hash = hasher.digest();
|
||||
outBuf.set(new Uint8Array(hash.buffer), outOff);
|
||||
outBuf.set(new Int8Array(hash.buffer), outOff);
|
||||
|
||||
// XXX Call the reset method instead to completely reset the object.
|
||||
data.set(MIDP.emptyDataArray);
|
||||
|
@ -120,7 +120,7 @@ Native["com/sun/midp/crypto/SHA.nativeClone.([I)V"] = function(data) {
|
|||
};
|
||||
|
||||
Native["com/sun/midp/crypto/MD5.nativeUpdate.([BII[I[I[I[I)V"] = function(inBuf, inOff, inLen, state, num, count, data) {
|
||||
MIDP.getMD5Hasher(data).update(MIDP.bin2String(new Uint8Array(inBuf.subarray(inOff, inOff + inLen))));
|
||||
MIDP.getMD5Hasher(data).update(MIDP.bin2String(new Int8Array(inBuf.subarray(inOff, inOff + inLen))));
|
||||
};
|
||||
|
||||
Native["com/sun/midp/crypto/MD5.nativeFinal.([BII[BI[I[I[I[I)V"] = function(inBuf, inOff, inLen, outBuf, outOff, state, num, count, data) {
|
||||
|
|
|
@ -174,7 +174,7 @@ NokiaMessagingLocalMsgConnection.prototype.sendMessageToServer = function(messag
|
|||
|
||||
default:
|
||||
console.error("(nokia.messaging) event " + name + " not implemented " +
|
||||
util.decodeUtf8(new Uint8Array(message.data.buffer, message.offset, message.length)));
|
||||
util.decodeUtf8(new Int8Array(message.data.buffer, message.offset, message.length)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -381,7 +381,7 @@ NokiaPhoneStatusLocalMsgConnection.prototype.sendMessageToServer = function(mess
|
|||
|
||||
default:
|
||||
console.error("(nokia.phone-status) Query " + decoder.getName() + " not implemented " +
|
||||
util.decodeUtf8(new Uint8Array(message.data.buffer, message.offset, message.length)));
|
||||
util.decodeUtf8(new Int8Array(message.data.buffer, message.offset, message.length)));
|
||||
break;
|
||||
}
|
||||
} else if (queryKind === "Disable") {
|
||||
|
@ -407,7 +407,7 @@ NokiaPhoneStatusLocalMsgConnection.prototype.sendMessageToServer = function(mess
|
|||
|
||||
default:
|
||||
console.error("(nokia.phone-status) event " + name + " not implemented " +
|
||||
util.decodeUtf8(new Uint8Array(message.data.buffer, message.offset, message.length)));
|
||||
util.decodeUtf8(new Int8Array(message.data.buffer, message.offset, message.length)));
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
@ -526,7 +526,7 @@ NokiaContactsLocalMsgConnection.prototype.sendMessageToServer = function(message
|
|||
var numEntries = decoder.getValue(DataType.ULONG);
|
||||
if (numEntries !== 1) {
|
||||
console.error("(nokia.contacts) event getFirst with numEntries != 1 not implemented " +
|
||||
util.decodeUtf8(new Uint8Array(message.data.buffer, message.offset, message.length)));
|
||||
util.decodeUtf8(new Int8Array(message.data.buffer, message.offset, message.length)));
|
||||
}
|
||||
|
||||
this.getFirstOrNext(trans_id, "getFirst");
|
||||
|
@ -542,12 +542,12 @@ NokiaContactsLocalMsgConnection.prototype.sendMessageToServer = function(message
|
|||
var includeStartEntry = decoder.getValue(DataType.BOOLEAN);
|
||||
if (includeStartEntry == 1) {
|
||||
console.error("(nokia.contacts) event getNext with includeStartEntry == true not implemented " +
|
||||
util.decodeUtf8(new Uint8Array(message.data.buffer, message.offset, message.length)));
|
||||
util.decodeUtf8(new Int8Array(message.data.buffer, message.offset, message.length)));
|
||||
}
|
||||
var numEntries = decoder.getValue(DataType.ULONG);
|
||||
if (numEntries !== 1) {
|
||||
console.error("(nokia.contacts) event getNext with numEntries != 1 not implemented " +
|
||||
util.decodeUtf8(new Uint8Array(message.data.buffer, message.offset, message.length)));
|
||||
util.decodeUtf8(new Int8Array(message.data.buffer, message.offset, message.length)));
|
||||
}
|
||||
|
||||
this.getFirstOrNext(trans_id, "getNext");
|
||||
|
@ -555,7 +555,7 @@ NokiaContactsLocalMsgConnection.prototype.sendMessageToServer = function(message
|
|||
|
||||
default:
|
||||
console.error("(nokia.contacts) event " + name + " not implemented " +
|
||||
util.decodeUtf8(new Uint8Array(message.data.buffer, message.offset, message.length)));
|
||||
util.decodeUtf8(new Int8Array(message.data.buffer, message.offset, message.length)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -684,7 +684,7 @@ NokiaFileUILocalMsgConnection.prototype.sendMessageToServer = function(message)
|
|||
|
||||
default:
|
||||
console.error("(nokia.file-ui) event " + name + " not implemented " +
|
||||
util.decodeUtf8(new Uint8Array(message.data.buffer, message.offset, message.length)));
|
||||
util.decodeUtf8(new Int8Array(message.data.buffer, message.offset, message.length)));
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
@ -756,7 +756,7 @@ NokiaImageProcessingLocalMsgConnection.prototype.sendMessageToServer = function(
|
|||
|
||||
if (aspect != "FullImage" && aspect != "LockToPartialView") {
|
||||
console.error("(nokia.image-processing) event " + name + " with aspect != 'FullImage' or 'LockToPartialView' not implemented " +
|
||||
util.decodeUtf8(new Uint8Array(message.data.buffer, message.offset, message.length)));
|
||||
util.decodeUtf8(new Int8Array(message.data.buffer, message.offset, message.length)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -859,7 +859,7 @@ NokiaImageProcessingLocalMsgConnection.prototype.sendMessageToServer = function(
|
|||
|
||||
default:
|
||||
console.error("(nokia.image-processing) event " + name + " not implemented " +
|
||||
util.decodeUtf8(new Uint8Array(message.data.buffer, message.offset, message.length)));
|
||||
util.decodeUtf8(new Int8Array(message.data.buffer, message.offset, message.length)));
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
@ -913,7 +913,7 @@ NokiaProductInfoLocalMsgConnection.prototype.sendMessageToServer = function(mess
|
|||
break;
|
||||
default:
|
||||
console.error("(nokia.status-info) event " + name + " not implemented " +
|
||||
util.decodeUtf8(new Uint8Array(message.data.buffer, message.offset, message.length)));
|
||||
util.decodeUtf8(new Int8Array(message.data.buffer, message.offset, message.length)));
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
@ -1038,7 +1038,7 @@ NokiaActiveStandbyLocalMsgConnection.prototype.sendMessageToServer = function(me
|
|||
|
||||
default:
|
||||
console.error("(nokia.active-standby) event " + name + " not implemented " +
|
||||
util.decodeUtf8(new Uint8Array(message.data.buffer, message.offset, message.length)));
|
||||
util.decodeUtf8(new Int8Array(message.data.buffer, message.offset, message.length)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1124,7 +1124,7 @@ Native["org/mozilla/io/LocalMsgConnection.sendData.([BII)V"] = function(data, of
|
|||
this.connection.sendMessageToClient(message);
|
||||
} else {
|
||||
if (MIDP.FakeLocalMsgServers.indexOf(this.protocolName) != -1) {
|
||||
console.warn("sendData (" + util.decodeUtf8(new Uint8Array(data.buffer, offset, length)) + ") to an unimplemented localmsg server (" + this.protocolName + ")");
|
||||
console.warn("sendData (" + util.decodeUtf8(new Int8Array(data.buffer, offset, length)) + ") to an unimplemented localmsg server (" + this.protocolName + ")");
|
||||
}
|
||||
|
||||
this.connection.sendMessageToServer(message);
|
||||
|
|
|
@ -714,7 +714,7 @@ PlayerContainer.prototype.getRecordedSize = function() {
|
|||
PlayerContainer.prototype.getRecordedData = function(offset, size, buffer) {
|
||||
var toRead = (size < this.audioRecorder.data.length) ? size : this.audioRecorder.data.byteLength;
|
||||
buffer.set(this.audioRecorder.data.subarray(0, toRead), offset);
|
||||
this.audioRecorder.data = new Uint8Array(this.audioRecorder.data.buffer.slice(toRead));
|
||||
this.audioRecorder.data = new Int8Array(this.audioRecorder.data.buffer.slice(toRead));
|
||||
};
|
||||
|
||||
PlayerContainer.prototype.startSnapshot = function(imageType) {
|
||||
|
@ -732,7 +732,7 @@ PlayerContainer.prototype.getDuration = function() {
|
|||
var AudioRecorder = function(aMimeType) {
|
||||
this.mimeType = aMimeType || "audio/3gpp";
|
||||
this.eventListeners = {};
|
||||
this.data = new Uint8Array();
|
||||
this.data = new Int8Array();
|
||||
this.sender = DumbPipe.open("audiorecorder", {
|
||||
mimeType: this.mimeType
|
||||
}, this.recipient.bind(this));
|
||||
|
@ -816,7 +816,7 @@ AudioRecorder.prototype.stop = function() {
|
|||
// The audio data we received are encoded with a proper format, it doesn't
|
||||
// make sense to concatenate them like the socket, so let just override
|
||||
// the buffered data here.
|
||||
var data = new Uint8Array(message.data);
|
||||
var data = new Int8Array(message.data);
|
||||
if (this.getContentType() === "audio/amr") {
|
||||
data = Media.convert3gpToAmr(data);
|
||||
}
|
||||
|
@ -854,7 +854,7 @@ AudioRecorder.prototype.pause = function() {
|
|||
// The audio data we received are encoded with a proper format, it doesn't
|
||||
// make sense to concatenate them like the socket, so let just override
|
||||
// the buffered data here.
|
||||
this.data = new Uint8Array(message.data);
|
||||
this.data = new Int8Array(message.data);
|
||||
resolve(1);
|
||||
}.bind(this);
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ Native["com/sun/midp/jarutil/JarReader.readJarEntry0.(Ljava/lang/String;Ljava/la
|
|||
if (!bytes)
|
||||
throw $.newIOException();
|
||||
var length = bytes.byteLength;
|
||||
var data = new Uint8Array(bytes);
|
||||
var data = new Int8Array(bytes);
|
||||
var array = J2ME.newByteArray(length);
|
||||
for (var n = 0; n < length; ++n)
|
||||
array[n] = data[n];
|
||||
|
@ -535,7 +535,7 @@ Native["com/sun/midp/util/ResourceHandler.loadRomizedResource0.(Ljava/lang/Strin
|
|||
}
|
||||
var len = data.byteLength;
|
||||
var bytes = J2ME.newByteArray(len);
|
||||
var src = new Uint8Array(data);
|
||||
var src = new Int8Array(data);
|
||||
for (var n = 0; n < bytes.byteLength; ++n)
|
||||
bytes[n] = src[n];
|
||||
return bytes;
|
||||
|
|
|
@ -65,7 +65,7 @@ Native["com/sun/midp/io/j2me/socket/Protocol.open0.([BI)V"] = function(ipBytes,
|
|||
this.options[SOCKET_OPT.RCVBUF] = 8192;
|
||||
this.options[SOCKET_OPT.SNDBUF] = 8192;
|
||||
|
||||
this.data = new Uint8Array();
|
||||
this.data = new Int8Array();
|
||||
this.waitingData = null;
|
||||
|
||||
this.socket.onopen = function() {
|
||||
|
@ -88,11 +88,11 @@ Native["com/sun/midp/io/j2me/socket/Protocol.open0.([BI)V"] = function(ipBytes,
|
|||
this.socket.ondata = (function(message) {
|
||||
// console.log("this.socket.ondata: " + JSON.stringify(message));
|
||||
if (this.data.byteLength === 0) {
|
||||
this.data = new Uint8Array(message.data);
|
||||
this.data = new Int8Array(message.data);
|
||||
} else {
|
||||
var newArray = new Uint8Array(this.data.byteLength + message.data.byteLength);
|
||||
var newArray = new Int8Array(this.data.byteLength + message.data.byteLength);
|
||||
newArray.set(this.data);
|
||||
newArray.set(new Uint8Array(message.data), this.data.byteLength);
|
||||
newArray.set(new Int8Array(message.data), this.data.byteLength);
|
||||
this.data = newArray;
|
||||
}
|
||||
|
||||
|
|
|
@ -797,7 +797,7 @@ Native["com/sun/cldc/i18n/j2me/UTF_8_Reader.readNative.([CII)I"] = function(cbuf
|
|||
};
|
||||
|
||||
Native["java/io/DataInputStream.bytesToUTF.([B)Ljava/lang/String;"] = function(bytearr) {
|
||||
var array = new Uint8Array(bytearr.buffer);
|
||||
var array = new Int8Array(bytearr.buffer);
|
||||
try {
|
||||
return J2ME.newString(util.decodeUtf8Array(array));
|
||||
} catch(e) {
|
||||
|
@ -860,7 +860,7 @@ Native["com/sun/cldc/i18n/j2me/UTF_8_Writer.encodeUTF8.([CII)[B"] = function(cbu
|
|||
var count = 0;
|
||||
|
||||
while (count < len) {
|
||||
var outputByte = new Uint8Array(4); // Never more than 4 encoded bytes
|
||||
var outputByte = new Int8Array(4); // Never more than 4 encoded bytes
|
||||
inputChar = 0xffff & cbuf[off + count];
|
||||
if (0 != pendingSurrogate) {
|
||||
if (0xdc00 <= inputChar && inputChar <= 0xdfff) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче