Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add toString to classes extending ByReference #1182

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Features
* [#1168](https://github.com/java-native-access/jna/pull/1168): Add `c.s.j.p.win32.Kernel32#SetProcessAffinityMask` - [@dbwiddis](https://github.com/dbwiddis).
* [#1169](https://github.com/java-native-access/jna/issues/1169): Wait for process in getLinuxLdPaths - [@rdesgroppes](https://github.com/rdesgroppes).
* [#1178](https://github.com/java-native-access/jna/pull/1178): Add `c.s.j.p.win32.IPHlpAPI#GetTcpStatistics`, `c.s.j.p.win32.IPHlpAPI#GetUdpStatistics`, `c.s.j.p.win32.IPHlpAPI#GetTcpStatisticsEx` and `c.s.j.p.win32.IPHlpAPI#GetUdpStatisticsEx` - [@dbwiddis](https://github.com/dbwiddis).
* [#1182](https://github.com/java-native-access/jna/pull/1182): Add `toString` to classes extending `c.s.j.ptr.ByReference` - [@dbwiddis](https://github.com/dbwiddis).

Bug Fixes
---------
Expand Down
10 changes: 10 additions & 0 deletions contrib/platform/src/com/sun/jna/platform/unix/X11.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ public Atom getValue() {
NativeLong value = getPointer().getNativeLong(0);
return (Atom)new Atom().fromNative(value, null);
}

@Override
public String toString() {
return super.toString(getValue());
}
}
class Colormap extends XID {
private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -251,6 +256,11 @@ public Window getValue() {
NativeLong value = getPointer().getNativeLong(0);
return value.longValue() == X11.None ? Window.None : new Window(value.longValue());
}

@Override
public String toString() {
return super.toString(getValue());
}
}
class Pixmap extends Drawable {
private static final long serialVersionUID = 1L;
Expand Down
5 changes: 5 additions & 0 deletions contrib/platform/src/com/sun/jna/platform/win32/BaseTSD.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ public ULONG_PTR getValue() {
? getPointer().getInt(0)
: getPointer().getLong(0));
}

@Override
public String toString() {
return super.toString(getValue());
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ public void setValue(MC_DISPLAY_TECHNOLOGY_TYPE value) {
public MC_DISPLAY_TECHNOLOGY_TYPE getValue() {
return EnumUtils.fromInteger(getPointer().getInt(0), MC_DISPLAY_TECHNOLOGY_TYPE.class);
}

@Override
public String toString() {
return super.toString(getValue());
}
}
}

Expand Down Expand Up @@ -440,6 +445,11 @@ public void setValue(MC_COLOR_TEMPERATURE value) {
public MC_COLOR_TEMPERATURE getValue() {
return EnumUtils.fromInteger(getPointer().getInt(0), MC_COLOR_TEMPERATURE.class);
}

@Override
public String toString() {
return super.toString(getValue());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ public void setValue(MC_VCP_CODE_TYPE value) {
public MC_VCP_CODE_TYPE getValue() {
return EnumUtils.fromInteger(getPointer().getInt(0), MC_VCP_CODE_TYPE.class);
}

@Override
public String toString() {
return super.toString(getValue());
}
}
}
}
Expand Down
21 changes: 21 additions & 0 deletions contrib/platform/src/com/sun/jna/platform/win32/OaIdl.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ public void setValue(VARIANT_BOOL value) {
public VARIANT_BOOL getValue() {
return new VARIANT_BOOL(getPointer().getShort(0));
}

@Override
public String toString() {
return super.toString(getValue());
}
}

public static class _VARIANT_BOOLByReference extends ByReference {
Expand All @@ -219,6 +224,11 @@ public void setValue(VARIANT_BOOL value) {
public VARIANT_BOOL getValue() {
return new VARIANT_BOOL(getPointer().getShort(0));
}

@Override
public String toString() {
return super.toString(getValue());
}
}

@FieldOrder({"date"})
Expand Down Expand Up @@ -311,6 +321,11 @@ public void setValue(DISPID value) {
public DISPID getValue() {
return new DISPID(getPointer().getInt(0));
}

@Override
public String toString() {
return super.toString(getValue());
}
}

public static class MEMBERID extends DISPID {
Expand Down Expand Up @@ -342,6 +357,11 @@ public void setValue(MEMBERID value) {
public MEMBERID getValue() {
return new MEMBERID(getPointer().getInt(0));
}

@Override
public String toString() {
return super.toString(getValue());
}
}

// The Collect property. You use this property if the method you are calling
Expand Down Expand Up @@ -895,6 +915,7 @@ public void destroy() {
/**
* Implemented to satisfy Closeable interface, delegates to destroy.
*/
@Override
public void close() {
destroy();
}
Expand Down
13 changes: 12 additions & 1 deletion contrib/platform/src/com/sun/jna/platform/win32/WTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
*/
package com.sun.jna.platform.win32;

import java.io.UnsupportedEncodingException;

import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.PointerType;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.WinDef.USHORT;
import com.sun.jna.ptr.ByReference;
import java.io.UnsupportedEncodingException;

/**
* Constant defined in WTypes.h
Expand Down Expand Up @@ -170,6 +171,11 @@ public BSTR getValue() {
public String getString() {
return this.getValue().getValue();
}

@Override
public String toString() {
return super.toString(getValue());
}
}

public static class LPSTR extends PointerType {
Expand Down Expand Up @@ -317,5 +323,10 @@ public void setValue(VARTYPE value) {
public VARTYPE getValue() {
return new VARTYPE(getPointer().getShort(0));
}

@Override
public String toString() {
return super.toString(getValue());
}
}
}
55 changes: 55 additions & 0 deletions contrib/platform/src/com/sun/jna/platform/win32/WinDef.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ public void setValue(WORD value) {
public WORD getValue() {
return new WORD(getPointer().getShort(0));
}

@Override
public String toString() {
return super.toString(getValue());
}
}

/**
Expand Down Expand Up @@ -207,6 +212,11 @@ public void setValue(DWORD value) {
public DWORD getValue() {
return new DWORD(getPointer().getInt(0));
}

@Override
public String toString() {
return super.toString(getValue());
}
}

/**
Expand Down Expand Up @@ -278,6 +288,11 @@ public void setValue(LONG value) {
public LONG getValue() {
return new LONG(getPointer().getInt(0));
}

@Override
public String toString() {
return super.toString(getValue());
}
}

/**
Expand Down Expand Up @@ -349,6 +364,11 @@ public void setValue(LONGLONG value) {
public LONGLONG getValue() {
return new LONGLONG(getPointer().getLong(0));
}

@Override
public String toString() {
return super.toString(getValue());
}
}

/**
Expand Down Expand Up @@ -906,6 +926,11 @@ public void setValue(ULONG value) {
public ULONG getValue() {
return new ULONG(getPointer().getInt(0));
}

@Override
public String toString() {
return super.toString(getValue());
}
}

/**
Expand Down Expand Up @@ -977,6 +1002,11 @@ public void setValue(ULONGLONG value) {
public ULONGLONG getValue() {
return new ULONGLONG(getPointer().getLong(0));
}

@Override
public String toString() {
return super.toString(getValue());
}
}

/**
Expand Down Expand Up @@ -1254,6 +1284,11 @@ public void setValue(USHORT value) {
public USHORT getValue() {
return new USHORT(getPointer().getShort(0));
}

@Override
public String toString() {
return super.toString(getValue());
}
}

/**
Expand Down Expand Up @@ -1357,6 +1392,11 @@ public void setValue(UINT value) {
public UINT getValue() {
return new UINT(getPointer().getInt(0));
}

@Override
public String toString() {
return super.toString(getValue());
}
}

/**
Expand Down Expand Up @@ -1421,6 +1461,11 @@ public void setValue(SCODE value) {
public SCODE getValue() {
return new SCODE(getPointer().getInt(0));
}

@Override
public String toString() {
return super.toString(getValue());
}
}

/**
Expand Down Expand Up @@ -1592,6 +1637,11 @@ public void setValue(BOOL value) {
public BOOL getValue() {
return new BOOL(getPointer().getInt(0));
}

@Override
public String toString() {
return super.toString(getValue());
}
}

/**
Expand Down Expand Up @@ -1728,6 +1778,11 @@ public void setValue(CHAR value) {
public CHAR getValue() {
return new CHAR(getPointer().getByte(0));
}

@Override
public String toString() {
return super.toString(getValue());
}
}

/**
Expand Down
15 changes: 15 additions & 0 deletions contrib/platform/src/com/sun/jna/platform/win32/WinNT.java
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,11 @@ public PSID getValue() {
return new PSID(p);
}
}

@Override
public String toString() {
return super.toString(getValue());
}
}

/**
Expand Down Expand Up @@ -1362,6 +1367,11 @@ public HANDLE getValue() {
h.setPointer(p);
return h;
}

@Override
public String toString() {
return super.toString(getValue());
}
}

/**
Expand Down Expand Up @@ -2562,6 +2572,11 @@ public ACL getValue() {
return new ACL(p);
}
}

@Override
public String toString() {
return super.toString(getValue());
}
}

@FieldOrder({"Revision", "Sbz1", "Control", "Owner", "Group", "Sacl", "Dacl"})
Expand Down
5 changes: 5 additions & 0 deletions contrib/platform/src/com/sun/jna/platform/win32/WinReg.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public HKEY getValue() {
h.setPointer(p);
return h;
}

@Override
public String toString() {
return super.toString(getValue());
}
}

HKEY HKEY_CLASSES_ROOT = new HKEY(0x80000000);
Expand Down
Loading