Use the new fromJavaChars from runtime.ts in gfx code and remove util::fromJavaChars

This commit is contained in:
Marco Castelluccio 2015-07-27 03:29:57 +02:00
Родитель f9348ec582
Коммит fc7a09fc58
3 изменённых файлов: 11 добавлений и 19 удалений

Просмотреть файл

@ -437,10 +437,9 @@ var currentlyFocusedTextEditor;
return fontContext.measureText(String.fromCharCode(char)).width | 0;
};
Native["javax/microedition/lcdui/Font.charsWidth.([CII)I"] = function(addr, strAddr, offset, len) {
var str = J2ME.getArrayFromAddr(strAddr);
Native["javax/microedition/lcdui/Font.charsWidth.([CII)I"] = function(addr, charsAddr, offset, len) {
var fontContext = NativeMap.get(addr);
return calcStringWidth(fontContext, util.fromJavaChars(str).slice(offset, offset + len));
return calcStringWidth(fontContext, J2ME.fromJavaChars(charsAddr).slice(offset, offset + len));
};
Native["javax/microedition/lcdui/Font.substringWidth.(Ljava/lang/String;II)I"] = function(addr, strAddr, offset, len) {
@ -1029,8 +1028,7 @@ var currentlyFocusedTextEditor;
Native["javax/microedition/lcdui/Graphics.drawChars.([CIIIII)V"] =
function(addr, dataAddr, offset, len, x, y, anchor) {
var data = J2ME.getArrayFromAddr(dataAddr);
drawString(NativeMap.get(addr), util.fromJavaChars(data, offset, len), x, y, anchor);
drawString(NativeMap.get(addr), J2ME.fromJavaChars(dataAddr, offset, len), x, y, anchor);
};
Native["javax/microedition/lcdui/Graphics.drawChar.(CIII)V"] = function(addr, jChr, x, y, anchor) {

8
tools/lib.d.ts поставляемый
Просмотреть файл

@ -12196,6 +12196,14 @@ declare var TextEncoder: {
new (encoding: string): TextEncoder;
}
interface TextDecoder {
decode(data: Uint8Array): string;
}
declare var TextDecoder: {
prototype: TextDecoder;
new (encoding: string): TextDecoder;
}
interface HTMLObjectElement {
/**
* Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server.

14
util.js
Просмотреть файл

@ -47,19 +47,6 @@ var util = (function () {
return Long.fromNumber(d);
}
var jStringDecoder = new TextDecoder('utf-16');
function fromJavaChars(chars, offset, count) {
if (!chars) {
return null;
}
if (typeof count !== 'number')
count = chars.length;
if (typeof offset !== 'number')
offset = 0;
return jStringDecoder.decode(chars.subarray(offset, offset + count));
}
var id = (function() {
var gen = 0;
return function() {
@ -151,7 +138,6 @@ var util = (function () {
decodeUtf8Array: decodeUtf8Array,
double2int: double2int,
double2long: double2long,
fromJavaChars: fromJavaChars,
id: id,
compareTypedArrays: compareTypedArrays,
pad: pad,