Comparar commits

..

75 Commits

Autor SHA1 Mensagem Data
Wayne Meissner 130885fda7 3.0.9 release
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@739 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-30 20:22:28 +00:00
Wayne Meissner c4fc42f8f4 Bump version to 3.0.9 and update release-notes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@738 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-30 20:17:14 +00:00
Wayne Meissner 21e73c5fb9 Fix for issue #93 and JRUBY-3084.
This alters the library search algorithm slightly:
1) Searches jna.library.path and any custom (per-library) paths for a
   matching library.
2) If that fails, tries to load the mapped library name, using
   dlopen/LoadLibrary.
3) If that fails, add all paths back into the search path and try to locate
   the library in jna.platform.library.path with all the normal fallbacks.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@737 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-29 00:30:54 +00:00
Wayne Meissner b635bf5591 Build 3.0.8
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@735 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-18 21:01:42 +00:00
Timothy Wall be594bb1f6 provide String->primitive array conversion
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@734 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-17 17:29:32 +00:00
Timothy Wall 543e3fca98 add more return types
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@733 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-15 02:56:51 +00:00
Wayne Meissner b385d76dc6 Add support for jna.boot.library.path property. This is a list of paths to attempt to load the jna stub library from. Its needed by JRuby and possibly Jython, to load the stub library from the file system, as they both put jna.jar in -Xbootclasspath, and java.library.path/LD_LIBRARY_PATH are ignored in that situation.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@732 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-12 06:02:31 +00:00
Timothy Wall 2adc88fec3 fix build of dependent test library on w32-x86
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@731 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-08 12:33:58 +00:00
Timothy Wall 2a9e2ceb61 support notes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@730 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-07 11:13:40 +00:00
Timothy Wall 47fa804469 bump version
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@728 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-01 13:44:23 +00:00
Timothy Wall f70c01eee7 fix broken link
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@727 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-01 13:37:10 +00:00
Timothy Wall eb4ea07a2d update win32 natives
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@726 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-01 13:37:01 +00:00
Timothy Wall 55cd72baaa Fix class cast exception
read all TYPE_MAPPERs regardless of access

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@725 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-29 12:20:56 +00:00
Timothy Wall 940076d101 update demo files
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@724 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-26 00:41:56 +00:00
Timothy Wall 93ebb9f7a9 improve win32 dependent library loading
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@723 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-22 15:55:59 +00:00
Timothy Wall 1a17ea52d8 add win64 target
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@718 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-17 18:14:49 +00:00
Timothy Wall 68bc0c0c7c add win64 target
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@717 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-17 18:09:40 +00:00
Timothy Wall 0e7dd6b350 note Memory vs primitive array usage
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@716 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-17 12:21:23 +00:00
Timothy Wall b3b0bf3845 note Memory vs primitive array usage
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@715 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-17 12:17:58 +00:00
Timothy Wall ddc32f1e43 update main page
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@714 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-16 18:25:25 +00:00
Timothy Wall c9de508a2c 3.0.6 build
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@712 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-16 18:15:53 +00:00
Timothy Wall fac68bca4e update native
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@711 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-14 20:11:57 +00:00
Timothy Wall eaf250c3c6 struct/union improvements
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@710 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-12 14:05:07 +00:00
Timothy Wall 8b99772d29 clean up field type checking
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@709 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-11 18:34:54 +00:00
Timothy Wall 862a32e97e Fix pointer field read bug
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@708 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-11 17:23:48 +00:00
Timothy Wall 6cfb84d6ee more mingw-64 fixes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@707 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-11 14:01:49 +00:00
xylo 2fda7ca6f6 in Union: added methods getTypedValue() and setTypedValue() as abridgment for the commands u.setType(), u.read(), x = u.field; also added corresonding tests to class UnionTest
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@706 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-11 05:48:17 +00:00
Timothy Wall f2aecb53bc fix configure/build with mingw-64 (tests still fail)
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@705 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-11 03:19:41 +00:00
Timothy Wall 05fdc2f17a update native
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@704 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-10 17:21:11 +00:00
xylo b9868b993c take X11 from x11-addons branch
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@703 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-10 17:16:22 +00:00
Wayne Meissner 573d8eefd1 Updated i386-OpenBSD build
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@702 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-10 15:28:33 +00:00
Timothy Wall 51d64f29e6 clean up some libffi bits
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@700 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-09 15:08:58 +00:00
Timothy Wall a39ab60ae5 update natives
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@698 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-08 15:30:23 +00:00
Timothy Wall ba9671fae5 update natives
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@697 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-08 15:21:04 +00:00
Timothy Wall a9340f354d update native
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@696 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-08 14:59:09 +00:00
Timothy Wall f9d6b069f7 update native
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@695 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-08 14:50:59 +00:00
Timothy Wall c363d5790d update native
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@694 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-08 14:38:54 +00:00
Timothy Wall 15a50d2a26 update native
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@693 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-08 14:29:43 +00:00
Timothy Wall bffc188151 bump revision
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@692 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-08 13:06:41 +00:00
Timothy Wall e78205430c update native
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@691 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-08 13:05:23 +00:00
Timothy Wall 4ef76d4f85 Allow arbitrary callback method names
Allow specification of callback type mapper with TYPE_MAPPER
Allow write with uninitialized boxed primitives in Structure
Fix memory leak with callbacks called from native threads w/no java context
Fix Structure derived classes to allow setting TypeMapper

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@690 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-08 12:56:04 +00:00
Timothy Wall 967da46793 Fix memory leak in callbacks
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@689 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-07 17:32:02 +00:00
xylo 46899503bd take X11 from x11-addons branch
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@686 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-06 17:24:37 +00:00
Timothy Wall 2dcf0f774c add win64 note
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@685 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-04 15:34:24 +00:00
Timothy Wall d669db0cab update jars with win64 build
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@684 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-04 15:29:52 +00:00
Timothy Wall f8aabcc50a merge win64 branch
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@683 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-04 15:04:34 +00:00
Timothy Wall 4bb3ece8dc Fix transparent window error on win2k
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@669 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-01 19:33:56 +00:00
Timothy Wall 495a7765d2 include LICENSE.txt in src.zip
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@648 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-26 13:39:46 +00:00
Timothy Wall 225296f253 avoid more content dragging on OSX, or warn
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@647 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-22 14:35:27 +00:00
Timothy Wall 52e6900e7a fix typo
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@645 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-14 14:56:01 +00:00
Timothy Wall 557bff1465 update doc
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@644 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-14 14:53:14 +00:00
Timothy Wall add32ac107 bump version
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@643 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-14 14:52:56 +00:00
Timothy Wall f7699b98fb release 3.0.5
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@641 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-14 14:47:41 +00:00
Timothy Wall 05a8ec1fec add java.net maven repo plumbing
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@640 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-14 14:33:01 +00:00
Timothy Wall 004e63c433 allow String[] as callback argument/return
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@639 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-13 14:17:40 +00:00
Timothy Wall 898f41b95a avoid reallocating Integer objects
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@638 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-13 13:51:59 +00:00
Timothy Wall 859a6a75aa apply patch #81
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@637 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-09 12:10:11 +00:00
Timothy Wall b90dae6448 add sunos-sparc build compatible with solaris 8
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@636 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-08 04:45:14 +00:00
Timothy Wall dc1ddf4cff add usb for java
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@635 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-08 04:37:37 +00:00
Timothy Wall 46ef5d86c3 add usb for java
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@634 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-08 04:36:27 +00:00
Timothy Wall ac63a6b125 fix field access
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@633 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-07 12:25:26 +00:00
Timothy Wall 72778c97df Allow explicit setting of structure field order
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@632 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-07 11:11:07 +00:00
Timothy Wall b4b86081f9 address issue #79, optionally omit jnilib
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@631 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-05 17:16:02 +00:00
Timothy Wall e4a47a4ca5 update relnotes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@630 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-31 16:17:51 +00:00
Timothy Wall 79c60f6d4e Fix cursor tracking on alpha-masked windows
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@629 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-31 16:17:10 +00:00
Timothy Wall 4c4d55e0dc add backup in case pkg-config fails
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@628 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-31 16:03:24 +00:00
Timothy Wall 9504416beb Allow link against system libffi with 'ant -Ddynlink.native=true'
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@627 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-29 14:55:59 +00:00
Timothy Wall 99586d9b3f Provide src.zip for linux builds, old version now src-full.zip
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@626 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-29 13:50:45 +00:00
Timothy Wall 65b19cbbd3 Fix 32/64-bit library lookup where both arch versions exist
Try 'lib' prefix on w32

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@625 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-29 00:00:40 +00:00
Wayne Meissner 7b64f4443d More OpenBSD build changes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@624 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-26 05:49:53 +00:00
Wayne Meissner abb2e857be Revert md5 sum now that OpenBSD is fixed up
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@623 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-26 05:47:47 +00:00
Wayne Meissner df10745963 Use ggrep for OpenBSD. Not strictly correct, but grep -A1 on OpenBSD does not print out a '--' separator between matches. Strangely, -B1 does ...
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@622 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-26 05:47:30 +00:00
Wayne Meissner 3d729595d1 i386-OpenBSD port
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@621 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-26 05:47:12 +00:00
Timothy Wall 96a38d1895 Fix division by zero on OSX/ppc calculating struct size
Fix overwriting of already-initialized NativeMapped field in struct when calculating struct size

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@620 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-13 18:53:49 +00:00
Timothy Wall b4c1390af8 Work around OSX transparent window dragging bug
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@619 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-08 14:32:52 +00:00
324 arquivos alterados com 31668 adições e 1910 exclusões
+3
Ver Arquivo
@@ -22,6 +22,9 @@
# TODO
* pointer.setValue(), to handle NativeMapped types and move read/writeValue
methods out of Structure, to be used by Function w/NativeMapped[] parameter
* write structure to contiguous Java array, then write all at once to minimize
native calls. Otherwise, structs with lots of fields take a big performance
hit making a native call for each field.
+59 -16
Ver Arquivo
@@ -17,6 +17,8 @@
<property name="jar" value="${name}.jar"/>
<property name="debug" value="true"/>
<property name="debug.native" value="false"/>
<property name="cflags_extra.native" value=""/>
<property name="dynlink.native" value="false"/>
<property name="native" location="native"/>
<property name="src" location="src"/>
<property name="dist" location="dist"/>
@@ -31,13 +33,13 @@
<!-- JNA library release version -->
<property name="jna.major" value="3"/>
<property name="jna.minor" value="0"/>
<property name="jna.revision" value="4"/>
<property name="jna.revision" value="9"/>
<property name="jna.build" value="${build.number}"/>
<property name="jna.version" value="${jna.major}.${jna.minor}.${jna.revision}"/>
<!-- jnidispatch library release version -->
<property name="jni.major" value="3"/>
<property name="jni.minor" value="0"/>
<property name="jni.revision" value="4"/>
<property name="jni.revision" value="6"/>
<property name="jni.build" value="${build.number}"/>
<property name="jni.version" value="${jni.major}.${jni.minor}.${jni.revision}"/>
<property name="jni.md5" value="892beacd437514d23ed9b1cefeb2ead6"/>
@@ -65,6 +67,13 @@
<echo>Java version: ${java.version}, compatibility: ${compatibility}</echo>
<echo>JNA version ${jna.version}, native API version ${jni.version}</echo>
<replaceregexp match="(&lt;version&gt;).*(&lt;/version&gt;)"
replace="\1${jna.version}\2"
file="pom.xml"/>
<condition property="jar.omitted" value="**/*jnidispatch*" else="jnilib-included">
<isset property="omit-jnilib"/>
</condition>
<condition property="vm.arch" value="-d64" else="">
<or>
<equals arg1="${sun.arch.data.model}" arg2="64" trim="true"/>
@@ -105,6 +114,9 @@
<condition property="os.prefix" value="freebsd-${os.arch}">
<os name="FreeBSD"/>
</condition>
<condition property="os.prefix" value="openbsd-${os.arch}">
<os name="OpenBSD"/>
</condition>
<fail unless="os.prefix" message="OS/arch not supported (${os.name}/${os.arch}), edit build.xml and native/Makefile to add it."/>
<condition property="jdk.home" value="${java.home}">
<available file="${java.home}/include"/>
@@ -189,7 +201,9 @@
<attribute name="Specification-Version" value="${spec.version}"/>
</section>
</manifest>
<fileset dir="${classes}"><patternset refid="jar-compiled"/></fileset>
<fileset dir="${classes}" excludes="${jar.omitted}">
<patternset refid="jar-compiled"/>
</fileset>
</jar>
</target>
<target name="examples" depends="jar,native">
@@ -216,6 +230,9 @@
<condition property="grep" value="/usr/sfw/bin/ggrep">
<os name="SunOS"/>
</condition>
<condition property="grep" value="ggrep">
<os name="OpenBSD"/>
</condition>
<property name="grep" value="grep"/>
<apply dir="${build.native}" executable="${grep}" parallel="true"
failonerror="true" relative="true" output="${md5.file}">
@@ -236,10 +253,12 @@
<echo>Invalidating native code, new checksum is ${md5}</echo>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/darwin.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-x86.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-amd64.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-i386.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-amd64.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-i386.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-amd64.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/openbsd-i386.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-x86.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-amd64.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-sparc.jar" overwrite="true"/>
@@ -317,7 +336,10 @@
<os name="SunOS"/>
</condition>
<condition property="make" value="gmake">
<os name="FreeBSD"/>
<or>
<os name="FreeBSD"/>
<os name="OpenBSD"/>
</or>
</condition>
<!-- Default make program -->
<property name="make" value="make"/>
@@ -326,6 +348,8 @@
<arg value="JAVA_HOME=${jdk.home}"/>
<arg value="JAVAH=${build.native}"/>
<arg value="DEBUG=${debug.native}"/>
<arg value="CFLAGS_EXTRA=${cflags_extra.native}"/>
<arg value="DYNAMIC_LIBFFI=${dynlink.native}"/>
<arg value="${make.CC}"/>
<arg value="${make.BUILD}"/>
<arg value="${make.SDKROOT}"/>
@@ -336,13 +360,13 @@
</exec>
<mkdir dir="${classes}/com/sun/jna/${os.prefix}"/>
<copy todir="${classes}/com/sun/jna/${os.prefix}">
<fileset dir="${build.native}"
<fileset dir="${build.native}"
includes="jnidispatch.dll,libjnidispatch.*"/>
</copy>
<mkdir dir="${eclipse.classes}/com/sun/jna/${os.prefix}"/>
<copy todir="${eclipse.classes}/com/sun/jna/${os.prefix}"
failonerror="false">
<fileset dir="${build.native}"
<fileset dir="${build.native}"
includes="jnidispatch.dll,libjnidispatch.*"/>
</copy>
<!-- For web start, native libraries may be provided in the root of -->
@@ -368,7 +392,7 @@
</target>
<!-- When running tests from an IDE, be sure to set jna.library.path -->
<!-- to where the test library (testlib) is found. Also need to add -Ddir.build.suffix=-d64 for 64-bit JVMs. -->
<!-- to where the test library (testlib) is found. -->
<target name="test" depends="jar,examples,compile-tests"
description="Run all unit tests">
<property name="test.fork" value="yes"/>
@@ -376,9 +400,13 @@
<property name="results.junit" location="${build}/junit-results"/>
<mkdir dir="${results.junit}"/>
<echo>Saving test results in ${results.junit}</echo>
<property name="tests.stdcall" value="**/win32/*StdCallTest.java"/>
<condition property="tests.platform" value="**/win32/*Test.java">
<os family="windows"/>
</condition>
<condition property="tests.exclude" value="**/win32/*StdCallTest.java">
<and><os family="windows"/><not><os arch="x86"/></not></and>
</condition>
<condition property="tests.platform" value="**/unix/*Test.java">
<and>
<os family="unix"/>
@@ -386,17 +414,19 @@
</and>
</condition>
<condition property="vmopt.arch" value="-d64" else="-Dignore">
<equals arg1="${vm.arch}" arg2="-d64" trim="true"/>
</condition>
<condition property="dir.build.suffix" value="-d64" else="">
<equals arg1="${vm.arch}" arg2="-d64" trim="true"/>
<and>
<!-- Sun 64-bit VM for windows doesn't support the -d64 switch -->
<not><os family="windows"/></not>
<equals arg1="${vm.arch}" arg2="-d64" trim="true"/>
</and>
</condition>
<property name="tests.platform" value=""/>
<property name="tests.exclude" value=""/>
<junit printsummary="yes" fork="${test.fork}" failureproperty="testfailure">
<jvmarg value="-Djna.library.path=${build.native}"/>
<!-- Avoid VM crashes, if possible -->
<jvmarg value="-Djna.protected=true"/>
<jvmarg value="-Ddir.build.suffix=${dir.build.suffix}"/>
<jvmarg value="-Djna.builddir=${build}"/>
<jvmarg value="${vmopt.arch}"/>
<classpath><path refid="test.runpath"/></classpath>
<formatter type="xml"/>
@@ -521,6 +551,12 @@
<zipfileset src="${dist}/freebsd-amd64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/freebsd-amd64"/>
<zipfileset src="${dist}/openbsd-i386.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/openbsd-i386"/>
<zipfileset src="${dist}/win32-amd64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/win32-amd64"/>
</jar>
<copy todir="${dist}">
<fileset dir="${build}">
@@ -531,13 +567,20 @@
<zip zipfile="${dist}/doc.zip">
<zipfileset dir="${javadoc}" prefix="javadoc"/>
</zip>
<!-- JNA sources only, for use in Linux build from source -->
<zip zipfile="${dist}/src.zip">
<zipfileset dir="." includes="build.xml,.classpath,.project"/>
<zipfileset dir="lib" includes="junit.jar" prefix="lib"/>
<zipfileset dir="nbproject" includes="**/*" prefix="nbproject"/>
<zipfileset dir="." includes="build.xml,LICENSE.txt"/>
<zipfileset dir="${src}" includes="**/*.java" prefix="src"/>
<zipfileset dir="${test.src}" includes="**/*.java" prefix="test"/>
<zipfileset dir="${native}" prefix="native"/>
<zipfileset dir="${native}" excludes="libffi,libffi/**/*" prefix="native"/>
</zip>
<!-- Full sources required to build and test everything -->
<zip zipfile="${dist}/src-full.zip">
<zipfileset src="${dist}/src.zip"/>
<zipfileset dir="lib" includes="junit.jar" prefix="lib"/>
<zipfileset dir="." includes=".classpath,.project"/>
<zipfileset dir="nbproject" includes="**/*" prefix="nbproject"/>
<zipfileset dir="${native}" includes="libffi,libffi/**/*" prefix="native"/>
</zip>
</target>
BIN
Ver Arquivo
Arquivo binário não exibido.
BIN
Ver Arquivo
Arquivo binário não exibido.
BIN
Ver Arquivo
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
BIN
Ver Arquivo
Arquivo binário não exibido.
BIN
Ver Arquivo
Arquivo binário não exibido.
BIN
Ver Arquivo
Arquivo binário não exibido.
Arquivo binário não exibido.
BIN
Ver Arquivo
Arquivo binário não exibido.
BIN
Ver Arquivo
Arquivo binário não exibido.
BIN
Ver Arquivo
Arquivo binário não exibido.
BIN
Ver Arquivo
Arquivo binário não exibido.
Arquivo binário não exibido.
BIN
Ver Arquivo
Arquivo binário não exibido.
externo Arquivo executável
BIN
Ver Arquivo
Arquivo binário não exibido.
BIN
Ver Arquivo
Arquivo binário não exibido.
+76 -38
Ver Arquivo
@@ -23,34 +23,40 @@
OS=$(shell uname | sed -e 's/\(CYGWIN\|MINGW32\).*/win32/g' \
-e 's/SunOS.*/solaris/g' \
-e 's/FreeBSD.*/freebsd/g' \
-e 's/OpenBSD.*/openbsd/g' \
-e 's/Darwin.*/darwin/g' \
-e 's/Linux.*/linux/g')
VERSION=3.0.4 # auto-generated by ant
VERSION=3.0.6 # auto-generated by ant
CHECKSUM=892beacd437514d23ed9b1cefeb2ead6 # auto-generated by ant
JAVA_INCLUDES=-I"$(JAVA_HOME)/include" \
-I"$(JAVA_HOME)/include/$(OS)"
LIBDIR=$(JAVA_HOME)/jre/lib/$(ARCH)
BUILD=../build/native
JAVAH=$(BUILD)
INSTALLDIR=../build/$(OS)
JNIDISPATCH_OBJS=$(BUILD)/dispatch.o $(BUILD)/callback.o $(EXTRAOBJS)
RSRC=$(BUILD)/rsrc.o
ifneq ($(DYNAMIC_LIBFFI),true)
FFI_SRC=$(shell pwd)/libffi
FFI_BUILD=$(BUILD)/libffi
FFI_LIB=$(FFI_BUILD)/.libs/libffi_convenience.a
FFI_CONFIG=--disable-static --with-pic=yes
FFI_LIB=$(FFI_BUILD)/.libs/libffi$(ARSFX)
FFI_ENV=CC="$(CC)" CFLAGS="$(CDEBUG)" CPPFLAGS="$(CDEFINES)"
FFI_CONFIG=--enable-static --disable-shared --with-pic=yes
endif
LIBRARY=$(BUILD)/$(LIBPFX)jnidispatch$(JNISFX)
TESTLIB=$(BUILD)/$(LIBPFX)testlib$(LIBSFX)
TESTLIB2=$(BUILD)/$(LIBPFX)testlib2$(LIBSFX)
# Reasonable defaults based on GCC
LIBPFX=lib
LIBSFX=.so
ARSFX=.a
JNISFX=$(LIBSFX)
CC=gcc
LD=gcc
LIBS=
# Default to Sun recommendations for JNI compilation
#COPT=-O2 -fomit-frame-pointer
COPT=-fno-omit-frame-pointer -fno-strict-aliasing
@@ -58,14 +64,21 @@ CASM=-S
ifeq ($(DEBUG),true)
CDEBUG=-g
endif
CFLAGS_EXTRA=
COUT=-o $@
CINCLUDES=$(JAVA_INCLUDES) -I"$(JAVAH)" -I$(FFI_BUILD)/include
CDEFINES=-D_REENTRANT
PCFLAGS=-W -Wall -Wno-unused -Wno-parentheses
CFLAGS=$(PCFLAGS) $(COPT) $(CDEBUG) $(CDEFINES) $(CINCLUDES) \
CFLAGS=$(PCFLAGS) $(CFLAGS_EXTRA) $(COPT) $(CDEBUG) $(CDEFINES) $(CINCLUDES) \
-DVERSION='"$(VERSION)"' -DCHECKSUM='"$(CHECKSUM)"'
LDFLAGS=-o $@ -shared
ifeq ($(DYNAMIC_LIBFFI),true)
CFLAGS += $(shell pkg-config --cflags libffi 2>/dev/null || echo)
LIBS += $(shell pkg-config --libs libffi 2>/dev/null || echo -lffi)
else
# -static-libgcc avoids gcc library incompatibilities across linux systems
LDFLAGS=-o $@ -shared -static-libgcc
LDFLAGS += -static-libgcc
endif
# Avoid bug in X11-based 1.5/1.6 VMs; dynamically load instead of linking
# See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6539705
#LIBS=-L"$(LIBDIR)" -ljawt
@@ -73,37 +86,41 @@ STRIP=strip -x
# end defaults
ifeq ($(OS),win32)
# Uncomment this line to use MSVC (doesn't yet work with libffi)
#CC=cl
ARCH=$(shell uname -m | sed 's/i.86/i386/g')
CDEFINES=-DHAVE_PROTECTION
ifeq ($(CC),cl)
LD=link
COPT=-O1 -Op
ifeq ($(DEBUG),true)
COPT=-Od
DBG=d
CDEBUG=-D_DEBUG -GZ -Zi
endif
COUT=-Fo$@
PCFLAGS=-nologo -MD$(DBG) -W3 -WX -GX -YX -Fd$(@D)/$* -Fp$(@D)/$*
CASM=-FAs
LDFLAGS=/pdb:$(subst .dll,,$@).pdb /implib:$(subst .dll,,$@).lib /debug /machine:i386 /pdbtype:sept /dll /nologo /opt:REF /incremental:no /out:$@
LIBDIR=/libpath:"$(JAVA_HOME)/lib"
#LIBS=$(LIBDIR) jawt.lib
WINDRES=windres
EXTRAOBJS=$(RSRC)
STRIP=@echo
else
CC += -mno-cygwin
LD += -mno-cygwin -Wl,--add-stdcall-alias
LIBDIR="$(JAVA_HOME)/lib"
#LIBS=$(LIBDIR)/jawt.lib
endif
LIBPFX=
LIBSFX=.dll
EXTRAOBJS=$(RSRC)
ifeq ($(CC),gcc)
CC += -mno-cygwin
LD += -mno-cygwin -Wl,--add-stdcall-alias
endif
ifeq ($(ARCH),amd64)
WINDRES=x86_64-pc-mingw32-windres
# Uncomment to enable MINGW64 cross compiler
# Last build attempt has too many runtime problems (alloca broken) (080831)
#MINGW = x86_64-pc-mingw32-gcc
ifneq ($(MINGW),)
CC = $(MINGW) -m64 -mno-cygwin
LD = $(CC)
LDFLAGS=-o $@ -shared
LIBS= -lmingwex -lkernel32 -lmsvcrt
FFI_CONFIG += --host=x86_64-pc-mingw32
else
# MSVC (wrapper scripts)
CC=$(FFI_SRC)/../cc.sh -m64
LD=$(FFI_SRC)/../ld.sh -m64
ARSFX=.lib
FFI_CONFIG += --host=x86_64-pc-mingw32 && rm -f include/ffitarget.h && cp $(FFI_SRC)/include/*.h $(FFI_SRC)/src/x86/ffitarget.h include
FFI_ENV += LD="$(LD)" CPP=cpp
endif
endif
endif
ifeq ($(OS),linux)
@@ -121,6 +138,14 @@ LDFLAGS=-o $@ -shared
CDEFINES+=-DHAVE_PROTECTION -DFFI_MMAP_EXEC_WRIT
endif
ifeq ($(OS),openbsd)
ARCH=$(shell uname -m | sed 's/i.86/i386/g')
PCFLAGS+=-fPIC
CINCLUDES+=-I/usr/X11R6/include
LDFLAGS=-o $@ -shared
CDEFINES+=-DHAVE_PROTECTION -DFFI_MMAP_EXEC_WRIT
endif
ifeq ($(OS),solaris)
ifeq ($(ARCH),)
ARCH=$(shell uname -p)
@@ -137,10 +162,12 @@ endif
endif
# Enable 64-bit builds if the arch demands it
ifeq ($(CC),gcc)
ifeq ($(ARCH),amd64)
CC += -m64
LD += -m64
endif
endif
ifeq ($(OS),darwin)
ARCH=$(shell arch)
@@ -156,8 +183,8 @@ SYSLIBROOT=-Wl,-syslibroot,$(SDKROOT)
ISYSROOT=-isysroot $(SDKROOT)
ARCHFLAGS=-arch ppc -arch i386
ifneq ($(findstring 10.5,$(SDKROOT)),)
ALT_ARCHS+=x86_64 #ppc64
ARCHFLAGS+=-arch x86_64 #-arch ppc64
ALT_ARCHS+=x86_64
ARCHFLAGS+=-arch x86_64
endif
endif
PCFLAGS+=$(ISYSROOT) -x objective-c
@@ -187,27 +214,37 @@ else
$(CC) $(CFLAGS) -c $< $(COUT)
endif
all: $(LIBRARY) $(TESTLIB)
all: $(LIBRARY) $(TESTLIB) $(TESTLIB2)
install:
mkdir $(INSTALLDIR)
cp $(LIBRARY) $(INSTALLDIR)
$(RSRC): $(BUILD)/jnidispatch.rc
windres -i $< -o $@
$(WINDRES) -i $< -o $@ \
|| (echo > $@.c && $(CC) $(CFLAGS) -c $@.c $(COUT))
$(LIBRARY): $(JNIDISPATCH_OBJS) $(FFI_LIB)
$(LD) $(LDFLAGS) $(JNIDISPATCH_OBJS) $(FFI_LIB) $(LIBS)
$(TESTLIB): $(BUILD)/testlib.o
$(LD) $(LDFLAGS) $< $(TESTDEF)
$(LD) $(LDFLAGS) $<
ifeq ($(ARSFX),.lib)
TESTDEP=$(TESTLIB:.dll=.lib)
else
TESTDEP=$(TESTLIB)
endif
$(TESTLIB2): $(BUILD)/testlib2.o
$(LD) $(LDFLAGS) $< $(TESTDEP)
ifneq ($(DYNAMIC_LIBFFI),true)
$(FFI_LIB):
@mkdir -p $(FFI_BUILD)
@if [ ! -f $(FFI_BUILD)/Makefile ]; then \
echo "Configuring libffi ($(ARCH))"; \
(cd $(FFI_BUILD) \
&& CC="$(CC)" CFLAGS="$(CDEBUG)" CPPFLAGS="$(CDEFINES)" $(FFI_SRC)/configure $(FFI_CONFIG)); \
&& $(FFI_ENV) $(FFI_SRC)/configure $(FFI_CONFIG)); \
fi
$(MAKE) -C $(FFI_BUILD)
ifneq ($(SDKROOT),)
@@ -225,6 +262,7 @@ ifneq ($(SDKROOT),)
/usr/bin/libtool -static -o $@.tmp $(FFI_BUILD)/.libs/${@F} $(BUILD)/libffi.*/.libs/${@F}
mv $@.tmp $@
endif
endif
clean:
$(RM) -rf $(BUILD)
+40 -23
Ver Arquivo
@@ -41,7 +41,6 @@ create_callback(JNIEnv* env, jobject obj, jobject method,
callback* cb;
ffi_abi abi = FFI_DEFAULT_ABI;
ffi_status status;
int args_size = 0;
jsize argc;
JavaVM* vm;
char rtype;
@@ -64,13 +63,13 @@ create_callback(JNIEnv* env, jobject obj, jobject method,
cb->param_jtypes[i] = get_jtype(env, cls);
cb->ffi_args[i] = get_ffi_type(env, cls, cb->param_jtypes[i]);
if (!cb->param_jtypes[i]) {
sprintf(msg, "Unsupported type at parameter %d", i);
snprintf(msg, sizeof(msg), "Unsupported type at parameter %d", i);
throwByName(env, EIllegalArgument, msg);
goto failure_cleanup;
}
}
#ifdef _WIN32
#if defined(_WIN32) && !defined(_WIN64)
if (calling_convention == CALLCONV_STDCALL) {
abi = FFI_STDCALL;
}
@@ -86,25 +85,30 @@ create_callback(JNIEnv* env, jobject obj, jobject method,
&cb->ffi_args[0]);
switch(status) {
case FFI_BAD_ABI:
sprintf(msg, "Invalid calling convention: %d", (int)calling_convention);
snprintf(msg, sizeof(msg),
"Invalid calling convention: %d", (int)calling_convention);
throwByName(env, EIllegalArgument, msg);
break;
case FFI_BAD_TYPEDEF:
sprintf(msg, "Invalid structure definition (native typedef error)");
snprintf(msg, sizeof(msg),
"Invalid structure definition (native typedef error)");
throwByName(env, EIllegalArgument, msg);
break;
case FFI_OK:
ffi_prep_closure_loc(cb->ffi_closure, &cb->ffi_cif, callback_dispatch, cb,
cb->x_closure);
return cb;
default:
sprintf(msg, "Native callback setup failure: error code %d", status);
snprintf(msg, sizeof(msg),
"Native callback setup failure: error code %d", status);
throwByName(env, EIllegalArgument, msg);
break;
}
failure_cleanup:
free_callback(env, cb);
return NULL;
}
void
@@ -115,23 +119,9 @@ free_callback(JNIEnv* env, callback *cb) {
}
static void
callback_dispatch(ffi_cif* cif, void* resp, void** cbargs, void* user_data) {
callback* cb = (callback *) user_data;
JavaVM* jvm = cb->vm;
callback_invoke(JNIEnv* env, callback *cb, ffi_cif* cif, void *resp, void **cbargs) {
jobject self;
JNIEnv* env;
int attached;
unsigned int i;
jobjectArray array;
attached = (*jvm)->GetEnv(jvm, (void *)&env, JNI_VERSION_1_4) == JNI_OK;
if (!attached) {
if ((*jvm)->AttachCurrentThread(jvm, (void *)&env, NULL) != JNI_OK) {
fprintf(stderr, "JNA: Can't attach to current thread\n");
return;
}
}
self = (*env)->NewLocalRef(env, cb->object);
// Avoid calling back to a GC'd object
if ((*env)->IsSameObject(env, self, NULL)) {
@@ -140,7 +130,10 @@ callback_dispatch(ffi_cif* cif, void* resp, void** cbargs, void* user_data) {
}
else {
jobject result;
array = (*env)->NewObjectArray(env, cif->nargs, classObject, NULL);
jobjectArray array =
(*env)->NewObjectArray(env, cif->nargs, classObject, NULL);
unsigned int i;
for (i=0;i < cif->nargs;i++) {
jobject arg = new_object(env, cb->param_jtypes[i], cbargs[i]);
(*env)->SetObjectArrayElement(env, array, i, arg);
@@ -154,6 +147,30 @@ callback_dispatch(ffi_cif* cif, void* resp, void** cbargs, void* user_data) {
extract_value(env, result, resp, cif->rtype->size);
}
}
}
static void
callback_dispatch(ffi_cif* cif, void* resp, void** cbargs, void* user_data) {
JavaVM* jvm = ((callback *)user_data)->vm;
JNIEnv* env;
int attached;
attached = (*jvm)->GetEnv(jvm, (void *)&env, JNI_VERSION_1_4) == JNI_OK;
if (!attached) {
if ((*jvm)->AttachCurrentThread(jvm, (void *)&env, NULL) != JNI_OK) {
fprintf(stderr, "JNA: Can't attach to current thread\n");
return;
}
}
// Give the callback its own local frame to ensure all local references
// are properly disposed
if ((*env)->PushLocalFrame(env, 16) < 0) {
fprintf(stderr, "JNA: Out of memory: Can't allocate local frame");
return;
}
callback_invoke(env, (callback *)user_data, cif, resp, cbargs);
(*env)->PopLocalFrame(env, NULL);
if (!attached) {
(*jvm)->DetachCurrentThread(jvm);
Arquivo executável
+147
Ver Arquivo
@@ -0,0 +1,147 @@
#!/bin/sh
#
# GCC-compatible wrapper for cl.exe
#
MSVC="/c/Program Files (x86)/Microsoft Visual Studio 9.0/vc/bin"
nowarn="/wd4127 /wd4820 /wd4706 /wd4100 /wd4255 /wd4668"
args="/nologo /EHac /W3 /LD $nowarn" # /WX
# FIXME is this equivalent to --static-libgcc? links to msvcrt.lib
# I've forgotten why it was originally added
# /MD causes link problems
#md=/MD
cl="$MSVC/cl"
ml="$MSVC/ml"
output=
while [ $# -gt 0 ]
do
case $1
in
-fexceptions)
shift 1
;;
-fno-omit-frame-pointer)
# TODO: does this have an equivalent?
shift 1
;;
-fno-strict-aliasing)
# TODO: does this have an equivalent?
shift 1
;;
-mno-cygwin)
shift 1
;;
-m32)
cl="$MSVC/cl"
ml="$MSVC/ml"
shift 1
;;
-m64)
cl="$MSVC/x86_amd64/cl"
ml="$MSVC/x86_amd64/ml64"
shift 1
;;
-O*)
args="$args /O1"
shift 1
;;
-g)
# using /RTC1 instead of /GZ
args="$args /Od /D_DEBUG /RTC1 /Zi"
md=/MDd
shift 1
;;
-c)
args="$args /c"
args="$(echo $args | sed 's%/Fe%/Fo%g')"
single="/c"
shift 1
;;
-D*=*)
name="$(echo $1|sed 's/-D\([^=][^=]*\)=.*/\1/g')"
value="$(echo $1|sed 's/-D[^=][^=]*=//g')"
args="$args -D${name}='$value'"
defines="$defines -D${name}='$value'"
shift 1
;;
-D*)
args="$args $1"
defines="$defines $1"
shift 1
;;
-I)
args="$args /I\"$2\""
includes="$includes /I\"$2\""
shift 2
;;
-I*)
args="$args /I\"$(echo $1|sed -e 's/-I//g')\""
includes="$includes /I\"$(echo $1|sed -e 's/-I//g')\""
shift 1
;;
-W|-Wextra)
# TODO map extra warnings
shift 1
;;
-Wall)
args="$args /Wall"
shift 1
;;
-Werror)
args="$args /WX"
shift 1
;;
-W*)
# TODO map specific warnings
shift 1
;;
-S)
args="$args /FAs"
shift 1
;;
-o)
outdir="$(dirname $2)"
base="$(basename $2|sed 's/\.[^.]*//g')"
if [ -n "$single" ]; then
output="/Fo$2"
else
output="/Fe$2"
fi
if [ -n "$assembly" ]; then
args="$args $output"
else
args="$args $output /Fd$outdir/$base /Fp$outdir/$base /Fa$outdir/$base"
fi
shift 2
;;
*.S)
src="$(echo $1|sed -e 's/.S$/.asm/g' -e 's%\\%/%g')"
echo "$cl /EP $includes $defines $1 > $src"
"$cl" /nologo /EP $includes $defines $1 > $src || exit $?
md=""
cl="$ml"
output="$(echo $output | sed 's%/F[dpa][^ ]*%%g')"
args="/nologo $single $src $output"
assembly="true"
shift 1
;;
*.c)
args="$args $(echo $1|sed -e 's%\\%/%g')"
shift 1
;;
*)
echo "Unsupported argument '$1'"
exit 1
;;
esac
done
args="$md $args"
echo "$cl $args"
eval "\"$cl\" $args"
result=$?
# @#!%@!# ml64 broken output
if [ -n "$assembly" ]; then
mv $src $outdir
mv *.obj $outdir
fi
exit $result
+80 -51
Ver Arquivo
@@ -22,6 +22,9 @@
*/
#if defined(_WIN32)
#ifndef UNICODE
#define UNICODE
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#ifdef _MSC_VER
@@ -31,7 +34,14 @@
#endif
#define LIBNAMETYPE wchar_t*
#define LIBNAME2CSTR(ENV,JSTR) newWideCString(ENV,JSTR)
#define LOAD_LIBRARY(NAME) LoadLibraryW(NAME)
/* See http://msdn.microsoft.com/en-us/library/ms682586(VS.85).aspx:
* "Note that the standard search strategy and the alternate search strategy
* specified by LoadLibraryEx with LOAD_WITH_ALTERED_SEARCH_PATH differ in
* just one way: The standard search begins in the calling application's
* directory, and the alternate search begins in the directory of the
* executable module that LoadLibraryEx is loading."
*/
#define LOAD_LIBRARY(NAME) LoadLibraryExW(NAME, NULL, LOAD_WITH_ALTERED_SEARCH_PATH)
#define LOAD_ERROR(BUF,LEN) w32_format_error(BUF, LEN)
#define FREE_LIBRARY(HANDLE) FreeLibrary(HANDLE)
#define FIND_ENTRY(HANDLE, NAME) GetProcAddress(HANDLE, NAME)
@@ -39,8 +49,8 @@
#define SET_LAST_ERROR(CODE) SetLastError(CODE)
static char*
w32_format_error(char* buf, int len) {
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
0, buf, len, NULL);
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
0, buf, len, NULL);
return buf;
}
#else
@@ -53,7 +63,7 @@ w32_format_error(char* buf, int len) {
#define LIBNAME2CSTR(ENV,JSTR) newCString(ENV,JSTR)
#endif
#define LOAD_LIBRARY(NAME) dlopen(NAME, RTLD_LAZY)
#define LOAD_ERROR(BUF,LEN) (sprintf(BUF, "%s", dlerror()), BUF)
#define LOAD_ERROR(BUF,LEN) (snprintf(BUF, LEN, "%s", dlerror()), BUF)
#define FREE_LIBRARY(HANDLE) dlclose(HANDLE)
#define FIND_ENTRY(HANDLE, NAME) dlsym(HANDLE, NAME)
#define GET_LAST_ERROR() errno
@@ -81,9 +91,9 @@ w32_format_error(char* buf, int len) {
#ifdef HAVE_PROTECTION
static int _protect;
#undef PROTECT
#define PROTECT _protect
#endif
#include "protect.h"
#ifdef __cplusplus
extern "C"
@@ -91,9 +101,6 @@ extern "C"
static jboolean preserve_last_error;
#define ON_ERROR() throwByName(env, EError, "Invalid memory access")
#define PSTART() PROTECTED_START()
#define PEND() PROTECTED_END(ON_ERROR())
#define MEMCPY(D,S,L) do { \
PSTART(); memcpy(D,S,L); PEND(); \
} while(0)
@@ -191,6 +198,7 @@ static void *getStructureAddress(JNIEnv *, jobject);
static ffi_type* getStructureType(JNIEnv *, jobject);
static void update_last_error(JNIEnv*, int);
/** Invokes System.err.println (for debugging only). */
static void
println(JNIEnv* env, const char* msg) {
jclass cls = (*env)->FindClass(env, "java/lang/System");
@@ -229,10 +237,11 @@ dispatch(JNIEnv *env, jobject self, jint callconv, jobjectArray arr,
nargs = (*env)->GetArrayLength(env, arr);
if (nargs > MAX_NARGS) {
sprintf(msg, "Too many arguments (max %ld)", MAX_NARGS);
snprintf(msg, sizeof(msg), "Too many arguments (max %ld)", MAX_NARGS);
throwByName(env, EUnsupportedOperation, msg);
return;
}
c_args = (jvalue*)alloca(nargs * sizeof(jvalue));
array_elements = (struct _array_elements*)
alloca(nargs * sizeof(struct _array_elements));
@@ -277,7 +286,7 @@ dispatch(JNIEnv *env, jobject self, jint callconv, jobjectArray arr,
ffi_values[i] = &c_args[i].i;
}
else {
sprintf(msg, "Unsupported wchar_t size (%d)", (int)sizeof(wchar_t));
snprintf(msg, sizeof(msg), "Unsupported wchar_t size (%d)", (int)sizeof(wchar_t));
throwByName(env, EUnsupportedOperation, msg);
goto cleanup;
}
@@ -312,7 +321,8 @@ dispatch(JNIEnv *env, jobject self, jint callconv, jobjectArray arr,
ffi_types[i] = getStructureType(env, arg);
ffi_values[i] = c_args[i].l;
if (!ffi_types[i]) {
sprintf(msg, "Structure type info not initialized at argument %d", i);
snprintf(msg, sizeof(msg),
"Structure type info not initialized at argument %d", i);
throwByName(env, EIllegalState, msg);
goto cleanup;
}
@@ -322,22 +332,21 @@ dispatch(JNIEnv *env, jobject self, jint callconv, jobjectArray arr,
ffi_types[i] = &ffi_type_pointer;
ffi_values[i] = &c_args[i].l;
if (c_args[i].l == NULL) {
c_args[i].l =
getBufferArray(env, arg, &array_elements[array_count].array,
&array_elements[array_count].type,
&array_elements[array_count].elems);
if (c_args[i].l == NULL) {
throwByName(env, EIllegalArgument,
"Buffer arguments must be direct or have a primitive backing array");
goto cleanup;
}
++array_count;
c_args[i].l =
getBufferArray(env, arg, &array_elements[array_count].array,
&array_elements[array_count].type,
&array_elements[array_count].elems);
if (c_args[i].l == NULL) {
throwByName(env, EIllegalArgument,
"Buffer arguments must be direct or have a primitive backing array");
goto cleanup;
}
++array_count;
}
}
else if ((array_pt = getArrayComponentType(env, arg)) != 0
&& array_pt != 'L') {
void *ptr = NULL;
switch(array_pt) {
case 'Z': ptr = (*env)->GetBooleanArrayElements(env, arg, NULL); break;
case 'B': ptr = (*env)->GetByteArrayElements(env, arg, NULL); break;
@@ -361,7 +370,7 @@ dispatch(JNIEnv *env, jobject self, jint callconv, jobjectArray arr,
array_elements[array_count++].elems = ptr;
}
else {
sprintf(msg, "Unsupported type at parameter %d", i);
snprintf(msg, sizeof(msg), "Unsupported type at parameter %d", i);
throwByName(env,EIllegalArgument, msg);
goto cleanup;
}
@@ -371,24 +380,33 @@ dispatch(JNIEnv *env, jobject self, jint callconv, jobjectArray arr,
case CALLCONV_C:
abi = FFI_DEFAULT_ABI;
break;
#if defined(_WIN32)
#ifdef _WIN32
case CALLCONV_STDCALL:
#ifdef _WIN64
// Ignore requests for stdcall on win64
abi = FFI_DEFAULT_ABI;
#else
abi = FFI_STDCALL;
#endif
break;
#endif // _WIN32
default:
sprintf(msg, "Unrecognized calling convention: %d", (int)callconv);
snprintf(msg, sizeof(msg),
"Unrecognized calling convention: %d", (int)callconv);
throwByName(env, EIllegalArgument, msg);
goto cleanup;
}
status = ffi_prep_cif(&cif, abi, nargs, ffi_return_type, ffi_types);
switch(status) {
case FFI_BAD_ABI:
sprintf(msg, "Invalid calling convention: %d", (int)callconv);
snprintf(msg, sizeof(msg),
"Invalid calling convention: %d", (int)callconv);
throwByName(env, EIllegalArgument, msg);
break;
case FFI_BAD_TYPEDEF:
sprintf(msg, "Invalid structure definition (native typedef error)");
snprintf(msg, sizeof(msg),
"Invalid structure definition (native typedef error)");
throwByName(env, EIllegalArgument, msg);
break;
case FFI_OK: {
@@ -401,7 +419,8 @@ dispatch(JNIEnv *env, jobject self, jint callconv, jobjectArray arr,
break;
}
default:
sprintf(msg, "Native call setup failure: error code %d", status);
snprintf(msg, sizeof(msg),
"Native call setup failure: error code %d", status);
throwByName(env, EIllegalArgument, msg);
break;
}
@@ -997,7 +1016,7 @@ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1read__J_3SII
JNIEXPORT jbyte JNICALL Java_com_sun_jna_Pointer__1getByte
(JNIEnv *env, jclass cls, jlong addr)
{
jbyte res;
jbyte res = 0;
MEMCPY(&res, L2A(addr), sizeof(res));
return res;
}
@@ -1010,7 +1029,7 @@ JNIEXPORT jbyte JNICALL Java_com_sun_jna_Pointer__1getByte
JNIEXPORT jchar JNICALL Java_com_sun_jna_Pointer__1getChar
(JNIEnv *env, jclass cls, jlong addr)
{
wchar_t res;
wchar_t res = 0;
MEMCPY(&res, L2A(addr), sizeof(res));
return (jchar)res;
}
@@ -1023,7 +1042,7 @@ JNIEXPORT jchar JNICALL Java_com_sun_jna_Pointer__1getChar
JNIEXPORT jobject JNICALL Java_com_sun_jna_Pointer__1getPointer
(JNIEnv *env, jclass cls, jlong addr)
{
void *ptr;
void *ptr = NULL;
MEMCPY(&ptr, L2A(addr), sizeof(ptr));
return newJavaPointer(env, ptr);
}
@@ -1047,7 +1066,7 @@ JNIEXPORT jobject JNICALL Java_com_sun_jna_Pointer__1getDirectByteBuffer
JNIEXPORT jdouble JNICALL Java_com_sun_jna_Pointer__1getDouble
(JNIEnv *env, jclass cls, jlong addr)
{
jdouble res;
jdouble res = 0;
MEMCPY(&res, L2A(addr), sizeof(res));
return res;
}
@@ -1060,7 +1079,7 @@ JNIEXPORT jdouble JNICALL Java_com_sun_jna_Pointer__1getDouble
JNIEXPORT jfloat JNICALL Java_com_sun_jna_Pointer__1getFloat
(JNIEnv *env, jclass cls, jlong addr)
{
jfloat res;
jfloat res = 0;
MEMCPY(&res, L2A(addr), sizeof(res));
return res;
}
@@ -1073,7 +1092,7 @@ JNIEXPORT jfloat JNICALL Java_com_sun_jna_Pointer__1getFloat
JNIEXPORT jint JNICALL Java_com_sun_jna_Pointer__1getInt
(JNIEnv *env, jclass cls, jlong addr)
{
jint res;
jint res = 0;
MEMCPY(&res, L2A(addr), sizeof(res));
return res;
}
@@ -1086,7 +1105,7 @@ JNIEXPORT jint JNICALL Java_com_sun_jna_Pointer__1getInt
JNIEXPORT jlong JNICALL Java_com_sun_jna_Pointer__1getLong
(JNIEnv *env, jclass cls, jlong addr)
{
jlong res;
jlong res = 0;
MEMCPY(&res, L2A(addr), sizeof(res));
return res;
}
@@ -1099,7 +1118,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_jna_Pointer__1getLong
JNIEXPORT jshort JNICALL Java_com_sun_jna_Pointer__1getShort
(JNIEnv *env, jclass cls, jlong addr)
{
jshort res;
jshort res = 0;
MEMCPY(&res, L2A(addr), sizeof(res));
return res;
}
@@ -1379,7 +1398,7 @@ newJavaString(JNIEnv *env, const char *ptr, jboolean wide)
if (wide) {
// TODO: proper conversion from native wchar_t to jchar
int len = wcslen((const wchar_t*)ptr);
int len = (int)wcslen((const wchar_t*)ptr);
if (sizeof(jchar) != sizeof(wchar_t)) {
jchar* buf = (jchar*)alloca(len * sizeof(jchar));
int i;
@@ -1394,7 +1413,7 @@ newJavaString(JNIEnv *env, const char *ptr, jboolean wide)
}
else {
jbyteArray bytes = 0;
int len = strlen(ptr);
int len = (int)strlen(ptr);
bytes = (*env)->NewByteArray(env, len);
if (bytes != 0) {
@@ -1534,6 +1553,7 @@ do { jboolean cpy; \
*elemp = ptr;
ptr = (char *)ptr + offset;
}
return ptr;
}
@@ -1652,7 +1672,7 @@ Java_com_sun_jna_Native_initIDs(JNIEnv *env, jclass cls) {
return;
}
for (i=0;i < sizeof(fields)/sizeof(fields[0]);i++) {
sprintf(field, "ffi_type_%s", fields[i]);
snprintf(field, sizeof(field), "ffi_type_%s", fields[i]);
fid = (*env)->GetStaticFieldID(env, cls, field, "Lcom/sun/jna/Pointer;");
if (!fid) {
throwByName(env, EUnsatisfiedLink, field);
@@ -1667,13 +1687,13 @@ Java_com_sun_jna_Native_initIDs(JNIEnv *env, jclass cls) {
#define JAWT_HEADLESS_HACK
#ifdef _WIN32
#define JAWT_NAME "jawt.dll"
#define METHOD_NAME (sizeof(void*)==4?"_JAWT_GetAWT@8":"_JAWT_GetAWT@16")
#define METHOD_NAME (sizeof(void*)==4?"_JAWT_GetAWT@8":"JAWT_GetAWT")
#else
#define JAWT_NAME "libjawt.so"
#define METHOD_NAME "JAWT_GetAWT"
#endif
static void* jawt_handle = NULL;
static jboolean JNICALL (*pJAWT_GetAWT)(JNIEnv*,JAWT*);
static jboolean (JNICALL *pJAWT_GetAWT)(JNIEnv*,JAWT*);
#define JAWT_GetAWT (*pJAWT_GetAWT)
#endif
@@ -1714,16 +1734,20 @@ Java_com_sun_jna_Native_getWindowHandle0(JNIEnv *env, jclass classp, jobject w)
if (java_home != NULL) {
if ((prop = newWideCString(env, java_home)) != NULL) {
const wchar_t* suffix = L"/bin/jawt.dll";
path = (wchar_t*)alloca((wcslen(prop) + wcslen(suffix) + 1)
* sizeof(wchar_t));
size_t len = wcslen(prop) + wcslen(suffix) + 1;
path = (wchar_t*)alloca(len * sizeof(wchar_t));
#ifdef _MSC_VER
swprintf(path, len, L"%s%s", prop, suffix);
#else
swprintf(path, L"%s%s", prop, suffix);
#endif
free(prop);
}
}
}
}
#undef LOAD_LIBRARY
#define LOAD_LIBRARY(X) LoadLibraryW(path)
#undef JAWT_NAME
#define JAWT_NAME path
#endif
if ((jawt_handle = LOAD_LIBRARY(JAWT_NAME)) == NULL) {
char msg[1024];
@@ -1732,7 +1756,7 @@ Java_com_sun_jna_Native_getWindowHandle0(JNIEnv *env, jclass classp, jobject w)
}
if ((pJAWT_GetAWT = (void*)FIND_ENTRY(jawt_handle, METHOD_NAME)) == NULL) {
char msg[1024], buf[1024];
sprintf(msg, "Error looking up %s: %s",
snprintf(msg, sizeof(msg), "Error looking up %s: %s",
METHOD_NAME, LOAD_ERROR(buf, sizeof(buf)));
throwByName(env, EUnsatisfiedLink, msg);
return -1;
@@ -1768,7 +1792,7 @@ Java_com_sun_jna_Native_getWindowHandle0(JNIEnv *env, jclass classp, jobject w)
// FIXME this kills the VM if the window is not realized;
// if not, wdsi might be a bogus, non-null value
// TODO: fix JVM (right) or ensure window is realized (done in Java)
handle = (jint)wdsi->hwnd;
handle = A2L(wdsi->hwnd);
if (!handle) {
throwByName(env, EIllegalState, "Can't get HWND");
}
@@ -1828,14 +1852,19 @@ Java_com_sun_jna_Native_setProtected(JNIEnv *env, jclass classp, jboolean protec
#endif
}
JNIEXPORT jboolean JNICALL
Java_com_sun_jna_Native_isProtected(JNIEnv *env, jclass classp) {
#ifdef HAVE_PROTECTION
jboolean
is_protected() {
#ifdef HAVE_PROTECTION
if (_protect) return JNI_TRUE;
#endif
return JNI_FALSE;
}
JNIEXPORT jboolean JNICALL
Java_com_sun_jna_Native_isProtected(JNIEnv *env, jclass classp) {
return is_protected();
}
JNIEXPORT void JNICALL
Java_com_sun_jna_Native_setPreserveLastError(JNIEnv *env, jclass classp, jboolean preserve) {
preserve_last_error = preserve;
@@ -2082,7 +2111,7 @@ get_ffi_rtype(JNIEnv* env, jclass cls, char jtype) {
return get_ffi_type(env, cls, jtype);
}
}
#ifdef __cplusplus
}
#endif
+18 -1
Ver Arquivo
@@ -23,7 +23,7 @@ extern "C" {
/* These are the calling conventions an invocation can handle. */
typedef enum _callconv {
CALLCONV_C = com_sun_jna_Function_C_CONVENTION,
#if defined(_WIN32)
#ifdef _WIN32
CALLCONV_STDCALL = com_sun_jna_Function_ALT_CONVENTION,
#endif
} callconv_t;
@@ -47,13 +47,19 @@ typedef struct _callback {
typedef long word_t;
#if defined(SOLARIS2) || defined(__GNUC__)
#if defined(_WIN64)
#define L2A(X) ((void *)(long long)(X))
#define A2L(X) ((jlong)(long long)(X))
#else
#define L2A(X) ((void *)(unsigned long)(X))
#define A2L(X) ((jlong)(unsigned long)(X))
#endif
#endif
#if defined(_MSC_VER)
#define L2A(X) ((void *)(X))
#define A2L(X) ((jlong)(X))
#define snprintf sprintf_s
#endif
/* Convenience macros */
@@ -96,6 +102,17 @@ extern callback* create_callback(JNIEnv*, jobject, jobject,
extern void free_callback(JNIEnv*, callback*);
extern void extract_value(JNIEnv*, jobject, void*, size_t size);
extern jobject new_object(JNIEnv*, char, void*);
extern jboolean is_protected();
/* Native memory fault protection */
#ifdef HAVE_PROTECTION
#define PROTECT is_protected()
#endif
#include "protect.h"
#define ON_ERROR() throwByName(env, EError, "Invalid memory access")
#define PSTART() PROTECTED_START()
#define PEND() PROTECTED_END(ON_ERROR())
#ifdef __cplusplus
}
#endif
Arquivo executável
+56
Ver Arquivo
@@ -0,0 +1,56 @@
#!/bin/sh
#
# ld-compatible wrapper for link.exe
#
#args="/pdbtype:sept"
MSVC="/c/Program Files (x86)/Microsoft Visual Studio 9.0/vc/bin"
args="/nologo /opt:REF /incremental:no /subsystem:console /nodefaultlib:msvcrtd"
link="$MSVC/link"
while [ $# -gt 0 ]
do
case $1
in
-m32)
link="$MSVC/link"
args="$args /machine:X86"
shift 1
;;
-m64)
link="$MSVC/x86_amd64/link"
args="$args /machine:X64"
shift 1
;;
-g)
args="$args /debug"
shift 1
;;
-o)
dir="$(dirname $2)"
base="$(basename $2|sed 's/\.[^.]*//g')"
args="$args /out:\"$2\" /pdb:$dir/$base.pdb /implib:$dir/$base.lib"
shift 2
;;
-shared)
args="$args /DLL"
shift 1
;;
-static-libgcc)
shift 1
;;
*.dll)
args="$args $(echo $1|sed -e 's/.dll/.lib/g')"
shift 1
;;
*.o|*.lib|*.a)
args="$args $(echo $1|sed -e 's%\\%/%g')"
shift 1
;;
*)
echo "Unsupported argument '$1'"
exit 1
;;
esac
done
echo "\"$link\" $args"
eval "\"$link\" $args"
+5 -1
Ver Arquivo
@@ -26,7 +26,8 @@ EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj configure.host \
src/sh64/ffi.c src/sh64/sysv.S src/sh64/ffitarget.h \
src/sparc/v8.S src/sparc/v9.S src/sparc/ffitarget.h \
src/sparc/ffi.c \
src/x86/ffi.c src/x86/sysv.S src/x86/win32.S src/x86/darwin.S \
src/x86/ffi.c src/x86/sysv.S src/x86/win32.S src/x86/win64.S \
src/x86/darwin.S \
src/x86/ffi64.c src/x86/unix64.S src/x86/ffitarget.h \
src/pa/ffitarget.h src/pa/ffi.c src/pa/linux.S src/pa/hpux32.S \
src/frv/ffi.c src/frv/eabi.S src/frv/ffitarget.h
@@ -93,6 +94,9 @@ endif
if X86_WIN32
nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/win32.S
endif
if X86_WIN64
nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/win64.S
endif
if X86_DARWIN
nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/darwin.S src/x86/ffi64.c src/x86/darwin64.S
endif
+59 -46
Ver Arquivo
@@ -40,25 +40,26 @@ target_triplet = @target@
@MIPS_TRUE@am__append_1 = src/mips/ffi.c src/mips/o32.S src/mips/n32.S
@X86_TRUE@am__append_2 = src/x86/ffi.c src/x86/sysv.S
@X86_WIN32_TRUE@am__append_3 = src/x86/ffi.c src/x86/win32.S
@X86_DARWIN_TRUE@am__append_4 = src/x86/ffi.c src/x86/darwin.S src/x86/ffi64.c src/x86/darwin64.S
@SPARC_TRUE@am__append_5 = src/sparc/ffi.c src/sparc/v8.S src/sparc/v9.S
@ALPHA_TRUE@am__append_6 = src/alpha/ffi.c src/alpha/osf.S
@IA64_TRUE@am__append_7 = src/ia64/ffi.c src/ia64/unix.S
@M32R_TRUE@am__append_8 = src/m32r/sysv.S src/m32r/ffi.c
@M68K_TRUE@am__append_9 = src/m68k/ffi.c src/m68k/sysv.S
@POWERPC_TRUE@am__append_10 = src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S src/powerpc/linux64.S src/powerpc/linux64_closure.S
@POWERPC_AIX_TRUE@am__append_11 = src/powerpc/ffi_darwin.c src/powerpc/aix.S src/powerpc/aix_closure.S
@POWERPC_DARWIN_TRUE@am__append_12 = src/powerpc/ffi_darwin.c src/powerpc/darwin.S src/powerpc/darwin_closure.S
@POWERPC_FREEBSD_TRUE@am__append_13 = src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S
@ARM_TRUE@am__append_14 = src/arm/sysv.S src/arm/ffi.c
@LIBFFI_CRIS_TRUE@am__append_15 = src/cris/sysv.S src/cris/ffi.c
@FRV_TRUE@am__append_16 = src/frv/eabi.S src/frv/ffi.c
@S390_TRUE@am__append_17 = src/s390/sysv.S src/s390/ffi.c
@X86_64_TRUE@am__append_18 = src/x86/ffi64.c src/x86/unix64.S src/x86/ffi.c src/x86/sysv.S
@SH_TRUE@am__append_19 = src/sh/sysv.S src/sh/ffi.c
@SH64_TRUE@am__append_20 = src/sh64/sysv.S src/sh64/ffi.c
@PA_LINUX_TRUE@am__append_21 = src/pa/linux.S src/pa/ffi.c
@PA_HPUX_TRUE@am__append_22 = src/pa/hpux32.S src/pa/ffi.c
@X86_WIN64_TRUE@am__append_4 = src/x86/ffi.c src/x86/win64.S
@X86_DARWIN_TRUE@am__append_5 = src/x86/ffi.c src/x86/darwin.S src/x86/ffi64.c src/x86/darwin64.S
@SPARC_TRUE@am__append_6 = src/sparc/ffi.c src/sparc/v8.S src/sparc/v9.S
@ALPHA_TRUE@am__append_7 = src/alpha/ffi.c src/alpha/osf.S
@IA64_TRUE@am__append_8 = src/ia64/ffi.c src/ia64/unix.S
@M32R_TRUE@am__append_9 = src/m32r/sysv.S src/m32r/ffi.c
@M68K_TRUE@am__append_10 = src/m68k/ffi.c src/m68k/sysv.S
@POWERPC_TRUE@am__append_11 = src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S src/powerpc/linux64.S src/powerpc/linux64_closure.S
@POWERPC_AIX_TRUE@am__append_12 = src/powerpc/ffi_darwin.c src/powerpc/aix.S src/powerpc/aix_closure.S
@POWERPC_DARWIN_TRUE@am__append_13 = src/powerpc/ffi_darwin.c src/powerpc/darwin.S src/powerpc/darwin_closure.S
@POWERPC_FREEBSD_TRUE@am__append_14 = src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S
@ARM_TRUE@am__append_15 = src/arm/sysv.S src/arm/ffi.c
@LIBFFI_CRIS_TRUE@am__append_16 = src/cris/sysv.S src/cris/ffi.c
@FRV_TRUE@am__append_17 = src/frv/eabi.S src/frv/ffi.c
@S390_TRUE@am__append_18 = src/s390/sysv.S src/s390/ffi.c
@X86_64_TRUE@am__append_19 = src/x86/ffi64.c src/x86/unix64.S src/x86/ffi.c src/x86/sysv.S
@SH_TRUE@am__append_20 = src/sh/sysv.S src/sh/ffi.c
@SH64_TRUE@am__append_21 = src/sh64/sysv.S src/sh64/ffi.c
@PA_LINUX_TRUE@am__append_22 = src/pa/linux.S src/pa/ffi.c
@PA_HPUX_TRUE@am__append_23 = src/pa/hpux32.S src/pa/ffi.c
DIST_COMMON = README $(am__configure_deps) $(srcdir)/../compile \
$(srcdir)/../config.guess $(srcdir)/../config.sub \
$(srcdir)/../depcomp $(srcdir)/../install-sh \
@@ -98,37 +99,38 @@ am_libffi_la_OBJECTS = src/debug.lo src/prep_cif.lo src/types.lo \
@MIPS_TRUE@ src/mips/n32.lo
@X86_TRUE@am__objects_2 = src/x86/ffi.lo src/x86/sysv.lo
@X86_WIN32_TRUE@am__objects_3 = src/x86/ffi.lo src/x86/win32.lo
@X86_DARWIN_TRUE@am__objects_4 = src/x86/ffi.lo src/x86/darwin.lo \
@X86_WIN64_TRUE@am__objects_4 = src/x86/ffi.lo src/x86/win64.lo
@X86_DARWIN_TRUE@am__objects_5 = src/x86/ffi.lo src/x86/darwin.lo \
@X86_DARWIN_TRUE@ src/x86/ffi64.lo src/x86/darwin64.lo
@SPARC_TRUE@am__objects_5 = src/sparc/ffi.lo src/sparc/v8.lo \
@SPARC_TRUE@am__objects_6 = src/sparc/ffi.lo src/sparc/v8.lo \
@SPARC_TRUE@ src/sparc/v9.lo
@ALPHA_TRUE@am__objects_6 = src/alpha/ffi.lo src/alpha/osf.lo
@IA64_TRUE@am__objects_7 = src/ia64/ffi.lo src/ia64/unix.lo
@M32R_TRUE@am__objects_8 = src/m32r/sysv.lo src/m32r/ffi.lo
@M68K_TRUE@am__objects_9 = src/m68k/ffi.lo src/m68k/sysv.lo
@POWERPC_TRUE@am__objects_10 = src/powerpc/ffi.lo src/powerpc/sysv.lo \
@ALPHA_TRUE@am__objects_7 = src/alpha/ffi.lo src/alpha/osf.lo
@IA64_TRUE@am__objects_8 = src/ia64/ffi.lo src/ia64/unix.lo
@M32R_TRUE@am__objects_9 = src/m32r/sysv.lo src/m32r/ffi.lo
@M68K_TRUE@am__objects_10 = src/m68k/ffi.lo src/m68k/sysv.lo
@POWERPC_TRUE@am__objects_11 = src/powerpc/ffi.lo src/powerpc/sysv.lo \
@POWERPC_TRUE@ src/powerpc/ppc_closure.lo \
@POWERPC_TRUE@ src/powerpc/linux64.lo \
@POWERPC_TRUE@ src/powerpc/linux64_closure.lo
@POWERPC_AIX_TRUE@am__objects_11 = src/powerpc/ffi_darwin.lo \
@POWERPC_AIX_TRUE@am__objects_12 = src/powerpc/ffi_darwin.lo \
@POWERPC_AIX_TRUE@ src/powerpc/aix.lo \
@POWERPC_AIX_TRUE@ src/powerpc/aix_closure.lo
@POWERPC_DARWIN_TRUE@am__objects_12 = src/powerpc/ffi_darwin.lo \
@POWERPC_DARWIN_TRUE@am__objects_13 = src/powerpc/ffi_darwin.lo \
@POWERPC_DARWIN_TRUE@ src/powerpc/darwin.lo \
@POWERPC_DARWIN_TRUE@ src/powerpc/darwin_closure.lo
@POWERPC_FREEBSD_TRUE@am__objects_13 = src/powerpc/ffi.lo \
@POWERPC_FREEBSD_TRUE@am__objects_14 = src/powerpc/ffi.lo \
@POWERPC_FREEBSD_TRUE@ src/powerpc/sysv.lo \
@POWERPC_FREEBSD_TRUE@ src/powerpc/ppc_closure.lo
@ARM_TRUE@am__objects_14 = src/arm/sysv.lo src/arm/ffi.lo
@LIBFFI_CRIS_TRUE@am__objects_15 = src/cris/sysv.lo src/cris/ffi.lo
@FRV_TRUE@am__objects_16 = src/frv/eabi.lo src/frv/ffi.lo
@S390_TRUE@am__objects_17 = src/s390/sysv.lo src/s390/ffi.lo
@X86_64_TRUE@am__objects_18 = src/x86/ffi64.lo src/x86/unix64.lo \
@ARM_TRUE@am__objects_15 = src/arm/sysv.lo src/arm/ffi.lo
@LIBFFI_CRIS_TRUE@am__objects_16 = src/cris/sysv.lo src/cris/ffi.lo
@FRV_TRUE@am__objects_17 = src/frv/eabi.lo src/frv/ffi.lo
@S390_TRUE@am__objects_18 = src/s390/sysv.lo src/s390/ffi.lo
@X86_64_TRUE@am__objects_19 = src/x86/ffi64.lo src/x86/unix64.lo \
@X86_64_TRUE@ src/x86/ffi.lo src/x86/sysv.lo
@SH_TRUE@am__objects_19 = src/sh/sysv.lo src/sh/ffi.lo
@SH64_TRUE@am__objects_20 = src/sh64/sysv.lo src/sh64/ffi.lo
@PA_LINUX_TRUE@am__objects_21 = src/pa/linux.lo src/pa/ffi.lo
@PA_HPUX_TRUE@am__objects_22 = src/pa/hpux32.lo src/pa/ffi.lo
@SH_TRUE@am__objects_20 = src/sh/sysv.lo src/sh/ffi.lo
@SH64_TRUE@am__objects_21 = src/sh64/sysv.lo src/sh64/ffi.lo
@PA_LINUX_TRUE@am__objects_22 = src/pa/linux.lo src/pa/ffi.lo
@PA_HPUX_TRUE@am__objects_23 = src/pa/hpux32.lo src/pa/ffi.lo
nodist_libffi_la_OBJECTS = $(am__objects_1) $(am__objects_2) \
$(am__objects_3) $(am__objects_4) $(am__objects_5) \
$(am__objects_6) $(am__objects_7) $(am__objects_8) \
@@ -136,22 +138,22 @@ nodist_libffi_la_OBJECTS = $(am__objects_1) $(am__objects_2) \
$(am__objects_12) $(am__objects_13) $(am__objects_14) \
$(am__objects_15) $(am__objects_16) $(am__objects_17) \
$(am__objects_18) $(am__objects_19) $(am__objects_20) \
$(am__objects_21) $(am__objects_22)
$(am__objects_21) $(am__objects_22) $(am__objects_23)
libffi_la_OBJECTS = $(am_libffi_la_OBJECTS) \
$(nodist_libffi_la_OBJECTS)
libffi_convenience_la_LIBADD =
am__objects_23 = src/debug.lo src/prep_cif.lo src/types.lo \
am__objects_24 = src/debug.lo src/prep_cif.lo src/types.lo \
src/raw_api.lo src/java_raw_api.lo src/closures.lo
am_libffi_convenience_la_OBJECTS = $(am__objects_23)
am__objects_24 = $(am__objects_1) $(am__objects_2) $(am__objects_3) \
am_libffi_convenience_la_OBJECTS = $(am__objects_24)
am__objects_25 = $(am__objects_1) $(am__objects_2) $(am__objects_3) \
$(am__objects_4) $(am__objects_5) $(am__objects_6) \
$(am__objects_7) $(am__objects_8) $(am__objects_9) \
$(am__objects_10) $(am__objects_11) $(am__objects_12) \
$(am__objects_13) $(am__objects_14) $(am__objects_15) \
$(am__objects_16) $(am__objects_17) $(am__objects_18) \
$(am__objects_19) $(am__objects_20) $(am__objects_21) \
$(am__objects_22)
nodist_libffi_convenience_la_OBJECTS = $(am__objects_24)
$(am__objects_22) $(am__objects_23)
nodist_libffi_convenience_la_OBJECTS = $(am__objects_25)
libffi_convenience_la_OBJECTS = $(am_libffi_convenience_la_OBJECTS) \
$(nodist_libffi_convenience_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
@@ -307,6 +309,8 @@ X86_FALSE = @X86_FALSE@
X86_TRUE = @X86_TRUE@
X86_WIN32_FALSE = @X86_WIN32_FALSE@
X86_WIN32_TRUE = @X86_WIN32_TRUE@
X86_WIN64_FALSE = @X86_WIN64_FALSE@
X86_WIN64_TRUE = @X86_WIN64_TRUE@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
@@ -379,7 +383,8 @@ EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj configure.host \
src/sh64/ffi.c src/sh64/sysv.S src/sh64/ffitarget.h \
src/sparc/v8.S src/sparc/v9.S src/sparc/ffitarget.h \
src/sparc/ffi.c \
src/x86/ffi.c src/x86/sysv.S src/x86/win32.S src/x86/darwin.S \
src/x86/ffi.c src/x86/sysv.S src/x86/win32.S src/x86/win64.S \
src/x86/darwin.S \
src/x86/ffi64.c src/x86/unix64.S src/x86/ffitarget.h \
src/pa/ffitarget.h src/pa/ffi.c src/pa/linux.S src/pa/hpux32.S \
src/frv/ffi.c src/frv/eabi.S src/frv/ffitarget.h
@@ -435,7 +440,7 @@ nodist_libffi_la_SOURCES = $(am__append_1) $(am__append_2) \
$(am__append_12) $(am__append_13) $(am__append_14) \
$(am__append_15) $(am__append_16) $(am__append_17) \
$(am__append_18) $(am__append_19) $(am__append_20) \
$(am__append_21) $(am__append_22)
$(am__append_21) $(am__append_22) $(am__append_23)
libffi_convenience_la_SOURCES = $(libffi_la_SOURCES)
nodist_libffi_convenience_la_SOURCES = $(nodist_libffi_la_SOURCES)
AM_CFLAGS = -Wall -g -fexceptions
@@ -569,6 +574,8 @@ src/x86/sysv.lo: src/x86/$(am__dirstamp) \
src/x86/$(DEPDIR)/$(am__dirstamp)
src/x86/win32.lo: src/x86/$(am__dirstamp) \
src/x86/$(DEPDIR)/$(am__dirstamp)
src/x86/win64.lo: src/x86/$(am__dirstamp) \
src/x86/$(DEPDIR)/$(am__dirstamp)
src/x86/darwin.lo: src/x86/$(am__dirstamp) \
src/x86/$(DEPDIR)/$(am__dirstamp)
src/x86/ffi64.lo: src/x86/$(am__dirstamp) \
@@ -836,6 +843,8 @@ mostlyclean-compile:
-rm -f src/x86/unix64.lo
-rm -f src/x86/win32.$(OBJEXT)
-rm -f src/x86/win32.lo
-rm -f src/x86/win64.$(OBJEXT)
-rm -f src/x86/win64.lo
distclean-compile:
-rm -f *.tab.c
@@ -863,6 +872,10 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@src/sparc/$(DEPDIR)/ffi.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/ffi.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/ffi64.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/sysv.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/unix64.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/win32.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/win64.Plo@am__quote@
.S.o:
$(CCASCOMPILE) -c $<
+21 -1
Ver Arquivo
@@ -459,7 +459,7 @@ ac_includes_default="\
# include <unistd.h>
#endif"
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS multi_basedir build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CFLAGS CCAS CCASFLAGS LIBTOOL SED EGREP FGREP GREP LD DUMPBIN ac_ct_DUMPBIN NM LN_S AR ac_ct_AR RANLIB ac_ct_RANLIB lt_ECHO CPP CPPFLAGS MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT TESTSUBDIR_TRUE TESTSUBDIR_FALSE AM_RUNTESTFLAGS MIPS_TRUE MIPS_FALSE SPARC_TRUE SPARC_FALSE X86_TRUE X86_FALSE X86_WIN32_TRUE X86_WIN32_FALSE X86_DARWIN_TRUE X86_DARWIN_FALSE ALPHA_TRUE ALPHA_FALSE IA64_TRUE IA64_FALSE M32R_TRUE M32R_FALSE M68K_TRUE M68K_FALSE POWERPC_TRUE POWERPC_FALSE POWERPC_AIX_TRUE POWERPC_AIX_FALSE POWERPC_DARWIN_TRUE POWERPC_DARWIN_FALSE POWERPC_FREEBSD_TRUE POWERPC_FREEBSD_FALSE ARM_TRUE ARM_FALSE LIBFFI_CRIS_TRUE LIBFFI_CRIS_FALSE FRV_TRUE FRV_FALSE S390_TRUE S390_FALSE X86_64_TRUE X86_64_FALSE SH_TRUE SH_FALSE SH64_TRUE SH64_FALSE PA_LINUX_TRUE PA_LINUX_FALSE PA_HPUX_TRUE PA_HPUX_FALSE PA64_HPUX_TRUE PA64_HPUX_FALSE ALLOCA HAVE_LONG_DOUBLE TARGET TARGETDIR toolexecdir toolexeclibdir LIBOBJS LTLIBOBJS'
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS multi_basedir build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CFLAGS CCAS CCASFLAGS LIBTOOL SED EGREP FGREP GREP LD DUMPBIN ac_ct_DUMPBIN NM LN_S AR ac_ct_AR RANLIB ac_ct_RANLIB lt_ECHO CPP CPPFLAGS MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT TESTSUBDIR_TRUE TESTSUBDIR_FALSE AM_RUNTESTFLAGS MIPS_TRUE MIPS_FALSE SPARC_TRUE SPARC_FALSE X86_TRUE X86_FALSE X86_WIN32_TRUE X86_WIN32_FALSE X86_WIN64_TRUE X86_WIN64_FALSE X86_DARWIN_TRUE X86_DARWIN_FALSE ALPHA_TRUE ALPHA_FALSE IA64_TRUE IA64_FALSE M32R_TRUE M32R_FALSE M68K_TRUE M68K_FALSE POWERPC_TRUE POWERPC_FALSE POWERPC_AIX_TRUE POWERPC_AIX_FALSE POWERPC_DARWIN_TRUE POWERPC_DARWIN_FALSE POWERPC_FREEBSD_TRUE POWERPC_FREEBSD_FALSE ARM_TRUE ARM_FALSE LIBFFI_CRIS_TRUE LIBFFI_CRIS_FALSE FRV_TRUE FRV_FALSE S390_TRUE S390_FALSE X86_64_TRUE X86_64_FALSE SH_TRUE SH_FALSE SH64_TRUE SH64_FALSE PA_LINUX_TRUE PA_LINUX_FALSE PA_HPUX_TRUE PA_HPUX_FALSE PA64_HPUX_TRUE PA64_HPUX_FALSE ALLOCA HAVE_LONG_DOUBLE TARGET TARGETDIR toolexecdir toolexeclibdir LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -10370,6 +10370,7 @@ case "$host" in
TARGET=X86_DARWIN; TARGETDIR=x86
;;
x86_64-*-cygwin* | x86_64-*-mingw*)
TARGET=X86_WIN64; TARGETDIR=x86
;;
x86_64-*-*)
TARGET=X86_64; TARGETDIR=x86
@@ -10426,6 +10427,16 @@ fi
if test x$TARGET = xX86_WIN64; then
X86_WIN64_TRUE=
X86_WIN64_FALSE='#'
else
X86_WIN64_TRUE='#'
X86_WIN64_FALSE=
fi
if test x$TARGET = xX86_DARWIN; then
X86_DARWIN_TRUE=
X86_DARWIN_FALSE='#'
@@ -12826,6 +12837,13 @@ echo "$as_me: error: conditional \"X86_WIN32\" was never defined.
Usually this means the macro was only invoked conditionally." >&2;}
{ (exit 1); exit 1; }; }
fi
if test -z "${X86_WIN64_TRUE}" && test -z "${X86_WIN64_FALSE}"; then
{ { echo "$as_me:$LINENO: error: conditional \"X86_WIN64\" was never defined.
Usually this means the macro was only invoked conditionally." >&5
echo "$as_me: error: conditional \"X86_WIN64\" was never defined.
Usually this means the macro was only invoked conditionally." >&2;}
{ (exit 1); exit 1; }; }
fi
if test -z "${X86_DARWIN_TRUE}" && test -z "${X86_DARWIN_FALSE}"; then
{ { echo "$as_me:$LINENO: error: conditional \"X86_DARWIN\" was never defined.
Usually this means the macro was only invoked conditionally." >&5
@@ -13838,6 +13856,8 @@ s,@X86_TRUE@,$X86_TRUE,;t t
s,@X86_FALSE@,$X86_FALSE,;t t
s,@X86_WIN32_TRUE@,$X86_WIN32_TRUE,;t t
s,@X86_WIN32_FALSE@,$X86_WIN32_FALSE,;t t
s,@X86_WIN64_TRUE@,$X86_WIN64_TRUE,;t t
s,@X86_WIN64_FALSE@,$X86_WIN64_FALSE,;t t
s,@X86_DARWIN_TRUE@,$X86_DARWIN_TRUE,;t t
s,@X86_DARWIN_FALSE@,$X86_DARWIN_FALSE,;t t
s,@ALPHA_TRUE@,$ALPHA_TRUE,;t t
+2
Ver Arquivo
@@ -139,6 +139,7 @@ case "$host" in
TARGET=X86_DARWIN; TARGETDIR=x86
;;
x86_64-*-cygwin* | x86_64-*-mingw*)
TARGET=X86_WIN64; TARGETDIR=x86
;;
x86_64-*-*)
TARGET=X86_64; TARGETDIR=x86
@@ -155,6 +156,7 @@ AM_CONDITIONAL(MIPS, test x$TARGET = xMIPS)
AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
AM_CONDITIONAL(X86, test x$TARGET = xX86)
AM_CONDITIONAL(X86_WIN32, test x$TARGET = xX86_WIN32)
AM_CONDITIONAL(X86_WIN64, test x$TARGET = xX86_WIN64)
AM_CONDITIONAL(X86_DARWIN, test x$TARGET = xX86_DARWIN)
AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
+2
Ver Arquivo
@@ -175,6 +175,8 @@ X86_FALSE = @X86_FALSE@
X86_TRUE = @X86_TRUE@
X86_WIN32_FALSE = @X86_WIN32_FALSE@
X86_WIN32_TRUE = @X86_WIN32_TRUE@
X86_WIN64_FALSE = @X86_WIN64_FALSE@
X86_WIN64_TRUE = @X86_WIN64_TRUE@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+4
Ver Arquivo
@@ -64,6 +64,10 @@ extern "C" {
#ifndef LIBFFI_ASM
#ifdef _MSC_VER
#define __attribute__(X)
#endif
#include <stddef.h>
#include <limits.h>
+15
Ver Arquivo
@@ -29,7 +29,11 @@ extern "C" {
#pragma alloca
# else
# ifndef alloca /* predefined by HP cc +Olibcalls */
# ifdef _MSC_VER
# define alloca _alloca
# else
char *alloca ();
# endif
# endif
# endif
# endif
@@ -77,6 +81,16 @@ typedef struct
} extended_cif;
/* Terse sized type definitions. */
#ifdef _MSC_VER
typedef unsigned char UINT8;
typedef signed char SINT8;
typedef unsigned short UINT16;
typedef signed short SINT16;
typedef unsigned int UINT32;
typedef signed int SINT32;
typedef unsigned __int64 UINT64;
typedef signed __int64 SINT64;
#else
typedef unsigned int UINT8 __attribute__((__mode__(__QI__)));
typedef signed int SINT8 __attribute__((__mode__(__QI__)));
typedef unsigned int UINT16 __attribute__((__mode__(__HI__)));
@@ -85,6 +99,7 @@ typedef unsigned int UINT32 __attribute__((__mode__(__SI__)));
typedef signed int SINT32 __attribute__((__mode__(__SI__)));
typedef unsigned int UINT64 __attribute__((__mode__(__DI__)));
typedef signed int SINT64 __attribute__((__mode__(__DI__)));
#endif
typedef float FLOAT32;
+11 -7
Ver Arquivo
@@ -43,7 +43,7 @@
# define FFI_MMAP_EXEC_WRIT 1
# define HAVE_MNTENT 1
# endif
# ifdef X86_WIN32
# if defined(X86_WIN32) || defined(X86_WIN64)
/* Windows systems may have Data Execution Protection (DEP) enabled,
which requires the use of VirtualMalloc/VirtualFree to alloc/free
executable memory. */
@@ -66,7 +66,9 @@
#define USE_LOCKS 1
#define USE_DL_PREFIX 1
#ifdef __GNUC__
#define USE_BUILTIN_FFS 1
#endif
/* We need to use mmap, not sbrk. */
#define HAVE_MORECORE 0
@@ -96,10 +98,12 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#ifndef _MSC_VER
#include <unistd.h>
#endif
#include <string.h>
#include <stdio.h>
#ifndef X86_WIN32
#if !defined(X86_WIN32) && !defined(X86_WIN64)
#ifdef HAVE_MNTENT
#include <mntent.h>
#endif /* HAVE_MNTENT */
@@ -159,7 +163,7 @@ selinux_enabled_check (void)
#define is_selinux_enabled() 0
#endif
#endif /* X86_WIN32 */
#endif /* !defined(X86_WIN32) && !defined(X86_WIN64) */
/* Declare all functions defined in dlmalloc.c as static. */
static void *dlmalloc(size_t);
@@ -178,11 +182,11 @@ static int dlmalloc_trim(size_t) MAYBE_UNUSED;
static size_t dlmalloc_usable_size(void*) MAYBE_UNUSED;
static void dlmalloc_stats(void) MAYBE_UNUSED;
#ifndef X86_WIN32
#if !defined(X86_WIN32) && !defined(X86_WIN64)
/* Use these for mmap and munmap within dlmalloc.c. */
static void *dlmmap(void *, size_t, int, int, int, off_t);
static int dlmunmap(void *, size_t);
#endif /* X86_WIN32 */
#endif /* !defined(X86_WIN32) && !defined(X86_WIN64) */
#define mmap dlmmap
#define munmap dlmunmap
@@ -192,7 +196,7 @@ static int dlmunmap(void *, size_t);
#undef mmap
#undef munmap
#ifndef X86_WIN32
#if !defined(X86_WIN32) && !defined(X86_WIN64)
/* A mutex used to synchronize access to *exec* variables in this file. */
static pthread_mutex_t open_temp_exec_file_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -507,7 +511,7 @@ segment_holding_code (mstate m, char* addr)
}
#endif
#endif /* X86_WIN32 */
#endif /* !defined(X86_WIN32) && !defined(X86_WIN64) */
/* Allocate a chunk of memory with the given size. Returns a pointer
to the writable address, and sets *CODE to the executable
+172 -28
Ver Arquivo
@@ -3,7 +3,7 @@
Copyright (c) 2002 Ranjit Mathew
Copyright (c) 2002 Bo Thorsen
Copyright (c) 2002 Roger Sayle
Copyright (c) 2007 Timothy Wall
Copyright (c) 2007,2008 Timothy Wall
x86 Foreign Function Interface
@@ -27,7 +27,7 @@
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#ifndef __x86_64__
#if !defined(__x86_64__) || defined(_WIN64)
#include <ffi.h>
#include <ffi_common.h>
@@ -46,10 +46,10 @@ void ffi_prep_args(char *stack, extended_cif *ecif)
argp = stack;
if (ecif->cif->flags == FFI_TYPE_STRUCT)
if (ecif->cif->rtype->type == FFI_TYPE_STRUCT)
{
*(void **) argp = ecif->rvalue;
argp += 4;
argp += sizeof(void*);
}
p_argv = ecif->avalue;
@@ -61,42 +61,48 @@ void ffi_prep_args(char *stack, extended_cif *ecif)
size_t z;
/* Align if necessary */
if ((sizeof(int) - 1) & (unsigned) argp)
argp = (char *) ALIGN(argp, sizeof(int));
if ((sizeof(void*) - 1) & (size_t) argp)
argp = (char *) ALIGN(argp, sizeof(void*));
z = (*p_arg)->size;
if (z < sizeof(int))
if (z < sizeof(ffi_arg))
{
z = sizeof(int);
z = sizeof(ffi_arg);
switch ((*p_arg)->type)
{
case FFI_TYPE_SINT8:
*(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
*(ffi_sarg *) argp = (ffi_sarg)*(SINT8 *)(* p_argv);
break;
case FFI_TYPE_UINT8:
*(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
*(ffi_arg *) argp = (ffi_arg)*(UINT8 *)(* p_argv);
break;
case FFI_TYPE_SINT16:
*(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
*(ffi_sarg *) argp = (ffi_sarg)*(SINT16 *)(* p_argv);
break;
case FFI_TYPE_UINT16:
*(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
*(ffi_arg *) argp = (ffi_arg)*(UINT16 *)(* p_argv);
break;
case FFI_TYPE_SINT32:
*(signed int *) argp = (signed int)*(SINT32 *)(* p_argv);
*(ffi_sarg *) argp = (ffi_sarg)*(SINT32 *)(* p_argv);
break;
case FFI_TYPE_UINT32:
*(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
*(ffi_arg *) argp = (ffi_arg)*(UINT32 *)(* p_argv);
break;
case FFI_TYPE_STRUCT:
*(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
*(ffi_arg *) argp = *(ffi_arg *)(* p_argv);
break;
#ifdef X86_WIN64
case FFI_TYPE_FLOAT:
memcpy(argp, *p_argv, z);
break;
#endif
default:
FFI_ASSERT(0);
@@ -104,8 +110,25 @@ void ffi_prep_args(char *stack, extended_cif *ecif)
}
else
{
#ifdef X86_WIN64
// Structs larger than 8 bytes are passed by reference
// Incoming data is always a pointer
if ((*p_arg)->type == FFI_TYPE_STRUCT)
{
if (z == FFI_SIZEOF_ARG)
{
*(ffi_arg *)argp = *(ffi_arg *)(* p_argv);
}
else
{
*(void **)argp = *p_argv;
}
}
else
#endif
memcpy(argp, *p_argv, z);
}
p_argv++;
argp += z;
}
@@ -131,11 +154,16 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
case FFI_TYPE_SINT64:
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE:
#endif
cif->flags = (unsigned) cif->rtype->type;
break;
case FFI_TYPE_UINT64:
#ifdef X86_WIN64
case FFI_TYPE_POINTER:
#endif
cif->flags = FFI_TYPE_SINT64;
break;
@@ -173,6 +201,12 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
cif->bytes = (cif->bytes + 15) & ~0xF;
#endif
#ifdef X86_WIN64
// ensure at least 40 bytes storage, one optional return address
// and four registers
cif->bytes = cif->bytes < 40 ? 40 : cif->bytes;
#endif
return FFI_OK;
}
@@ -184,6 +218,11 @@ extern void ffi_call_STDCALL(void (*)(char *, extended_cif *), extended_cif *,
unsigned, unsigned, unsigned *, void (*fn)());
#endif /* X86_WIN32 */
#ifdef X86_WIN64
extern int
ffi_call_win64(void (*)(char *, extended_cif *), extended_cif *,
unsigned, unsigned, unsigned *, void (*fn)());
#endif
void ffi_call(ffi_cif *cif, void (*fn)(), void *rvalue, void **avalue)
{
@@ -196,7 +235,7 @@ void ffi_call(ffi_cif *cif, void (*fn)(), void *rvalue, void **avalue)
/* value address then we need to make one */
if ((rvalue == NULL) &&
(cif->flags == FFI_TYPE_STRUCT))
(cif->rtype->type == FFI_TYPE_STRUCT))
{
ecif.rvalue = alloca(cif->rtype->size);
}
@@ -206,6 +245,27 @@ void ffi_call(ffi_cif *cif, void (*fn)(), void *rvalue, void **avalue)
switch (cif->abi)
{
#ifdef X86_WIN64
// TODO: check small struct return, args
case FFI_WIN64:
{
// Make copies of all struct arguments
// NOTE: not sure if responsibility should be here or in caller
unsigned int i;
for (i=0; i < cif->nargs;i++) {
size_t size = cif->arg_types[i]->size;
if (cif->arg_types[i]->type == FFI_TYPE_STRUCT
&& size > sizeof(void *)) {
void *local = alloca(size);
memcpy(local, avalue[i], size);
avalue[i] = local;
}
}
ffi_call_win64(ffi_prep_args, &ecif, cif->bytes,
cif->flags, ecif.rvalue, fn);
}
break;
#else
case FFI_SYSV:
ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags, ecif.rvalue,
fn);
@@ -216,6 +276,7 @@ void ffi_call(ffi_cif *cif, void (*fn)(), void *rvalue, void **avalue)
ecif.rvalue, fn);
break;
#endif /* X86_WIN32 */
#endif
default:
FFI_ASSERT(0);
break;
@@ -236,10 +297,43 @@ void FFI_HIDDEN ffi_closure_raw_SYSV (ffi_raw_closure *)
#ifdef X86_WIN32
void FFI_HIDDEN ffi_closure_STDCALL (ffi_closure *)
__attribute__ ((regparm(1)));
#endif /* X86_WIN32 */
#ifdef X86_WIN64
void FFI_HIDDEN ffi_closure_win64 (ffi_closure *);
#endif
/* This function is jumped to by the trampoline */
#ifdef X86_WIN64
void * FFI_HIDDEN
ffi_closure_win64_inner (ffi_closure *closure, void *args) {
ffi_cif *cif;
void **arg_area;
void *result;
void *resp = &result;
cif = closure->cif;
arg_area = (void**) alloca (cif->nargs * sizeof (void*));
/* this call will initialize ARG_AREA, such that each
* element in that array points to the corresponding
* value on the stack; and if the function returns
* a structure, it will change RESP to point to the
* structure return address. */
ffi_prep_incoming_args_SYSV(args, &resp, arg_area, cif);
(closure->fun) (cif, resp, arg_area, closure->user_data);
/* The result is returned in rax. This does the right thing for
result types except for floats; we have to 'mov xmm0, rax' in the
caller to correct this.
*/
return cif->rtype->size > sizeof(void *) ? resp : *(void **)resp;
}
#else
unsigned int FFI_HIDDEN
ffi_closure_SYSV_inner (closure, respp, args)
ffi_closure *closure;
@@ -256,16 +350,19 @@ ffi_closure_SYSV_inner (closure, respp, args)
/* this call will initialize ARG_AREA, such that each
* element in that array points to the corresponding
* value on the stack; and if the function returns
* a structure, it will re-set RESP to point to the
* a structure, it will change RESP to point to the
* structure return address. */
ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif);
(closure->fun) (cif, *respp, arg_area, closure->user_data);
return cif->flags;
}
#endif /* !X86_WIN64 */
static void
ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, void **avalue,
ffi_cif *cif)
@@ -277,10 +374,17 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, void **avalue,
argp = stack;
if ( cif->flags == FFI_TYPE_STRUCT ) {
#ifdef X86_WIN64
if (cif->rtype->size > sizeof(void *)) {
*rvalue = *(void **) argp;
argp += 4;
argp += sizeof(void *);
}
#else
if (cif->rtype->type == FFI_TYPE_STRUCT) {
*rvalue = *(void **) argp;
argp += sizeof(void *);
}
#endif
p_argv = avalue;
@@ -289,15 +393,25 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, void **avalue,
size_t z;
/* Align if necessary */
if ((sizeof(int) - 1) & (unsigned) argp) {
argp = (char *) ALIGN(argp, sizeof(int));
if ((sizeof(void*) - 1) & (size_t) argp) {
argp = (char *) ALIGN(argp, sizeof(void*));
}
z = (*p_arg)->size;
/* because we're little endian, this is what it turns into. */
*p_argv = (void*) argp;
#ifdef X86_WIN64
if ((*p_arg)->size > sizeof(void *))
{
z = sizeof(void *);
*p_argv = *(void **)argp;
}
else
#endif
{
z = (*p_arg)->size;
/* because we're little endian, this is what it turns into. */
*p_argv = (void*) argp;
}
p_argv++;
argp += z;
@@ -306,6 +420,24 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, void **avalue,
return;
}
#define FFI_INIT_TRAMPOLINE_WIN64(TRAMP,FUN,CTX,MASK) \
{ unsigned char *__tramp = (unsigned char*)(TRAMP); \
void* __fun = (void*)(FUN); \
void* __ctx = (void*)(CTX); \
*(unsigned char*) &__tramp[0] = 0x41; \
*(unsigned char*) &__tramp[1] = 0xbb; \
*(unsigned int*) &__tramp[2] = MASK; /* mov $mask, %r11 */ \
*(unsigned char*) &__tramp[6] = 0x48; \
*(unsigned char*) &__tramp[7] = 0xb8; \
*(void**) &__tramp[8] = __ctx; /* mov __ctx, %rax */ \
*(unsigned char *) &__tramp[16] = 0x49; \
*(unsigned char *) &__tramp[17] = 0xba; \
*(void**) &__tramp[18] = __fun; /* mov __fun, %r10 */ \
*(unsigned char *) &__tramp[26] = 0x41; \
*(unsigned char *) &__tramp[27] = 0xff; \
*(unsigned char *) &__tramp[28] = 0xe2; /* jmp %r10 */ \
}
/* How to make a trampoline. Derived from gcc/config/i386/i386.c. */
#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \
@@ -342,6 +474,17 @@ ffi_prep_closure_loc (ffi_closure* closure,
void *user_data,
void *codeloc)
{
#ifdef X86_WIN64
#define ISFLOAT(IDX) (cif->arg_types[IDX]->type == FFI_TYPE_FLOAT || cif->arg_types[IDX]->type == FFI_TYPE_DOUBLE)
#define FLAG(IDX) (cif->nargs>(IDX)&&ISFLOAT(IDX)?(1<<(IDX)):0)
if (cif->abi == FFI_WIN64)
{
int mask = FLAG(0)|FLAG(1)|FLAG(2)|FLAG(3);
FFI_INIT_TRAMPOLINE_WIN64 (&closure->tramp[0],
&ffi_closure_win64,
codeloc, mask);
}
#else
if (cif->abi == FFI_SYSV)
{
FFI_INIT_TRAMPOLINE (&closure->tramp[0],
@@ -355,7 +498,8 @@ ffi_prep_closure_loc (ffi_closure* closure,
&ffi_closure_STDCALL,
codeloc, cif->bytes);
}
#endif
#endif /* X86_WIN32 */
#endif /* !X86_WIN64 */
else
{
return FFI_BAD_ABI;
@@ -467,4 +611,4 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(), void *rvalue, ffi_raw *fake_avalue)
#endif
#endif /* __x86_64__ */
#endif /* !__x86_64__ || X86_WIN64 */
+1 -1
Ver Arquivo
@@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------
ffi.c - Copyright (c) 2002, 2007 Bo Thorsen <bo@suse.de>
ffi64.c - Copyright (c) 2002, 2007 Bo Thorsen <bo@suse.de>
x86-64 Foreign Function Interface
+28
Ver Arquivo
@@ -33,11 +33,26 @@
#define X86
#endif
#ifdef X86_WIN64
#define FFI_SIZEOF_ARG 8
#define USE_BUILTIN_FFS 0 // until mingw-64 gets it
#endif
/* ---- Generic type definitions ----------------------------------------- */
#ifndef LIBFFI_ASM
#ifdef X86_WIN64
#ifdef _MSC_VER
typedef unsigned __int64 ffi_arg;
typedef __int64 ffi_sarg;
#else
typedef unsigned long long ffi_arg;
typedef long long ffi_sarg;
#endif
#else
typedef unsigned long ffi_arg;
typedef signed long ffi_sarg;
#endif
typedef enum ffi_abi {
FFI_FIRST_ABI = 0,
@@ -50,6 +65,10 @@ typedef enum ffi_abi {
FFI_DEFAULT_ABI = FFI_SYSV,
#endif
#ifdef X86_WIN64
FFI_WIN64,
FFI_DEFAULT_ABI = FFI_WIN64,
#else
/* ---- Intel x86 and AMD x86-64 - */
#if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__))
FFI_SYSV,
@@ -60,6 +79,7 @@ typedef enum ffi_abi {
FFI_DEFAULT_ABI = FFI_UNIX64,
#endif
#endif
#endif /* X86_WIN64 */
FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
} ffi_abi;
@@ -76,10 +96,18 @@ typedef enum ffi_abi {
#ifdef X86_WIN32
#define FFI_TRAMPOLINE_SIZE 13
#else
#ifdef X86_WIN64
#define FFI_TRAMPOLINE_SIZE 29
#define FFI_NATIVE_RAW_API 0
#define FFI_NO_RAW_API 1
#else
#define FFI_TRAMPOLINE_SIZE 10
#endif
#endif
#ifndef X86_WIN64
#define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */
#endif
#endif
#endif
-2
Ver Arquivo
@@ -33,8 +33,6 @@
.text
.globl ffi_prep_args
# This assumes we are using gas.
.balign 16
.globl _ffi_call_SYSV
+311
Ver Arquivo
@@ -0,0 +1,311 @@
#define LIBFFI_ASM
#include <fficonfig.h>
#include <ffi.h>
/* Constants for ffi_call_win64 */
#define STACK 0
#define PREP_ARGS_FN 32
#define ECIF 40
#define CIF_BYTES 48
#define CIF_FLAGS 56
#define RVALUE 64
#define FN 72
/* ffi_call_win64 (void (*prep_args_fn)(char *, extended_cif *),
extended_cif *ecif, unsigned bytes, unsigned flags,
unsigned *rvalue, void (*fn)());
*/
#ifdef _MSC_VER
PUBLIC ffi_call_win64
EXTRN __chkstk:NEAR
EXTRN ffi_closure_win64_inner:NEAR
_TEXT SEGMENT
;;; ffi_closure_win64 will be called with these registers set:
;;; rax points to 'closure'
;;; r11 contains a bit mask that specifies which of the
;;; first four parameters are float or double
;;;
;;; It must move the parameters passed in registers to their stack location,
;;; call ffi_closure_win64_inner for the actual work, then return the result.
;;;
ffi_closure_win64 PROC FRAME
;; copy register arguments onto stack
test r11, 1
jne first_is_float
mov QWORD PTR [rsp+8], rcx
jmp second
first_is_float:
movlpd QWORD PTR [rsp+8], xmm0
second:
test r11, 2
jne second_is_float
mov QWORD PTR [rsp+16], rdx
jmp third
second_is_float:
movlpd QWORD PTR [rsp+16], xmm1
third:
test r11, 4
jne third_is_float
mov QWORD PTR [rsp+24], r8
jmp fourth
third_is_float:
movlpd QWORD PTR [rsp+24], xmm2
fourth:
test r11, 8
jne fourth_is_float
mov QWORD PTR [rsp+32], r9
jmp done
fourth_is_float:
movlpd QWORD PTR [rsp+32], xmm3
done:
.ALLOCSTACK 40
sub rsp, 40
.ENDPROLOG
mov rcx, rax ; context is first parameter
mov rdx, rsp ; stack is second parameter
add rdx, 48 ; point to start of arguments
mov rax, ffi_closure_win64_inner
call rax ; call the real closure function
add rsp, 40
movd xmm0, rax ; If the closure returned a float,
; ffi_closure_win64_inner wrote it to rax
ret 0
ffi_closure_win64 ENDP
ffi_call_win64 PROC FRAME
;; copy registers onto stack
mov QWORD PTR [rsp+32], r9
mov QWORD PTR [rsp+24], r8
mov QWORD PTR [rsp+16], rdx
mov QWORD PTR [rsp+8], rcx
.PUSHREG rbp
push rbp
.ALLOCSTACK 48
sub rsp, 48 ; 00000030H
.SETFRAME rbp, 32
lea rbp, QWORD PTR [rsp+32]
.ENDPROLOG
mov eax, DWORD PTR CIF_BYTES[rbp]
add rax, 15
and rax, -16
call __chkstk
sub rsp, rax
lea rax, QWORD PTR [rsp+32]
mov QWORD PTR STACK[rbp], rax
mov rdx, QWORD PTR ECIF[rbp]
mov rcx, QWORD PTR STACK[rbp]
call QWORD PTR PREP_ARGS_FN[rbp]
mov rsp, QWORD PTR STACK[rbp]
movlpd xmm3, QWORD PTR [rsp+24]
movd r9, xmm3
movlpd xmm2, QWORD PTR [rsp+16]
movd r8, xmm2
movlpd xmm1, QWORD PTR [rsp+8]
movd rdx, xmm1
movlpd xmm0, QWORD PTR [rsp]
movd rcx, xmm0
call QWORD PTR FN[rbp]
ret_int$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_INT
jne ret_float$
mov rcx, QWORD PTR RVALUE[rbp]
mov DWORD PTR [rcx], eax
jmp SHORT ret_void$
ret_float$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_FLOAT
jne SHORT ret_double$
mov rax, QWORD PTR RVALUE[rbp]
movlpd QWORD PTR [rax], xmm0
jmp SHORT ret_void$
ret_double$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_DOUBLE
jne SHORT ret_int64$
mov rax, QWORD PTR RVALUE[rbp]
movlpd QWORD PTR [rax], xmm0
jmp SHORT ret_void$
ret_int64$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT64
jne ret_void$
mov rcx, QWORD PTR RVALUE[rbp]
mov QWORD PTR [rcx], rax
jmp SHORT ret_void$
ret_void$:
xor eax, eax
lea rsp, QWORD PTR [rbp+16]
pop rbp
ret 0
ffi_call_win64 ENDP
_TEXT ENDS
END
#else
.text
.extern ___chkstk
.extern _ffi_closure_win64_inner
# ffi_closure_win64 will be called with these registers set:
# rax points to 'closure'
# r11 contains a bit mask that specifies which of the
# first four parameters are float or double
#
# It must move the parameters passed in registers to their stack location,
# call ffi_closure_win64_inner for the actual work, then return the result.
#
.balign 16
.globl _ffi_closure_win64
_ffi_closure_win64:
# copy register arguments onto stack
test $1,%r11
jne .Lfirst_is_float
mov %rcx, 8(%rsp)
jmp .Lsecond
.Lfirst_is_float:
movlpd %xmm0, 8(%rsp)
.Lsecond:
test $2, %r11
jne .Lsecond_is_float
mov %rdx, 16(%rsp)
jmp .Lthird
.Lsecond_is_float:
movlpd %xmm1, 16(%rsp)
.Lthird:
test $4, %r11
jne .Lthird_is_float
mov %r8,24(%rsp)
jmp .Lfourth
.Lthird_is_float:
movlpd %xmm2, 24(%rsp)
.Lfourth:
test $8, %r11
jne .Lfourth_is_float
mov %r9, 32(%rsp)
jmp .Ldone
.Lfourth_is_float:
movlpd %xmm3, 32(%rsp)
.Ldone:
#.ALLOCSTACK 40
sub $40, %rsp
#.ENDPROLOG
mov %rax, %rcx # context is first parameter
mov %rsp, %rdx # stack is second parameter
add $48, %rdx # point to start of arguments
mov $_ffi_closure_win64_inner, %rax
callq *%rax # call the real closure function
add $40, %rsp
movq %rax, %xmm0 # If the closure returned a float,
# ffi_closure_win64_inner wrote it to rax
retq
.ffi_closure_win64_end:
.balign 16
.globl _ffi_call_win64
_ffi_call_win64:
# copy registers onto stack
mov %r9,32(%rsp)
mov %r8,24(%rsp)
mov %rdx,16(%rsp)
mov %rcx,8(%rsp)
#.PUSHREG rbp
push %rbp
#.ALLOCSTACK 48
sub $48,%rsp
#.SETFRAME rbp, 32
lea 32(%rsp),%rbp
#.ENDPROLOG
mov CIF_BYTES(%rbp),%eax
add $15, %rax
and $-16, %rax
callq ___chkstk
sub %rax, %rsp
lea 32(%rsp), %rax
mov %rax, STACK(%rbp)
mov ECIF(%rbp), %rdx
mov STACK(%rbp), %rcx
callq *PREP_ARGS_FN(%rbp)
mov STACK(%rbp), %rsp
movlpd 24(%rsp), %xmm3
movd %xmm3, %r9
movlpd 16(%rsp), %xmm2
movd %xmm2, %r8
movlpd 8(%rsp), %xmm1
movd %xmm1, %rdx
movlpd (%rsp), %xmm0
movd %xmm0, %rcx
callq *FN(%rbp)
.Lret_int:
cmpl $FFI_TYPE_INT, CIF_FLAGS(%rbp)
jne .Lret_float
mov RVALUE(%rbp), %rcx
mov %eax, (%rcx)
jmp .Lret_void
.Lret_float:
cmpl $FFI_TYPE_FLOAT, CIF_FLAGS(%rbp)
jne .Lret_double
mov RVALUE(%rbp), %rax
movlpd %xmm0,(%rax)
jmp .Lret_void
.Lret_double:
cmpl $FFI_TYPE_DOUBLE, CIF_FLAGS(%rbp)
jne .Lret_int64
mov RVALUE(%rbp), %rax
movlpd %xmm0, (%rax)
jmp .Lret_void
.Lret_int64:
cmpl $FFI_TYPE_SINT64, CIF_FLAGS(%rbp)
jne .Lret_void
mov RVALUE(%rbp), %rcx
mov %rax, (%rcx)
jmp .Lret_void
.Lret_void:
xor %eax, %eax
lea 16(%rbp), %rsp
pop %rbp
retq
.ffi_call_win64_end:
#endif /* !_MSC_VER */
+2
Ver Arquivo
@@ -164,6 +164,8 @@ X86_FALSE = @X86_FALSE@
X86_TRUE = @X86_TRUE@
X86_WIN32_FALSE = @X86_WIN32_FALSE@
X86_WIN32_TRUE = @X86_WIN32_TRUE@
X86_WIN64_FALSE = @X86_WIN64_FALSE@
X86_WIN64_TRUE = @X86_WIN64_TRUE@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+32 -3
Ver Arquivo
@@ -41,7 +41,17 @@
#else
#ifdef _WIN32
#ifdef __GNUC__
#include <excpt.h>
#else
// copied from mingw header
typedef EXCEPTION_DISPOSITION (*PEXCEPTION_HANDLER)
(struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*);
typedef struct _EXCEPTION_REGISTRATION {
struct _EXCEPTION_REGISTRATION* prev;
PEXCEPTION_HANDLER handler;
} EXCEPTION_REGISTRATION, *PEXCEPTION_REGISTRATION;
#endif
#include <setjmp.h>
typedef struct _exc_rec {
@@ -62,13 +72,30 @@ _exc_handler(struct _EXCEPTION_RECORD* exception_record,
return ExceptionContinueExecution;
}
#ifdef _MSC_VER
#define PROTECTED_START() __try {
#define PROTECTED_END(ONERR) } __except((PROTECT)?EXCEPTION_EXECUTE_HANDLER:EXCEPTION_CONTINUE_SEARCH) { ONERR; }
#else
#ifdef _WIN64
// FIXME: mingw64 is untested
#define SEH_TRY(ER) \
__asm__ ("pushq %0;pushq %%gs:0;movq %%rsp,%%gs:0;" : : "g" (&(ER)))
#define SEH_CATCH(ER) \
__asm__ ("movq (%%rsp),%%rax;movq %%rax,%%gs:0;addq $16,%%rsp" : : : "%rax")
#else
#define SEH_TRY(ER) \
__asm__ ("movl %%fs:0, %0" : "=r" ((ER).ex_reg.prev)); \
__asm__ ("movl %0, %%fs:0" : : "r" (&(ER)))
#define SEH_CATCH(ER) \
__asm__ ("movl %0, %%fs:0" : : "r" ((ER).ex_reg.prev))
#endif /* !_WIN64 */
#define PROTECTED_START() \
exc_rec _er; \
int _error = 0; \
if (PROTECT) { \
_er.ex_reg.handler = _exc_handler; \
asm volatile ("movl %%fs:0, %0" : "=r" (_er.ex_reg.prev)); \
asm volatile ("movl %0, %%fs:0" : : "r" (&_er)); \
SEH_TRY(_er); \
if ((_error = setjmp(_er.buf)) != 0) { \
goto _exc_caught; \
} \
@@ -82,9 +109,11 @@ _exc_handler(struct _EXCEPTION_RECORD* exception_record,
_exc_caught: \
ONERR; \
_remove_handler: \
if (PROTECT) { asm volatile ("movl %0, %%fs:0" : : "r" (_er.ex_reg.prev)); } \
if (PROTECT) { SEH_CATCH(_er); } \
} while(0)
#endif /* !_MSC_VER */
#else // _WIN32
// Most other platforms support signals
// Catch both SIGSEGV and SIGBUS
+58 -11
Ver Arquivo
@@ -1,5 +1,17 @@
/* Standard C calling convention tests. */
/* Copyright (c) 2007-2008 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.
*/
/* Native library implementation to support JUnit tests. */
#ifdef __cplusplus
extern "C" {
#endif
@@ -21,7 +33,7 @@ extern "C" {
#define int64 long long
#define LONG(X) X ## LL
#else
#error 64-bit type not defined for this platform
#error 64-bit type not defined for this compiler
#endif
#define MAGICSTRING "magic";
@@ -212,7 +224,6 @@ returnPointerArrayElement(void* args[], int which) {
EXPORT int
returnRotatedArgumentCount(char* args[]) {
int i=0;
int count = 0;
char* first = args[0];
while (args[count] != NULL) {
@@ -346,6 +357,37 @@ testStructureByValueArgument(struct CheckFieldAlignment arg) {
+ arg.int64Field + arg.floatField + arg.doubleField;
}
typedef struct ByValue8 { int8 data; } ByValue9;
typedef struct ByValue16 { int16 data; } ByValue16;
typedef struct ByValue32 { int32 data; } ByValue32;
typedef struct ByValue64 { int64 data; } ByValue64;
typedef struct ByValue128 { int64 data, data1; } ByValue128;
EXPORT int8
testStructureByValueArgument8(struct ByValue8 arg){
return arg.data;
}
EXPORT int16
testStructureByValueArgument16(struct ByValue16 arg){
return arg.data;
}
EXPORT int32
testStructureByValueArgument32(struct ByValue32 arg){
return arg.data;
}
EXPORT int64
testStructureByValueArgument64(struct ByValue64 arg){
return arg.data;
}
EXPORT int64
testStructureByValueArgument128(struct ByValue128 arg){
return arg.data + arg.data1;
}
typedef struct {
int8 field0;
int16 field1;
@@ -388,9 +430,9 @@ getStructureSize(unsigned index) {
return STRUCT_SIZES[index];
}
extern void exit(int);
extern void exit(int);
#define FIELD(T,X,N) (((T*)X)->field ## N)
#define OFFSET(T,X,N) (((char*)&FIELD(T,X,N))-((char*)&FIELD(T,X,0)))
#define OFFSET(T,X,N) (int)(((char*)&FIELD(T,X,N))-((char*)&FIELD(T,X,0)))
#define V8(N) (N+1)
#define V16(N) ((((int32)V8(N))<<8)|V8(N))
#define V32(N) ((((int32)V16(N))<<16)|V16(N))
@@ -448,7 +490,7 @@ modifyStructureArray(struct CheckFieldAlignment arg[], int length) {
EXPORT void
callVoidCallback(void (*func)()) {
callVoidCallback(void (*func)(void)) {
(*func)();
}
@@ -513,13 +555,18 @@ callStringCallback(char* (*func)(char* arg), char* arg) {
return (*func)(arg);
}
EXPORT char**
callStringArrayCallback(char** (*func)(char** arg), char** arg) {
return (*func)(arg);
}
EXPORT wchar_t*
callWideStringCallback(wchar_t* (*func)(wchar_t* arg), wchar_t* arg) {
return (*func)(arg);
}
struct cbstruct {
void (*func)();
void (*func)(void);
};
EXPORT void
@@ -545,13 +592,14 @@ structCallbackFunction(int arg1, int arg2) {
EXPORT void
setCallbackInStruct(struct cbstruct* cb) {
cb->func = (void (*)())structCallbackFunction;
cb->func = (void (*)(void))structCallbackFunction;
}
EXPORT int32
fillInt8Buffer(char *buf, int len, char value) {
int i;
for (i=0;i < len;i++) {
buf[i] = value;
}
@@ -635,14 +683,13 @@ EXPORT char *
returnStringVarArgs(const char *fmt, ...) {
char* cp;
va_list ap;
int32 sum = 0;
va_start(ap, fmt);
cp = va_arg(ap, char *);
va_end(ap);
return cp;
}
#ifdef _WIN32
#if defined(_WIN32) && !defined(_WIN64)
///////////////////////////////////////////////////////////////////////
// stdcall tests
///////////////////////////////////////////////////////////////////////
@@ -678,7 +725,7 @@ callInt32StdCallCallback(int32 (__stdcall *func)(int32 arg, int32 arg2),
}
return value;
}
#endif /* _WIN32 */
#endif /* _WIN32 && !_WIN64 */
#ifdef __cplusplus
}
+35
Ver Arquivo
@@ -0,0 +1,35 @@
/* Copyright (c) 2007-2008 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.
*/
/* Simple library with a dependency. */
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _WIN32
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
extern int returnFalse();
EXPORT int
dependentReturnFalse() {
return returnFalse();
}
#ifdef __cplusplus
}
#endif
+66
Ver Arquivo
@@ -0,0 +1,66 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<packaging>jar</packaging>
<version>3.0.9</version>
<name>Java Native Access</name>
<distributionManagement>
<repository>
<id>java.net-m2-repository</id>
<url>java-net:/maven2-repository/trunk/www/repository/</url>
</repository>
</distributionManagement>
<build>
<plugins>
<!-- fake out maven and install the binary artifact -->
<plugin>
<groupId>org.jvnet.maven-antrun-extended-plugin</groupId>
<artifactId>maven-antrun-extended-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<!--<ant dir="." target="dist" />-->
<attachArtifact file="dist/jna.jar" />
<attachArtifact file="dist/src-full.zip" classifier="sources" type="jar"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<extensions>
<extension>
<groupId>org.jvnet.wagon-svn</groupId>
<artifactId>wagon-svn</artifactId>
<version>1.8</version>
</extension>
</extensions>
</build>
<repositories>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
</pluginRepository>
</pluginRepositories>
</project>
+66
Ver Arquivo
@@ -1,4 +1,70 @@
<a name="top"></a>
<h2>Release 3.0.9</h2>
<b>Features</b><br>
<ul>
</ul>
<b>Bugs</b>
<ul>
<li> Fix issue 93 by only manually searching jna.library.path, then falling back to passing the mapped library name to dlopen/LoadLibrary. This fixes an issue in JRUBY (http://jira.codehaus.org/browse/JRUBY-3084) where the incorrect libc.so.6 was being loaded.
</ul>
<h2>Release 3.0.8</h2>
<b>Features</b><br>
<ul>
<li>Auto-map Pointer[]/String[]/WString[] return values.
<li>Provide utility functions to convert String to primitive array.
<li>Add jna.library.boot.path property to define the directory that the native stub library is loaded from
</ul>
<b>Bugs</b>
<ul>
</ul>
<h2>Release 3.0.7</h2>
<b>Features</b><br>
<ul>
<li>Improve win32 loading of libraries with dependencies.
</ul>
<b>Bug Fixes</b><br>
<li>Fix bug reading structures with PointerType fields, introduced with Pointer field preservation fix.
<ul></ul>
<h2>Release 3.0.6</h2>
<b>Features</b><br>
<ul>
<li>Allow arbitrary callback method names if only one method is defined in the class which implements Callback (colinwalters).
<li>Allow specification of callback type mappers by using a TYPE_MAPPER field (colinwalters).
<li>Allow uninitialized (null-valued) boxed primitives in Structures (colinwalters).
<li>Add convenience methods to set active Union field and value simultaneously (xylo).
<li>Augment Union read/writeField to set the active field.
<li>Allow Structure auto-synch across native calls to be disabled.
<li>Win64 support.
</ul>
<b>Bug Fixes</b><br>
<ul>
<li>Avoid overwriting unchanged Structure fields of type Pointer.
<li>Avoid more content dragging on OSX or warn if it's too late.
<li>Fix UnsatisfiedLinkError using transparent window on Win2K.
<li>Fix memory leak with callbacks called from native threads with no Java context (johnwallace).
<li>Defer structure size calculation if type mapper not yet set, allowing type mapper to be set in derived constructors (colinwalters).
<li>Ensure structure memory is allocated in Structure.read/writeField.
</ul>
<h2>Release 3.0.5</h2>
<b>Features</b><br>
<ul>
<li>Allow explicit declaration of field order for VMs which have an unpredictable field order.
<li>Check for w32 libraries with a "lib" prefix in addition to normal lookup.
<li>Allow String[]/WString[] as callback argument/return value (assume NULL-terminated array).
<li>Add Solaris8 compatibility to sunos-sparc build (Corey Puffalt).
<li>Look up libraries using web start library path, if appropriate (Corey Puffalt).
<li>Use constants to return integer boolean values.
</ul>
<b>Bug Fixes</b><br>
<ul>
<li>Properly track cursor on alpha-masked windows.
<li>Avoid searching /lib or /usr/lib on 64-bit Linux.
<li>Avoid using incorrect version of a library when both 32- and 64-bit versions are found.
<li>Avoid transparent window events always dragging window bug on OSX.
<li>Fix division by zero error calculating structure size on OSX/ppc.
<li>Avoid overwriting initialized NativeMapped Structure fields when calculating structure size.
<li>Fix NPE reading back into StringArray.
</ul>
<h2>Release 3.0.4</h2>
<b>Features</b><br>
<ul>
+14 -1
Ver Arquivo
@@ -12,8 +12,12 @@
*/
package com.sun.jna;
import java.util.Arrays;
import java.util.Collection;
/** All callback definitions must derive from this interface. Any
* derived interfaces must define a <code>callback</code> method.
* derived interfaces must define a single public method (which may not be named
* "hashCode", "equals", or "toString"), or one public method named "callback".
* You are responsible for deregistering your callback (if necessary)
* in its {@link Object#finalize} method. If native code attempts to call
* a callback which has been GC'd, you will likely crash the VM. If
@@ -24,5 +28,14 @@ package com.sun.jna;
* necessarily have an encompassing Java environment to catch it.
*/
public interface Callback {
/** You must this method name if your callback interface has multiple
public methods. Typically a callback will have only one such
method, in which case any method name may be used, with the exception
of those in {@link #FORBIDDEN_NAMES}.
*/
String METHOD_NAME = "callback";
/** These method names may not be used for a callback method. */
Collection FORBIDDEN_NAMES = Arrays.asList(new String[] {
"hashCode", "equals", "toString",
});
}
+71 -36
Ver Arquivo
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2007-2008 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
@@ -17,9 +17,12 @@ import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
/** Provides a reference to an association between a native callback closure
@@ -32,8 +35,19 @@ class CallbackReference extends WeakReference {
static final Map callbackMap = new WeakHashMap();
static final Map altCallbackMap = new WeakHashMap();
private static final Map nativeStrings = new WeakHashMap();
private static final Map allocations = new WeakHashMap();
private static final Method PROXY_CALLBACK_METHOD;
static {
try {
PROXY_CALLBACK_METHOD = CallbackProxy.class.getMethod("callback", new Class[] { Object[].class });
}
catch(Exception e) {
throw new Error("Error looking up CallbackProxy.callback() method");
}
}
/** Return a Callback associated with the given function pointer.
* If the pointer refers to a Java callback trampoline, return the original
* Java Callback. Otherwise, return a proxy to the native function pointer.
@@ -69,30 +83,17 @@ class CallbackReference extends WeakReference {
return null;
}
private static Class getCallbackClass(Class type) {
Class[] ifaces = type.getInterfaces();
for (int i=0;i < ifaces.length;i++) {
if (Callback.class.isAssignableFrom(ifaces[i])) {
type = ifaces[i];
break;
}
}
return type;
}
Pointer cbstruct;
// Keep a reference to avoid premature GC
CallbackProxy proxy;
private CallbackReference(Callback callback, int callingConvention) {
super(callback);
Class type = getCallbackClass(callback.getClass());
TypeMapper mapper = Native.getTypeMapper(type);
Method m = getCallbackMethod(callback);
TypeMapper mapper = Native.getTypeMapper(Native.findCallbackClass(callback.getClass()));
if (callback instanceof CallbackProxy) {
proxy = (CallbackProxy)callback;
}
else {
proxy = new DefaultCallbackProxy(m, mapper);
proxy = new DefaultCallbackProxy(getCallbackMethod(callback), mapper);
}
// Generate a list of parameter types that the native code can
@@ -127,8 +128,7 @@ class CallbackReference extends WeakReference {
throw new IllegalArgumentException(msg);
}
Method proxyMethod = getCallbackMethod(proxy);
cbstruct = createNativeCallback(proxy, proxyMethod,
cbstruct = createNativeCallback(proxy, PROXY_CALLBACK_METHOD,
nativeParamTypes, returnType,
callingConvention);
}
@@ -145,27 +145,50 @@ class CallbackReference extends WeakReference {
}
else if (cls == String.class
|| cls == WString.class
|| cls == String[].class
|| cls == WString[].class
|| Callback.class.isAssignableFrom(cls)) {
return Pointer.class;
}
return cls;
}
private static Method checkMethod(Method m) {
if (m.getParameterTypes().length > Function.MAX_NARGS) {
String msg = "Method signature exceeds the maximum "
+ "parameter count: " + m;
throw new IllegalArgumentException(msg);
}
return m;
}
private static Method getCallbackMethod(Callback callback) {
Method[] mlist = callback.getClass().getMethods();
for (int mi=0;mi < mlist.length;mi++) {
Method m = mlist[mi];
if (Callback.METHOD_NAME.equals(m.getName())) {
if (m.getParameterTypes().length > Function.MAX_NARGS) {
String msg = "Method signature exceeds the maximum "
+ "parameter count: " + m;
throw new IllegalArgumentException(msg);
}
return m;
// Look at only public methods defined by the Callback class
Class cls = Native.findCallbackClass(callback.getClass());
Method[] pubMethods = cls.getDeclaredMethods();
Method[] classMethods = cls.getMethods();
Set pmethods = new HashSet(Arrays.asList(pubMethods));
pmethods.retainAll(Arrays.asList(classMethods));
// Remove Object methods disallowed as callback method names
for (Iterator i=pmethods.iterator();i.hasNext();) {
Method m = (Method)i.next();
if (Callback.FORBIDDEN_NAMES.contains(m.getName())) {
i.remove();
}
}
String msg = "Callback must implement method named '"
+ Callback.METHOD_NAME + "'";
Method[] methods = (Method[])pmethods.toArray(new Method[pmethods.size()]);
if (methods.length == 1) {
return checkMethod(methods[0]);
}
for (int i=0;i < methods.length;i++) {
Method m = methods[i];
if (Callback.METHOD_NAME.equals(m.getName())) {
return checkMethod(m);
}
}
String msg = "Callback must implement a single public method, "
+ "or one public method named '" + Callback.METHOD_NAME + "'";
throw new IllegalArgumentException(msg);
}
@@ -310,6 +333,10 @@ class CallbackReference extends WeakReference {
else if (dstType == WString.class) {
value = new WString(((Pointer)value).getString(0, true));
}
else if (dstType == String[].class
|| dstType == WString[].class) {
value = ((Pointer)value).getStringArray(0, dstType == WString[].class);
}
else if (Callback.class.isAssignableFrom(dstType)) {
value = getCallback(dstType, (Pointer)value);
}
@@ -347,15 +374,23 @@ class CallbackReference extends WeakReference {
return ((Structure)value).getPointer();
}
else if (cls == boolean.class || cls == Boolean.class) {
return new Integer(Boolean.TRUE.equals(value)?-1:0);
return Boolean.TRUE.equals(value) ?
Function.INTEGER_TRUE : Function.INTEGER_FALSE;
}
else if (cls == String.class || cls == WString.class) {
// Store in a weak hash map to delay GC until string
// itself is GC'd.
NativeString ns = new NativeString(value.toString(), cls == WString.class);
nativeStrings.put(value, ns);
// Delay GC until string itself is GC'd.
allocations.put(value, ns);
return ns.getPointer();
}
else if (cls == String[].class || cls == WString.class) {
StringArray sa = cls == String[].class
? new StringArray((String[])value)
: new StringArray((WString[])value);
// Delay GC until array itself is GC'd.
allocations.put(value, sa);
return sa;
}
else if (Callback.class.isAssignableFrom(cls)) {
return getFunctionPointer((Callback)value);
}
@@ -383,7 +418,7 @@ class CallbackReference extends WeakReference {
String str = super.getName();
if (options.containsKey(Function.OPTION_INVOKING_METHOD)) {
Method m = (Method)options.get(Function.OPTION_INVOKING_METHOD);
Class cls = getCallbackClass(m.getDeclaringClass());
Class cls = Native.findCallbackClass(m.getDeclaringClass());
str += " (" + cls.getName() + ")";
}
return str;
+51 -9
Ver Arquivo
@@ -46,6 +46,9 @@ public class Function extends Pointer {
/** First alternate convention (currently used only for w32 stdcall). */
public static final int ALT_CONVENTION = 1;
static final Integer INTEGER_TRUE = new Integer(-1);
static final Integer INTEGER_FALSE = new Integer(0);
/**
* Obtain a <code>Function</code> representing a native
* function that follows the standard "C" calling convention.
@@ -239,7 +242,9 @@ public class Function extends Pointer {
continue;
if (inArg instanceof Structure) {
if (!(inArg instanceof Structure.ByValue)) {
((Structure)inArg).read();
if (((Structure)inArg).getAutoRead()) {
((Structure)inArg).read();
}
}
}
else if (args[i] instanceof PostCallRead) {
@@ -259,7 +264,9 @@ public class Function extends Pointer {
else if (Structure[].class.isAssignableFrom(inArg.getClass())) {
Structure[] ss = (Structure[])inArg;
for (int si=0;si < ss.length;si++) {
ss[si].read();
if (ss[si].getAutoRead()) {
ss[si].read();
}
}
}
}
@@ -304,7 +311,9 @@ public class Function extends Pointer {
}
else if (returnType==WString.class) {
String s = invokeString(callingConvention, args, true);
result = s != null ? new WString(s) : null;
if (s != null) {
result = new WString(s);
}
}
else if (Pointer.class.isAssignableFrom(returnType)) {
result = invokePointer(callingConvention, args);
@@ -314,7 +323,9 @@ public class Function extends Pointer {
Structure s =
invokeStructure(callingConvention, args,
Structure.newInstance(returnType));
s.read();
if (s.getAutoRead()) {
s.read();
}
result = s;
}
else {
@@ -322,7 +333,9 @@ public class Function extends Pointer {
if (result != null) {
Structure s = Structure.newInstance(returnType);
s.useMemory((Pointer)result);
s.read();
if (s.getAutoRead()) {
s.read();
}
result = s;
}
}
@@ -333,6 +346,29 @@ public class Function extends Pointer {
result = CallbackReference.getCallback(returnType, (Pointer)result);
}
}
else if (returnType==String[].class) {
Pointer p = invokePointer(callingConvention, args);
if (p != null) {
result = p.getStringArray(0);
}
}
else if (returnType==WString[].class) {
Pointer p = invokePointer(callingConvention, args);
if (p != null) {
String[] arr = p.getStringArray(0, true);
WString[] warr = new WString[arr.length];
for (int i=0;i < arr.length;i++) {
warr[i] = new WString(arr[i]);
}
result = warr;
}
}
else if (returnType==Pointer[].class) {
Pointer p = invokePointer(callingConvention, args);
if (p != null) {
result = p.getPointerArray(0);
}
}
else {
throw new IllegalArgumentException("Unsupported return type "
+ returnType
@@ -370,7 +406,9 @@ public class Function extends Pointer {
// Convert Structures to native pointers
if (arg instanceof Structure) {
Structure struct = (Structure)arg;
struct.write();
if (struct.getAutoWrite()) {
struct.write();
}
if (struct instanceof Structure.ByValue) {
// Double-check against the method signature, if available
Class ptype = struct.getClass();
@@ -415,7 +453,7 @@ public class Function extends Pointer {
// Default conversion of boolean to int; if you want something
// different, use a ToNativeConverter
else if (arg instanceof Boolean) {
return new Integer(Boolean.TRUE.equals(arg) ? -1 : 0);
return Boolean.TRUE.equals(arg) ? INTEGER_TRUE : INTEGER_FALSE;
}
else if (String[].class == argClass) {
return new StringArray((String[])arg);
@@ -456,14 +494,18 @@ public class Function extends Pointer {
else {
Pointer base = ss[0].getPointer();
int size = ss[0].size();
ss[0].write();
if (ss[0].getAutoWrite()) {
ss[0].write();
}
for (int si=1;si < ss.length;si++) {
if (ss[si].getPointer().peer != base.peer + size*si) {
String msg = "Structure array elements must use"
+ " contiguous memory (at element index " + si + ")";
throw new IllegalArgumentException(msg);
}
ss[si].write();
if (ss[si].getAutoWrite()) {
ss[si].write();
}
}
return base;
}
+131 -36
Ver Arquivo
@@ -84,12 +84,7 @@ public final class Native {
/** Size of a native <code>wchar_t</code> type, in bytes. */
public static final int WCHAR_SIZE;
static {
try {
System.loadLibrary("jnidispatch");
}
catch(UnsatisfiedLinkError e) {
loadNativeLibrary();
}
loadNativeLibrary();
POINTER_SIZE = pointerSize();
LONG_SIZE = longSize();
WCHAR_SIZE = wideCharSize();
@@ -280,20 +275,17 @@ public final class Native {
* Returns whether an instance variable was instantiated.
* Expects that lock on libraries is already held
*/
private static boolean loadInstance(Class cls) {
if (libraries.containsKey(cls)) {
return true;
}
if (cls != null) {
private static void loadLibraryInstance(Class cls) {
if (cls != null && !libraries.containsKey(cls)) {
try {
Field[] fields = cls.getFields();
for (int i=0;i < fields.length;i++) {
Field field = fields[i];
if (field.getType() == cls
&& Modifier.isStatic(field.getModifiers())) {
// Ensure the field gets initialized
// Ensure the field gets initialized by reading it
libraries.put(cls, new WeakReference(field.get(null)));
return true;
break;
}
}
}
@@ -302,25 +294,51 @@ public final class Native {
+ cls + " (" + e + ")");
}
}
return false;
}
/** Find the first instance of an interface which implements the Callback
* interface or an interface derived from Callback.
*/
static Class findCallbackClass(Class type) {
if (!Callback.class.isAssignableFrom(type)) {
throw new IllegalArgumentException(type.getName() + " is not derived from com.sun.jna.Callback");
}
if (type.isInterface()) {
return type;
}
Class[] ifaces = type.getInterfaces();
for (int i=0;i < ifaces.length;i++) {
if (Callback.class.isAssignableFrom(ifaces[i])) {
if (ifaces[i].getMethods().length == 1)
return ifaces[i];
break;
}
}
if (Callback.class.isAssignableFrom(type.getSuperclass())) {
return findCallbackClass(type.getSuperclass());
}
return type;
}
/** Find the library interface corresponding to the given class. Checks
* all ancestor classes for a declaring class which implements
* {@link Library}.
* all ancestor classes and interfaces for a declaring class which
* implements {@link Library}.
*/
static Class findLibraryClass(Class cls) {
static Class findEnclosingLibraryClass(Class cls) {
if (cls == null) {
return null;
}
if (Library.class.isAssignableFrom(cls)) {
return cls;
}
Class fromDeclaring = findLibraryClass(cls.getDeclaringClass());
if (Callback.class.isAssignableFrom(cls)) {
cls = findCallbackClass(cls);
}
Class fromDeclaring = findEnclosingLibraryClass(cls.getDeclaringClass());
if (fromDeclaring != null) {
return fromDeclaring;
}
return findLibraryClass(cls.getSuperclass());
return findEnclosingLibraryClass(cls.getSuperclass());
}
@@ -330,13 +348,15 @@ public final class Native {
*/
public static Map getLibraryOptions(Class type) {
synchronized(libraries) {
Class interfaceClass = findLibraryClass(type);
if (interfaceClass == null)
return null;
if (!loadInstance(interfaceClass)
|| !options.containsKey(interfaceClass)) {
Class interfaceClass = findEnclosingLibraryClass(type);
if (interfaceClass != null)
loadLibraryInstance(interfaceClass);
else
interfaceClass = type;
if (!options.containsKey(interfaceClass)) {
try {
Field field = interfaceClass.getField("OPTIONS");
field.setAccessible(true);
options.put(interfaceClass, field.get(null));
}
catch (NoSuchFieldException e) {
@@ -355,13 +375,16 @@ public final class Native {
*/
public static TypeMapper getTypeMapper(Class cls) {
synchronized(libraries) {
Class interfaceClass = findLibraryClass(cls);
if (interfaceClass == null)
return null;
if (!loadInstance(interfaceClass)
|| !typeMappers.containsKey(interfaceClass)) {
Class interfaceClass = findEnclosingLibraryClass(cls);
if (interfaceClass != null)
loadLibraryInstance(interfaceClass);
else
interfaceClass = cls;
if (!typeMappers.containsKey(interfaceClass)) {
try {
Field field = interfaceClass.getField("TYPE_MAPPER");
field.setAccessible(true);
typeMappers.put(interfaceClass, field.get(null));
}
catch (NoSuchFieldException e) {
@@ -386,17 +409,19 @@ public final class Native {
*/
public static int getStructureAlignment(Class cls) {
synchronized(libraries) {
Class interfaceClass = findLibraryClass(cls);
if (interfaceClass == null)
return Structure.ALIGN_DEFAULT;
if (!loadInstance(interfaceClass)
|| !alignments.containsKey(interfaceClass)) {
Class interfaceClass = findEnclosingLibraryClass(cls);
if (interfaceClass != null)
loadLibraryInstance(interfaceClass);
else
interfaceClass = cls;
if (!alignments.containsKey(interfaceClass)) {
try {
Field field = interfaceClass.getField("STRUCTURE_ALIGNMENT");
field.setAccessible(true);
alignments.put(interfaceClass, field.get(null));
}
catch(NoSuchFieldException e) {
Map options = getLibraryOptions(cls);
Map options = getLibraryOptions(interfaceClass);
if (options != null
&& options.containsKey(Library.OPTION_STRUCTURE_ALIGNMENT)) {
alignments.put(interfaceClass, options.get(Library.OPTION_STRUCTURE_ALIGNMENT));
@@ -428,6 +453,24 @@ public final class Native {
return s.getBytes();
}
/** Obtain a NUL-terminated byte buffer equivalent to the given String. */
public static byte[] toByteArray(String s) {
byte[] bytes = getBytes(s);
byte[] buf = new byte[bytes.length+1];
System.arraycopy(bytes, 0, buf, 0, bytes.length);
return buf;
}
/** Obtain a NUL-terminated wide character buffer equivalent to the given
String.
*/
public static char[] toCharArray(String s) {
char[] chars = s.toCharArray();
char[] buf = new char[chars.length+1];
System.arraycopy(chars, 0, buf, 0, chars.length);
return buf;
}
private static String getNativeLibraryResourcePath() {
String arch = System.getProperty("os.arch").toLowerCase();
String osPrefix;
@@ -460,7 +503,58 @@ public final class Native {
return "/com/sun/jna/" + osPrefix;
}
/**
* Loads the JNA stub library. It will first attempt to load this library
* from the directories specified in jna.boot.library.path. If that fails,
* it will fallback to loading from the system library paths. Finally it will
* attempt to extract the stub library from from the JNA jar file, and load it.
* <p>
* The jna.boot.library.path property is mainly to support jna.jar being
* included in -Xbootclasspath, where java.library.path and LD_LIBRARY_PATH
* are ignored. It might also be useful in other situations.
* </p>
*/
private static void loadNativeLibrary() {
String libName = "jnidispatch";
String bootPath = System.getProperty("jna.boot.library.path");
if (bootPath != null) {
String[] dirs = bootPath.split(File.pathSeparator);
for (int i = 0; i < dirs.length; ++i) {
String path = new File(new File(dirs[i]), System.mapLibraryName(libName)).getAbsolutePath();
try {
System.load(path);
return;
} catch (UnsatisfiedLinkError ex) {
}
if (Platform.isMac()) {
String orig, ext;
if (path.endsWith("dylib")) {
orig = "dylib";
ext = "jnilib";
} else {
orig = "jnilib";
ext = "dylib";
}
try {
System.load(path.substring(0, path.lastIndexOf(orig)) + ext);
return;
} catch (UnsatisfiedLinkError ex) {
}
}
}
}
try {
System.loadLibrary(libName);
}
catch(UnsatisfiedLinkError e) {
loadNativeLibraryFromJar();
}
}
/**
* Extracts and loads the JNA stub library from jna.jar
*/
private static void loadNativeLibraryFromJar() {
String libname = System.mapLibraryName("jnidispatch");
String resourceName = getNativeLibraryResourcePath() + "/" + libname;
URL url = Native.class.getResource(resourceName);
@@ -594,7 +688,8 @@ public final class Native {
* <code>jna.library.path</code> so that JNA can load libraries identified
* by the &lt;nativelib&gt; tag in the JNLP configuration file. Returns
* <code>null</code> if the Web Start native library cache location can not
* be determined.
* be determined. Note that the path returned may be different for any
* given library name.
* <p>
* Use <code>System.getProperty("javawebstart.version")</code> to detect
* whether your code is running under Web Start.
+42 -5
Ver Arquivo
@@ -1,5 +1,5 @@
/* Copyright (c) 2007 Wayne Meissner, 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
@@ -48,6 +48,7 @@ public class NativeLibrary {
private static final Map libraries = new HashMap();
private static final Map searchPaths = Collections.synchronizedMap(new HashMap());
private static final List librarySearchPath = new LinkedList();
private static final List userSearchPath = new LinkedList();
static {
// Force initialization of native library
@@ -74,7 +75,14 @@ public class NativeLibrary {
}
private static NativeLibrary loadLibrary(String libraryName) {
List searchPath = new LinkedList(librarySearchPath);
List searchPath = new LinkedList();
// Append web start path, if available. Note that this does not
// attempt any library name variations
String webstartPath = Native.getWebStartLibraryPath(libraryName);
if (webstartPath != null) {
searchPath.add(webstartPath);
}
//
// Prepend any custom search paths specifically for this library
@@ -85,11 +93,28 @@ public class NativeLibrary {
searchPath.addAll(0, customPaths);
}
}
searchPath.addAll(userSearchPath);
String libraryPath = findLibraryPath(libraryName, searchPath);
long handle = 0;
//
// Only search user specified paths first. This will also fall back
// to dlopen/LoadLibrary() since findLibraryPath returns the mapped name
// if it cannot find the library.
//
try {
handle = open(libraryPath);
}
catch(UnsatisfiedLinkError e) {
// Add the system paths back for all fallback searching
searchPath.addAll(librarySearchPath);
}
try {
if (handle == 0) {
libraryPath = findLibraryPath(libraryName, searchPath);
handle = open(libraryPath);
}
}
catch(UnsatisfiedLinkError e) {
if (Platform.isLinux()) {
//
@@ -110,6 +135,12 @@ public class NativeLibrary {
catch(UnsatisfiedLinkError e2) { e = e2; }
}
}
// Try the same library with a "lib" prefix
else if (Platform.isWindows()) {
libraryPath = findLibraryPath("lib" + libraryName, searchPath);
try { handle = open(libraryPath); }
catch(UnsatisfiedLinkError e2) { e = e2; }
}
if (handle == 0) {
throw new UnsatisfiedLinkError("Unable to load library '" + libraryName + "': "
+ e.getMessage());
@@ -404,7 +435,7 @@ public class NativeLibrary {
String path = ((File) it.next()).getAbsolutePath();
String ver = path.substring(path.lastIndexOf(".so.") + 4);
double version = parseVersion(ver);
if (version >= bestVersion) {
if (version > bestVersion) {
bestVersion = version;
bestMatch = path;
}
@@ -443,8 +474,7 @@ public class NativeLibrary {
private static native void close(long handle);
private static native long findSymbol(long handle, String name);
static {
librarySearchPath.addAll(initPaths("jna.library.path"));
userSearchPath.addAll(initPaths("jna.library.path"));
String webstartPath = Native.getWebStartLibraryPath("jnidispatch");
if (webstartPath != null) {
librarySearchPath.add(webstartPath);
@@ -477,6 +507,13 @@ public class NativeLibrary {
"/usr/lib",
"/lib",
};
// Linux 64-bit does not use /lib or /usr/lib
if (Platform.isLinux() && Pointer.SIZE == 8) {
paths = new String[] {
"/usr/lib" + archPath,
"/lib" + archPath,
};
}
for (int i=0;i < paths.length;i++) {
File dir = new File(paths[i]);
if (dir.exists() && dir.isDirectory()) {
+8 -1
Ver Arquivo
@@ -17,7 +17,8 @@ public final class Platform {
private static final int WINDOWS = 2;
private static final int SOLARIS = 3;
private static final int FREEBSD = 4;
private static final int WINDOWSCE = 5;
private static final int OPENBSD = 5;
private static final int WINDOWSCE = 6;
private static final int osType;
static {
@@ -40,6 +41,9 @@ public final class Platform {
else if (osName.startsWith("FreeBSD")) {
osType = FREEBSD;
}
else if (osName.startsWith("OpenBSD")) {
osType = OPENBSD;
}
else {
osType = UNSPECIFIED;
}
@@ -63,6 +67,9 @@ public final class Platform {
public static final boolean isFreeBSD() {
return osType == FREEBSD;
}
public static final boolean isOpenBSD() {
return osType == OPENBSD;
}
public static final boolean isX11() {
// TODO: check filesystem for /usr/X11 or some other X11-specific test
return !Platform.isWindows() && !Platform.isMac();
+43
Ver Arquivo
@@ -13,6 +13,8 @@ package com.sun.jna;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.List;
/**
* An abstraction for a native pointer data type. A Pointer instance
@@ -603,12 +605,53 @@ v * @param wide whether to convert from a wide or standard C string
return buf;
}
/** Returns an array of {@link Pointer}. The array length is
* determined by a NULL-valued terminating element.
*/
public Pointer[] getPointerArray(long base) {
List array = new ArrayList();
int offset = 0;
Pointer p = getPointer(base);
while (p != null) {
array.add(p);
offset += Pointer.SIZE;
p = getPointer(base + offset);
}
return (Pointer[])array.toArray(new Pointer[array.size()]);
}
/** Returns an array of {@link Pointer} of the requested size. */
public Pointer[] getPointerArray(long offset, int arraySize) {
Pointer[] buf = new Pointer[arraySize];
read(offset, buf, 0, arraySize);
return buf;
}
/** Returns an array of <code>String</code> based on a native array
* of <code>char *</code>. The array length is determined by a
* NULL-valued terminating element.
*/
public String[] getStringArray(long base) {
return getStringArray(base, false);
}
/** Returns an array of <code>String</code> based on a native array
* of <code>char*</code> or <code>wchar_t*</code> based on the
* <code>wide</code> parameter. The array length is determined by a
* NULL-valued terminating element.
*/
public String[] getStringArray(long base, boolean wide) {
List strings = new ArrayList();
int offset = 0;
Pointer p = getPointer(base);
while (p != null) {
strings.add(p.getString(0, wide));
offset += SIZE;
p = getPointer(base + offset);
}
return (String[])strings.toArray(new String[strings.size()]);
}
//////////////////////////////////////////////////////////////////////////
// Java type write methods
//////////////////////////////////////////////////////////////////////////
+19 -2
Ver Arquivo
@@ -1,3 +1,15 @@
/* Copyright (c) 2007-2008 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;
import java.util.ArrayList;
@@ -43,8 +55,13 @@ public class StringArray extends Memory implements Function.PostCallRead {
public void read() {
boolean returnWide = original instanceof WString[];
for (int si=0;si < original.length;si++) {
String s = getPointer(si * Pointer.SIZE).getString(0, wide);
original[si] = returnWide ? new WString(s) : (Object)s;
Pointer p = getPointer(si * Pointer.SIZE);
Object s = null;
if (p != null) {
s = p.getString(0, wide);
if (returnWide) s = new WString((String)s);
}
original[si] = s;
}
}
}
+191 -38
Ver Arquivo
@@ -14,10 +14,13 @@ import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.Buffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
@@ -56,6 +59,7 @@ import java.util.WeakHashMap;
* @author twall@users.sf.net
*/
public abstract class Structure {
/** Tagging interface to indicate the value of an instance of the
* <code>Structure</code> type is to be used in function invocations rather
* than its address. The default behavior is to treat
@@ -77,17 +81,16 @@ public abstract class Structure {
}
private static final boolean REVERSE_FIELDS;
static boolean REQUIRES_FIELD_ORDER;
static final boolean isPPC;
static final boolean isSPARC;
static {
// IBM and JRockit store fields in reverse order; check for it
Field[] fields = MemberOrder.class.getFields();
REVERSE_FIELDS = "last".equals(fields[0].getName());
if (!"middle".equals(fields[1].getName())) {
throw new Error("This VM does not store fields in a predictable order");
}
REQUIRES_FIELD_ORDER = !"middle".equals(fields[1].getName());
String arch = System.getProperty("os.arch").toLowerCase();
isPPC = "ppc".equals(arch) || "powerpc".equals(arch);
isSPARC = "sparc".equals(arch);
@@ -102,7 +105,7 @@ public abstract class Structure {
/** validated for w32/msvc; align on field size */
public static final int ALIGN_MSVC = 3;
private static final int MAX_GNUC_ALIGNMENT = isSPARC ? 8 : NativeLong.SIZE;
private static final int MAX_GNUC_ALIGNMENT = isSPARC ? 8 : Native.LONG_SIZE;
protected static final int CALCULATE_SIZE = -1;
// This field is accessed by native code
@@ -116,6 +119,9 @@ public abstract class Structure {
private TypeMapper typeMapper;
// This field is accessed by native code
private long typeInfo;
private List fieldOrder;
private boolean autoRead = true;
private boolean autoWrite = true;
protected Structure() {
this(CALCULATE_SIZE);
@@ -126,8 +132,16 @@ public abstract class Structure {
}
protected Structure(int size, int alignment) {
this(size, alignment, null);
}
protected Structure(TypeMapper mapper) {
this(CALCULATE_SIZE, ALIGN_DEFAULT, mapper);
}
protected Structure(int size, int alignment, TypeMapper mapper) {
setAlignType(alignment);
setTypeMapper(null);
setTypeMapper(mapper);
allocateMemory(size);
}
@@ -285,11 +299,13 @@ public abstract class Structure {
}
}
/** Force a read of the given field from native memory.
/** Force a read of the given field from native memory. The Java field
* will be updated from the current contents of native memory.
* @return the new field value, after updating
* @throws IllegalArgumentException if no field exists with the given name
*/
public Object readField(String name) {
ensureAllocated();
StructField f = (StructField)structFields.get(name);
if (f == null)
throw new IllegalArgumentException("No such field: " + name);
@@ -310,7 +326,7 @@ public abstract class Structure {
}
}
private void setField(StructField structField, Object value) {
void setField(StructField structField, Object value) {
try {
structField.field.set(this, value);
}
@@ -321,8 +337,8 @@ public abstract class Structure {
}
}
/** Only keep the original structure if its address is unchanged. Otherwise
* replace it with a new object.
/** Only keep the original structure if its native address is unchanged.
* Otherwise replace it with a new object.
* @param type Structure subclass
* @param s Original Structure object
* @param address the native <code>struct *</code>
@@ -337,12 +353,16 @@ public abstract class Structure {
s = newInstance(type);
s.useMemory(address);
}
s.read();
if (s.getAutoRead()) {
s.read();
}
}
return s;
}
/** Read the given field and return its value. */
/** Read the given field and return its value. The Java field will be
* updated from the contents of native memory.
*/
// TODO: make overridable method with calculated native type, offset, etc
Object readField(StructField structField) {
@@ -355,9 +375,11 @@ public abstract class Structure {
if (readConverter != null) {
nativeType = readConverter.nativeType();
}
// Get the value at the offset according to its type
// Get the current value only for types which might need to be preserved
Object currentValue = (Structure.class.isAssignableFrom(nativeType)
|| Callback.class.isAssignableFrom(nativeType)
|| Buffer.class.isAssignableFrom(nativeType)
|| Pointer.class.isAssignableFrom(nativeType)
|| nativeType.isArray())
? getField(structField) : null;
Object result = readValue(offset, nativeType, currentValue);
@@ -410,7 +432,15 @@ public abstract class Structure {
result = new Double(memory.getDouble(offset));
}
else if (nativeType == Pointer.class) {
result = memory.getPointer(offset);
Pointer p = memory.getPointer(offset);
if (p != null) {
Pointer oldp = currentValue instanceof Pointer
? (Pointer)currentValue : null;
if (oldp == null || p.peer != oldp.peer)
result = p;
else
result = oldp;
}
}
else if (nativeType == String.class) {
Pointer p = memory.getPointer(offset);
@@ -549,14 +579,32 @@ public abstract class Structure {
}
}
/** Write the given field to native memory. */
/** Write the given field to native memory. The current value in the Java
* field will be translated into native memory.
* @throws IllegalArgumentException if no field exists with the given name
*/
public void writeField(String name) {
ensureAllocated();
StructField f = (StructField)structFields.get(name);
if (f == null)
throw new IllegalArgumentException("No such field: " + name);
writeField(f);
}
/** Write the given field value to the field and native memory. The
* given value will be written both to the Java field and the
* corresponding native memory.
* @throws IllegalArgumentException if no field exists with the given name
*/
public void writeField(String name, Object value) {
ensureAllocated();
StructField f = (StructField)structFields.get(name);
if (f == null)
throw new IllegalArgumentException("No such field: " + name);
setField(f, value);
writeField(f);
}
void writeField(StructField structField) {
// Get the offset of the field
int offset = structField.offset;
@@ -587,6 +635,7 @@ public abstract class Structure {
}
else {
value = null;
nativeStrings.remove(structField.name);
}
}
@@ -606,25 +655,25 @@ public abstract class Structure {
memory.setInt(offset, Boolean.TRUE.equals(value) ? -1 : 0);
}
else if (nativeType == byte.class || nativeType == Byte.class) {
memory.setByte(offset, ((Byte)value).byteValue());
memory.setByte(offset, value == null ? 0 : ((Byte)value).byteValue());
}
else if (nativeType == short.class || nativeType == Short.class) {
memory.setShort(offset, ((Short)value).shortValue());
memory.setShort(offset, value == null ? 0 : ((Short)value).shortValue());
}
else if (nativeType == char.class || nativeType == Character.class) {
memory.setChar(offset, ((Character)value).charValue());
memory.setChar(offset, value == null ? 0 : ((Character)value).charValue());
}
else if (nativeType == int.class || nativeType == Integer.class) {
memory.setInt(offset, ((Integer)value).intValue());
memory.setInt(offset, value == null ? 0 : ((Integer)value).intValue());
}
else if (nativeType == long.class || nativeType == Long.class) {
memory.setLong(offset, ((Long)value).longValue());
memory.setLong(offset, value == null ? 0 : ((Long)value).longValue());
}
else if (nativeType == float.class || nativeType == Float.class) {
memory.setFloat(offset, ((Float)value).floatValue());
memory.setFloat(offset, value == null ? 0f : ((Float)value).floatValue());
}
else if (nativeType == double.class || nativeType == Double.class) {
memory.setDouble(offset, ((Double)value).doubleValue());
memory.setDouble(offset, value == null ? 0.0 : ((Double)value).doubleValue());
}
else if (nativeType == Pointer.class) {
memory.setPointer(offset, (Pointer)value);
@@ -732,6 +781,35 @@ public abstract class Structure {
return true;
}
protected List getFieldOrder() {
synchronized(this) {
if (fieldOrder == null) {
fieldOrder = new ArrayList();
}
return fieldOrder;
}
}
/** Provided for VMs where the field order as returned by {@link
* Class#getFields()} is not predictable.
*/
protected void setFieldOrder(String[] fields) {
getFieldOrder().addAll(Arrays.asList(fields));
}
/** Sort the structure fields according to the given array of names. */
protected void sortFields(Field[] fields, String[] names) {
for (int i=0;i < names.length;i++) {
for (int f=i;f < fields.length;f++) {
if (names[i].equals(fields[f].getName())) {
Field tmp = fields[f];
fields[f] = fields[i];
fields[i] = tmp;
break;
}
}
}
}
/** Calculate the amount of native memory required for this structure.
* May return {@link #CALCULATE_SIZE} if the size can not yet be
@@ -752,6 +830,16 @@ public abstract class Structure {
structAlignment = 1;
int calculatedSize = 0;
Field[] fields = getClass().getFields();
// Restrict to valid fields
List flist = new ArrayList();
for (int i=0;i < fields.length;i++) {
int modifiers = fields[i].getModifiers();
if (Modifier.isStatic(modifiers) || !Modifier.isPublic(modifiers))
continue;
flist.add(fields[i]);
}
fields = (Field[])flist.toArray(new Field[flist.size()]);
if (REVERSE_FIELDS) {
for (int i=0;i < fields.length/2;i++) {
int idx = fields.length-1-i;
@@ -760,11 +848,20 @@ public abstract class Structure {
fields[idx] = tmp;
}
}
else if (REQUIRES_FIELD_ORDER) {
List fieldOrder = getFieldOrder();
if (fieldOrder.size() < fields.length) {
if (force) {
throw new Error("This VM does not store fields in a predictable order; you must use setFieldOrder: " + System.getProperty("java.vendor") + ", " + System.getProperty("java.version"));
}
return CALCULATE_SIZE;
}
sortFields(fields, (String[])fieldOrder.toArray(new String[fieldOrder.size()]));
}
for (int i=0; i<fields.length; i++) {
Field field = fields[i];
int modifiers = field.getModifiers();
if (Modifier.isStatic(modifiers) || !Modifier.isPublic(modifiers))
continue;
Class type = field.getType();
StructField structField = new StructField();
@@ -819,12 +916,14 @@ public abstract class Structure {
Class nativeType = type;
if (NativeMapped.class.isAssignableFrom(type)) {
NativeMappedConverter tc = NativeMappedConverter.getInstance(type);
value = tc.defaultValue();
if (value == null) {
value = tc.defaultValue();
setField(structField, value);
}
nativeType = tc.nativeType();
structField.writeConverter = tc;
structField.readConverter = tc;
structField.context = new StructureReadContext(this, field);
setField(structField, value);
}
else if (typeMapper != null) {
ToNativeConverter writeConverter = typeMapper.getToNativeConverter(type);
@@ -842,8 +941,17 @@ public abstract class Structure {
throw new IllegalArgumentException(msg);
}
}
structField.size = getNativeSize(nativeType, value);
fieldAlignment = getNativeAlignment(nativeType, value, i==0);
try {
structField.size = getNativeSize(nativeType, value);
fieldAlignment = getNativeAlignment(nativeType, value, i==0);
}
catch(IllegalArgumentException e) {
// Might simply not yet have a type mapper set
if (!force && typeMapper == null) {
return CALCULATE_SIZE;
}
throw e;
}
// Align fields as appropriate
structAlignment = Math.max(structAlignment, fieldAlignment);
@@ -899,7 +1007,7 @@ public abstract class Structure {
int size = getNativeSize(type, value);
if (type.isPrimitive() || Long.class == type || Integer.class == type
|| Short.class == type || Character.class == type
|| Byte.class == type
|| Byte.class == type || Boolean.class == type
|| Float.class == type || Double.class == type) {
alignment = size;
}
@@ -927,15 +1035,18 @@ public abstract class Structure {
throw new IllegalArgumentException("Type " + type + " has unknown "
+ "native alignment");
}
if (alignType == ALIGN_NONE)
return 1;
if (alignType == ALIGN_MSVC)
return Math.min(8, alignment);
if (alignType == ALIGN_GNUC) {
if (alignType == ALIGN_NONE) {
alignment = 1;
}
else if (alignType == ALIGN_MSVC) {
alignment = Math.min(8, alignment);
}
else if (alignType == ALIGN_GNUC) {
// NOTE this is published ABI for 32-bit gcc/linux/x86, osx/x86,
// and osx/ppc. osx/ppc special-cases the first element
if (!isFirstElement || !(Platform.isMac() && isPPC))
return Math.min(MAX_GNUC_ALIGNMENT, alignment);
if (!isFirstElement || !(Platform.isMac() && isPPC)) {
alignment = Math.min(MAX_GNUC_ALIGNMENT, alignment);
}
}
return alignment;
}
@@ -955,7 +1066,7 @@ public abstract class Structure {
// auto-create a java.nio.Buffer w/o knowing its size
if (Buffer.class.isAssignableFrom(type)) {
throw new IllegalArgumentException("the type \"" + type.getName()
+ "\" is not supported as a structure field");
+ "\" is not supported as a structure field: ");
}
if (Structure.class.isAssignableFrom(type)
&& !Structure.ByReference.class.isAssignableFrom(type)) {
@@ -968,7 +1079,8 @@ public abstract class Structure {
}
catch(IllegalArgumentException e) {
throw new IllegalArgumentException("The type \"" + type.getName()
+ "\" is not supported as a structure field");
+ "\" is not supported as a structure field: "
+ e.getMessage());
}
}
@@ -1116,6 +1228,47 @@ public abstract class Structure {
return p;
}
/** Set whether the structure is automatically synched to native memory
before and after a native function call. Convenience method for
<pre><code>
boolean auto = ...;
setAutoRead(auto);
setAutoWrite(auto);
</code></pre>
*/
public void setAutoSynch(boolean auto) {
setAutoRead(auto);
setAutoWrite(auto);
}
/** Set whether the struture is written to native memory prior to
a native function call.
*/
public void setAutoRead(boolean auto) {
this.autoRead = auto;
}
/** Returns whether the struture is written to native memory prior to
a native function call.
*/
public boolean getAutoRead() {
return this.autoRead;
}
/** Set whether the structure is read from native memory after a native
function call.
*/
public void setAutoWrite(boolean auto) {
this.autoWrite = auto;
}
/** Returns whether the structure is read from native memory after a native
function call.
*/
public boolean getAutoWrite() {
return this.autoWrite;
}
/** Exposed for testing purposes only. */
static Pointer getTypeInfo(Object obj) {
return FFIType.get(obj);
+108
Ver Arquivo
@@ -39,6 +39,14 @@ public abstract class Union extends Structure {
protected Union(int size, int alignType) {
super(size, alignType);
}
/** Create a Union of the given size and alignment type. */
protected Union(TypeMapper mapper) {
super(mapper);
}
/** Create a Union of the given size and alignment type. */
protected Union(int size, int alignType, TypeMapper mapper) {
super(size, alignType, mapper);
}
/** Indicates which field will be used to write to native memory.
* @throws IllegalArgumentException if the type does not correspond to
* any declared union field.
@@ -55,6 +63,106 @@ public abstract class Union extends Structure {
throw new IllegalArgumentException("No field of type " + type + " in " + this);
}
/** Force a read of the given field from native memory.
* @return the new field value, after updating
* @throws IllegalArgumentException if no field exists with the given name
*/
public Object readField(String name) {
ensureAllocated();
StructField f = (StructField)fields().get(name);
if (f != null) {
setType(f.type);
}
return super.readField(name);
}
/** Write the given field value to native memory.
* The given field will become the active one.
* @throws IllegalArgumentException if no field exists with the given name
*/
public void writeField(String name) {
ensureAllocated();
StructField f = (StructField)fields().get(name);
if (f != null) {
setType(f.type);
}
super.writeField(name);
}
/** Write the given field value to the field and native memory.
* The given field will become the active one.
* @throws IllegalArgumentException if no field exists with the given name
*/
public void writeField(String name, Object value) {
ensureAllocated();
StructField f = (StructField)fields().get(name);
if (f != null) {
setType(f.type);
}
super.writeField(name, value);
}
/** Reads the Structure field of the given type from memory, sets it as
* the active type and returns it. Convenience method for
* <pre><code>
* Union u;
* Class type;
* u.setType(type);
* u.read();
* value = u.<i>field</i>;
* </code></pre>
* @param type class type of the Structure field to read
* @return the Structure field with the given type
*/
public Object getTypedValue(Class type) {
ensureAllocated();
for (Iterator i=fields().values().iterator();i.hasNext();) {
StructField f = (StructField)i.next();
if (f.type == type) {
activeField = f;
read();
return getField(activeField);
}
}
throw new IllegalArgumentException("No field of type " + type + " in " + this);
}
/** Set the active type and its value. Convenience method for
* <pre><code>
* Union u;
* Class type;
* u.setType(type);
* u.<i>field</i> = value;
* </code></pre>
* @param object instance of a class which is part of the union
* @return this Union object
*/
public Object setTypedValue(Object object) {
ensureAllocated();
StructField f = findField(object.getClass());
if (f != null) {
activeField = f;
setField(f, object);
return this;
}
throw new IllegalArgumentException("No field of type " + object.getClass() + " in " + this);
}
/** Returns the field in this union with the same type as <code>type</code>,
* if any, null otherwise.
* @param type type to search for
* @return StructField of matching type
*/
private StructField findField(Class type) {
for (Iterator i=fields().values().iterator();i.hasNext();) {
StructField f = (StructField)i.next();
if (f.type.isAssignableFrom(type)) {
return f;
}
}
return null;
}
/** Only the currently selected field will be written. */
void writeField(StructField field) {
if (field == activeField) {
@@ -10,6 +10,7 @@
*/
package com.sun.jna.examples;
import java.awt.Cursor;
import java.awt.BorderLayout;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsEnvironment;
@@ -51,16 +52,11 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.MouseInputAdapter;
// TODO: put this into a reasonable API; right now this is pretty much
// just hard-coded blitting of an image into a window
// Thanks to Rui Lopes for the C# example on which this is based:
// rui@ruilopes.com
// http://www.codeproject.com/cs/media/perpxalpha_sharp.asp?df=100&forumid=3270&exp=0&select=773155
public class AlphaMaskDemo2 implements Runnable {
private static final DataFlavor URL_FLAVOR = new DataFlavor("application/x-java-url; class=java.net.URL",
"URL");
private static final DataFlavor URI_LIST_FLAVOR = new DataFlavor("text/uri-list; class=java.lang.String",
"URI list");
private static final DataFlavor URL_FLAVOR =
new DataFlavor("application/x-java-url; class=java.net.URL", "URL");
private static final DataFlavor URI_LIST_FLAVOR =
new DataFlavor("text/uri-list; class=java.lang.String", "URI list");
private JFrame frame;
private JWindow alphaWindow;
private JLabel icon;
@@ -107,6 +103,7 @@ public class AlphaMaskDemo2 implements Runnable {
frame = new JFrame("Alpha Mask Demo");
alphaWindow = new JWindow(frame, gconfig);
icon = new JLabel();
icon.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
alphaWindow.getContentPane().add(icon);
JButton quit = new JButton("Quit");
JLabel label = new JLabel("Drag this window by its image");
@@ -252,6 +249,7 @@ public class AlphaMaskDemo2 implements Runnable {
"<html><center>Drop an image with an alpha channel onto this window<br>"
+ "You may also adjust the overall transparency with the slider</center></html>"),
BorderLayout.NORTH);
p.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
final JSlider slider = new JSlider(0, 255, 255);
slider.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
@@ -291,7 +291,7 @@ public abstract class FileMonitor {
finfo.overlapped, null)) {
int err = klib.GetLastError();
throw new IOException("ReadDirectoryChangesW failed on "
+ finfo.file
+ finfo.file + ", handle " + handle
+ ": '" + getSystemError(err)
+ "' (" + err + ")");
}
@@ -356,6 +356,7 @@ public abstract class FileMonitor {
null, code,
0, pref, 0, null);
String s = pref.getValue().getString(0, !Boolean.getBoolean("w32.ascii"));
s = s.replace(".\r",".").replace(".\n",".");
lib.LocalFree(pref.getValue());
return s;
}
+44 -27
Ver Arquivo
@@ -13,6 +13,9 @@
package com.sun.jna.examples;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import com.sun.jna.examples.win32.Shell32;
import com.sun.jna.examples.win32.Shell32.SHFILEOPSTRUCT;
@@ -24,9 +27,9 @@ public abstract class FileUtils {
}
/** Move the given file to the system trash, if one is available.
Returns whether the operation was successful.
Throws an exception on failure.
*/
public abstract boolean moveToTrash(File[] files);
public abstract void moveToTrash(File[] files) throws IOException;
/** Canonical lazy loading of a singleton. */
private static class Holder {
@@ -53,7 +56,7 @@ public abstract class FileUtils {
public boolean hasTrash() { return true; }
public boolean moveToTrash(File[] files) {
public void moveToTrash(File[] files) throws IOException {
Shell32 shell = Shell32.INSTANCE;
SHFILEOPSTRUCT fileop = new SHFILEOPSTRUCT();
fileop.wFunc = Shell32.FO_DELETE;
@@ -63,7 +66,13 @@ public abstract class FileUtils {
}
fileop.pFrom = fileop.encodePaths(paths);
fileop.fFlags = Shell32.FOF_ALLOWUNDO|Shell32.FOF_NOCONFIRMATION|Shell32.FOF_SILENT;
return shell.SHFileOperation(fileop) == 0;
int ret = shell.SHFileOperation(fileop);
if (ret != 0) {
throw new IOException("Move to trash failed: " + ret);
}
if (fileop.fAnyOperationsAborted) {
throw new IOException("Move to trash aborted");
}
}
}
@@ -71,22 +80,24 @@ public abstract class FileUtils {
public boolean hasTrash() { return true; }
public boolean moveToTrash(File[] files) {
public void moveToTrash(File[] files) throws IOException {
// TODO: use native API for moving to trash (if any)
File home = new File(System.getProperty("user.home"));
File trash = new File(home, ".Trash");
if (trash.exists()) {
boolean success = true;
for (int i=0;i < files.length;i++) {
File src = files[i];
File target = new File(trash, src.getName());
if (!src.renameTo(target)) {
success = false;
}
}
return success;
if (!trash.exists()) {
throw new IOException("The Trash was not found in its expected location (" + trash + ")");
}
List failed = new ArrayList();
for (int i=0;i < files.length;i++) {
File src = files[i];
File target = new File(trash, src.getName());
if (!src.renameTo(target)) {
failed.add(src);
}
}
if (failed.size() > 0) {
throw new IOException("The following files could not be trashed: " + failed);
}
return false;
}
}
@@ -105,6 +116,9 @@ public abstract class FileUtils {
trash = new File(desktop, ".Trash");
if (!trash.exists()) {
trash = new File(desktop, "Trash");
if (!trash.exists()) {
trash = new File(System.getProperty("fileutils.trash", "Trash"));
}
}
}
}
@@ -119,19 +133,22 @@ public abstract class FileUtils {
/** The default implementation attempts to move the file to
* the desktop "Trash" folder.
*/
public boolean moveToTrash(File[] files) {
public void moveToTrash(File[] files) throws IOException {
File trash = getTrashDirectory();
if (trash.exists()) {
boolean success = true;
for (int i=0;i < files.length;i++) {
File src = files[i];
File target = new File(trash, src.getName());
if (!src.renameTo(target))
success = false;
}
return success;
if (!trash.exists()) {
throw new IOException("No trash location found (define fileutils.trash to be the path to the trash)");
}
List failed = new ArrayList();
for (int i=0;i < files.length;i++) {
File src = files[i];
File target = new File(trash, src.getName());
if (!src.renameTo(target)) {
failed.add(src);
}
}
if (failed.size() > 0) {
throw new IOException("The following files could not be trashed: " + failed);
}
return false;
}
}
}
@@ -239,8 +239,6 @@ public class ShapedWindowDemo {
frame.getContentPane().setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
frame.getContentPane().add(face);
frame.setUndecorated(true);
frame.pack();
frame.setLocation(100, 100);
try {
Shape mask = new Area(new Ellipse2D.Float(0, 0, 150, 150));
WindowUtils.setWindowMask(frame, mask);
@@ -249,8 +247,11 @@ public class ShapedWindowDemo {
}
frame.setIconImage(face.getIconImage());
frame.setResizable(false);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocation(100, 100);
frame.setVisible(true);
}
catch(UnsatisfiedLinkError e) {
e.printStackTrace();
+109 -19
Ver Arquivo
@@ -16,6 +16,7 @@ package com.sun.jna.examples;
import java.awt.AlphaComposite;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dialog;
@@ -29,6 +30,10 @@ import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.Toolkit;
import java.awt.event.AWTEventListener;
import java.awt.event.MouseEvent;
import java.awt.AWTEvent;
import java.awt.Window;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
@@ -107,7 +112,15 @@ import com.sun.jna.ptr.PointerByReference;
* Window#paint(Graphics)} on OS X, you'll need to explicitly set the clip
* mask on the <code>Graphics</code> object with the window mask; only the
* content pane of the window and below have the window mask automatically
* applied.
* applied.<p>
* NOTE: On OSX, the property
* <code>apple.awt.draggableWindowBackground</code> is set automatically when
* a window's background color has an alpha component. That property must be
* set to its final value <em>before</em> the heavyweight peer for the Window
* is created. Once {@link Component#addNotify} has been called on the
* component, causing creation of the heavyweight peer, changing this
* property has no effect.
* @see <a href="http://developer.apple.com/technotes/tn2007/tn2196.html#APPLE_AWT_DRAGGABLEWINDOWBACKGROUND">Apple Technote 2007</a>
*/
// TODO: setWindowMask() should accept a threshold; some cases want a
// 50% threshold, some might want zero/non-zero
@@ -162,8 +175,9 @@ public class WindowUtils {
*/
protected static class RepaintTrigger extends JComponent {
protected class Listener extends WindowAdapter implements
ComponentListener, HierarchyListener {
protected class Listener
extends WindowAdapter
implements ComponentListener, HierarchyListener, AWTEventListener {
public void windowOpened(WindowEvent e) {
repaint();
}
@@ -184,6 +198,15 @@ public class WindowUtils {
public void hierarchyChanged(HierarchyEvent e) {
repaint();
}
public void eventDispatched(AWTEvent e) {
Component src = (Component)e.getSource();
MouseEvent me = SwingUtilities.convertMouseEvent(src, (MouseEvent)e, content);
Component c = SwingUtilities.getDeepestComponentAt(content, me.getX(), me.getY());
if (c != null) {
setCursor(c.getCursor());
}
};
}
private final Listener listener = createListener();
@@ -199,9 +222,11 @@ public class WindowUtils {
setSize(getParent().getSize());
w.addComponentListener(listener);
w.addWindowListener(listener);
Toolkit.getDefaultToolkit().addAWTEventListener(listener, AWTEvent.MOUSE_EVENT_MASK|AWTEvent.MOUSE_MOTION_EVENT_MASK);
}
public void removeNotify() {
Toolkit.getDefaultToolkit().removeAWTEventListener(listener);
Window w = SwingUtilities.getWindowAncestor(this);
w.removeComponentListener(listener);
w.removeWindowListener(listener);
@@ -715,9 +740,14 @@ public class WindowUtils {
ByteByReference bref = new ByteByReference();
IntByReference iref = new IntByReference();
byte level = getAlpha(win);
if (user.GetLayeredWindowAttributes(hWnd, null, bref, iref)
&& (iref.getValue() & User32.LWA_ALPHA) != 0) {
level = bref.getValue();
try {
// GetLayeredwindowAttributes supported WinXP and later
if (user.GetLayeredWindowAttributes(hWnd, null, bref, iref)
&& (iref.getValue() & User32.LWA_ALPHA) != 0) {
level = bref.getValue();
}
}
catch(UnsatisfiedLinkError e) {
}
blend.SourceConstantAlpha = level;
blend.AlphaFormat = User32.AC_SRC_ALPHA;
@@ -906,24 +936,52 @@ public class WindowUtils {
return content;
}
/** Note that the property
* <code>apple.awt.draggableWindowBackground</code> must be set to its
* final value <em>before</em> the heavyweight peer for the Window is
* created. Once {@link Component#addNotify} has been called on the
* component, causing creation of the heavyweight peer, changing this
* property has no effect.
* @see <a href="http://developer.apple.com/technotes/tn2007/tn2196.html#APPLE_AWT_DRAGGABLEWINDOWBACKGROUND">Apple Technote 2007</a>
*/
public void setWindowTransparent(Window w, boolean transparent) {
boolean isTransparent = w.getBackground() != null
&& w.getBackground().getAlpha() == 0;
if (transparent != isTransparent) {
installTransparentContent(w);
setBackgroundTransparent(w, transparent);
setBackgroundTransparent(w, transparent, "setWindowTransparent");
setLayersTransparent(w, transparent);
}
}
/** Setting this false restores the original setting. */
private static final String WDRAG = "apple.awt.draggableWindowBackground";
private void fixWindowDragging(Window w, String context) {
if (w instanceof RootPaneContainer) {
JRootPane p = ((RootPaneContainer)w).getRootPane();
Boolean oldDraggable = (Boolean)p.getClientProperty(WDRAG);
if (oldDraggable == null) {
p.putClientProperty(WDRAG, Boolean.FALSE);
if (w.isDisplayable()) {
System.err.println(context + "(): To avoid content dragging, " + context + "() must be called before the window is realized, or " + WDRAG + " must be set to Boolean.FALSE before the window is realized. If you really want content dragging, set " + WDRAG + " on the window's root pane to Boolean.TRUE before calling " + context + "() to hide this message.");
}
}
}
}
/** Note that the property
* <code>apple.awt.draggableWindowBackground</code> must be set to its
* final value <em>before</em> the heavyweight peer for the Window is
* created. Once {@link Component#addNotify} has been called on the
* component, causing creation of the heavyweight peer, changing this
* property has no effect.
* @see <a href="http://developer.apple.com/technotes/tn2007/tn2196.html#APPLE_AWT_DRAGGABLEWINDOWBACKGROUND">Apple Technote 2007</a>
*/
public void setWindowAlpha(final Window w, final float alpha) {
if (w instanceof RootPaneContainer) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JRootPane p = ((RootPaneContainer)w).getRootPane();
p.putClientProperty("Window.alpha", new Float(alpha));
}
});
JRootPane p = ((RootPaneContainer)w).getRootPane();
p.putClientProperty("Window.alpha", new Float(alpha));
fixWindowDragging(w, "setWindowAlpha");
}
whenDisplayable(w, new Runnable() {
public void run() {
@@ -936,7 +994,7 @@ public class WindowUtils {
});
}
catch (Exception e) {
}
}
}
});
}
@@ -956,7 +1014,7 @@ public class WindowUtils {
Window w = (Window)c;
OSXTransparentContent content = installTransparentContent(w);
content.setMask(shape);
setBackgroundTransparent(w, shape != MASK_NONE);
setBackgroundTransparent(w, shape != MASK_NONE, "setWindowMask");
}
else {
// not yet implemented
@@ -998,14 +1056,24 @@ public class WindowUtils {
}
}
private void setBackgroundTransparent(Window w, boolean transparent) {
private void setBackgroundTransparent(Window w, boolean transparent, String context) {
JRootPane rp = w instanceof RootPaneContainer
? ((RootPaneContainer)w).getRootPane() : null;
if (transparent) {
if (rp != null) {
rp.putClientProperty("bg.old", w.getBackground());
}
w.setBackground(new Color(0,0,0,0));
}
else {
// FIXME restore background to original color
w.setBackground(null);
if (rp != null) {
w.setBackground((Color)rp.getClientProperty("bg.old"));
}
else {
w.setBackground(null);
}
}
fixWindowDragging(w, context);
}
}
private static class X11WindowUtils extends NativeWindowUtils {
@@ -1039,6 +1107,14 @@ public class WindowUtils {
rects[i].y = (short)r.y;
rects[i].width = (short)r.width;
rects[i].height = (short)r.height;
// Optimization: write directly to native memory
Pointer p = rects[i].getPointer();
p.setShort(0, (short)r.x);
p.setShort(2, (short)r.y);
p.setShort(4, (short)r.width);
p.setShort(6, (short)r.height);
rects[i].setAutoSynch(false);
// End optimization
}
final int UNMASKED = 1;
x11.XSetForeground(dpy, gc, new NativeLong(UNMASKED));
@@ -1405,7 +1481,14 @@ public class WindowUtils {
* opaque, 0.0 fully transparent. The alpha level is applied equally
* to all window pixels.<p>
* NOTE: Windows requires that <code>sun.java2d.noddraw=true</code>
* in order for alpha to work.
* in order for alpha to work.<p>
* NOTE: On OSX, the property
* <code>apple.awt.draggableWindowBackground</code> must be set to its
* final value <em>before</em> the heavyweight peer for the Window is
* created. Once {@link Component#addNotify} has been called on the
* component, causing creation of the heavyweight peer, changing this
* property has no effect.
* @see <a href="http://developer.apple.com/technotes/tn2007/tn2196.html#APPLE_AWT_DRAGGABLEWINDOWBACKGROUND">Apple Technote 2007</a>
*/
public static void setWindowAlpha(Window w, float alpha) {
getInstance().setWindowAlpha(w, Math.max(0f, Math.min(alpha, 1f)));
@@ -1415,6 +1498,13 @@ public class WindowUtils {
* Set the window to be transparent. Only explicitly painted pixels
* will be non-transparent. All pixels will be composited with
* whatever is under the window using their alpha values.
*
* On OSX, the property <code>apple.awt.draggableWindowBackground</code>
* must be set to its final value <em>before</em> the heavyweight peer for
* the Window is created. Once {@link Component#addNotify} has been
* called on the component, causing creation of the heavyweight peer,
* changing this property has no effect.
* @see <a href="http://developer.apple.com/technotes/tn2007/tn2196.html#APPLE_AWT_DRAGGABLEWINDOWBACKGROUND">Apple Technote 2007</a>
*/
public static void setWindowTransparent(Window w, boolean transparent) {
getInstance().setWindowTransparent(w, transparent);
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+52 -14
Ver Arquivo
@@ -48,6 +48,7 @@ additional JNI or native code.
<li><a href="#invocation-mapping">Invocation Mapping</a>
<li><a href="#global-data">Library Global Data</a>
<li><a href="#crash-protection">VM Crash Protection</a>
<li><a href="#performance">Performance</a>
</ul>
<p>
@@ -65,13 +66,18 @@ public interface CLibrary extends Library {
The <code>String</code> passed to the <code>Native.loadLibrary</code> method
is the undecorated name of the shared library file. Here are some examples of
library name mappings.<p>
<center>
<table style="background-color: #EAEAEA;" width="400">
<style type="text/css">
table.styled { border-collapse:collapse; background-color:#EAEAEA; }
td { padding-left: 10px; padding-right: 10px; }
blockquote { background-color:#EAEAEA; }
</style>
<table border=1 borderColor=white class=styled>
<tr><td><b>OS</b></td><td><b>Library Name</b></td><td><b>String</b></td></tr>
<tr><td>Windows</td><td>user32.dll</td><td>user32</td></tr>
<tr><td>Linux</td><td>libX11.so</td><td>X11</td></tr>
<tr><td>Mac OS X</td><td>libm.dylib</td><td>m</td></tr>
</table></center>
<tr><td>Mac OS X Framework</td><td>/System/Library/Frameworks/Carbon.framework/Carbon</td><td>Carbon</td></tr>
</table>
<p>
Any given native library with a unique filesystem path is represented by a single instance of {@link com.sun.jna.NativeLibrary} and obtained via {@link com.sun.jna.NativeLibrary#getInstance(String)}. The native library will be unloaded when no longer referenced by any Java code.
<p>
@@ -99,7 +105,7 @@ An instance of the {@link com.sun.jna.Function} class is obtained through the {@
<h2>Marshalling/Unmarshalling (Java/Native Type Conversions)</h2>
Java types must be chosen to match native types of the same size. Following are the types supported by the JNA library.<p>
<center>
<table border=1 bordercolor=#CCCCCC style="border-collapse:collapse" width="100%">
<table border=1 borderColor=white class=styled width="100%">
<tr><td><b>Java Type</b></td><td><b>C Type</b></td><td><b>Native Representation</b></td></tr>
<tr><td>boolean</td><td>int</td><td>32-bit integer (customizable)</td>
<tr><td>byte</td><td>char</td><td>8-bit integer</td>
@@ -115,6 +121,8 @@ Java types must be chosen to match native types of the same size. Following are
<tr><td colspan=3>In addition to the above types, which are supported at the native layer, the JNA Java library automatically handles the following types. All but <code>NativeMapped</code> and <code>NativeLong</code> are converted to {@link com.sun.jna.Pointer} before being passed to the native layer.</td></tr>
<tr><td>{@link java.lang.String}</td><td>char*</td><td>NUL-terminated array (native encoding or <code>jna.encoding</code>)</td>
<tr><td>{@link com.sun.jna.WString}</td><td>wchar_t*</td><td>NUL-terminated array (unicode)</td>
<tr><td>{@link java.lang.String String[]}</td><td>char**</td><td>NULL-terminated array of C strings</td>
<tr><td>{@link com.sun.jna.WString WString[]}</td><td>wchar_t**</td><td>NULL-terminated array of wide C strings</td>
<tr><td>{@link com.sun.jna.Structure}</td><td>struct*<br>struct</td><td>pointer to struct (argument or return) ({@link com.sun.jna.Structure.ByReference or explicitly})<br>struct by value (member of struct) ({@link com.sun.jna.Structure.ByValue or explicitly})</td>
<tr><td>{@link com.sun.jna.Union}</td><td>union</td><td>same as <code>Structure</code></td>
<tr><td>{@link com.sun.jna.Structure Structure[]}</td><td>struct[]</td><td>array of structs, contiguous in memory</td>
@@ -129,10 +137,15 @@ Java types must be chosen to match native types of the same size. Following are
<ul>
<li>Unsigned values may be passed by assigning the corresponding
two's-complement representation to the signed type of the same size.
<li>Java arrays of primitive type may be wrapped by {@link java.nio.Buffer} in order to access a subset of the array (changing the effective size and/or offest).
<li>Java arrays of primitive type may be wrapped by {@link java.nio.Buffer} in
order to access a subset of the array (changing the effective size and/or
offest).
<li>Java arrays of primitive type are only valid for use within the scope of a
single call. If the native code keeps a reference to the memory, use {@link
com.sun.jna.Memory} or {@link java.nio.Buffer} instead.
<li>Primitive arrays and structures as members of a structure are overlaid on the parent structure memory.
<li>Bitfields must be manully packed into an integer type.
<li>All other types must eventually be converted to one of these basic types. Methods with arguments or return values of types other than these must either use types deriving from {@link com.sun.jna.NativeMapped} or supply type conversion information for the unsupported types.
<li>All other types must eventually be converted to one of the types in this table. Methods with arguments or return values of types other than these must either use types deriving from {@link com.sun.jna.NativeMapped} or supply type conversion information for the unsupported types.
<li>Type mapping behavior may be customized by providing a {@link com.sun.jna.TypeMapper} for the {@link com.sun.jna.Library#OPTION_TYPE_MAPPER} option when initializing a library interface. See {@link com.sun.jna.win32.W32APITypeMapper} for an example which provides custom conversion of boolean and String types. You are free to use whatever types are convenient in your defined interfaces, but all custom types <em>must</em> provide a mapping to one of the basic or derived types listed above.
<li>Type mapping may also be customized on a per-class basis for user-defined types by making the user-defined type implement the {@link com.sun.jna.NativeMapped} interface.
<li><code>Structure</code> and <code>Union</code> are <em>not</em> converted to <code>Pointer</code> when passed by value.
@@ -198,6 +211,7 @@ the default platform encoding is used, unless the system property
<code>jna.encoding</code> is set to a valid encoding. This property may be
set to "UTF8", for example, to ensure all native strings use that encoding.
<p>
Arrays of <code>String</code> passed to native code (either as a function argument or callback return value) will be converted into a NULL-terminated array of <code>char*</code> (or <code>wchar_t*</code> in the case of an array of <code>WString</code>.
<a name="wide-strings"></a>
<h3>Wide Strings</h3>
@@ -224,8 +238,14 @@ JNA supports supplying Java callbacks to native code. You must define an
interface that extends the {@link com.sun.jna.Callback} interface, and define
a single <code>callback</code> method with a signature that matches the
function pointer required by the native code. The name of the method
<em>must</em> be "callback", and the arguments and return value follow the
same rules as for a direct function invocation.
may be something other than "callback" only if there is only a single method
in the interface which extends Callback or the class which implements
{@link com.sun.jna.Callback}. The arguments and return value follow the same rules
as for a
direct function invocation.
<p>
If the callback returns a <code>String</code> or <code>String[]</code>, the
returned memory will be valid until the returned object is GC'd.
<p>
If your native code initializes function pointers within a struct, JNA will
automatically generate an <code>Callback</code> instance matching the declared
@@ -241,10 +261,10 @@ struct _functions {
// Equivalent JNA mapping
public class Functions extends Structure {
public static interface OpenFunc extends Callback {
int callback(String name, int options);
int invoke(String name, int options);
}
public static interface CloseFunc extends Callback {
int callback(int fd);
int invoke(int fd);
}
public OpenFunc open;
public CloseFunc close;
@@ -252,8 +272,8 @@ public class Functions extends Structure {
...
Functions funcs = new Functions();
lib.init(funcs);
int fd = funcs.open.callback("myfile", 0);
funcs.close.callback(fd);
int fd = funcs.open.invoke("myfile", 0);
funcs.close.invoke(fd);
</pre></code></blockquote>
Callbacks may also be used as return values. Native function pointers are wrapped in a proxy implementing the declared Callback type, to facilitate calling from Java.
@@ -265,7 +285,7 @@ sig_t signal(int signal, sig_t sigfunc);
// Equivalent JNA mapping
public interface CLibrary extends Library {
public interface SignalFunction extends Callback {
void callback(int signal);
void invoke(int signal);
}
SignalFunction signal(int signal, SignalFunction func);
}
@@ -593,7 +613,25 @@ The method {@link com.sun.jna.NativeLibrary#getGlobalVariableAddress} may be use
<a href="#toc">Table of Contents</a>
<a name="crash-protection"></a>
<h2>VM Crash Protection</h2>
It is not uncommon when defining a new library and writing tests to encounter memory access errors which crash the VM. These are often caused by improper mappings or invalid arguments passed to the native library. To generate Java errors instead of crashing the VM, call {@link com.sun.jna.Native#setProtected Native.setProtected(true)}</code>.
It is not uncommon when defining a new library and writing tests to encounter memory access errors which crash the VM. These are often caused by improper mappings or invalid arguments passed to the native library. To generate Java errors instead of crashing the VM, call {@link com.sun.jna.Native#setProtected Native.setProtected(true)}</code>. Not all platforms support this protection; if not, the value of {@link com.sun.jna.Native#isProtected} will remain <code>false</code>.
<p>
<a href="#toc">Table of Contents</a>
<a name="performance"></a>
<h2>Performance</h2>
<h3>Pointer/Array/Buffer Variants</h3>
Java primitive arrays are generally slower to use than memory
(Pointer, Memory, or ByReference) or NIO buffers, since the Java memory has to
be pinned and possibly copied across the native call, since the Java array is not necessarily contiguously allocated.
<h3>Large Structures</h3>
Structures are normally written to native memory before and read back from
native memory after a function call. With very large structures, there can be
a performance hit using reflection to walk through all the fields. Structure
auto-synch can be disabled by calling
{@link com.sun.jna.Structure#setAutoSynch} with a <code>false</code> parameter.
It is then up to you to use {@link com.sun.jna.Structure#readField(String)}
and {@link com.sun.jna.Structure#writeField(String)}/{@link
com.sun.jna.Structure#writeField(String,Object)} to synch with just the fields
of interest.
</body>
</html>
@@ -277,9 +277,9 @@ public class ArgumentsMarshalTest extends TestCase {
// ensure that even if the argument is ByValue, it's passed as ptr
struct = new TestLibrary.CheckFieldAlignment.ByValue();
assertEquals("Structure argument should be passed according to method "
+ "parameter type, not argument type",
struct.getPointer(),
lib.testStructurePointerArgument(struct));
+ "parameter type, not argument type",
struct.getPointer(),
lib.testStructurePointerArgument(struct));
}
public void testStructureByValueArgument() {
@@ -356,7 +356,7 @@ public class ArgumentsMarshalTest extends TestCase {
public void testByteArrayArgument() {
byte[] buf = new byte[1024];
final byte MAGIC = (byte)0xED;
assertEquals("Wrong return value", buf.length, +
assertEquals("Wrong return value", buf.length,
lib.fillInt8Buffer(buf, buf.length, MAGIC));
for (int i=0;i < buf.length;i++) {
assertEquals("Bad value at index " + i, MAGIC, buf[i]);
@@ -366,7 +366,7 @@ public class ArgumentsMarshalTest extends TestCase {
public void testShortArrayArgument() {
short[] buf = new short[1024];
final short MAGIC = (short)0xABED;
assertEquals("Wrong return value", buf.length, +
assertEquals("Wrong return value", buf.length,
lib.fillInt16Buffer(buf, buf.length, MAGIC));
for (int i=0;i < buf.length;i++) {
assertEquals("Bad value at index " + i, MAGIC, buf[i]);
@@ -376,7 +376,7 @@ public class ArgumentsMarshalTest extends TestCase {
public void testIntArrayArgument() {
int[] buf = new int[1024];
final int MAGIC = 0xABEDCF23;
assertEquals("Wrong return value", buf.length, +
assertEquals("Wrong return value", buf.length,
lib.fillInt32Buffer(buf, buf.length, MAGIC));
for (int i=0;i < buf.length;i++) {
assertEquals("Bad value at index " + i, MAGIC, buf[i]);
@@ -386,7 +386,7 @@ public class ArgumentsMarshalTest extends TestCase {
public void testLongArrayArgument() {
long[] buf = new long[1024];
final long MAGIC = 0x1234567887654321L;
assertEquals("Wrong return value", buf.length, +
assertEquals("Wrong return value", buf.length,
lib.fillInt64Buffer(buf, buf.length, MAGIC));
for (int i=0;i < buf.length;i++) {
assertEquals("Bad value at index " + i, MAGIC, buf[i]);
+160 -1
Ver Arquivo
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2007-2008 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
@@ -12,6 +12,7 @@
*/
package com.sun.jna;
import java.util.HashMap;
import java.util.Map;
import com.sun.jna.CallbacksTest.TestLibrary.CbCallback;
@@ -47,6 +48,14 @@ public class CallbacksTest extends TestCase {
void callback();
}
void callVoidCallback(VoidCallback c);
interface VoidCallbackCustom extends Callback {
void customMethodName();
}
abstract class VoidCallbackCustomAbstract implements VoidCallbackCustom {
public void customMethodName() { }
}
class VoidCallbackCustomDerived extends VoidCallbackCustomAbstract { }
void callVoidCallback(VoidCallbackCustom c);
interface BooleanCallback extends Callback {
boolean callback(boolean arg, boolean arg2);
}
@@ -94,12 +103,22 @@ public class CallbacksTest extends TestCase {
interface CopyArgToByReference extends Callback {
int callback(int arg, IntByReference result);
}
interface StringArrayCallback extends Callback {
String[] callback(String[] arg);
}
Pointer callStringArrayCallback(StringArrayCallback c, String[] arg);
int callCallbackWithByReferenceArgument(CopyArgToByReference cb, int arg, IntByReference result);
TestStructure.ByValue callCallbackWithStructByValue(TestStructure.TestCallback callback, TestStructure.ByValue cbstruct);
interface CbCallback extends Callback {
CbCallback callback(CbCallback arg);
}
CbCallback callCallbackWithCallback(CbCallback cb);
public interface Int32CallbackX extends Callback {
public int callback(int arg);
}
Int32CallbackX returnCallback();
Int32CallbackX returnCallbackArgument(Int32CallbackX cb);
}
TestLibrary lib;
@@ -146,6 +165,17 @@ public class CallbacksTest extends TestCase {
assertEquals("Callback trampoline not freed", 0, cbstruct.peer);
}
public void testFindCallbackInterface() {
TestLibrary.Int32Callback cb = new TestLibrary.Int32Callback() {
public int callback(int arg, int arg2) {
return arg + arg2;
}
};
assertEquals("Wrong callback interface",
TestLibrary.Int32Callback.class,
Native.findCallbackClass(cb.getClass()));
}
public void testCallInt32Callback() {
final int MAGIC = 0x11111111;
final boolean[] called = { false };
@@ -406,6 +436,24 @@ public class CallbacksTest extends TestCase {
assertEquals("Wrong wide string return", VALUE, value);
}
public void testCallStringArrayCallback() {
final boolean[] called = {false};
final String[][] cbargs = { null };
TestLibrary.StringArrayCallback cb = new TestLibrary.StringArrayCallback() {
public String[] callback(String[] arg) {
called[0] = true;
cbargs[0] = arg;
return arg;
}
};
final String[] VALUE = { "value", null };
Pointer value = lib.callStringArrayCallback(cb, VALUE);
assertTrue("Callback not called", called[0]);
assertEquals("Wrong callback argument 1", VALUE[0], cbargs[0][0]);
String[] result = value.getStringArray(0);
assertEquals("Wrong String return", VALUE[0], result[0]);
}
public void testCallCallbackWithByReferenceArgument() {
final boolean[] called = {false};
TestLibrary.CopyArgToByReference cb = new TestLibrary.CopyArgToByReference() {
@@ -427,6 +475,7 @@ public class CallbacksTest extends TestCase {
final TestStructure innerResult = new TestStructure();
TestStructure.TestCallback cb = new TestStructure.TestCallback() {
public TestStructure.ByValue callback(TestStructure.ByValue s) {
// Copy the argument value for later comparison
Pointer old = innerResult.getPointer();
innerResult.useMemory(s.getPointer());
innerResult.read();
@@ -456,6 +505,116 @@ public class CallbacksTest extends TestCase {
assertEquals("Callback reference should be reused", cb, cb2);
}
public static interface CallbackTestLibrary extends Library {
interface Int32Callback extends Callback {
float callback(float arg, float arg2);
}
float callInt32Callback(Int32Callback c, float arg, float arg2);
}
public void testCallbackTypeMappingFromLibrary() throws Exception {
final DefaultTypeMapper mapper = new DefaultTypeMapper();
Map options = new HashMap() {
{ put(Library.OPTION_TYPE_MAPPER, mapper); }
};
CallbackTestLibrary lib = (CallbackTestLibrary)
Native.loadLibrary("testlib", CallbackTestLibrary.class, options);
// Convert java floats into native integers and back
TypeConverter converter = new TypeConverter() {
public Object fromNative(Object value, FromNativeContext context) {
return new Float(((Integer)value).intValue());
}
public Class nativeType() {
return Integer.class;
}
public Object toNative(Object value, ToNativeContext ctx) {
return new Integer(Math.round(((Float)value).floatValue()));
}
};
mapper.addTypeConverter(float.class, converter);
CallbackTestLibrary.Int32Callback cb = new CallbackTestLibrary.Int32Callback() {
public float callback(float arg, float arg2) {
return arg + arg2;
}
};
assertEquals("Wrong type mapper for callback class", mapper,
Native.getTypeMapper(CallbackTestLibrary.Int32Callback.class));
assertEquals("Wrong type mapper for callback object", mapper,
Native.getTypeMapper(cb.getClass()));
assertEquals("Wrong type mapper used in callback invocation",
-2, lib.callInt32Callback(cb, -1, -1), 0);
}
private static class TestCallback implements Callback {
public static final TypeMapper TYPE_MAPPER = new DefaultTypeMapper();
public void callback() { }
}
public void testCallbackTypeMappingFromCallback() throws Exception {
assertEquals("Wrong type mapper for callback class",
TestCallback.TYPE_MAPPER,
Native.getTypeMapper(TestCallback.class));
}
public void testInvokeCallback() {
TestLibrary lib = (TestLibrary)
Native.loadLibrary("testlib", TestLibrary.class);
TestLibrary.Int32CallbackX cb = lib.returnCallback();
assertNotNull("Callback should not be null", cb);
assertEquals("Callback should be callable", 1, cb.callback(1));
TestLibrary.Int32CallbackX cb2 = new TestLibrary.Int32CallbackX() {
public int callback(int arg) {
return 0;
}
};
assertSame("Java callback should be looked up",
cb2, lib.returnCallbackArgument(cb2));
assertSame("Existing native function wrapper should be reused",
cb, lib.returnCallbackArgument(cb));
}
static class CbStruct extends Structure {
public Callback cb;
}
interface CbTest extends Library {
public void callCallbackInStruct(CbStruct cbstruct);
}
public void testCallCallbackInStructure() {
final boolean[] flag = {false};
final CbStruct s = new CbStruct();
s.cb = new Callback() {
public void callback() {
flag[0] = true;
}
};
CbTest lib = (CbTest)Native.loadLibrary("testlib", CbTest.class);
lib.callCallbackInStruct(s);
assertTrue("Callback not invoked", flag[0]);
}
public void testCustomCallbackMethodName() {
final boolean[] called = {false};
TestLibrary.VoidCallbackCustom cb = new TestLibrary.VoidCallbackCustom() {
public void customMethodName() {
called[0] = true;
}
public String toString() {
return "Some debug output";
}
};
lib.callVoidCallback(cb);
assertTrue("Callback with custom method name not called", called[0]);
}
public void testCustomCallbackVariedInheritance() {
final boolean[] called = {false};
TestLibrary.VoidCallbackCustom cb =
new TestLibrary.VoidCallbackCustomDerived();
lib.callVoidCallback(cb);
}
public static void main(java.lang.String[] argList) {
junit.textui.TestRunner.run(CallbacksTest.class);
}
@@ -58,6 +58,12 @@ public class IntegerTypeTest extends TestCase {
}
}
}
public void testInitialValue() {
long VALUE = 20;
NativeLong nl = new NativeLong(VALUE);
assertEquals("Wrong initial value", VALUE, nl.longValue());
}
public static void main(String[] args) {
junit.textui.TestRunner.run(IntegerTypeTest.class);
+5 -3
Ver Arquivo
@@ -21,12 +21,14 @@ import junit.framework.TestCase;
public class JNAUnloadTest extends TestCase {
private static final String BUILDDIR =
System.getProperty("jna.builddir", "build"
+ (Native.POINTER_SIZE == 8 ? "-d64" : ""));
private static class TestLoader extends URLClassLoader {
public TestLoader() throws MalformedURLException {
super(new URL[] {
// use "build-d64" for 64-bit jvm's
new File("build" + System.getProperty(LibraryLoadTest.DIR_BUILD_SUFFIX, "")
+ "/classes").toURI().toURL(),
new File(BUILDDIR + "/classes").toURI().toURL(),
}, null);
}
}
+21 -6
Ver Arquivo
@@ -24,6 +24,10 @@ import junit.framework.TestCase;
public class LibraryLoadTest extends TestCase {
private static final String BUILDDIR =
System.getProperty("jna.builddir", "build"
+ (Native.POINTER_SIZE == 8 ? "-d64" : ""));
public void testLoadJNALibrary() {
assertTrue("Point size should never be zero", Pointer.SIZE > 0);
}
@@ -81,15 +85,10 @@ public class LibraryLoadTest extends TestCase {
}
}
/** System property name (set by Ant) when running with 64-bit JVM. */
static final String DIR_BUILD_SUFFIX = "dir.build.suffix";
public void testLoadLibraryWithUnicodeName() throws Exception {
String tmp = System.getProperty("java.io.tmpdir");
String libName = System.mapLibraryName("jnidispatch");
// use "build-d64" for 64-bit jvm's
File src = new File("build" + System.getProperty(DIR_BUILD_SUFFIX, "")
+ "/native", libName);
File src = new File(BUILDDIR + "/native", libName);
String newLibName = UNICODE;
if (libName.startsWith("lib"))
newLibName = "lib" + newLibName;
@@ -124,6 +123,22 @@ public class LibraryLoadTest extends TestCase {
}
}
public interface TestLib2 extends Library {
int dependentReturnFalse();
}
public void testLoadDependentLibrary() {
try {
TestLib2 lib = (TestLib2)Native.loadLibrary("testlib2", TestLib2.class);
lib.dependentReturnFalse();
}
catch(UnsatisfiedLinkError e) {
// failure expected on anything but windows
if (Platform.isWindows()) {
fail("Failed to load dependent libraries: " + e);
}
}
}
public static void main(String[] args) {
junit.textui.TestRunner.run(LibraryLoadTest.class);
}
+19 -8
Ver Arquivo
@@ -84,21 +84,32 @@ public class NativeTest extends TestCase {
}
public void testSynchronizedAccess() throws Exception {
final boolean[] lockHeld = { false };
TestLib base = (TestLib)Native.loadLibrary("testlib", TestLib.class);
final TestLib lib = (TestLib)Native.synchronizedLibrary(base);
final NativeLibrary nlib = NativeLibrary.getInstance("testlib");
final TestLib lib = (TestLib)Native.loadLibrary("testlib", TestLib.class);
final TestLib synchlib = (TestLib)Native.synchronizedLibrary(lib);
final TestLib.VoidCallback cb = new TestLib.VoidCallback() {
public void callback() {
lockHeld[0] = Thread.holdsLock(NativeLibrary.getInstance("testlib"));
lockHeld[0] = Thread.holdsLock(nlib);
}
};
Thread t1 = new Thread() {
Thread t0 = new Thread() {
public void run() {
lib.callVoidCallback(cb);
}
};
t0.start();
t0.join();
assertFalse("NativeLibrary lock should not be held during native call to normal library",
lockHeld[0]);
Thread t1 = new Thread() {
public void run() {
synchlib.callVoidCallback(cb);
}
};
t1.start();
t1.join();
assertTrue("NativeLibrary lock should be held during native call",
assertTrue("NativeLibrary lock should be held during native call to synchronized library",
lockHeld[0]);
}
@@ -115,11 +126,11 @@ public class NativeTest extends TestCase {
Class subClass = TestInterface.InnerTestClass.InnerSubclass.class;
Class callbackClass = TestInterface.InnerTestClass.TestCallback.class;
assertEquals("Enclosing interface not found for class",
interfaceClass, Native.findLibraryClass(cls));
interfaceClass, Native.findEnclosingLibraryClass(cls));
assertEquals("Enclosing interface not found for derived class",
interfaceClass, Native.findLibraryClass(subClass));
interfaceClass, Native.findEnclosingLibraryClass(subClass));
assertEquals("Enclosing interface not found for callback",
interfaceClass, Native.findLibraryClass(callbackClass));
interfaceClass, Native.findEnclosingLibraryClass(callbackClass));
}
public interface TestInterfaceWithInstance extends Library {
+34 -21
Ver Arquivo
@@ -67,11 +67,10 @@ public class ReturnTypesTest extends TestCase {
SimpleStructure returnStaticTestStructure();
SimpleStructure returnNullTestStructure();
TestStructure.ByValue returnStructureByValue();
public interface Int32Callback extends Callback {
public int callback(int arg);
}
Int32Callback returnCallback();
Int32Callback returnCallbackArgument(Int32Callback cb);
Pointer[] returnPointerArgument(Pointer[] arg);
String[] returnPointerArgument(String[] arg);
WString[] returnPointerArgument(WString[] arg);
}
TestLibrary lib;
@@ -194,22 +193,6 @@ public class ReturnTypesTest extends TestCase {
assertNull("Expect null structure return", s);
}
public void testInvokeCallback() {
TestLibrary.Int32Callback cb = lib.returnCallback();
assertNotNull("Callback should not be null", cb);
assertEquals("Callback should be callable", 1, cb.callback(1));
TestLibrary.Int32Callback cb2 = new TestLibrary.Int32Callback() {
public int callback(int arg) {
return 0;
}
};
assertSame("Java callback should be looked up",
cb2, lib.returnCallbackArgument(cb2));
assertSame("Existing native function wrapper should be reused",
cb, lib.returnCallbackArgument(cb));
}
public void testReturnStructureByValue() {
TestStructure s = lib.returnStructureByValue();
assertNotNull("Returned structure must not be null", s);
@@ -222,6 +205,36 @@ public class ReturnTypesTest extends TestCase {
assertEquals("Wrong inner structure value", 5, s.inner.value, 0);
}
public void testReturnPointerArray() {
Pointer value = new Memory(10);
Pointer[] input = {
value, null,
};
Pointer[] result = lib.returnPointerArgument(input);
assertEquals("Wrong array length", input.length-1, result.length);
assertEquals("Wrong array element value", value, result[0]);
}
public void testReturnStringArray() {
String value = getName();
String[] input = {
value, null,
};
String[] result = lib.returnPointerArgument(input);
assertEquals("Wrong array length", input.length-1, result.length);
assertEquals("Wrong array element value", value, result[0]);
}
public void testReturnWStringArray() {
WString value = new WString(getName());
WString[] input = {
value, null,
};
WString[] result = lib.returnPointerArgument(input);
assertEquals("Wrong array length", input.length-1, result.length);
assertEquals("Wrong array element value", value, result[0]);
}
public static void main(java.lang.String[] argList) {
junit.textui.TestRunner.run(ReturnTypesTest.class);
}
+107
Ver Arquivo
@@ -0,0 +1,107 @@
/* Copyright (c) 2007 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;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.util.Map;
import junit.framework.TestCase;
/** General structure by value functionality tests. */
public class StructureByValueTest extends TestCase {
public static void main(java.lang.String[] argList) {
junit.textui.TestRunner.run(StructureByValueTest.class);
}
public static class TestNativeMappedInStructure extends Structure {
public static class ByValue extends TestNativeMappedInStructure implements Structure.ByValue { }
public NativeLong field;
}
public void testNativeMappedInByValue() {
new TestNativeMappedInStructure.ByValue();
}
public interface TestLibrary extends Library {
byte testStructureByValueArgument8(ByValue8 arg);
short testStructureByValueArgument16(ByValue16 arg);
int testStructureByValueArgument32(ByValue32 arg);
long testStructureByValueArgument64(ByValue64 arg);
long testStructureByValueArgument128(ByValue128 arg);
}
TestLibrary lib;
protected void setUp() {
lib = (TestLibrary)Native.loadLibrary("testlib", TestLibrary.class);
}
protected void tearDown() {
lib = null;
}
public static class ByValueStruct extends Structure implements Structure.ByValue { }
public static class ByValue8 extends ByValueStruct {
public byte data;
}
public static class ByValue16 extends ByValueStruct {
public short data;
}
public static class ByValue32 extends ByValueStruct {
public int data;
}
public static class ByValue64 extends ByValueStruct {
public long data;
}
public static class ByValue128 extends ByValueStruct {
public long data, data1;
}
final long MAGIC = 0x0123456789ABCDEFL;
public void testStructureArgByValue8() {
ByValue8 data = new ByValue8();
final byte DATA = (byte)MAGIC;
data.data = DATA;
assertEquals("Failed to pass 8-bit struct by value",
DATA, lib.testStructureByValueArgument8(data));
}
public void testStructureArgByValue16() {
ByValue16 data = new ByValue16();
final short DATA = (short)MAGIC;
data.data = DATA;
assertEquals("Failed to pass 16-bit struct by value",
DATA, lib.testStructureByValueArgument16(data));
}
public void testStructureArgByValue32() {
ByValue32 data = new ByValue32();
final int DATA = (int)MAGIC;
data.data = DATA;
assertEquals("Failed to pass 32-bit struct by value",
DATA, lib.testStructureByValueArgument32(data));
}
public void testStructureArgByValue64() {
ByValue64 data = new ByValue64();
final long DATA = (long)MAGIC;
data.data = DATA;
assertEquals("Failed to pass 64-bit struct by value",
DATA, lib.testStructureByValueArgument64(data));
}
public void testStructureArgByValue128() {
ByValue128 data = new ByValue128();
final long DATA = (long)MAGIC;
data.data = DATA;
data.data1 = DATA;
assertEquals("Failed to pass 128-bit struct by value",
2*DATA, lib.testStructureByValueArgument128(data));
}
}
+131 -25
Ver Arquivo
@@ -419,7 +419,7 @@ public class StructureTest extends TestCase {
public Function cb;
}
try {
BadFieldStructure s = new BadFieldStructure();
new BadFieldStructure().size();
fail("Function fields should not be allowed");
}
catch(IllegalArgumentException e) {
@@ -445,7 +445,6 @@ public class StructureTest extends TestCase {
public TestCallback cb;
}
static interface CbTest extends Library {
public void callCallbackInStruct(CbStruct cbstruct);
public void setCallbackInStruct(CbStruct2 cbstruct);
}
public void testCallbackWrite() {
@@ -463,19 +462,6 @@ public class StructureTest extends TestCase {
assertEquals("Wrong trampoline", ref.getTrampoline(), func);
}
public void testCallCallbackInStructure() {
final boolean[] flag = {false};
final CbStruct s = new CbStruct();
s.cb = new Callback() {
public void callback() {
flag[0] = true;
}
};
CbTest lib = (CbTest)Native.loadLibrary("testlib", CbTest.class);
lib.callCallbackInStruct(s);
assertTrue("Callback not invoked", flag[0]);
}
public void testReadFunctionPointerAsCallback() {
CbStruct2 s = new CbStruct2();
CbTest lib = (CbTest)Native.loadLibrary("testlib", CbTest.class);
@@ -543,8 +529,8 @@ public class StructureTest extends TestCase {
}
}
try {
new BufferStructure(new byte[1024]);
fail("Buffer fields should fail immediately");
new BufferStructure(new byte[1024]).size();
fail("Buffer fields should not be allowed");
}
catch(IllegalArgumentException e) {
}
@@ -600,6 +586,21 @@ public class StructureTest extends TestCase {
assertTrue("Read should preserve structure memory",
inner.getPointer() instanceof Memory);
}
public static class TestPointer extends PointerType { }
public void testPreservePointerFields() {
class TestStructure extends Structure {
public Pointer p = new Memory(256);
public TestPointer p2 = new TestPointer() {
{ setPointer(new Memory(256)); }
};
}
TestStructure s = new TestStructure();
final Pointer p = s.p;
s.write();
s.read();
assertSame("Should preserve Pointer references if peer unchanged", p, s.p);
}
public void testOverwriteStructureByReferenceFieldOnRead() {
StructureWithPointers s = new StructureWithPointers();
@@ -756,14 +757,6 @@ public class StructureTest extends TestCase {
s.write();
}
public static class TestNativeMappedInStructure extends Structure {
public static class ByValue extends TestNativeMappedInStructure implements Structure.ByValue { }
public NativeLong field;
}
public void testNativeMappedInByValue() {
new TestNativeMappedInStructure.ByValue();
}
public static class ROStructure extends Structure {
public final int field;
{
@@ -802,4 +795,117 @@ public class StructureTest extends TestCase {
i, s.longs[i].intValue());
}
}
public void testInitializeNativeMappedField() {
final long VALUE = 20;
final NativeLong INITIAL = new NativeLong(VALUE);
class TestStructure extends Structure {
// field overwritten, wrong value before write
// NL bug, wrong value written
{ setAlignType(ALIGN_NONE); }
public NativeLong nl = INITIAL;
public NativeLong uninitialized;
}
TestStructure ts = new TestStructure();
assertEquals("Wrong value in field", VALUE, ts.nl.longValue());
assertSame("Initial value overwritten", INITIAL, ts.nl);
assertEquals("Wrong field value before write", VALUE, ts.nl.longValue());
assertNotNull("Uninitialized field should be initialized", ts.uninitialized);
assertEquals("Wrong initialized value", 0, ts.uninitialized.longValue());
ts.write();
assertEquals("Wrong field value written", VALUE, ts.getPointer().getNativeLong(0).longValue());
assertEquals("Wrong field value written (2)", 0, ts.getPointer().getNativeLong(NativeLong.SIZE).longValue());
ts.read();
assertEquals("Wrong field value", VALUE, ts.nl.longValue());
assertEquals("Wrong field value (2)", 0, ts.uninitialized.longValue());
}
public void testStructureFieldOrder() {
Structure.REQUIRES_FIELD_ORDER = true;
try {
class TestStructure extends Structure {
public int one = 1;
public int three = 3;
public int two = 2;
{
setFieldOrder(new String[] { "one", "two", "three" });
}
}
class DerivedTestStructure extends TestStructure {
public int four = 4;
{
setFieldOrder(new String[] { "four" });
}
}
DerivedTestStructure s = new DerivedTestStructure();
DerivedTestStructure s2 = new DerivedTestStructure();
s.write();
s2.write();
assertEquals("Wrong first field", 1, s.getPointer().getInt(0));
assertEquals("Wrong second field", 2, s.getPointer().getInt(4));
assertEquals("Wrong third field", 3, s.getPointer().getInt(8));
assertEquals("Wrong derived field", 4, s.getPointer().getInt(12));
}
finally {
Structure.REQUIRES_FIELD_ORDER = false;
}
}
public void testCustomTypeMapper() {
class TestField { }
class TestStructure extends Structure {
public TestField field;
public TestStructure() {
DefaultTypeMapper m = new DefaultTypeMapper();
m.addTypeConverter(TestField.class, new TypeConverter() {
public Object fromNative(Object value, FromNativeContext context) {
return new TestField();
}
public Class nativeType() {
return String.class;
}
public Object toNative(Object value, ToNativeContext ctx) {
return value == null ? null : value.toString();
}
});
setTypeMapper(new DefaultTypeMapper());
}
}
new TestStructure();
}
public void testWriteWithNullBoxedPrimitives() {
class TestStructure extends Structure {
public Boolean zfield;
public Integer field;
}
TestStructure s = new TestStructure();
s.write();
s.read();
assertNotNull("Field should not be null after read", s.field);
}
public interface AutoSynchTest extends Library {
public static class TestStructure extends Structure {
public int field;
}
Pointer testStructurePointerArgument(TestStructure s);
}
public void testDisableAutoSynch() {
AutoSynchTest lib = (AutoSynchTest)Native.loadLibrary("testlib", AutoSynchTest.class);
AutoSynchTest.TestStructure s = new AutoSynchTest.TestStructure();
final int VALUE = 42;
s.field = VALUE;
s.setAutoWrite(false);
lib.testStructurePointerArgument(s);
assertEquals("Auto write should be disabled", 0, s.field);
final int EXPECTED = s.field;
s.getPointer().setInt(0, VALUE);
s.setAutoRead(false);
lib.testStructurePointerArgument(s);
assertEquals("Auto read should be disabled", EXPECTED, s.field);
}
}
-37
Ver Arquivo
@@ -173,43 +173,6 @@ public class TypeMapperTest extends TestCase {
assertFalse("Wrong value read", s.data);
}
public static interface CallbackTestLibrary extends Library {
interface Int32Callback extends Callback {
float callback(float arg, float arg2);
}
float callInt32Callback(Int32Callback c, float arg, float arg2);
}
public void testCallbackTypeMapping() throws Exception {
final DefaultTypeMapper mapper = new DefaultTypeMapper();
Map options = new HashMap() {
{ put(Library.OPTION_TYPE_MAPPER, mapper); }
};
CallbackTestLibrary lib = (CallbackTestLibrary)
Native.loadLibrary("testlib", CallbackTestLibrary.class, options);
// Convert java floats into native integers and back
TypeConverter converter = new TypeConverter() {
public Object fromNative(Object value, FromNativeContext context) {
return new Float(((Integer)value).intValue());
}
public Class nativeType() {
return Integer.class;
}
public Object toNative(Object value, ToNativeContext ctx) {
return new Integer(Math.round(((Float)value).floatValue()));
}
};
mapper.addTypeConverter(float.class, converter);
CallbackTestLibrary.Int32Callback cb = new CallbackTestLibrary.Int32Callback() {
public float callback(float arg, float arg2) {
return arg + arg2;
}
};
assertEquals("Wrong result", 0, lib.callInt32Callback(cb, 0, 0), 0);
assertEquals("Wrong result", 1, lib.callInt32Callback(cb, 0, 1), 0);
assertEquals("Wrong result", 2, lib.callInt32Callback(cb, 1, 1), 0);
assertEquals("Wrong result", -2, lib.callInt32Callback(cb, -1, -1), 0);
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public static @interface FooBoolean {}
+50
Ver Arquivo
@@ -20,6 +20,16 @@ public class UnionTest extends TestCase {
public String value;
}
public static class IntStructure extends Structure {
public int value;
}
public static class SubIntStructure extends IntStructure {}
public static interface Func1 extends Callback {
public void callback();
}
public static class SizedUnion extends Union {
public byte byteField;
public short shortField;
@@ -31,6 +41,13 @@ public class UnionTest extends TestCase {
public Pointer pointer;
}
public static class StructUnion extends Union {
public int intField;
public TestStructure testStruct;
public IntStructure intStruct;
public Func1 func1;
}
public void testCalculateSize() {
Union u = new SizedUnion();
assertEquals("Union should be size of largest field", 8, u.size());
@@ -60,6 +77,39 @@ public class UnionTest extends TestCase {
assertNull("Unselected WString should be null", u.wstring);
}
public void testWriteTypedUnion() {
final int VALUE = 0x12345678;
// write an instance of a direct union class to memory
StructUnion u = new StructUnion();
IntStructure intStruct = new IntStructure();
intStruct.value = VALUE;
u.setTypedValue(intStruct);
u.write();
assertEquals("Wrong value written", VALUE, u.getPointer().getInt(0));
// write an instance of a sub class of an union class to memory
u = new StructUnion();
SubIntStructure subIntStructure = new SubIntStructure();
subIntStructure.value = VALUE;
u.setTypedValue(subIntStructure);
u.write();
assertEquals("Wrong value written", VALUE, u.getPointer().getInt(0));
// write an instance of an interface
u = new StructUnion();
Func1 func1 = new Func1() {
public void callback() {
System.out.println("hi");
}
};
u.setTypedValue(func1);
}
public void testReadTypedUnion() {
StructUnion u = new StructUnion();
final int VALUE = 0x12345678;
u.getPointer().setInt(0, VALUE);
assertEquals("int structure not read properly", VALUE, ((IntStructure) u.getTypedValue(IntStructure.class)).value);
}
public void testReadTypeInfo() {
SizedUnion u = new SizedUnion();
assertEquals("Type should be that of longest field if no field active",
@@ -13,6 +13,7 @@
package com.sun.jna.examples;
import java.io.File;
import java.io.IOException;
import junit.framework.TestCase;
public class FileUtilsTest extends TestCase {
@@ -26,7 +27,12 @@ public class FileUtilsTest extends TestCase {
File file = File.createTempFile(getName(), ".tmp", home);
try {
assertTrue("File should exist", file.exists());
assertTrue("Move to trash failed", utils.moveToTrash(new File[] { file }));
try {
utils.moveToTrash(new File[] { file });
}
catch(IOException e) {
fail(e.toString());
}
assertFalse("Failed to move " + file + " to trash", file.exists());
}
finally {
@@ -12,12 +12,19 @@
*/
package com.sun.jna.examples.win32;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import junit.framework.TestCase;
public class Shell32Test extends TestCase {
public static void main(String[] args) {
junit.textui.TestRunner.run(Shell32Test.class);
}
public void testStructurePacking() {
Structure s = new Shell32.SHFILEOPSTRUCT();
assertEquals("Wrong structure size", 30, s.size());
final int SIZE = Pointer.SIZE * 5 + 10; // 5 pointers, 2 ints, 1 short
assertEquals("Wrong structure size", SIZE, s.size());
}
}
@@ -14,6 +14,7 @@ package com.sun.jna.win32;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.examples.win32.W32API;
import junit.framework.TestCase;
@@ -22,6 +23,10 @@ public class W32APIMapperTest extends TestCase {
final String MAGIC = "magic";
public static void main(String[] args) {
junit.textui.TestRunner.run(W32APIMapperTest.class);
}
public interface UnicodeLibrary extends Library {
public static class TestStructure extends Structure {
public String string;
@@ -89,40 +94,42 @@ public class W32APIMapperTest extends TestCase {
public void testUnicodeStructureSize() {
UnicodeLibrary.TestStructure s = new UnicodeLibrary.TestStructure();
assertEquals("Wrong structure size", 16, s.size());
assertEquals("Wrong structure size",
Pointer.SIZE*2+8, s.size());
}
public void testASCIIStructureSize() {
ASCIILibrary.TestStructure s = new ASCIILibrary.TestStructure();
assertEquals("Wrong structure size", 16, s.size());
assertEquals("Wrong structure size",
Pointer.SIZE*2+8, s.size());
}
public void testUnicodeStructureWriteBoolean() {
UnicodeLibrary.TestStructure s = new UnicodeLibrary.TestStructure();
s.bool2 = true;
s.write();
assertEquals("Wrong value written for FALSE", 0, s.getPointer().getInt(8));
assertEquals("Wrong value written for TRUE", 1, s.getPointer().getInt(12));
assertEquals("Wrong value written for FALSE", 0, s.getPointer().getInt(Pointer.SIZE*2));
assertEquals("Wrong value written for TRUE", 1, s.getPointer().getInt(Pointer.SIZE*2+4));
}
public void testASCIIStructureWriteBoolean() {
ASCIILibrary.TestStructure s = new ASCIILibrary.TestStructure();
s.bool2 = true;
s.write();
assertEquals("Wrong value written for FALSE", 0, s.getPointer().getInt(8));
assertEquals("Wrong value written for TRUE", 1, s.getPointer().getInt(12));
assertEquals("Wrong value written for FALSE", 0, s.getPointer().getInt(Pointer.SIZE*2));
assertEquals("Wrong value written for TRUE", 1, s.getPointer().getInt(Pointer.SIZE*2+4));
}
public void testUnicodeStructureReadBoolean() {
UnicodeLibrary.TestStructure s = new UnicodeLibrary.TestStructure();
s.getPointer().setInt(8, 1);
s.getPointer().setInt(12, 0);
s.getPointer().setInt(Pointer.SIZE*2, 1);
s.getPointer().setInt(Pointer.SIZE*2+4, 0);
s.read();
assertTrue("Wrong value read for TRUE", s.bool);
assertFalse("Wrong value read for FALSE", s.bool2);
}
public void testASCIIStructureReadBoolean() {
ASCIILibrary.TestStructure s = new ASCIILibrary.TestStructure();
s.getPointer().setInt(8, 1);
s.getPointer().setInt(12, 0);
s.getPointer().setInt(Pointer.SIZE*2, 1);
s.getPointer().setInt(Pointer.SIZE*2+4, 0);
s.read();
assertTrue("Wrong value read for TRUE", s.bool);
assertFalse("Wrong value read for FALSE", s.bool2);
@@ -133,7 +140,7 @@ public class W32APIMapperTest extends TestCase {
s.string2 = MAGIC;
s.write();
assertEquals("Improper null write", null, s.getPointer().getPointer(0));
assertEquals("Improper string write", MAGIC, s.getPointer().getPointer(4).getString(0, true));
assertEquals("Improper string write", MAGIC, s.getPointer().getPointer(Pointer.SIZE).getString(0, true));
}
public void testASCIIStructureWriteString() {
ASCIILibrary.TestStructure s = new ASCIILibrary.TestStructure();
@@ -141,7 +148,7 @@ public class W32APIMapperTest extends TestCase {
s.string2 = MAGIC;
s.write();
assertEquals("Improper null write", null, s.getPointer().getPointer(0));
assertEquals("Improper string write", MAGIC, s.getPointer().getPointer(4).getString(0, false));
assertEquals("Improper string write", MAGIC, s.getPointer().getPointer(Pointer.SIZE).getString(0, false));
}
public void testUnicodeStructureReadString() {
UnicodeLibrary.TestStructure s = new UnicodeLibrary.TestStructure();
+6
Ver Arquivo
@@ -18,6 +18,9 @@
<resources os="Windows" arch="x86">
<nativelib href="win32-x86.jar"/>
</resources>
<resources os="Windows" arch="amd64">
<nativelib href="win32-amd64.jar"/>
</resources>
<resources os="Linux" arch="i386">
<!-- Use 32-bit X11 libs on 64-bit systems (Ubuntu) -->
<property name="jna.library.path" value="/usr/X11R6/lib:/usr/lib32:/usr/lib"/>
@@ -27,6 +30,9 @@
<property name="jna.library.path" value="/usr/X11R6/lib:/usr/lib"/>
<nativelib href="linux-amd64.jar"/>
</resources>
<resources os="OpenBSD" arch="i386">
<nativelib href="openbsd-i386.jar"/>
</resources>
<resources os="FreeBSD" arch="i386">
<nativelib href="freebsd-i386.jar"/>
</resources>
+6
Ver Arquivo
@@ -18,6 +18,9 @@
<resources os="Windows" arch="x86">
<nativelib href="win32-x86.jar"/>
</resources>
<resources os="Windows" arch="amd64">
<nativelib href="win32-amd64.jar"/>
</resources>
<resources os="Linux" arch="i386">
<!-- Use 32-bit X11 libs on 64-bit systems (Ubuntu) -->
<property name="jna.library.path" value="/usr/X11R6/lib:/usr/lib32:/usr/lib"/>
@@ -27,6 +30,9 @@
<property name="jna.library.path" value="/usr/X11R6/lib:/usr/lib"/>
<nativelib href="linux-amd64.jar"/>
</resources>
<resources os="OpenBSD" arch="i386">
<nativelib href="openbsd-i386.jar"/>
</resources>
<resources os="FreeBSD" arch="i386">
<nativelib href="freebsd-i386.jar"/>
</resources>
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo executável
BIN
Ver Arquivo
Arquivo binário não exibido.
Arquivo binário não exibido.
+25 -19
Ver Arquivo
@@ -3,7 +3,7 @@
<meta name="author" content="Timothy Wall">
<meta name="keywords" content="java,jna,jni,c,c++,native,method,function,call,ctypes,ffi,foreign function interface,jdirect,jinvoke,pinvoke,platform invoke,native library access,native access,call native from java,java c library,easy jni,call c from java,avoid jni,jni alternative,jni replacement,legacy,call from java">
<meta name="description" content="Java Native Access (JNA): access native libraries with pure Java code.">
<meta name="date" content="2008-05-14">
<meta name="date" content="2008-10-07">
<title>Java Native Access (JNA): Pure Java access to native libraries</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
@@ -39,8 +39,7 @@
<ul>
<li><a href="#features">Features</a>
<li><a href="#demos">Demos</a>
<li><a href="#community">Community</a>
<li><a href="#support">Support</a>
<li><a href="#community">Community and Support</a>
<li><a href="#projects">Projects</a>
<li><a href="#development">Development</a>&nbsp;&nbsp;&nbsp;
<li><a href="#building">Building</a>
@@ -50,14 +49,16 @@
<td valign=center>
<a name=top></a>
<h2>Java Native Access (JNA) </h2>
JNA provides Java programs easy access to native shared libraries (DLLs on Windows) without writing anything but Java code&#8212;no JNI or native code is required. This functionality is comparable to Windows' Platform/Invoke and Python's ctypes. Access is dynamic at runtime without code generation.</p>
<p>JNA's design aims to provide native access in a natural way with a minimum of effort. No boilerplate or generated code is required. While some attention is paid to performance, correctness and ease of use take priority.</p>
<p>JNA provides Java programs easy access to native shared libraries (DLLs on Windows) without writing anything but Java code&#8212;no JNI or native code is required. This functionality is comparable to Windows' Platform/Invoke and Python's ctypes. Access is dynamic at runtime without code generation.</p>
<p>JNA allows you to call directly into native functions using natural Java method invocation. The Java call looks just like it does in native code. Most calls require no special handling or configuration; no boilerplate or generated code is required.</p>
<p>The JNA library uses a small native library stub to dynamically invoke native code. The developer uses a Java interface to describe functions and structures in the target native library. This makes it quite easy to take advantage of native platform features without incurring the high overhead of configuring and building JNI code for multiple platforms.</p>
<p>While some attention is paid to performance, correctness and ease of use take priority.</p>
</td>
<td valign=center>
<ul>
<li><a href="#getting_started">Getting&nbsp;Started</a>
<li><a href="javadoc/overview-summary.html">API&nbsp;Overview&nbsp;(JavaDoc)</a>
<li><a href="javadoc/overview-summary.html">Documentation</a>
<li><a href="/nonav/javadoc/index.html">API&nbsp;(JavaDoc)</a>
<li><a href="#mapping">Mapping&nbsp;between&nbsp;Java&nbsp;and&nbsp;Native</a>
<li><a href="#pointers">Using&nbsp;Pointers&nbsp;and&nbsp;Arrays</a>
<li><a href="#structures">Using&nbsp;Structures&nbsp;and&nbsp;Unions</a>
@@ -210,7 +211,7 @@ Java primitive types (and their object equivalents) map directly to the native C
<tr><td>int</td><td>32-bit integer</td><td>int</td><td>DWORD</td>
<tr><td>int</td><td>boolean value</td><td>boolean</td><td>BOOL</td>
<tr><td>long</td><td>32/64-bit integer</td><td>NativeLong</td><td>LONG</td>
<tr><td>long long</td><td>64-bit integer</td><td>long</td><td></td>
<tr><td>long long</td><td>64-bit integer</td><td>long</td><td>__int64</td>
<tr><td>float</td><td>32-bit FP</td><td>float</td><td></td>
<tr><td>double</td><td>64-bit FP</td><td>double</td><td></td>
<tr><td>char*</td><td>C string</td><td>String</td><td>LPTCSTR</td>
@@ -234,7 +235,14 @@ void fill_buffer(int[] buf, int len);
</textarea>
</blockquote>
<p>
Arrays of C strings (the <code>char* argv[]</code> to the C <code>main</code>, for example), may be represented by <code>String[]</code> in Java code.
NOTE: if the parameter is to be used by the native function outside the
scope of the function call, you <em>must</em> use <code>Memory</code> or an
NIO Buffer. The memory provided by a Java primitive array will only be valid
for use by the native code for the duration of the function call.
<p>
Arrays of C strings (the <code>char* argv[]</code> to the C <code>main</code>,
for example), may be represented by <code>String[]</code> in Java code. JNA
will pass an equivalent array with a NULL final element.
<p>
<a href=#top>Top</a>
@@ -243,7 +251,7 @@ Arrays of C strings (the <code>char* argv[]</code> to the C <code>main</code>, f
When a function requires a pointer to a <code>struct</code>, a Java <a href="javadoc/com/sun/jna/Structure.html">Structure</a> should be used. If the <code>struct</code> is passed or returned by value, you need only make <a href="javadoc/overview-summary.html#byvalue">minor modifications</a> to the parameter or return type class declaration.<p>
Typically you define a <code>public static</code> class derived from <code>Structure</code> within your library interface definition. This allows the structure to share any options (like custom type mapping) defined for the library interface.
<p>
If a function requires an array of <code>struct</code>, a Java <code>Structure[]</code> may be used. When passing in an array of <code>Structure</code>, it is not necessary to initialize the array elements (the function call will allocate, zero memory, and assign the elements for you). If you <em>do</em> need to initialize the array, you should use the <code>Structure.toArray</code> method to obtain an array of <code>Structure</code> elements contiguous in memory, which you can then initialize as needed.
If a function requires an array of <code>struct</code> (allocated contiguously in memory), a Java <code>Structure[]</code> may be used. When passing in an array of <code>Structure</code>, it is not necessary to initialize the array elements (the function call will allocate, zero memory, and assign the elements for you). If you <em>do</em> need to initialize the array, you should use the <code>Structure.toArray</code> method to obtain an array of <code>Structure</code> elements contiguous in memory, which you can then initialize as needed.
<p>
Unions are generally interchangeable with <code>Structure</code>s, but require that you indicate which union field is active with the <code>setType</code> method before it can be properly passed to a function call.
<p>
@@ -294,7 +302,8 @@ overview</a> for a complete list of built-in type mappings.
<a name=callbacks></a>
<h3>Callbacks/Closures (Function Pointers)</h3>
Callback declarations consist of a simple interface that extends the <a href="javadoc/com/sun/jna/Callback.html">Callback</a>
interface and implements a <code>callback</code> method. Callbacks are
interface and implements a <code>callback</code> method (or defines a single
method of arbitrary name). Callbacks are
implemented by wrapping a Java object method in a little bit of C glue code.
The simplest usage resembles using anonymous inner classes to register event
listeners. Following is an example of callback usage:<br>
@@ -507,10 +516,6 @@ the JNA library (and are pretty nifty utilities in and of themselves).
<li><a href="https://jna.dev.java.net/servlets/MailingListRSS?listName=issues"><img src=https://jna.dev.java.net/branding/images/rss.gif></img> Bugs and Enhancements Issue Tracking</a>
</ul>
<p>
<a href=#top>Top</a>
<a name=support></a>
<h3>Support</h3>
If you are interested in paid support, feel free to say so on one of the JNA mailing lists. Most simple questions will be answered on the list, but more complicated work, new features or target platforms can be negotiated with any of the JNA developers (this is how several of JNA's features came into being). You may even encounter other users with the same need and be able to cost share the new development.
<p>
@@ -531,8 +536,8 @@ If you are interested in paid support, feel free to say so on one of the JNA mai
<li><a href="https://jna.dev.java.net/source/browse/jna/trunk/jnalib/contrib">Miscellaneous contributed mappings and utilities</a> (including Windows NT Service, Registry, and User Account libraries).
<li><a href="http://sellmic.com/blog/2007/05/22/javafx-clock-update-now-with-transparency">A JavaFX Clock</a> (Augusto Sellhorn)
<li><a href="http://ochafik.free.fr/blog/?p=98">Detect User Inactivity</a> (Olivier Chafik)
<li><a href="http://glossitope.org">Glossitope (AKA ab5k)</a> (Josh Marinacci)
<li><a href="http://www.athenabackup.com">Athena Backup</a> (Doug Patriarche)
<li><a href="https://launchpad.net/libusb4j">USB for Java</a> (Mario Boikov)
</ul>
Post to users AT jna DOT dev DOT java DOT net to include your project in this list, or if you'd like to contribute a library mapping you've written.
<p>
@@ -548,6 +553,7 @@ If you are interested in paid support, feel free to say so on one of the JNA mai
<li>Tips and recommended usage of JNA: Likely danger areas, failure modes, best practices, multithreading, etc.</li>
<li>Native library definitions for the more useful libraries on various platforms; for example, <code>user32</code> on Windows. This is important not for having an exhaustive library definition but to illustrate all the different ways a native library may need to be mapped.</li>
<li>Testing on various JDK versions and platforms (linux flavors!).</li>
<li>See the TODO file in the project directory for more up-to-date items.</li>
</ul>
<p>
@@ -555,10 +561,10 @@ If you are interested in paid support, feel free to say so on one of the JNA mai
<a name=building></a>
<h3>Building and Multi-platform support</h3>
JNA has been built and tested on OSX (ppc, x86, x86_64), linux (x86, amd64),
FreeBSD (x86, amd64), SunOS (x86, amd64, sparc, sparcv9) and Windows (x86).
The ant build script's test target will build and run the test suite, which
has decent coverage and is a quick way to determine if your environment is set
up correctly.<p>
FreeBSD/OpenBSD (x86, amd64), Solaris (x86, amd64, sparc, sparcv9) and Windows
(x86, amd64). The ant build script's test target will build and run the test suite,
which has decent coverage and is a quick way to determine if your environment
is set up correctly.<p>
If you want to do a build yourself, you'll need <a
href="http://ant.apache.org">ANT</a>, <a
href="http://directory.fsf.org/make.html">GNU make</a> and <a
+82
Ver Arquivo
@@ -307,16 +307,84 @@ All Classes (JNA API)
<BR>
<A HREF="com/sun/jna/examples/unix/X11.WindowByReference.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.WindowByReference</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XAnyEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XAnyEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XButtonEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XButtonEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XButtonPressedEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XButtonPressedEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XButtonReleasedEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XButtonReleasedEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XCirculateEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XCirculateEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XCirculateRequestEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XCirculateRequestEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XClientMessageEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XClientMessageEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XClientMessageEvent.Data.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XClientMessageEvent.Data</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XColormapEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XColormapEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XConfigureEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XConfigureEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XConfigureRequestEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XConfigureRequestEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XCreateWindowEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XCreateWindowEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XCrossingEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XCrossingEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XDestroyWindowEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XDestroyWindowEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XEnterWindowEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XEnterWindowEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XErrorEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XErrorEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.Xevie.html" title="interface in com.sun.jna.examples.unix" target="classFrame"><I>X11.Xevie</I></A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XExposeEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XExposeEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.Xext.html" title="interface in com.sun.jna.examples.unix" target="classFrame"><I>X11.Xext</I></A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XFocusChangeEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XFocusChangeEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XFocusInEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XFocusInEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XFocusOutEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XFocusOutEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XGCValues.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XGCValues</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XGraphicsExposeEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XGraphicsExposeEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XGravityEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XGravityEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XID.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XID</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XImage.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XImage</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XKeyEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XKeyEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XKeymapEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XKeymapEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XLeaveWindowEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XLeaveWindowEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XMapEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XMapEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XMappingEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XMappingEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XMapRequestEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XMapRequestEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XMotionEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XMotionEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XNoExposeEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XNoExposeEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XPoint.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XPoint</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XPointerMovedEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XPointerMovedEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XPropertyEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XPropertyEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XRectangle.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XRectangle</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.Xrender.html" title="interface in com.sun.jna.examples.unix" target="classFrame"><I>X11.Xrender</I></A>
@@ -327,6 +395,16 @@ All Classes (JNA API)
<BR>
<A HREF="com/sun/jna/examples/unix/X11.Xrender.XRenderPictFormat.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.Xrender.XRenderPictFormat</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XReparentEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XReparentEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XResizeRequestEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XResizeRequestEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XSelectionClearEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XSelectionClearEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XSelectionEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XSelectionEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XSelectionRequestEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XSelectionRequestEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XSetWindowAttributes.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XSetWindowAttributes</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XSizeHints.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XSizeHints</A>
@@ -335,6 +413,10 @@ All Classes (JNA API)
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XTextProperty.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XTextProperty</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XUnmapEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XUnmapEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XVisibilityEvent.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XVisibilityEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XVisualInfo.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XVisualInfo</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XWindowAttributes.html" title="class in com.sun.jna.examples.unix" target="classFrame">X11.XWindowAttributes</A>
+82
Ver Arquivo
@@ -307,16 +307,84 @@ All Classes (JNA API)
<BR>
<A HREF="com/sun/jna/examples/unix/X11.WindowByReference.html" title="class in com.sun.jna.examples.unix">X11.WindowByReference</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XAnyEvent.html" title="class in com.sun.jna.examples.unix">X11.XAnyEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XButtonEvent.html" title="class in com.sun.jna.examples.unix">X11.XButtonEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XButtonPressedEvent.html" title="class in com.sun.jna.examples.unix">X11.XButtonPressedEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XButtonReleasedEvent.html" title="class in com.sun.jna.examples.unix">X11.XButtonReleasedEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XCirculateEvent.html" title="class in com.sun.jna.examples.unix">X11.XCirculateEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XCirculateRequestEvent.html" title="class in com.sun.jna.examples.unix">X11.XCirculateRequestEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XClientMessageEvent.html" title="class in com.sun.jna.examples.unix">X11.XClientMessageEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XClientMessageEvent.Data.html" title="class in com.sun.jna.examples.unix">X11.XClientMessageEvent.Data</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XColormapEvent.html" title="class in com.sun.jna.examples.unix">X11.XColormapEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XConfigureEvent.html" title="class in com.sun.jna.examples.unix">X11.XConfigureEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XConfigureRequestEvent.html" title="class in com.sun.jna.examples.unix">X11.XConfigureRequestEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XCreateWindowEvent.html" title="class in com.sun.jna.examples.unix">X11.XCreateWindowEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XCrossingEvent.html" title="class in com.sun.jna.examples.unix">X11.XCrossingEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XDestroyWindowEvent.html" title="class in com.sun.jna.examples.unix">X11.XDestroyWindowEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XEnterWindowEvent.html" title="class in com.sun.jna.examples.unix">X11.XEnterWindowEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XErrorEvent.html" title="class in com.sun.jna.examples.unix">X11.XErrorEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XEvent.html" title="class in com.sun.jna.examples.unix">X11.XEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.Xevie.html" title="interface in com.sun.jna.examples.unix"><I>X11.Xevie</I></A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XExposeEvent.html" title="class in com.sun.jna.examples.unix">X11.XExposeEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.Xext.html" title="interface in com.sun.jna.examples.unix"><I>X11.Xext</I></A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XFocusChangeEvent.html" title="class in com.sun.jna.examples.unix">X11.XFocusChangeEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XFocusInEvent.html" title="class in com.sun.jna.examples.unix">X11.XFocusInEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XFocusOutEvent.html" title="class in com.sun.jna.examples.unix">X11.XFocusOutEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XGCValues.html" title="class in com.sun.jna.examples.unix">X11.XGCValues</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XGraphicsExposeEvent.html" title="class in com.sun.jna.examples.unix">X11.XGraphicsExposeEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XGravityEvent.html" title="class in com.sun.jna.examples.unix">X11.XGravityEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XID.html" title="class in com.sun.jna.examples.unix">X11.XID</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XImage.html" title="class in com.sun.jna.examples.unix">X11.XImage</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XKeyEvent.html" title="class in com.sun.jna.examples.unix">X11.XKeyEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XKeymapEvent.html" title="class in com.sun.jna.examples.unix">X11.XKeymapEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XLeaveWindowEvent.html" title="class in com.sun.jna.examples.unix">X11.XLeaveWindowEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XMapEvent.html" title="class in com.sun.jna.examples.unix">X11.XMapEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XMappingEvent.html" title="class in com.sun.jna.examples.unix">X11.XMappingEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XMapRequestEvent.html" title="class in com.sun.jna.examples.unix">X11.XMapRequestEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XMotionEvent.html" title="class in com.sun.jna.examples.unix">X11.XMotionEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XNoExposeEvent.html" title="class in com.sun.jna.examples.unix">X11.XNoExposeEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XPoint.html" title="class in com.sun.jna.examples.unix">X11.XPoint</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XPointerMovedEvent.html" title="class in com.sun.jna.examples.unix">X11.XPointerMovedEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XPropertyEvent.html" title="class in com.sun.jna.examples.unix">X11.XPropertyEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XRectangle.html" title="class in com.sun.jna.examples.unix">X11.XRectangle</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.Xrender.html" title="interface in com.sun.jna.examples.unix"><I>X11.Xrender</I></A>
@@ -327,6 +395,16 @@ All Classes (JNA API)
<BR>
<A HREF="com/sun/jna/examples/unix/X11.Xrender.XRenderPictFormat.html" title="class in com.sun.jna.examples.unix">X11.Xrender.XRenderPictFormat</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XReparentEvent.html" title="class in com.sun.jna.examples.unix">X11.XReparentEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XResizeRequestEvent.html" title="class in com.sun.jna.examples.unix">X11.XResizeRequestEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XSelectionClearEvent.html" title="class in com.sun.jna.examples.unix">X11.XSelectionClearEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XSelectionEvent.html" title="class in com.sun.jna.examples.unix">X11.XSelectionEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XSelectionRequestEvent.html" title="class in com.sun.jna.examples.unix">X11.XSelectionRequestEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XSetWindowAttributes.html" title="class in com.sun.jna.examples.unix">X11.XSetWindowAttributes</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XSizeHints.html" title="class in com.sun.jna.examples.unix">X11.XSizeHints</A>
@@ -335,6 +413,10 @@ All Classes (JNA API)
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XTextProperty.html" title="class in com.sun.jna.examples.unix">X11.XTextProperty</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XUnmapEvent.html" title="class in com.sun.jna.examples.unix">X11.XUnmapEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XVisibilityEvent.html" title="class in com.sun.jna.examples.unix">X11.XVisibilityEvent</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XVisualInfo.html" title="class in com.sun.jna.examples.unix">X11.XVisualInfo</A>
<BR>
<A HREF="com/sun/jna/examples/unix/X11.XWindowAttributes.html" title="class in com.sun.jna.examples.unix">X11.XWindowAttributes</A>
@@ -44,7 +44,7 @@ function windowTitle()
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>JNA API</><font size="-1"> 3.0.4</font></EM>
<b>JNA API</><font size="-1"> 3.0.6</font></EM>
</TD>
</TR>
@@ -133,7 +133,7 @@ Tagging interface to indicate the library or callback uses an alternate
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>JNA API</><font size="-1"> 3.0.4</font></EM>
<b>JNA API</><font size="-1"> 3.0.6</font></EM>
</TD>
</TR>
+31 -4
Ver Arquivo
@@ -44,7 +44,7 @@ function windowTitle()
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>JNA API</><font size="-1"> 3.0.4</font></EM>
<b>JNA API</><font size="-1"> 3.0.6</font></EM>
</TD>
</TR>
@@ -96,7 +96,8 @@ Interface Callback</H2>
<P>
All callback definitions must derive from this interface. Any
derived interfaces must define a <code>callback</code> method.
derived interfaces must define a single public method (which may not be named
"hashCode", "equals", or "toString"), or one public method named "callback".
You are responsible for deregistering your callback (if necessary)
in its <A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html#finalize()" title="class or interface in java.lang"><CODE>Object.finalize()</CODE></A> method. If native code attempts to call
a callback which has been GC'd, you will likely crash the VM. If
@@ -121,11 +122,20 @@ All callback definitions must derive from this interface. Any
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;<A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collection.html" title="class or interface in java.util">Collection</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/sun/jna/Callback.html#FORBIDDEN_NAMES">FORBIDDEN_NAMES</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;These method names may not be used for a callback method.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;<A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/sun/jna/Callback.html#METHOD_NAME">METHOD_NAME</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;You must this method name if your callback interface has multiple
public methods.</TD>
</TR>
</TABLE>
&nbsp;
@@ -146,9 +156,26 @@ METHOD_NAME</H3>
<PRE>
static final <A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>METHOD_NAME</B></PRE>
<DL>
<DD>You must this method name if your callback interface has multiple
public methods. Typically a callback will have only one such
method, in which case any method name may be used, with the exception
of those in <A HREF="../../../com/sun/jna/Callback.html#FORBIDDEN_NAMES"><CODE>FORBIDDEN_NAMES</CODE></A>.
<P>
<DL>
<DT><B>See Also:</B><DD><A HREF="../../../constant-values.html#com.sun.jna.Callback.METHOD_NAME">Constant Field Values</A></DL>
</DL>
<HR>
<A NAME="FORBIDDEN_NAMES"><!-- --></A><H3>
FORBIDDEN_NAMES</H3>
<PRE>
static final <A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collection.html" title="class or interface in java.util">Collection</A> <B>FORBIDDEN_NAMES</B></PRE>
<DL>
<DD>These method names may not be used for a callback method.
<P>
<DL>
</DL>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
@@ -173,7 +200,7 @@ static final <A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.h
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>JNA API</><font size="-1"> 3.0.4</font></EM>
<b>JNA API</><font size="-1"> 3.0.6</font></EM>
</TD>
</TR>
@@ -44,7 +44,7 @@ function windowTitle()
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>JNA API</><font size="-1"> 3.0.4</font></EM>
<b>JNA API</><font size="-1"> 3.0.6</font></EM>
</TD>
</TR>
@@ -263,7 +263,7 @@ public int <B>getIndex</B>()</PRE>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>JNA API</><font size="-1"> 3.0.4</font></EM>
<b>JNA API</><font size="-1"> 3.0.6</font></EM>
</TD>
</TR>
+3 -3
Ver Arquivo
@@ -44,7 +44,7 @@ function windowTitle()
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>JNA API</><font size="-1"> 3.0.4</font></EM>
<b>JNA API</><font size="-1"> 3.0.6</font></EM>
</TD>
</TR>
@@ -120,7 +120,7 @@ Placeholder proxy interface to allow an InvocationHandler to convert
<TH ALIGN="left"><B>Fields inherited from interface com.sun.jna.<A HREF="../../../com/sun/jna/Callback.html" title="interface in com.sun.jna">Callback</A></B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="../../../com/sun/jna/Callback.html#METHOD_NAME">METHOD_NAME</A></CODE></TD>
<TD><CODE><A HREF="../../../com/sun/jna/Callback.html#FORBIDDEN_NAMES">FORBIDDEN_NAMES</A>, <A HREF="../../../com/sun/jna/Callback.html#METHOD_NAME">METHOD_NAME</A></CODE></TD>
</TR>
</TABLE>
&nbsp;
@@ -241,7 +241,7 @@ getReturnType</H3>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>JNA API</><font size="-1"> 3.0.4</font></EM>
<b>JNA API</><font size="-1"> 3.0.6</font></EM>
</TD>
</TR>
+2 -2
Ver Arquivo
@@ -44,7 +44,7 @@ function windowTitle()
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>JNA API</><font size="-1"> 3.0.4</font></EM>
<b>JNA API</><font size="-1"> 3.0.6</font></EM>
</TD>
</TR>
@@ -352,7 +352,7 @@ public static <A HREF="../../../com/sun/jna/Pointer.html" title="class in com.su
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>JNA API</><font size="-1"> 3.0.4</font></EM>
<b>JNA API</><font size="-1"> 3.0.6</font></EM>
</TD>
</TR>
@@ -44,7 +44,7 @@ function windowTitle()
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>JNA API</><font size="-1"> 3.0.4</font></EM>
<b>JNA API</><font size="-1"> 3.0.6</font></EM>
</TD>
</TR>
@@ -210,7 +210,7 @@ public <A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/reflect/Method
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>JNA API</><font size="-1"> 3.0.4</font></EM>
<b>JNA API</><font size="-1"> 3.0.6</font></EM>
</TD>
</TR>

Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais