Encapsulates lookup of W32 API UNICODE/ASCII functions.
| 32 | * Encapsulates lookup of W32 API UNICODE/ASCII functions. |
| 33 | */ |
| 34 | public class W32APIFunctionMapper implements FunctionMapper { |
| 35 | public static final FunctionMapper UNICODE = new W32APIFunctionMapper(true); |
| 36 | public static final FunctionMapper ASCII = new W32APIFunctionMapper(false); |
| 37 | private final String suffix; |
| 38 | protected W32APIFunctionMapper(boolean unicode) { |
| 39 | this.suffix = unicode ? "W" : "A"; |
| 40 | } |
| 41 | /** |
| 42 | * Looks up the method name by adding a "W" or "A" suffix as appropriate. |
| 43 | */ |
| 44 | public String getFunctionName(NativeLibrary library, Method method) { |
| 45 | String name = method.getName(); |
| 46 | if (!name.endsWith("W") && !name.endsWith("A")) { |
| 47 | try { |
| 48 | name = library.getFunction(name + suffix, StdCallLibrary.STDCALL_CONVENTION).getName(); |
| 49 | } |
| 50 | catch(UnsatisfiedLinkError e) { |
| 51 | // ignore and let caller use undecorated name |
| 52 | } |
| 53 | } |
| 54 | return name; |
| 55 | } |
| 56 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…