Skip to content

Commit

Permalink
When deriving from a native-mapped struct, need to provide an updated…
Browse files Browse the repository at this point in the history
… fromNative method

add standalone X11 test
  • Loading branch information
twall committed Dec 3, 2015
1 parent 5ec9eeb commit 02445e4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
6 changes: 6 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 @@ -286,8 +286,14 @@ protected List getFieldOrder() {
}
class PictFormat extends XID {
private static final long serialVersionUID = 1L;
public static final PictFormat None = null;
public PictFormat(long value) { super(value); }
public PictFormat() { this(0); }
public Object fromNative(Object nativeValue, FromNativeContext context) {
if (isNone(nativeValue))
return None;
return new PictFormat(((Number)nativeValue).longValue());
}
}
class XRenderPictFormat extends Structure {
public PictFormat id;
Expand Down
36 changes: 36 additions & 0 deletions contrib/platform/test/com/sun/jna/platform/unix/X11Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* Copyright (c) 2015 Timothy Wall, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* <p/>
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.unix;

import junit.framework.TestCase;

/**
* Exercise the {@link X11} class.
*
* @author [email protected]
*/
// @SuppressWarnings("unused")
public class X11Test extends TestCase {

public void testXrender() {
X11.Xrender.XRenderPictFormat s = new X11.Xrender.XRenderPictFormat();
s.getPointer().setInt(0, 25);
s.read();
}

public static void main(java.lang.String[] argList) {
junit.textui.TestRunner.run(X11Test.class);
}
}


0 comments on commit 02445e4

Please sign in to comment.