Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdecc38a

Browse files
committed
implicit boxing in lambda expressions
This had not been implemented.
1 parentf5cb0ca commitdecc38a

File tree

13 files changed

+84
-37
lines changed

13 files changed

+84
-37
lines changed
-15 KB
Binary file not shown.
35 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20250313105418
1+
20250318122834
-15 KB
Binary file not shown.
35 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20250313105418
1+
20250318122834

‎sources/net.sf.j2s.core/src/j2s/swingjs/Java2ScriptVisitor.java‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,7 @@ private void processMethodDeclaration(MethodDeclaration mnode, IMethodBinding mB
13831383

13841384
buffer.append(") ");
13851385
if (lambdaType !=NOT_LAMBDA) {
1386-
addLambdaBody(body);
1386+
addLambdaBody(body,mBinding.getReturnType());
13871387
if (body ==null)
13881388
return;
13891389
}elseif (isConstructor) {
@@ -7575,16 +7575,17 @@ private void addLambdaReuse(int pt, String anonName) {
75757575
buffer.append("(" +anonName +"$||(" +anonName +"$=(").append(tmp).append(")))");
75767576
}
75777577

7578-
privatevoidaddLambdaBody(ASTNodebody) {
7578+
privatevoidaddLambdaBody(ASTNodebody,ITypeBindingretType) {
75797579
if (bodyinstanceofBlock) {
7580+
buffer.append("/*block*/");
75807581
body.accept(this);
75817582
}else {
75827583
// there may be no return, but we still want to do this
75837584
buffer.append("{ return ");
75847585
if (body ==null)
75857586
return;// handled elsewhere
75867587
buffer.append("(");
7587-
body.accept(this);
7588+
addExpressionAsTargetType((Expression)body,retType,"r",null);
75887589
buffer.append(");}");
75897590
}
75907591
}
-15 KB
Binary file not shown.

‎sources/net.sf.j2s.java.core/src/swingjs/JSToolkit.java‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -262,26 +262,25 @@ public static Object getTextMetrics(HTML5CanvasContext2D context, Font font,
262262
if (text ==null ||text.length() ==0)
263263
return0;
264264
// Chrome delivers integer values, so we x 10 and then reduce.
265-
booleanisChrome = (/** @j2sNative J2S._isChrome || **/false);
265+
// just setting this true generally; we don't need huge precision, I think.
266+
//boolean isChrome = true || (/** @j2sNative J2S._isChrome || **/ false);
266267
@SuppressWarnings("unused")
267-
StringfontInfo =getCanvasFontScaled(font,isChrome ?10 :1);
268+
StringfontInfo =getCanvasFontScaled(font,100);//isChrome ?100 : 1);
268269
if (context ==null)
269270
context =getDefaultCanvasContext2d();
270271
Objecttm =null;
271272
/**
272273
* @j2sNative
273274
* context.font = fontInfo;
274275
* tm = context.measureText(text);
275-
if (isChrome) {
276-
tm = { "width":tm.width/10,
277-
"actualBoundingBoxAscent":tm.actualBoundingBoxAscent/10,
278-
"actualBoundingBoxDescent":tm.actualBoundingBoxDescent/10,
279-
"actualBoundingBoxLeft":tm.actualBoundingBoxLeft/10,
280-
"actualBoundingBoxRight":tm.actualBoundingBoxRight/10,
281-
"fontBoundingBoxAscent":tm.fontBoundingBoxAscent/10,
282-
"fontBoundingBoxDescent":tm.fontBoundingBoxDescent/10
283-
}
284-
}
276+
tm = { "width":tm.width/100,
277+
"actualBoundingBoxAscent":tm.actualBoundingBoxAscent/100,
278+
"actualBoundingBoxDescent":tm.actualBoundingBoxDescent/100,
279+
"actualBoundingBoxLeft":tm.actualBoundingBoxLeft/100,
280+
"actualBoundingBoxRight":tm.actualBoundingBoxRight/100,
281+
"fontBoundingBoxAscent":tm.fontBoundingBoxAscent/100,
282+
"fontBoundingBoxDescent":tm.fontBoundingBoxDescent/100
283+
}
285284
*/
286285
{
287286
}

‎sources/net.sf.j2s.java.core/src/test/Test_Font.java‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
importjava.awt.Graphics2D;
66
importjava.awt.font.FontRenderContext;
77
importjava.awt.font.TextLayout;
8+
importjava.text.NumberFormat;
9+
importjava.util.Locale;
810

911
importjavax.swing.JFrame;
1012
importjavax.swing.JLabel;
@@ -21,8 +23,33 @@
2123
*
2224
*/
2325
publicclassTest_Font {//extends Test_ {
26+
protectedstaticStringformatMDLFloat(floatfl) {
27+
Strings,fs ="";
28+
intl;
29+
NumberFormatnf =NumberFormat.getNumberInstance(Locale.ENGLISH);
30+
nf.setMinimumIntegerDigits(1);
31+
nf.setMaximumIntegerDigits(4);
32+
nf.setMinimumFractionDigits(4);
33+
nf.setMaximumFractionDigits(4);
34+
nf.setGroupingUsed(false);
35+
if (Double.isNaN(fl) ||Double.isInfinite(fl))
36+
s ="0.0000";
37+
else
38+
s =nf.format(fl);
39+
l =10 -s.length();
40+
for (intf =0;f <l;f++)
41+
fs +=" ";
42+
fs +=s;
43+
returnfs;
44+
}
45+
2446
publicstaticvoidmain(String[]args) {
2547

48+
49+
System.out.println(formatMDLFloat(2.3f));
50+
51+
if (true)
52+
return;
2653
JLabelc =newJLabel("testing");
2754
Graphics2Dg = (Graphics2D)c.getGraphics();
2855
assert (g ==null);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp