Skip to content

Commit c1a171d

Browse files
committed
Merge branch 'winspool_1' of https://github.com/mlfreeman2/jna
2 parents 5bbf48b + 536f2ec commit c1a171d

File tree

108 files changed

+3679
-2752
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+3679
-2752
lines changed

CHANGES.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ Features
2929
* [#562](https://github.com/java-native-access/jna/pull/562): Added `com.sun.jna.platform.win32.VersionUtil` with `getFileVersionInfo` utility method to get file major, minor, revision, and build version parts - [@mlfreeman2](https://github.com/mlfreeman2).
3030
* [#563](https://github.com/java-native-access/jna/pull/563): Added `com.sun.jna.platform.win32.Wininet` with the following 4 methods: `FindFirstUrlCacheEntry`, `DeleteUrlCacheEntry`, `FindCloseUrlCache`, `FindNextUrlCacheEntry`, and the `INTERNET_CACHE_ENTRY_INFO` structure, and a helper in `com.sun.jna.platform.win32.WininetUtil` for parsing WinInet's cache - [@mlfreeman2](https://github.com/mlfreeman2).
3131
* [#567](https://github.com/java-native-access/jna/pull/567): Added `PrintWindow`, `IsWindowEnabled`, `IsWindow`, `FindWindowEx`, `GetAncestor`, `GetCursorPos`, `SetCursorPos`, `SetWinEventHook`, `UnhookWinEvent`, `CopyIcon`, and `GetClassLong` to `com.sun.jna.platform.win32.User32` and supporting constants to `com.sun.jna.platform.win32.WinUser` - [@mlfreeman2](https://github.com/mlfreeman2).
32-
* [#569](https://github.com/java-native-access/jna/pull/569): Added `com.sun.jna.platform.win32.Winspool.PRINTER_INFO_2` support and GetPrinter function in `com.sun.jna.platform.win32.Winspool` - [@IvanRF](https://github.com/IvanRF).
33-
32+
* [#573](https://github.com/java-native-access/jna/pull/573): Added `EnumProcessModules`, `GetModuleInformation`, and `GetProcessImageFileName` to `com.sun.jna.platform.win32.Psapi` and added `ExtractIconEx` to `com.sun.jna.platform.win32.Shell32` - [@mlfreeman2](https://github.com/mlfreeman2).
33+
* [#574](https://github.com/java-native-access/jna/pull/574): Using static final un-modifiable List of field names for structure(s) [@lgoldstein](https://github.com/lgoldstein).
34+
* [#569](https://github.com/java-native-access/jna/pull/569): Added `com.sun.jna.platform.win32.Winspool.PRINTER_INFO_2` support. Added GetPrinter and ClosePrinter functions in `com.sun.jna.platform.win32.Winspool` - [@IvanRF](https://github.com/IvanRF).
3435

3536
Bug Fixes
3637
---------

contrib/ntservice/src/jnacontrib/jna/Advapi32.java

+14-6
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ public int callback(int dwControl, int dwEventType,
151151
* SERVICE_STATUS,LPSERVICE_STATUS;
152152
*/
153153
public static class SERVICE_STATUS extends Structure {
154+
public static final List<String> FIELDS = createFieldsOrder(
155+
"dwServiceType", "dwCurrentState", "dwControlsAccepted", "dwWin32ExitCode", "dwServiceSpecificExitCode", "dwCheckPoint", "dwWaitHint");
156+
154157
public int dwServiceType;
155158
public int dwCurrentState;
156159
public int dwControlsAccepted;
@@ -159,8 +162,9 @@ public static class SERVICE_STATUS extends Structure {
159162
public int dwCheckPoint;
160163
public int dwWaitHint;
161164

162-
protected List getFieldOrder() {
163-
return Arrays.asList(new String[] { "dwServiceType", "dwCurrentState", "dwControlsAccepted", "dwWin32ExitCode", "dwServiceSpecificExitCode", "dwCheckPoint", "dwWaitHint" });
165+
@Override
166+
protected List<String> getFieldOrder() {
167+
return FIELDS;
164168
}
165169
}
166170

@@ -170,11 +174,13 @@ protected List getFieldOrder() {
170174
* LPSERVICE_TABLE_ENTRY;
171175
*/
172176
public static class SERVICE_TABLE_ENTRY extends Structure {
177+
public static final List<String> FIELDS = createFieldsOrder("lpServiceName", "lpServiceProc");
173178
public String lpServiceName;
174179
public SERVICE_MAIN_FUNCTION lpServiceProc;
175180

176-
protected List getFieldOrder() {
177-
return Arrays.asList(new String[] { "lpServiceName", "lpServiceProc" });
181+
@Override
182+
protected List<String> getFieldOrder() {
183+
return FIELDS;
178184
}
179185
}
180186

@@ -186,10 +192,12 @@ public static abstract class ChangeServiceConfig2Info extends Structure {
186192
* SERVICE_DESCRIPTION,LPSERVICE_DESCRIPTION;
187193
*/
188194
public static class SERVICE_DESCRIPTION extends ChangeServiceConfig2Info {
195+
public static final List<String> FIELDS = createFieldsOrder("lpDescription");
189196
public String lpDescription;
190197

191-
protected List getFieldOrder() {
192-
return Arrays.asList(new String[] { "lpDescription" });
198+
@Override
199+
protected List<String> getFieldOrder() {
200+
return FIELDS;
193201
}
194202
}
195203
}

contrib/platform/src/com/sun/jna/platform/RasterRangesUtils.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
/**
3232
* Methods that are useful to decompose a raster into a set of rectangles.
33-
* An occupied pixel has two possible meanings, depending on the raster :
33+
* An occupied pixel has two possible meanings, depending on the raster :
3434
* <ul>
3535
* <li>if the raster has an alpha layer, occupied means with alpha not null</li>
3636
* <li>if the raster doesn't have any alpha layer, occupied means not completely black</li>
@@ -45,6 +45,7 @@ public class RasterRangesUtils {
4545
};
4646

4747
private static final Comparator<Object> COMPARATOR = new Comparator<Object>() {
48+
@Override
4849
public int compare(Object o1, Object o2) {
4950
return ((Rectangle)o1).x - ((Rectangle)o2).x;
5051
}
@@ -117,7 +118,7 @@ public static boolean outputOccupiedRanges(Raster raster, RangesOutput out) {
117118
*/
118119
public static boolean outputOccupiedRangesOfBinaryPixels(byte[] binaryBits, int w, int h, RangesOutput out) {
119120
Set<Rectangle> rects = new HashSet<Rectangle>();
120-
Set<Rectangle> prevLine = Collections.EMPTY_SET;
121+
Set<Rectangle> prevLine = Collections.<Rectangle>emptySet();
121122
int scanlineBytes = binaryBits.length / h;
122123
for (int row = 0; row < h; row++) {
123124
Set<Rectangle> curLine = new TreeSet<Rectangle>(COMPARATOR);
@@ -190,7 +191,7 @@ public static boolean outputOccupiedRangesOfBinaryPixels(byte[] binaryBits, int
190191
*/
191192
public static boolean outputOccupiedRanges(int[] pixels, int w, int h, int occupationMask, RangesOutput out) {
192193
Set<Rectangle> rects = new HashSet<Rectangle>();
193-
Set<Rectangle> prevLine = Collections.EMPTY_SET;
194+
Set<Rectangle> prevLine = Collections.<Rectangle>emptySet();
194195
for (int row = 0; row < h; row++) {
195196
Set<Rectangle> curLine = new TreeSet<Rectangle>(COMPARATOR);
196197
int idxOffset = row * w;

contrib/platform/src/com/sun/jna/platform/mac/Carbon.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package com.sun.jna.platform.mac;
1919

2020
import java.nio.IntBuffer;
21-
import java.util.Arrays;
2221
import java.util.List;
2322

2423
import com.sun.jna.Library;
@@ -72,22 +71,28 @@ public interface Carbon extends Library {
7271
int UnregisterEventHotKey(Pointer inHotKey);
7372

7473
public class EventTypeSpec extends Structure {
74+
public static final List<String> FIELDS = createFieldsOrder("eventClass", "eventKind");
75+
7576
public int eventClass;
7677
public int eventKind;
78+
7779
@Override
7880
protected List<String> getFieldOrder() {
79-
return Arrays.asList("eventClass", "eventKind");
81+
return FIELDS;
8082
}
8183
}
8284

8385
public static class EventHotKeyID extends Structure {
86+
public static final List<String> FIELDS = createFieldsOrder("signature", "id");
87+
8488
public int signature;
8589
public int id;
8690

8791
public static class ByValue extends EventHotKeyID implements Structure.ByValue { }
92+
8893
@Override
8994
protected List<String> getFieldOrder() {
90-
return Arrays.asList("signature", "id");
95+
return FIELDS;
9196
}
9297
}
9398

contrib/platform/src/com/sun/jna/platform/mac/MacFileUtils.java

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* Copyright (c) 2007-2013 Timothy Wall, All Rights Reserved
2-
*
2+
*
33
* This library is free software; you can redistribute it and/or
44
* modify it under the terms of the GNU Lesser General Public
55
* License as published by the Free Software Foundation; either
66
* version 2.1 of the License, or (at your option) any later version.
7-
*
7+
*
88
* This library is distributed in the hope that it will be useful,
99
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1010
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -15,19 +15,18 @@
1515
import java.io.File;
1616
import java.io.IOException;
1717
import java.util.ArrayList;
18-
import java.util.Arrays;
1918
import java.util.List;
2019

2120
import com.sun.jna.Library;
2221
import com.sun.jna.Native;
23-
import com.sun.jna.Pointer;
2422
import com.sun.jna.Structure;
2523
import com.sun.jna.ptr.PointerByReference;
2624
import com.sun.jna.ptr.ByteByReference;
2725
import com.sun.jna.platform.FileUtils;
2826

2927
public class MacFileUtils extends FileUtils {
3028

29+
@Override
3130
public boolean hasTrash() { return true; }
3231

3332
public interface FileManager extends Library {
@@ -44,19 +43,25 @@ public interface FileManager extends Library {
4443
int kFSPathMakeRefDoNotFollowLeafSymlink = 0x01;
4544

4645
class FSRef extends Structure {
46+
public static final List<String> FIELDS = createFieldsOrder("hidden");
4747
public byte[] hidden = new byte[80];
48-
protected List getFieldOrder() { return Arrays.asList(new String[] { "hidden" }); }
48+
49+
@Override
50+
protected List<String> getFieldOrder() {
51+
return FIELDS;
52+
}
4953
}
5054

5155
// Deprecated; use trashItemAtURL instead:
52-
// https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html#//apple_ref/occ/instm/NSFileManager/trashItemAtURL:resultingItemURL:error:
56+
// https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html#//apple_ref/occ/instm/NSFileManager/trashItemAtURL:resultingItemURL:error:
5357
int FSRefMakePath(FSRef fsref, byte[] path, int maxPathSize);
5458
int FSPathMakeRef(String source, int options, ByteByReference isDirectory);
5559
int FSPathMakeRefWithOptions(String source, int options, FSRef fsref, ByteByReference isDirectory);
5660
int FSPathMoveObjectToTrashSync(String source, PointerByReference target, int options);
5761
int FSMoveObjectToTrashSync(FSRef source, FSRef target, int options);
5862
}
5963

64+
@Override
6065
public void moveToTrash(File[] files) throws IOException {
6166
File home = new File(System.getProperty("user.home"));
6267
File trash = new File(home, ".Trash");
@@ -67,7 +72,7 @@ public void moveToTrash(File[] files) throws IOException {
6772
for (int i=0;i < files.length;i++) {
6873
File src = files[i];
6974
FileManager.FSRef fsref = new FileManager.FSRef();
70-
int status = FileManager.INSTANCE.FSPathMakeRefWithOptions(src.getAbsolutePath(),
75+
int status = FileManager.INSTANCE.FSPathMakeRefWithOptions(src.getAbsolutePath(),
7176
FileManager.kFSPathMakeRefDoNotFollowLeafSymlink,
7277
fsref, null);
7378
if (status != 0) {

contrib/platform/src/com/sun/jna/platform/mac/SystemB.java

+26-21
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
package com.sun.jna.platform.mac;
1919

20-
import java.util.Arrays;
2120
import java.util.List;
2221

2322
import com.sun.jna.Library;
@@ -59,25 +58,33 @@ public interface SystemB extends Library {
5958
int INT_SIZE = Native.getNativeSize(int.class);
6059

6160
public static class HostCpuLoadInfo extends Structure {
61+
public static final List<String> FIELDS = createFieldsOrder("cpu_ticks");
6262
public int cpu_ticks[] = new int[CPU_STATE_MAX];
6363

6464
@Override
6565
protected List<String> getFieldOrder() {
66-
return Arrays.asList("cpu_ticks");
66+
return FIELDS;
6767
}
6868
}
6969

7070
public static class HostLoadInfo extends Structure {
71+
public static final List<String> FIELDS = createFieldsOrder("avenrun", "mach_factor");
7172
public int[] avenrun = new int[3]; // scaled by LOAD_SCALE
7273
public int[] mach_factor = new int[3]; // scaled by LOAD_SCALE
7374

7475
@Override
7576
protected List<String> getFieldOrder() {
76-
return Arrays.asList("avenrun", "mach_factor");
77+
return FIELDS;
7778
}
7879
}
7980

8081
public static class VMStatistics extends Structure {
82+
public static final List<String> FIELDS = createFieldsOrder("free_count", "active_count",
83+
"inactive_count", "wire_count", "zero_fill_count",
84+
"reactivations", "pageins", "pageouts", "faults",
85+
"cow_faults", "lookups", "hits", "purgeable_count",
86+
"purges", "speculative_count");
87+
8188
public int free_count; // # of pages free
8289
public int active_count; // # of pages active
8390
public int inactive_count; // # of pages inactive
@@ -97,15 +104,25 @@ public static class VMStatistics extends Structure {
97104

98105
@Override
99106
protected List<String> getFieldOrder() {
100-
return Arrays.asList("free_count", "active_count",
101-
"inactive_count", "wire_count", "zero_fill_count",
102-
"reactivations", "pageins", "pageouts", "faults",
103-
"cow_faults", "lookups", "hits", "purgeable_count",
104-
"purges", "speculative_count");
107+
return FIELDS;
105108
}
106109
}
107110

108111
public static class VMStatistics64 extends Structure {
112+
public static final List<String> FIELDS = createFieldsOrder("free_count", "active_count",
113+
"inactive_count", "wire_count",
114+
"zero_fill_count", "reactivations",
115+
"pageins", "pageouts",
116+
"faults", "cow_faults",
117+
"lookups", "hits",
118+
"purges",
119+
"purgeable_count", "speculative_count",
120+
"decompressions", "compressions",
121+
"swapins", "swapouts",
122+
"compressor_page_count", "throttled_count",
123+
"external_page_count", "internal_page_count",
124+
"total_uncompressed_pages_in_compressor");
125+
109126
public int free_count; // # of pages free
110127
public int active_count; // # of pages active
111128
public int inactive_count; // # of pages inactive
@@ -139,19 +156,7 @@ public static class VMStatistics64 extends Structure {
139156

140157
@Override
141158
protected List<String> getFieldOrder() {
142-
return Arrays.asList("free_count", "active_count",
143-
"inactive_count", "wire_count",
144-
"zero_fill_count", "reactivations",
145-
"pageins", "pageouts",
146-
"faults", "cow_faults",
147-
"lookups", "hits",
148-
"purges",
149-
"purgeable_count", "speculative_count",
150-
"decompressions", "compressions",
151-
"swapins", "swapouts",
152-
"compressor_page_count", "throttled_count",
153-
"external_page_count", "internal_page_count",
154-
"total_uncompressed_pages_in_compressor");
159+
return FIELDS;
155160
}
156161
}
157162

contrib/platform/src/com/sun/jna/platform/unix/Resource.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
*/
1313
package com.sun.jna.platform.unix;
1414

15-
import java.util.Arrays;
1615
import java.util.List;
1716

1817
import com.sun.jna.Structure;
@@ -83,6 +82,8 @@ public interface Resource {
8382
int RLIMIT_NLIMITS = 16;
8483

8584
public static class Rlimit extends Structure {
85+
public static final List<String> FIELDS = createFieldsOrder("rlim_cur", "rlim_max");
86+
8687
/** The current (soft) limit. */
8788
public long rlim_cur;
8889

@@ -91,7 +92,7 @@ public static class Rlimit extends Structure {
9192

9293
@Override
9394
protected List<String> getFieldOrder() {
94-
return Arrays.asList(new String[] { "rlim_cur", "rlim_max" });
95+
return FIELDS;
9596
}
9697
}
9798

0 commit comments

Comments
 (0)