Comparar commits
89 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| f308faf1ea | |||
| 4ea22e54e3 | |||
| 10e77227b6 | |||
| a9521411a5 | |||
| 70b11b47ee | |||
| 63ba1fa79f | |||
| 24fbca4c1d | |||
| b0fa11cb0a | |||
| 8bd15d139a | |||
| 7aab825cf1 | |||
| cb03ea8f4e | |||
| 35ee8d44f3 | |||
| 9db7e1a958 | |||
| ce0138e614 | |||
| fd07c9e404 | |||
| ed6ae9501b | |||
| ffef2e046a | |||
| 95eecebb28 | |||
| 176aa9d2e2 | |||
| f3a4f3fdde | |||
| 522f8fef49 | |||
| c4dfa259eb | |||
| f62bd63fe6 | |||
| f7cd61e9e6 | |||
| 6a79012942 | |||
| 370112938e | |||
| bcc0c28001 | |||
| bada2e326d | |||
| 655bb8f369 | |||
| 1035ffb2f4 | |||
| 840f975866 | |||
| aeb8719a34 | |||
| 40860245a4 | |||
| 20cae32b15 | |||
| 9742f91782 | |||
| f03eab0824 | |||
| 05fbe1faed | |||
| 0b4986a788 | |||
| 3c337eef51 | |||
| 90720962ce | |||
| bff052d9cd | |||
| cd41aeab61 | |||
| 8bf987d4df | |||
| 3ee74fd6dc | |||
| 13e2d7b925 | |||
| 5141543000 | |||
| 56ba8d86f4 | |||
| 6a028caec1 | |||
| 2d9b393975 | |||
| 8308984e47 | |||
| f26c7ca671 | |||
| 74c776e219 | |||
| 8962c8c8d0 | |||
| 35ddb69c2b | |||
| f7879bc3f3 | |||
| 67cea90fc0 | |||
| 0de3277b18 | |||
| 8f4772f383 | |||
| ea7f8440d5 | |||
| f06c0f1037 | |||
| 1f8675d4c1 | |||
| 335f419a86 | |||
| 53236d5061 | |||
| 72222ca3fb | |||
| 1e326c9543 | |||
| cb6671f5b8 | |||
| ebbe779668 | |||
| 4394096da0 | |||
| ed7a59c3ff | |||
| ccee09a4ff | |||
| 089dbce7cc | |||
| 980a334c42 | |||
| 8bad679ade | |||
| 981c32ee11 | |||
| 61a0549295 | |||
| f6b58d2bdc | |||
| 69da33a076 | |||
| f680b598b7 | |||
| dfadfb1985 | |||
| e944b8c7eb | |||
| 9ccd51be1f | |||
| f342996cb5 | |||
| 58e8b66f70 | |||
| fa5d747905 | |||
| 6993a6686f | |||
| 70084e70dd | |||
| 9c00a3f674 | |||
| 048d2f41c3 | |||
| 6d6f711080 |
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" output="jna/build.eclipse/test-classes" path="contrib/platform/test"/>
|
||||
<classpathentry kind="src" path="contrib/platform/src"/>
|
||||
<classpathentry kind="src" output="build.eclipse/test-classes" path="test"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
|
||||
<classpathentry kind="output" path="build.eclipse/classes"/>
|
||||
</classpath>
|
||||
+20
-16
@@ -1,17 +1,21 @@
|
||||
build
|
||||
build-d64
|
||||
build.eclipse
|
||||
build.number
|
||||
.metadata
|
||||
.DS_Store
|
||||
bin
|
||||
contrib/ntservice/dist
|
||||
contrib/platform/dist
|
||||
doc
|
||||
.libs
|
||||
.deps
|
||||
*.o
|
||||
*.lo
|
||||
.dirstamp
|
||||
*.la
|
||||
Makefile
|
||||
config.log
|
||||
config.status
|
||||
*~
|
||||
**/*~
|
||||
dist/*.asc
|
||||
dist/*-sources.jar
|
||||
dist/*-javadoc.jar
|
||||
dist/src-mvn.zip
|
||||
dist/out-of-date.jar
|
||||
fficonfig.h
|
||||
include/ffi.h
|
||||
include/ffitarget.h
|
||||
libffi.pc
|
||||
libtool
|
||||
stamp-h1
|
||||
libffi*gz
|
||||
autom4te.cache
|
||||
libffi.xcodeproj/xcuserdata
|
||||
libffi.xcodeproj/project.xcworkspace
|
||||
ios/
|
||||
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>jnalib</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,62 +0,0 @@
|
||||
#Wed Aug 29 20:43:29 EDT 2007
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.deprecation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
|
||||
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
|
||||
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
|
||||
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.nullReference=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
|
||||
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedImport=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
||||
@@ -1,3 +0,0 @@
|
||||
#Tue Mar 27 21:18:08 EDT 2007
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
|
||||
@@ -0,0 +1,8 @@
|
||||
language: c
|
||||
compiler:
|
||||
- gcc
|
||||
- clang
|
||||
|
||||
before_script: sudo apt-get install dejagnu
|
||||
|
||||
script: ./configure && make && make check
|
||||
-602
@@ -1,602 +0,0 @@
|
||||
Release 3.5.1
|
||||
====================
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
* [#145](https://github.com/twall/jna/pull/145): Fix `Netapi32Util.getDomainTrusts()` returns "empty" domain object - [@aikidojohn](https://github.com/aikidojohn).
|
||||
* [#145](https://github.com/twall/jna/pull/145): Fix `Netapi32.getDC()` - added missing fields in `DOMAIN_CONTROLLER_INFO` - [@aikidojohn](https://github.com/aikidojohn).
|
||||
* [#151] 'platform.jar' in the dist directory was not updated for release 3.5.0. (The 'platform.jar' published to maven central was correct.)
|
||||
|
||||
Release 3.5.0
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
* `Structure.getFieldOrder()` supersedes `Structure.setFieldOrder()` and is now required - [@twall](https://github.com/twall).
|
||||
* Search `~/Library/Frameworks` and `/Library/Frameworks` on OSX - [@shaneholloway](https://github.com/shaneholloway).
|
||||
* Automatic cleanup of native threads (based on suggestions from neil smith) - [@twall](https://github.com/twall).
|
||||
* Add `android-arm` target - [@ochafik](https://github.com/ochafik), [@twall](https://github.com/twall).
|
||||
* Add `jna.tmpdir` to override temporary JNA storage location - [@twall](https://github.com/twall).
|
||||
* Add `EXTRA_MAKE_OPTS` ant property to override make variables - [@twall](https://github.com/twall).
|
||||
* Add `Library.OPTION_OPEN_FLAGS` to customize dlopen behavior - [@twall](https://github.com/twall).
|
||||
* [#113](https://github.com/twall/jna/issues/113), [#114](https://github.com/twall/jna/issues/114): Add support for GNU/kFreeBSD and debian multi-arch distros - [@twall](https://github.com/twall).
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
* Fix `Advapi32Util.registryGetValues()` tried to allocate memory for a zero-length `REG_BINARY` value - [@phailwhale22](https://github.com/phailwhale22).
|
||||
* Fix crash in direct mode callbacks with certain type conversions - [@twall](https://github.com/twall).
|
||||
* More thoroughly propagate unexpected exceptions generated in jnidispatch - [@twall](https://github.com/twall).
|
||||
* Cleanup maven poms and publishing to central repo - [@bhamail](https://github.com/bhamail).
|
||||
* [#129](https://github.com/twall/jna/issues/129): Allow `Memory` field in structure - [@twall](https://github.com/twall).
|
||||
* Preserve `PointerType` fields on `Structure.read()` if unchanged - [@twall](https://github.com/twall).
|
||||
* [#128](https://github.com/twall/jna/issues/128): Fix masking extracting DWORD upper and lower WORD values - [@twall](https://github.com/twall).
|
||||
* [#135](https://github.com/twall/jna/issues/135): Fix for `Advapi32Util.registryGetValues()` when reading zero length values - [@danwi](https://github.com/danwi).
|
||||
|
||||
Release 3.4.2
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
* Add `platform.win32.Kernel32.GetEnvironmentVariable` and `platform.win32.Kernel32Util.getEnvironmentVariable` - [@dblock](https://github.com/dblock).
|
||||
* Moved `Kernel32.dll` function definitions from `WinNT.java` into `Kernel32.java` - [@dblock](https://github.com/dblock).
|
||||
* Provide `toPointer()` methods on all `_PTR` types (platform win32) - [@twall](https://github.com/twall).
|
||||
* Provide `ant -Dskip-native` to skip platform native build - [@twall](https://github.com/twall).
|
||||
* Provide `ant -Dheadless=true` to run unit tests headless - [@twall](https://github.com/twall).
|
||||
* Added Windows dev environment instructions - [@twall](https://github.com/twall).
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
* Ensure platform win32 classes use unsigned where appropriate (`ULONG_PTR`, `UINT_PTR`, `ULONGLONG`, `WORD`, `DWORDLONG`) - [@twall](https://github.com/twall).
|
||||
* [#71](https://github.com/twall/jna/issues/71), [#73](https://github.com/twall/jna/issues/73): Fix OSGI entries in manifest - [@twall](https://github.com/twall).
|
||||
* [#78](https://github.com/twall/jna/issues/78): Fix NPE in `platform.win32.Netapi32Util.getDomainTrusts` - [@dblock](https://github.com/dblock).
|
||||
* Fix: auto-sync memory for `struct**` arguments (array of struct pointers) - [@twall](https://github.com/twall).
|
||||
* Fix: `platform.win32.Secur32.AcquireCredentialsHandle`, `InitializeSecurityContext` and `AcceptSecurityContext` on Win32 64-bit - [@dblock](https://github.com/dblock).
|
||||
* Fix: avoid overwriting native `char *` or `wchar_t *` fields within structures when unmodified (similar to current operation with pointers) - [@twall](https://github.com/twall).
|
||||
* Fix: `platform.win32.DsGetDC.DS_DOMAIN_TRUSTS` and `DsEnumerateDomainTrusts` on Win32 64-bit - [@trejkaz](https://github.com/trejkaz).
|
||||
* Fix: Crash freeing the wrong pointer in `Netapi32Util.getDomainTrusts` - [@trejkaz](https://github.com/trejkaz).
|
||||
* [#100](https://github.com/twall/jna/issues/100): Fix `platform.win32.W32FileMonitor` - [@dblock](https://github.com/dblock).
|
||||
* Return INT_PTR from `platform.win32.Shell32.ShellExecute`, since returning
|
||||
`HINSTANCE` is useless.
|
||||
* Fix runtime error in some instances where Structure.setFieldOrder is used (never return self when sharing AutoAllocated memory).
|
||||
* [#107](https://github.com/twall/jna/issues/107): `Structure.clear()` always calls `ensureAllocated()` to avoid NPE.
|
||||
* Ensure internal memory pointer is *always* allocated when calling `Structure.useMemory()`, even if layout is not yet determined.
|
||||
|
||||
Release 3.4.1
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
* Add 'unsigned' modifier to IntegerType.
|
||||
* Add to `platform.win32.User32`: `GetLastInputInfo`.
|
||||
* Add `platform.win32.WinNT.GetFileType` and `platform.win32.Kernel32Util.getFileType`.
|
||||
* Add to `platform.win32.Kernel32Util`: `getFileType`.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
* Re-build linux-amd and linux-i386 against older versions of glibc (2.2.5 and
|
||||
2.1.3 respectively).
|
||||
* Properly initialize first printer info struct in winspool library.
|
||||
* Properly support getting and setting zero-array-length `REG_MULTI_SZ` values on Win32.
|
||||
* Fixed SID in Win32 `USER_INFO_23` and `GROUP_INFO_3`.
|
||||
* Fixed passing domain name into Win32 `Netapi32Util.getUserInfo`.
|
||||
|
||||
Release 3.4.0
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
* Provide `jna.nosys=true` to avoid loading any system-provided JNA (useful for local build/development).
|
||||
* Allow override of default jnidispatch library name with `jna.boot.library.name` system property.
|
||||
* Throw an Error if a system install of JNA is incompatible or if JNA's JNI library does not match.
|
||||
* Disable automatic jnidispatch unpacking with `jna.nounpack=true`.
|
||||
* Automatically look up system error messages for LastErrorException.
|
||||
* Improved callback thread-mapping support; re-use, rename, and group callback
|
||||
threads.
|
||||
* Cache structure layout results, improving performance of structure creation.
|
||||
* linux/arm 32-bit support (hardware provided by Alex Lam).
|
||||
* linux/ppc 32-bit support (hardware provided by Fritiof Hedman).
|
||||
* Preliminary linux/ia64, linux/ppc64 support (thanks to Laurent Guerby and the GCC compile farm).
|
||||
* Windows CE/Mobile support (w32ce-arm) (resources provided by andrea antonello and Hydrologis SRL).
|
||||
* linux multi-arch support (kohsuke).
|
||||
* Added REG_QWORD registry type support
|
||||
* Add to `platform.unix.x11`: `XGrabKey`, `XUngrabKey`, `XSetErrorHandler`.
|
||||
* Add to `platform.mac.Carbon`: `GetEventDispatcherTarget`, `InstallEventHandler`, `RegisterEventHotKey`, `GetEventParameter`, `RemoveEventHandler`, `UnregisterEventHotKey`.
|
||||
* Add to `platform.win32.Kernel32`: `CopyFile`, `MoveFile`, `MoveFileEx`, `CreateProcess`, `SetEnvironmentVariables`, `GetFileTime`, `SetFileTime`, `SetFileAttributes`, `DeviceIoControl`, `GetDiskFreeSpaceEx`, `CreateToolhelp32Snapshot`, `Process32First`, `Process32Next`.
|
||||
* Add to `platform.win32.Msi`: `MsiGetComponentPath`, `MsiLocateComponent`, `MsiGetProductCode`, `MsiEnumComponents`.
|
||||
* Add to `platform.win32.User32`: `RegisterHotKey`, `UnregisterHotKey`
|
||||
* Add to `platform.win32.SetupApi`: `SetupDiGetClassDevs`, `SetupDiDestroyDeviceInfoList`, `SetupDiEnumDeviceInterfaces`, `SetupDiGetDeviceInterfaceDetail`, `SetupDiGetDeviceRegistryProperty`.
|
||||
* Add `platform.win32.Shell32.ShellExecute`.
|
||||
* Add to `platform.win32.User32`: `SetParent`, `IsWindowVisible`, `MoveWindow`, `SetWindowPos`, `AttachInputThread`, `SetForegroundWindow`, `GetForegroundWindow`, `SetFocus`, `SendInput`, `WaitForInputIdle`, `InvalidateRect`, `RedrawWindow`, `GetWindow`, `UpdateWindow`, `ShowWindow`, `CloseWindow`.
|
||||
* Add to `platform.win32.Version`: `GetFileVersionInfoSize`, `GetFileVersionInfo`, `VerQueryValue`.
|
||||
* Add to `platform.win32.Advapi32`: `GetFileSecurity`, `RegQueryValueEx(...Long...)`.
|
||||
* Add to `platform.win32.Netapi32`: `NetUserGetInfo`.
|
||||
|
||||
Bug Fixes
|
||||
--------
|
||||
* Revise cleanup of in-use temporary files on win32 (issue 6).
|
||||
* Fix structure alignment issues on linux/ppc.
|
||||
* Fix structure alignment issues on linux/arm.
|
||||
* Account for NIO Buffer position (JIRA issue 185).
|
||||
* Avoid crash with very long Strings (> 150k in length).
|
||||
* Fix bug tracking Memory with an associated direct ByteBuffer.
|
||||
* Fix bug handling structs by value when type mappers are in effect (JIRA issue 188).
|
||||
|
||||
Release 3.3.0
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Facilitate `Memory` subclasses (jbellis).
|
||||
* Allow multiple fields of the same type in Unions (Francis Barber).
|
||||
* Add `platform.win32.Advapi32.AdjustTokenPrivileges`, `platform.win32.Advapi32.LookupPrivilegeName`, `platform.win32.Advapi32.LookupPrivilegeValue`, `platform.win32.Advapi32.ImpersonateSelf`.
|
||||
* Add `platform.win32.Advapi32.DuplicateTokenEx`, `platform.win32.Advapi32.CreateProcessAsUser`, `platform.win32.Kernel32.GetExitCodeProcess`, `platform.win32.Kernel32.TerminateProcess`, `platform.win32.Kernel32.ReadFile`, `platform.win32.Kernel32.CreatePipe`, `platform.win32.Kernel32.SetHandleInformation` and related constants / structures in `platform.win32.WinBase` and `platform.win32.WinNT`. Please note that the `SECURITY_ATTRIBUTES` structure has been moved from `platform.win32.WinNT` to `platform.win32.WinBase`.
|
||||
* Add `platform.win32.Kernel32.DeleteFile` and `platform.win32.Kernel32Util.deleteFile`.
|
||||
* Add `platform.win32.Kernel32.GetFileAttributes` and `platform.win32.Kernel32Util.getFileAttributes`.
|
||||
* Add `platform.win32.Kernel32.GetTickCount`.
|
||||
* Add Win32 Service functions to `platform.win32.Advapi32`.
|
||||
* Add `platform.win32.W32ServiceManager` and `W32Service`.
|
||||
* Add Win32 Event Logging functions to `platform.win32.Advapi32` and `platform.win32.Advapi32Util.EventLogIterator`.
|
||||
* `platform.win32.Advapi32Util.registryCreateKey` returns `true` if key was created, `false` if it already exists.
|
||||
* Add `REG_BINARY`, `REG_EXPAND_SZ` and `REG_MULTI_SZ` support to `platform.win32.Advapi32Util` registry functions.
|
||||
* Reduce JNI crossings in a number of native methods, moving object creation out into pure Java code.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Move all native functions into `com.sun.jna.Native`, to ensure that all dependent classes must be disposed before the `Native` class is unloaded. Note that this change is incompatible with all previous JNA native libraries.
|
||||
* Fix `platform.win32.Kernel32.GetNativeSystemInfo` and `GetSystemInfo` AV on Win64.
|
||||
* Fix several potential minor bugs as reported by TvT.
|
||||
* Fix bug in Structure.StructureSet.toString (Blair Zajac), exposed by Tomcat ThreadLocal cleanup.
|
||||
* Fix several bugs when using Structure(Pointer) ctor and array fields (Samuel Audet).
|
||||
|
||||
Release 3.2.7
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Add native peer value accessors for Pointer
|
||||
* The `jna.library.path` property is now re-evaluated whenever a native library is loaded. Previously this value was cached when the JNA classes loaded.
|
||||
* `Native.loadLibrary` can now load `.drv` files.
|
||||
* Refactor `com.sun.jna.platform.win32.WINBASE` into `WinDef`, `WinNT` and `BaseTSD`, matching Windows SDK headers.
|
||||
* Refactor constants from `com.sun.jna.platform.win32.GDI32` into `WinGDI`, matching Windows SDK headers.
|
||||
* Refactor constants from `com.sun.jna.platform.win32.User32` into `WinUser`, matching Windows SDK headers.
|
||||
* Refactor `platform.win32.WinNT.LARGE_INTEGER` into a union.
|
||||
* Add `platform.win32.ObjBase`, `com.sun.jna.platform.win32.Ole32.CoInitializeEx`, `CoUninitialize`, and `CoCreateInstance`.
|
||||
* Add `platform.win32.Oleaut32.SysAllocString` and `SysFreeString`.
|
||||
* Add `platform.win32.Secur32.ImpersonateSecurityContext` and `RevertSecurityContext`.
|
||||
* Add `platform.win32.WinNT.WELL_KNOWN_SID_TYPE`, `SECURITY_MAX_SID_SIZE` and other related SID-related constants.
|
||||
* Add `platform.win32.Advapi32.CreateWellKnownSid` and `IsWellKnownSid` and `com.sun.jna.platform.win32.Advapi32Util.isWellKnownSid`.
|
||||
* Add `platform.win32.Kernel32.GetVersion`, `GetVersionEx`, `GetSystemInfo`, `GetNativeSystemInfo`, `GlobalMemoryStatusEx`, `GetLogicalDriveStrings` and `IsWow64Process`.
|
||||
* Add `platform.win32.Kernel32Util.getLogicalDriveStrings`.
|
||||
* Add `platform.win32.User32.GetSystemMetrics`.
|
||||
* Add `platform.win32.BaseTSD.DWORD_PTR`.
|
||||
* Add `platform.win32.WinBase.SYSTEM_INFO` and `MEMORYSTATUSEX`.
|
||||
* Add `platform.win32.WinNT.OSVERSIONINFOEX`, `VER` constants.
|
||||
* Add `platform.win32.WinDef.ULONGLONG` and `DWORDLONG`.
|
||||
* Add `platform.win32.Shell32.SHGetDesktopFolder` (prep work for Com4JNA).
|
||||
* Add `platform.win32.Winspool.GetPrinterInfo`.
|
||||
* Add `platform.win32.WinspoolUtil.getPrinterInfo1`.
|
||||
* Add `platform.win32.GDI32.GetDeviceCaps`.
|
||||
* Add `platform.win32.GDI32.GetDIBits`.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix `ClassCastException` in `Structure.equals` (issue 152).
|
||||
* Fix bug initializing a structure object from existing memory when the structure has initialized fields (issue 133).
|
||||
* Fix NPE reading an array of string from a pointer when an element of the array is `NULL` (issue 151).
|
||||
* Avoid calling `UnregisterNatives` in native code (issue 154).
|
||||
* Compare unpacked library path against canonical (long) filename (issue 156).
|
||||
* Fix `read()` of uninitialized memory in `platform.win32.Advapi32Util.getTokenGroups` and `getTokenAccount`.
|
||||
* Fix `com.sun.jna.platform.win32.Secur32.QuerySecurityContextToken` to take a `CtxtHandle` instead of `PSecHandle`.
|
||||
* Fix definition of BITMAPINFO (platform/win32).
|
||||
|
||||
Release 3.2.5
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Split code in examples.jar into a contrib platform.jar package and individual packages for demos.
|
||||
* Fix Eclipse build and added Eclipse projects for all contrib samples, import projects from jnalib and contrib.
|
||||
* Ensure Structure fields correctly ordered when inherited.
|
||||
* Use explicit Structure field whenever provided, regardless of whether the VM requires it.
|
||||
* Add Win32 mappings for two dozen functions from Kernel32.dll, Advapi32.dll, Netapi32.dll, Secur32.dll, NtDll.dll, Ole32.dll, Shell32.dll and Crypt32.dll to com.sun.jna.platform.win32.
|
||||
* Port parts of WinError.h, WinNT.h, LMAccess.h, LMCons.h, LMErr.h, LMJoin.h, NTStatus.h, ShlObj.h, WinDef.h, ShellApi.h, Wdm.h, WinReg.h, WinCrypt.h, Sspi.h, Guid.h, NtSecApi.h and DsGetDc.h.
|
||||
* Add Win32 simplified utility interfaces Kernel32Util, Advapi32Util, Netapi32Util, Crypt32Util, NtDllUtil, Shell32Util, Ole32Util and Secur32Util to com.sun.jna.platform.win32.
|
||||
* Support unicode paths in W32FileUtils.
|
||||
* Fix exception during dispose in W32FileMonitor.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Provide String.replace for 1.4 compatibility.
|
||||
* Avoid allocating memory when Structure is provided a pointer in the ctor.
|
||||
* Ensure proper value returned in Pointer.getValue() for non-null, unchanged NIO Buffer values.
|
||||
* Use 1.4-compatible URI generation (issue 149).
|
||||
|
||||
Release 3.2.4
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Make Pointer ctor public.
|
||||
* Provide access to Function objects for arbitrary Pointer values.
|
||||
* Add linux/ia64 binaries (bpiwowar). See issue 134 patch.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Use a more robust method to decode a file-based URL (issue 135).
|
||||
|
||||
Release 3.2.3
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Include version information in code in case package information lost.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix WindowUtils exception on mouse over TrayIcon.
|
||||
* Fix bug toggling windows transparent/opaque (win32/OSX).
|
||||
* Avoid overwriting unchanged Pointer values in arrays (function calls with Pointer[] and Structure.read).
|
||||
* Ensure Structure fields marked `final` are never written.
|
||||
* Fix bug preventing proper population Structure.ByReference fields on Structure read.
|
||||
* Ensure double buffering is disabled in components added to a transparent window.
|
||||
* Fix UnsatisfiedLinkError attempting to load system libraries under Web Start.
|
||||
* Fix loading Web Start-provided libraries on OSX (libraries must have a .jnilib suffix under Web Start).
|
||||
* Properly include sources in Maven zip file (Issue 129).
|
||||
|
||||
Release 3.2.2
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Provide length-specified Pointer.getStringArray()
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix crash with direct mapping if NULL struct* used (Issue 125).
|
||||
* Fix case where null-valued Structure fields would get non-null values on write.
|
||||
* Synch callback Structure/Structure[] arguments on callback return.
|
||||
* Fix NPE when mapping an interface to the current process.
|
||||
* Automatically load proper C library version from current process on Linux (avoids crashing bug on Ubuntu with libc-i686 packages active).
|
||||
* Avoid scanning structure contents in Structure.toString if contents aren't actually used.
|
||||
|
||||
Release 3.2.1
|
||||
==========
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Add HRESULT, LONG mapping to W32API (marc strapetz).
|
||||
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix definition of HWND_BROADCAST in W32API.
|
||||
* Fix memory alignment checking (Issue 121).
|
||||
* Fix Structure equals/hashCode implementation, based on current Java fields rather than strictly native memory contents. Avoid using equals/hashCode when avoiding recursive reads/writes.
|
||||
|
||||
Release 3.2.0
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Handle String, Structure, Callback, Buffer, and primitive arrays in direct mappings. Handle NativeMapped and TypeMapper, with optimized paths for IntegerType and PointerType.
|
||||
* Optionally throw errno/GetLastError as an exception. This is preferred to (and more efficient than) calling Native.getLastError().
|
||||
* Unload/delete native library unpacked from jna.jar if Native class is garbage collected. Only install shutdown hook if using the system class loader.
|
||||
* Auto-write contiguous Structure arrays when first element is written.
|
||||
* Support NativeMapped[] as function arguments for interface-mapped libraries (Issue 90).
|
||||
* Enable function lookup within current process on Windows.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Restrict recursive structure reads/writes by thread instead of globally. This avoids potentially missed reads/writes with concurrent access (Issue 120).
|
||||
* Ensure Memory is not GC'd and freed if direct NIO buffers mapped to it are extant.
|
||||
* Allow types derived from java.nio.Buffer as Structure fields.
|
||||
|
||||
Release 3.1.0
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Add raw JNI mapping of static Java methods. Performance is about 10X that of traditional JNA interface mapping, although with less type conversion functionality.
|
||||
* Add library option to allow passing/return of Java Objects.
|
||||
* Allow handling of uncaught callback exceptions (Issue 63).
|
||||
* Object oriented interface to X server (see contrib/x11)
|
||||
* Make Memory class more accessible.
|
||||
* Provide Structure ctor with Pointer argument (issue 102).
|
||||
* Allow implicit library access to current process on linux (issue 98).
|
||||
* Open all shared libraries with RTLD_GLOBAL, if applicable. This was the default behavior on OSX and changes the default behavior on linux.
|
||||
* Allow NIO Buffer as Structure field (with limitations) (Issue 57)
|
||||
* Add `size_t` size.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Run tests with libjsig.so, if available, which fixes some crashes when running tests on 64-bit platforms.
|
||||
* Fix Issue 104.
|
||||
* Fix Issue 94 (Java 1.6 update 10 regression).
|
||||
* Fix Issue 51 (Java 1.6 update 10 regression).
|
||||
* Fix Issue 95.
|
||||
* Fix Issue 101.
|
||||
* Fix Issue 111, memory leak with String-returning Callback.
|
||||
* Fix missing storage of union type information (affects usage of struct/union by value as argument and return type).
|
||||
* Remove non-functional Structure ctors requiring explicit size.
|
||||
|
||||
Release 3.0.9
|
||||
=============
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* 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 where the incorrect libc.so.6 was being loaded.
|
||||
|
||||
Release 3.0.8
|
||||
==========
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Auto-map Pointer[]/String[]/WString[] return values.
|
||||
* Provide utility functions to convert String to primitive array.
|
||||
* Add jna.library.boot.path property to define the directory that the native stub library is loaded from
|
||||
|
||||
Release 3.0.7
|
||||
==========
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Improve Win32 loading of libraries with dependencies.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix bug reading structures with PointerType fields, introduced with Pointer field preservation fix.
|
||||
|
||||
Release 3.0.6
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Allow arbitrary callback method names if only one method is defined in the class which implements Callback (colinwalters).
|
||||
* Allow specification of callback type mappers by using a TYPE_MAPPER field (colinwalters).
|
||||
* Allow uninitialized (null-valued) boxed primitives in Structures (colinwalters).
|
||||
* Add convenience methods to set active Union field and value simultaneously (xylo).
|
||||
* Augment Union read/writeField to set the active field.
|
||||
* Allow Structure auto-synch across native calls to be disabled.
|
||||
* Win64 support.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Avoid overwriting unchanged Structure fields of type Pointer.
|
||||
* Avoid more content dragging on OSX or warn if it's too late.
|
||||
* Fix UnsatisfiedLinkError using transparent window on Win2K.
|
||||
* Fix memory leak with callbacks called from native threads with no Java context (johnwallace).
|
||||
* Defer structure size calculation if type mapper not yet set, allowing type mapper to be set in derived constructors (colinwalters).
|
||||
* Ensure structure memory is allocated in Structure.read/writeField.
|
||||
|
||||
Release 3.0.5
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Allow explicit declaration of field order for VMs which have an unpredictable field order.
|
||||
* Check for w32 libraries with a "lib" prefix in addition to normal lookup.
|
||||
* Allow String[]/WString[] as callback argument/return value (assume NULL-terminated array).
|
||||
* Add Solaris8 compatibility to sunos-sparc build (Corey Puffalt).
|
||||
* Look up libraries using web start library path, if appropriate (Corey Puffalt).
|
||||
* Use constants to return integer boolean values.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Properly track cursor on alpha-masked windows.
|
||||
* Avoid searching /lib or /usr/lib on 64-bit Linux.
|
||||
* Avoid using incorrect version of a library when both 32- and 64-bit versions are found.
|
||||
* Avoid transparent window events always dragging window bug on OSX.
|
||||
* Fix division by zero error calculating structure size on OSX/ppc.
|
||||
* Avoid overwriting initialized NativeMapped Structure fields when calculating structure size.
|
||||
* Fix NPE reading back into StringArray.
|
||||
|
||||
Release 3.0.4
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Automatically write contents of Structure.ByReference fields on Structure.write().
|
||||
* Use the actual parameter type in Function invocations if no parameter type information is available (whether method is missing or untyped varargs).
|
||||
* Augmented X11 library mappings (xylo).
|
||||
* Support read/write of NativeMapped arrays within Structure (notably NativeLong).
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix library load error when /usr/lib32 and /usr/lib both exist (linux) (Marek Slama).
|
||||
* Avoid incorrect matches against libraries named with the same prefix (e.g. libc-client.so vs libc.so) (xylo).
|
||||
* Properly handle arrays of NativeMapped (e.g. NativeLong) as a Structure field (stefan endrullis).
|
||||
* Ensure structure size calculated prior to setting union active type.
|
||||
* XID is 64-bits on 64-bit X clients (xylo).
|
||||
* Ensure proper arch name is used on Debian (amd64 instead of x86_64).
|
||||
|
||||
Release 3.0.3
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Enable build/run using IBM's J9 VM (leonardo).
|
||||
* Make StdCallFunctionMapper attempt a leading underscore if the simpler mapping doesn't work.
|
||||
* Allow Structure.read to overwrite final fields (may not work on some 1.4 VMs).
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix NPE when passing an array of Structure.ByReference.
|
||||
* Compare entire linux library version when finding a match.
|
||||
* Don't pass struct by value unless the method signature declares it.
|
||||
* Restrict custom first element structure alignment to OSX/ppc.
|
||||
* Improve performance and reduce memory footprint for window masks. Optimize polygon-based masks on w32. Use XFillRectangles on X11.
|
||||
* Fix linkage settings on sunos-amd64 to avoid relocation errors.
|
||||
* Fix callback allocation code on w32, solaris, freebsd, darwin (libffi was misconfigured).
|
||||
* Fix bug when NativeMapped fields are used in a Structure.ByValue instance.
|
||||
* Fix NPE calling Structure.read() before memory is initialized.
|
||||
* Fix NPE calling Structure.read/write with uninitialized NativeMapped fields.
|
||||
|
||||
Release 3.0.2
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Attempt to force unload of jnidispatch library prior to deleting it (w32).
|
||||
* Added amd64 targets for OSX, FreeBSD, and Solaris.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Reduce space allocated for invocation arguments.
|
||||
* Fix NPE when NativeMapped type is used in a Structure.
|
||||
* Fix some X11 type mappings for 64-bit.
|
||||
* Fix OSX Leopard/JRE1.5+ window transparency.
|
||||
* Fix window alpha compositing on X11.
|
||||
* Fix loading of libraries with unicode names on OSX.
|
||||
|
||||
Release 3.0.1
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Improve transparent window drawing performance on w32
|
||||
* Use closure allocation from libffi
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Ensure nested structure arrays initialized with Structure.toArray use the appropriate native memory.
|
||||
* Ensure structure size is calculated prior to converting to array
|
||||
* Avoid creating new windows when setting a window mask
|
||||
* Fix bug in Pointer.setChar.
|
||||
|
||||
Release 3.0
|
||||
===========
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* More supported platforms, via GCC's libffi (wmeissner)
|
||||
* Support struct by value as parameter and return value (duncan)
|
||||
* Support struct by reference within structures
|
||||
* Provide access to native peer for java.awt.Component
|
||||
* Provide access to native peer on OS X.
|
||||
* Support MINGW32 builds (fullung)
|
||||
* Allow per-field Structure read/write by field name
|
||||
* Avoid writing Structure fields marked 'volatile'
|
||||
* Read and wrap function pointers in Structure fields when read with a Java proxy to allow easy Java-side invocation (Ken Larson)
|
||||
* Support array-backed Buffers as arguments (wmeissner)
|
||||
* Auto-conversion of custom types (wmeissner)
|
||||
* Allow pointer type-safety
|
||||
* Optional VM crash protection, via Native.setProtected(boolean)
|
||||
* Auto-convert WString[]
|
||||
* Provide library synchronization wrapper similar to Collections.synchronizedX
|
||||
* Support lookup of OSX framework libraries by name
|
||||
* Explicit access to shared library global data
|
||||
* Invocation interception to facilitate translation of C preprocessor macros and inline functions
|
||||
* Provide utility to determine Web Start native library cache location; auto-include this path if jnidispatch is included as a <nativelib> (robertengels)
|
||||
* Provide access to aligned memory
|
||||
* Versioning information embedded in jna.jar and native library
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Avoid attempts to free native library if it failed to load (wmeissner)
|
||||
* Explicitly check method signatures for varargs instead of heuristically guessing (wmeissner)
|
||||
* Disallow declaring Pointer-derived fields in Structures (Function, Memory)
|
||||
* Ensure Object.toString/hashCode/equals methods are intercepted on proxyied interfaces
|
||||
* Update X11 library for 64-bit use (wmeissner)
|
||||
* Properly map arrays of char*/wchar_t* under w32
|
||||
* Allow Pointer[] as a Structure field and Function argument
|
||||
* Fix some misleading Structure error messages
|
||||
* Properly preserve/return GetLastError/errno after native calls
|
||||
* Allocate executable memory on w32 to avoid errors with hardware-enforced data execution protection (DEP)
|
||||
* Fix VM crash on w32 stdcall callbacks
|
||||
* Use long offsets and sizes rather than ints (64-bit safe)
|
||||
* Properly clean up references and release closure memory on JNI_Unload
|
||||
* Use simpler AWT/JAWT library loading workaround
|
||||
* Avoid changing array references within a Structure on read
|
||||
|
||||
Release 2.5
|
||||
===========
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Unions
|
||||
* Optimized shaped windows (chris deckers & olivier chafik); instantiation time improved by about 2-3 orders of magnitude for large, mostly contiguous shapes
|
||||
* Provide type mapping in callback arguments/results
|
||||
* Provide access to ByteBuffer direct address as a Pointer
|
||||
* Provide customization of native string encoding with jna.encoding system property
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Properly handle VMs with reversed Structure member storage
|
||||
* Avoid making window undecorated when clearing window mask on X11
|
||||
* Fix structure alignment bug on OSX/PPC when first element is > 4 bytes in size
|
||||
* Clearing OSX window mask by setting to MASK_NONE now works properly
|
||||
* Avoid index exceptions if native buffers are not NUL-terminated on string conversions
|
||||
* Write initialized Structure[] argument memory prior to function calls
|
||||
* Fix IllegalArgumentException reading WString into a Structure
|
||||
* Clear memory when allocating a structure block (fixes VM crash)
|
||||
* Remove versioned JAWT dependency on OSX, allowing use on 10.3/JRE1.4.
|
||||
|
||||
Release 2.4
|
||||
===========
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Explicitly support unaligned structures
|
||||
* Auto-reallocate structure arrays
|
||||
* Automatic handling of w32 UNICODE/ASCII variants
|
||||
* Automatic mapping of decorated w32 stdcall function names
|
||||
* Customizable, automatic type conversion of arguments and results (wmeissner)
|
||||
* Support char*[] arguments as Java String[]
|
||||
* Structure supports Callback members (wmeissner)
|
||||
* getByteBuffer from Pointer/Memory (wmeissner)
|
||||
* Allow GC of native libraries
|
||||
* Facilitate use from non-Java contexts (JRuby et al.) (wmeissner)
|
||||
* Improve library path searching (wmeissner)
|
||||
* Handle Structure[] arguments
|
||||
* Handle native long arguments and return values
|
||||
* Handle direct and array-based ByteBuffer arguments (wmeissner)
|
||||
* Change default w32 build to use GCC (it's free, yo)
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Structure.toArray failed to initialize members
|
||||
* Disallow explicit free of Structure/Memory
|
||||
* Ensure native libraries are only loaded once until released
|
||||
* Properly handle NULL when the return value is a Structure
|
||||
* Proper conversion to wchar_t on linux
|
||||
* Copy full length of Java strings to C strings instead of stopping when a NUL character is encountered
|
||||
@@ -1,3 +1,381 @@
|
||||
2013-02-11 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* configure.ac: Update release number to 3.0.12.
|
||||
* configure: Rebuilt.
|
||||
* README: Update release info.
|
||||
|
||||
2013-02-10 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* README: Add Moxie.
|
||||
* src/moxie/ffi.c: Created.
|
||||
* src/moxie/eabi.S: Created.
|
||||
* src/moxie/ffitarget.h: Created.
|
||||
* Makefile.am (nodist_libffi_la_SOURCES): Add Moxie.
|
||||
* Makefile.in: Rebuilt.
|
||||
* configure.ac: Add Moxie.
|
||||
* configure: Rebuilt.
|
||||
* testsuite/libffi.call/huge_struct.c: Disable format string
|
||||
warnings for moxie*-*-elf tests.
|
||||
|
||||
2013-02-10 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* Makefile.am (LTLDFLAGS): Fix reference.
|
||||
* Makefile.in: Rebuilt.
|
||||
|
||||
2013-02-10 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* README: Update supported platforms. Update test results link.
|
||||
|
||||
2013-02-09 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* testsuite/libffi.call/negint.c: Remove forced -O2.
|
||||
* testsuite/libffi.call/many2.c (foo): Remove GCCism.
|
||||
* testsuite/libffi.call/ffitest.h: Add default PRIuPTR definition.
|
||||
|
||||
* src/sparc/v8.S (ffi_closure_v8): Import ancient ulonglong
|
||||
closure return type fix developed by Martin v. Löwis for cpython
|
||||
fork.
|
||||
|
||||
2013-02-08 Andreas Tobler <andreast@fgznet.ch>
|
||||
|
||||
* src/powerpc/ffi.c (ffi_prep_cif_machdep): Fix small struct
|
||||
support.
|
||||
* src/powerpc/sysv.S: Ditto.
|
||||
|
||||
2013-02-08 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* testsuite/libffi.call/cls_longdouble.c: Remove xfail for
|
||||
arm*-*-*.
|
||||
|
||||
2013-02-08 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* src/sparc/ffi.c (ffi_prep_closure_loc): Fix cache flushing for GCC.
|
||||
|
||||
2013-02-08 Matthias Klose <doko@ubuntu.com>
|
||||
|
||||
* man/ffi_prep_cif.3: Clean up for debian linter.
|
||||
|
||||
2013-02-08 Peter Bergner <bergner@vnet.ibm.com>
|
||||
|
||||
* src/powerpc/ffi.c (ffi_prep_args_SYSV): Account for FP args pushed
|
||||
on the stack.
|
||||
|
||||
2013-02-08 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* Makefile.am (EXTRA_DIST): Add missing files.
|
||||
* testsuite/Makefile.am (EXTRA_DIST): Ditto.
|
||||
* Makefile.in: Rebuilt.
|
||||
|
||||
2013-02-08 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* configure.ac: Move sparc asm config checks to within functions
|
||||
for compatibility with sun tools.
|
||||
* configure: Rebuilt.
|
||||
* src/sparc/ffi.c (ffi_prep_closure_loc): Flush cache on v9
|
||||
systems.
|
||||
* src/sparc/v8.S (ffi_flush_icache): Implement a sparc v9 cache
|
||||
flusher.
|
||||
|
||||
2013-02-08 Nathan Rossi <nathan.rossi@xilinx.com>
|
||||
|
||||
* src/microblaze/ffi.c (ffi_closure_call_SYSV): Fix handling of
|
||||
small big-endian structures.
|
||||
(ffi_prep_args): Ditto.
|
||||
|
||||
2013-02-07 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* src/sparc/v8.S (ffi_call_v8): Fix typo from last patch
|
||||
(effectively hiding ffi_call_v8).
|
||||
|
||||
2013-02-07 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* configure.ac: Update bug reporting address.
|
||||
* configure.in: Rebuild.
|
||||
|
||||
* src/sparc/v8.S (ffi_flush_icache): Out-of-line cache flusher for
|
||||
Sun compiler.
|
||||
* src/sparc/ffi.c (ffi_call): Remove warning.
|
||||
Call ffi_flush_icache for non-GCC builds.
|
||||
(ffi_prep_closure_loc): Use ffi_flush_icache.
|
||||
|
||||
* Makefile.am (EXTRA_DIST): Add libtool-ldflags.
|
||||
* Makefile.in: Rebuilt.
|
||||
* libtool-ldflags: New file.
|
||||
|
||||
2013-02-07 Daniel Schepler <dschepler@gmail.com>
|
||||
|
||||
* configure.ac: Correctly identify x32 systems as 64-bit.
|
||||
* m4/libtool.m4: Remove libtool expr error.
|
||||
* aclocal.m4, configure: Rebuilt.
|
||||
|
||||
2013-02-07 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* configure.ac: Fix GCC usage test.
|
||||
* configure: Rebuilt.
|
||||
* README: Mention LLVM/GCC x86_64 issue.
|
||||
* testsuite/Makefile.in: Rebuilt.
|
||||
|
||||
2013-02-07 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* testsuite/libffi.call/cls_double_va.c (main): Replace // style
|
||||
comments with /* */ for xlc compiler.
|
||||
* testsuite/libffi.call/stret_large.c (main): Ditto.
|
||||
* testsuite/libffi.call/stret_large2.c (main): Ditto.
|
||||
* testsuite/libffi.call/nested_struct1.c (main): Ditto.
|
||||
* testsuite/libffi.call/huge_struct.c (main): Ditto.
|
||||
* testsuite/libffi.call/float_va.c (main): Ditto.
|
||||
* testsuite/libffi.call/cls_struct_va1.c (main): Ditto.
|
||||
* testsuite/libffi.call/cls_pointer_stack.c (main): Ditto.
|
||||
* testsuite/libffi.call/cls_pointer.c (main): Ditto.
|
||||
* testsuite/libffi.call/cls_longdouble_va.c (main): Ditto.
|
||||
|
||||
2013-02-06 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* man/ffi_prep_cif.3: Clean up for debian lintian checker.
|
||||
|
||||
2013-02-06 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* Makefile.am (pkgconfigdir): Add missing pkgconfig install bits.
|
||||
* Makefile.in: Rebuild.
|
||||
|
||||
2013-02-02 Mark H Weaver <mhw@netris.org>
|
||||
|
||||
* src/x86/ffi64.c (ffi_call): Sign-extend integer arguments passed
|
||||
via general purpose registers.
|
||||
|
||||
2013-01-21 Nathan Rossi <nathan.rossi@xilinx.com>
|
||||
|
||||
* README: Add MicroBlaze details.
|
||||
* Makefile.am: Add MicroBlaze support.
|
||||
* configure.ac: Likewise.
|
||||
* src/microblaze/ffi.c: New.
|
||||
* src/microblaze/ffitarget.h: Likewise.
|
||||
* src/microblaze/sysv.S: Likewise.
|
||||
|
||||
2013-01-21 Nathan Rossi <nathan.rossi@xilinx.com>
|
||||
* testsuite/libffi.call/return_uc.c: Fixed issue.
|
||||
|
||||
2013-01-21 Chris Zankel <chris@zankel.net>
|
||||
|
||||
* README: Add Xtensa support.
|
||||
* Makefile.am: Likewise.
|
||||
* configure.ac: Likewise.
|
||||
* Makefile.in Regenerate.
|
||||
* configure: Likewise.
|
||||
* src/prep_cif.c: Handle Xtensa.
|
||||
* src/xtensa: New directory.
|
||||
* src/xtensa/ffi.c: New file.
|
||||
* src/xtensa/ffitarget.h: Ditto.
|
||||
* src/xtensa/sysv.S: Ditto.
|
||||
|
||||
2013-01-11 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* src/powerpc/ffi_darwin.c (ffi_prep_args): Replace // style
|
||||
comments with /* */ for xlc compiler.
|
||||
* src/powerpc/aix.S (ffi_call_AIX): Ditto.
|
||||
* testsuite/libffi.call/ffitest.h (allocate_mmap): Delete
|
||||
deprecated inline function.
|
||||
* testsuite/libffi.special/ffitestcxx.h: Ditto.
|
||||
* README: Add update for AIX support.
|
||||
|
||||
2013-01-11 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* configure.ac: Robustify pc relative reloc check.
|
||||
* m4/ax_cc_maxopt.m4: Don't -malign-double. This is an ABI
|
||||
changing option for 32-bit x86.
|
||||
* aclocal.m4, configure: Rebuilt.
|
||||
* README: Update supported target list.
|
||||
|
||||
2013-01-10 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* README (tested): Add Compiler column to table.
|
||||
|
||||
2013-01-10 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* src/x86/ffi64.c (struct register_args): Make sse array and array
|
||||
of unions for sunpro compiler compatibility.
|
||||
|
||||
2013-01-10 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* configure.ac: Test target platform size_t size. Handle both 32
|
||||
and 64-bit builds for x86_64-* and i?86-* targets (allowing for
|
||||
CFLAG option to change default settings).
|
||||
* configure, aclocal.m4: Rebuilt.
|
||||
|
||||
2013-01-10 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* testsuite/libffi.special/special.exp: Only run exception
|
||||
handling tests when using GNU compiler.
|
||||
|
||||
* m4/ax_compiler_vendor.m4: New file.
|
||||
* configure.ac: Test for compiler vendor and don't use
|
||||
AX_CFLAGS_WARN_ALL with the sun compiler.
|
||||
* aclocal.m4, configure: Rebuilt.
|
||||
|
||||
2013-01-10 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* include/ffi_common.h: Don't use GCCisms to define types when
|
||||
building with the SUNPRO compiler.
|
||||
|
||||
2013-01-10 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* configure.ac: Put local.exp in the right place.
|
||||
* configure: Rebuilt.
|
||||
|
||||
* src/x86/ffi.c: Update comment about regparm function attributes.
|
||||
* src/x86/sysv.S (ffi_closure_SYSV): The SUNPRO compiler requires
|
||||
that all function arguments be passed on the stack (no regparm
|
||||
support).
|
||||
|
||||
2013-01-08 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* configure.ac: Generate local.exp. This sets CC_FOR_TARGET
|
||||
when we are using the vendor compiler.
|
||||
* testsuite/Makefile.am (EXTRA_DEJAGNU_SITE_CONFIG): Point to
|
||||
../local.exp.
|
||||
* configure, testsuite/Makefile.in: Rebuilt.
|
||||
|
||||
* testsuite/libffi.call/call.exp: Run tests with different
|
||||
options, depending on whether or not we are using gcc or the
|
||||
vendor compiler.
|
||||
* testsuite/lib/libffi.exp (libffi-init): Set using_gcc based on
|
||||
whether or not we are building/testing with gcc.
|
||||
|
||||
2013-01-08 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* configure.ac: Switch x86 solaris target to X86 by default.
|
||||
* configure: Rebuilt.
|
||||
|
||||
2013-01-08 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* configure.ac: Fix test for read-only eh_frame.
|
||||
* configure: Rebuilt.
|
||||
|
||||
2013-01-08 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* src/x86/sysv.S, src/x86/unix64.S: Only emit DWARF unwind info
|
||||
when building with the GNU toolchain.
|
||||
* testsuite/libffi.call/ffitest.h (CHECK): Fix for Solaris vendor
|
||||
compiler.
|
||||
|
||||
2013-01-07 Thorsten Glaser <tg@mirbsd.org>
|
||||
|
||||
* testsuite/libffi.call/cls_uchar_va.c,
|
||||
testsuite/libffi.call/cls_ushort_va.c,
|
||||
testsuite/libffi.call/va_1.c: Testsuite fixes.
|
||||
|
||||
2013-01-07 Thorsten Glaser <tg@mirbsd.org>
|
||||
|
||||
* src/m68k/ffi.c (CIF_FLAGS_SINT8, CIF_FLAGS_SINT16): Define.
|
||||
(ffi_prep_cif_machdep): Fix 8-bit and 16-bit signed calls.
|
||||
* src/m68k/sysv.S (ffi_call_SYSV, ffi_closure_SYSV): Ditto.
|
||||
|
||||
2013-01-04 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* Makefile.am (AM_CFLAGS): Don't automatically add -fexceptions
|
||||
and -Wall. This is set in the configure script after testing for
|
||||
GCC.
|
||||
* Makefile.in: Rebuilt.
|
||||
|
||||
2013-01-02 rofl0r <https://github.com/rofl0r>
|
||||
|
||||
* src/powerpc/ffi.c (ffi_prep_cif_machdep): Fix build error on ppc
|
||||
when long double == double.
|
||||
|
||||
2013-01-02 Reini Urban <rurban@x-ray.at>
|
||||
|
||||
* Makefile.am (libffi_la_LDFLAGS): Add -no-undefined to LDFLAGS
|
||||
(required for shared libs on cygwin/mingw).
|
||||
* Makefile.in: Rebuilt.
|
||||
|
||||
2012-10-31 Alan Modra <amodra@gmail.com>
|
||||
|
||||
* src/powerpc/linux64_closure.S: Add new ABI support.
|
||||
* src/powerpc/linux64.S: Likewise.
|
||||
|
||||
2012-10-30 Magnus Granberg <zorry@gentoo.org>
|
||||
Pavel Labushev <pavel.labushev@runbox.ru>
|
||||
|
||||
* configure.ac: New options pax_emutramp
|
||||
* configure, fficonfig.h.in: Regenerated
|
||||
* src/closures.c: New function emutramp_enabled_check() and
|
||||
checks.
|
||||
|
||||
2012-10-30 Frederick Cheung <frederick.cheung@gmail.com>
|
||||
|
||||
* configure.ac: Enable FFI_MAP_EXEC_WRIT for Darwin 12 (mountain
|
||||
lion) and future version.
|
||||
* configure: Rebuild.
|
||||
|
||||
2012-10-30 James Greenhalgh <james.greenhalgh at arm.com>
|
||||
Marcus Shawcroft <marcus.shawcroft at arm.com>
|
||||
|
||||
* README: Add details of aarch64 port.
|
||||
* src/aarch64/ffi.c: New.
|
||||
* src/aarch64/ffitarget.h: Likewise.
|
||||
* src/aarch64/sysv.S: Likewise.
|
||||
* Makefile.am: Support aarch64.
|
||||
* configure.ac: Support aarch64.
|
||||
* Makefile.in, configure: Rebuilt.
|
||||
|
||||
2012-10-30 James Greenhalgh <james.greenhalgh at arm.com>
|
||||
Marcus Shawcroft <marcus.shawcroft at arm.com>
|
||||
|
||||
* testsuite/lib/libffi.exp: Add support for aarch64.
|
||||
* testsuite/libffi.call/cls_struct_va1.c: New.
|
||||
* testsuite/libffi.call/cls_uchar_va.c: Likewise.
|
||||
* testsuite/libffi.call/cls_uint_va.c: Likewise.
|
||||
* testsuite/libffi.call/cls_ulong_va.c: Likewise.
|
||||
* testsuite/libffi.call/cls_ushort_va.c: Likewise.
|
||||
* testsuite/libffi.call/nested_struct11.c: Likewise.
|
||||
* testsuite/libffi.call/uninitialized.c: Likewise.
|
||||
* testsuite/libffi.call/va_1.c: Likewise.
|
||||
* testsuite/libffi.call/va_struct1.c: Likewise.
|
||||
* testsuite/libffi.call/va_struct2.c: Likewise.
|
||||
* testsuite/libffi.call/va_struct3.c: Likewise.
|
||||
|
||||
2012-10-12 Walter Lee <walt@tilera.com>
|
||||
|
||||
* Makefile.am: Add TILE-Gx/TILEPro support.
|
||||
* configure.ac: Likewise.
|
||||
* Makefile.in: Regenerate.
|
||||
* configure: Likewise.
|
||||
* src/prep_cif.c (ffi_prep_cif_core): Handle TILE-Gx/TILEPro.
|
||||
* src/tile: New directory.
|
||||
* src/tile/ffi.c: New file.
|
||||
* src/tile/ffitarget.h: Ditto.
|
||||
* src/tile/tile.S: Ditto.
|
||||
|
||||
2012-10-12 Matthias Klose <doko@ubuntu.com>
|
||||
|
||||
* generate-osx-source-and-headers.py: Normalize whitespace.
|
||||
|
||||
2012-09-14 David Edelsohn <dje.gcc@gmail.com>
|
||||
|
||||
* configure: Regenerated.
|
||||
|
||||
2012-08-26 Andrew Pinski <apinski@cavium.com>
|
||||
|
||||
PR libffi/53014
|
||||
* src/mips/ffi.c (ffi_prep_closure_loc): Allow n32 with soft-float and n64 with
|
||||
soft-float.
|
||||
|
||||
2012-08-08 Uros Bizjak <ubizjak@gmail.com>
|
||||
|
||||
* src/s390/ffi.c (ffi_prep_closure_loc): Don't ASSERT ABI test,
|
||||
just return FFI_BAD_ABI when things are wrong.
|
||||
|
||||
2012-07-18 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
PR libffi/53982
|
||||
PR libffi/53973
|
||||
* src/x86/ffitarget.h: Check __ILP32__ instead of __LP64__ for x32.
|
||||
(FFI_SIZEOF_JAVA_RAW): Defined to 4 for x32.
|
||||
|
||||
2012-05-16 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* configure: Regenerated.
|
||||
|
||||
2012-05-05 Nicolas Lelong
|
||||
|
||||
* libffi.xcodeproj/project.pbxproj: Fixes.
|
||||
@@ -9,7 +387,6 @@
|
||||
* Makefile.am: Add Blackfin/sysv support
|
||||
* src/bfin/ffi.c: Add Blackfin/sysv support
|
||||
* src/bfin/ffitarget.h: Add Blackfin/sysv support
|
||||
* src/bfin/sysv.S: Add Blackfin/sysv support
|
||||
|
||||
2012-04-11 Anthony Green <green@moxielogic.com>
|
||||
|
||||
@@ -40,15 +417,15 @@
|
||||
* README: Update instructions on building iOS binary.
|
||||
* build-ios.sh: Delete.
|
||||
|
||||
2012-04-06 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* m4/libtool.m4 (_LT_ENABLE_LOCK): Support x32.
|
||||
|
||||
2012-04-06 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* src/x86/ffi64.c (UINT128): Define differently for Intel and GNU
|
||||
compilers, then use it.
|
||||
|
||||
2012-04-06 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* m4/libtool.m4 (_LT_ENABLE_LOCK): Support x32.
|
||||
|
||||
2012-04-06 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* testsuite/Makefile.am (EXTRA_DIST): Add missing test cases.
|
||||
@@ -61,6 +438,14 @@
|
||||
in CNAME.
|
||||
* src/x86/ffi.c: Wrap Windows specific code in ifdefs.
|
||||
|
||||
2012-04-02 Peter Bergner <bergner@vnet.ibm.com>
|
||||
|
||||
* src/powerpc/ffi.c (ffi_prep_args_SYSV): Declare double_tmp.
|
||||
Silence casting pointer to integer of different size warning.
|
||||
Delete goto to previously deleted label.
|
||||
(ffi_call): Silence possibly undefined warning.
|
||||
(ffi_closure_helper_SYSV): Declare variable type.
|
||||
|
||||
2012-04-02 Peter Rosin <peda@lysator.liu.se>
|
||||
|
||||
* src/x86/win32.S (ffi_call_win32): Sign/zero extend the return
|
||||
@@ -206,14 +591,6 @@
|
||||
* testsuite/libffi.call/struct9.c: Likewise.
|
||||
* testsuite/libffi.call/testclosure.c: Likewise.
|
||||
|
||||
2012-03-06 Chung-Lin Tang <cltang@codesourcery.com>
|
||||
|
||||
* src/arm/ffi.c (ffi_call): Add __ARM_EABI__ guard around call to
|
||||
ffi_call_VFP().
|
||||
(ffi_prep_closure_loc): Add __ARM_EABI__ guard around use of
|
||||
ffi_closure_VFP.
|
||||
* src/arm/sysv.S: Add __ARM_EABI__ guard around VFP code.
|
||||
|
||||
2012-03-21 Peter Rosin <peda@lysator.liu.se>
|
||||
|
||||
* testsuite/libffi.call/float_va.c (float_va_fn): Use %f when
|
||||
@@ -227,6 +604,19 @@
|
||||
(and save PATH for later).
|
||||
(restore_ld_library_path_env_vars): Restore PATH.
|
||||
|
||||
2012-03-21 Peter Rosin <peda@lysator.liu.se>
|
||||
|
||||
* testsuite/lib/target-libpath.exp [*-*-cygwin*, *-*-mingw*]
|
||||
(set_ld_library_path_env_vars): Add the library search dir to PATH
|
||||
(and save PATH for later).
|
||||
(restore_ld_library_path_env_vars): Restore PATH.
|
||||
|
||||
2012-03-20 Peter Rosin <peda@lysator.liu.se>
|
||||
|
||||
* testsuite/libffi.call/strlen2_win32.c (main): Remove bug.
|
||||
* src/x86/win32.S [MSVC] (ffi_closure_SYSV): Make the 'stub' label
|
||||
visible outside the PROC, so that ffi_closure_THISCALL can see it.
|
||||
|
||||
2012-03-20 Peter Rosin <peda@lysator.liu.se>
|
||||
|
||||
* testsuite/libffi.call/strlen2_win32.c (main): Remove bug.
|
||||
@@ -238,19 +628,19 @@
|
||||
* src/m68k/ffi.c: Add MINT support.
|
||||
* src/m68k/sysv.S: Ditto.
|
||||
|
||||
2012-03-06 Chung-Lin Tang <cltang@codesourcery.com>
|
||||
|
||||
* src/arm/ffi.c (ffi_call): Add __ARM_EABI__ guard around call to
|
||||
ffi_call_VFP().
|
||||
(ffi_prep_closure_loc): Add __ARM_EABI__ guard around use of
|
||||
ffi_closure_VFP.
|
||||
* src/arm/sysv.S: Add __ARM_EABI__ guard around VFP code.
|
||||
|
||||
2012-03-19 chennam <csit@axway.com>
|
||||
|
||||
* src/powerpc/ffi_darwin.c (ffi_prep_closure_loc): Fix AIX closure
|
||||
support.
|
||||
|
||||
2012-04-02 Peter Bergner <bergner@vnet.ibm.com>
|
||||
|
||||
* src/powerpc/ffi.c (ffi_prep_args_SYSV): Declare double_tmp.
|
||||
Silence casting pointer to integer of different size warning.
|
||||
Delete goto to previously deleted label.
|
||||
(ffi_call): Silence possibly undefined warning.
|
||||
(ffi_closure_helper_SYSV): Declare variable type.
|
||||
|
||||
2012-03-13 Kaz Kojima <kkojima@gcc.gnu.org>
|
||||
|
||||
* src/sh/ffi.c (ffi_prep_closure_loc): Don't ASSERT ABI test,
|
||||
@@ -574,8 +574,8 @@
|
||||
* Makefile.am, include/Makefile.am: Move headers to
|
||||
libffi_la_SOURCES for new automake.
|
||||
* Makefile.in, include/Makefile.in: Rebuilt.
|
||||
|
||||
* testsuite/lib/wrapper.exp: Copied from gcc tree to allow for
|
||||
|
||||
* testsuite/lib/wrapper.exp: Copied from gcc tree to allow for
|
||||
execution outside of gcc tree.
|
||||
* testsuite/lib/target-libpath.exp: Ditto.
|
||||
|
||||
Arquivo executável → Arquivo normal
+21
-504
@@ -1,504 +1,21 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
||||
libffi - Copyright (c) 1996-2012 Anthony Green, Red Hat, Inc and others.
|
||||
See source files for details.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
``Software''), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@@ -2,41 +2,49 @@
|
||||
|
||||
AUTOMAKE_OPTIONS = foreign subdir-objects
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
SUBDIRS = include testsuite man
|
||||
|
||||
EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj configure.host \
|
||||
src/alpha/ffi.c src/alpha/osf.S src/alpha/ffitarget.h \
|
||||
src/arm/ffi.c src/arm/sysv.S src/arm/ffitarget.h \
|
||||
src/avr32/ffi.c src/avr32/sysv.S src/avr32/ffitarget.h \
|
||||
src/cris/ffi.c src/cris/sysv.S src/cris/ffitarget.h \
|
||||
src/ia64/ffi.c src/ia64/ffitarget.h src/ia64/ia64_flags.h \
|
||||
src/ia64/unix.S src/mips/ffi.c src/mips/n32.S src/mips/o32.S \
|
||||
src/mips/ffitarget.h src/m32r/ffi.c src/m32r/sysv.S \
|
||||
src/m32r/ffitarget.h src/m68k/ffi.c src/m68k/sysv.S \
|
||||
src/m68k/ffitarget.h src/powerpc/ffi.c src/powerpc/sysv.S \
|
||||
src/powerpc/linux64.S src/powerpc/linux64_closure.S \
|
||||
src/powerpc/ppc_closure.S src/powerpc/asm.h src/powerpc/aix.S \
|
||||
src/powerpc/darwin.S src/powerpc/aix_closure.S \
|
||||
src/powerpc/darwin_closure.S src/powerpc/ffi_darwin.c \
|
||||
src/powerpc/ffitarget.h src/s390/ffi.c src/s390/sysv.S \
|
||||
src/s390/ffitarget.h src/sh/ffi.c src/sh/sysv.S \
|
||||
src/sh/ffitarget.h 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/darwin64.S \
|
||||
src/x86/ffi.c src/x86/sysv.S src/x86/win32.S src/x86/darwin.S \
|
||||
src/x86/win64.S src/x86/freebsd.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/bfin/ffi.c src/bfin/ffitarget.h src/bfin/sysv.S \
|
||||
src/frv/eabi.S src/frv/ffitarget.h src/dlmalloc.c \
|
||||
src/moxie/ffi.c src/moxie/eabi.S libtool-version \
|
||||
ChangeLog.libffi m4/libtool.m4 m4/lt~obsolete.m4 \
|
||||
m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 \
|
||||
m4/ltversion.m4 src/arm/gentramp.sh src/debug.c \
|
||||
msvcc.sh generate-ios-source-and-headers.py \
|
||||
generate-osx-source-and-headers.py \
|
||||
libffi.xcodeproj/project.pbxproj \
|
||||
src/arm/trampoline.S
|
||||
EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj configure.host \
|
||||
src/aarch64/ffi.c src/aarch64/ffitarget.h \
|
||||
src/aarch64/sysv.S build-ios.sh \
|
||||
src/alpha/ffi.c src/alpha/osf.S src/alpha/ffitarget.h \
|
||||
src/arm/ffi.c src/arm/sysv.S src/arm/ffitarget.h \
|
||||
src/avr32/ffi.c src/avr32/sysv.S src/avr32/ffitarget.h \
|
||||
src/cris/ffi.c src/cris/sysv.S src/cris/ffitarget.h \
|
||||
src/ia64/ffi.c src/ia64/ffitarget.h src/ia64/ia64_flags.h \
|
||||
src/ia64/unix.S src/mips/ffi.c src/mips/n32.S src/mips/o32.S \
|
||||
src/mips/ffitarget.h src/m32r/ffi.c src/m32r/sysv.S \
|
||||
src/m32r/ffitarget.h src/m68k/ffi.c src/m68k/sysv.S \
|
||||
src/m68k/ffitarget.h src/microblaze/ffi.c \
|
||||
src/microblaze/sysv.S src/microblaze/ffitarget.h \
|
||||
src/powerpc/ffi.c src/powerpc/sysv.S \
|
||||
src/powerpc/linux64.S src/powerpc/linux64_closure.S \
|
||||
src/powerpc/ppc_closure.S src/powerpc/asm.h \
|
||||
src/powerpc/aix.S src/powerpc/darwin.S \
|
||||
src/powerpc/aix_closure.S src/powerpc/darwin_closure.S \
|
||||
src/powerpc/ffi_darwin.c src/powerpc/ffitarget.h \
|
||||
src/s390/ffi.c src/s390/sysv.S src/s390/ffitarget.h \
|
||||
src/sh/ffi.c src/sh/sysv.S src/sh/ffitarget.h 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/darwin64.S src/x86/ffi.c src/x86/sysv.S \
|
||||
src/x86/win32.S src/x86/darwin.S src/x86/win64.S \
|
||||
src/x86/freebsd.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/bfin/ffi.c \
|
||||
src/bfin/ffitarget.h src/bfin/sysv.S src/frv/eabi.S \
|
||||
src/frv/ffitarget.h src/dlmalloc.c src/tile/ffi.c \
|
||||
src/tile/ffitarget.h src/tile/tile.S libtool-version \
|
||||
src/xtensa/ffitarget.h src/xtensa/ffi.c src/xtensa/sysv.S \
|
||||
ChangeLog.libffi m4/libtool.m4 m4/lt~obsolete.m4 \
|
||||
m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 \
|
||||
m4/ltversion.m4 src/arm/gentramp.sh src/debug.c msvcc.sh \
|
||||
generate-ios-source-and-headers.py \
|
||||
generate-osx-source-and-headers.py \
|
||||
libffi.xcodeproj/project.pbxproj src/arm/trampoline.S \
|
||||
libtool-ldflags
|
||||
|
||||
info_TEXINFOS = doc/libffi.texi
|
||||
|
||||
@@ -84,11 +92,12 @@ AM_MAKEFLAGS = \
|
||||
"RANLIB=$(RANLIB)" \
|
||||
"DESTDIR=$(DESTDIR)"
|
||||
|
||||
# Subdir rules rely on $(FLAGS_TO_PASS)
|
||||
FLAGS_TO_PASS = $(AM_MAKEFLAGS)
|
||||
|
||||
MAKEOVERRIDES=
|
||||
|
||||
ACLOCAL_AMFLAGS=$(ACLOCAL_AMFLAGS) -I m4
|
||||
|
||||
lib_LTLIBRARIES = libffi.la
|
||||
toolexeclib_LTLIBRARIES = libffi.la
|
||||
noinst_LTLIBRARIES = libffi_convenience.la
|
||||
|
||||
libffi_la_SOURCES = src/prep_cif.c src/types.c \
|
||||
@@ -139,6 +148,12 @@ endif
|
||||
if M68K
|
||||
nodist_libffi_la_SOURCES += src/m68k/ffi.c src/m68k/sysv.S
|
||||
endif
|
||||
if MOXIE
|
||||
nodist_libffi_la_SOURCES += src/moxie/ffi.c src/moxie/eabi.S
|
||||
endif
|
||||
if MICROBLAZE
|
||||
nodist_libffi_la_SOURCES += src/microblaze/ffi.c src/microblaze/sysv.S
|
||||
endif
|
||||
if POWERPC
|
||||
nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S src/powerpc/linux64.S src/powerpc/linux64_closure.S
|
||||
endif
|
||||
@@ -151,6 +166,9 @@ endif
|
||||
if POWERPC_FREEBSD
|
||||
nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S
|
||||
endif
|
||||
if AARCH64
|
||||
nodist_libffi_la_SOURCES += src/aarch64/sysv.S src/aarch64/ffi.c
|
||||
endif
|
||||
if ARM
|
||||
nodist_libffi_la_SOURCES += src/arm/sysv.S src/arm/ffi.c
|
||||
if FFI_EXEC_TRAMPOLINE_TABLE
|
||||
@@ -166,9 +184,6 @@ endif
|
||||
if FRV
|
||||
nodist_libffi_la_SOURCES += src/frv/eabi.S src/frv/ffi.c
|
||||
endif
|
||||
if MOXIE
|
||||
nodist_libffi_la_SOURCES += src/moxie/eabi.S src/moxie/ffi.c
|
||||
endif
|
||||
if S390
|
||||
nodist_libffi_la_SOURCES += src/s390/sysv.S src/s390/ffi.c
|
||||
endif
|
||||
@@ -187,23 +202,20 @@ endif
|
||||
if PA_HPUX
|
||||
nodist_libffi_la_SOURCES += src/pa/hpux32.S src/pa/ffi.c
|
||||
endif
|
||||
if TILE
|
||||
nodist_libffi_la_SOURCES += src/tile/tile.S src/tile/ffi.c
|
||||
endif
|
||||
if XTENSA
|
||||
nodist_libffi_la_SOURCES += src/xtensa/sysv.S src/xtensa/ffi.c
|
||||
endif
|
||||
|
||||
libffi_convenience_la_SOURCES = $(libffi_la_SOURCES)
|
||||
nodist_libffi_convenience_la_SOURCES = $(nodist_libffi_la_SOURCES)
|
||||
|
||||
AM_CFLAGS =
|
||||
if FFI_DEBUG
|
||||
# Build debug. Define FFI_DEBUG on the commandline so that, when building with
|
||||
# MSVC, it can link against the debug CRT.
|
||||
AM_CFLAGS += -DFFI_DEBUG
|
||||
endif
|
||||
LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/libtool-ldflags $(LDFLAGS))
|
||||
|
||||
libffi_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(LTLDFLAGS) $(AM_LTLDFLAGS)
|
||||
libffi_la_LDFLAGS = -no-undefined -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(LTLDFLAGS) $(AM_LTLDFLAGS)
|
||||
|
||||
AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src -DFFI_BUILDING
|
||||
AM_CCASFLAGS = $(AM_CPPFLAGS)
|
||||
AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
|
||||
AM_CCASFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
# No install-html or install-pdf support in automake yet
|
||||
.PHONY: install-html install-pdf
|
||||
install-html:
|
||||
install-pdf:
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
-33
@@ -1,33 +0,0 @@
|
||||
* RELATED and/or SIMILAR PROJECTS:
|
||||
* Feel free to add notes and/or descriptions here (this should probably go
|
||||
* on a wiki somewhere).
|
||||
----
|
||||
* nlink.dev.java.net:
|
||||
pros: simple definitions (same as jna)
|
||||
cons: w32 only
|
||||
* sf.net/projects/jnative:
|
||||
cons: boilerplate, manual code generation by calling setup methods
|
||||
pros: callbacks, byref args?
|
||||
* JNIWrapper: kinda like jnative (commercial), includes platform "packs"
|
||||
* coroutine for Java, like jnative (commercial)
|
||||
* jnieasy: c++ mappings (http://www.innowhere.com:8080/webapp/jsp/products/jnieasy/index.jsp?_page=products.jnieasy)
|
||||
* j2native (www.smardec.com)
|
||||
* j-interop.sf.net
|
||||
* jawinproject.sf.net (COM DLL access)
|
||||
* jacob-project.sf.net (COM DLL access)
|
||||
* nativecall.sf.net (minimal)
|
||||
* cxxwrap.sf.net
|
||||
* J/Direct (defunct)
|
||||
* NoodleGlue
|
||||
* SWIG
|
||||
* ctypes4j.sf.net
|
||||
* ctypes-java (out of date)
|
||||
* jnbridge
|
||||
* xFunction (http://excelsior-usa.com/xfunction.html, commercial, osx)
|
||||
* JACE c++ mappings
|
||||
* JAW Java API wrapper http://www.aplu.ch/home/apluhome.jsp?site=5
|
||||
|
||||
# OTHER REFERENCES
|
||||
# JNI options: http://staff.develop.com/halloway/JavaWin32.html
|
||||
# List of JNI alternatives: http://weblog.janek.org/Archive/2005/07/28/AlternativestoJavaNativeI.html
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
Status
|
||||
======
|
||||
|
||||
libffi-3.0.XX was released on XXXXXXX. Check the libffi web page for
|
||||
updates: <URL:http://sourceware.org/libffi/>.
|
||||
libffi-3.0.12 was released on February 11, 2013. Check the libffi web
|
||||
page for updates: <URL:http://sourceware.org/libffi/>.
|
||||
|
||||
|
||||
What is libffi?
|
||||
@@ -43,55 +43,69 @@ Libffi has been ported to many different platforms.
|
||||
For specific configuration details and testing status, please
|
||||
refer to the wiki page here:
|
||||
|
||||
http://www.moxielogic.org/wiki/index.php?title=Libffi_3.0.11
|
||||
http://www.moxielogic.org/wiki/index.php?title=Libffi_3.0.12
|
||||
|
||||
At the time of release, the following basic configurations have been
|
||||
tested:
|
||||
|
||||
|--------------+------------------|
|
||||
| Architecture | Operating System |
|
||||
|--------------+------------------|
|
||||
| Alpha | Linux |
|
||||
| Alpha | Tru64 |
|
||||
| ARM | Linux |
|
||||
| ARM | iOS |
|
||||
| AVR32 | Linux |
|
||||
| Blackfin | uClinux |
|
||||
| HPPA | HPUX |
|
||||
| IA-64 | Linux |
|
||||
| M68K | FreeMiNT |
|
||||
| M68K | RTEMS |
|
||||
| MIPS | IRIX |
|
||||
| MIPS | Linux |
|
||||
| MIPS | RTEMS |
|
||||
| MIPS64 | Linux |
|
||||
| PowerPC | AMIGA |
|
||||
| PowerPC | Linux |
|
||||
| PowerPC | Mac OSX |
|
||||
| PowerPC | FreeBSD |
|
||||
| PowerPC64 | Linux |
|
||||
| S390 | Linux |
|
||||
| S390X | Linux |
|
||||
| SPARC | Linux |
|
||||
| SPARC | Solaris |
|
||||
| SPARC64 | Linux |
|
||||
| SPARC64 | FreeBSD |
|
||||
| X86 | FreeBSD |
|
||||
| X86 | Interix |
|
||||
| X86 | kFreeBSD |
|
||||
| X86 | Linux |
|
||||
| X86 | Mac OSX |
|
||||
| X86 | OpenBSD |
|
||||
| X86 | OS/2 |
|
||||
| X86 | Solaris |
|
||||
| X86 | Windows/Cygwin |
|
||||
| X86 | Windows/MingW |
|
||||
| X86-64 | FreeBSD |
|
||||
| X86-64 | Linux |
|
||||
| X86-64 | Linux/x32 |
|
||||
| X86-64 | OpenBSD |
|
||||
| X86-64 | Windows/MingW |
|
||||
|--------------+------------------|
|
||||
|-----------------+------------------+-------------------------|
|
||||
| Architecture | Operating System | Compiler |
|
||||
|-----------------+------------------+-------------------------|
|
||||
| AArch64 | Linux | GCC |
|
||||
| Alpha | Linux | GCC |
|
||||
| Alpha | Tru64 | GCC |
|
||||
| ARM | Linux | GCC |
|
||||
| ARM | iOS | GCC |
|
||||
| AVR32 | Linux | GCC |
|
||||
| Blackfin | uClinux | GCC |
|
||||
| HPPA | HPUX | GCC |
|
||||
| IA-64 | Linux | GCC |
|
||||
| M68K | FreeMiNT | GCC |
|
||||
| M68K | Linux | GCC |
|
||||
| M68K | RTEMS | GCC |
|
||||
| MicroBlaze | Linux | GCC |
|
||||
| MIPS | IRIX | GCC |
|
||||
| MIPS | Linux | GCC |
|
||||
| MIPS | RTEMS | GCC |
|
||||
| MIPS64 | Linux | GCC |
|
||||
| Moxie | Bare metal | GCC
|
||||
| PowerPC 32-bit | AIX | IBM XL C |
|
||||
| PowerPC 64-bit | AIX | IBM XL C |
|
||||
| PowerPC | AMIGA | GCC |
|
||||
| PowerPC | Linux | GCC |
|
||||
| PowerPC | Mac OSX | GCC |
|
||||
| PowerPC | FreeBSD | GCC |
|
||||
| PowerPC 64-bit | FreeBSD | GCC |
|
||||
| PowerPC 64-bit | Linux | GCC |
|
||||
| S390 | Linux | GCC |
|
||||
| S390X | Linux | GCC |
|
||||
| SPARC | Linux | GCC |
|
||||
| SPARC | Solaris | GCC |
|
||||
| SPARC | Solaris | Oracle Solaris Studio C |
|
||||
| SPARC64 | Linux | GCC |
|
||||
| SPARC64 | FreeBSD | GCC |
|
||||
| SPARC64 | Solaris | Oracle Solaris Studio C |
|
||||
| TILE-Gx/TILEPro | Linux | GCC |
|
||||
| X86 | FreeBSD | GCC |
|
||||
| X86 | GNU HURD | GCC |
|
||||
| X86 | Interix | GCC |
|
||||
| X86 | kFreeBSD | GCC |
|
||||
| X86 | Linux | GCC |
|
||||
| X86 | Mac OSX | GCC |
|
||||
| X86 | OpenBSD | GCC |
|
||||
| X86 | OS/2 | GCC |
|
||||
| X86 | Solaris | GCC |
|
||||
| X86 | Solaris | Oracle Solaris Studio C |
|
||||
| X86 | Windows/Cygwin | GCC |
|
||||
| X86 | Windows/MingW | GCC |
|
||||
| X86-64 | FreeBSD | GCC |
|
||||
| X86-64 | Linux | GCC |
|
||||
| X86-64 | Linux/x32 | GCC |
|
||||
| X86-64 | OpenBSD | GCC |
|
||||
| X86-64 | Solaris | Oracle Solaris Studio C |
|
||||
| X86-64 | Windows/MingW | GCC |
|
||||
| Xtensa | Linux | GCC |
|
||||
|-----------------+------------------+-------------------------|
|
||||
|
||||
Please send additional platform test results to
|
||||
libffi-discuss@sourceware.org and feel free to update the wiki page
|
||||
@@ -135,7 +149,7 @@ For iOS builds, the 'libffi.xcodeproj' Xcode project is available.
|
||||
Configure has many other options. Use "configure --help" to see them all.
|
||||
|
||||
Once configure has finished, type "make". Note that you must be using
|
||||
GNU make. You can ftp GNU make from prep.ai.mit.edu:/pub/gnu.
|
||||
GNU make. You can ftp GNU make from ftp.gnu.org:/pub/gnu/make .
|
||||
|
||||
To ensure that libffi is working as advertised, type "make check".
|
||||
This will require that you have DejaGNU installed.
|
||||
@@ -148,19 +162,29 @@ History
|
||||
|
||||
See the ChangeLog files for details.
|
||||
|
||||
3.0.12 XXX-XX-XX
|
||||
Add Blackfin support.
|
||||
3.0.12 Feb-11-13
|
||||
Add Moxie support.
|
||||
Add AArch64 support.
|
||||
Add Blackfin support.
|
||||
Add TILE-Gx/TILEPro support.
|
||||
Add MicroBlaze support.
|
||||
Add Xtensa support.
|
||||
Add support for PaX enabled kernels with MPROTECT.
|
||||
Add support for native vendor compilers on
|
||||
Solaris and AIX.
|
||||
Work around LLVM/GCC interoperability issue on x86_64.
|
||||
|
||||
3.0.11 Apr-11-12
|
||||
Add support for variadic functions (ffi_prep_cif_var).
|
||||
Lots of build fixes.
|
||||
Add Amiga newer MacOS support.
|
||||
Add support for variadic functions (ffi_prep_cif_var).
|
||||
Add Linux/x32 support.
|
||||
Add thiscall, fastcall and MSVC cdecl support on Windows.
|
||||
Add Amiga and newer MacOS support.
|
||||
Add Amiga and newer MacOS support.
|
||||
Add m68k FreeMiNT support.
|
||||
Integration with iOS' xcode build tools.
|
||||
Fix Octeon and MC68881 support.
|
||||
Fix code pessimizations.
|
||||
Lots of build fixes.
|
||||
|
||||
3.0.10 Aug-23-11
|
||||
Add support for Apple's iOS.
|
||||
@@ -304,7 +328,7 @@ See the ChangeLog files for details.
|
||||
Authors & Credits
|
||||
=================
|
||||
|
||||
libffi was originally written by Anthony Green <green@moxielogic.com>.
|
||||
libffi was originally written by Anthony Green <green@redhat.com>.
|
||||
|
||||
The developers of the GNU Compiler Collection project have made
|
||||
innumerable valuable contributions. See the ChangeLog file for
|
||||
@@ -319,15 +343,19 @@ Thorup.
|
||||
Major processor architecture ports were contributed by the following
|
||||
developers:
|
||||
|
||||
aarch64 Marcus Shawcroft, James Greenhalgh
|
||||
alpha Richard Henderson
|
||||
arm Raffaele Sena
|
||||
blackfin Alexandre Keunecke I. de Mendonca
|
||||
cris Simon Posnjak, Hans-Peter Nilsson
|
||||
frv Anthony Green
|
||||
ia64 Hans Boehm
|
||||
m32r Kazuhiro Inaoka
|
||||
m68k Andreas Schwab
|
||||
microblaze Nathan Rossi
|
||||
mips Anthony Green, Casey Marshall
|
||||
mips64 David Daney
|
||||
moxie Anthony Green
|
||||
pa Randolph Chung, Dave Anglin, Andreas Tobler
|
||||
powerpc Geoffrey Keating, Andreas Tobler,
|
||||
David Edelsohn, John Hornkvist
|
||||
@@ -336,8 +364,10 @@ s390 Gerhard Tonn, Ulrich Weigand
|
||||
sh Kaz Kojima
|
||||
sh64 Kaz Kojima
|
||||
sparc Anthony Green, Gordon Irlam
|
||||
tile-gx/tilepro Walter Lee
|
||||
x86 Anthony Green, Jon Beniston
|
||||
x86-64 Bo Thorsen
|
||||
xtensa Chris Zankel
|
||||
|
||||
Jesper Skov and Andrew Haley both did more than their fair share of
|
||||
stepping through the code and tracking down bugs.
|
||||
-112
@@ -1,112 +0,0 @@
|
||||

|
||||
|
||||
Java Native Access (JNA)
|
||||
========================
|
||||
|
||||
The definitive JNA reference (including an overview and usage details) is in the [JavaDoc](http://twall.github.com/jna/3.5.1/javadoc/). Please read the [overview](http://twall.github.com/jna/3.5.1/javadoc/overview-summary.html#overview_description).
|
||||
|
||||
JNA provides Java programs easy access to native shared libraries (DLLs on Windows) without writing anything but Java code—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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
While some attention is paid to performance, correctness and ease of use take priority.
|
||||
|
||||
JNA includes a platform library with many native functions already mapped as well as a set of utility interfaces that simplify native access.
|
||||
|
||||
Download
|
||||
========
|
||||
|
||||
Version 3.5.1
|
||||
|
||||
* [jna.jar](jna/blob/3.5.1/dist/jna.jar?raw=true)
|
||||
* [platform.jar](jna/blob/3.5.1/dist/platform.jar?raw=true)
|
||||
|
||||
Features
|
||||
========
|
||||
|
||||
* Automatic mapping from Java to native functions, with simple mappings for all primitive data types
|
||||
* Runs on most platforms which support Java
|
||||
* Automatic conversion between C and Java strings, with customizable encoding/decoding
|
||||
* Structure and Union arguments/return values, by reference and by value
|
||||
* Function Pointers, (callbacks from native code to Java) as arguments and/or members of a struct
|
||||
* Auto-generated Java proxies for native function pointers
|
||||
* By-reference (pointer-to-type) arguments
|
||||
* Java array and NIO Buffer arguments (primitive types and pointers) as pointer-to-buffer
|
||||
* Nested structures and arrays
|
||||
* Wide (wchar_t-based) strings
|
||||
* Native long support (32- or 64-bit as appropriate)
|
||||
* [Demo applications/examples](https://github.com/twall/jna/tree/master/contrib)
|
||||
* Supported on 1.4 or later JVMs, including JavaME (earlier VMs may work with stubbed NIO support)
|
||||
* Customizable marshalling/unmarshalling (argument and return value conversions)
|
||||
* Customizable mapping from Java method to native function name, and customizable invocation to simulate C preprocessor function macros
|
||||
* Support for automatic Windows ASCII/UNICODE function mappings
|
||||
* Varargs support
|
||||
* Type-safety for native pointers
|
||||
* VM crash protection (optional)
|
||||
* Optimized direct mapping for high-performance applications.
|
||||
|
||||
Community and Support
|
||||
=====================
|
||||
|
||||
All questions should be posted to the [jna-users Google group](http://groups.google.com/group/jna-users). Issues can be submitted [here on Github](https://github.com/twall/jna/issues).
|
||||
|
||||
When posting to the mailing list, please include the following:
|
||||
|
||||
* What OS/CPU/architecture you're using (e.g. Windows 7 64-bit)
|
||||
* Reference to your native interface definitions (i.e. C headers), if available
|
||||
* The JNA mapping you're trying to use
|
||||
* VM crash logs, if any
|
||||
* Example native usage, and your attempted Java usage
|
||||
|
||||
It's nearly impossible to indicate proper Java usage when there's no native
|
||||
reference to work from.
|
||||
|
||||
For commercial support, please contact twalljava [at] java [dot] net.
|
||||
|
||||
Using the Library
|
||||
=================
|
||||
|
||||
* [Getting Started](https://github.com/twall/jna/blob/master/www/GettingStarted.md)
|
||||
* [Mapping between Java and Native](https://github.com/twall/jna/blob/master/www/Mappings.md)
|
||||
* [Using Pointers and Arrays](https://github.com/twall/jna/blob/master/www/PointersAndArrays.md)
|
||||
* [Using Structures and Unions](https://github.com/twall/jna/blob/master/www/StructuresAndUnions.md)
|
||||
* [Using By-Reference Arguments](https://github.com/twall/jna/blob/master/www/ByRefArguments.md)
|
||||
* [Customization of Type Mapping](https://github.com/twall/jna/blob/master/www/CustomMappings.md)
|
||||
* [Callbacks/Function Pointers/Closures](https://github.com/twall/jna/blob/master/www/CallbacksAndClosures.md)
|
||||
* [Dynamically Typed Languages (JRuby/Jython)](https://github.com/twall/jna/blob/master/www/DynamicallyTypedLanguages.md)
|
||||
* [Platform Library](https://github.com/twall/jna/blob/master/www/PlatformLibrary.md)
|
||||
* [Direct Method Mapping](https://github.com/twall/jna/blob/master/www/DirectMapping.md) (Optimization)
|
||||
* [Frequently Asked Questions (FAQ)](https://github.com/twall/jna/blob/master/www/FrequentlyAskedQuestions.md)
|
||||
* [Avoiding Crashes](http://twall.github.com/jna/3.5.1/javadoc/overview-summary.html#crash-protection)
|
||||
|
||||
Primary Documentation (JavaDoc)
|
||||
===============================
|
||||
|
||||
The definitive JNA reference is in the [JavaDoc](http://twall.github.com/jna/3.5.1/javadoc/).
|
||||
|
||||
Developers
|
||||
==========
|
||||
|
||||
* [Contributing to JNA](https://github.com/twall/jna/blob/master/www/Contributing.md).
|
||||
* [Setting up a Windows Development Environment](https://github.com/twall/jna/blob/master/www/WindowsDevelopmentEnvironment.md)
|
||||
* [Setting up an Android Development Environment](https://github.com/twall/jna/blob/master/www/AndroidDevelopmentEnvironment.md)
|
||||
* [Releasing JNA](https://github.com/twall/jna/blob/master/www/ReleasingJNA.md)
|
||||
* [Publishing to Maven Central](https://github.com/twall/jna/blob/master/www/PublishingToMavenCentral.md)
|
||||
|
||||
Contributing
|
||||
============
|
||||
|
||||
You're encouraged to contribute to JNA. Fork the code from [https://github.com/twall/jna](https://github.com/twall/jna) and submit pull requests.
|
||||
|
||||
For more information on setting up a development environment see [Contributing to JNA](https://github.com/twall/jna/blob/master/www/Contributing.md).
|
||||
|
||||
If you are interested in paid support, feel free to say so on the [jna-users mailing list](http://groups.google.com/group/jna-users). 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.
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
This library is provided under the LGPL, version 2.1 or later. Alternative license arrangements are negotiable.
|
||||
|
||||
*NOTE: Oracle is not sponsoring this project, even though the package name (com.sun.jna) might imply otherwise.*
|
||||
-273
@@ -1,273 +0,0 @@
|
||||
# DESIGN GOALS/REQUIREMENTS
|
||||
o no permanent references to java objects in native code (hard to get rid of)
|
||||
this means no java object arguments to callbacks; use some sort of integer
|
||||
key instead (hashcode?) callbacks can hold local data anyway...
|
||||
o make simplest Java usage map to most common C usage
|
||||
- additional constructs provided for less-common cases
|
||||
(WString,Structure.ByValue/ByReference)
|
||||
o structure is treated as a pointer, except within a struct
|
||||
o primitive types are passed directly
|
||||
o arrays are treated as pointers, except within a struct
|
||||
- in structure (inline; otherwise pointer-to-X should be used)
|
||||
- as function argument (auto-convert to pointer via Memory)
|
||||
o pointer to type in struct should use Pointer or ByReference
|
||||
o "free" should be invisible wherever possible
|
||||
|
||||
# FUTURE DEMOS:
|
||||
* test keyboard keys' state (needs OSX)
|
||||
* get system process information, basic process control
|
||||
* additional file utilities (meta info, free space, etc)
|
||||
* enforce window minimum/maximum size (workaround java bug)
|
||||
|
||||
# TODO
|
||||
|
||||
* make native dll extraction from jar public, to use with user dlls packaged
|
||||
in a jar
|
||||
|
||||
* dispose memory/callbacks in Native finalizer to ensure they run first
|
||||
(use referencequeue to run them when they become unreachable)
|
||||
|
||||
* make direct calls call back *once* to Java where conversion is required,
|
||||
and process all arguments from there (instead of potentially swapping back
|
||||
and forth multiple times). This also makes it easer to perform conversions
|
||||
(no native changes required).
|
||||
|
||||
* use libffi java raw?
|
||||
|
||||
* direct/raw non-primitive array arguments (String[], Pointer[], NativeMapped[])
|
||||
* ppc64 direct/raw failures (multiple)
|
||||
* direct calls on ppc to varargs (callbacks) with FP args fail; avoid them for
|
||||
now
|
||||
* combine direct and interface mapping calling code where possible
|
||||
* Callback.PostCallWrite.write() cf PostCallRead
|
||||
* GetPrimitiveArrayCritical: use this if flagged (by annotation? method name?)
|
||||
* MethodArgument/ReturnMapper: per method mapping of arguments/return type.
|
||||
Can use annotations as shorthand to initialize a map, but basically set up a
|
||||
per-NativeLibrary (or per-Function?) map of methods to mappers.
|
||||
|
||||
Requires separate compilation of annotation handling.
|
||||
* ditch type conversion context (?)
|
||||
* packaging: 'types', 'convert/marshal' subpackages?
|
||||
note: marshal/unmarshal vs to/fromnative: to/fromnative is more
|
||||
explicit, since marshal/unmarshal doesn't indicate src/dst.
|
||||
o moving conversion contexts to subpackage cleans up top level
|
||||
substantially, but we probably don't want to move things like Structure and
|
||||
Pointer into a types subpackage (which would leave just a few top-level
|
||||
classes). Javadoc is cluttered by example classes anyway.
|
||||
|
||||
* support annotations of parameters and return values w/o breaking
|
||||
1.4 compatibility (retroweaver?), e.g.
|
||||
-- retroweaver (requires retroweaver runtime classes to provide annotation
|
||||
features) not yet worth doing
|
||||
|
||||
void my_function(@MarshalAs(off_t)long arg);
|
||||
|
||||
trading off cruft in the interface def to avoid cruft in the usage:
|
||||
|
||||
my_function(0) versus my_function(new off_t(0))
|
||||
|
||||
this only really applies to NativeLong/IntegerType types that want to use a
|
||||
primitive value instead of creating an object instance.
|
||||
|
||||
* flag string(/wstring)-returning methods which need to free their result
|
||||
to avoid leaking memory whan auto-creating strings from the result
|
||||
(since normally we don't take explicit ownership of any returned pointers)
|
||||
this is a special case for returned strings only, since other returned
|
||||
pointers are available to the user for later "freeing"
|
||||
Use a map on library creation, an iface for the library, or annotation
|
||||
NOTE: how many methods actually do this? strdup...
|
||||
Maybe make function return "Memory", which can then be converted to a
|
||||
Structure or some other type. Then memory will free itself when no longer
|
||||
referenced.
|
||||
* make Pointer free-able (system allocates memory, client frees it); actually,
|
||||
this should probably be automatic so the user doesn't have to think about it.
|
||||
Maybe a custom type representing "function-allocated-pointer" or
|
||||
"pointer-requiring-free" (which is just Memory). For now, leave it up to
|
||||
the user to manage the pointer, since they have to define the free method
|
||||
anyway. use could always put a finalizer on a PointerType-derived type.
|
||||
* universal GCC build w/cross-compile (needs cross compilers...)
|
||||
* return Pointer.SIZE/LONG_SIZE/WCHAR_SIZE in bits (for consistency with 1.5)
|
||||
Long.SIZE, Integer.SIZE, et al.
|
||||
* interface "lvalue", which can provide a pointer to itself (reference() or
|
||||
addressOf())?
|
||||
* bitfields for structs (how?)
|
||||
|
||||
|
||||
# DONE
|
||||
* cache structure information per-class
|
||||
* fix setFieldOrder to *always* apply if used
|
||||
* Make a separate jar file for all OS-specific headers
|
||||
Maybe make interfaces per-header file (winbase, winnt, stdlib, etc),
|
||||
aggregated per-library (interface CLibrary extends stdlib, stdio, etc)
|
||||
(how useful would it really be, or is this just sorting legos?)
|
||||
o same for windowutils, fileutils, etc. (not useful)
|
||||
* check Structure "final" fields; should never write back to native memory
|
||||
* OSX ObjC access (see rococoa)
|
||||
* do Structure.write for any callback args
|
||||
* pointer.setValue(), to handle NativeMapped types and move read/writeValue
|
||||
methods out of Structure, to be used by Function w/NativeMapped[] parameter
|
||||
|
||||
* if method has "GetLastErrorException/ErrnoException" in its signature, use
|
||||
result codes + GetLastError/errno/errstr to auto-generate
|
||||
runtime exceptions? (cf P/Invoke; also useful for X11 return types)
|
||||
provide annotation/custom invocation handler/hook to examine return value and
|
||||
throw an exception if the return value indicates an error
|
||||
|
||||
o are error return values consistent (if so, a single handler works)?
|
||||
if null -> call GetLastError
|
||||
if nonzero ?
|
||||
o otherwise, need an ExceptionOnZero, ExceptionOnNonZero runtime, from which
|
||||
derive GetLastError/ErrnoExceptionOnZero/NZ
|
||||
* verify get/set methods vs read/write for performance (Pointer)?
|
||||
(see RawTest for performance comparisons)
|
||||
* Allow Buffer in Structures (and callbacks) (auto-wrap in direct byte buffer)?
|
||||
o this gets tricky when reading structs from native memory; we don't know if
|
||||
the value is already mapped to a buffer (cf CallbackReference)
|
||||
* standard types for various platforms: posix/types.h, w32 (DWORD, HANDLE)
|
||||
|
||||
* embed version in DLL ('depends'-done)/so (symlink?)
|
||||
* use libffi closure allocation/deallocation
|
||||
|
||||
* ensure Library options are passed to NativeFunctionHandler
|
||||
(needs getLibraryOptions(Class cls))
|
||||
|
||||
* handle array of Structure.ByReference as parameter/return value (cf Pointer[])
|
||||
* test performance of setByte/getByte and pass pointer field directly if it
|
||||
makes sense to do so (done, halves access time to use pointer field directly,
|
||||
slight variations on 1.4/1.5/1.6).
|
||||
* test callback arg/return value for callback type
|
||||
* structure by value in callback
|
||||
|
||||
* call native to fix up FFIType on creation (avoid multithreading problems)
|
||||
properly handle union by value (or punt; must pass union field instead)
|
||||
|
||||
* hash javah-generated headers; when changed, invalidate platform-specific
|
||||
|
||||
* add main class which spits out version information
|
||||
|
||||
* docs: split pages: FAQ
|
||||
FAQ: J2ME, new platform builds, stdcall
|
||||
|
||||
* struct by reference within structure
|
||||
* struct by value
|
||||
(how to do struct value return (vs struct pointer) (uncommon)?)
|
||||
(how to do struct value argument (vs struct pointer) (uncommon)?)
|
||||
* use appropriate size_t and off_t sizes (use long offsets everywhere in
|
||||
Pointer)
|
||||
* Callback/function pointer as return value (e.g. signal())
|
||||
* type safety between returned and passed in pointers (w32 API); advantage of
|
||||
deriving from Pointer is that type mapping can be made automatic, without an
|
||||
explicit type mapping defined.
|
||||
* catch native crash/exception/faults and re-throw as java exception
|
||||
this is mostly for debugging a new mapping to avoid crashing the VM
|
||||
could do setjmp/longjmp on *nix and catch C++ exception on w32
|
||||
* NativeMapped: provide interface to automatically convert custom Java
|
||||
type to/from native types.
|
||||
* update X11 libs for 64-bit
|
||||
* use libffi from gcc to handle calls and callbacks?
|
||||
or move callback asm templates into dispatch_<arch>.c
|
||||
* more tests for argument types (2 args, all permutations of basic data types)
|
||||
ensures native stack handling is done properly (handled by libffi)
|
||||
* universal OSX build w/cross-compile (hard to do with libffi)
|
||||
* use jna.encoding property to affect string encoding instead of just using
|
||||
the system default encoding.
|
||||
* change/augment getWindowHandle0 to provide any heavyweight component window
|
||||
* unions (copy-on-call is problematic: which member is active?) must require
|
||||
explicit write, either per member or whole object before export
|
||||
* rename Argument/Result Converter to be fromNative/toNative
|
||||
* split unit tests
|
||||
* auto-convert struct pointers in callback args to Java Structure
|
||||
(may need a proxy wrapper around callback to avoid excessive JNI)
|
||||
use proxy for callbacks to enable auto-conversion of arguments and/or return
|
||||
value (in java-land instead of C-land).
|
||||
* review/use refactor nativelibrary/function
|
||||
* auto-generate stdcall decorated symbols (try if undecorated lookup fails)
|
||||
* per-library jna.library.path: many libraries have a "standard" location (or
|
||||
several); let the library author indicate what these are (X11, for example)
|
||||
* return array of struct (annotation to indicate which argument has the
|
||||
length of the returned value might be nice) (this can now be done with a
|
||||
type mapper)
|
||||
* callbacks need a dispose if they are to live beyond the lifetime of the
|
||||
function to which they are passed; maybe a simpler callback interface for
|
||||
transient callbacks, and require callback+dispose for most callbacks?
|
||||
TransientCallback: callback
|
||||
NonTransientCallback: callback+dispose
|
||||
(callback is disposed when no longer referenced; user must ensure callback
|
||||
is not GC'd until it is removed as a native callback)
|
||||
* auto-convert strings in w32 functions ending in 'W'? would this introduce
|
||||
any ambiguity?
|
||||
* Dispose/unload library on GC (use ref queue)
|
||||
* fix dnd on linux (no hole?) (mostly fixed, still some artifacts)
|
||||
* transparent/shaped drag image
|
||||
* windows handles need to be Pointer (void*), not 'int'
|
||||
* other demos: move to trash, file change notification
|
||||
* tests for other primitive array types
|
||||
* build test dll/dispatch lib w/cygwin/gcc instead of msvc (?) under w32
|
||||
* nested struct alignment (4/8 byte? depends on first element?)
|
||||
* nested structs in structs: easier to define using struct; use pointer
|
||||
if you need a pointer
|
||||
struct auto-converts to pointer as argument, should be inline in struct
|
||||
(struct should require explicit pointer, argument should require explicit
|
||||
non-pointer) (maybe use object version of basic type as "pointer" version)
|
||||
* provide JNA-only search path for libraries
|
||||
* callbacks
|
||||
* move javah-generated files to own space
|
||||
* darwin/PPC asm layer
|
||||
* enable w32 build with either GCC or MSVC (GCC-built dll doesn't work yet)
|
||||
* support pointer to basic type argument (int *) w/type safety - what's the
|
||||
best API from a user perspective? new Pointer(int)? new Pointer<int>?
|
||||
Base class "pointer to" gets converted to Pointer in invocation handler;
|
||||
provide a getValue() to retrieve the result; otherwise the memory is opaque
|
||||
|
||||
o IntPtr, WCharPtr, CharPtr, ShortPtr, LongPtr, DoublePtr, FloatPtr,
|
||||
Handle (PtrPtr), getValue(), getPointer()
|
||||
o add getCharArray() et al. to Pointer?
|
||||
|
||||
* inline arrays of primitive types
|
||||
* remove debug flags (they're not useful)
|
||||
* Use WString to identify return type and arg
|
||||
* use interface to identify native, instead of annotation
|
||||
* isolate stdcall to w32 (should be private to platform)
|
||||
* generic gcc build/osx(ppc/x86)/linux
|
||||
* remove generics/enable build under 1.4
|
||||
* tests for structs
|
||||
* test float/double
|
||||
* offset placeholders for structs (explicit alignment)
|
||||
* vanilla ant build file
|
||||
* build native stuff from build.xml
|
||||
* implement basic junit tests
|
||||
* auto-align struct fields
|
||||
* handle long/byte/short
|
||||
* make annotations for native method names optional
|
||||
// hard clip for now, alpha transparency later
|
||||
// also allow ImageIcon to be used as clip (getImage())
|
||||
void setWindowMask(Window w, Shape clip);
|
||||
// needs:
|
||||
int findNativeWindow(Window w);
|
||||
|
||||
#MAYBE NOT
|
||||
* should structure offsets be 64-bit? technically yes, but in practice I don't
|
||||
think a structure that big actually works.
|
||||
* (maybe) move all native functions into Native (limit header files, easier
|
||||
management)
|
||||
* Does it make sense to define Int16/UInt16, Int32/UInt32, etc? Probably not
|
||||
the signed versions, but maybe the unsigned ones, to facilitate generating
|
||||
unsigned values (maybe just provide utilities to pack an unsigned int into a
|
||||
signed int). What about size_t, off_t, et al.? Would either need a
|
||||
bunch of native lookup functions (more accurate) or java-side conditionals
|
||||
(less robust but easier to change).
|
||||
o bounds checking is handled by IntegerType (pass in a long, get an
|
||||
exception if the value is out of bounds).
|
||||
o when used as struct fields, could allow detection of field order by order
|
||||
of initialization (requires all-or-nothing usage, though)
|
||||
* StringBuffer/StringBuilder as mutable char*/wchar_t* argument
|
||||
NOTE: byte[]/char[] is probably better; it's trivial to convert to String
|
||||
and native code can't change the size anyway
|
||||
* provide library load/unload hooks (Runnables in options?). Examples:
|
||||
o GetLastError (no longer needed)
|
||||
o WSAInit?
|
||||
* determine X11 display name from current java program (if any); null is ok
|
||||
since it uses getenv(DISPLAY), which is what java would do
|
||||
note: DISPLAY may be available in GraphicsDevice->getIDstring
|
||||
|
||||
|
||||
externo
+1903
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
-1090
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+50
-32
@@ -2,13 +2,13 @@
|
||||
# Attempt to guess a canonical system name.
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
# 2011 Free Software Foundation, Inc.
|
||||
# 2011, 2012, 2013 Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2011-06-03'
|
||||
timestamp='2012-12-29'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
@@ -17,26 +17,22 @@ timestamp='2011-06-03'
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
|
||||
# Originally written by Per Bothner. Please send patches (context
|
||||
# diff format) to <config-patches@gnu.org> and include a ChangeLog
|
||||
# entry.
|
||||
# the same distribution terms that you use for the rest of that
|
||||
# program. This Exception is an additional permission under section 7
|
||||
# of the GNU General Public License, version 3 ("GPLv3").
|
||||
#
|
||||
# This script attempts to guess a canonical system name similar to
|
||||
# config.sub. If it succeeds, it prints the system name on stdout, and
|
||||
# exits with 0. Otherwise, it exits with 1.
|
||||
# Originally written by Per Bothner.
|
||||
#
|
||||
# You can get the latest version of this script from:
|
||||
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
|
||||
#
|
||||
# Please send patches with a ChangeLog entry to config-patches@gnu.org.
|
||||
|
||||
|
||||
me=`echo "$0" | sed -e 's,.*/,,'`
|
||||
|
||||
@@ -57,8 +53,8 @@ GNU config.guess ($timestamp)
|
||||
|
||||
Originally written by Per Bothner.
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
|
||||
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free
|
||||
Software Foundation, Inc.
|
||||
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
|
||||
2012, 2013 Free Software Foundation, Inc.
|
||||
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
|
||||
@@ -145,7 +141,7 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
|
||||
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
*:NetBSD:*:*)
|
||||
# NetBSD (nbsd) targets should (where applicable) match one or
|
||||
# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
|
||||
# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
|
||||
# *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
|
||||
# switched to ELF, *-*-netbsd* would select the old
|
||||
# object file format. This provides both forward
|
||||
@@ -202,6 +198,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
|
||||
echo "${machine}-${os}${release}"
|
||||
exit ;;
|
||||
*:Bitrig:*:*)
|
||||
UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
|
||||
echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
|
||||
exit ;;
|
||||
*:OpenBSD:*:*)
|
||||
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
|
||||
echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
|
||||
@@ -304,7 +304,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
|
||||
echo arm-acorn-riscix${UNAME_RELEASE}
|
||||
exit ;;
|
||||
arm:riscos:*:*|arm:RISCOS:*:*)
|
||||
arm*:riscos:*:*|arm*:RISCOS:*:*)
|
||||
echo arm-unknown-riscos
|
||||
exit ;;
|
||||
SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
|
||||
@@ -792,21 +792,26 @@ EOF
|
||||
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
|
||||
exit ;;
|
||||
*:FreeBSD:*:*)
|
||||
case ${UNAME_MACHINE} in
|
||||
pc98)
|
||||
echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
|
||||
UNAME_PROCESSOR=`/usr/bin/uname -p`
|
||||
case ${UNAME_PROCESSOR} in
|
||||
amd64)
|
||||
echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
|
||||
*)
|
||||
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
|
||||
echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
|
||||
esac
|
||||
exit ;;
|
||||
i*:CYGWIN*:*)
|
||||
echo ${UNAME_MACHINE}-pc-cygwin
|
||||
exit ;;
|
||||
*:MINGW64*:*)
|
||||
echo ${UNAME_MACHINE}-pc-mingw64
|
||||
exit ;;
|
||||
*:MINGW*:*)
|
||||
echo ${UNAME_MACHINE}-pc-mingw32
|
||||
exit ;;
|
||||
i*:MSYS*:*)
|
||||
echo ${UNAME_MACHINE}-pc-msys
|
||||
exit ;;
|
||||
i*:windows32*:*)
|
||||
# uname -m includes "-pc" on this system.
|
||||
echo ${UNAME_MACHINE}-mingw32
|
||||
@@ -861,6 +866,13 @@ EOF
|
||||
i*86:Minix:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-minix
|
||||
exit ;;
|
||||
aarch64:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
aarch64_be:Linux:*:*)
|
||||
UNAME_MACHINE=aarch64_be
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
alpha:Linux:*:*)
|
||||
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
|
||||
EV5) UNAME_MACHINE=alphaev5 ;;
|
||||
@@ -895,13 +907,16 @@ EOF
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
cris:Linux:*:*)
|
||||
echo cris-axis-linux-gnu
|
||||
echo ${UNAME_MACHINE}-axis-linux-gnu
|
||||
exit ;;
|
||||
crisv32:Linux:*:*)
|
||||
echo crisv32-axis-linux-gnu
|
||||
echo ${UNAME_MACHINE}-axis-linux-gnu
|
||||
exit ;;
|
||||
frv:Linux:*:*)
|
||||
echo frv-unknown-linux-gnu
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
hexagon:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
i*86:Linux:*:*)
|
||||
LIBC=gnu
|
||||
@@ -943,7 +958,7 @@ EOF
|
||||
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
|
||||
;;
|
||||
or32:Linux:*:*)
|
||||
echo or32-unknown-linux-gnu
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
padre:Linux:*:*)
|
||||
echo sparc-unknown-linux-gnu
|
||||
@@ -984,7 +999,7 @@ EOF
|
||||
echo ${UNAME_MACHINE}-dec-linux-gnu
|
||||
exit ;;
|
||||
x86_64:Linux:*:*)
|
||||
echo x86_64-unknown-linux-gnu
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
xtensa*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
@@ -1191,6 +1206,9 @@ EOF
|
||||
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
|
||||
echo i586-pc-haiku
|
||||
exit ;;
|
||||
x86_64:Haiku:*:*)
|
||||
echo x86_64-unknown-haiku
|
||||
exit ;;
|
||||
SX-4:SUPER-UX:*:*)
|
||||
echo sx4-nec-superux${UNAME_RELEASE}
|
||||
exit ;;
|
||||
@@ -1246,7 +1264,7 @@ EOF
|
||||
NEO-?:NONSTOP_KERNEL:*:*)
|
||||
echo neo-tandem-nsk${UNAME_RELEASE}
|
||||
exit ;;
|
||||
NSE-?:NONSTOP_KERNEL:*:*)
|
||||
NSE-*:NONSTOP_KERNEL:*:*)
|
||||
echo nse-tandem-nsk${UNAME_RELEASE}
|
||||
exit ;;
|
||||
NSR-?:NONSTOP_KERNEL:*:*)
|
||||
@@ -1315,11 +1333,11 @@ EOF
|
||||
i*86:AROS:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-aros
|
||||
exit ;;
|
||||
x86_64:VMkernel:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-esx
|
||||
exit ;;
|
||||
esac
|
||||
|
||||
#echo '(No uname command or uname output not recognized.)' 1>&2
|
||||
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
|
||||
|
||||
eval $set_cc_for_build
|
||||
cat >$dummy.c <<EOF
|
||||
#ifdef _SEQUENT_
|
||||
+63
-40
@@ -2,37 +2,32 @@
|
||||
# Configuration validation subroutine script.
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
# 2011 Free Software Foundation, Inc.
|
||||
# 2011, 2012, 2013 Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2011-10-29'
|
||||
timestamp='2012-12-29'
|
||||
|
||||
# This file is (in principle) common to ALL GNU software.
|
||||
# The presence of a machine in this file suggests that SOME GNU software
|
||||
# can handle that machine. It does not imply ALL GNU software can.
|
||||
#
|
||||
# This file is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program 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 General Public License for more details.
|
||||
# This program 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
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
# the same distribution terms that you use for the rest of that
|
||||
# program. This Exception is an additional permission under section 7
|
||||
# of the GNU General Public License, version 3 ("GPLv3").
|
||||
|
||||
|
||||
# Please send patches to <config-patches@gnu.org>. Submit a context
|
||||
# diff and a properly formatted GNU ChangeLog entry.
|
||||
# Please send patches with a ChangeLog entry to config-patches@gnu.org.
|
||||
#
|
||||
# Configuration subroutine to validate and canonicalize a configuration type.
|
||||
# Supply the specified configuration type as an argument.
|
||||
@@ -76,8 +71,8 @@ version="\
|
||||
GNU config.sub ($timestamp)
|
||||
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
|
||||
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free
|
||||
Software Foundation, Inc.
|
||||
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
|
||||
2012, 2013 Free Software Foundation, Inc.
|
||||
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
|
||||
@@ -125,13 +120,17 @@ esac
|
||||
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
|
||||
case $maybe_os in
|
||||
nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
|
||||
linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
|
||||
linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
|
||||
knetbsd*-gnu* | netbsd*-gnu* | \
|
||||
kopensolaris*-gnu* | \
|
||||
storm-chaos* | os2-emx* | rtmk-nova*)
|
||||
os=-$maybe_os
|
||||
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
|
||||
;;
|
||||
android-linux)
|
||||
os=-linux-android
|
||||
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
|
||||
;;
|
||||
*)
|
||||
basic_machine=`echo $1 | sed 's/-[^-]*$//'`
|
||||
if [ $basic_machine != $1 ]
|
||||
@@ -154,7 +153,7 @@ case $os in
|
||||
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
|
||||
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
|
||||
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
|
||||
-apple | -axis | -knuth | -cray | -microblaze)
|
||||
-apple | -axis | -knuth | -cray | -microblaze*)
|
||||
os=
|
||||
basic_machine=$1
|
||||
;;
|
||||
@@ -223,6 +222,12 @@ case $os in
|
||||
-isc*)
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-lynx*178)
|
||||
os=-lynxos178
|
||||
;;
|
||||
-lynx*5)
|
||||
os=-lynxos5
|
||||
;;
|
||||
-lynx*)
|
||||
os=-lynxos
|
||||
;;
|
||||
@@ -247,11 +252,14 @@ case $basic_machine in
|
||||
# Some are omitted here because they have special meanings below.
|
||||
1750a | 580 \
|
||||
| a29k \
|
||||
| aarch64 | aarch64_be \
|
||||
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
|
||||
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
|
||||
| am33_2.0 \
|
||||
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
|
||||
| be32 | be64 \
|
||||
| arc \
|
||||
| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
|
||||
| avr | avr32 \
|
||||
| be32 | be64 \
|
||||
| bfin \
|
||||
| c4x | clipper \
|
||||
| d10v | d30v | dlx | dsp16xx \
|
||||
@@ -264,7 +272,7 @@ case $basic_machine in
|
||||
| le32 | le64 \
|
||||
| lm32 \
|
||||
| m32c | m32r | m32rle | m68000 | m68k | m88k \
|
||||
| maxq | mb | microblaze | mcore | mep | metag \
|
||||
| maxq | mb | microblaze | microblazeel | mcore | mep | metag \
|
||||
| mips | mipsbe | mipseb | mipsel | mipsle \
|
||||
| mips16 \
|
||||
| mips64 | mips64el \
|
||||
@@ -319,8 +327,7 @@ case $basic_machine in
|
||||
c6x)
|
||||
basic_machine=tic6x-unknown
|
||||
;;
|
||||
m6811 | m68hc11 | m6812 | m68hc12 | picochip)
|
||||
# Motorola 68HC11/12.
|
||||
m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
|
||||
basic_machine=$basic_machine-unknown
|
||||
os=-none
|
||||
;;
|
||||
@@ -333,7 +340,10 @@ case $basic_machine in
|
||||
strongarm | thumb | xscale)
|
||||
basic_machine=arm-unknown
|
||||
;;
|
||||
|
||||
xgate)
|
||||
basic_machine=$basic_machine-unknown
|
||||
os=-none
|
||||
;;
|
||||
xscaleeb)
|
||||
basic_machine=armeb-unknown
|
||||
;;
|
||||
@@ -356,6 +366,7 @@ case $basic_machine in
|
||||
# Recognize the basic CPU types with company name.
|
||||
580-* \
|
||||
| a29k-* \
|
||||
| aarch64-* | aarch64_be-* \
|
||||
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
|
||||
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
|
||||
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
|
||||
@@ -377,7 +388,8 @@ case $basic_machine in
|
||||
| lm32-* \
|
||||
| m32c-* | m32r-* | m32rle-* \
|
||||
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
|
||||
| m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
|
||||
| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
|
||||
| microblaze-* | microblazeel-* \
|
||||
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
|
||||
| mips16-* \
|
||||
| mips64-* | mips64el-* \
|
||||
@@ -719,7 +731,6 @@ case $basic_machine in
|
||||
i370-ibm* | ibm*)
|
||||
basic_machine=i370-ibm
|
||||
;;
|
||||
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
|
||||
i*86v32)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
os=-sysv32
|
||||
@@ -777,9 +788,13 @@ case $basic_machine in
|
||||
basic_machine=ns32k-utek
|
||||
os=-sysv
|
||||
;;
|
||||
microblaze)
|
||||
microblaze*)
|
||||
basic_machine=microblaze-xilinx
|
||||
;;
|
||||
mingw64)
|
||||
basic_machine=x86_64-pc
|
||||
os=-mingw64
|
||||
;;
|
||||
mingw32)
|
||||
basic_machine=i386-pc
|
||||
os=-mingw32
|
||||
@@ -816,6 +831,10 @@ case $basic_machine in
|
||||
ms1-*)
|
||||
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
|
||||
;;
|
||||
msys)
|
||||
basic_machine=i386-pc
|
||||
os=-msys
|
||||
;;
|
||||
mvs)
|
||||
basic_machine=i370-ibm
|
||||
os=-mvs
|
||||
@@ -1004,7 +1023,11 @@ case $basic_machine in
|
||||
basic_machine=i586-unknown
|
||||
os=-pw32
|
||||
;;
|
||||
rdos)
|
||||
rdos | rdos64)
|
||||
basic_machine=x86_64-pc
|
||||
os=-rdos
|
||||
;;
|
||||
rdos32)
|
||||
basic_machine=i386-pc
|
||||
os=-rdos
|
||||
;;
|
||||
@@ -1337,15 +1360,15 @@ case $os in
|
||||
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
|
||||
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
|
||||
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
|
||||
| -openbsd* | -solidbsd* \
|
||||
| -bitrig* | -openbsd* | -solidbsd* \
|
||||
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
|
||||
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
|
||||
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
|
||||
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
|
||||
| -chorusos* | -chorusrdb* | -cegcc* \
|
||||
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
|
||||
| -mingw32* | -linux-gnu* | -linux-android* \
|
||||
| -linux-newlib* | -linux-uclibc* \
|
||||
| -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
|
||||
| -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
|
||||
| -linux-newlib* | -linux-musl* | -linux-uclibc* \
|
||||
| -uxpv* | -beos* | -mpeix* | -udk* \
|
||||
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
|
||||
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
|
||||
@@ -1528,6 +1551,9 @@ case $basic_machine in
|
||||
c4x-* | tic4x-*)
|
||||
os=-coff
|
||||
;;
|
||||
hexagon-*)
|
||||
os=-elf
|
||||
;;
|
||||
tic54x-*)
|
||||
os=-coff
|
||||
;;
|
||||
@@ -1555,9 +1581,6 @@ case $basic_machine in
|
||||
;;
|
||||
m68000-sun)
|
||||
os=-sunos3
|
||||
# This also exists in the configure program, but was not the
|
||||
# default.
|
||||
# os=-sunos4
|
||||
;;
|
||||
m68*-cisco)
|
||||
os=-aout
|
||||
+821
-541
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -2,7 +2,7 @@ dnl Process this with autoconf to create configure
|
||||
|
||||
AC_PREREQ(2.68)
|
||||
|
||||
AC_INIT([libffi], [3.0.11], [http://github.com/atgreen/libffi/issues])
|
||||
AC_INIT([libffi], [3.0.12], [http://github.com/atgreen/libffi/issues])
|
||||
AC_CONFIG_HEADERS([fficonfig.h])
|
||||
|
||||
AC_CANONICAL_SYSTEM
|
||||
@@ -27,7 +27,7 @@ save_CFLAGS=$CFLAGS
|
||||
AC_PROG_CC
|
||||
CFLAGS=$save_CFLAGS
|
||||
m4_undefine([_AC_ARG_VAR_PRECIOUS])
|
||||
m4_rename([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
|
||||
m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
|
||||
|
||||
AC_SUBST(CFLAGS)
|
||||
|
||||
@@ -36,10 +36,24 @@ AM_PROG_CC_C_O
|
||||
AC_PROG_LIBTOOL
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
# Test for 64-bit build.
|
||||
AC_CHECK_SIZEOF([size_t])
|
||||
|
||||
AX_COMPILER_VENDOR
|
||||
AX_CC_MAXOPT
|
||||
AX_CFLAGS_WARN_ALL
|
||||
# The AX_CFLAGS_WARN_ALL macro doesn't currently work for sunpro
|
||||
# compiler.
|
||||
if test "$ax_cv_c_compiler_vendor" != "sun"; then
|
||||
AX_CFLAGS_WARN_ALL
|
||||
fi
|
||||
|
||||
if test "x$GCC" = "xyes"; then
|
||||
CFLAGS="$CFLAGS -fexceptions"
|
||||
touch local.exp
|
||||
else
|
||||
cat > local.exp <<EOF
|
||||
set CC_FOR_TARGET "$CC"
|
||||
EOF
|
||||
fi
|
||||
|
||||
AM_MAINTAINER_MODE
|
||||
@@ -53,6 +67,10 @@ AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
|
||||
|
||||
TARGETDIR="unknown"
|
||||
case "$host" in
|
||||
aarch64*-*-*)
|
||||
TARGET=AARCH64; TARGETDIR=aarch64
|
||||
;;
|
||||
|
||||
alpha*-*-*)
|
||||
TARGET=ALPHA; TARGETDIR=alpha;
|
||||
# Support 128-bit long double, changeable via command-line switch.
|
||||
@@ -67,6 +85,10 @@ case "$host" in
|
||||
TARGET=X86_64; TARGETDIR=x86
|
||||
;;
|
||||
|
||||
amd64-*-freebsd*)
|
||||
TARGET=X86_64; TARGETDIR=x86
|
||||
;;
|
||||
|
||||
amd64-*-freebsd*)
|
||||
TARGET=X86_64; TARGETDIR=x86
|
||||
;;
|
||||
@@ -116,10 +138,45 @@ case "$host" in
|
||||
TARGET=X86_DARWIN; TARGETDIR=x86
|
||||
;;
|
||||
i?86-*-solaris2.1[[0-9]]*)
|
||||
TARGET=X86_64; TARGETDIR=x86
|
||||
TARGETDIR=x86
|
||||
if test $ac_cv_sizeof_size_t = 4; then
|
||||
TARGET=X86;
|
||||
else
|
||||
TARGET=X86_64;
|
||||
fi
|
||||
;;
|
||||
i?86-*-*)
|
||||
TARGET=X86_64; TARGETDIR=x86
|
||||
|
||||
x86_64-*-darwin*)
|
||||
TARGET=X86_DARWIN; TARGETDIR=x86
|
||||
;;
|
||||
|
||||
x86_64-*-cygwin* | x86_64-*-mingw*)
|
||||
TARGET=X86_WIN64; TARGETDIR=x86
|
||||
# All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
|
||||
# We must also check with_cross_host to decide if this is a native
|
||||
# or cross-build and select where to install dlls appropriately.
|
||||
if test -n "$with_cross_host" &&
|
||||
test x"$with_cross_host" != x"no"; then
|
||||
AM_LTLDFLAGS='-no-undefined -bindir "$(toolexeclibdir)"';
|
||||
else
|
||||
AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"';
|
||||
fi
|
||||
;;
|
||||
|
||||
i?86-*-* | x86_64-*-*)
|
||||
TARGETDIR=x86
|
||||
if test $ac_cv_sizeof_size_t = 4; then
|
||||
case "$host" in
|
||||
*-gnux32)
|
||||
TARGET=X86_64
|
||||
;;
|
||||
*)
|
||||
TARGET=X86
|
||||
;;
|
||||
esac
|
||||
else
|
||||
TARGET=X86_64;
|
||||
fi
|
||||
;;
|
||||
|
||||
ia64*-*-*)
|
||||
@@ -134,6 +191,14 @@ case "$host" in
|
||||
TARGET=M68K; TARGETDIR=m68k
|
||||
;;
|
||||
|
||||
microblaze*-*-*)
|
||||
TARGET=MICROBLAZE; TARGETDIR=microblaze
|
||||
;;
|
||||
|
||||
moxie-*-*)
|
||||
TARGET=MOXIE; TARGETDIR=moxie
|
||||
;;
|
||||
|
||||
mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*)
|
||||
TARGET=MIPS; TARGETDIR=mips
|
||||
;;
|
||||
@@ -143,10 +208,6 @@ case "$host" in
|
||||
TARGET=MIPS; TARGETDIR=mips
|
||||
;;
|
||||
|
||||
moxie-*-*)
|
||||
TARGET=MOXIE; TARGETDIR=moxie
|
||||
;;
|
||||
|
||||
powerpc*-*-linux* | powerpc-*-sysv*)
|
||||
TARGET=POWERPC; TARGETDIR=powerpc
|
||||
;;
|
||||
@@ -187,26 +248,14 @@ case "$host" in
|
||||
TARGET=SPARC; TARGETDIR=sparc
|
||||
;;
|
||||
|
||||
x86_64-*-darwin*)
|
||||
TARGET=X86_DARWIN; TARGETDIR=x86
|
||||
tile*-*)
|
||||
TARGET=TILE; TARGETDIR=tile
|
||||
;;
|
||||
|
||||
xtensa*-*)
|
||||
TARGET=XTENSA; TARGETDIR=xtensa
|
||||
;;
|
||||
|
||||
x86_64-*-cygwin* | x86_64-*-mingw*)
|
||||
TARGET=X86_WIN64; TARGETDIR=x86
|
||||
# All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
|
||||
# We must also check with_cross_host to decide if this is a native
|
||||
# or cross-build and select where to install dlls appropriately.
|
||||
if test -n "$with_cross_host" &&
|
||||
test x"$with_cross_host" != x"no"; then
|
||||
AM_LTLDFLAGS='-no-undefined -bindir "$(toolexeclibdir)"';
|
||||
else
|
||||
AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"';
|
||||
fi
|
||||
;;
|
||||
|
||||
x86_64-*-*)
|
||||
TARGET=X86_64; TARGETDIR=x86
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_SUBST(AM_RUNTESTFLAGS)
|
||||
@@ -228,11 +277,13 @@ AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
|
||||
AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
|
||||
AM_CONDITIONAL(M32R, test x$TARGET = xM32R)
|
||||
AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
|
||||
AM_CONDITIONAL(MICROBLAZE, test x$TARGET = xMICROBLAZE)
|
||||
AM_CONDITIONAL(MOXIE, test x$TARGET = xMOXIE)
|
||||
AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
|
||||
AM_CONDITIONAL(POWERPC_AIX, test x$TARGET = xPOWERPC_AIX)
|
||||
AM_CONDITIONAL(POWERPC_DARWIN, test x$TARGET = xPOWERPC_DARWIN)
|
||||
AM_CONDITIONAL(POWERPC_FREEBSD, test x$TARGET = xPOWERPC_FREEBSD)
|
||||
AM_CONDITIONAL(AARCH64, test x$TARGET = xAARCH64)
|
||||
AM_CONDITIONAL(ARM, test x$TARGET = xARM)
|
||||
AM_CONDITIONAL(AVR32, test x$TARGET = xAVR32)
|
||||
AM_CONDITIONAL(LIBFFI_CRIS, test x$TARGET = xLIBFFI_CRIS)
|
||||
@@ -244,6 +295,8 @@ AM_CONDITIONAL(SH64, test x$TARGET = xSH64)
|
||||
AM_CONDITIONAL(PA_LINUX, test x$TARGET = xPA_LINUX)
|
||||
AM_CONDITIONAL(PA_HPUX, test x$TARGET = xPA_HPUX)
|
||||
AM_CONDITIONAL(PA64_HPUX, test x$TARGET = xPA64_HPUX)
|
||||
AM_CONDITIONAL(TILE, test x$TARGET = xTILE)
|
||||
AM_CONDITIONAL(XTENSA, test x$TARGET = xXTENSA)
|
||||
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_FUNCS(memcpy)
|
||||
@@ -289,7 +342,7 @@ if test x$TARGET = xSPARC; then
|
||||
libffi_cv_as_register_pseudo_op, [
|
||||
libffi_cv_as_register_pseudo_op=unknown
|
||||
# Check if we have .register
|
||||
AC_TRY_COMPILE([asm (".register %g2, #scratch");],,
|
||||
AC_TRY_COMPILE(,[asm (".register %g2, #scratch");],
|
||||
[libffi_cv_as_register_pseudo_op=yes],
|
||||
[libffi_cv_as_register_pseudo_op=no])
|
||||
])
|
||||
@@ -302,10 +355,10 @@ fi
|
||||
if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64; then
|
||||
AC_CACHE_CHECK([assembler supports pc related relocs],
|
||||
libffi_cv_as_x86_pcrel, [
|
||||
libffi_cv_as_x86_pcrel=yes
|
||||
libffi_cv_as_x86_pcrel=no
|
||||
echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s
|
||||
if $CC $CFLAGS -c conftest.s 2>&1 | $EGREP -i 'illegal|warning' > /dev/null; then
|
||||
libffi_cv_as_x86_pcrel=no
|
||||
if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then
|
||||
libffi_cv_as_x86_pcrel=yes
|
||||
fi
|
||||
])
|
||||
if test "x$libffi_cv_as_x86_pcrel" = xyes; then
|
||||
@@ -317,7 +370,7 @@ if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64
|
||||
libffi_cv_as_ascii_pseudo_op, [
|
||||
libffi_cv_as_ascii_pseudo_op=unknown
|
||||
# Check if we have .ascii
|
||||
AC_TRY_COMPILE([asm (".ascii \\"string\\"");],,
|
||||
AC_TRY_COMPILE(,[asm (".ascii \\"string\\"");],
|
||||
[libffi_cv_as_ascii_pseudo_op=yes],
|
||||
[libffi_cv_as_ascii_pseudo_op=no])
|
||||
])
|
||||
@@ -330,7 +383,7 @@ if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64
|
||||
libffi_cv_as_string_pseudo_op, [
|
||||
libffi_cv_as_string_pseudo_op=unknown
|
||||
# Check if we have .string
|
||||
AC_TRY_COMPILE([asm (".string \\"string\\"");],,
|
||||
AC_TRY_COMPILE(,[asm (".string \\"string\\"");],
|
||||
[libffi_cv_as_string_pseudo_op=yes],
|
||||
[libffi_cv_as_string_pseudo_op=no])
|
||||
])
|
||||
@@ -340,6 +393,14 @@ if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64
|
||||
fi
|
||||
fi
|
||||
|
||||
# On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC.
|
||||
AC_ARG_ENABLE(pax_emutramp,
|
||||
[ --enable-pax_emutramp enable pax emulated trampolines, for we can't use PROT_EXEC],
|
||||
if test "$enable_pax_emutramp" = "yes"; then
|
||||
AC_DEFINE(FFI_MMAP_EXEC_EMUTRAMP_PAX, 1,
|
||||
[Define this if you want to enable pax emulated trampolines])
|
||||
fi)
|
||||
|
||||
if test x$TARGET = xX86_WIN64; then
|
||||
LT_SYS_SYMBOL_USCORE
|
||||
if test "x$sys_symbol_underscore" = xyes; then
|
||||
@@ -347,7 +408,6 @@ if test x$TARGET = xX86_WIN64; then
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
FFI_EXEC_TRAMPOLINE_TABLE=0
|
||||
case "$target" in
|
||||
*arm*-apple-darwin*)
|
||||
@@ -356,7 +416,7 @@ case "$target" in
|
||||
[Cannot use PROT_EXEC on this target, so, we revert to
|
||||
alternative means])
|
||||
;;
|
||||
*-apple-darwin1[[10]]* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris*)
|
||||
*-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris*)
|
||||
AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1,
|
||||
[Cannot use malloc on this target, so, we revert to
|
||||
alternative means])
|
||||
@@ -385,11 +445,12 @@ if test "x$GCC" = "xyes"; then
|
||||
libffi_cv_ro_eh_frame, [
|
||||
libffi_cv_ro_eh_frame=no
|
||||
echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
|
||||
if $CC $CFLAGS -S -fpic -fexceptions -o conftest.s conftest.c > /dev/null 2>&1; then
|
||||
if grep '.section.*eh_frame.*"a"' conftest.s > /dev/null; then
|
||||
libffi_cv_ro_eh_frame=yes
|
||||
elif grep '.section.*eh_frame.*#alloc' conftest.c \
|
||||
| grep -v '#write' > /dev/null; then
|
||||
if $CC $CFLAGS -c -fpic -fexceptions -o conftest.o conftest.c > /dev/null 2>&1; then
|
||||
objdump -h conftest.o > conftest.dump 2>&1
|
||||
libffi_eh_frame_line=`grep -n eh_frame conftest.dump | cut -d: -f 1`
|
||||
libffi_test_line=`expr $libffi_eh_frame_line + 1`p
|
||||
sed -n $libffi_test_line conftest.dump > conftest.line
|
||||
if grep READONLY conftest.line > /dev/null; then
|
||||
libffi_cv_ro_eh_frame=yes
|
||||
fi
|
||||
fi
|
||||
@@ -455,6 +516,7 @@ AC_ARG_ENABLE(structs,
|
||||
if test "$enable_structs" = "no"; then
|
||||
AC_DEFINE(FFI_NO_STRUCTS, 1, [Define this is you do not want support for aggregate types.])
|
||||
fi)
|
||||
AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes")
|
||||
|
||||
AC_ARG_ENABLE(raw-api,
|
||||
[ --disable-raw-api make the raw api unavailable],
|
||||
@@ -470,7 +532,7 @@ AC_ARG_ENABLE(purify-safety,
|
||||
|
||||
# These variables are only ever used when we cross-build to X86_WIN32.
|
||||
# And we only support this with GCC, so...
|
||||
if test x"$GCC" != x"no"; then
|
||||
if test "x$GCC" = "xyes"; then
|
||||
if test -n "$with_cross_host" &&
|
||||
test x"$with_cross_host" != x"no"; then
|
||||
toolexecdir='$(exec_prefix)/$(target_alias)'
|
||||
@@ -485,14 +547,10 @@ if test x"$GCC" != x"no"; then
|
||||
*) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
|
||||
esac
|
||||
AC_SUBST(toolexecdir)
|
||||
AC_SUBST(toolexeclibdir)
|
||||
fi
|
||||
|
||||
if test "${multilib}" = "yes"; then
|
||||
multilib_arg="--enable-multilib"
|
||||
else
|
||||
multilib_arg=
|
||||
toolexeclibdir='$(libdir)'
|
||||
fi
|
||||
AC_SUBST(toolexeclibdir)
|
||||
|
||||
AC_CONFIG_COMMANDS(include, [test -d include || mkdir include])
|
||||
AC_CONFIG_COMMANDS(src, [
|
||||
@@ -1,4 +0,0 @@
|
||||
This directory contains code which has been contributed by JNA users. If no
|
||||
tests are included, you should assume the code has only been checked for
|
||||
compile-time errors :)
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="/jnalib/dist/jna.jar"/>
|
||||
<classpathentry kind="src" path="/platform"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>alphamaskdemo</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,66 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="jnacontrib.alphamaskdemo" default="jar" basedir=".">
|
||||
<description>Builds, tests, and runs the project jnacontrib.alphamaskdemo.</description>
|
||||
<!-- Locations -->
|
||||
<property name="src" location="."/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="jna-dist" location="../../dist"/>
|
||||
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-alphamask.jar"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.AlphaMaskDemo" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset file="${file.reference.jna.jar}"/>
|
||||
<fileset dir="../platform/dist" includes="platform.jar"/>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${classes}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${classes}"/>
|
||||
<delete file="${jar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes}"/>
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com"/>
|
||||
<!-- jna -->
|
||||
<zipfileset src="${file.reference.jna.jar}"/>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
@@ -1,530 +0,0 @@
|
||||
/* 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.
|
||||
*
|
||||
* 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.contrib.demo;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.Window;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.awt.image.Raster;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.JWindow;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.TransferHandler;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.MouseInputAdapter;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
import com.sun.jna.platform.unix.X11;
|
||||
import com.sun.jna.platform.unix.X11.Display;
|
||||
import com.sun.jna.platform.unix.X11.GC;
|
||||
import com.sun.jna.platform.win32.GDI32;
|
||||
import com.sun.jna.platform.win32.User32;
|
||||
import com.sun.jna.platform.win32.WinGDI;
|
||||
import com.sun.jna.platform.win32.WinUser;
|
||||
import com.sun.jna.platform.win32.WinDef.HBITMAP;
|
||||
import com.sun.jna.platform.win32.WinDef.HDC;
|
||||
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||
import com.sun.jna.platform.win32.WinGDI.BITMAPINFO;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinUser.BLENDFUNCTION;
|
||||
import com.sun.jna.platform.win32.WinUser.POINT;
|
||||
import com.sun.jna.platform.win32.WinUser.SIZE;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
// 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 AlphaMaskDemo 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 JFrame frame;
|
||||
private JWindow alphaWindow;
|
||||
private float alpha = 1f;
|
||||
private Image image;
|
||||
|
||||
private void update() {
|
||||
update(false, true);
|
||||
}
|
||||
|
||||
private void update(boolean a, boolean i) {
|
||||
String os = System.getProperty("os.name");
|
||||
if (os.startsWith("Windows"))
|
||||
updateW32(a, i);
|
||||
else if (os.startsWith("Linux"))
|
||||
updateX11(a, i);
|
||||
else if (os.startsWith("Mac"))
|
||||
updateMac(a, i);
|
||||
}
|
||||
|
||||
private void updateMac(boolean a, boolean i) {
|
||||
if (!alphaWindow.isDisplayable()) {
|
||||
alphaWindow.pack();
|
||||
}
|
||||
if (a)
|
||||
WindowUtils.setWindowAlpha(alphaWindow, alpha);
|
||||
if (i) {
|
||||
alphaWindow.setBackground(new Color(0,0,0,0));
|
||||
alphaWindow.setContentPane(new JLabel(new ImageIcon(image)));
|
||||
alphaWindow.setSize(alphaWindow.getPreferredSize());
|
||||
}
|
||||
if (!alphaWindow.isVisible()) {
|
||||
Window parent = alphaWindow.getOwner();
|
||||
Point where = parent.getLocationOnScreen();
|
||||
where.translate(parent.getWidth(), 0);
|
||||
alphaWindow.setLocation(where);
|
||||
alphaWindow.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
private com.sun.jna.Memory buffer;
|
||||
private int[] pixels;
|
||||
private void updateX11(boolean a, boolean i) {
|
||||
X11 x11 = X11.INSTANCE;
|
||||
X11.Window win = X11.Window.None;
|
||||
Display dpy = x11.XOpenDisplay(null);
|
||||
try {
|
||||
if (!alphaWindow.isDisplayable()) {
|
||||
alphaWindow.pack();
|
||||
if (System.getProperty("java.version").matches("^1\\.4\\..*"))
|
||||
alphaWindow.setVisible(true);
|
||||
win = new X11.Window((int)Native.getWindowID(alphaWindow));
|
||||
Window parent = alphaWindow.getOwner();
|
||||
Point where = parent.getLocationOnScreen();
|
||||
where.translate(parent.getWidth(), 0);
|
||||
alphaWindow.removeAll();
|
||||
alphaWindow.setLocation(where);
|
||||
alphaWindow.setBackground(new Color(0,0,0,0));
|
||||
}
|
||||
else {
|
||||
win = new X11.Window((int)Native.getWindowID(alphaWindow));
|
||||
}
|
||||
|
||||
if (i) {
|
||||
int w = image.getWidth(null);
|
||||
int h = image.getHeight(null);
|
||||
alphaWindow.setSize(w, h);
|
||||
if (buffer == null || buffer.getSize() != w*h*4) {
|
||||
buffer = new com.sun.jna.Memory(w*h*4);
|
||||
pixels = new int[w*h];
|
||||
}
|
||||
|
||||
BufferedImage buf = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);
|
||||
Graphics g = buf.getGraphics();
|
||||
g.drawImage(image, 0, 0, w, h, null);
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
long blitTime, putImageTime, write;
|
||||
GC gc = x11.XCreateGC(dpy, win, new NativeLong(0), null);
|
||||
long gcTime = System.currentTimeMillis();
|
||||
try {
|
||||
Raster raster = buf.getData();
|
||||
int[] pixel = new int[4];
|
||||
for (int y=0;y < h;y++) {
|
||||
for (int x=0;x < w;x++) {
|
||||
raster.getPixel(x, y, pixel);
|
||||
int alpha = (pixel[3]&0xFF)<<24;
|
||||
int red = (pixel[2]&0xFF);
|
||||
int green = (pixel[1]&0xFF)<<8;
|
||||
int blue = (pixel[0]&0xFF)<<16;
|
||||
pixels[y*w+x] = alpha|red|green|blue;
|
||||
}
|
||||
}
|
||||
blitTime = System.currentTimeMillis();
|
||||
X11.XWindowAttributes xwa = new X11.XWindowAttributes();
|
||||
x11.XGetWindowAttributes(dpy, win, xwa);
|
||||
X11.XImage image = x11.XCreateImage(dpy, xwa.visual,
|
||||
32, X11.ZPixmap,
|
||||
0, buffer, w, h, 32, w*4);
|
||||
buffer.write(0, pixels, 0, pixels.length);
|
||||
write = System.currentTimeMillis();
|
||||
x11.XPutImage(dpy, win, gc, image, 0,0,0,0,w,h);
|
||||
x11.XFree(image.getPointer());
|
||||
putImageTime = System.currentTimeMillis();
|
||||
}
|
||||
finally {
|
||||
if (gc != null)
|
||||
x11.XFreeGC(dpy, gc);
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
//System.out.println("gc: " + (gcTime-start) + "ms");
|
||||
//System.out.println("blit: " + (blitTime-gcTime) + "ms");
|
||||
//System.out.println("write: " + (write-blitTime) + "ms");
|
||||
//System.out.println("put image: " + (putImageTime-write) + "ms");
|
||||
//System.out.println("total: " + (end-start) + "ms");
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if (dpy != null)
|
||||
x11.XCloseDisplay(dpy);
|
||||
}
|
||||
if (a)
|
||||
WindowUtils.setWindowAlpha(alphaWindow, alpha);
|
||||
|
||||
if (!alphaWindow.isVisible()) {
|
||||
alphaWindow.setVisible(true);
|
||||
// hack for initial refresh (X11)
|
||||
update(true, true);
|
||||
}
|
||||
}
|
||||
|
||||
private HWND getHwnd(Window w) {
|
||||
HWND hwnd = new HWND();
|
||||
hwnd.setPointer(Native.getWindowPointer(w));
|
||||
return hwnd;
|
||||
}
|
||||
|
||||
private void updateW32(boolean a, boolean i) {
|
||||
User32 user = User32.INSTANCE;
|
||||
GDI32 gdi = GDI32.INSTANCE;
|
||||
HWND hWnd = null;
|
||||
|
||||
if (!alphaWindow.isDisplayable()) {
|
||||
alphaWindow.pack();
|
||||
hWnd = getHwnd(alphaWindow);
|
||||
int flags = user.GetWindowLong(hWnd, WinUser.GWL_EXSTYLE);
|
||||
flags |= WinUser.WS_EX_LAYERED;
|
||||
user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags);
|
||||
Window parent = alphaWindow.getOwner();
|
||||
Point where = parent.getLocationOnScreen();
|
||||
where.translate(parent.getWidth(), 0);
|
||||
alphaWindow.setLocation(where);
|
||||
}
|
||||
else {
|
||||
hWnd = getHwnd(alphaWindow);
|
||||
}
|
||||
|
||||
if (i) {
|
||||
int w = image.getWidth(null);
|
||||
int h = image.getHeight(null);
|
||||
HDC screenDC = user.GetDC(null);
|
||||
HDC memDC = gdi.CreateCompatibleDC(screenDC);
|
||||
HBITMAP hBitmap = null;
|
||||
HANDLE oldBitmap = null;
|
||||
|
||||
try {
|
||||
BufferedImage buf = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);
|
||||
Graphics g = buf.getGraphics();
|
||||
g.drawImage(image, 0, 0, w, h, null);
|
||||
|
||||
BITMAPINFO bmi = new BITMAPINFO();
|
||||
bmi.bmiHeader.biWidth = w;
|
||||
bmi.bmiHeader.biHeight = h;
|
||||
bmi.bmiHeader.biPlanes = 1;
|
||||
bmi.bmiHeader.biBitCount = 32;
|
||||
bmi.bmiHeader.biCompression = WinGDI.BI_RGB;
|
||||
bmi.bmiHeader.biSizeImage = w * h * 4;
|
||||
|
||||
PointerByReference ppbits = new PointerByReference();
|
||||
hBitmap = gdi.CreateDIBSection(memDC, bmi, WinGDI.DIB_RGB_COLORS,
|
||||
ppbits, null, 0);
|
||||
oldBitmap = gdi.SelectObject(memDC, hBitmap);
|
||||
Pointer pbits = ppbits.getValue();
|
||||
|
||||
Raster raster = buf.getData();
|
||||
int[] pixel = new int[4];
|
||||
int[] bits = new int[w*h];
|
||||
for (int y=0;y < h;y++) {
|
||||
for (int x=0;x < w;x++) {
|
||||
raster.getPixel(x, h-y-1, pixel);
|
||||
int alpha = (pixel[3]&0xFF)<<24;
|
||||
int red = (pixel[2]&0xFF);
|
||||
int green = (pixel[1]&0xFF)<<8;
|
||||
int blue = (pixel[0]&0xFF)<<16;
|
||||
bits[x + y * w] = alpha|red|green|blue;
|
||||
}
|
||||
}
|
||||
pbits.write(0, bits, 0, bits.length);
|
||||
|
||||
SIZE size = new SIZE();
|
||||
size.cx = w;
|
||||
size.cy = h;
|
||||
POINT loc = new POINT();
|
||||
loc.x = alphaWindow.getX();
|
||||
loc.y = alphaWindow.getY();
|
||||
POINT srcLoc = new POINT();
|
||||
BLENDFUNCTION blend = new BLENDFUNCTION();
|
||||
blend.SourceConstantAlpha = (byte)(alpha * 255);
|
||||
blend.AlphaFormat = WinUser.AC_SRC_ALPHA;
|
||||
user.UpdateLayeredWindow(hWnd, screenDC, loc, size, memDC, srcLoc,
|
||||
0, blend, WinUser.ULW_ALPHA);
|
||||
}
|
||||
finally {
|
||||
user.ReleaseDC(null, screenDC);
|
||||
if (hBitmap != null) {
|
||||
gdi.SelectObject(memDC, oldBitmap);
|
||||
gdi.DeleteObject(hBitmap);
|
||||
}
|
||||
gdi.DeleteDC(memDC);
|
||||
}
|
||||
}
|
||||
else if (a) {
|
||||
BLENDFUNCTION blend = new BLENDFUNCTION();
|
||||
blend.SourceConstantAlpha = (byte)(alpha * 255);
|
||||
blend.AlphaFormat = WinUser.AC_SRC_ALPHA;
|
||||
user.UpdateLayeredWindow(hWnd, null, null, null, null, null,
|
||||
0, blend, WinUser.ULW_ALPHA);
|
||||
}
|
||||
|
||||
if (!alphaWindow.isVisible()) {
|
||||
alphaWindow.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
private ImageObserver observer = new ImageObserver() {
|
||||
public boolean imageUpdate(final Image img, int infoflags, int x, int y, int width, int height) {
|
||||
if ((infoflags & (ImageObserver.ALLBITS|ImageObserver.FRAMEBITS)) != 0) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
setImage(img);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
else if ((infoflags & (ImageObserver.ERROR|ImageObserver.ABORT)) != 0) {
|
||||
System.out.println("Image load error: " + img);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
private void setImage(final Image image) {
|
||||
int w = image.getWidth(observer);
|
||||
int h = image.getHeight(observer);
|
||||
if (w > 0 && h > 0) {
|
||||
this.image = image;
|
||||
frame.setIconImage(image);
|
||||
update(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void setAlpha(float alpha) {
|
||||
this.alpha = alpha = Math.min(1f, Math.max(0f, alpha));
|
||||
update(true, false);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// Must find a graphics configuration with a depth of 32 bits
|
||||
GraphicsConfiguration gconfig = WindowUtils.getAlphaCompatibleGraphicsConfiguration();
|
||||
frame = new JFrame("Alpha Mask Demo");
|
||||
alphaWindow = new JWindow(frame, gconfig);
|
||||
MouseInputAdapter handler = new MouseInputAdapter() {
|
||||
private Point offset;
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (SwingUtilities.isLeftMouseButton(e))
|
||||
offset = e.getPoint();
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
offset = null;
|
||||
// hack (w32) calling this has the side effect of re-enabling
|
||||
// hit testing; not sure why it gets disabled
|
||||
if (System.getProperty("os.name").startsWith("Windows"))
|
||||
update(true, true);
|
||||
}
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
if (offset != null) {
|
||||
Window w = (Window)e.getSource();
|
||||
Point where = e.getPoint();
|
||||
where.translate(-offset.x, -offset.y);
|
||||
Point loc = w.getLocationOnScreen();
|
||||
loc.translate(where.x, where.y);
|
||||
w.setLocation(loc.x, loc.y);
|
||||
}
|
||||
}
|
||||
};
|
||||
alphaWindow.addMouseListener(handler);
|
||||
alphaWindow.addMouseMotionListener(handler);
|
||||
JPanel p = new JPanel(new BorderLayout(8, 8));
|
||||
p.setBorder(new EmptyBorder(8, 8, 8, 8));
|
||||
p.setTransferHandler(new TransferHandler() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) {
|
||||
List<DataFlavor> list = Arrays.asList(transferFlavors);
|
||||
if (list.contains(URL_FLAVOR)
|
||||
|| list.contains(URI_LIST_FLAVOR)
|
||||
|| list.contains(DataFlavor.imageFlavor)
|
||||
|| list.contains(DataFlavor.javaFileListFlavor)) {
|
||||
return true;
|
||||
}
|
||||
if (DataFlavor.selectBestTextFlavor(transferFlavors) != null) {
|
||||
return true;
|
||||
}
|
||||
System.out.println("No acceptable flavor found in "
|
||||
+ Arrays.asList(transferFlavors));
|
||||
return false;
|
||||
}
|
||||
public boolean importData(JComponent comp, Transferable t) {
|
||||
try {
|
||||
if (t.isDataFlavorSupported(URL_FLAVOR)) {
|
||||
URL url = (URL)t.getTransferData(URL_FLAVOR);
|
||||
setImage(Toolkit.getDefaultToolkit().getImage(url));
|
||||
return true;
|
||||
}
|
||||
if (t.isDataFlavorSupported(URI_LIST_FLAVOR)) {
|
||||
String s = (String)t.getTransferData(URI_LIST_FLAVOR);
|
||||
String[] uris = s.split("[\r\n]");
|
||||
if (uris.length > 0) {
|
||||
URL url = new URL(uris[0]);
|
||||
setImage(Toolkit.getDefaultToolkit().getImage(url));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (t.isDataFlavorSupported(DataFlavor.imageFlavor)) {
|
||||
Image image = (Image)t.getTransferData(DataFlavor.imageFlavor);
|
||||
setImage(image);
|
||||
return true;
|
||||
}
|
||||
if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)){
|
||||
List<File> files = (List<File>) t.getTransferData(DataFlavor.javaFileListFlavor);
|
||||
File f = files.get(0);
|
||||
URL url = new URL("file://" + f.toURI().toURL().getPath());
|
||||
Image image = Toolkit.getDefaultToolkit().getImage(url);
|
||||
setImage(image);
|
||||
return true;
|
||||
}
|
||||
DataFlavor flavor = DataFlavor.selectBestTextFlavor(t.getTransferDataFlavors());
|
||||
if (flavor != null) {
|
||||
Reader reader = flavor.getReaderForText(t);
|
||||
char[] buf = new char[512];
|
||||
StringBuffer b = new StringBuffer();
|
||||
int count;
|
||||
// excise excess NUL characters (bug in firefox, java
|
||||
// or my code, not sure which). someone got the
|
||||
// encoding wrong
|
||||
while ((count = reader.read(buf)) > 0) {
|
||||
for (int i=0;i < count;i++) {
|
||||
if (buf[i] != 0)
|
||||
b.append(buf, i, 1);
|
||||
}
|
||||
}
|
||||
String html = b.toString();
|
||||
Pattern p = Pattern.compile("<img.*src=\"([^\\\"\">]+)\"",
|
||||
Pattern.CANON_EQ|Pattern.UNICODE_CASE);
|
||||
Matcher m = p.matcher(html);
|
||||
if (m.find()) {
|
||||
URL url = new URL(m.group(1));
|
||||
System.out.println("Load image from " + url);
|
||||
Image image = Toolkit.getDefaultToolkit().getImage(url);
|
||||
setImage(image);
|
||||
return true;
|
||||
}
|
||||
System.out.println("Can't parse text: " + html);
|
||||
return false;
|
||||
}
|
||||
System.out.println("No flavor available: "
|
||||
+ Arrays.asList(t.getTransferDataFlavors()));
|
||||
}
|
||||
catch (UnsupportedFlavorException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
p.add(new JLabel("<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);
|
||||
final JSlider slider = new JSlider(0, 255, 255);
|
||||
slider.addChangeListener(new ChangeListener() {
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
int value = slider.getValue();
|
||||
setAlpha(value / 255f);
|
||||
}
|
||||
});
|
||||
p.add(slider, BorderLayout.SOUTH);
|
||||
|
||||
frame.getContentPane().add(p);
|
||||
frame.pack();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
centerOnScreen(frame);
|
||||
frame.setVisible(true);
|
||||
p.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
update();
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
URL url = getClass().getResource("tardis.png");
|
||||
if (url != null) {
|
||||
setImage(Toolkit.getDefaultToolkit().getImage(url));
|
||||
}
|
||||
}
|
||||
catch(Exception e) { }
|
||||
}
|
||||
|
||||
/** Center the given {@link Window} on the default screen. */
|
||||
private static void centerOnScreen(Window window) {
|
||||
Point center = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
|
||||
Rectangle max = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
|
||||
int x = Math.max(center.x - Math.round(window.getWidth()/2f), max.x);
|
||||
int y = Math.max(center.y - Math.round(window.getHeight()/2f), max.y);
|
||||
window.setLocation(new Point(x, y));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
SwingUtilities.invokeLater(new AlphaMaskDemo());
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generic JNLP/Web Start Configuration -->
|
||||
<jnlp spec="1.0" codebase="http://abbot.sf.net/demo" href="AlphaMaskDemo.jnlp">
|
||||
<information>
|
||||
<title>Alpha Mask Demo</title>
|
||||
<vendor>Technomage</vendor>
|
||||
<homepage href="http://rabbit-hole.blogspot.com"/>
|
||||
<description>Demo of a per-pixel alpha masked window.</description>
|
||||
<description kind="short">Alpha Mask</description>
|
||||
</information>
|
||||
<resources>
|
||||
<j2se version="1.3+" href="http://java.sun.com/products/autodl/j2se"/>
|
||||
<!-- Required for window transparency -->
|
||||
<property name="sun.java2d.noddraw" value="true"/>
|
||||
<jar href="examples.jar" main="true"/>
|
||||
<jar href="jna.jar"/>
|
||||
</resources>
|
||||
<resources os="Windows" arch="x86">
|
||||
<nativelib href="win32-x86.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"/>
|
||||
<nativelib href="linux-i386.jar"/>
|
||||
</resources>
|
||||
<resources os="Mac">
|
||||
<nativelib href="darwin.jar"/>
|
||||
</resources>
|
||||
<application-desc main-class="com.sun.jna.examples.AlphaMaskDemo"/>
|
||||
<security>
|
||||
<all-permissions/>
|
||||
</security>
|
||||
</jnlp>
|
||||
@@ -1,301 +0,0 @@
|
||||
/*
|
||||
* 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. 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.contrib.demo;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.Window;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.JWindow;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.TransferHandler;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.MouseInputAdapter;
|
||||
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
|
||||
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 JFrame frame;
|
||||
private JWindow alphaWindow;
|
||||
private JLabel icon;
|
||||
private ImageObserver observer = new ImageObserver() {
|
||||
public boolean imageUpdate(final Image img, int infoflags, int x,
|
||||
int y, int width, int height) {
|
||||
if ((infoflags & (ImageObserver.ALLBITS | ImageObserver.FRAMEBITS)) != 0) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
setImage(img);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
else if ((infoflags & (ImageObserver.ERROR | ImageObserver.ABORT)) != 0) {
|
||||
System.err.println("Image load error: " + img);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
private void setImage(final Image image) {
|
||||
final int w = image.getWidth(observer);
|
||||
final int h = image.getHeight(observer);
|
||||
if (w > 0 && h > 0) {
|
||||
frame.setIconImage(image);
|
||||
icon.setIcon(new ImageIcon(image));
|
||||
if (!alphaWindow.isVisible()) {
|
||||
alphaWindow.pack();
|
||||
alphaWindow.setVisible(true);
|
||||
}
|
||||
else {
|
||||
alphaWindow.setSize(alphaWindow.getPreferredSize());
|
||||
}
|
||||
icon.getParent().invalidate();
|
||||
icon.getParent().repaint();
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// Must find a graphics configuration with a depth of 32 bits
|
||||
GraphicsConfiguration gconfig = WindowUtils.getAlphaCompatibleGraphicsConfiguration();
|
||||
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");
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
alphaWindow.getContentPane().add(label, BorderLayout.NORTH);
|
||||
alphaWindow.getContentPane().add(quit, BorderLayout.SOUTH);
|
||||
quit.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
MouseInputAdapter handler = new MouseInputAdapter() {
|
||||
private Point offset;
|
||||
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (SwingUtilities.isLeftMouseButton(e))
|
||||
offset = e.getPoint();
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
offset = null;
|
||||
}
|
||||
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
if (offset != null) {
|
||||
Window w = (Window)e.getSource();
|
||||
Point where = e.getPoint();
|
||||
where.translate(-offset.x, -offset.y);
|
||||
Point loc = w.getLocationOnScreen();
|
||||
loc.translate(where.x, where.y);
|
||||
w.setLocation(loc.x, loc.y);
|
||||
}
|
||||
}
|
||||
};
|
||||
alphaWindow.addMouseListener(handler);
|
||||
alphaWindow.addMouseMotionListener(handler);
|
||||
JPanel p = new JPanel(new BorderLayout(8, 8));
|
||||
p.setBorder(new EmptyBorder(8, 8, 8, 8));
|
||||
p.setTransferHandler(new TransferHandler() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public boolean canImport(JComponent comp,
|
||||
DataFlavor[] transferFlavors) {
|
||||
List<DataFlavor> list = Arrays.asList(transferFlavors);
|
||||
if (list.contains(URL_FLAVOR) || list.contains(URI_LIST_FLAVOR)
|
||||
|| list.contains(DataFlavor.imageFlavor)
|
||||
|| list.contains(DataFlavor.javaFileListFlavor)) {
|
||||
return true;
|
||||
}
|
||||
if (DataFlavor.selectBestTextFlavor(transferFlavors) != null) {
|
||||
return true;
|
||||
}
|
||||
System.err.println("No acceptable flavor found in "
|
||||
+ Arrays.asList(transferFlavors));
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean importData(JComponent comp, Transferable t) {
|
||||
try {
|
||||
if (t.isDataFlavorSupported(URL_FLAVOR)) {
|
||||
URL url = (URL)t.getTransferData(URL_FLAVOR);
|
||||
setImage(Toolkit.getDefaultToolkit().getImage(url));
|
||||
return true;
|
||||
}
|
||||
if (t.isDataFlavorSupported(URI_LIST_FLAVOR)) {
|
||||
String s = (String)t.getTransferData(URI_LIST_FLAVOR);
|
||||
String[] uris = s.split("[\r\n]");
|
||||
if (uris.length > 0) {
|
||||
URL url = new URL(uris[0]);
|
||||
setImage(Toolkit.getDefaultToolkit().getImage(url));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (t.isDataFlavorSupported(DataFlavor.imageFlavor)) {
|
||||
Image image = (Image)t
|
||||
.getTransferData(DataFlavor.imageFlavor);
|
||||
setImage(image);
|
||||
return true;
|
||||
}
|
||||
if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
|
||||
List<File> files = (List<File>) t.getTransferData(DataFlavor.javaFileListFlavor);
|
||||
File f = files.get(0);
|
||||
URL url = new URL("file://"
|
||||
+ f.toURI().toURL().getPath());
|
||||
Image image = Toolkit.getDefaultToolkit().getImage(url);
|
||||
setImage(image);
|
||||
return true;
|
||||
}
|
||||
DataFlavor flavor = DataFlavor
|
||||
.selectBestTextFlavor(t
|
||||
.getTransferDataFlavors());
|
||||
if (flavor != null) {
|
||||
Reader reader = flavor.getReaderForText(t);
|
||||
char[] buf = new char[512];
|
||||
StringBuffer b = new StringBuffer();
|
||||
int count;
|
||||
// excise excess NUL characters (bug in firefox,
|
||||
// java
|
||||
// or my code, not sure which). someone got the
|
||||
// encoding wrong
|
||||
while ((count = reader.read(buf)) > 0) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (buf[i] != 0)
|
||||
b.append(buf, i, 1);
|
||||
}
|
||||
}
|
||||
String html = b.toString();
|
||||
Pattern p = Pattern
|
||||
.compile(
|
||||
"<img.*src=\"([^\\\"\">]+)\"",
|
||||
Pattern.CANON_EQ
|
||||
| Pattern.UNICODE_CASE);
|
||||
Matcher m = p.matcher(html);
|
||||
if (m.find()) {
|
||||
URL url = new URL(m.group(1));
|
||||
System.out.println("Load image from " + url);
|
||||
Image image = Toolkit.getDefaultToolkit()
|
||||
.getImage(url);
|
||||
setImage(image);
|
||||
return true;
|
||||
}
|
||||
System.err.println("Can't parse text: " + html);
|
||||
return false;
|
||||
}
|
||||
System.err.println("No flavor available: "
|
||||
+ Arrays.asList(t.getTransferDataFlavors()));
|
||||
}
|
||||
catch (UnsupportedFlavorException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
p
|
||||
.add(
|
||||
new JLabel(
|
||||
"<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) {
|
||||
int value = slider.getValue();
|
||||
WindowUtils.setWindowAlpha(alphaWindow, value / 255f);
|
||||
}
|
||||
});
|
||||
p.add(slider, BorderLayout.SOUTH);
|
||||
frame.getContentPane().add(p);
|
||||
frame.pack();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
centerOnScreen(frame);
|
||||
frame.setVisible(true);
|
||||
WindowUtils.setWindowTransparent(alphaWindow, true);
|
||||
alphaWindow.setLocation(frame.getX() + frame.getWidth() + 4,
|
||||
frame.getY());
|
||||
try {
|
||||
URL url = getClass().getResource("tardis.png");
|
||||
if (url != null) {
|
||||
setImage(Toolkit.getDefaultToolkit().getImage(url));
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
/** Center the given {@link Window} on the default screen. */
|
||||
private static void centerOnScreen(Window window) {
|
||||
Point center = GraphicsEnvironment.getLocalGraphicsEnvironment()
|
||||
.getCenterPoint();
|
||||
Rectangle max = GraphicsEnvironment.getLocalGraphicsEnvironment()
|
||||
.getMaximumWindowBounds();
|
||||
int x = Math.max(center.x - Math.round(window.getWidth() / 2f), max.x);
|
||||
int y = Math.max(center.y - Math.round(window.getHeight() / 2f), max.y);
|
||||
window.setLocation(new Point(x, y));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
System.setProperty("sun.java2d.noddraw", "true");
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
SwingUtilities.invokeLater(new AlphaMaskDemo2());
|
||||
}
|
||||
}
|
||||
Arquivo binário não exibido.
|
Antes Largura: | Altura: | Tamanho: 18 KiB |
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="src" path="/platform"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>balloonmanagerdemo</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,68 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="jnacontrib.balloonmanagerdemo" default="jar" basedir=".">
|
||||
<description>Builds, tests, and runs the project jnacontrib.balloonmanagerdemo.</description>
|
||||
<!-- Locations -->
|
||||
<property name="src" location="."/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="jna-dist" location="../../dist"/>
|
||||
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-balloonmanager.jar"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.BalloonManagerDemo" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset file="${file.reference.jna.jar}"/>
|
||||
<fileset dir="../platform/dist" includes="platform.jar"/>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${classes}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${classes}"/>
|
||||
<delete file="${jar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes}"/>
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com"/>
|
||||
<!-- jna -->
|
||||
<zipfileset src="${file.reference.jna.jar}"/>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
@@ -1,263 +0,0 @@
|
||||
/*
|
||||
* 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.contrib.demo;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GradientPaint;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Shape;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.JWindow;
|
||||
import javax.swing.Popup;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
|
||||
/**
|
||||
* Provides a popup balloon containing an arbitrary component. This provides
|
||||
* a form of content-specific decoration less transient than a tooltip, and less
|
||||
* heavyweight and more adaptable to changing content than a dedicated window.
|
||||
* Clients are responsible for invoking show and hide on the provided popup.
|
||||
*/
|
||||
// TODO: anchor balloon point
|
||||
// TODO: connect drop shadow and parent masks
|
||||
// TODO: proper preferred size for html
|
||||
// TODO: lightweight popups
|
||||
public class BalloonManager {
|
||||
|
||||
// Avoid using drop shadow in some instances
|
||||
private static boolean useDropShadow() {
|
||||
return WindowUtils.isWindowAlphaSupported();
|
||||
}
|
||||
|
||||
private static class DropShadow extends JWindow {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final float SHADOW_ALPHA = .25f;
|
||||
private static final float YSCALE = .80f;
|
||||
private static final double ANGLE = 2*Math.PI/24;
|
||||
private static final Point OFFSET = new Point(8, 8);
|
||||
private static final Color COLOR = new Color(0, 0, 0, 50);
|
||||
|
||||
private Shape parentMask;
|
||||
private ComponentListener listener;
|
||||
public DropShadow(final Window parent, Shape mask) {
|
||||
super(parent);
|
||||
setFocusableWindowState(false);
|
||||
setName("###overrideRedirect###");
|
||||
|
||||
Point where = parent.isShowing()
|
||||
? parent.getLocationOnScreen() : parent.getLocation();
|
||||
setLocation(where.x + OFFSET.x, where.y + OFFSET.y);
|
||||
setBackground(COLOR);
|
||||
getContentPane().setBackground(COLOR);
|
||||
|
||||
parentMask = mask;
|
||||
parent.addComponentListener(listener = new ComponentAdapter() {
|
||||
public void componentMoved(ComponentEvent e) {
|
||||
Point where = getOwner().isShowing()
|
||||
? getOwner().getLocationOnScreen()
|
||||
: getOwner().getLocation();
|
||||
setLocation(where.x + OFFSET.x, where.y + OFFSET.y);
|
||||
}
|
||||
public void componentResized(ComponentEvent e) {
|
||||
Component c = e.getComponent();
|
||||
int extra = c.getWidth() + (int)Math.sin(ANGLE)*c.getHeight();
|
||||
setSize(c.getWidth() + extra, c.getHeight());
|
||||
WindowUtils.setWindowMask(DropShadow.this, getMask());
|
||||
}
|
||||
public void componentShown(ComponentEvent e) {
|
||||
if (!isVisible()) {
|
||||
pack();
|
||||
setVisible(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
addWindowListener(new WindowAdapter() {
|
||||
public void windowClosed(WindowEvent e) {
|
||||
if (listener != null) {
|
||||
parent.removeComponentListener(listener);
|
||||
listener = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
WindowUtils.setWindowMask(DropShadow.this, getMask());
|
||||
WindowUtils.setWindowAlpha(DropShadow.this, SHADOW_ALPHA);
|
||||
if (parent.isVisible()) {
|
||||
pack();
|
||||
setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void paint(Graphics graphics) {
|
||||
Graphics2D g = (Graphics2D)graphics.create();
|
||||
// Workaround for OSX since we only get automatic clipping
|
||||
// on the content pane and below
|
||||
g.setClip(getMask());
|
||||
g.setPaint(new GradientPaint(0, getHeight()/2, new Color(0,0,0,0), getWidth(), getHeight()/2, new Color(0,0,0,255)));
|
||||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
g.dispose();
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
Dimension size = getOwner().getPreferredSize();
|
||||
size.width += 100;
|
||||
size.height += 100;
|
||||
return size;
|
||||
}
|
||||
|
||||
private Shape getMask() {
|
||||
Area area = new Area(parentMask);
|
||||
Area clip = new Area(parentMask);
|
||||
|
||||
AffineTransform tx = new AffineTransform();
|
||||
tx.translate(Math.sin(ANGLE)*getOwner().getHeight(), 0);
|
||||
tx.shear(-Math.tan(ANGLE), 0);
|
||||
tx.scale(1, YSCALE);
|
||||
tx.translate(0, (1-YSCALE)*getOwner().getHeight());
|
||||
area.transform(tx);
|
||||
tx = new AffineTransform();
|
||||
tx.translate(-OFFSET.x, -OFFSET.y);
|
||||
clip.transform(tx);
|
||||
area.subtract(clip);
|
||||
return area;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class BubbleWindow extends JWindow {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final int Y_OFFSET = 50;
|
||||
private static final int ARC = 25;
|
||||
|
||||
private Point offset;
|
||||
private Area mask;
|
||||
private Dimension maskSize;
|
||||
private ComponentListener moveTracker = new ComponentAdapter() {
|
||||
public void componentMoved(ComponentEvent e) {
|
||||
Point where =
|
||||
e.getComponent().isShowing()
|
||||
? e.getComponent().getLocationOnScreen()
|
||||
: e.getComponent().getLocation();
|
||||
setLocation(where.x - offset.x, where.y - offset.y);
|
||||
// TODO preserve stacking order (linux)
|
||||
}
|
||||
};
|
||||
|
||||
public BubbleWindow(Window owner, Component content) {
|
||||
super(owner);
|
||||
setFocusableWindowState(false);
|
||||
setName("###overrideRedirect###");
|
||||
getContentPane().setBackground(Color.white);
|
||||
getContentPane().add(content, BorderLayout.CENTER);
|
||||
getContentPane().add(Box.createVerticalStrut(Y_OFFSET), BorderLayout.SOUTH);
|
||||
owner.addComponentListener(moveTracker);
|
||||
setSize(getPreferredSize());
|
||||
mask = new Area(getMask(getWidth(), getHeight()));
|
||||
maskSize = getSize();
|
||||
WindowUtils.setWindowMask(BubbleWindow.this, mask);
|
||||
if (useDropShadow()) {
|
||||
new DropShadow(this, mask);
|
||||
}
|
||||
}
|
||||
|
||||
public void setBounds(int x, int y, int w, int h) {
|
||||
super.setBounds(x, y, w, h);
|
||||
Dimension size = new Dimension(w, h);
|
||||
if (mask != null && !size.equals(maskSize)) {
|
||||
mask.subtract(mask);
|
||||
mask.add(new Area(getMask(w, h)));
|
||||
maskSize = size;
|
||||
}
|
||||
}
|
||||
|
||||
public void setAnchorLocation(int x, int y) {
|
||||
super.setLocation(x, y);
|
||||
Window owner = getOwner();
|
||||
if (owner != null) {
|
||||
Point ref = owner.isShowing()
|
||||
? owner.getLocationOnScreen() : owner.getLocation();
|
||||
offset = new Point(ref.x - x, ref.y - y);
|
||||
}
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
getOwner().removeComponentListener(moveTracker);
|
||||
}
|
||||
|
||||
private Shape getMask(int w, int h) {
|
||||
Shape shape = new RoundRectangle2D.Float(0, 0, w, h-Y_OFFSET,
|
||||
ARC, ARC);
|
||||
Area area = new Area(shape);
|
||||
GeneralPath path = new GeneralPath();
|
||||
path.moveTo(w/3, h-1);
|
||||
path.lineTo(w/2, h-1-Y_OFFSET);
|
||||
path.lineTo(w*2/3, h-1-Y_OFFSET);
|
||||
path.closePath();
|
||||
area.add(new Area(path));
|
||||
return area;
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
Dimension size = super.getPreferredSize();
|
||||
size.height += Y_OFFSET;
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
/** Get a balloon pointing to the given location. The coordinates are
|
||||
* relative to <code>owner</code>, which if null, indicates the coordinates
|
||||
* are absolute.
|
||||
*/
|
||||
public static Popup getBalloon(final Component owner, final Component content, int x, int y) {
|
||||
|
||||
// Simulate PopupFactory, ensuring we get a heavyweight "popup"
|
||||
final Point origin =
|
||||
owner == null ? new Point(0, 0)
|
||||
: (owner.isShowing()
|
||||
? owner.getLocationOnScreen() : owner.getLocation());
|
||||
final Window parent = owner != null
|
||||
? SwingUtilities.getWindowAncestor(owner) : null;
|
||||
origin.translate(x, y);
|
||||
return new Popup() {
|
||||
private BubbleWindow w;
|
||||
public void show() {
|
||||
w = new BubbleWindow(parent, content);
|
||||
w.pack();
|
||||
Point where = new Point(origin);
|
||||
where.translate(-w.getWidth()/3, -w.getHeight());
|
||||
w.setAnchorLocation(where.x, where.y);
|
||||
w.setVisible(true);
|
||||
}
|
||||
public void hide() {
|
||||
w.setVisible(false);
|
||||
w.dispose();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
/* 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.
|
||||
*
|
||||
* 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.contrib.demo;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.Popup;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
|
||||
/** Demonstration of BalloonManager. */
|
||||
public class BalloonManagerDemo {
|
||||
private static final int ICON_SIZE = 48;
|
||||
private static class InfoIcon implements Icon {
|
||||
public int getIconHeight() {
|
||||
return ICON_SIZE;
|
||||
}
|
||||
public int getIconWidth() {
|
||||
return ICON_SIZE;
|
||||
}
|
||||
public void paintIcon(Component c, Graphics graphics, int x, int y) {
|
||||
Font font = UIManager.getFont("TextField.font");
|
||||
Graphics2D g = (Graphics2D)graphics.create(x, y, getIconWidth(), getIconHeight());
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||
g.setFont(font.deriveFont(Font.BOLD, getIconWidth()*3/4));
|
||||
g.setColor(Color.green.darker());
|
||||
final int SW = Math.max(getIconWidth()/10, 4);
|
||||
g.setStroke(new BasicStroke(SW));
|
||||
g.drawArc(SW/2, SW/2, getIconWidth()-SW-1, getIconHeight()-SW-1, 0, 360);
|
||||
Rectangle2D bounds =
|
||||
font.getStringBounds("i", g.getFontRenderContext());
|
||||
g.drawString("i", Math.round((getIconWidth() - bounds.getWidth())/2 - getIconWidth()/12),
|
||||
SW/2 + Math.round((getIconHeight()-bounds.getHeight())/2 - bounds.getY() + getIconHeight()/8));
|
||||
g.dispose();
|
||||
}
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
System.setProperty("sun.java2d.noddraw", "true");
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
}
|
||||
catch(Exception e) {
|
||||
}
|
||||
JFrame f = new JFrame("Balloon Test");
|
||||
final String BALLOON_TEXT = "<html><center>"
|
||||
+ "This is some sample balloon text<br>"
|
||||
+ "which has been formatted with html.<br>"
|
||||
+ "Click to dismiss.</center></html>";
|
||||
final JLabel content = new JLabel(BALLOON_TEXT);
|
||||
content.setIconTextGap(10);
|
||||
content.setBorder(new EmptyBorder(0, 8, 0, 8));
|
||||
content.setSize(content.getPreferredSize());
|
||||
content.setIcon(new InfoIcon());
|
||||
JLabel label = new JLabel("Click anywhere for more information");
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
label.addMouseListener(new MouseAdapter() {
|
||||
private MouseListener listener = new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
hidePopup(e);
|
||||
}
|
||||
};
|
||||
private Popup popup;
|
||||
private void hidePopup(MouseEvent e) {
|
||||
e.getComponent().removeMouseListener(listener);
|
||||
if (popup != null)
|
||||
popup.hide();
|
||||
}
|
||||
public void mousePressed(MouseEvent e) {
|
||||
hidePopup(e);
|
||||
popup = BalloonManager.getBalloon(e.getComponent(), content, e.getX(), e.getY());
|
||||
popup.show();
|
||||
content.getParent().addMouseListener(listener);
|
||||
}
|
||||
});
|
||||
f.getContentPane().add(label);
|
||||
f.pack();
|
||||
f.setSize(new Dimension(300, 300));
|
||||
f.setLocation(100, 100);
|
||||
try {
|
||||
// Force a load of JNA
|
||||
WindowUtils.setWindowMask(f, WindowUtils.MASK_NONE);
|
||||
f.setVisible(true);
|
||||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
}
|
||||
catch(UnsatisfiedLinkError e) {
|
||||
e.printStackTrace();
|
||||
String msg = e.getMessage()
|
||||
+ "\nError loading the JNA library";
|
||||
JTextArea area = new JTextArea(msg);
|
||||
area.setOpaque(false);
|
||||
area.setFont(UIManager.getFont("Label.font"));
|
||||
area.setEditable(false);
|
||||
area.setColumns(80);
|
||||
area.setRows(8);
|
||||
area.setWrapStyleWord(true);
|
||||
area.setLineWrap(true);
|
||||
JOptionPane.showMessageDialog(null, new JScrollPane(area),
|
||||
"Library Load Error: "
|
||||
+ System.getProperty("os.name")
|
||||
+ "/" + System.getProperty("os.arch"),
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="src" path="/platform"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>balloontips</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,7 +0,0 @@
|
||||
An implementation of balloon tips.
|
||||
|
||||
Compile the two classes in this directory. Requires Java 1.5+.
|
||||
|
||||
javac -cp examples.jar *.java
|
||||
java -cp .:examples.jar FilteredTextField
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="jnacontrib.balloontipsdemo" default="jar" basedir=".">
|
||||
<description>Builds, tests, and runs the project jnacontrib.balloontipsdemo.</description>
|
||||
<!-- Locations -->
|
||||
<property name="src" location="."/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="jna-dist" location="../../dist"/>
|
||||
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-balloontips.jar"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.FilteredTextField" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset file="${file.reference.jna.jar}"/>
|
||||
<fileset dir="../platform/dist" includes="platform.jar"/>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${classes}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${classes}"/>
|
||||
<delete file="${jar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes}"/>
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com"/>
|
||||
<!-- jna -->
|
||||
<zipfileset src="${file.reference.jna.jar}"/>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
@@ -1,519 +0,0 @@
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Point;
|
||||
import java.awt.Polygon;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JWindow;
|
||||
import javax.swing.Popup;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.Timer;
|
||||
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
|
||||
/**
|
||||
* The BalloonTipManager class handles creation and disposal of balloon style
|
||||
* tips that are typically used to display warning/error information based on
|
||||
* results from input validation. The balloon tip location and direction are
|
||||
* computed based on the owner component location on the screen. The balloon
|
||||
* tip is only displayed for a limited amount of time that is configurable.
|
||||
* The balloon tip is also disposed when the owner component loses focus or the
|
||||
* mouse is pressed.
|
||||
*/
|
||||
public class BalloonTipManager {
|
||||
public static final Color DEFAULT_BORDER_COLOR = Color.BLACK;
|
||||
public static final Color DEFAULT_BACKGROUND_COLOR = new Color(255, 255, 225);
|
||||
public static final Color DEFAULT_TEXT_COLOR = Color.BLACK;
|
||||
|
||||
private static final Integer VPOS_ABOVE = 0; // Positioned above component.
|
||||
private static final Integer VPOS_BELOW = 1; // Positioned below component.
|
||||
private static final Integer HPOS_LEFT = 0; // Arrow is on the left side.
|
||||
private static final Integer HPOS_RIGHT = 1; // Arros is on the right side.
|
||||
|
||||
private static Integer vpos = null;
|
||||
private static Integer hpos = null;
|
||||
|
||||
private static Timer hidePopupTimer = null;
|
||||
private static boolean isShowing = false;
|
||||
|
||||
|
||||
/*
|
||||
* The BalloonTip class defines the look of the BalloonTip object.
|
||||
*/
|
||||
private static final class BalloonTip extends JWindow {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Integer HMARGIN = 10;
|
||||
private static final Integer VMARGIN = 6;
|
||||
private static final Integer VSPACER = 4;
|
||||
private static final int ARC_D = 16;
|
||||
|
||||
private Area mask = null;
|
||||
private Dimension maskSize = null;
|
||||
private String[] textList = null;
|
||||
|
||||
private Color backgroundColor = null;
|
||||
private Color borderColor = null;
|
||||
private Color textColor = null;
|
||||
|
||||
/**
|
||||
* Create a BalloonTip object.
|
||||
* @param owner the parent window for the components
|
||||
* @param content the string for the balloon tip
|
||||
* @param position the position for the balloon; either above or below the
|
||||
* owner component
|
||||
* @param origin the origin point for the balloon tip
|
||||
* @param bordercolor the background color for the balloon tip
|
||||
* @param backgroundcolor the border color for the balloon tip
|
||||
* @param textcolor the text color for the balloon tip
|
||||
*/
|
||||
public BalloonTip (
|
||||
Window owner, String content, Point origin, Color bordercolor,
|
||||
Color backgroundcolor, Color textcolor)
|
||||
{
|
||||
super(owner);
|
||||
textList = content.split("\n");
|
||||
borderColor = bordercolor;
|
||||
backgroundColor = backgroundcolor;
|
||||
textColor = textcolor;
|
||||
setFocusableWindowState(false);
|
||||
setName("###overrideRedirect###");
|
||||
setSize(getPreferredSize());
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the mask for the Balloon Tip.
|
||||
*/
|
||||
private void setWindowMask () {
|
||||
mask = new Area(getMask());
|
||||
maskSize = getSize();
|
||||
WindowUtils.setWindowMask(BalloonTip.this, mask);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.awt.Container#paint(java.awt.Graphics)
|
||||
*/
|
||||
public void paint (Graphics g) {
|
||||
super.paint(g);
|
||||
Dimension d = getMinimumWindowSize();
|
||||
int width = d.width + 2 * HMARGIN;
|
||||
int height = d.height + 2 * VMARGIN;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
if (vpos == VPOS_BELOW) {
|
||||
y += 15;
|
||||
}
|
||||
// Draw the filled rounded rectangle and clean up the missed pixels.
|
||||
g.setColor(backgroundColor);
|
||||
g.fillRoundRect(x, y, width, height, ARC_D, ARC_D);
|
||||
g.drawLine(x + 6, y + height - 1, x + 6, y + height - 1);
|
||||
g.drawLine(x + width - 1, y + 6, x + width - 1, y + 6);
|
||||
g.drawLine(x + width - 1, y + height - 6, x + width - 1, y + height - 7);
|
||||
g.drawLine(x + width - 2, y + height - 4, x + width - 4, y + height - 2);
|
||||
g.drawLine(x + width - 6, y + height - 1, x + width - 7, y + height - 1);
|
||||
g.clearRect(x + 2, y + 2, 1, 1);
|
||||
// Draw the border of the rounded rectangle.
|
||||
g.setColor(borderColor);
|
||||
g.drawRoundRect(x, y, width, height, ARC_D, ARC_D);
|
||||
// Draw the external triangle for the balloon.
|
||||
if (vpos == VPOS_BELOW) {
|
||||
if (hpos == HPOS_LEFT) {
|
||||
g.setColor(backgroundColor);
|
||||
int[] xPts = {16, 16, 31};
|
||||
int[] yPts = {0, 16, 16};
|
||||
g.fillPolygon(xPts, yPts, 3);
|
||||
g.setColor(borderColor);
|
||||
g.drawLine(16, 0, 16, 15);
|
||||
g.drawLine(16, 0, 31, 15);
|
||||
g.drawLine(16, 1, 30, 15);
|
||||
}
|
||||
else {
|
||||
g.setColor(backgroundColor);
|
||||
int[] xPts = {width - 16, width - 16, width - 31};
|
||||
int[] yPts = {0, 16, 16};
|
||||
g.fillPolygon(xPts, yPts, 3);
|
||||
g.setColor(borderColor);
|
||||
g.drawLine(width - 16, 0, width - 16, 15);
|
||||
g.drawLine(width - 16, 0, width - 31, 15);
|
||||
g.drawLine(width - 16, 1, width - 30, 15);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (hpos == HPOS_LEFT) {
|
||||
g.setColor(backgroundColor);
|
||||
int[] xPts = {16, 16, 31};
|
||||
int[] yPts = {height, height + 16, height};
|
||||
g.fillPolygon(xPts, yPts, 3);
|
||||
g.setColor(borderColor);
|
||||
g.drawLine(16, height, 16, height + 15);
|
||||
g.drawLine(16, height + 15, 31, height);
|
||||
g.drawLine(16, height + 14, 30, height);
|
||||
}
|
||||
else {
|
||||
g.setColor(backgroundColor);
|
||||
int[] xPts = {width - 16, width - 16, width - 31};
|
||||
int[] yPts = {height, height + 16, height};
|
||||
g.fillPolygon(xPts, yPts, 3);
|
||||
g.setColor(borderColor);
|
||||
g.drawLine(width - 16, height, width - 16, height + 15);
|
||||
g.drawLine(width - 16, height + 15, width - 31, height);
|
||||
g.drawLine(width - 16, height + 14, width - 30, height);
|
||||
}
|
||||
}
|
||||
// Draw the inner component for the balloon.
|
||||
g.setColor(textColor);
|
||||
g.setFont(new Font("Tahoma", Font.PLAIN, 11));
|
||||
int stringY = y + VMARGIN / 2;
|
||||
for (int i = 0; i < textList.length; i++) {
|
||||
stringY += new JLabel(textList[i]).getPreferredSize().height;
|
||||
if (i > 0) {
|
||||
stringY += VSPACER;
|
||||
}
|
||||
g.drawString(textList[i], HMARGIN, stringY);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the mask for the balloon tip window.
|
||||
*/
|
||||
private Shape getMask () {
|
||||
Dimension d = getMinimumWindowSize();
|
||||
int width = d.width + 2 * HMARGIN;
|
||||
int height = d.height + 2 * VMARGIN;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
if (vpos == VPOS_BELOW) {
|
||||
y += 15;
|
||||
}
|
||||
// Start by creating the area of the main rounded rectangle.
|
||||
Area area = new Area(
|
||||
new RoundRectangle2D.Float(x, y, width + 1, height + 1, ARC_D, ARC_D));
|
||||
// Add in the remaining pixels that are not included by default due to
|
||||
// the differences between Graphics drawing and Shape creation.
|
||||
area.add(new Area(new Rectangle(0, y + 6, 1, 2)));
|
||||
area.add(new Area(new Rectangle(0, y + height - 7, 1, 2)));
|
||||
area.add(new Area(new Rectangle(1, y + 4, 1, 1)));
|
||||
area.add(new Area(new Rectangle(1, y + height - 5, 1, 2)));
|
||||
area.add(new Area(new Rectangle(4, y + 1, 1, 1)));
|
||||
area.add(new Area(new Rectangle(6, y, 2, 1)));
|
||||
area.add(new Area(new Rectangle(width - 7, y, 2, 1)));
|
||||
// Subtract the extra pixels that are not included by default due to the
|
||||
// differences between Graphics drawing and Shape creation.
|
||||
area.subtract(new Area(new Rectangle(2, y + height - 2, 1, 1)));
|
||||
area.subtract(new Area(new Rectangle(3, y + height - 1, 1, 1)));
|
||||
area.subtract(new Area(new Rectangle(5, y + height, 1, 1)));
|
||||
area.subtract(new Area(new Rectangle(width - 5, y + height, 2, 1)));
|
||||
area.subtract(new Area(new Rectangle(width - 3, y + height - 1, 2, 1)));
|
||||
area.subtract(new Area(new Rectangle(width - 2, y + 2, 1, 1)));
|
||||
area.subtract(new Area(new Rectangle(width - 2, y + height - 2, 2, 1)));
|
||||
area.subtract(new Area(new Rectangle(width - 1, y + 3, 1, 1)));
|
||||
area.subtract(new Area(new Rectangle(width - 1, y + height - 3, 1, 1)));
|
||||
area.subtract(new Area(new Rectangle(width, y + 5, 1, 1)));
|
||||
area.subtract(new Area(new Rectangle(width, y + height - 5, 1, 2)));
|
||||
// Add in the triangle piece for the balloon.
|
||||
if (vpos == VPOS_BELOW) {
|
||||
if (hpos == HPOS_LEFT) {
|
||||
int[] xPts = {16, 16, 32};
|
||||
int[] yPts = {-1, 16, 16};
|
||||
area.add(new Area(new Polygon(xPts, yPts, 3)));
|
||||
}
|
||||
else {
|
||||
int[] xPts = {width - 15, width - 15, width - 32};
|
||||
int[] yPts = {-1, 16, 16};
|
||||
area.add(new Area(new Polygon(xPts, yPts, 3)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (hpos == HPOS_LEFT) {
|
||||
int[] xPts = {16, 16, 31};
|
||||
int[] yPts = {height, height + 16, height};
|
||||
area.add(new Area(new Polygon(xPts, yPts, 3)));
|
||||
}
|
||||
else {
|
||||
int[] xPts = {width - 15, width - 15, width - 32};
|
||||
int[] yPts = {height, height + 16, height};
|
||||
area.add(new Area(new Polygon(xPts, yPts, 3)));
|
||||
}
|
||||
}
|
||||
return area;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the dimension of the window based on the preferred component
|
||||
* sizes.
|
||||
*/
|
||||
private Dimension getMinimumWindowSize () {
|
||||
int maxWidth = 0;
|
||||
int textHeight = 0;
|
||||
JLabel tempLabel = null;
|
||||
for (int i = 0; i < textList.length; i++) {
|
||||
tempLabel = new JLabel(textList[i]);
|
||||
maxWidth = Math.max(maxWidth, tempLabel.getPreferredSize().width);
|
||||
textHeight += tempLabel.getPreferredSize().height;
|
||||
}
|
||||
int w = Math.max(maxWidth, 32);
|
||||
int h = Math.max(textHeight + (textList.length - 1) * VSPACER, 8);
|
||||
return new Dimension(w, h);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.awt.Window#setBounds(int, int, int, int)
|
||||
*/
|
||||
public void setBounds (int x, int y, int w, int h) {
|
||||
super.setBounds(x, y, w, h);
|
||||
Dimension size = new Dimension(w, h);
|
||||
if (mask != null && !size.equals(maskSize)) {
|
||||
mask.subtract(mask);
|
||||
mask.add(new Area(getMask()));
|
||||
maskSize = size;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.awt.Container#getPreferredSize()
|
||||
*/
|
||||
public Dimension getPreferredSize () {
|
||||
Dimension d = getMinimumWindowSize();
|
||||
int w = d.width + 2 * HMARGIN + 1;
|
||||
int h = d.height + 2 * VMARGIN + 16;
|
||||
return new Dimension(w, h);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the popup window of the balloon tip.
|
||||
* @param owner the owner component for the balloon tip
|
||||
* @param content the text string to display in the balloon tip
|
||||
* @param x the x coordinate for the origin for the balloon tip in relation
|
||||
* to the owner component
|
||||
* @param y the y coordinate for the origin for the balloon tip in relation
|
||||
* to the owner component
|
||||
* @param position the position for the balloon; either above or below the
|
||||
* owner component
|
||||
* @param duration the duration in milliseconds to display balloon tip
|
||||
* @return the popup window of the balloon tip
|
||||
*/
|
||||
public static Popup getBalloonTip (final Component owner,
|
||||
final String content, int x, int y, final int duration)
|
||||
{
|
||||
return getBalloonTip(owner, content, x, y, duration, DEFAULT_BORDER_COLOR,
|
||||
DEFAULT_BACKGROUND_COLOR, DEFAULT_TEXT_COLOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the popup is showing or not.
|
||||
* @return true if the popup is showing, else false
|
||||
*/
|
||||
public static boolean isShowing () {
|
||||
return isShowing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restarts the popup timer.
|
||||
*/
|
||||
public static void restartTimer () {
|
||||
hidePopupTimer.restart();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the popup window of the balloon tip.
|
||||
* @param owner the owner component for the balloon tip
|
||||
* @param content the text string to display in the balloon tip
|
||||
* @param x the x coordinate for the origin for the balloon tip in relation
|
||||
* to the owner component
|
||||
* @param y the y coordinate for the origin for the balloon tip in relation
|
||||
* to the owner component
|
||||
* @param position the position for the balloon; either above or below the
|
||||
* owner component
|
||||
* @param duration the duration in milliseconds to display balloon tip
|
||||
* @param bordercolor the background color for the balloon tip
|
||||
* @param backgroundcolor the border color for the balloon tip
|
||||
* @param textcolor the text color for the balloon tip
|
||||
* @return the popup window of the balloon tip
|
||||
*/
|
||||
public static Popup getBalloonTip (final Component owner,
|
||||
final String content, int x, int y, final Integer duration,
|
||||
final Color bordercolor, final Color backgroundcolor,
|
||||
final Color textcolor)
|
||||
{
|
||||
final Point origin =
|
||||
owner == null ? new Point(0, 0) : owner.getLocationOnScreen();
|
||||
final Window parent =
|
||||
owner != null ? SwingUtilities.getWindowAncestor(owner) : null;
|
||||
final String text =
|
||||
content != null ? content : "";
|
||||
final Integer timerDuration =
|
||||
duration != null ? duration : 10000;
|
||||
origin.translate(x, y);
|
||||
vpos = VPOS_BELOW;
|
||||
hpos = HPOS_LEFT;
|
||||
return new Popup () {
|
||||
private BalloonTip bt = null;
|
||||
final ComponentEar componentEar = new ComponentEar();
|
||||
final MouseEar mouseEar = new MouseEar();
|
||||
final FocusEar focusEar = new FocusEar();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see javax.swing.Popup#show()
|
||||
*/
|
||||
public void show () {
|
||||
hidePopupTimer = new Timer(timerDuration, new TimerAction());
|
||||
bt = new BalloonTip(parent, text, origin, bordercolor,
|
||||
backgroundcolor, textcolor);
|
||||
bt.pack();
|
||||
Point pt = new Point(origin);
|
||||
pt.translate(10, owner.getHeight());
|
||||
bt.setLocation(getAdjustedOrigin(pt));
|
||||
bt.setWindowMask();
|
||||
bt.setVisible(true);
|
||||
owner.addFocusListener(focusEar);
|
||||
owner.addMouseListener(mouseEar);
|
||||
parent.addMouseListener(mouseEar);
|
||||
parent.addComponentListener(componentEar);
|
||||
hidePopupTimer.start();
|
||||
isShowing = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see javax.swing.Popup#hide()
|
||||
*/
|
||||
public void hide () {
|
||||
if (bt != null) {
|
||||
isShowing = false;
|
||||
hidePopupTimer.stop();
|
||||
parent.removeComponentListener(componentEar);
|
||||
parent.removeMouseListener(mouseEar);
|
||||
owner.removeMouseListener(mouseEar);
|
||||
owner.removeFocusListener(focusEar);
|
||||
bt.setVisible(false);
|
||||
bt.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Adjust the location of the balloon popup so that is drawn completely
|
||||
* on the screen and specify the orientation.
|
||||
*/
|
||||
private Point getAdjustedOrigin (Point pt) {
|
||||
Point ret = new Point(pt.x, pt.y);
|
||||
GraphicsConfiguration gc = owner.getGraphicsConfiguration();
|
||||
Rectangle sBounds = gc.getBounds();
|
||||
Insets sInsets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
|
||||
sBounds.x += sInsets.left;
|
||||
sBounds.y += sInsets.top;
|
||||
sBounds.width -= (sInsets.left + sInsets.right);
|
||||
sBounds.height -= (sInsets.top + sInsets.bottom);
|
||||
|
||||
if (ret.x < sBounds.x) {
|
||||
ret.x = sBounds.x;
|
||||
}
|
||||
else if (ret.x - sBounds.x + bt.getWidth() > sBounds.width) {
|
||||
ret.x = owner.getLocationOnScreen().x - bt.getWidth() + 43;
|
||||
}
|
||||
if (ret.x >= pt.x) {
|
||||
hpos = HPOS_LEFT;
|
||||
}
|
||||
else {
|
||||
hpos = HPOS_RIGHT;
|
||||
}
|
||||
|
||||
if (ret.y < sBounds.y) {
|
||||
ret.y = sBounds.y;
|
||||
}
|
||||
else if (ret.y - sBounds.y + bt.getHeight() > sBounds.height) {
|
||||
ret.y = owner.getLocationOnScreen().y - bt.getHeight();
|
||||
}
|
||||
if (ret.y >= pt.y) {
|
||||
vpos = VPOS_BELOW;
|
||||
}
|
||||
else {
|
||||
vpos = VPOS_ABOVE;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* This class handles actions from the balloon tip timer.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
final class TimerAction extends AbstractAction {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.awt.event.ActionListener#actionPerformed(
|
||||
* java.awt.event.ActionEvent)
|
||||
*/
|
||||
public void actionPerformed (ActionEvent e) {
|
||||
hide();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This class handles events spawned from moving the component.
|
||||
*/
|
||||
final class ComponentEar extends ComponentAdapter {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.awt.event.ComponentAdapter#componentMoved(
|
||||
* java.awt.event.ComponentEvent)
|
||||
*/
|
||||
public void componentMoved (ComponentEvent e) {
|
||||
hide();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This class handles events spawned when a mouse button is pressed.
|
||||
*/
|
||||
final class MouseEar extends MouseAdapter {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.awt.event.MouseAdapter#mousePressed(
|
||||
* java.awt.event.MouseEvent)
|
||||
*/
|
||||
public void mousePressed (MouseEvent e) {
|
||||
hide();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This class handles events spawned when the component loses focus.
|
||||
*/
|
||||
final class FocusEar extends FocusAdapter {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.awt.event.FocusAdapter#focusLost(
|
||||
* java.awt.event.FocusEvent)
|
||||
*/
|
||||
public void focusLost (FocusEvent e) {
|
||||
hide();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,424 +0,0 @@
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.Popup;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.text.AttributeSet;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.Document;
|
||||
import javax.swing.text.PlainDocument;
|
||||
//TODO: FilteredTextField - Comment this class.
|
||||
/**
|
||||
* The FilteredTextField class is a JTextField that only allows specified
|
||||
* characters to be entered into it. The allowed characters can be added to
|
||||
* the text field, and entry validation is performed as each character is
|
||||
* typed. In addition, complete string validation is tested against a
|
||||
* configurable regular expression when leaving the field. If the string is
|
||||
* invalid the text field is bordered with a red line, and the user is notified
|
||||
* of the error upon returning to the text field. The text field can also be
|
||||
* configured to accept a limited number of characters.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class FilteredTextField extends JTextField {
|
||||
public static final Character[] UPPERCASE_CHARS = {'A', 'B', 'C', 'D', 'E',
|
||||
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
|
||||
'U', 'V', 'W', 'X', 'Y', 'Z'};
|
||||
public static final Character[] LOWERCASE_CHARS = {'a', 'b', 'c', 'd', 'e',
|
||||
'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
|
||||
'u', 'v', 'w', 'x', 'y', 'z'};
|
||||
public static final Character[] NUMERIC_CHARS = {'1', '2', '3', '4', '5',
|
||||
'6', '7', '8', '9', '0'};
|
||||
|
||||
private static final Integer ENTRY_BALLOON = 0;
|
||||
private static final Integer VALID_BALLOON = 1;
|
||||
private static final Integer LENGTH_BALLOON = 2;
|
||||
private static final Border RED_BORDER =
|
||||
BorderFactory.createLineBorder(Color.RED, 2);
|
||||
|
||||
private ArrayList<Character> allowable = new ArrayList<Character>();
|
||||
private int maximumLength = String.valueOf(Long.MAX_VALUE).length();
|
||||
|
||||
private Border defaultBorder = null;
|
||||
private boolean isValid = true;
|
||||
|
||||
private Popup balloon = null;
|
||||
private String entryError = null;
|
||||
private String validRegex = null;
|
||||
private String validError = null;
|
||||
private Color balloonBorderColor = null;
|
||||
private Color balloonBackgroundColor = null;
|
||||
private Color balloonTextColor = null;
|
||||
private Integer balloonDuration = null;
|
||||
|
||||
private Integer balloonType = null;
|
||||
|
||||
/**
|
||||
* Create a FilteredTextField.
|
||||
*/
|
||||
public FilteredTextField () {
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a FilteredTextField.
|
||||
* @param columns the number of columns to use to calculate the preferred
|
||||
* width
|
||||
*/
|
||||
public FilteredTextField (int columns) {
|
||||
super(columns);
|
||||
init();
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the FilteredTextField.
|
||||
*/
|
||||
private void init () {
|
||||
defaultBorder = getBorder();
|
||||
entryError = "";
|
||||
validRegex = "";
|
||||
validError = "";
|
||||
balloonBorderColor = BalloonTipManager.DEFAULT_BORDER_COLOR;
|
||||
balloonBackgroundColor = BalloonTipManager.DEFAULT_BACKGROUND_COLOR;
|
||||
balloonTextColor = BalloonTipManager.DEFAULT_TEXT_COLOR;
|
||||
balloonDuration = 10000;
|
||||
balloonType = ENTRY_BALLOON;
|
||||
addFocusListener(new ValidationEar());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the allowable character used for entry validation.
|
||||
* @param characters the allowable characters
|
||||
*/
|
||||
public void setCharacters (Character[] characters) {
|
||||
clearCharacters();
|
||||
for (int i = 0; i < characters.length; i++) {
|
||||
addCharacter(characters[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the character array to the list used for entry validation.
|
||||
* @param characters the character array
|
||||
*/
|
||||
public void addCharacters (Character[] characters) {
|
||||
for (int i = 0; i < characters.length; i++) {
|
||||
addCharacter(characters[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the character to the list used for entry validation.
|
||||
* @param characters the character
|
||||
*/
|
||||
public void addCharacter (Character character) {
|
||||
if (!allowable.contains(character)) {
|
||||
allowable.add(character);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the list of allowable characters for entry validation.
|
||||
*/
|
||||
public void clearCharacters () {
|
||||
allowable.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the character array from the list used for entry validation.
|
||||
* @param characters the character array
|
||||
*/
|
||||
public void removeCharacters (Character[] characters) {
|
||||
for (int i = 0; i < characters.length; i++) {
|
||||
removeCharacter(characters[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the character from the list used for entry validation.
|
||||
* @param character the character
|
||||
*/
|
||||
public void removeCharacter (Character character) {
|
||||
if (allowable.contains(character)) {
|
||||
allowable.remove(character);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum number of characters for the length of the entry string.
|
||||
* @param maximumLength the number of characters
|
||||
*/
|
||||
public void setMaximumLength (int maximumLength) {
|
||||
this.maximumLength = maximumLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the message that is displayed when there is an entry error.
|
||||
* @param entryError the entry error message
|
||||
*/
|
||||
public void setEntryError (String entryError) {
|
||||
this.entryError = entryError;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the regular expression that is used for string validation. String
|
||||
* validation is checked when exiting the text field.
|
||||
* @param validRegex the validation regular expression
|
||||
*/
|
||||
public void setValidRegex (String validRegex) {
|
||||
this.validRegex = validRegex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the message that is displayed when there is a validation error.
|
||||
* @param validError the validation error message
|
||||
*/
|
||||
public void setValidError (String validError) {
|
||||
this.validError = validError;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the color to use for the balloon border.
|
||||
* @param borderColor the balloon border color
|
||||
*/
|
||||
public void setBalloonBorderColor (Color borderColor) {
|
||||
balloonBorderColor = borderColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the color to use for the balloon background.
|
||||
* @param backgroundColor the balloon background color
|
||||
*/
|
||||
public void setBalloonBackgroundColor (Color backgroundColor) {
|
||||
balloonBackgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the color to use for the balloon text.
|
||||
* @param textColor the balloon text color
|
||||
*/
|
||||
public void setBalloonTextColor (Color textColor) {
|
||||
balloonTextColor = textColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the time in milliseconds that the balloon is visible before
|
||||
* disappearing. This is the maximum time that the balloon will be visible,
|
||||
* as other events can also make the balloon disappear.
|
||||
* @param duration the time in milliseconds
|
||||
*/
|
||||
public void setBalloonDuration (Integer duration) {
|
||||
balloonDuration = duration;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see javax.swing.JTextField#createDefaultModel()
|
||||
*/
|
||||
protected Document createDefaultModel () {
|
||||
return new FilteredTextFieldDocument();
|
||||
}
|
||||
|
||||
/*
|
||||
* This class defines the document used for the FilteredTextField.
|
||||
*/
|
||||
private class FilteredTextFieldDocument extends PlainDocument {
|
||||
/*
|
||||
* Create a FilteredTextFieldDocument.
|
||||
*/
|
||||
public FilteredTextFieldDocument () {
|
||||
addDocumentListener(new FilteredTextFieldEar());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see javax.swing.text.PlainDocument#insertString(
|
||||
* int, java.lang.String, javax.swing.text.AttributeSet)
|
||||
*/
|
||||
public void insertString (int offset, String str, AttributeSet a)
|
||||
throws BadLocationException
|
||||
{
|
||||
if (balloon != null && BalloonTipManager.isShowing()) {
|
||||
if (balloonType == VALID_BALLOON) {
|
||||
balloon.hide();
|
||||
}
|
||||
}
|
||||
StringBuffer buffer =
|
||||
new StringBuffer(FilteredTextField.this.getText());
|
||||
if (offset >= 0 && offset <= buffer.length()) {
|
||||
buffer.insert(offset, str);
|
||||
String strBuf = buffer.toString();
|
||||
|
||||
if (buffer.length() > maximumLength) {
|
||||
if (balloon != null && BalloonTipManager.isShowing()) {
|
||||
if (balloonType == LENGTH_BALLOON) {
|
||||
BalloonTipManager.restartTimer();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
balloon.hide();
|
||||
}
|
||||
}
|
||||
balloon = BalloonTipManager.getBalloonTip(FilteredTextField.this,
|
||||
"The number of characters must be less than or equal to " +
|
||||
maximumLength, 0, 0, balloonDuration, balloonBorderColor,
|
||||
balloonBackgroundColor, balloonTextColor);
|
||||
balloon.show();
|
||||
balloonType = LENGTH_BALLOON;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strBuf == null || strBuf.equals("")) {
|
||||
remove(0, getLength());
|
||||
super.insertString(0, "", null);
|
||||
if (balloon != null && BalloonTipManager.isShowing()) {
|
||||
balloon.hide();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (allowable.contains(str.charAt(0))) {
|
||||
super.insertString(offset, str, a);
|
||||
if (balloon != null && BalloonTipManager.isShowing()) {
|
||||
balloon.hide();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (balloon != null && BalloonTipManager.isShowing()) {
|
||||
if (balloonType == ENTRY_BALLOON) {
|
||||
BalloonTipManager.restartTimer();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
balloon.hide();
|
||||
}
|
||||
}
|
||||
balloon = BalloonTipManager.getBalloonTip(FilteredTextField.this,
|
||||
entryError, 0, 0, balloonDuration, balloonBorderColor,
|
||||
balloonBackgroundColor, balloonTextColor);
|
||||
balloon.show();
|
||||
balloonType = ENTRY_BALLOON;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This listener class is needed to catch character removal events.
|
||||
*/
|
||||
private class FilteredTextFieldEar implements DocumentListener {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see javax.swing.event.DocumentListener#insertUpdate(
|
||||
* javax.swing.event.DocumentEvent)
|
||||
*/
|
||||
public void insertUpdate (DocumentEvent e) {/* N/A */}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see javax.swing.event.DocumentListener#removeUpdate(
|
||||
* javax.swing.event.DocumentEvent)
|
||||
*/
|
||||
public void removeUpdate (DocumentEvent e) {
|
||||
if (balloon != null && BalloonTipManager.isShowing())
|
||||
{
|
||||
balloon.hide();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see javax.swing.event.DocumentListener#changedUpdate(
|
||||
* javax.swing.event.DocumentEvent)
|
||||
*/
|
||||
public void changedUpdate (DocumentEvent e) {/* N/A */}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This listener class is used to determine whether the string is valid based
|
||||
* on a regular expression. The validation is tested when leaving the text
|
||||
* field, and notification is performed when returning to the text field.
|
||||
*/
|
||||
private class ValidationEar extends FocusAdapter {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.awt.event.FocusAdapter#focusLost(java.awt.event.FocusEvent)
|
||||
*/
|
||||
public void focusLost (FocusEvent e) {
|
||||
String entered = getText().trim();
|
||||
if (!entered.matches(validRegex)) {
|
||||
if (balloon != null) {
|
||||
balloon.hide();
|
||||
}
|
||||
setBorder(
|
||||
BorderFactory.createCompoundBorder(RED_BORDER, defaultBorder));
|
||||
isValid = false;
|
||||
}
|
||||
else {
|
||||
setBorder(defaultBorder);
|
||||
isValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.awt.event.FocusAdapter#focusGained(java.awt.event.FocusEvent)
|
||||
*/
|
||||
public void focusGained (FocusEvent e) {
|
||||
if (!isValid) {
|
||||
balloon = BalloonTipManager.getBalloonTip(FilteredTextField.this,
|
||||
validError, 0, 0, balloonDuration, balloonBorderColor,
|
||||
balloonBackgroundColor, balloonTextColor);
|
||||
balloon.show();
|
||||
balloonType = VALID_BALLOON;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* A main entry point to test the FilteredTextField.
|
||||
* @param args application arguments
|
||||
*/
|
||||
public static void main (String[] args) {
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
JFrame jframe = new JFrame("Balloon Tips on FilteredTextField");
|
||||
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
jframe.setSize(400, 75);
|
||||
jframe.setLocation(400, 400);
|
||||
JPanel jpanel = new JPanel();
|
||||
jpanel.setLayout(new BorderLayout());
|
||||
FilteredTextField ftfield = new FilteredTextField(10);
|
||||
ftfield.setCharacters(LOWERCASE_CHARS);
|
||||
ftfield.addCharacter('-');
|
||||
ftfield.addCharacter('_');
|
||||
ftfield.addCharacter(' ');
|
||||
ftfield.setMaximumLength(10);
|
||||
ftfield.setEntryError(
|
||||
"Only lower case letters, hyphens, underscores, and spaces allowed.");
|
||||
ftfield.setValidRegex("^a+[a-z-_ ]*");
|
||||
ftfield.setValidError("The string must begin with the letter 'a'.");
|
||||
jpanel.add(new JLabel("Type some text into either field"), BorderLayout.NORTH);
|
||||
jpanel.add(ftfield, BorderLayout.CENTER);
|
||||
jpanel.add(new FilteredTextField(10), BorderLayout.SOUTH);
|
||||
jframe.getContentPane().add(jpanel);
|
||||
jframe.setVisible(true);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="/jnalib/dist/jna.jar"/>
|
||||
<classpathentry kind="src" path="/platform"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>dnddemo</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,68 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="jnacontrib.dnddemo" default="jar" basedir=".">
|
||||
<description>Builds, tests, and runs the project jnacontrib.dnddemo.</description>
|
||||
<!-- Locations -->
|
||||
<property name="src" location="."/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="jna-dist" location="../../dist"/>
|
||||
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-dnd.jar"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.GhostedDragImageDemo" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset file="${file.reference.jna.jar}"/>
|
||||
<fileset dir="../platform/dist" includes="platform.jar"/>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${classes}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${classes}"/>
|
||||
<delete file="${jar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes}"/>
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com"/>
|
||||
<!-- jna -->
|
||||
<zipfileset src="${file.reference.jna.jar}"/>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
@@ -1,140 +0,0 @@
|
||||
/* 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.
|
||||
*
|
||||
* 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.contrib.demo;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.ClipboardOwner;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.awt.dnd.DnDConstants;
|
||||
import java.awt.dnd.DragGestureEvent;
|
||||
import java.awt.dnd.DragSourceDropEvent;
|
||||
import java.awt.dnd.DropTargetDropEvent;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import com.sun.jna.platform.dnd.DragHandler;
|
||||
import com.sun.jna.platform.dnd.DropHandler;
|
||||
|
||||
|
||||
/** Demonstrate ghosted drag images. Unfortunately, Swing drag support hides
|
||||
* the hooks we need to move the drag image around, so we don't use it and
|
||||
* roll our own.
|
||||
*/
|
||||
public class GhostedDragImageDemo {
|
||||
|
||||
public static class ImageSelection implements Transferable, ClipboardOwner {
|
||||
public static final DataFlavor IMAGE_FLAVOR = DataFlavor.imageFlavor;
|
||||
private static final DataFlavor[] FLAVORS = { IMAGE_FLAVOR };
|
||||
|
||||
private Image image;
|
||||
public ImageSelection(Image image) {
|
||||
this.image = image;
|
||||
}
|
||||
public void lostOwnership(Clipboard clipboard, Transferable transferable) {
|
||||
// don't care
|
||||
}
|
||||
public Object getTransferData(DataFlavor flavor) {
|
||||
return isDataFlavorSupported(flavor) ? image : null;
|
||||
}
|
||||
public DataFlavor[] getTransferDataFlavors() { return FLAVORS; }
|
||||
public boolean isDataFlavorSupported(DataFlavor flavor) {
|
||||
return flavor.equals(IMAGE_FLAVOR);
|
||||
}
|
||||
}
|
||||
|
||||
public static class DragLabel extends JLabel {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private boolean dragging;
|
||||
public DragLabel(Icon icon) {
|
||||
super(icon);
|
||||
new DragHandler(this, DnDConstants.ACTION_COPY_OR_MOVE) {
|
||||
protected Icon getDragIcon(DragGestureEvent e, Point imageOffset) {
|
||||
dragging = true;
|
||||
return getIcon();
|
||||
}
|
||||
public void dragDropEnd(DragSourceDropEvent e) {
|
||||
super.dragDropEnd(e);
|
||||
if (e.getDropSuccess() && getDropAction(e) == MOVE) {
|
||||
if (dragging) {
|
||||
setIcon(null);
|
||||
dragging = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
protected Transferable getTransferable(DragGestureEvent e) {
|
||||
ImageIcon icon = (ImageIcon)getIcon();
|
||||
if (icon != null) {
|
||||
return new ImageSelection(icon.getImage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
DataFlavor[] flavors = new DataFlavor[] { DataFlavor.imageFlavor };
|
||||
new DropHandler(this, DnDConstants.ACTION_COPY_OR_MOVE, flavors) {
|
||||
protected void drop(DropTargetDropEvent e, int action) throws UnsupportedFlavorException, IOException {
|
||||
final Image image = (Image)e.getTransferable().getTransferData(DataFlavor.imageFlavor);
|
||||
dragging = false;
|
||||
setIcon(new ImageIcon(image));
|
||||
}
|
||||
};
|
||||
}
|
||||
public void setIcon(Icon icon) {
|
||||
super.setIcon(icon);
|
||||
if (icon == null) {
|
||||
setText("Empty");
|
||||
}
|
||||
else {
|
||||
setText(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
System.setProperty("sun.java2d.noddraw", "true");
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
JFrame f1 = new JFrame("Drag this");
|
||||
JFrame f2 = new JFrame("Over here");
|
||||
URL url = GhostedDragImageDemo.class.getResource("toucan.png");
|
||||
if (url == null)
|
||||
throw new RuntimeException("Icon not found");
|
||||
Icon icon = new ImageIcon(url);
|
||||
f1.getContentPane().add(new DragLabel(icon));
|
||||
JLabel label2 = new DragLabel(icon);
|
||||
f2.getContentPane().add(label2);
|
||||
f1.setLocation(100, 100);
|
||||
f1.pack();
|
||||
f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
f2.setLocation(300, 100);
|
||||
f2.pack();
|
||||
label2.setIcon(null);
|
||||
f2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
f2.setVisible(true);
|
||||
f1.setVisible(true);
|
||||
}
|
||||
catch(Throwable t){
|
||||
t.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Arquivo binário não exibido.
|
Antes Largura: | Altura: | Tamanho: 28 KiB |
@@ -1,13 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Copyright (c) 2007 Timothy Wall
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<!-- One sentence summary -->
|
||||
Cross-platform ghosted drag image implementation with demo application.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" output="build.eclipse/contrib-test-classes" path="test"/>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/jnalib"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
|
||||
<classpathentry kind="lib" path="/jnalib/dist/jna.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>ntservice</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,60 +0,0 @@
|
||||
Copyright (c) 2007 Thomas Boerkel, All Rights Reserved
|
||||
|
||||
Disclaimer:
|
||||
===========
|
||||
This code 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.
|
||||
|
||||
This code 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.
|
||||
|
||||
|
||||
Description:
|
||||
============
|
||||
|
||||
Accounts.java:
|
||||
--------------
|
||||
Static methods for getting information about Win32 accounts (users
|
||||
and groups).
|
||||
- list all domain users
|
||||
- list all domain groups
|
||||
- list all local or domain groups where a user belongs to
|
||||
- get account by SID
|
||||
- get SID of account
|
||||
- get domain controller name
|
||||
- get domain name
|
||||
|
||||
Registry.java:
|
||||
--------------
|
||||
Static methods for reading and manipulating the Windows Registry.
|
||||
Only String and DWORD values supported, but could be easily
|
||||
extended.
|
||||
- create key
|
||||
- delete key
|
||||
- delete value
|
||||
- read value
|
||||
- get all sub keys of a key
|
||||
- get all values of a key
|
||||
- set value
|
||||
- check existence of value
|
||||
|
||||
Win32Service.java:
|
||||
------------------
|
||||
Abstract class to wrap a Win32 service. Derive from this class
|
||||
to build your own service. Supports only one type of service and
|
||||
startup, but could be easily extended.
|
||||
- install service
|
||||
- uninstall service
|
||||
- start service
|
||||
- stop service
|
||||
- callback for service start request (onStart), should spawn a thread
|
||||
- callback for service stop request (onStop)
|
||||
|
||||
TestService.java:
|
||||
-----------------
|
||||
Very simple example of an implementation of Win32Service.java.
|
||||
Does nothing but starting and stopping (no "useful" work).
|
||||
@@ -1,69 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- You may freely edit this file. See commented blocks below for -->
|
||||
<!-- some examples of how to customize the build. -->
|
||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||
<project name="JnaContrib" default="default" basedir=".">
|
||||
<description>Builds, tests, and runs the project JnaContrib.</description>
|
||||
<import file="nbproject/build-impl.xml"/>
|
||||
<!--
|
||||
|
||||
There exist several targets which are by default empty and which can be
|
||||
used for execution of your tasks. These targets are usually executed
|
||||
before and after some main targets. They are:
|
||||
|
||||
-pre-init: called before initialization of project properties
|
||||
-post-init: called after initialization of project properties
|
||||
-pre-compile: called before javac compilation
|
||||
-post-compile: called after javac compilation
|
||||
-pre-compile-single: called before javac compilation of single file
|
||||
-post-compile-single: called after javac compilation of single file
|
||||
-pre-compile-test: called before javac compilation of JUnit tests
|
||||
-post-compile-test: called after javac compilation of JUnit tests
|
||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||
-pre-jar: called before JAR building
|
||||
-post-jar: called after JAR building
|
||||
-post-clean: called after cleaning build products
|
||||
|
||||
(Targets beginning with '-' are not intended to be called on their own.)
|
||||
|
||||
Example of inserting an obfuscator after compilation could look like this:
|
||||
|
||||
<target name="-post-compile">
|
||||
<obfuscate>
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
</obfuscate>
|
||||
</target>
|
||||
|
||||
For list of available properties check the imported
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
|
||||
Another way to customize the build is by overriding existing main targets.
|
||||
The targets of interest are:
|
||||
|
||||
-init-macrodef-javac: defines macro for javac compilation
|
||||
-init-macrodef-junit: defines macro for junit execution
|
||||
-init-macrodef-debug: defines macro for class debugging
|
||||
-init-macrodef-java: defines macro for class execution
|
||||
-do-jar-with-manifest: JAR building (if you are using a manifest)
|
||||
-do-jar-without-manifest: JAR building (if you are not using a manifest)
|
||||
run: execution of project
|
||||
-javadoc-build: Javadoc generation
|
||||
test-report: JUnit report generation
|
||||
|
||||
An example of overriding the target for project execution could look like this:
|
||||
|
||||
<target name="run" depends="JnaContrib-impl.jar">
|
||||
<exec dir="bin" executable="launcher.exe">
|
||||
<arg file="${dist.jar}"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
Notice that the overridden target depends on the jar target and not only on
|
||||
the compile target as the regular run target does. Again, for a list of available
|
||||
properties which you can use, check the target you are overriding in the
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
-->
|
||||
</project>
|
||||
@@ -1,3 +0,0 @@
|
||||
Manifest-Version: 1.0
|
||||
X-COMMENT: Main-Class will be added automatically by build
|
||||
|
||||
@@ -1,541 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
*** GENERATED FROM project.xml - DO NOT EDIT ***
|
||||
*** EDIT ../build.xml INSTEAD ***
|
||||
|
||||
For the purpose of easier reading the script
|
||||
is divided into following sections:
|
||||
|
||||
- initialization
|
||||
- compilation
|
||||
- jar
|
||||
- execution
|
||||
- debugging
|
||||
- javadoc
|
||||
- junit compilation
|
||||
- junit execution
|
||||
- junit debugging
|
||||
- applet
|
||||
- cleanup
|
||||
|
||||
-->
|
||||
<project name="ntservice-impl" default="default" basedir=".." xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:jaxws="http://www.netbeans.org/ns/jax-ws/1">
|
||||
<target name="default" depends="test,jar,javadoc" description="Build and test whole project."/>
|
||||
<!--
|
||||
======================
|
||||
INITIALIZATION SECTION
|
||||
======================
|
||||
-->
|
||||
<target name="-pre-init">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-init-private" depends="-pre-init">
|
||||
<property file="nbproject/private/private.properties"/>
|
||||
</target>
|
||||
<target name="-init-user" depends="-pre-init,-init-private">
|
||||
<property file="${user.properties.file}"/>
|
||||
<!-- The two properties below are usually overridden -->
|
||||
<!-- by the active platform. Just a fallback. -->
|
||||
<property name="default.javac.source" value="1.4"/>
|
||||
<property name="default.javac.target" value="1.4"/>
|
||||
</target>
|
||||
<target name="-init-project" depends="-pre-init,-init-private,-init-user">
|
||||
<property file="nbproject/project.properties"/>
|
||||
</target>
|
||||
<target name="-do-init" depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property">
|
||||
<available file="${manifest.file}" property="manifest.available"/>
|
||||
<condition property="manifest.available+main.class">
|
||||
<and>
|
||||
<isset property="manifest.available"/>
|
||||
<isset property="main.class"/>
|
||||
<not>
|
||||
<equals arg1="${main.class}" arg2="" trim="true"/>
|
||||
</not>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="manifest.available+main.class+mkdist.available">
|
||||
<and>
|
||||
<istrue value="${manifest.available+main.class}"/>
|
||||
<isset property="libs.CopyLibs.classpath"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="have.tests">
|
||||
<or>
|
||||
<available file="${test.src.dir}"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition property="have.sources">
|
||||
<or>
|
||||
<available file="${src.dir}"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition property="netbeans.home+have.tests">
|
||||
<and>
|
||||
<isset property="netbeans.home"/>
|
||||
<isset property="have.tests"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="no.javadoc.preview">
|
||||
<isfalse value="${javadoc.preview}"/>
|
||||
</condition>
|
||||
<property name="run.jvmargs" value=""/>
|
||||
<property name="javac.compilerargs" value=""/>
|
||||
<property name="work.dir" value="${basedir}"/>
|
||||
<condition property="no.deps">
|
||||
<and>
|
||||
<istrue value="${no.dependencies}"/>
|
||||
</and>
|
||||
</condition>
|
||||
<property name="javac.debug" value="true"/>
|
||||
<property name="javadoc.preview" value="true"/>
|
||||
</target>
|
||||
<target name="-post-init">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-init-check" depends="-pre-init,-init-private,-init-user,-init-project,-do-init">
|
||||
<fail unless="src.dir">Must set src.dir</fail>
|
||||
<fail unless="test.src.dir">Must set test.src.dir</fail>
|
||||
<fail unless="build.dir">Must set build.dir</fail>
|
||||
<fail unless="dist.dir">Must set dist.dir</fail>
|
||||
<fail unless="build.classes.dir">Must set build.classes.dir</fail>
|
||||
<fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
|
||||
<fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
|
||||
<fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
|
||||
<fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
|
||||
<fail unless="dist.jar">Must set dist.jar</fail>
|
||||
</target>
|
||||
<target name="-init-macrodef-property">
|
||||
<macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="name"/>
|
||||
<attribute name="value"/>
|
||||
<sequential>
|
||||
<property name="@{name}" value="${@{value}}"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-javac">
|
||||
<macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="srcdir" default="${src.dir}"/>
|
||||
<attribute name="destdir" default="${build.classes.dir}"/>
|
||||
<attribute name="classpath" default="${javac.classpath}"/>
|
||||
<attribute name="debug" default="${javac.debug}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<javac srcdir="@{srcdir}" destdir="@{destdir}" debug="@{debug}" deprecation="${javac.deprecation}" source="${javac.source}" target="${javac.target}" includeantruntime="false">
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<compilerarg line="${javac.compilerargs}"/>
|
||||
<customize/>
|
||||
</javac>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-junit">
|
||||
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="includes" default="**/*Test.java"/>
|
||||
<sequential>
|
||||
<junit showoutput="true" fork="true" dir="${basedir}" failureproperty="tests.failed" errorproperty="tests.failed">
|
||||
<batchtest todir="${build.test.results.dir}">
|
||||
<fileset dir="${test.src.dir}" includes="@{includes}"/>
|
||||
</batchtest>
|
||||
<classpath>
|
||||
<path path="${run.test.classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="test-sys-prop."/>
|
||||
<mapper type="glob" from="test-sys-prop.*" to="*"/>
|
||||
</syspropertyset>
|
||||
<formatter type="brief" usefile="false"/>
|
||||
<formatter type="xml"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
</junit>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-nbjpda">
|
||||
<macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="name" default="${main.class}"/>
|
||||
<attribute name="classpath" default="${debug.classpath}"/>
|
||||
<attribute name="stopclassname" default=""/>
|
||||
<sequential>
|
||||
<nbjpdastart transport="dt_socket" addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}">
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
</nbjpdastart>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
<macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="dir" default="${build.classes.dir}"/>
|
||||
<sequential>
|
||||
<nbjpdareload>
|
||||
<fileset includes="${fix.includes}*.class" dir="@{dir}"/>
|
||||
</nbjpdareload>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-debug">
|
||||
<macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="classname" default="${main.class}"/>
|
||||
<attribute name="classpath" default="${debug.classpath}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<java fork="true" classname="@{classname}" dir="${work.dir}">
|
||||
<jvmarg value="-Xdebug"/>
|
||||
<jvmarg value="-Xnoagent"/>
|
||||
<jvmarg value="-Djava.compiler=none"/>
|
||||
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="run-sys-prop."/>
|
||||
<mapper type="glob" from="run-sys-prop.*" to="*"/>
|
||||
</syspropertyset>
|
||||
<customize/>
|
||||
</java>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-java">
|
||||
<macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="classname" default="${main.class}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<java fork="true" classname="@{classname}" dir="${work.dir}">
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<classpath>
|
||||
<path path="${run.classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="run-sys-prop."/>
|
||||
<mapper type="glob" from="run-sys-prop.*" to="*"/>
|
||||
</syspropertyset>
|
||||
<customize/>
|
||||
</java>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-presetdef-jar">
|
||||
<presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<jar jarfile="${dist.jar}" compress="${jar.compress}">
|
||||
<j2seproject1:fileset dir="${build.classes.dir}"/>
|
||||
</jar>
|
||||
</presetdef>
|
||||
</target>
|
||||
<target name="init" depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar"/>
|
||||
<!--
|
||||
===================
|
||||
COMPILATION SECTION
|
||||
===================
|
||||
-->
|
||||
<target name="deps-jar" depends="init" unless="no.deps"/>
|
||||
<target name="-pre-pre-compile" depends="init,deps-jar">
|
||||
<mkdir dir="${build.classes.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-compile">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile" if="have.sources">
|
||||
<j2seproject3:javac/>
|
||||
<copy todir="${build.classes.dir}">
|
||||
<fileset dir="${src.dir}" excludes="${build.classes.excludes}"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project."/>
|
||||
<target name="-pre-compile-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile-single" depends="init,deps-jar,-pre-pre-compile">
|
||||
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
|
||||
<j2seproject3:javac>
|
||||
<customize>
|
||||
<patternset includes="${javac.includes}"/>
|
||||
</customize>
|
||||
</j2seproject3:javac>
|
||||
</target>
|
||||
<target name="-post-compile-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile-single" depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single"/>
|
||||
<!--
|
||||
====================
|
||||
JAR BUILDING SECTION
|
||||
====================
|
||||
-->
|
||||
<target name="-pre-pre-jar" depends="init">
|
||||
<dirname property="dist.jar.dir" file="${dist.jar}"/>
|
||||
<mkdir dir="${dist.jar.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-jar">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-jar-without-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" unless="manifest.available">
|
||||
<j2seproject1:jar/>
|
||||
</target>
|
||||
<target name="-do-jar-with-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" unless="manifest.available+main.class">
|
||||
<j2seproject1:jar manifest="${manifest.file}"/>
|
||||
</target>
|
||||
<target name="-do-jar-with-mainclass" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" unless="manifest.available+main.class+mkdist.available">
|
||||
<j2seproject1:jar manifest="${manifest.file}">
|
||||
<j2seproject1:manifest>
|
||||
<j2seproject1:attribute name="Main-Class" value="${main.class}"/>
|
||||
</j2seproject1:manifest>
|
||||
</j2seproject1:jar>
|
||||
<echo>To run this application from the command line without Ant, try:</echo>
|
||||
<property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
|
||||
<property name="dist.jar.resolved" location="${dist.jar}"/>
|
||||
<pathconvert property="run.classpath.with.dist.jar">
|
||||
<path path="${run.classpath}"/>
|
||||
<map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
|
||||
</pathconvert>
|
||||
<echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
|
||||
</target>
|
||||
<target name="-do-jar-with-libraries" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available">
|
||||
<property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
|
||||
<pathconvert property="run.classpath.without.build.classes.dir">
|
||||
<path path="${run.classpath}"/>
|
||||
<map from="${build.classes.dir.resolved}" to=""/>
|
||||
</pathconvert>
|
||||
<pathconvert property="jar.classpath" pathsep=" ">
|
||||
<path path="${run.classpath.without.build.classes.dir}"/>
|
||||
<chainedmapper>
|
||||
<flattenmapper/>
|
||||
<globmapper from="*" to="lib/*"/>
|
||||
</chainedmapper>
|
||||
</pathconvert>
|
||||
<taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" name="copylibs" classpath="${libs.CopyLibs.classpath}"/>
|
||||
<copylibs manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}" jarfile="${dist.jar}" compress="${jar.compress}">
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main.class}"/>
|
||||
<attribute name="Class-Path" value="${jar.classpath}"/>
|
||||
</manifest>
|
||||
</copylibs>
|
||||
<echo>To run this application from the command line without Ant, try:</echo>
|
||||
<property name="dist.jar.resolved" location="${dist.jar}"/>
|
||||
<echo>java -jar "${dist.jar.resolved}"</echo>
|
||||
</target>
|
||||
<target name="-post-jar">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="jar" depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR."/>
|
||||
<!--
|
||||
=================
|
||||
EXECUTION SECTION
|
||||
=================
|
||||
-->
|
||||
<target name="run" depends="init,compile" description="Run a main class.">
|
||||
<j2seproject1:java>
|
||||
<customize>
|
||||
<arg line="${application.args}"/>
|
||||
</customize>
|
||||
</j2seproject1:java>
|
||||
</target>
|
||||
<target name="run-single" depends="init,compile-single">
|
||||
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>
|
||||
<j2seproject1:java classname="${run.class}"/>
|
||||
</target>
|
||||
<!--
|
||||
=================
|
||||
DEBUGGING SECTION
|
||||
=================
|
||||
-->
|
||||
<target name="-debug-start-debugger" if="netbeans.home" depends="init">
|
||||
<j2seproject1:nbjpdastart name="${debug.class}"/>
|
||||
</target>
|
||||
<target name="-debug-start-debuggee" depends="init,compile">
|
||||
<j2seproject3:debug>
|
||||
<customize>
|
||||
<arg line="${application.args}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target name="debug" if="netbeans.home" depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE."/>
|
||||
<target name="-debug-start-debugger-stepinto" if="netbeans.home" depends="init">
|
||||
<j2seproject1:nbjpdastart stopclassname="${main.class}"/>
|
||||
</target>
|
||||
<target name="debug-stepinto" if="netbeans.home" depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee"/>
|
||||
<target name="-debug-start-debuggee-single" if="netbeans.home" depends="init,compile-single">
|
||||
<fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
|
||||
<j2seproject3:debug classname="${debug.class}"/>
|
||||
</target>
|
||||
<target name="debug-single" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single"/>
|
||||
<target name="-pre-debug-fix" depends="init">
|
||||
<fail unless="fix.includes">Must set fix.includes</fail>
|
||||
<property name="javac.includes" value="${fix.includes}.java"/>
|
||||
</target>
|
||||
<target name="-do-debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,compile-single">
|
||||
<j2seproject1:nbjpdareload/>
|
||||
</target>
|
||||
<target name="debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix"/>
|
||||
<!--
|
||||
===============
|
||||
JAVADOC SECTION
|
||||
===============
|
||||
-->
|
||||
<target name="-javadoc-build" depends="init">
|
||||
<mkdir dir="${dist.javadoc.dir}"/>
|
||||
<javadoc destdir="${dist.javadoc.dir}" source="${javac.source}" notree="${javadoc.notree}" use="${javadoc.use}" nonavbar="${javadoc.nonavbar}" noindex="${javadoc.noindex}" splitindex="${javadoc.splitindex}" author="${javadoc.author}" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}" private="${javadoc.private}" additionalparam="${javadoc.additionalparam}" failonerror="true" useexternalfile="true">
|
||||
<classpath>
|
||||
<path path="${javac.classpath}"/>
|
||||
</classpath>
|
||||
<sourcepath>
|
||||
<pathelement location="${src.dir}"/>
|
||||
</sourcepath>
|
||||
<packageset dir="${src.dir}" includes="*/**"/>
|
||||
<fileset dir="${src.dir}" includes="*.java"/>
|
||||
</javadoc>
|
||||
</target>
|
||||
<target name="-javadoc-browse" if="netbeans.home" unless="no.javadoc.preview" depends="init,-javadoc-build">
|
||||
<nbbrowse file="${dist.javadoc.dir}/index.html"/>
|
||||
</target>
|
||||
<target name="javadoc" depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc."/>
|
||||
<!--
|
||||
=========================
|
||||
JUNIT COMPILATION SECTION
|
||||
=========================
|
||||
-->
|
||||
<target name="-pre-pre-compile-test" if="have.tests" depends="init,compile">
|
||||
<mkdir dir="${build.test.classes.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-compile-test">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile-test" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test">
|
||||
<j2seproject3:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}"/>
|
||||
<copy todir="${build.test.classes.dir}">
|
||||
<fileset dir="${test.src.dir}" excludes="**/*.java"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile-test">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile-test" depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test"/>
|
||||
<target name="-pre-compile-test-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile-test-single" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single">
|
||||
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
|
||||
<j2seproject3:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}">
|
||||
<customize>
|
||||
<patternset includes="${javac.includes}"/>
|
||||
</customize>
|
||||
</j2seproject3:javac>
|
||||
<copy todir="${build.test.classes.dir}">
|
||||
<fileset dir="${test.src.dir}" excludes="**/*.java"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile-test-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile-test-single" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single"/>
|
||||
<!--
|
||||
=======================
|
||||
JUNIT EXECUTION SECTION
|
||||
=======================
|
||||
-->
|
||||
<target name="-pre-test-run" if="have.tests" depends="init">
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
</target>
|
||||
<target name="-do-test-run" if="have.tests" depends="init,compile-test,-pre-test-run">
|
||||
<j2seproject3:junit/>
|
||||
</target>
|
||||
<target name="-post-test-run" if="have.tests" depends="init,compile-test,-pre-test-run,-do-test-run">
|
||||
<fail if="tests.failed">Some tests failed; see details above.</fail>
|
||||
</target>
|
||||
<target name="test-report" if="have.tests" depends="init"/>
|
||||
<target name="-test-browse" if="netbeans.home+have.tests" depends="init"/>
|
||||
<target name="test" depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests."/>
|
||||
<target name="-pre-test-run-single" if="have.tests" depends="init">
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
</target>
|
||||
<target name="-do-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single">
|
||||
<fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
|
||||
<j2seproject3:junit includes="${test.includes}"/>
|
||||
</target>
|
||||
<target name="-post-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single">
|
||||
<fail if="tests.failed">Some tests failed; see details above.</fail>
|
||||
</target>
|
||||
<target name="test-single" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test."/>
|
||||
<!--
|
||||
=======================
|
||||
JUNIT DEBUGGING SECTION
|
||||
=======================
|
||||
-->
|
||||
<target name="-debug-start-debuggee-test" if="have.tests" depends="init,compile-test">
|
||||
<fail unless="test.class">Must select one file in the IDE or set test.class</fail>
|
||||
<j2seproject3:debug classname="junit.textui.TestRunner" classpath="${debug.test.classpath}">
|
||||
<customize>
|
||||
<arg line="${test.class}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target name="-debug-start-debugger-test" if="netbeans.home+have.tests" depends="init,compile-test">
|
||||
<j2seproject1:nbjpdastart name="${test.class}" classpath="${debug.test.classpath}"/>
|
||||
</target>
|
||||
<target name="debug-test" depends="init,compile-test,-debug-start-debugger-test,-debug-start-debuggee-test"/>
|
||||
<target name="-do-debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,compile-test-single">
|
||||
<j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
|
||||
</target>
|
||||
<target name="debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix-test"/>
|
||||
<!--
|
||||
=========================
|
||||
APPLET EXECUTION SECTION
|
||||
=========================
|
||||
-->
|
||||
<target name="run-applet" depends="init,compile-single">
|
||||
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
|
||||
<j2seproject1:java classname="sun.applet.AppletViewer">
|
||||
<customize>
|
||||
<arg value="${applet.url}"/>
|
||||
</customize>
|
||||
</j2seproject1:java>
|
||||
</target>
|
||||
<!--
|
||||
=========================
|
||||
APPLET DEBUGGING SECTION
|
||||
=========================
|
||||
-->
|
||||
<target name="-debug-start-debuggee-applet" if="netbeans.home" depends="init,compile-single">
|
||||
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
|
||||
<j2seproject3:debug classname="sun.applet.AppletViewer">
|
||||
<customize>
|
||||
<arg value="${applet.url}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target name="debug-applet" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet"/>
|
||||
<!--
|
||||
===============
|
||||
CLEANUP SECTION
|
||||
===============
|
||||
-->
|
||||
<target name="deps-clean" depends="init" unless="no.deps"/>
|
||||
<target name="-do-clean" depends="init">
|
||||
<delete dir="${build.dir}"/>
|
||||
<delete dir="${dist.dir}"/>
|
||||
</target>
|
||||
<target name="-post-clean">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="clean" depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products."/>
|
||||
</project>
|
||||
@@ -1,8 +0,0 @@
|
||||
build.xml.data.CRC32=94714fd7
|
||||
build.xml.script.CRC32=64128189
|
||||
build.xml.stylesheet.CRC32=240b97a2
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
nbproject/build-impl.xml.data.CRC32=94714fd7
|
||||
nbproject/build-impl.xml.script.CRC32=9d2a0176
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=65d7ca21
|
||||
@@ -1,59 +0,0 @@
|
||||
application.args=
|
||||
build.classes.dir=${build.dir}/classes
|
||||
build.classes.excludes=**/*.java,**/*.form
|
||||
# This directory is removed when the project is cleaned:
|
||||
build.dir=build
|
||||
build.generated.dir=${build.dir}/generated
|
||||
# Only compile against the classpath explicitly listed here:
|
||||
build.sysclasspath=ignore
|
||||
build.test.classes.dir=${build.dir}/test/classes
|
||||
build.test.results.dir=${build.dir}/test/results
|
||||
debug.classpath=\
|
||||
${run.classpath}
|
||||
debug.test.classpath=\
|
||||
${run.test.classpath}
|
||||
# This directory is removed when the project is cleaned:
|
||||
dist.dir=dist
|
||||
dist.jar=${dist.dir}/contrib-ntservice.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
file.reference.jna.jar=../../build/jna.jar
|
||||
libs.junit.classpath=../../lib/junit.jar
|
||||
jar.compress=false
|
||||
javac.classpath=\
|
||||
${file.reference.jna.jar};
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
javac.source=1.5
|
||||
javac.target=1.5
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}:\
|
||||
${libs.junit.classpath}
|
||||
javadoc.additionalparam=
|
||||
javadoc.author=false
|
||||
javadoc.encoding=
|
||||
javadoc.noindex=false
|
||||
javadoc.nonavbar=false
|
||||
javadoc.notree=false
|
||||
javadoc.private=false
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
main.class=
|
||||
manifest.file=manifest.mf
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
platform.active=default_platform
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
# Space-separated list of JVM arguments used when running the project
|
||||
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
|
||||
# or test-sys-prop.name=value to set system properties for unit tests):
|
||||
run.jvmargs=
|
||||
run.test.classpath=\
|
||||
${javac.test.classpath}:\
|
||||
${build.test.classes.dir}
|
||||
src.dir=src
|
||||
test.src.dir=test
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>org.netbeans.modules.java.j2seproject</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<name>ntservice</name>
|
||||
<minimum-ant-version>1.6.5</minimum-ant-version>
|
||||
<source-roots>
|
||||
<root id="src.dir"/>
|
||||
</source-roots>
|
||||
<test-roots>
|
||||
<root id="test.src.dir"/>
|
||||
</test-roots>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
||||
@@ -1,196 +0,0 @@
|
||||
/*
|
||||
* Advapi32.java
|
||||
*
|
||||
* Created on 6. August 2007, 11:24
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.jna;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TB
|
||||
*/
|
||||
public interface Advapi32 extends StdCallLibrary {
|
||||
Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32",
|
||||
Advapi32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/*
|
||||
* SC_HANDLE WINAPI OpenSCManager( LPCTSTR lpMachineName, LPCTSTR
|
||||
* lpDatabaseName, DWORD dwDesiredAccess );
|
||||
*/
|
||||
public Pointer OpenSCManager(String lpMachineName, WString lpDatabaseName,
|
||||
int dwDesiredAccess);
|
||||
|
||||
/*
|
||||
* BOOL WINAPI CloseServiceHandle( SC_HANDLE hSCObject );
|
||||
*/
|
||||
public boolean CloseServiceHandle(Pointer hSCObject);
|
||||
|
||||
/*
|
||||
* SC_HANDLE WINAPI OpenService( SC_HANDLE hSCManager, LPCTSTR
|
||||
* lpServiceName, DWORD dwDesiredAccess );
|
||||
*/
|
||||
public Pointer OpenService(Pointer hSCManager, String lpServiceName,
|
||||
int dwDesiredAccess);
|
||||
|
||||
/*
|
||||
* BOOL WINAPI StartService( SC_HANDLE hService, DWORD dwNumServiceArgs,
|
||||
* LPCTSTR* lpServiceArgVectors );
|
||||
*/
|
||||
public boolean StartService(Pointer hService, int dwNumServiceArgs,
|
||||
char[] lpServiceArgVectors);
|
||||
|
||||
/*
|
||||
* BOOL WINAPI ControlService( SC_HANDLE hService, DWORD dwControl,
|
||||
* LPSERVICE_STATUS lpServiceStatus );
|
||||
*/
|
||||
public boolean ControlService(Pointer hService, int dwControl,
|
||||
SERVICE_STATUS lpServiceStatus);
|
||||
|
||||
/*
|
||||
* BOOL WINAPI StartServiceCtrlDispatcher( const SERVICE_TABLE_ENTRY*
|
||||
* lpServiceTable );
|
||||
*/
|
||||
public boolean StartServiceCtrlDispatcher(Structure[] lpServiceTable);
|
||||
|
||||
/*
|
||||
* SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandler( LPCTSTR
|
||||
* lpServiceName, LPHANDLER_FUNCTION lpHandlerProc );
|
||||
*/
|
||||
public Pointer RegisterServiceCtrlHandler(String lpServiceName,
|
||||
Handler lpHandlerProc);
|
||||
|
||||
/*
|
||||
* SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerEx( LPCTSTR
|
||||
* lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext );
|
||||
*/
|
||||
public Pointer RegisterServiceCtrlHandlerEx(String lpServiceName,
|
||||
HandlerEx lpHandlerProc, Pointer lpContext);
|
||||
|
||||
/*
|
||||
* BOOL WINAPI SetServiceStatus( SERVICE_STATUS_HANDLE hServiceStatus,
|
||||
* LPSERVICE_STATUS lpServiceStatus );
|
||||
*/
|
||||
public boolean SetServiceStatus(Pointer hServiceStatus,
|
||||
SERVICE_STATUS lpServiceStatus);
|
||||
|
||||
/*
|
||||
* SC_HANDLE WINAPI CreateService( SC_HANDLE hSCManager, LPCTSTR
|
||||
* lpServiceName, LPCTSTR lpDisplayName, DWORD dwDesiredAccess, DWORD
|
||||
* dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCTSTR
|
||||
* lpBinaryPathName, LPCTSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPCTSTR
|
||||
* lpDependencies, LPCTSTR lpServiceStartName, LPCTSTR lpPassword );
|
||||
*/
|
||||
public Pointer CreateService(Pointer hSCManager, String lpServiceName,
|
||||
String lpDisplayName, int dwDesiredAccess, int dwServiceType,
|
||||
int dwStartType, int dwErrorControl, String lpBinaryPathName,
|
||||
String lpLoadOrderGroup, IntByReference lpdwTagId,
|
||||
String lpDependencies, String lpServiceStartName, String lpPassword);
|
||||
|
||||
/*
|
||||
* BOOL WINAPI DeleteService( SC_HANDLE hService );
|
||||
*/
|
||||
public boolean DeleteService(Pointer hService);
|
||||
|
||||
/*
|
||||
* BOOL WINAPI ChangeServiceConfig2( SC_HANDLE hService, DWORD dwInfoLevel,
|
||||
* LPVOID lpInfo );
|
||||
*/
|
||||
public boolean ChangeServiceConfig2(Pointer hService, int dwInfoLevel,
|
||||
ChangeServiceConfig2Info lpInfo);
|
||||
|
||||
/*
|
||||
* LONG WINAPI RegEnumValue( HKEY hKey, DWORD dwIndex, LPTSTR lpValueName,
|
||||
* LPDWORD lpcchValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE
|
||||
* lpData, LPDWORD lpcbData );
|
||||
*/
|
||||
public int RegEnumValue(int hKey, int dwIndex, char[] lpValueName,
|
||||
IntByReference lpcchValueName, IntByReference reserved,
|
||||
IntByReference lpType, byte[] lpData, IntByReference lpcbData);
|
||||
|
||||
interface SERVICE_MAIN_FUNCTION extends StdCallCallback {
|
||||
/*
|
||||
* VOID WINAPI ServiceMain( DWORD dwArgc, LPTSTR* lpszArgv );
|
||||
*/
|
||||
public void callback(int dwArgc, Pointer lpszArgv);
|
||||
}
|
||||
|
||||
interface Handler extends StdCallCallback {
|
||||
/*
|
||||
* VOID WINAPI Handler( DWORD fdwControl );
|
||||
*/
|
||||
public void callback(int fdwControl);
|
||||
}
|
||||
|
||||
interface HandlerEx extends StdCallCallback {
|
||||
/*
|
||||
* DWORD WINAPI HandlerEx( DWORD dwControl, DWORD dwEventType, LPVOID
|
||||
* lpEventData, LPVOID lpContext );
|
||||
*/
|
||||
public int callback(int dwControl, int dwEventType,
|
||||
Pointer lpEventData, Pointer lpContext);
|
||||
}
|
||||
|
||||
/*
|
||||
* typedef struct _SERVICE_STATUS { DWORD dwServiceType; DWORD
|
||||
* dwCurrentState; DWORD dwControlsAccepted; DWORD dwWin32ExitCode; DWORD
|
||||
* dwServiceSpecificExitCode; DWORD dwCheckPoint; DWORD dwWaitHint; }
|
||||
* SERVICE_STATUS,LPSERVICE_STATUS;
|
||||
*/
|
||||
public static class SERVICE_STATUS extends Structure {
|
||||
public int dwServiceType;
|
||||
public int dwCurrentState;
|
||||
public int dwControlsAccepted;
|
||||
public int dwWin32ExitCode;
|
||||
public int dwServiceSpecificExitCode;
|
||||
public int dwCheckPoint;
|
||||
public int dwWaitHint;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dwServiceType", "dwCurrentState", "dwControlsAccepted", "dwWin32ExitCode", "dwServiceSpecificExitCode", "dwCheckPoint", "dwWaitHint" });
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* typedef struct _SERVICE_TABLE_ENTRY { LPTSTR lpServiceName;
|
||||
* LPSERVICE_MAIN_FUNCTION lpServiceProc; } SERVICE_TABLE_ENTRY,
|
||||
* LPSERVICE_TABLE_ENTRY;
|
||||
*/
|
||||
public static class SERVICE_TABLE_ENTRY extends Structure {
|
||||
public String lpServiceName;
|
||||
public SERVICE_MAIN_FUNCTION lpServiceProc;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "lpServiceName", "lpServiceProc" });
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class ChangeServiceConfig2Info extends Structure {
|
||||
}
|
||||
|
||||
/*
|
||||
* typedef struct _SERVICE_DESCRIPTION { LPTSTR lpDescription; }
|
||||
* SERVICE_DESCRIPTION,LPSERVICE_DESCRIPTION;
|
||||
*/
|
||||
public static class SERVICE_DESCRIPTION extends ChangeServiceConfig2Info {
|
||||
public String lpDescription;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "lpDescription" });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* WINERROR.java
|
||||
*
|
||||
* Created on 7. August 2007, 08:09
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.jna;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TB
|
||||
*/
|
||||
public interface WINERROR {
|
||||
public final static int ERROR_SUCCESS = 0;
|
||||
public final static int NO_ERROR = 0;
|
||||
public final static int ERROR_FILE_NOT_FOUND = 2;
|
||||
public final static int ERROR_MORE_DATA = 234;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* WINNT.java
|
||||
*
|
||||
* Created on 8. August 2007, 13:41
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.jna;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TB
|
||||
*/
|
||||
public interface WINNT {
|
||||
public final static int DELETE = 0x00010000;
|
||||
public final static int READ_CONTROL = 0x00020000;
|
||||
public final static int WRITE_DAC = 0x00040000;
|
||||
public final static int WRITE_OWNER = 0x00080000;
|
||||
public final static int SYNCHRONIZE = 0x00100000;
|
||||
|
||||
public final static int STANDARD_RIGHTS_REQUIRED = 0x000F0000;
|
||||
|
||||
public final static int STANDARD_RIGHTS_READ = READ_CONTROL;
|
||||
public final static int STANDARD_RIGHTS_WRITE = READ_CONTROL;
|
||||
public final static int STANDARD_RIGHTS_EXECUTE = READ_CONTROL;
|
||||
|
||||
public final static int STANDARD_RIGHTS_ALL = 0x001F0000;
|
||||
|
||||
public final static int SPECIFIC_RIGHTS_ALL = 0x0000FFFF;
|
||||
|
||||
public final static int GENERIC_EXECUTE = 0x20000000;
|
||||
|
||||
public final static int SERVICE_WIN32_OWN_PROCESS = 0x00000010;
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* WINSVC.java
|
||||
*
|
||||
* Created on 8. August 2007, 15:07
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.jna;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TB
|
||||
*/
|
||||
public interface WINSVC {
|
||||
public final static int SERVICE_CONTROL_STOP = 0x00000001;
|
||||
public final static int SERVICE_CONTROL_SHUTDOWN = 0x00000005;
|
||||
|
||||
public final static int SERVICE_STOPPED = 0x00000001;
|
||||
public final static int SERVICE_START_PENDING = 0x00000002;
|
||||
public final static int SERVICE_STOP_PENDING = 0x00000003;
|
||||
public final static int SERVICE_RUNNING = 0x00000004;
|
||||
public final static int SERVICE_CONTINUE_PENDING = 0x00000005;
|
||||
public final static int SERVICE_PAUSE_PENDING = 0x00000006;
|
||||
public final static int SERVICE_PAUSED = 0x00000007;
|
||||
|
||||
public final static int SERVICE_ACCEPT_STOP = 0x00000001;
|
||||
public final static int SERVICE_ACCEPT_PAUSE_CONTINUE = 0x00000002;
|
||||
public final static int SERVICE_ACCEPT_SHUTDOWN = 0x00000004;
|
||||
public final static int SERVICE_ACCEPT_PARAMCHANGE = 0x00000008;
|
||||
public final static int SERVICE_ACCEPT_NETBINDCHANGE = 0x00000010;
|
||||
|
||||
public final static int SC_MANAGER_CONNECT = 0x0001;
|
||||
public final static int SC_MANAGER_CREATE_SERVICE = 0x0002;
|
||||
public final static int SC_MANAGER_ENUMERATE_SERVICE = 0x0004;
|
||||
public final static int SC_MANAGER_LOCK = 0x0008;
|
||||
public final static int SC_MANAGER_QUERY_LOCK_STATUS = 0x0010;
|
||||
public final static int SC_MANAGER_MODIFY_BOOT_CONFIG = 0x0020;
|
||||
|
||||
public final static int SC_MANAGER_ALL_ACCESS = WINNT.STANDARD_RIGHTS_REQUIRED |
|
||||
SC_MANAGER_CONNECT |
|
||||
SC_MANAGER_CREATE_SERVICE |
|
||||
SC_MANAGER_ENUMERATE_SERVICE |
|
||||
SC_MANAGER_LOCK |
|
||||
SC_MANAGER_QUERY_LOCK_STATUS |
|
||||
SC_MANAGER_MODIFY_BOOT_CONFIG;
|
||||
|
||||
public final static int SERVICE_QUERY_CONFIG = 0x0001;
|
||||
public final static int SERVICE_CHANGE_CONFIG = 0x0002;
|
||||
public final static int SERVICE_QUERY_STATUS = 0x0004;
|
||||
public final static int SERVICE_ENUMERATE_DEPENDENTS = 0x0008;
|
||||
public final static int SERVICE_START = 0x0010;
|
||||
public final static int SERVICE_STOP = 0x0020;
|
||||
public final static int SERVICE_PAUSE_CONTINUE = 0x0040;
|
||||
public final static int SERVICE_INTERROGATE = 0x0080;
|
||||
public final static int SERVICE_USER_DEFINED_CONTROL = 0x0100;
|
||||
|
||||
public final static int SERVICE_ALL_ACCESS = WINNT.STANDARD_RIGHTS_REQUIRED |
|
||||
SERVICE_QUERY_CONFIG |
|
||||
SERVICE_CHANGE_CONFIG |
|
||||
SERVICE_QUERY_STATUS |
|
||||
SERVICE_ENUMERATE_DEPENDENTS |
|
||||
SERVICE_START |
|
||||
SERVICE_STOP |
|
||||
SERVICE_PAUSE_CONTINUE |
|
||||
SERVICE_INTERROGATE |
|
||||
SERVICE_USER_DEFINED_CONTROL;
|
||||
|
||||
public final static int SERVICE_CONFIG_DESCRIPTION = 1;
|
||||
public final static int SERVICE_CONFIG_FAILURE_ACTIONS = 2;
|
||||
|
||||
public final static int SERVICE_KERNEL_DRIVER = 0x00000001;
|
||||
public final static int SERVICE_FILE_SYSTEM_DRIVER = 0x00000002;
|
||||
public final static int SERVICE_ADAPTER = 0x00000004;
|
||||
public final static int SERVICE_RECOGNIZER_DRIVER = 0x00000008;
|
||||
|
||||
public final static int SERVICE_DRIVER = SERVICE_KERNEL_DRIVER |
|
||||
SERVICE_FILE_SYSTEM_DRIVER |
|
||||
SERVICE_RECOGNIZER_DRIVER;
|
||||
|
||||
public final static int SERVICE_WIN32_OWN_PROCESS = 0x00000010;
|
||||
public final static int SERVICE_WIN32_SHARE_PROCESS = 0x00000020;
|
||||
public final static int SERVICE_WIN32 = SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS;
|
||||
|
||||
public final static int SERVICE_INTERACTIVE_PROCESS = 0x00000100;
|
||||
|
||||
public final static int SERVICE_TYPE_ALL = SERVICE_WIN32 |
|
||||
SERVICE_ADAPTER |
|
||||
SERVICE_DRIVER |
|
||||
SERVICE_INTERACTIVE_PROCESS;
|
||||
|
||||
public final static int SERVICE_BOOT_START = 0x00000000;
|
||||
public final static int SERVICE_SYSTEM_START = 0x00000001;
|
||||
public final static int SERVICE_AUTO_START = 0x00000002;
|
||||
public final static int SERVICE_DEMAND_START = 0x00000003;
|
||||
public final static int SERVICE_DISABLED = 0x00000004;
|
||||
|
||||
public final static int SERVICE_ERROR_IGNORE = 0x00000000;
|
||||
public final static int SERVICE_ERROR_NORMAL = 0x00000001;
|
||||
public final static int SERVICE_ERROR_SEVERE = 0x00000002;
|
||||
public final static int SERVICE_ERROR_CRITICAL = 0x00000003;
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* TestService.java
|
||||
*
|
||||
* Created on 12. September 2007, 12:49
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.win32;
|
||||
|
||||
/**
|
||||
* TestService.
|
||||
*/
|
||||
public class TestService extends Win32Service {
|
||||
|
||||
/**
|
||||
* main.
|
||||
* @param args arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
TestService service = new TestService();
|
||||
|
||||
if(args.length == 1) {
|
||||
|
||||
if(args[0].equalsIgnoreCase("install")) {
|
||||
System.out.println(service.install("TestService DisplayName", "TestService Description",
|
||||
null, null, null));
|
||||
|
||||
} else if(args[0].equalsIgnoreCase("uninstall")) {
|
||||
System.out.println(service.uninstall());
|
||||
|
||||
} else {
|
||||
System.out.println("Arguments:");
|
||||
System.out.println("install = install service");
|
||||
System.out.println("uninstall = uninstall service");
|
||||
System.out.println("<none> = run service");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
} else {
|
||||
service.init();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of TestService.
|
||||
*/
|
||||
public TestService() {
|
||||
super("TestService");
|
||||
}
|
||||
|
||||
/**
|
||||
* Will be called on start.
|
||||
*/
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Will be called on stop.
|
||||
*/
|
||||
public void onStop() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,310 +0,0 @@
|
||||
/*
|
||||
* Win32Service.java
|
||||
*
|
||||
* Created on 12. September 2007, 12:05
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.win32;
|
||||
|
||||
import jnacontrib.jna.*;
|
||||
import com.sun.jna.Pointer;
|
||||
|
||||
/**
|
||||
* Baseclass for a Win32 service.
|
||||
*/
|
||||
public abstract class Win32Service {
|
||||
protected String serviceName;
|
||||
private ServiceMain serviceMain;
|
||||
private ServiceControl serviceControl;
|
||||
private Pointer serviceStatusHandle;
|
||||
private Object waitObject = new Object();
|
||||
|
||||
/**
|
||||
* Creates a new instance of Win32Service.
|
||||
*
|
||||
* @param serviceName internal name of the service
|
||||
*/
|
||||
public Win32Service(String serviceName) {
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install the service.
|
||||
*
|
||||
* @param displayName visible name
|
||||
* @param description description
|
||||
* @param dependencies array of other services to depend on or null
|
||||
* @param account service account or null for LocalSystem
|
||||
* @param password password for service account or null
|
||||
* @throws java.lang.Exception
|
||||
* @return true on success
|
||||
*/
|
||||
public boolean install(String displayName, String description, String[] dependencies, String account, String password) {
|
||||
return(install(displayName, description, dependencies, account, password, "java.exe -cp \"" +
|
||||
System.getProperty("java.class.path") + "\" -Xrs " + this.getClass().getName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Install the service.
|
||||
*
|
||||
* @return true on success
|
||||
* @param displayName visible name
|
||||
* @param description description
|
||||
* @param dependencies array of other services to depend on or null
|
||||
* @param account service account or null for LocalSystem
|
||||
* @param password password for service account or null
|
||||
* @param command command line to start the service
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
public boolean install(String displayName, String description, String[] dependencies, String account, String password, String command) {
|
||||
Advapi32 advapi32;
|
||||
Advapi32.SERVICE_DESCRIPTION desc;
|
||||
Pointer serviceManager, service;
|
||||
boolean success = false;
|
||||
String dep = "";
|
||||
|
||||
if(dependencies != null) {
|
||||
for(String s : dependencies) {
|
||||
dep += s + "\0";
|
||||
}
|
||||
}
|
||||
dep += "\0";
|
||||
|
||||
desc = new Advapi32.SERVICE_DESCRIPTION();
|
||||
desc.lpDescription = description;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
serviceManager = openServiceControlManager(null, WINSVC.SC_MANAGER_ALL_ACCESS);
|
||||
|
||||
if(serviceManager != null) {
|
||||
service = advapi32.CreateService(serviceManager, serviceName, displayName,
|
||||
WINSVC.SERVICE_ALL_ACCESS, WINSVC.SERVICE_WIN32_OWN_PROCESS, WINSVC.SERVICE_DEMAND_START,
|
||||
WINSVC.SERVICE_ERROR_NORMAL,
|
||||
command,
|
||||
null, null, dep, account, password);
|
||||
|
||||
if(service != null) {
|
||||
success = advapi32.ChangeServiceConfig2(service, WINSVC.SERVICE_CONFIG_DESCRIPTION, desc);
|
||||
advapi32.CloseServiceHandle(service);
|
||||
}
|
||||
advapi32.CloseServiceHandle(serviceManager);
|
||||
}
|
||||
return(success);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstall the service.
|
||||
*
|
||||
* @throws java.lang.Exception
|
||||
* @return true on success
|
||||
*/
|
||||
public boolean uninstall() {
|
||||
Advapi32 advapi32;
|
||||
Pointer serviceManager, service;
|
||||
boolean success = false;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
serviceManager = openServiceControlManager(null, WINSVC.SC_MANAGER_ALL_ACCESS);
|
||||
|
||||
if(serviceManager != null) {
|
||||
service = advapi32.OpenService(serviceManager, serviceName, WINSVC.SERVICE_ALL_ACCESS);
|
||||
|
||||
if(service != null) {
|
||||
success = advapi32.DeleteService(service);
|
||||
advapi32.CloseServiceHandle(service);
|
||||
}
|
||||
advapi32.CloseServiceHandle(serviceManager);
|
||||
}
|
||||
return(success);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask the ServiceControlManager to start the service.
|
||||
* @return true on success
|
||||
*/
|
||||
public boolean start() {
|
||||
Advapi32 advapi32;
|
||||
Pointer serviceManager, service;
|
||||
boolean success = false;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
|
||||
serviceManager = openServiceControlManager(null, WINNT.GENERIC_EXECUTE);
|
||||
|
||||
if(serviceManager != null) {
|
||||
service = advapi32.OpenService(serviceManager, serviceName, WINNT.GENERIC_EXECUTE);
|
||||
|
||||
if(service != null) {
|
||||
success = advapi32.StartService(service, 0, null);
|
||||
advapi32.CloseServiceHandle(service);
|
||||
}
|
||||
advapi32.CloseServiceHandle(serviceManager);
|
||||
}
|
||||
|
||||
return(success);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask the ServiceControlManager to stop the service.
|
||||
* @return true on success
|
||||
*/
|
||||
public boolean stop() throws Exception {
|
||||
Advapi32 advapi32;
|
||||
Pointer serviceManager, service;
|
||||
Advapi32.SERVICE_STATUS serviceStatus;
|
||||
boolean success = false;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
|
||||
serviceManager = openServiceControlManager(null, WINNT.GENERIC_EXECUTE);
|
||||
|
||||
if(serviceManager != null) {
|
||||
service = advapi32.OpenService(serviceManager, serviceName, WINNT.GENERIC_EXECUTE);
|
||||
|
||||
if(service != null) {
|
||||
serviceStatus = new Advapi32.SERVICE_STATUS();
|
||||
success = advapi32.ControlService(service, WINSVC.SERVICE_CONTROL_STOP, serviceStatus);
|
||||
advapi32.CloseServiceHandle(service);
|
||||
}
|
||||
advapi32.CloseServiceHandle(serviceManager);
|
||||
}
|
||||
|
||||
return(success);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the service, connect to the ServiceControlManager.
|
||||
*/
|
||||
public void init() {
|
||||
Advapi32 advapi32;
|
||||
Advapi32.SERVICE_TABLE_ENTRY entry;
|
||||
|
||||
serviceMain = new ServiceMain();
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
entry = new Advapi32.SERVICE_TABLE_ENTRY();
|
||||
entry.lpServiceName = serviceName;
|
||||
entry.lpServiceProc = serviceMain;
|
||||
|
||||
advapi32.StartServiceCtrlDispatcher(entry.toArray(2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a handle to the ServiceControlManager.
|
||||
*
|
||||
* @param machine name of the machine or null for localhost
|
||||
* @param access access flags
|
||||
* @return handle to ServiceControlManager or null when failed
|
||||
*/
|
||||
private Pointer openServiceControlManager(String machine, int access) {
|
||||
Pointer handle = null;
|
||||
Advapi32 advapi32;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
handle = advapi32.OpenSCManager(machine, null, access);
|
||||
return(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Report service status to the ServiceControlManager.
|
||||
*
|
||||
* @param status status
|
||||
* @param win32ExitCode exit code
|
||||
* @param waitHint time to wait
|
||||
*/
|
||||
private void reportStatus(int status, int win32ExitCode, int waitHint) {
|
||||
Advapi32 advapi32;
|
||||
Advapi32.SERVICE_STATUS serviceStatus;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
serviceStatus = new Advapi32.SERVICE_STATUS();
|
||||
serviceStatus.dwServiceType = WINNT.SERVICE_WIN32_OWN_PROCESS;
|
||||
serviceStatus.dwControlsAccepted = WINSVC.SERVICE_ACCEPT_STOP | WINSVC.SERVICE_ACCEPT_SHUTDOWN;
|
||||
serviceStatus.dwWin32ExitCode = win32ExitCode;
|
||||
serviceStatus.dwWaitHint = waitHint;
|
||||
serviceStatus.dwCurrentState = status;
|
||||
|
||||
advapi32.SetServiceStatus(serviceStatusHandle, serviceStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when service is starting.
|
||||
*/
|
||||
public abstract void onStart();
|
||||
|
||||
/*
|
||||
* Called when service should stop.
|
||||
*/
|
||||
public abstract void onStop();
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of the service main function.
|
||||
*/
|
||||
private class ServiceMain implements Advapi32.SERVICE_MAIN_FUNCTION {
|
||||
|
||||
/**
|
||||
* Called when the service is starting.
|
||||
*
|
||||
* @param dwArgc number of arguments
|
||||
* @param lpszArgv pointer to arguments
|
||||
*/
|
||||
public void callback(int dwArgc, Pointer lpszArgv) {
|
||||
Advapi32 advapi32;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
|
||||
serviceControl = new ServiceControl();
|
||||
serviceStatusHandle = advapi32.RegisterServiceCtrlHandlerEx(serviceName, serviceControl, null);
|
||||
|
||||
reportStatus(WINSVC.SERVICE_START_PENDING, WINERROR.NO_ERROR, 3000);
|
||||
reportStatus(WINSVC.SERVICE_RUNNING, WINERROR.NO_ERROR, 0);
|
||||
|
||||
onStart();
|
||||
|
||||
try {
|
||||
synchronized(waitObject) {
|
||||
waitObject.wait();
|
||||
}
|
||||
} catch (InterruptedException ex) {
|
||||
}
|
||||
reportStatus(WINSVC.SERVICE_STOPPED, WINERROR.NO_ERROR, 0);
|
||||
|
||||
// Avoid returning from ServiceMain, which will cause a crash
|
||||
// See http://support.microsoft.com/kb/201349, which recommends
|
||||
// having init() wait for this thread.
|
||||
// Waiting on this thread in init() won't fix the crash, though.
|
||||
//System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of the service control function.
|
||||
*/
|
||||
private class ServiceControl implements Advapi32.HandlerEx {
|
||||
|
||||
/**
|
||||
* Called when the service get a control code.
|
||||
*
|
||||
* @param dwControl
|
||||
* @param dwEventType
|
||||
* @param lpEventData
|
||||
* @param lpContext
|
||||
*/
|
||||
public int callback(int dwControl, int dwEventType, Pointer lpEventData, Pointer lpContext) {
|
||||
switch(dwControl) {
|
||||
case WINSVC.SERVICE_CONTROL_STOP:
|
||||
case WINSVC.SERVICE_CONTROL_SHUTDOWN:
|
||||
reportStatus(WINSVC.SERVICE_STOP_PENDING, WINERROR.NO_ERROR, 5000);
|
||||
onStop();
|
||||
synchronized(waitObject) {
|
||||
waitObject.notifyAll();
|
||||
}
|
||||
}
|
||||
return WINERROR.NO_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
# placeholder
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" output="build.eclipse/contrib-test-classes" path="test"/>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/jnalib"/>
|
||||
<classpathentry kind="lib" path="/jnalib/dist/jna.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>platform</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,89 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="platform" default="default" basedir=".">
|
||||
<description>Builds, tests, and runs the project platform.</description>
|
||||
<import file="nbproject/build-impl.xml"/>
|
||||
<!--
|
||||
|
||||
There exist several targets which are by default empty and which can be
|
||||
used for execution of your tasks. These targets are usually executed
|
||||
before and after some main targets. They are:
|
||||
|
||||
-pre-init: called before initialization of project properties
|
||||
-post-init: called after initialization of project properties
|
||||
-pre-compile: called before javac compilation
|
||||
-post-compile: called after javac compilation
|
||||
-pre-compile-single: called before javac compilation of single file
|
||||
-post-compile-single: called after javac compilation of single file
|
||||
-pre-compile-test: called before javac compilation of JUnit tests
|
||||
-post-compile-test: called after javac compilation of JUnit tests
|
||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||
-pre-jar: called before JAR building
|
||||
-post-jar: called after JAR building
|
||||
-post-clean: called after cleaning build products
|
||||
|
||||
(Targets beginning with '-' are not intended to be called on their own.)
|
||||
|
||||
Example of inserting an obfuscator after compilation could look like this:
|
||||
|
||||
<target name="-post-compile">
|
||||
<obfuscate>
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
</obfuscate>
|
||||
</target>
|
||||
|
||||
For list of available properties check the imported
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
|
||||
Another way to customize the build is by overriding existing main targets.
|
||||
The targets of interest are:
|
||||
|
||||
-init-macrodef-javac: defines macro for javac compilation
|
||||
-init-macrodef-junit: defines macro for junit execution
|
||||
-init-macrodef-debug: defines macro for class debugging
|
||||
-init-macrodef-java: defines macro for class execution
|
||||
-do-jar-with-manifest: JAR building (if you are using a manifest)
|
||||
-do-jar-without-manifest: JAR building (if you are not using a manifest)
|
||||
run: execution of project
|
||||
-javadoc-build: Javadoc generation
|
||||
test-report: JUnit report generation
|
||||
|
||||
An example of overriding the target for project execution could look like this:
|
||||
|
||||
<target name="run" depends="JnaContrib-impl.jar">
|
||||
<exec dir="bin" executable="launcher.exe">
|
||||
<arg file="${dist.jar}"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
Notice that the overridden target depends on the jar target and not only on
|
||||
the compile target as the regular run target does. Again, for a list of available
|
||||
properties which you can use, check the target you are overriding in the
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
-->
|
||||
<condition property="tests.platform" value="test-win32">
|
||||
<os family="windows"/>
|
||||
</condition>
|
||||
<condition property="tests.platform" value="test-osx">
|
||||
<os family="mac"/>
|
||||
</condition>
|
||||
<target name="test" depends="init,compile-test" description="Run unit tests." if="tests.platform">
|
||||
<antcall target="${tests.platform}" />
|
||||
</target>
|
||||
<target name="test-report">
|
||||
<junitreport todir="${build.test.results.dir}">
|
||||
<fileset dir="${build.test.results.dir}">
|
||||
<include name="TEST-*.xml"/>
|
||||
</fileset>
|
||||
<report todir="${build.test.results.dir}"/>
|
||||
</junitreport>
|
||||
<property name="build.test.results.dir.abs" location="${build.test.results.dir}"/>
|
||||
<echo message="View test report in file://${build.test.results.dir.abs}/index.html" />
|
||||
</target>
|
||||
<target name="test-osx">
|
||||
<echo>No platform tests yet for OSX</echo>
|
||||
</target>
|
||||
<target name="test-win32" depends="-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" />
|
||||
</project>
|
||||
@@ -1,541 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
*** GENERATED FROM project.xml - DO NOT EDIT ***
|
||||
*** EDIT ../build.xml INSTEAD ***
|
||||
|
||||
For the purpose of easier reading the script
|
||||
is divided into following sections:
|
||||
|
||||
- initialization
|
||||
- compilation
|
||||
- jar
|
||||
- execution
|
||||
- debugging
|
||||
- javadoc
|
||||
- junit compilation
|
||||
- junit execution
|
||||
- junit debugging
|
||||
- applet
|
||||
- cleanup
|
||||
|
||||
-->
|
||||
<project name="platform-impl" default="default" basedir=".." xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:jaxws="http://www.netbeans.org/ns/jax-ws/1">
|
||||
<target name="default" depends="test,jar,javadoc" description="Build and test whole project."/>
|
||||
<!--
|
||||
======================
|
||||
INITIALIZATION SECTION
|
||||
======================
|
||||
-->
|
||||
<target name="-pre-init">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-init-private" depends="-pre-init">
|
||||
<property file="nbproject/private/private.properties"/>
|
||||
</target>
|
||||
<target name="-init-user" depends="-pre-init,-init-private">
|
||||
<property file="${user.properties.file}"/>
|
||||
<!-- The two properties below are usually overridden -->
|
||||
<!-- by the active platform. Just a fallback. -->
|
||||
<property name="default.javac.source" value="1.4"/>
|
||||
<property name="default.javac.target" value="1.4"/>
|
||||
</target>
|
||||
<target name="-init-project" depends="-pre-init,-init-private,-init-user">
|
||||
<property file="nbproject/project.properties"/>
|
||||
</target>
|
||||
<target name="-do-init" depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property">
|
||||
<available file="${manifest.file}" property="manifest.available"/>
|
||||
<condition property="manifest.available+main.class">
|
||||
<and>
|
||||
<isset property="manifest.available"/>
|
||||
<isset property="main.class"/>
|
||||
<not>
|
||||
<equals arg1="${main.class}" arg2="" trim="true"/>
|
||||
</not>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="manifest.available+main.class+mkdist.available">
|
||||
<and>
|
||||
<istrue value="${manifest.available+main.class}"/>
|
||||
<isset property="libs.CopyLibs.classpath"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="have.tests">
|
||||
<or>
|
||||
<available file="${test.src.dir}"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition property="have.sources">
|
||||
<or>
|
||||
<available file="${src.dir}"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition property="netbeans.home+have.tests">
|
||||
<and>
|
||||
<isset property="netbeans.home"/>
|
||||
<isset property="have.tests"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="no.javadoc.preview">
|
||||
<isfalse value="${javadoc.preview}"/>
|
||||
</condition>
|
||||
<property name="run.jvmargs" value=""/>
|
||||
<property name="javac.compilerargs" value=""/>
|
||||
<property name="work.dir" value="${basedir}"/>
|
||||
<condition property="no.deps">
|
||||
<and>
|
||||
<istrue value="${no.dependencies}"/>
|
||||
</and>
|
||||
</condition>
|
||||
<property name="javac.debug" value="true"/>
|
||||
<property name="javadoc.preview" value="true"/>
|
||||
</target>
|
||||
<target name="-post-init">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-init-check" depends="-pre-init,-init-private,-init-user,-init-project,-do-init">
|
||||
<fail unless="src.dir">Must set src.dir</fail>
|
||||
<fail unless="test.src.dir">Must set test.src.dir</fail>
|
||||
<fail unless="build.dir">Must set build.dir</fail>
|
||||
<fail unless="dist.dir">Must set dist.dir</fail>
|
||||
<fail unless="build.classes.dir">Must set build.classes.dir</fail>
|
||||
<fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
|
||||
<fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
|
||||
<fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
|
||||
<fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
|
||||
<fail unless="dist.jar">Must set dist.jar</fail>
|
||||
</target>
|
||||
<target name="-init-macrodef-property">
|
||||
<macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="name"/>
|
||||
<attribute name="value"/>
|
||||
<sequential>
|
||||
<property name="@{name}" value="${@{value}}"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-javac">
|
||||
<macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="srcdir" default="${src.dir}"/>
|
||||
<attribute name="destdir" default="${build.classes.dir}"/>
|
||||
<attribute name="classpath" default="${javac.classpath}"/>
|
||||
<attribute name="debug" default="${javac.debug}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<javac srcdir="@{srcdir}" destdir="@{destdir}" debug="@{debug}" deprecation="${javac.deprecation}" source="${javac.source}" target="${javac.target}" includeantruntime="false">
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<compilerarg line="${javac.compilerargs}"/>
|
||||
<customize/>
|
||||
</javac>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-junit">
|
||||
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="includes" default="**/*Test.java"/>
|
||||
<sequential>
|
||||
<junit showoutput="true" fork="true" dir="${basedir}" failureproperty="tests.failed" errorproperty="tests.failed">
|
||||
<batchtest todir="${build.test.results.dir}">
|
||||
<fileset dir="${test.src.dir}" includes="@{includes}"/>
|
||||
</batchtest>
|
||||
<classpath>
|
||||
<path path="${run.test.classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="test-sys-prop."/>
|
||||
<mapper type="glob" from="test-sys-prop.*" to="*"/>
|
||||
</syspropertyset>
|
||||
<formatter type="brief" usefile="false"/>
|
||||
<formatter type="xml"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
</junit>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-nbjpda">
|
||||
<macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="name" default="${main.class}"/>
|
||||
<attribute name="classpath" default="${debug.classpath}"/>
|
||||
<attribute name="stopclassname" default=""/>
|
||||
<sequential>
|
||||
<nbjpdastart transport="dt_socket" addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}">
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
</nbjpdastart>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
<macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="dir" default="${build.classes.dir}"/>
|
||||
<sequential>
|
||||
<nbjpdareload>
|
||||
<fileset includes="${fix.includes}*.class" dir="@{dir}"/>
|
||||
</nbjpdareload>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-debug">
|
||||
<macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="classname" default="${main.class}"/>
|
||||
<attribute name="classpath" default="${debug.classpath}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<java fork="true" classname="@{classname}" dir="${work.dir}">
|
||||
<jvmarg value="-Xdebug"/>
|
||||
<jvmarg value="-Xnoagent"/>
|
||||
<jvmarg value="-Djava.compiler=none"/>
|
||||
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="run-sys-prop."/>
|
||||
<mapper type="glob" from="run-sys-prop.*" to="*"/>
|
||||
</syspropertyset>
|
||||
<customize/>
|
||||
</java>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-java">
|
||||
<macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="classname" default="${main.class}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<java fork="true" classname="@{classname}" dir="${work.dir}">
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<classpath>
|
||||
<path path="${run.classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="run-sys-prop."/>
|
||||
<mapper type="glob" from="run-sys-prop.*" to="*"/>
|
||||
</syspropertyset>
|
||||
<customize/>
|
||||
</java>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-presetdef-jar">
|
||||
<presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<jar jarfile="${dist.jar}" compress="${jar.compress}">
|
||||
<j2seproject1:fileset dir="${build.classes.dir}"/>
|
||||
</jar>
|
||||
</presetdef>
|
||||
</target>
|
||||
<target name="init" depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar"/>
|
||||
<!--
|
||||
===================
|
||||
COMPILATION SECTION
|
||||
===================
|
||||
-->
|
||||
<target name="deps-jar" depends="init" unless="no.deps"/>
|
||||
<target name="-pre-pre-compile" depends="init,deps-jar">
|
||||
<mkdir dir="${build.classes.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-compile">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile" if="have.sources">
|
||||
<j2seproject3:javac/>
|
||||
<copy todir="${build.classes.dir}">
|
||||
<fileset dir="${src.dir}" excludes="${build.classes.excludes}"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project."/>
|
||||
<target name="-pre-compile-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile-single" depends="init,deps-jar,-pre-pre-compile">
|
||||
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
|
||||
<j2seproject3:javac>
|
||||
<customize>
|
||||
<patternset includes="${javac.includes}"/>
|
||||
</customize>
|
||||
</j2seproject3:javac>
|
||||
</target>
|
||||
<target name="-post-compile-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile-single" depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single"/>
|
||||
<!--
|
||||
====================
|
||||
JAR BUILDING SECTION
|
||||
====================
|
||||
-->
|
||||
<target name="-pre-pre-jar" depends="init">
|
||||
<dirname property="dist.jar.dir" file="${dist.jar}"/>
|
||||
<mkdir dir="${dist.jar.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-jar">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-jar-without-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" unless="manifest.available">
|
||||
<j2seproject1:jar/>
|
||||
</target>
|
||||
<target name="-do-jar-with-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" unless="manifest.available+main.class">
|
||||
<j2seproject1:jar manifest="${manifest.file}"/>
|
||||
</target>
|
||||
<target name="-do-jar-with-mainclass" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" unless="manifest.available+main.class+mkdist.available">
|
||||
<j2seproject1:jar manifest="${manifest.file}">
|
||||
<j2seproject1:manifest>
|
||||
<j2seproject1:attribute name="Main-Class" value="${main.class}"/>
|
||||
</j2seproject1:manifest>
|
||||
</j2seproject1:jar>
|
||||
<echo>To run this application from the command line without Ant, try:</echo>
|
||||
<property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
|
||||
<property name="dist.jar.resolved" location="${dist.jar}"/>
|
||||
<pathconvert property="run.classpath.with.dist.jar">
|
||||
<path path="${run.classpath}"/>
|
||||
<map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
|
||||
</pathconvert>
|
||||
<echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
|
||||
</target>
|
||||
<target name="-do-jar-with-libraries" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available">
|
||||
<property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
|
||||
<pathconvert property="run.classpath.without.build.classes.dir">
|
||||
<path path="${run.classpath}"/>
|
||||
<map from="${build.classes.dir.resolved}" to=""/>
|
||||
</pathconvert>
|
||||
<pathconvert property="jar.classpath" pathsep=" ">
|
||||
<path path="${run.classpath.without.build.classes.dir}"/>
|
||||
<chainedmapper>
|
||||
<flattenmapper/>
|
||||
<globmapper from="*" to="lib/*"/>
|
||||
</chainedmapper>
|
||||
</pathconvert>
|
||||
<taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" name="copylibs" classpath="${libs.CopyLibs.classpath}"/>
|
||||
<copylibs manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}" jarfile="${dist.jar}" compress="${jar.compress}">
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main.class}"/>
|
||||
<attribute name="Class-Path" value="${jar.classpath}"/>
|
||||
</manifest>
|
||||
</copylibs>
|
||||
<echo>To run this application from the command line without Ant, try:</echo>
|
||||
<property name="dist.jar.resolved" location="${dist.jar}"/>
|
||||
<echo>java -jar "${dist.jar.resolved}"</echo>
|
||||
</target>
|
||||
<target name="-post-jar">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="jar" depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR."/>
|
||||
<!--
|
||||
=================
|
||||
EXECUTION SECTION
|
||||
=================
|
||||
-->
|
||||
<target name="run" depends="init,compile" description="Run a main class.">
|
||||
<j2seproject1:java>
|
||||
<customize>
|
||||
<arg line="${application.args}"/>
|
||||
</customize>
|
||||
</j2seproject1:java>
|
||||
</target>
|
||||
<target name="run-single" depends="init,compile-single">
|
||||
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>
|
||||
<j2seproject1:java classname="${run.class}"/>
|
||||
</target>
|
||||
<!--
|
||||
=================
|
||||
DEBUGGING SECTION
|
||||
=================
|
||||
-->
|
||||
<target name="-debug-start-debugger" if="netbeans.home" depends="init">
|
||||
<j2seproject1:nbjpdastart name="${debug.class}"/>
|
||||
</target>
|
||||
<target name="-debug-start-debuggee" depends="init,compile">
|
||||
<j2seproject3:debug>
|
||||
<customize>
|
||||
<arg line="${application.args}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target name="debug" if="netbeans.home" depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE."/>
|
||||
<target name="-debug-start-debugger-stepinto" if="netbeans.home" depends="init">
|
||||
<j2seproject1:nbjpdastart stopclassname="${main.class}"/>
|
||||
</target>
|
||||
<target name="debug-stepinto" if="netbeans.home" depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee"/>
|
||||
<target name="-debug-start-debuggee-single" if="netbeans.home" depends="init,compile-single">
|
||||
<fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
|
||||
<j2seproject3:debug classname="${debug.class}"/>
|
||||
</target>
|
||||
<target name="debug-single" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single"/>
|
||||
<target name="-pre-debug-fix" depends="init">
|
||||
<fail unless="fix.includes">Must set fix.includes</fail>
|
||||
<property name="javac.includes" value="${fix.includes}.java"/>
|
||||
</target>
|
||||
<target name="-do-debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,compile-single">
|
||||
<j2seproject1:nbjpdareload/>
|
||||
</target>
|
||||
<target name="debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix"/>
|
||||
<!--
|
||||
===============
|
||||
JAVADOC SECTION
|
||||
===============
|
||||
-->
|
||||
<target name="-javadoc-build" depends="init">
|
||||
<mkdir dir="${dist.javadoc.dir}"/>
|
||||
<javadoc destdir="${dist.javadoc.dir}" source="${javac.source}" notree="${javadoc.notree}" use="${javadoc.use}" nonavbar="${javadoc.nonavbar}" noindex="${javadoc.noindex}" splitindex="${javadoc.splitindex}" author="${javadoc.author}" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}" private="${javadoc.private}" additionalparam="${javadoc.additionalparam}" failonerror="true" useexternalfile="true">
|
||||
<classpath>
|
||||
<path path="${javac.classpath}"/>
|
||||
</classpath>
|
||||
<sourcepath>
|
||||
<pathelement location="${src.dir}"/>
|
||||
</sourcepath>
|
||||
<packageset dir="${src.dir}" includes="*/**"/>
|
||||
<fileset dir="${src.dir}" includes="*.java"/>
|
||||
</javadoc>
|
||||
</target>
|
||||
<target name="-javadoc-browse" if="netbeans.home" unless="no.javadoc.preview" depends="init,-javadoc-build">
|
||||
<nbbrowse file="${dist.javadoc.dir}/index.html"/>
|
||||
</target>
|
||||
<target name="javadoc" depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc."/>
|
||||
<!--
|
||||
=========================
|
||||
JUNIT COMPILATION SECTION
|
||||
=========================
|
||||
-->
|
||||
<target name="-pre-pre-compile-test" if="have.tests" depends="init,compile">
|
||||
<mkdir dir="${build.test.classes.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-compile-test">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile-test" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test">
|
||||
<j2seproject3:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}"/>
|
||||
<copy todir="${build.test.classes.dir}">
|
||||
<fileset dir="${test.src.dir}" excludes="**/*.java"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile-test">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile-test" depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test"/>
|
||||
<target name="-pre-compile-test-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile-test-single" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single">
|
||||
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
|
||||
<j2seproject3:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}">
|
||||
<customize>
|
||||
<patternset includes="${javac.includes}"/>
|
||||
</customize>
|
||||
</j2seproject3:javac>
|
||||
<copy todir="${build.test.classes.dir}">
|
||||
<fileset dir="${test.src.dir}" excludes="**/*.java"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile-test-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile-test-single" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single"/>
|
||||
<!--
|
||||
=======================
|
||||
JUNIT EXECUTION SECTION
|
||||
=======================
|
||||
-->
|
||||
<target name="-pre-test-run" if="have.tests" depends="init">
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
</target>
|
||||
<target name="-do-test-run" if="have.tests" depends="init,compile-test,-pre-test-run">
|
||||
<j2seproject3:junit/>
|
||||
</target>
|
||||
<target name="-post-test-run" if="have.tests" depends="init,compile-test,-pre-test-run,-do-test-run">
|
||||
<fail if="tests.failed">Some tests failed; see details above.</fail>
|
||||
</target>
|
||||
<target name="test-report" if="have.tests" depends="init"/>
|
||||
<target name="-test-browse" if="netbeans.home+have.tests" depends="init"/>
|
||||
<target name="test" depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests."/>
|
||||
<target name="-pre-test-run-single" if="have.tests" depends="init">
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
</target>
|
||||
<target name="-do-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single">
|
||||
<fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
|
||||
<j2seproject3:junit includes="${test.includes}"/>
|
||||
</target>
|
||||
<target name="-post-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single">
|
||||
<fail if="tests.failed">Some tests failed; see details above.</fail>
|
||||
</target>
|
||||
<target name="test-single" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test."/>
|
||||
<!--
|
||||
=======================
|
||||
JUNIT DEBUGGING SECTION
|
||||
=======================
|
||||
-->
|
||||
<target name="-debug-start-debuggee-test" if="have.tests" depends="init,compile-test">
|
||||
<fail unless="test.class">Must select one file in the IDE or set test.class</fail>
|
||||
<j2seproject3:debug classname="junit.textui.TestRunner" classpath="${debug.test.classpath}">
|
||||
<customize>
|
||||
<arg line="${test.class}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target name="-debug-start-debugger-test" if="netbeans.home+have.tests" depends="init,compile-test">
|
||||
<j2seproject1:nbjpdastart name="${test.class}" classpath="${debug.test.classpath}"/>
|
||||
</target>
|
||||
<target name="debug-test" depends="init,compile-test,-debug-start-debugger-test,-debug-start-debuggee-test"/>
|
||||
<target name="-do-debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,compile-test-single">
|
||||
<j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
|
||||
</target>
|
||||
<target name="debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix-test"/>
|
||||
<!--
|
||||
=========================
|
||||
APPLET EXECUTION SECTION
|
||||
=========================
|
||||
-->
|
||||
<target name="run-applet" depends="init,compile-single">
|
||||
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
|
||||
<j2seproject1:java classname="sun.applet.AppletViewer">
|
||||
<customize>
|
||||
<arg value="${applet.url}"/>
|
||||
</customize>
|
||||
</j2seproject1:java>
|
||||
</target>
|
||||
<!--
|
||||
=========================
|
||||
APPLET DEBUGGING SECTION
|
||||
=========================
|
||||
-->
|
||||
<target name="-debug-start-debuggee-applet" if="netbeans.home" depends="init,compile-single">
|
||||
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
|
||||
<j2seproject3:debug classname="sun.applet.AppletViewer">
|
||||
<customize>
|
||||
<arg value="${applet.url}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target name="debug-applet" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet"/>
|
||||
<!--
|
||||
===============
|
||||
CLEANUP SECTION
|
||||
===============
|
||||
-->
|
||||
<target name="deps-clean" depends="init" unless="no.deps"/>
|
||||
<target name="-do-clean" depends="init">
|
||||
<delete dir="${build.dir}"/>
|
||||
<delete dir="${dist.dir}"/>
|
||||
</target>
|
||||
<target name="-post-clean">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="clean" depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products."/>
|
||||
</project>
|
||||
@@ -1,59 +0,0 @@
|
||||
application.args=
|
||||
build.classes.dir=${build.dir}/classes
|
||||
build.classes.excludes=**/*.java
|
||||
# This directory is removed when the project is cleaned:
|
||||
build.dir=build
|
||||
build.generated.dir=${build.dir}/generated
|
||||
# Only compile against the classpath explicitly listed here:
|
||||
build.sysclasspath=ignore
|
||||
build.test.classes.dir=${build.dir}/test/classes
|
||||
build.test.results.dir=${build.dir}/test/results
|
||||
debug.classpath=\
|
||||
${run.classpath}
|
||||
debug.test.classpath=\
|
||||
${run.test.classpath}
|
||||
# This directory is removed when the project is cleaned:
|
||||
dist.dir=dist
|
||||
dist.jar=${dist.dir}/platform.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
file.reference.jna.jar=../../build/jna.jar
|
||||
libs.junit.classpath=../../lib/junit.jar
|
||||
jar.compress=false
|
||||
javac.classpath=\
|
||||
${file.reference.jna.jar};
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
javac.source=1.5
|
||||
javac.target=1.5
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}:\
|
||||
${libs.junit.classpath}
|
||||
javadoc.additionalparam=
|
||||
javadoc.author=false
|
||||
javadoc.encoding=
|
||||
javadoc.noindex=false
|
||||
javadoc.nonavbar=false
|
||||
javadoc.notree=false
|
||||
javadoc.private=false
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
main.class=
|
||||
manifest.file=manifest.mf
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
platform.active=default_platform
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
# Space-separated list of JVM arguments used when running the project
|
||||
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
|
||||
# or test-sys-prop.name=value to set system properties for unit tests):
|
||||
run.jvmargs=
|
||||
run.test.classpath=\
|
||||
${javac.test.classpath}:\
|
||||
${build.test.classes.dir}
|
||||
src.dir=src
|
||||
test.src.dir=test
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>org.netbeans.modules.java.j2seproject</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<name>platform</name>
|
||||
<minimum-ant-version>1.6.5</minimum-ant-version>
|
||||
<source-roots>
|
||||
<root id="src.dir"/>
|
||||
</source-roots>
|
||||
<test-roots>
|
||||
<root id="test.src.dir"/>
|
||||
</test-roots>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
||||
@@ -1,135 +0,0 @@
|
||||
/* 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.platform;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EventObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sun.jna.platform.win32.W32FileMonitor;
|
||||
|
||||
/** Provides notification of file system changes. Actual capabilities may
|
||||
* vary slightly by platform.
|
||||
* <p>
|
||||
* Watched files which are removed from the filesystem are no longer watched.
|
||||
* @author twall
|
||||
*/
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class FileMonitor {
|
||||
|
||||
public static final int FILE_CREATED = 0x1;
|
||||
public static final int FILE_DELETED = 0x2;
|
||||
public static final int FILE_MODIFIED = 0x4;
|
||||
public static final int FILE_ACCESSED = 0x8;
|
||||
public static final int FILE_NAME_CHANGED_OLD = 0x10;
|
||||
public static final int FILE_NAME_CHANGED_NEW = 0x20;
|
||||
public static final int FILE_RENAMED = FILE_NAME_CHANGED_OLD|FILE_NAME_CHANGED_NEW;
|
||||
public static final int FILE_SIZE_CHANGED = 0x40;
|
||||
public static final int FILE_ATTRIBUTES_CHANGED = 0x80;
|
||||
public static final int FILE_SECURITY_CHANGED = 0x100;
|
||||
public static final int FILE_ANY = 0x1FF;
|
||||
|
||||
public interface FileListener {
|
||||
public void fileChanged(FileEvent e);
|
||||
}
|
||||
|
||||
public class FileEvent extends EventObject {
|
||||
private final File file;
|
||||
private final int type;
|
||||
public FileEvent(File file, int type) {
|
||||
super(FileMonitor.this);
|
||||
this.file = file;
|
||||
this.type = type;
|
||||
}
|
||||
public File getFile() { return file; }
|
||||
public int getType() { return type; }
|
||||
public String toString() {
|
||||
return "FileEvent: " + file + ":" + type;
|
||||
}
|
||||
}
|
||||
|
||||
private final Map<File, Integer> watched = new HashMap<File, Integer>();
|
||||
private List<FileListener> listeners = new ArrayList<FileListener>();
|
||||
|
||||
protected abstract void watch(File file, int mask, boolean recursive) throws IOException ;
|
||||
protected abstract void unwatch(File file);
|
||||
public abstract void dispose();
|
||||
|
||||
public void addWatch(File dir) throws IOException {
|
||||
addWatch(dir, FILE_ANY);
|
||||
}
|
||||
|
||||
public void addWatch(File dir, int mask) throws IOException {
|
||||
addWatch(dir, mask, dir.isDirectory());
|
||||
}
|
||||
|
||||
public void addWatch(File dir, int mask, boolean recursive) throws IOException {
|
||||
watched.put(dir, new Integer(mask));
|
||||
watch(dir, mask, recursive);
|
||||
}
|
||||
|
||||
public void removeWatch(File file) {
|
||||
if (watched.remove(file) != null) {
|
||||
unwatch(file);
|
||||
}
|
||||
}
|
||||
|
||||
protected void notify(FileEvent e) {
|
||||
for (FileListener listener : listeners) {
|
||||
listener.fileChanged(e);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void addFileListener(FileListener listener) {
|
||||
List<FileListener> list = new ArrayList<FileListener>(listeners);
|
||||
list.add(listener);
|
||||
listeners = list;
|
||||
}
|
||||
|
||||
public synchronized void removeFileListener(FileListener x) {
|
||||
List<FileListener> list = new ArrayList<FileListener>(listeners);
|
||||
list.remove(x);
|
||||
listeners = list;
|
||||
}
|
||||
|
||||
protected void finalize() {
|
||||
for (File watchedFile : watched.keySet()) {
|
||||
removeWatch(watchedFile);
|
||||
}
|
||||
|
||||
dispose();
|
||||
}
|
||||
|
||||
/** Canonical lazy loading of a singleton. */
|
||||
private static class Holder {
|
||||
public static final FileMonitor INSTANCE;
|
||||
static {
|
||||
String os = System.getProperty("os.name");
|
||||
if (os.startsWith("Windows")) {
|
||||
INSTANCE = new W32FileMonitor();
|
||||
}
|
||||
else {
|
||||
throw new Error("FileMonitor not implemented for " + os);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static FileMonitor getInstance() {
|
||||
return Holder.INSTANCE;
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
/* 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.platform;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.platform.mac.MacFileUtils;
|
||||
import com.sun.jna.platform.win32.W32FileUtils;
|
||||
|
||||
/** Miscellaneous file utils not provided for by Java. */
|
||||
public abstract class FileUtils {
|
||||
|
||||
public boolean hasTrash() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Move the given file to the system trash, if one is available.
|
||||
Throws an exception on failure.
|
||||
*/
|
||||
public abstract void moveToTrash(File[] files) throws IOException;
|
||||
|
||||
/** Canonical lazy loading of a singleton. */
|
||||
private static class Holder {
|
||||
public static final FileUtils INSTANCE;
|
||||
static {
|
||||
String os = System.getProperty("os.name");
|
||||
if (os.startsWith("Windows")) {
|
||||
INSTANCE = new W32FileUtils();
|
||||
}
|
||||
else if (os.startsWith("Mac")){
|
||||
INSTANCE = new MacFileUtils();
|
||||
}
|
||||
else {
|
||||
INSTANCE = new DefaultFileUtils();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static FileUtils getInstance() {
|
||||
return Holder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class DefaultFileUtils extends FileUtils {
|
||||
|
||||
private File getTrashDirectory() {
|
||||
// very simple implementation. should take care of renaming when
|
||||
// a file already exists, or any other platform-specific behavior
|
||||
File home = new File(System.getProperty("user.home"));
|
||||
File trash = new File(home, ".Trash");
|
||||
if (!trash.exists()) {
|
||||
trash = new File(home, "Trash");
|
||||
if (!trash.exists()) {
|
||||
File desktop = new File(home, "Desktop");
|
||||
if (desktop.exists()) {
|
||||
trash = new File(desktop, ".Trash");
|
||||
if (!trash.exists()) {
|
||||
trash = new File(desktop, "Trash");
|
||||
if (!trash.exists()) {
|
||||
trash = new File(System.getProperty("fileutils.trash", "Trash"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return trash;
|
||||
}
|
||||
|
||||
public boolean hasTrash() {
|
||||
return getTrashDirectory().exists();
|
||||
}
|
||||
|
||||
/** The default implementation attempts to move the file to
|
||||
* the desktop "Trash" folder.
|
||||
*/
|
||||
public void moveToTrash(File[] files) throws IOException {
|
||||
File trash = getTrashDirectory();
|
||||
if (!trash.exists()) {
|
||||
throw new IOException("No trash location found (define fileutils.trash to be the path to the trash)");
|
||||
}
|
||||
List<File> failed = new ArrayList<File>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
/* 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.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform;
|
||||
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.HeadlessException;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import com.sun.jna.Platform;
|
||||
import com.sun.jna.platform.unix.X11;
|
||||
import com.sun.jna.platform.unix.X11.Display;
|
||||
import com.sun.jna.platform.win32.User32;
|
||||
import com.sun.jna.platform.win32.WinUser;
|
||||
|
||||
/** Provide access to the local keyboard state. Note that this is meaningless
|
||||
* on a headless system and some VNC setups.
|
||||
*
|
||||
* @author twall
|
||||
*/
|
||||
// TODO: key clicks
|
||||
// TODO: auto-repeat
|
||||
// TODO: keyboard bell
|
||||
// TODO: led state
|
||||
public class KeyboardUtils {
|
||||
static final NativeKeyboardUtils INSTANCE;
|
||||
static {
|
||||
if (GraphicsEnvironment.isHeadless()) {
|
||||
throw new HeadlessException("KeyboardUtils requires a keyboard");
|
||||
}
|
||||
if (Platform.isWindows()) {
|
||||
INSTANCE = new W32KeyboardUtils();
|
||||
}
|
||||
else if (Platform.isMac()) {
|
||||
INSTANCE = new MacKeyboardUtils();
|
||||
throw new UnsupportedOperationException("No support (yet) for "
|
||||
+ System.getProperty("os.name"));
|
||||
}
|
||||
else {
|
||||
INSTANCE = new X11KeyboardUtils();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isPressed(int keycode, int location) {
|
||||
return INSTANCE.isPressed(keycode, location);
|
||||
}
|
||||
public static boolean isPressed(int keycode) {
|
||||
return INSTANCE.isPressed(keycode);
|
||||
}
|
||||
|
||||
private static abstract class NativeKeyboardUtils {
|
||||
public abstract boolean isPressed(int keycode, int location);
|
||||
public boolean isPressed(int keycode) {
|
||||
return isPressed(keycode, KeyEvent.KEY_LOCATION_UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
private static class W32KeyboardUtils extends NativeKeyboardUtils {
|
||||
private int toNative(int code, int loc) {
|
||||
if ((code >= KeyEvent.VK_A && code <= KeyEvent.VK_Z)
|
||||
|| (code >= KeyEvent.VK_0 && code <= KeyEvent.VK_9)) {
|
||||
return code;
|
||||
}
|
||||
if (code == KeyEvent.VK_SHIFT) {
|
||||
if ((loc & KeyEvent.KEY_LOCATION_RIGHT) != 0) {
|
||||
return WinUser.VK_RSHIFT;
|
||||
}
|
||||
if ((loc & KeyEvent.KEY_LOCATION_LEFT) != 0) {
|
||||
return WinUser.VK_LSHIFT;
|
||||
}
|
||||
return WinUser.VK_SHIFT;
|
||||
}
|
||||
if (code == KeyEvent.VK_CONTROL) {
|
||||
if ((loc & KeyEvent.KEY_LOCATION_RIGHT) != 0) {
|
||||
return WinUser.VK_RCONTROL;
|
||||
}
|
||||
if ((loc & KeyEvent.KEY_LOCATION_LEFT) != 0) {
|
||||
return WinUser.VK_LCONTROL;
|
||||
}
|
||||
return WinUser.VK_CONTROL;
|
||||
}
|
||||
if (code == KeyEvent.VK_ALT) {
|
||||
if ((loc & KeyEvent.KEY_LOCATION_RIGHT) != 0) {
|
||||
return WinUser.VK_RMENU;
|
||||
}
|
||||
if ((loc & KeyEvent.KEY_LOCATION_LEFT) != 0) {
|
||||
return WinUser.VK_LMENU;
|
||||
}
|
||||
return WinUser.VK_MENU;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public boolean isPressed(int keycode, int location) {
|
||||
User32 lib = User32.INSTANCE;
|
||||
return (lib.GetAsyncKeyState(toNative(keycode, location)) & 0x8000) != 0;
|
||||
}
|
||||
}
|
||||
private static class MacKeyboardUtils extends NativeKeyboardUtils {
|
||||
public boolean isPressed(int keycode, int location) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private static class X11KeyboardUtils extends NativeKeyboardUtils {
|
||||
// TODO: fully map from X11 keycodes to java keycodes
|
||||
// this is a minimal implementation
|
||||
private int toKeySym(int code, int location) {
|
||||
if (code >= KeyEvent.VK_A && code <= KeyEvent.VK_Z)
|
||||
return X11.XK_a + (code - KeyEvent.VK_A);
|
||||
if (code >= KeyEvent.VK_0 && code <= KeyEvent.VK_9)
|
||||
return X11.XK_0 + (code - KeyEvent.VK_0);
|
||||
if (code == KeyEvent.VK_SHIFT) {
|
||||
if ((location & KeyEvent.KEY_LOCATION_RIGHT) != 0)
|
||||
return X11.XK_Shift_R;
|
||||
return X11.XK_Shift_L;
|
||||
}
|
||||
if (code == KeyEvent.VK_CONTROL) {
|
||||
if ((location & KeyEvent.KEY_LOCATION_RIGHT) != 0)
|
||||
return X11.XK_Control_R;
|
||||
return X11.XK_Control_L;
|
||||
}
|
||||
if (code == KeyEvent.VK_ALT) {
|
||||
if ((location & KeyEvent.KEY_LOCATION_RIGHT) != 0)
|
||||
return X11.XK_Alt_R;
|
||||
return X11.XK_Alt_L;
|
||||
}
|
||||
if (code == KeyEvent.VK_META) {
|
||||
if ((location & KeyEvent.KEY_LOCATION_RIGHT) != 0)
|
||||
return X11.XK_Meta_R;
|
||||
return X11.XK_Meta_L;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public boolean isPressed(int keycode, int location) {
|
||||
X11 lib = X11.INSTANCE;
|
||||
Display dpy = lib.XOpenDisplay(null);
|
||||
if (dpy == null) {
|
||||
throw new Error("Can't open X Display");
|
||||
}
|
||||
try {
|
||||
byte[] keys = new byte[32];
|
||||
// Ignore the return value
|
||||
lib.XQueryKeymap(dpy, keys);
|
||||
int keysym = toKeySym(keycode, location);
|
||||
for (int code=5;code < 256;code++) {
|
||||
int idx = code / 8;
|
||||
int shift = code % 8;
|
||||
if ((keys[idx] & (1 << shift)) != 0) {
|
||||
int sym = lib.XKeycodeToKeysym(dpy, (byte)code, 0).intValue();
|
||||
if (sym == keysym)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
lib.XCloseDisplay(dpy);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,258 +0,0 @@
|
||||
/* Copyright (c) 2007 Olivier Chafik, All Rights Reserved
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.awt.image.DataBufferByte;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.MultiPixelPackedSampleModel;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.SampleModel;
|
||||
import java.awt.image.SinglePixelPackedSampleModel;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* Methods that are useful to decompose a raster into a set of rectangles.
|
||||
* An occupied pixel has two possible meanings, depending on the raster :
|
||||
* <ul>
|
||||
* <li>if the raster has an alpha layer, occupied means with alpha not null</li>
|
||||
* <li>if the raster doesn't have any alpha layer, occupied means not completely black</li>
|
||||
* </ul>
|
||||
* @author Olivier Chafik
|
||||
*/
|
||||
public class RasterRangesUtils {
|
||||
/// Masks used to isolate the current column in a set of 8 binary columns packed in a byte
|
||||
private static final int[] subColMasks = new int[] {
|
||||
0x0080, 0x0040, 0x0020, 0x0010,
|
||||
0x0008, 0x0004, 0x0002, 0x0001
|
||||
};
|
||||
|
||||
private static final Comparator<Object> COMPARATOR = new Comparator<Object>() {
|
||||
public int compare(Object o1, Object o2) {
|
||||
return ((Rectangle)o1).x - ((Rectangle)o2).x;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Abstraction of a sink for ranges.
|
||||
*/
|
||||
public static interface RangesOutput {
|
||||
/**
|
||||
* Output a rectangular range.
|
||||
* @param x x coordinate of the top-left corner of the range
|
||||
* @param y y coordinate of the top-left corner of the range
|
||||
* @param w width of the range
|
||||
* @param h height of the range
|
||||
* @return true if the output succeeded, false otherwise
|
||||
*/
|
||||
boolean outputRange(int x, int y, int w, int h);
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs ranges of occupied pixels.
|
||||
* In a raster that has an alpha layer, a pixel is occupied if its alpha value is not null.
|
||||
* In a raster without alpha layer, a pixel is occupied if it is not completely black.
|
||||
* @param raster image to be segmented in non black or non-transparent ranges
|
||||
* @param out destination of the non null ranges
|
||||
* @return true if the output succeeded, false otherwise
|
||||
*/
|
||||
public static boolean outputOccupiedRanges(Raster raster, RangesOutput out) {
|
||||
Rectangle bounds = raster.getBounds();
|
||||
SampleModel sampleModel = raster.getSampleModel();
|
||||
boolean hasAlpha = sampleModel.getNumBands() == 4;
|
||||
|
||||
// Try to use the underlying data array directly for a few common raster formats
|
||||
if (raster.getParent() == null && bounds.x == 0 && bounds.y == 0) {
|
||||
// No support for subraster (as obtained with Image.getSubimage(...))
|
||||
|
||||
DataBuffer data = raster.getDataBuffer();
|
||||
if (data.getNumBanks() == 1) {
|
||||
// There is always a single bank for all BufferedImage types, except maybe TYPE_CUSTOM
|
||||
|
||||
if (sampleModel instanceof MultiPixelPackedSampleModel) {
|
||||
MultiPixelPackedSampleModel packedSampleModel = (MultiPixelPackedSampleModel)sampleModel;
|
||||
if (packedSampleModel.getPixelBitStride() == 1) {
|
||||
// TYPE_BYTE_BINARY
|
||||
return outputOccupiedRangesOfBinaryPixels(((DataBufferByte)data).getData(), bounds.width, bounds.height, out);
|
||||
}
|
||||
} else if (sampleModel instanceof SinglePixelPackedSampleModel) {
|
||||
if (sampleModel.getDataType() == DataBuffer.TYPE_INT) {
|
||||
// TYPE_INT_ARGB, TYPE_INT_ARGB_PRE, TYPE_INT_BGR or TYPE_INT_RGB
|
||||
return outputOccupiedRanges(((DataBufferInt)data).getData(), bounds.width, bounds.height, hasAlpha ? 0xff000000 : 0xffffff, out);
|
||||
}
|
||||
// TODO could easily handle cases of TYPE_USHORT_GRAY and TYPE_BYTE_GRAY.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback behaviour : copy pixels of raster
|
||||
int[] pixels = raster.getPixels(0, 0, bounds.width, bounds.height, (int[])null);
|
||||
return outputOccupiedRanges(pixels, bounds.width, bounds.height, hasAlpha ? 0xff000000 : 0xffffff, out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the non-null values of a binary image as ranges of contiguous values.
|
||||
* @param binaryBits byte-packed binary bits of an image
|
||||
* @param w width of the image (in pixels)
|
||||
* @param h height of the image
|
||||
* @param out
|
||||
* @return true if the output succeeded, false otherwise
|
||||
*/
|
||||
public static boolean outputOccupiedRangesOfBinaryPixels(byte[] binaryBits, int w, int h, RangesOutput out) {
|
||||
Set<Rectangle> rects = new HashSet<Rectangle>();
|
||||
Set<Rectangle> prevLine = Collections.EMPTY_SET;
|
||||
int scanlineBytes = binaryBits.length / h;
|
||||
for (int row = 0; row < h; row++) {
|
||||
Set<Rectangle> curLine = new TreeSet<Rectangle>(COMPARATOR);
|
||||
int rowOffsetBytes = row * scanlineBytes;
|
||||
int startCol = -1;
|
||||
// Look at each batch of 8 columns in this row
|
||||
for (int byteCol = 0; byteCol < scanlineBytes; byteCol++) {
|
||||
int firstByteCol = byteCol << 3;
|
||||
byte byteColBits = binaryBits[rowOffsetBytes + byteCol];
|
||||
if (byteColBits == 0) {
|
||||
// all 8 bits are zeroes
|
||||
if (startCol >= 0) {
|
||||
// end of current region
|
||||
curLine.add(new Rectangle(startCol, row, firstByteCol - startCol, 1));
|
||||
startCol = -1;
|
||||
}
|
||||
} else if (byteColBits == 0xff) {
|
||||
// all 8 bits are ones
|
||||
if (startCol < 0) {
|
||||
// start of new region
|
||||
startCol = firstByteCol;
|
||||
}
|
||||
} else {
|
||||
// mixed case : some bits are ones, others are zeroes
|
||||
for (int subCol = 0; subCol < 8; subCol++) {
|
||||
int col = firstByteCol | subCol;
|
||||
if ((byteColBits & subColMasks[subCol]) != 0) {
|
||||
if (startCol < 0) {
|
||||
// start of new region
|
||||
startCol = col;
|
||||
}
|
||||
} else {
|
||||
if (startCol >= 0) {
|
||||
// end of current region
|
||||
curLine.add(new Rectangle(startCol, row, col - startCol, 1));
|
||||
startCol = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (startCol >= 0) {
|
||||
// end of last region
|
||||
curLine.add(new Rectangle(startCol, row, w - startCol, 1));
|
||||
}
|
||||
Set<Rectangle> unmerged = mergeRects(prevLine, curLine);
|
||||
rects.addAll(unmerged);
|
||||
prevLine = curLine;
|
||||
}
|
||||
// Add anything left over
|
||||
rects.addAll(prevLine);
|
||||
for (Iterator<Rectangle> i=rects.iterator();i.hasNext();) {
|
||||
Rectangle r = i.next();
|
||||
if (!out.outputRange(r.x, r.y, r.width, r.height)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the occupied values of an integer-pixels image as ranges of contiguous values.
|
||||
* A pixel is considered occupied if the bitwise AND of its integer value with the provided occupationMask is not null.
|
||||
* @param pixels integer values of the pixels of an image
|
||||
* @param w width of the image (in pixels)
|
||||
* @param h height of the image
|
||||
* @param occupationMask mask used to select which bits are used in a pixel to check its occupied status. 0xff000000 would only take the alpha layer into account, for instance.
|
||||
* @param out where to output all the contiguous ranges of non occupied pixels
|
||||
* @return true if the output succeeded, false otherwise
|
||||
*/
|
||||
public static boolean outputOccupiedRanges(int[] pixels, int w, int h, int occupationMask, RangesOutput out) {
|
||||
Set<Rectangle> rects = new HashSet<Rectangle>();
|
||||
Set<Rectangle> prevLine = Collections.EMPTY_SET;
|
||||
for (int row = 0; row < h; row++) {
|
||||
Set<Rectangle> curLine = new TreeSet<Rectangle>(COMPARATOR);
|
||||
int idxOffset = row * w;
|
||||
int startCol = -1;
|
||||
|
||||
for (int col = 0; col < w; col++) {
|
||||
if ((pixels[idxOffset + col] & occupationMask) != 0) {
|
||||
if (startCol < 0) {
|
||||
startCol = col;
|
||||
}
|
||||
} else {
|
||||
if (startCol >= 0) {
|
||||
// end of current region
|
||||
curLine.add(new Rectangle(startCol, row, col-startCol, 1));
|
||||
startCol = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (startCol >= 0) {
|
||||
// end of last region of current row
|
||||
curLine.add(new Rectangle(startCol, row, w-startCol, 1));
|
||||
}
|
||||
Set<Rectangle> unmerged = mergeRects(prevLine, curLine);
|
||||
rects.addAll(unmerged);
|
||||
prevLine = curLine;
|
||||
}
|
||||
// Add anything left over
|
||||
rects.addAll(prevLine);
|
||||
for (Iterator<Rectangle> i=rects.iterator();i.hasNext();) {
|
||||
Rectangle r = i.next();
|
||||
if (!out.outputRange(r.x, r.y, r.width, r.height)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Set<Rectangle> mergeRects(Set<Rectangle> prev, Set<Rectangle> current) {
|
||||
Set<Rectangle> unmerged = new HashSet<Rectangle>(prev);
|
||||
if (!prev.isEmpty() && !current.isEmpty()) {
|
||||
Rectangle[] pr = prev.toArray(new Rectangle[prev.size()]);
|
||||
Rectangle[] cr = current.toArray(new Rectangle[current.size()]);
|
||||
int ipr = 0;
|
||||
int icr = 0;
|
||||
while (ipr < pr.length && icr < cr.length) {
|
||||
while (cr[icr].x < pr[ipr].x) {
|
||||
if (++icr == cr.length) {
|
||||
return unmerged;
|
||||
}
|
||||
}
|
||||
if (cr[icr].x == pr[ipr].x && cr[icr].width == pr[ipr].width) {
|
||||
unmerged.remove(pr[ipr]);
|
||||
cr[icr].y = pr[ipr].y;
|
||||
cr[icr].height = pr[ipr].height + 1;
|
||||
++icr;
|
||||
}
|
||||
else {
|
||||
++ipr;
|
||||
}
|
||||
}
|
||||
}
|
||||
return unmerged;
|
||||
}
|
||||
|
||||
}
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -1,533 +0,0 @@
|
||||
/* 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.platform.dnd;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Component;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.Transparency;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.dnd.DnDConstants;
|
||||
import java.awt.dnd.DragGestureEvent;
|
||||
import java.awt.dnd.DragGestureListener;
|
||||
import java.awt.dnd.DragSource;
|
||||
import java.awt.dnd.DragSourceContext;
|
||||
import java.awt.dnd.DragSourceDragEvent;
|
||||
import java.awt.dnd.DragSourceDropEvent;
|
||||
import java.awt.dnd.DragSourceEvent;
|
||||
import java.awt.dnd.DragSourceListener;
|
||||
import java.awt.dnd.DragSourceMotionListener;
|
||||
import java.awt.dnd.DropTargetDragEvent;
|
||||
import java.awt.dnd.DropTargetDropEvent;
|
||||
import java.awt.dnd.DropTargetEvent;
|
||||
import java.awt.dnd.InvalidDnDOperationException;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JColorChooser;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.text.JTextComponent;
|
||||
|
||||
/** Provides simplified drag handling for a component.
|
||||
* Usage:<br>
|
||||
* <pre><code>
|
||||
* int actions = DnDConstants.MOVE_OR_COPY;
|
||||
* Component component = ...;
|
||||
* DragHandler handler = new DragHandler(component, actions);
|
||||
* </code></pre>
|
||||
* <ul>
|
||||
* <li>Supports painting an arbitrary {@link Icon} with transparency to
|
||||
* represent the item being dragged (restricted to the {@link java.awt.Window}
|
||||
* of the drag source if the platform doesn't support drag images).
|
||||
* <li>Disallow starting a drag if the user requests an unsupported action.
|
||||
* <li>Adjusts the cursor on drags with no modifier for which the default action
|
||||
* is disallowed but where one or more non-default actions are allowed, e.g. a
|
||||
* drag (with no modifiers) to a target which supports "link" should change the
|
||||
* cursor to "link" (prior to 1.6, the JRE behavior is to display a
|
||||
* "not allowed" cursor, even though the action actually depends on how the
|
||||
* drop target responds).
|
||||
* <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4869264">
|
||||
* The bug</a> is fixed in java 1.6.
|
||||
* <li>Disallow drops to targets if the non-default (user-requested) action
|
||||
* is not supported by the target, e.g. the user requests a "copy" when the
|
||||
* target only supports "move". This is generally the responsibility of the
|
||||
* drop handler, which decides whether or not to accept a drag. The DragHandler
|
||||
* provides static modifier state information since the drop handler doesn't
|
||||
* have access to it.
|
||||
* </ul>
|
||||
* NOTE: Fundamentally, the active action is determined by the drop handler
|
||||
* in {@link DropTargetDragEvent#acceptDrag}, but often client code
|
||||
* simply relies on {@link DropTargetDragEvent#getDropAction}.
|
||||
*/
|
||||
//TODO: separate into the the following drag pieces:
|
||||
// * default cursor changing behavior fix (fixed in jre1.6) (global DSL)
|
||||
// * drag unselected item (fixed in 1.6, flag in 1.5.0.05+) bug not an issue w/DragHandler
|
||||
// * multi-selection drag workaround (if not using swing drag gesture recognizer)
|
||||
// proper multi-selection drag is provided for swing dnd as of 1.4
|
||||
// (use swing drag gesture recognizer if possible?) DSL+mouse listener
|
||||
//TODO: identify overlap with default Swing support + TransferHandler
|
||||
// * TransferHandler doesn't have drop location information (included in 1.6)
|
||||
// * SwingDropTarget allows listeners, so target highlighting is possible
|
||||
|
||||
//NOTE: acceptDrag(int) is simply indicates the drag is accepted; the action
|
||||
// value doesn't get propagated anywhere, it's certainly not communicated to
|
||||
// the drag source
|
||||
//MAYBE: should Transferable/Icon provision be a separate interface
|
||||
//(i.e. TransferHandler)? only if the rest of the drag handler is constant and
|
||||
// only the image needs to change (for standard components, e.g. tree cells,
|
||||
// table cells, etc.)
|
||||
|
||||
public abstract class DragHandler
|
||||
implements DragSourceListener, DragSourceMotionListener, DragGestureListener {
|
||||
|
||||
/** Default maximum size for ghosted images. */
|
||||
public static final Dimension MAX_GHOST_SIZE = new Dimension(250, 250);
|
||||
|
||||
/** Default transparency for ghosting. */
|
||||
public static final float DEFAULT_GHOST_ALPHA = 0.5f;
|
||||
|
||||
/** {@link #getModifiers} returns this value when the current
|
||||
* modifiers state is unknown.
|
||||
*/
|
||||
public static final int UNKNOWN_MODIFIERS = -1;
|
||||
|
||||
/** {@link #getTransferable} returns this value when
|
||||
* the current {@link Transferable} is unknown.
|
||||
*/
|
||||
public static final Transferable UNKNOWN_TRANSFERABLE = null;
|
||||
/** Convenience to reference {@link DnDConstants#ACTION_MOVE}. */
|
||||
protected static final int MOVE = DnDConstants.ACTION_MOVE;
|
||||
/** Convenience to reference {@link DnDConstants#ACTION_COPY}. */
|
||||
protected static final int COPY = DnDConstants.ACTION_COPY;
|
||||
/** Convenience to reference {@link DnDConstants#ACTION_LINK}. */
|
||||
protected static final int LINK = DnDConstants.ACTION_LINK;
|
||||
/** Convenience to reference {@link DnDConstants#ACTION_NONE}. */
|
||||
protected static final int NONE = DnDConstants.ACTION_NONE;
|
||||
|
||||
// TODO: w32 explorer: link=alt or ctrl+shift, copy=ctrl or shift
|
||||
// w32 others: copy=ctrl
|
||||
/** Modifier mask for a user-requested move. */
|
||||
static final int MOVE_MASK = InputEvent.SHIFT_DOWN_MASK;
|
||||
static final boolean OSX =
|
||||
System.getProperty("os.name").toLowerCase().indexOf("mac") != -1;
|
||||
/** Modifier mask for a user-requested copy. */
|
||||
static final int COPY_MASK =
|
||||
OSX ? InputEvent.ALT_DOWN_MASK : InputEvent.CTRL_DOWN_MASK;
|
||||
/** Modifier mask for a user-requested link. */
|
||||
static final int LINK_MASK =
|
||||
OSX ? InputEvent.ALT_DOWN_MASK|InputEvent.META_DOWN_MASK
|
||||
: InputEvent.CTRL_DOWN_MASK|InputEvent.SHIFT_DOWN_MASK;
|
||||
/** Modifier mask for any user-requested action. */
|
||||
static final int KEY_MASK =
|
||||
InputEvent.ALT_DOWN_MASK|InputEvent.META_DOWN_MASK
|
||||
|InputEvent.CTRL_DOWN_MASK|InputEvent.SHIFT_DOWN_MASK
|
||||
|InputEvent.ALT_GRAPH_DOWN_MASK;
|
||||
|
||||
private static int modifiers = UNKNOWN_MODIFIERS;
|
||||
private static Transferable transferable = UNKNOWN_TRANSFERABLE;
|
||||
|
||||
/** Used to communicate modifier state to {@link DropHandler}. Note that
|
||||
* this field will only be accurate when a {@link DragHandler} in
|
||||
* the same VM started the drag. Otherwise, {@link #UNKNOWN_MODIFIERS}
|
||||
* will be returned.
|
||||
*/
|
||||
static int getModifiers() {
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
/** Used to communicate the current {@link Transferable} during a drag,
|
||||
* if available. Work around absence of access to the data when dragging
|
||||
* pre-1.5.
|
||||
*/
|
||||
public static Transferable getTransferable(DropTargetEvent e) {
|
||||
if (e instanceof DropTargetDragEvent) {
|
||||
try {
|
||||
// getTransferable is available during drag only on 1.5+
|
||||
return (Transferable)
|
||||
e.getClass().getMethod("getTransferable", (Class[])null).invoke(e, (Object[])null);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
// Method not available
|
||||
}
|
||||
}
|
||||
else if (e instanceof DropTargetDropEvent) {
|
||||
return ((DropTargetDropEvent)e).getTransferable();
|
||||
}
|
||||
return transferable;
|
||||
}
|
||||
|
||||
private int supportedActions;
|
||||
private boolean fixCursor = true;
|
||||
private Component dragSource;
|
||||
private GhostedDragImage ghost;
|
||||
private Point imageOffset;
|
||||
private Dimension maxGhostSize = MAX_GHOST_SIZE;
|
||||
private float ghostAlpha = DEFAULT_GHOST_ALPHA;
|
||||
|
||||
/** Enable drags from the given component, supporting the actions in
|
||||
* the given action mask.
|
||||
*/
|
||||
protected DragHandler(Component dragSource, int actions) {
|
||||
this.dragSource = dragSource;
|
||||
this.supportedActions = actions;
|
||||
try {
|
||||
String alpha = System.getProperty("DragHandler.alpha");
|
||||
if (alpha != null) {
|
||||
try {
|
||||
ghostAlpha = Float.parseFloat(alpha);
|
||||
}
|
||||
catch(NumberFormatException e) { }
|
||||
}
|
||||
String max = System.getProperty("DragHandler.maxDragImageSize");
|
||||
if (max != null) {
|
||||
String[] size = max.split("x");
|
||||
if (size.length == 2) {
|
||||
try {
|
||||
maxGhostSize = new Dimension(Integer.parseInt(size[0]),
|
||||
Integer.parseInt(size[1]));
|
||||
}
|
||||
catch(NumberFormatException e) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(SecurityException e) { }
|
||||
// Avoid having more than one gesture recognizer active
|
||||
disableSwingDragSupport(dragSource);
|
||||
DragSource src = DragSource.getDefaultDragSource();
|
||||
src.createDefaultDragGestureRecognizer(dragSource, supportedActions, this);
|
||||
}
|
||||
|
||||
private void disableSwingDragSupport(Component comp) {
|
||||
if (comp instanceof JTree) {
|
||||
((JTree)comp).setDragEnabled(false);
|
||||
}
|
||||
else if (comp instanceof JList) {
|
||||
((JList)comp).setDragEnabled(false);
|
||||
}
|
||||
else if (comp instanceof JTable) {
|
||||
((JTable)comp).setDragEnabled(false);
|
||||
}
|
||||
else if (comp instanceof JTextComponent) {
|
||||
((JTextComponent)comp).setDragEnabled(false);
|
||||
}
|
||||
else if (comp instanceof JColorChooser) {
|
||||
((JColorChooser)comp).setDragEnabled(false);
|
||||
}
|
||||
else if (comp instanceof JFileChooser) {
|
||||
((JFileChooser)comp).setDragEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
/** Override to control whether a drag is started. The default
|
||||
* implementation disallows the drag if the user is applying modifiers
|
||||
* and the user-requested action is not supported.
|
||||
*/
|
||||
protected boolean canDrag(DragGestureEvent e) {
|
||||
int mods = e.getTriggerEvent().getModifiersEx() & KEY_MASK;
|
||||
if (mods == MOVE_MASK)
|
||||
return (supportedActions & MOVE) != 0;
|
||||
if (mods == COPY_MASK)
|
||||
return (supportedActions & COPY) != 0;
|
||||
if (mods == LINK_MASK)
|
||||
return (supportedActions & LINK) != 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Update the modifiers hint. */
|
||||
protected void setModifiers(int mods) {
|
||||
modifiers = mods;
|
||||
}
|
||||
/** Override to provide an appropriate {@link Transferable} representing
|
||||
* the data being dragged.
|
||||
*/
|
||||
protected abstract Transferable getTransferable(DragGestureEvent e);
|
||||
|
||||
/** Override this to provide a custom image. The {@link Icon}
|
||||
* returned by this method by default is <code>null</code>, which results
|
||||
* in no drag image.
|
||||
* @param srcOffset set this to be the offset from the drag source
|
||||
* component's upper left corner to the image's upper left corner.
|
||||
* For example, when dragging a row from a list, the offset would be the
|
||||
* row's bounding rectangle's (x,y) coordinate.<p>
|
||||
* The default value is (0,0), so if unchanged, the image is will
|
||||
* use the same origin as the drag source component.
|
||||
*/
|
||||
protected Icon getDragIcon(DragGestureEvent e, Point srcOffset) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Override to perform any decoration of the target at the start of a drag,
|
||||
* if desired.
|
||||
*/
|
||||
protected void dragStarted(DragGestureEvent e) { }
|
||||
|
||||
/** Called when a user drag gesture is recognized. This method is
|
||||
* responsible for initiating the drag operation.
|
||||
*/
|
||||
public void dragGestureRecognized(DragGestureEvent e) {
|
||||
if ((e.getDragAction() & supportedActions) != 0
|
||||
&& canDrag(e)) {
|
||||
setModifiers(e.getTriggerEvent().getModifiersEx() & KEY_MASK);
|
||||
Transferable transferable = getTransferable(e);
|
||||
if (transferable == null)
|
||||
return;
|
||||
try {
|
||||
Point srcOffset = new Point(0, 0);
|
||||
Icon icon = getDragIcon(e, srcOffset);
|
||||
Point origin = e.getDragOrigin();
|
||||
// offset of the image origin from the cursor
|
||||
imageOffset = new Point(srcOffset.x - origin.x,
|
||||
srcOffset.y - origin.y);
|
||||
Icon dragIcon = scaleDragIcon(icon, imageOffset);
|
||||
Cursor cursor = null;
|
||||
if (dragIcon != null && DragSource.isDragImageSupported()) {
|
||||
GraphicsConfiguration gc = e.getComponent().getGraphicsConfiguration();
|
||||
e.startDrag(cursor, createDragImage(gc, dragIcon),
|
||||
imageOffset, transferable, this);
|
||||
}
|
||||
else {
|
||||
if (dragIcon != null) {
|
||||
Point screen = dragSource.getLocationOnScreen();
|
||||
screen.translate(origin.x, origin.y);
|
||||
Point cursorOffset = new Point(-imageOffset.x, -imageOffset.y);
|
||||
ghost = new GhostedDragImage(dragSource, dragIcon,
|
||||
getImageLocation(screen), cursorOffset);
|
||||
ghost.setAlpha(ghostAlpha);
|
||||
}
|
||||
e.startDrag(cursor, transferable, this);
|
||||
}
|
||||
dragStarted(e);
|
||||
moved = false;
|
||||
e.getDragSource().addDragSourceMotionListener(this);
|
||||
DragHandler.transferable = transferable;
|
||||
}
|
||||
catch (InvalidDnDOperationException ex) {
|
||||
if (ghost != null) {
|
||||
ghost.dispose();
|
||||
ghost = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Reduce the size of the given drag icon, if appropriate. When using
|
||||
* a smaller drag icon, we also need to adjust the cursor offset within
|
||||
* the icon.
|
||||
*/
|
||||
protected Icon scaleDragIcon(Icon icon, Point imageOffset) {
|
||||
/*
|
||||
if (icon != null && maxGhostSize != null) {
|
||||
if (icon.getIconWidth() > maxGhostSize.width
|
||||
|| icon.getIconHeight() > maxGhostSize.height) {
|
||||
Icon scaled = new ScaledIcon(icon, maxGhostSize.width,
|
||||
maxGhostSize.height);
|
||||
double scale = (double)scaled.getIconWidth()/icon.getIconWidth();
|
||||
imageOffset.x *= scale;
|
||||
imageOffset.y *= scale;
|
||||
return scaled;
|
||||
}
|
||||
}*/
|
||||
return icon;
|
||||
}
|
||||
|
||||
/** Create an image from the given icon. The image is provided to the
|
||||
* native handler if drag images are supported natively.
|
||||
*/
|
||||
protected Image createDragImage(GraphicsConfiguration gc, Icon icon) {
|
||||
int w = icon.getIconWidth();
|
||||
int h = icon.getIconHeight();
|
||||
BufferedImage image = gc.createCompatibleImage(w, h, Transparency.TRANSLUCENT);
|
||||
Graphics2D g = (Graphics2D)image.getGraphics();
|
||||
g.setComposite(AlphaComposite.Clear);
|
||||
g.fillRect(0, 0, w, h);
|
||||
// Ignore pixels in the buffered image
|
||||
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, ghostAlpha));
|
||||
icon.paintIcon(dragSource, g, 0, 0);
|
||||
g.dispose();
|
||||
return image;
|
||||
}
|
||||
|
||||
/** Reduce a multiply-set bit mask to a single bit. */
|
||||
private int reduce(int actions) {
|
||||
if ((actions & MOVE) != 0 && actions != MOVE) {
|
||||
return MOVE;
|
||||
}
|
||||
else if ((actions & COPY) != 0 && actions != COPY) {
|
||||
return COPY;
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
protected Cursor getCursorForAction(int actualAction) {
|
||||
switch(actualAction) {
|
||||
case MOVE:
|
||||
return DragSource.DefaultMoveDrop;
|
||||
case COPY:
|
||||
return DragSource.DefaultCopyDrop;
|
||||
case LINK:
|
||||
return DragSource.DefaultLinkDrop;
|
||||
default:
|
||||
return DragSource.DefaultMoveNoDrop;
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the first available action supported by source and target. */
|
||||
protected int getAcceptableDropAction(int targetActions) {
|
||||
return reduce(supportedActions & targetActions);
|
||||
}
|
||||
|
||||
/** Get the currently requested drop action. */
|
||||
protected int getDropAction(DragSourceEvent ev) {
|
||||
if (ev instanceof DragSourceDragEvent) {
|
||||
DragSourceDragEvent e = (DragSourceDragEvent)ev;
|
||||
return e.getDropAction();
|
||||
}
|
||||
if (ev instanceof DragSourceDropEvent) {
|
||||
return ((DragSourceDropEvent)ev).getDropAction();
|
||||
}
|
||||
return NONE;
|
||||
}
|
||||
|
||||
/** Pick a different drop action if the target doesn't support the current
|
||||
* one and there are no modifiers.
|
||||
*/
|
||||
protected int adjustDropAction(DragSourceEvent ev) {
|
||||
int action = getDropAction(ev);
|
||||
if (ev instanceof DragSourceDragEvent) {
|
||||
DragSourceDragEvent e = (DragSourceDragEvent)ev;
|
||||
if (action == NONE) {
|
||||
int mods = e.getGestureModifiersEx() & KEY_MASK;
|
||||
if (mods == 0) {
|
||||
action = getAcceptableDropAction(e.getTargetActions());
|
||||
}
|
||||
}
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
protected void updateCursor(DragSourceEvent ev) {
|
||||
if (!fixCursor)
|
||||
return;
|
||||
Cursor cursor = getCursorForAction(adjustDropAction(ev));
|
||||
ev.getDragSourceContext().setCursor(cursor);
|
||||
}
|
||||
|
||||
static String actionString(int action) {
|
||||
switch(action) {
|
||||
case MOVE: return "MOVE";
|
||||
case MOVE|COPY: return "MOVE|COPY";
|
||||
case MOVE|LINK: return "MOVE|LINK";
|
||||
case MOVE|COPY|LINK: return "MOVE|COPY|LINK";
|
||||
case COPY: return "COPY";
|
||||
case COPY|LINK: return "COPY|LINK";
|
||||
case LINK: return "LINK";
|
||||
default: return "NONE";
|
||||
}
|
||||
}
|
||||
private String lastAction;
|
||||
private void describe(String type, DragSourceEvent e) {
|
||||
if (false) {
|
||||
DragSourceContext ds = e.getDragSourceContext();
|
||||
String msg = "drag: " + type;
|
||||
if (e instanceof DragSourceDragEvent) {
|
||||
DragSourceDragEvent ev = (DragSourceDragEvent)e;
|
||||
msg += ": src=" + actionString(ds.getSourceActions())
|
||||
+ " usr=" + actionString(ev.getUserAction())
|
||||
+ " tgt=" + actionString(ev.getTargetActions())
|
||||
+ " act=" + actionString(ev.getDropAction())
|
||||
+ " mods=" + ev.getGestureModifiersEx();
|
||||
}
|
||||
else {
|
||||
msg += ": e=" + e;
|
||||
}
|
||||
if (!msg.equals(lastAction)) {
|
||||
System.out.println(lastAction = msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void dragDropEnd(DragSourceDropEvent e) {
|
||||
describe("end", e);
|
||||
setModifiers(UNKNOWN_MODIFIERS);
|
||||
transferable = UNKNOWN_TRANSFERABLE;
|
||||
if (ghost != null) {
|
||||
if (e.getDropSuccess()) {
|
||||
ghost.dispose();
|
||||
}
|
||||
else {
|
||||
ghost.returnToOrigin();
|
||||
}
|
||||
ghost = null;
|
||||
}
|
||||
DragSource src = e.getDragSourceContext().getDragSource();
|
||||
src.removeDragSourceMotionListener(this);
|
||||
moved = false;
|
||||
}
|
||||
|
||||
private Point getImageLocation(Point where) {
|
||||
where.translate(imageOffset.x, imageOffset.y);
|
||||
return where;
|
||||
}
|
||||
|
||||
public void dragEnter(DragSourceDragEvent e) {
|
||||
describe("enter", e);
|
||||
if (ghost != null) {
|
||||
ghost.move(getImageLocation(e.getLocation()));
|
||||
}
|
||||
updateCursor(e);
|
||||
}
|
||||
|
||||
// bug workaround; need to skip initial dragMouseMoved event,
|
||||
// which has reports "0" for the available target actions (1.4+?)
|
||||
// filed a bug for this
|
||||
private boolean moved;
|
||||
public void dragMouseMoved(DragSourceDragEvent e) {
|
||||
describe("move", e);
|
||||
if (ghost != null) {
|
||||
ghost.move(getImageLocation(e.getLocation()));
|
||||
}
|
||||
if (moved)
|
||||
updateCursor(e);
|
||||
moved = true;
|
||||
}
|
||||
|
||||
public void dragOver(DragSourceDragEvent e) {
|
||||
describe("over", e);
|
||||
if (ghost != null) {
|
||||
ghost.move(getImageLocation(e.getLocation()));
|
||||
}
|
||||
updateCursor(e);
|
||||
}
|
||||
|
||||
public void dragExit(DragSourceEvent e) {
|
||||
describe("exit", e);
|
||||
}
|
||||
|
||||
public void dropActionChanged(DragSourceDragEvent e) {
|
||||
describe("change", e);
|
||||
setModifiers(e.getGestureModifiersEx() & KEY_MASK);
|
||||
if (ghost != null) {
|
||||
ghost.move(getImageLocation(e.getLocation()));
|
||||
}
|
||||
updateCursor(e);
|
||||
}
|
||||
}
|
||||
@@ -1,393 +0,0 @@
|
||||
/* 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.platform.dnd;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Point;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.awt.dnd.DnDConstants;
|
||||
import java.awt.dnd.DropTarget;
|
||||
import java.awt.dnd.DropTargetContext;
|
||||
import java.awt.dnd.DropTargetDragEvent;
|
||||
import java.awt.dnd.DropTargetDropEvent;
|
||||
import java.awt.dnd.DropTargetEvent;
|
||||
import java.awt.dnd.DropTargetListener;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/** Provides simplified drop handling for a component.
|
||||
* Usage:<br>
|
||||
* <pre><code>
|
||||
* int actions = DnDConstants.MOVE_OR_COPY;
|
||||
* Component component = ...;
|
||||
* DropHandler handler = new DropHandler(component, actions);
|
||||
* </code></pre>
|
||||
* <p>
|
||||
* <ul>
|
||||
* <li>Accept drops where the action is the default (i.e. no modifiers) but
|
||||
* the intersection of source and target actions is <i>not</i> the default.
|
||||
* Doing so allows the source to adjust the cursor appropriately.
|
||||
* <li>Refuse drops where the user modifiers request an action that is not
|
||||
* supported (this works for all cases except when the drag source is not
|
||||
* a {@link DragHandler} and the user explicitly requests a MOVE operation;
|
||||
* this is indistinguishable from a drag with no modifiers unless we have
|
||||
* access to the key modifiers, which {@link DragHandler} provides).
|
||||
* <li>Drops may be refused based on data flavor, location, intended drop
|
||||
* action, or any combination of those, by overriding {@link #canDrop}.
|
||||
* <li>Custom decoration of the drop area may be performed in
|
||||
* {@link #paintDropTarget(DropTargetEvent, int, Point)} or by providing
|
||||
* a {@link DropTargetPainter}.
|
||||
* </ul>
|
||||
*
|
||||
* The method {@link #getDropAction(DropTargetEvent)} follows these steps to
|
||||
* determine the appropriate action (if any).
|
||||
* <ul>
|
||||
* <li>{@link #isSupported(DataFlavor[])} determines if there are any supported
|
||||
* flavors
|
||||
* <li>{@link #getDropActionsForFlavors(DataFlavor[])} reduces the supported
|
||||
* actions based on available flavors. For instance, a text field for file
|
||||
* paths might support {@link DnDConstants#ACTION_COPY_OR_MOVE} on a plain
|
||||
* string, but {@link DnDConstants#ACTION_LINK} might be the only action
|
||||
* supported on a file.
|
||||
* <li>{@link #getDropAction(DropTargetEvent, int, int, int)} relax the action
|
||||
* if it's the default, or restrict it for user requested actions.
|
||||
* <li>{@link #canDrop(DropTargetEvent, int, Point)} change the action based on
|
||||
* the location in the drop target component, or any other criteria.
|
||||
* </ul>
|
||||
*
|
||||
* Override {@link #drop(DropTargetDropEvent, int)} to handle the drop.
|
||||
* You should invoke {@link DropTargetDropEvent#dropComplete} as soon
|
||||
* as the {@link Transferable} data is obtained, to avoid making the DnD
|
||||
* operation look suspended.
|
||||
*
|
||||
* @see DragHandler
|
||||
* @author twall
|
||||
*/
|
||||
// NOTE: you could probably make one of these handlers serve several targets,
|
||||
// but for simplicity, keep the mapping 1-1-1 handler/droptarget/component
|
||||
// TODO: look into making use of the existing
|
||||
// Transferable.SwingDropTarget on JComponent instances instead of
|
||||
// creating a new DropTarget; we can add self as a listener; probably would
|
||||
// want to remove the default TransferHandler.DropHandler, which uses
|
||||
// the TransferHandler to drop
|
||||
public abstract class DropHandler implements DropTargetListener {
|
||||
|
||||
private int acceptedActions;
|
||||
private List<DataFlavor> acceptedFlavors;
|
||||
private DropTarget dropTarget;
|
||||
private boolean active = true;
|
||||
private DropTargetPainter painter;
|
||||
|
||||
/** Create a handler that allows the given set of actions. If using
|
||||
* this constructor, you will need to override {@link #isSupported} to
|
||||
* indicate which data flavors are allowed.
|
||||
*/
|
||||
public DropHandler(Component c, int acceptedActions) {
|
||||
this(c, acceptedActions, new DataFlavor[0]);
|
||||
}
|
||||
|
||||
/** Enable handling of drops, indicating what actions and flavors are
|
||||
* acceptable.
|
||||
* @param c The component to receive drops
|
||||
* @param acceptedActions Allowed actions for drops
|
||||
* @param acceptedFlavors Allowed data flavors for drops
|
||||
* @see #isSupported
|
||||
*/
|
||||
public DropHandler(final Component c, int acceptedActions, DataFlavor[] acceptedFlavors) {
|
||||
this(c, acceptedActions, acceptedFlavors, null);
|
||||
}
|
||||
|
||||
/** Enable handling of drops, indicating what actions and flavors are
|
||||
* acceptable, and providing a painter for drop target feedback.
|
||||
* @param c The component to receive drops
|
||||
* @param acceptedActions Allowed actions for drops
|
||||
* @param acceptedFlavors Allowed data flavors for drops
|
||||
* @param painter Painter to handle drop target feedback
|
||||
* @see #paintDropTarget
|
||||
*/
|
||||
public DropHandler(final Component c, int acceptedActions,
|
||||
DataFlavor[] acceptedFlavors, DropTargetPainter painter) {
|
||||
this.acceptedActions = acceptedActions;
|
||||
this.acceptedFlavors = Arrays.asList(acceptedFlavors);
|
||||
this.painter = painter;
|
||||
dropTarget = new DropTarget(c, acceptedActions, this, active);
|
||||
}
|
||||
|
||||
protected DropTarget getDropTarget() {
|
||||
return dropTarget;
|
||||
}
|
||||
|
||||
/** Whether this drop target is active. */
|
||||
public boolean isActive() { return active; }
|
||||
|
||||
/** Set whether this handler (and thus its drop target) will accept
|
||||
* any drops.
|
||||
*/
|
||||
public void setActive(boolean active) {
|
||||
this.active = active;
|
||||
if (dropTarget != null) {
|
||||
dropTarget.setActive(active);
|
||||
}
|
||||
}
|
||||
|
||||
/** Indicate the actions available for the given list of data flavors.
|
||||
* Override this method if the acceptable drop actions depend
|
||||
* on the currently available {@link DataFlavor}. The default returns
|
||||
* the accepted actions passed into the constructor.
|
||||
* @param dataFlavors currently available flavors
|
||||
* @see #getDropAction(DropTargetEvent, int, int, int)
|
||||
* @see #canDrop(DropTargetEvent, int, Point)
|
||||
*/
|
||||
protected int getDropActionsForFlavors(DataFlavor[] dataFlavors) {
|
||||
return acceptedActions;
|
||||
}
|
||||
|
||||
/** Calculate the effective action. The default implementation
|
||||
* checks whether any {@link DataFlavor}s are supported, and if so,
|
||||
* will change the current action from {@link DnDConstants#ACTION_NONE} to
|
||||
* something in common between the source and destination. Refuse
|
||||
* user-requested actions if they are not supported (rather than silently
|
||||
* accepting a non-user-requested action, which is the Java's DnD default
|
||||
* behavior). The drop action is forced to {@link DnDConstants#ACTION_NONE}
|
||||
* if there is no supported data flavor.<p>
|
||||
* @see #isSupported(DataFlavor[])
|
||||
* @see #getDropActionsForFlavors
|
||||
* @see #getDropAction(DropTargetEvent, int, int, int)
|
||||
* @see #canDrop(DropTargetEvent, int, Point)
|
||||
*/
|
||||
protected int getDropAction(DropTargetEvent e) {
|
||||
int currentAction = DragHandler.NONE;
|
||||
int sourceActions = DragHandler.NONE;
|
||||
Point location = null;
|
||||
DataFlavor[] flavors = new DataFlavor[0];
|
||||
if (e instanceof DropTargetDragEvent) {
|
||||
DropTargetDragEvent ev = (DropTargetDragEvent)e;
|
||||
currentAction = ev.getDropAction();
|
||||
sourceActions = ev.getSourceActions();
|
||||
flavors = ev.getCurrentDataFlavors();
|
||||
location = ev.getLocation();
|
||||
}
|
||||
else if (e instanceof DropTargetDropEvent) {
|
||||
DropTargetDropEvent ev = (DropTargetDropEvent)e;
|
||||
currentAction = ev.getDropAction();
|
||||
sourceActions = ev.getSourceActions();
|
||||
flavors = ev.getCurrentDataFlavors();
|
||||
location = ev.getLocation();
|
||||
}
|
||||
if (isSupported(flavors)) {
|
||||
int availableActions = getDropActionsForFlavors(flavors);
|
||||
currentAction = getDropAction(e, currentAction, sourceActions, availableActions);
|
||||
if (currentAction != DragHandler.NONE) {
|
||||
if (canDrop(e, currentAction, location)) {
|
||||
return currentAction;
|
||||
}
|
||||
}
|
||||
}
|
||||
return DragHandler.NONE;
|
||||
}
|
||||
|
||||
/* Adjust the drop action depending on whether the
|
||||
* current action is the default or a specific user-requested action.
|
||||
* The default implementation will change the current action from
|
||||
* {@link DnDConstants#ACTION_NONE} if there are actions in
|
||||
* common between the source and destination. It will refuse user-requested
|
||||
* actions if they are not supported (rather than silently accepting
|
||||
* a non-user-requested action, which is the behavior of Swing's default
|
||||
* drop handlers).<p>
|
||||
* You can override this method if you wish to adjust the action based
|
||||
* on the the drag location; if you wish to deny drops based on location,
|
||||
* override {@link #canDrop} instead. If you wish to adjust
|
||||
* the action based on the available data flavors, override
|
||||
* {@link #getDropActionsForFlavor} instead.
|
||||
* @see #getDropActionsForFlavor
|
||||
* @see #canDrop(DropTargetEvent, int, Point)
|
||||
*/
|
||||
protected int getDropAction(DropTargetEvent e, int currentAction,
|
||||
int sourceActions, int acceptedActions) {
|
||||
boolean modifiersActive = modifiersActive(currentAction);
|
||||
if ((currentAction & acceptedActions) == DragHandler.NONE
|
||||
&& !modifiersActive) {
|
||||
int action = acceptedActions & sourceActions;
|
||||
currentAction = action;
|
||||
}
|
||||
else if (modifiersActive) {
|
||||
int action = currentAction & acceptedActions & sourceActions;
|
||||
if (action != currentAction) {
|
||||
currentAction = action;
|
||||
}
|
||||
}
|
||||
return currentAction;
|
||||
}
|
||||
|
||||
/** Returns whether there are key modifiers active ,
|
||||
* or false if they can't be determined.
|
||||
* We use the DragHandler hint, if available, or fall back to whether
|
||||
* the drop action is other than the default (move).
|
||||
*/
|
||||
protected boolean modifiersActive(int dropAction) {
|
||||
int mods = DragHandler.getModifiers();
|
||||
if (mods == DragHandler.UNKNOWN_MODIFIERS) {
|
||||
if (dropAction == DragHandler.LINK
|
||||
|| dropAction == DragHandler.COPY) {
|
||||
return true;
|
||||
}
|
||||
// Can't (yet) distinguish between a forced and a default move
|
||||
// without help from DragHandler
|
||||
return false;
|
||||
}
|
||||
return mods != 0;
|
||||
}
|
||||
|
||||
private String lastAction;
|
||||
private void describe(String type, DropTargetEvent e) {
|
||||
if (false) {
|
||||
String msg = "drop: " + type;
|
||||
if (e instanceof DropTargetDragEvent) {
|
||||
DropTargetContext dtc = e.getDropTargetContext();
|
||||
DropTarget dt = dtc.getDropTarget();
|
||||
DropTargetDragEvent ev = (DropTargetDragEvent)e;
|
||||
msg += ": src=" + DragHandler.actionString(ev.getSourceActions())
|
||||
+ " tgt=" + DragHandler.actionString(dt.getDefaultActions())
|
||||
+ " act=" + DragHandler.actionString(ev.getDropAction());
|
||||
}
|
||||
else if (e instanceof DropTargetDropEvent) {
|
||||
DropTargetContext dtc = e.getDropTargetContext();
|
||||
DropTarget dt = dtc.getDropTarget();
|
||||
DropTargetDropEvent ev = (DropTargetDropEvent)e;
|
||||
msg += ": src=" + DragHandler.actionString(ev.getSourceActions())
|
||||
+ " tgt=" + DragHandler.actionString(dt.getDefaultActions())
|
||||
+ " act=" + DragHandler.actionString(ev.getDropAction());
|
||||
}
|
||||
if (!msg.equals(lastAction)) {
|
||||
System.out.println(lastAction = msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Accept or reject the drag represented by the given event. Returns
|
||||
* the action determined by {@link #getDropAction(DropTargetEvent)}.
|
||||
*/
|
||||
protected int acceptOrReject(DropTargetDragEvent e) {
|
||||
int action = getDropAction(e);
|
||||
if (action != DragHandler.NONE) {
|
||||
// NOTE: the action argument (as of 1.5+) is only passed
|
||||
// to the DropTargetContextPeer, *not* the drag source
|
||||
e.acceptDrag(action);
|
||||
}
|
||||
else {
|
||||
e.rejectDrag();
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
public void dragEnter(DropTargetDragEvent e) {
|
||||
describe("enter(tgt)", e);
|
||||
int action = acceptOrReject(e);
|
||||
paintDropTarget(e, action, e.getLocation());
|
||||
}
|
||||
|
||||
public void dragOver(DropTargetDragEvent e) {
|
||||
describe("over(tgt)", e);
|
||||
int action = acceptOrReject(e);
|
||||
paintDropTarget(e, action, e.getLocation());
|
||||
}
|
||||
|
||||
public void dragExit(DropTargetEvent e) {
|
||||
describe("exit(tgt)", e);
|
||||
paintDropTarget(e, DragHandler.NONE, null);
|
||||
}
|
||||
|
||||
public void dropActionChanged(DropTargetDragEvent e) {
|
||||
describe("change(tgt)", e);
|
||||
int action = acceptOrReject(e);
|
||||
paintDropTarget(e, action, e.getLocation());
|
||||
}
|
||||
|
||||
/** Indicates the user has initiated a drop. The default performs all
|
||||
* standard drop validity checking and handling, then invokes
|
||||
* {@link #drop(DropTargetDropEvent,int)} if the drop looks acceptable.
|
||||
*/
|
||||
public void drop(DropTargetDropEvent e) {
|
||||
describe("drop(tgt)", e);
|
||||
int action = getDropAction(e);
|
||||
if (action != DragHandler.NONE) {
|
||||
e.acceptDrop(action);
|
||||
try {
|
||||
drop(e, action);
|
||||
// Just in case this hasn't been done yet
|
||||
e.dropComplete(true);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
e.dropComplete(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
e.rejectDrop();
|
||||
}
|
||||
paintDropTarget(e, DragHandler.NONE, e.getLocation());
|
||||
}
|
||||
|
||||
/** Return whether any of the flavors in the given list are accepted.
|
||||
* The list is compared against the accepted list provided in the
|
||||
* constructor.
|
||||
*/
|
||||
protected boolean isSupported(DataFlavor[] flavors) {
|
||||
Set<DataFlavor> set = new HashSet<DataFlavor>(Arrays.asList(flavors));
|
||||
set.retainAll(acceptedFlavors);
|
||||
return !set.isEmpty();
|
||||
}
|
||||
|
||||
/** Update the appearance of the target component. Normally the decoration
|
||||
* should be painted only if the event is an instance of
|
||||
* {@link DropTargetDragEvent} with an action that is not
|
||||
* {@link DragHandler#NONE}. Otherwise the decoration should be removed
|
||||
* or hidden.
|
||||
* <p>
|
||||
* For an easy way to highlight the drop target, consider using a single
|
||||
* instance of <code>AbstractComponentDecorator</code> and moving it
|
||||
* according to the intended drop location.
|
||||
* @param e The drop target event
|
||||
* @param action The action for the drop
|
||||
* @param location The intended drop location, or null if there is none
|
||||
*/
|
||||
protected void paintDropTarget(DropTargetEvent e, int action, Point location) {
|
||||
if (painter != null) {
|
||||
painter.paintDropTarget(e, action, location);
|
||||
}
|
||||
}
|
||||
|
||||
/** Indicate whether the given drop action is acceptable at the given
|
||||
* location. This method is the last check performed by
|
||||
* {@link #getDropAction(DropTargetEvent)}.
|
||||
* You may override this method to refuse drops on certain areas
|
||||
* within the drop target component. The default always returns true.
|
||||
*/
|
||||
protected boolean canDrop(DropTargetEvent e, int action, Point location) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Handle an incoming drop with the given action. The action passed in
|
||||
* might be different from {@link DropTargetDropEvent#getDropAction},
|
||||
* for instance, if there are no modifiers and the default action is not
|
||||
* supported. Calling {@link DropTargetDropEvent#dropComplete} is
|
||||
* recommended as soon as the {@link Transferable} data is obtained; this
|
||||
* allows the drag source to reset the cursor and any drag images which
|
||||
* may be in effect.
|
||||
*/
|
||||
protected abstract void drop(DropTargetDropEvent e, int action) throws UnsupportedFlavorException, IOException;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
/* 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.platform.dnd;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.dnd.DropTargetEvent;
|
||||
|
||||
/** Provides a callback for {@link DropHandler} to customize drop target
|
||||
* feedback.
|
||||
* @author twall
|
||||
*/
|
||||
public interface DropTargetPainter {
|
||||
void paintDropTarget(DropTargetEvent e, int action, Point location);
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
/* 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.platform.dnd;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Window;
|
||||
import java.awt.dnd.DragSource;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.geom.Area;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.Timer;
|
||||
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
|
||||
/** Provide a ghosted drag image for use during drags where
|
||||
* {@link DragSource#isDragImageSupported} returns false.<p>
|
||||
* Its location in screen coordinates may be changed via {@link #move}.<p>
|
||||
* When the image is no longer needed, invoke {@link #dispose}, which
|
||||
* hides the graphic immediately, or {@link #returnToOrigin}, which
|
||||
* moves the image to its original location and then disposes it.
|
||||
*/
|
||||
public class GhostedDragImage {
|
||||
|
||||
private static final float DEFAULT_ALPHA = .5f;
|
||||
private Window dragImage;
|
||||
// Initial image position, relative to drag source
|
||||
private Point origin;
|
||||
|
||||
/** Create a ghosted drag image, using the given icon.
|
||||
* @param icon image to be drawn
|
||||
* @param initialScreenLoc initial screen location of the image
|
||||
*/
|
||||
public GhostedDragImage(Component dragSource, final Icon icon, Point initialScreenLoc,
|
||||
final Point cursorOffset) {
|
||||
Window parent = dragSource instanceof Window
|
||||
? (Window)dragSource : SwingUtilities.getWindowAncestor(dragSource);
|
||||
// FIXME ensure gc is compatible (X11)
|
||||
GraphicsConfiguration gc = parent.getGraphicsConfiguration();
|
||||
dragImage = new Window(JOptionPane.getRootFrame(), gc) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public void paint(Graphics g) {
|
||||
icon.paintIcon(this, g, 0, 0);
|
||||
}
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(icon.getIconWidth(), icon.getIconHeight());
|
||||
}
|
||||
public Dimension getMinimumSize() {
|
||||
return getPreferredSize();
|
||||
}
|
||||
public Dimension getMaximumSize() {
|
||||
return getPreferredSize();
|
||||
}
|
||||
};
|
||||
dragImage.setFocusableWindowState(false);
|
||||
dragImage.setName("###overrideRedirect###");
|
||||
Icon dragIcon = new Icon() {
|
||||
public int getIconHeight() {
|
||||
return icon.getIconHeight();
|
||||
}
|
||||
public int getIconWidth() {
|
||||
return icon.getIconWidth();
|
||||
}
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
g = g.create();
|
||||
Area area = new Area(new Rectangle(x, y, getIconWidth(), getIconHeight()));
|
||||
// X11 needs more of a window due to differences in event processing
|
||||
area.subtract(new Area(new Rectangle(x + cursorOffset.x-1, y + cursorOffset.y-1, 3, 3)));
|
||||
g.setClip(area);
|
||||
icon.paintIcon(c, g, x, y);
|
||||
g.dispose();
|
||||
}
|
||||
|
||||
};
|
||||
dragImage.pack();
|
||||
WindowUtils.setWindowMask(dragImage, dragIcon);
|
||||
WindowUtils.setWindowAlpha(dragImage, DEFAULT_ALPHA);
|
||||
move(initialScreenLoc);
|
||||
dragImage.setVisible(true);
|
||||
}
|
||||
|
||||
/** Set the transparency of the ghosted image. */
|
||||
public void setAlpha(float alpha) {
|
||||
WindowUtils.setWindowAlpha(dragImage, alpha);
|
||||
}
|
||||
|
||||
/** Make all ghosted images go away. */
|
||||
public void dispose() {
|
||||
dragImage.dispose();
|
||||
dragImage = null;
|
||||
}
|
||||
|
||||
/** Move the ghosted image to the requested location.
|
||||
* @param screenLocation Where to draw the image, in screen coordinates
|
||||
*/
|
||||
public void move(Point screenLocation) {
|
||||
if (origin == null) {
|
||||
origin = screenLocation;
|
||||
}
|
||||
dragImage.setLocation(screenLocation.x, screenLocation.y);
|
||||
}
|
||||
|
||||
private static final int SLIDE_INTERVAL = 1000/30;
|
||||
/** Animate the ghosted image returning to its origin. */
|
||||
public void returnToOrigin() {
|
||||
final Timer timer = new Timer(SLIDE_INTERVAL, null);
|
||||
timer.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Point location = dragImage.getLocationOnScreen();
|
||||
Point dst = new Point(origin);
|
||||
int dx = (dst.x - location.x)/2;
|
||||
int dy = (dst.y - location.y)/2;
|
||||
if (dx != 0 || dy != 0) {
|
||||
location.translate(dx, dy);
|
||||
move(location);
|
||||
}
|
||||
else {
|
||||
timer.stop();
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
});
|
||||
timer.setInitialDelay(0);
|
||||
timer.start();
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Copyright (c) 2010 Timothy Wall
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<!-- One sentence summary -->
|
||||
Provides integrated, extended drag and drop functionality,
|
||||
allowing ghosted drag images to be used on all platforms.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2011 Denis Tulskiy
|
||||
*
|
||||
* This program 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sun.jna.platform.mac;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Callback;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* Author: Denis Tulskiy
|
||||
* Date: 7/25/11
|
||||
*/
|
||||
public interface Carbon {
|
||||
public static Carbon INSTANCE = (Carbon) Native.loadLibrary("Carbon", Carbon.class);
|
||||
|
||||
public static final int cmdKey = 0x0100;
|
||||
public static final int shiftKey = 0x0200;
|
||||
public static final int optionKey = 0x0800;
|
||||
public static final int controlKey = 0x1000;
|
||||
|
||||
/**
|
||||
* Obtains the event target reference for the standard toolbox dispatcher
|
||||
*/
|
||||
public Pointer GetEventDispatcherTarget();
|
||||
|
||||
/**
|
||||
* Installs an event handler on a specified event target.
|
||||
*/
|
||||
public int InstallEventHandler(Pointer inTarget, EventHandlerProcPtr inHandler, int inNumTypes, EventTypeSpec[] inList, Pointer inUserData, PointerByReference outRef);
|
||||
|
||||
/**
|
||||
* Registers a global hot key.
|
||||
*/
|
||||
public int RegisterEventHotKey(int inHotKeyCode, int inHotKeyModifiers, EventHotKeyID.ByValue inHotKeyID, Pointer inTarget, int inOptions, PointerByReference outRef);
|
||||
|
||||
/**
|
||||
* Obtains a parameter from the specified event.
|
||||
*/
|
||||
public int GetEventParameter(Pointer inEvent, int inName, int inDesiredType, Pointer outActualType, int inBufferSize, IntBuffer outActualSize, EventHotKeyID outData);
|
||||
|
||||
/**
|
||||
* Removes the specified event handler
|
||||
*/
|
||||
public int RemoveEventHandler(Pointer inHandlerRef);
|
||||
|
||||
/**
|
||||
* Unregisters a global hot key.
|
||||
*/
|
||||
public int UnregisterEventHotKey(Pointer inHotKey);
|
||||
|
||||
public class EventTypeSpec extends Structure {
|
||||
public int eventClass;
|
||||
public int eventKind;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "eventClass", "eventKind" }); }
|
||||
}
|
||||
|
||||
public static class EventHotKeyID extends Structure {
|
||||
public int signature;
|
||||
public int id;
|
||||
|
||||
public static class ByValue extends EventHotKeyID implements Structure.ByValue { }
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "signature", "id" }); }
|
||||
}
|
||||
|
||||
public static interface EventHandlerProcPtr extends Callback {
|
||||
public int callback(Pointer inHandlerCallRef, Pointer inEvent, Pointer inUserData);
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/* 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.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.mac;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.platform.FileUtils;
|
||||
|
||||
public class MacFileUtils extends FileUtils {
|
||||
|
||||
public boolean hasTrash() { return true; }
|
||||
|
||||
public interface FileManager extends Library {
|
||||
int kFSFileOperationDefaultOptions = 0;
|
||||
int kFSFileOperationsOverwrite = 0x01;
|
||||
int kFSFileOperationsSkipSourcePermissionErrors = 0x02;
|
||||
int kFSFileOperationsDoNotMoveAcrossVolumes = 0x04;
|
||||
int kFSFileOperationsSkipPreflight = 0x08;
|
||||
|
||||
public FileManager INSTANCE = (FileManager)Native.loadLibrary("CoreServices", FileManager.class);
|
||||
int FSPathMoveObjectToTrashSync(String src, PointerByReference target, int options);
|
||||
}
|
||||
|
||||
public void moveToTrash(File[] files) throws IOException {
|
||||
File home = new File(System.getProperty("user.home"));
|
||||
File trash = new File(home, ".Trash");
|
||||
if (!trash.exists()) {
|
||||
throw new IOException("The Trash was not found in its expected location (" + trash + ")");
|
||||
}
|
||||
List<File> failed = new ArrayList<File>();
|
||||
for (int i=0;i < files.length;i++) {
|
||||
File src = files[i];
|
||||
if (FileManager.INSTANCE.FSPathMoveObjectToTrashSync(src.getAbsolutePath(), null, 0) != 0) {
|
||||
failed.add(src);
|
||||
}
|
||||
}
|
||||
if (failed.size() > 0) {
|
||||
throw new IOException("The following files could not be trashed: " + failed);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Copyright (c) 2010 Timothy Wall
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<!-- One sentence summary -->
|
||||
Provides common library mappings for the OS X platform.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,13 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Copyright (c) 2010 Timothy Wall
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<!-- One sentence summary -->
|
||||
Provides cross-platform utilities based on platform-specific libraries.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -1,13 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Copyright (c) 2010 Timothy Wall
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<!-- One sentence summary -->
|
||||
Provides common library mappings for Unix and X11-based platforms.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -1,127 +0,0 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, 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.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.IntegerType;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.ptr.ByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Based on basetsd.h (various types)
|
||||
* @author dblock[at]dblock[dot]org
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public interface BaseTSD extends StdCallLibrary {
|
||||
/**
|
||||
* Signed long type for pointer precision.
|
||||
* Use when casting a pointer to a long to perform pointer arithmetic.
|
||||
*/
|
||||
public static class LONG_PTR extends IntegerType {
|
||||
public LONG_PTR() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public LONG_PTR(long value) {
|
||||
super(Pointer.SIZE, value);
|
||||
}
|
||||
|
||||
public Pointer toPointer() {
|
||||
return Pointer.createConstant(longValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Signed SIZE_T.
|
||||
*/
|
||||
public static class SSIZE_T extends LONG_PTR {
|
||||
public SSIZE_T() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public SSIZE_T(long value) {
|
||||
super(value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsigned LONG_PTR.
|
||||
*/
|
||||
public static class ULONG_PTR extends IntegerType {
|
||||
public ULONG_PTR() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public ULONG_PTR(long value) {
|
||||
super(Pointer.SIZE, value, true);
|
||||
}
|
||||
|
||||
public Pointer toPointer() {
|
||||
return Pointer.createConstant(longValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PULONG_PTR
|
||||
*/
|
||||
public static class ULONG_PTRByReference extends ByReference {
|
||||
public ULONG_PTRByReference() {
|
||||
this(new ULONG_PTR(0));
|
||||
}
|
||||
public ULONG_PTRByReference(ULONG_PTR value) {
|
||||
super(Pointer.SIZE);
|
||||
setValue(value);
|
||||
}
|
||||
public void setValue(ULONG_PTR value) {
|
||||
if (Pointer.SIZE == 4) {
|
||||
getPointer().setInt(0, value.intValue());
|
||||
}
|
||||
else {
|
||||
getPointer().setLong(0, value.longValue());
|
||||
}
|
||||
}
|
||||
public ULONG_PTR getValue() {
|
||||
return new ULONG_PTR(Pointer.SIZE == 4
|
||||
? getPointer().getInt(0)
|
||||
: getPointer().getLong(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unsigned DWORD_PTR.
|
||||
*/
|
||||
public static class DWORD_PTR extends IntegerType {
|
||||
public DWORD_PTR() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public DWORD_PTR(long value) {
|
||||
super(Pointer.SIZE, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum number of bytes to which a pointer can point.
|
||||
* Use for a count that must span the full range of a pointer.
|
||||
*/
|
||||
public static class SIZE_T extends ULONG_PTR {
|
||||
public SIZE_T() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public SIZE_T(long value) {
|
||||
super(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, 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.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.WinCrypt.CRYPTPROTECT_PROMPTSTRUCT;
|
||||
import com.sun.jna.platform.win32.WinCrypt.DATA_BLOB;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Crypt32.dll Interface.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface Crypt32 extends StdCallLibrary {
|
||||
|
||||
Crypt32 INSTANCE = (Crypt32) Native.loadLibrary("Crypt32",
|
||||
Crypt32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* The CryptProtectData function performs encryption on the data in a DATA_BLOB
|
||||
* structure. Typically, only a user with the same logon credential as the encrypter
|
||||
* can decrypt the data. In addition, the encryption and decryption usually must be
|
||||
* done on the same computer.
|
||||
* @param pDataIn
|
||||
* Pointer to a DATA_BLOB structure that contains the plaintext to be encrypted.
|
||||
* @param szDataDescr
|
||||
* String with a readable description of the data to be encrypted. This description
|
||||
* string is included with the encrypted data. This parameter is optional and can
|
||||
* be set to NULL, except on Windows 2000.
|
||||
* @param pOptionalEntropy
|
||||
* Pointer to a DATA_BLOB structure that contains a password or other additional
|
||||
* entropy used to encrypt the data. The DATA_BLOB structure used in the encryption
|
||||
* phase must also be used in the decryption phase. This parameter can be set to NULL
|
||||
* for no additional entropy.
|
||||
* @param pvReserved
|
||||
* Reserved for future use and must be set to NULL.
|
||||
* @param pPromptStruct
|
||||
* Pointer to a CRYPTPROTECT_PROMPTSTRUCT structure that provides information about
|
||||
* where and when prompts are to be displayed and what the content of those prompts
|
||||
* should be. This parameter can be set to NULL in both the encryption and decryption
|
||||
* phases.
|
||||
* @param dwFlags
|
||||
* One of CRYPTPROTECT_LOCAL_MACHINE, CRYPTPROTECT_UI_FORBIDDEN, CRYPTPROTECT_AUDIT,
|
||||
* CRYPTPROTECT_VERIFY_PROTECTION.
|
||||
* @param pDataOut
|
||||
* Pointer to a DATA_BLOB structure that receives the encrypted data. When you have
|
||||
* finished using the DATA_BLOB structure, free its pbData member by calling the
|
||||
* LocalFree function.
|
||||
* @return
|
||||
* If the function succeeds, the function returns TRUE. If the function fails,
|
||||
* it returns FALSE. For extended error information, call GetLastError.
|
||||
*/
|
||||
public boolean CryptProtectData(DATA_BLOB pDataIn, String szDataDescr,
|
||||
DATA_BLOB pOptionalEntropy, Pointer pvReserved,
|
||||
CRYPTPROTECT_PROMPTSTRUCT pPromptStruct,
|
||||
int dwFlags,
|
||||
DATA_BLOB pDataOut);
|
||||
|
||||
/**
|
||||
* The CryptUnprotectData function decrypts and does an integrity check of the data in
|
||||
* a DATA_BLOB structure. Usually, only a user with the same logon credentials as the
|
||||
* encrypter can decrypt the data. In addition, the encryption and decryption must be
|
||||
* done on the same computer.
|
||||
* @param pDataIn
|
||||
* Pointer to a DATA_BLOB structure that holds the encrypted data. The DATA_BLOB
|
||||
* structure's cbData member holds the length of the pbData member's byte string that
|
||||
* contains the text to be encrypted.
|
||||
* @param szDataDescr
|
||||
* Pointer to a string-readable description of the encrypted data included with the
|
||||
* encrypted data. This parameter can be set to NULL. When you have finished using
|
||||
* ppszDataDescr, free it by calling the LocalFree function.
|
||||
* @param pOptionalEntropy
|
||||
* Pointer to a DATA_BLOB structure that contains a password or other additional
|
||||
* entropy used when the data was encrypted. This parameter can be set to NULL;
|
||||
* however, if an optional entropy DATA_BLOB structure was used in the encryption
|
||||
* phase, that same DATA_BLOB structure must be used for the decryption phase.
|
||||
* @param pvReserved
|
||||
* Reserved for future use; must be set to NULL.
|
||||
* @param pPromptStruct
|
||||
* Pointer to a CRYPTPROTECT_PROMPTSTRUCT structure that provides information about
|
||||
* where and when prompts are to be displayed and what the content of those prompts
|
||||
* should be. This parameter can be set to NULL.
|
||||
* @param dwFlags
|
||||
* DWORD value that specifies options for this function. This parameter can be zero,
|
||||
* in which case no option is set, or CRYPTPROTECT_UI_FORBIDDEN.
|
||||
* @param pDataOut
|
||||
* Pointer to a DATA_BLOB structure where the function stores the decrypted data.
|
||||
* When you have finished using the DATA_BLOB structure, free its pbData member by
|
||||
* calling the LocalFree function.
|
||||
* @return
|
||||
* If the function succeeds, the return value is TRUE. If the function fails, the
|
||||
* return value is FALSE.
|
||||
*/
|
||||
public boolean CryptUnprotectData(DATA_BLOB pDataIn, PointerByReference szDataDescr,
|
||||
DATA_BLOB pOptionalEntropy, Pointer pvReserved,
|
||||
CRYPTPROTECT_PROMPTSTRUCT pPromptStruct,
|
||||
int dwFlags,
|
||||
DATA_BLOB pDataOut);
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, 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.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.platform.win32.WinCrypt.CRYPTPROTECT_PROMPTSTRUCT;
|
||||
import com.sun.jna.platform.win32.WinCrypt.DATA_BLOB;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* Crypt32 utility API.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class Crypt32Util {
|
||||
|
||||
/**
|
||||
* Protect a blob of data.
|
||||
* @param data
|
||||
* Data to protect.
|
||||
* @return
|
||||
* Protected data.
|
||||
*/
|
||||
public static byte[] cryptProtectData(byte[] data) {
|
||||
return cryptProtectData(data, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect a blob of data with optional flags.
|
||||
* @param data
|
||||
* Data to protect.
|
||||
* @param flags
|
||||
* Optional flags, eg. CRYPTPROTECT_LOCAL_MACHINE | CRYPTPROTECT_UI_FORBIDDEN.
|
||||
* @return
|
||||
* Protected data.
|
||||
*/
|
||||
public static byte[] cryptProtectData(byte[] data, int flags) {
|
||||
return cryptProtectData(data, null, flags, "", null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect a blob of data.
|
||||
* @param data
|
||||
* Data to protect.
|
||||
* @param entropy
|
||||
* Optional entropy.
|
||||
* @param flags
|
||||
* Optional flags.
|
||||
* @param description
|
||||
* Optional description.
|
||||
* @param prompt
|
||||
* Prompt structure.
|
||||
* @return
|
||||
* Protected bytes.
|
||||
*/
|
||||
public static byte[] cryptProtectData(byte[] data, byte[] entropy, int flags,
|
||||
String description, CRYPTPROTECT_PROMPTSTRUCT prompt) {
|
||||
DATA_BLOB pDataIn = new DATA_BLOB(data);
|
||||
DATA_BLOB pDataProtected = new DATA_BLOB();
|
||||
DATA_BLOB pEntropy = (entropy == null) ? null : new DATA_BLOB(entropy);
|
||||
try {
|
||||
if (! Crypt32.INSTANCE.CryptProtectData(pDataIn, description,
|
||||
pEntropy, null, prompt, flags, pDataProtected)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return pDataProtected.getData();
|
||||
} finally {
|
||||
if (pDataProtected.pbData != null) {
|
||||
Kernel32.INSTANCE.LocalFree(pDataProtected.pbData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unprotect a blob of data.
|
||||
* @param data
|
||||
* Data to unprotect.
|
||||
* @return
|
||||
* Unprotected blob of data.
|
||||
*/
|
||||
public static byte[] cryptUnprotectData(byte[] data) {
|
||||
return cryptUnprotectData(data, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unprotect a blob of data.
|
||||
* @param data
|
||||
* Data to unprotect.
|
||||
* @param flags
|
||||
* Optional flags, eg. CRYPTPROTECT_UI_FORBIDDEN.
|
||||
* @return
|
||||
* Unprotected blob of data.
|
||||
*/
|
||||
public static byte[] cryptUnprotectData(byte[] data, int flags) {
|
||||
return cryptUnprotectData(data, null, flags, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unprotect a blob of data.
|
||||
* @param data
|
||||
* Data to unprotect.
|
||||
* @param entropy
|
||||
* Optional entropy.
|
||||
* @param flags
|
||||
* Optional flags.
|
||||
* @param prompt
|
||||
* Optional prompt structure.
|
||||
* @return
|
||||
* Unprotected blob of data.
|
||||
*/
|
||||
public static byte[] cryptUnprotectData(byte[] data, byte[] entropy, int flags,
|
||||
CRYPTPROTECT_PROMPTSTRUCT prompt) {
|
||||
DATA_BLOB pDataIn = new DATA_BLOB(data);
|
||||
DATA_BLOB pDataUnprotected = new DATA_BLOB();
|
||||
DATA_BLOB pEntropy = (entropy == null) ? null : new DATA_BLOB(entropy);
|
||||
PointerByReference pDescription = new PointerByReference();
|
||||
try {
|
||||
if (! Crypt32.INSTANCE.CryptUnprotectData(pDataIn, pDescription,
|
||||
pEntropy, null, prompt, flags, pDataUnprotected)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return pDataUnprotected.getData();
|
||||
} finally {
|
||||
if (pDataUnprotected.pbData != null) {
|
||||
Kernel32.INSTANCE.LocalFree(pDataUnprotected.pbData);
|
||||
}
|
||||
if (pDescription.getValue() != null) {
|
||||
Kernel32.INSTANCE.LocalFree(pDescription.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,220 +0,0 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, 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.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.WinNT.PSID;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
|
||||
/**
|
||||
* Ported from DsGetDC.h.
|
||||
* Windows SDK 6.0a
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface DsGetDC extends StdCallLibrary {
|
||||
|
||||
/**
|
||||
* The DOMAIN_CONTROLLER_INFO structure is used with the DsGetDcName
|
||||
* function to receive data about a domain controller.
|
||||
*/
|
||||
public static class DOMAIN_CONTROLLER_INFO extends Structure {
|
||||
|
||||
public static class ByReference extends DOMAIN_CONTROLLER_INFO implements Structure.ByReference { }
|
||||
|
||||
public DOMAIN_CONTROLLER_INFO() { }
|
||||
|
||||
public DOMAIN_CONTROLLER_INFO(Pointer memory) {
|
||||
super(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the computer name
|
||||
* of the discovered domain controller. The returned computer name is
|
||||
* prefixed with "\\". The DNS-style name, for example, "\\phoenix.fabrikam.com",
|
||||
* is returned, if available. If the DNS-style name is not available, the
|
||||
* flat-style name (for example, "\\phoenix") is returned. This example would apply
|
||||
* if the domain is a Windows NT 4.0 domain or if the domain does not support the
|
||||
* IP family of protocols.
|
||||
*/
|
||||
public WString DomainControllerName;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the address of the discovered
|
||||
* domain controller. The address is prefixed with "\\". This WString is one of the
|
||||
* types defined by the DomainControllerAddressType member.
|
||||
*/
|
||||
public WString DomainControllerAddress;
|
||||
/**
|
||||
* Indicates the type of WString that is contained in the DomainControllerAddress member.
|
||||
*/
|
||||
public int DomainControllerAddressType;
|
||||
/**
|
||||
* The GUID of the domain. This member is zero if the domain controller does not have
|
||||
* a Domain GUID; for example, the domain controller is not a Windows 2000 domain
|
||||
* controller.
|
||||
*/
|
||||
public GUID DomainGuid;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the domain. The
|
||||
* DNS-style name, for example, "fabrikam.com", is returned if available. Otherwise,
|
||||
* the flat-style name, for example, "fabrikam", is returned. This name may be different
|
||||
* than the requested domain name if the domain has been renamed.
|
||||
*/
|
||||
public WString DomainName;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the domain at the root
|
||||
* of the DS tree. The DNS-style name, for example, "fabrikam.com", is returned if
|
||||
* available. Otherwise, the flat-style name, for example, "fabrikam" is returned.
|
||||
*/
|
||||
public WString DnsForestName;
|
||||
/**
|
||||
* Contains a set of flags that describe the domain controller.
|
||||
*/
|
||||
public int Flags;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the site where the
|
||||
* domain controller is located. This member may be NULL if the domain controller is
|
||||
* not in a site; for example, the domain controller is a Windows NT 4.0 domain
|
||||
* controller.
|
||||
*/
|
||||
public WString DcSiteName;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the site that the
|
||||
* computer belongs to. The computer is specified in the ComputerName parameter passed
|
||||
* to DsGetDcName. This member may be NULL if the site that contains the computer
|
||||
* cannot be found; for example, if the DS administrator has not associated the
|
||||
* subnet that the computer is in with a valid site.
|
||||
*/
|
||||
public WString ClientSiteName;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "DomainControllerName", "DomainControllerAddress", "DomainControllerAddressType", "DomainGuid", "DomainName", "DnsForestName", "Flags", "DcSiteName", "ClientSiteName"});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to DOMAIN_CONTROLLER_INFO.
|
||||
*/
|
||||
public static class PDOMAIN_CONTROLLER_INFO extends Structure {
|
||||
|
||||
public static class ByReference extends PDOMAIN_CONTROLLER_INFO implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public DOMAIN_CONTROLLER_INFO.ByReference dci;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dci" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Domain is a member of the forest.
|
||||
*/
|
||||
int DS_DOMAIN_IN_FOREST = 0x0001;
|
||||
/**
|
||||
* Domain is directly trusted.
|
||||
*/
|
||||
int DS_DOMAIN_DIRECT_OUTBOUND = 0x0002;
|
||||
/**
|
||||
* Domain is root of a tree in the forest.
|
||||
*/
|
||||
int DS_DOMAIN_TREE_ROOT = 0x0004;
|
||||
/**
|
||||
* Domain is the primary domain of queried server.
|
||||
*/
|
||||
int DS_DOMAIN_PRIMARY = 0x0008;
|
||||
/**
|
||||
* Primary domain is running in native mode.
|
||||
*/
|
||||
int DS_DOMAIN_NATIVE_MODE = 0x0010;
|
||||
/**
|
||||
* Domain is directly trusting.
|
||||
*/
|
||||
int DS_DOMAIN_DIRECT_INBOUND = 0x0020;
|
||||
/**
|
||||
* Valid domain flags.
|
||||
*/
|
||||
int DS_DOMAIN_VALID_FLAGS =
|
||||
DS_DOMAIN_IN_FOREST |
|
||||
DS_DOMAIN_DIRECT_OUTBOUND |
|
||||
DS_DOMAIN_TREE_ROOT |
|
||||
DS_DOMAIN_PRIMARY |
|
||||
DS_DOMAIN_NATIVE_MODE |
|
||||
DS_DOMAIN_DIRECT_INBOUND;
|
||||
|
||||
/**
|
||||
* The DS_DOMAIN_TRUSTS structure is used with the DsEnumerateDomainTrusts function to
|
||||
* contain trust data for a domain.
|
||||
*/
|
||||
public static class DS_DOMAIN_TRUSTS extends Structure {
|
||||
|
||||
public static class ByReference extends DS_DOMAIN_TRUSTS implements Structure.ByReference {
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated string that contains the NetBIOS name of the domain.
|
||||
*/
|
||||
public WString NetbiosDomainName;
|
||||
/**
|
||||
* Pointer to a null-terminated string that contains the DNS name of the domain. This member may be NULL.
|
||||
*/
|
||||
public WString DnsDomainName;
|
||||
/**
|
||||
* Contains a set of flags that specify more data about the domain trust.
|
||||
*/
|
||||
public int Flags;
|
||||
/**
|
||||
* Contains the index in the Domains array returned by the DsEnumerateDomainTrusts function that
|
||||
* corresponds to the parent domain of the domain represented by this structure.
|
||||
*/
|
||||
public int ParentIndex;
|
||||
/**
|
||||
* Contains a value that indicates the type of trust represented by this structure.
|
||||
*/
|
||||
public int TrustType;
|
||||
/**
|
||||
* Contains a value that indicates the attributes of the trust represented by this structure.
|
||||
*/
|
||||
public int TrustAttributes;
|
||||
|
||||
/**
|
||||
* Contains the security identifier of the domain represented by this structure.
|
||||
*/
|
||||
public PSID.ByReference DomainSid;
|
||||
|
||||
/**
|
||||
* Contains the GUID of the domain represented by this structure.
|
||||
*/
|
||||
public GUID DomainGuid;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "NetbiosDomainName", "DnsDomainName", "Flags", "ParentIndex", "TrustType", "TrustAttributes", "DomainSid", "DomainGuid" });
|
||||
}
|
||||
|
||||
public DS_DOMAIN_TRUSTS() {
|
||||
}
|
||||
|
||||
public DS_DOMAIN_TRUSTS(Pointer p) {
|
||||
super(p);
|
||||
read();
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,316 +0,0 @@
|
||||
/* 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.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.WinDef.HBITMAP;
|
||||
import com.sun.jna.platform.win32.WinDef.HDC;
|
||||
import com.sun.jna.platform.win32.WinDef.HRGN;
|
||||
import com.sun.jna.platform.win32.WinGDI.BITMAPINFO;
|
||||
import com.sun.jna.platform.win32.WinGDI.BITMAPINFOHEADER;
|
||||
import com.sun.jna.platform.win32.WinGDI.RGNDATA;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/** Definition (incomplete) of <code>gdi32.dll</code>. */
|
||||
public interface GDI32 extends StdCallLibrary {
|
||||
|
||||
GDI32 INSTANCE = (GDI32) Native.loadLibrary("gdi32", GDI32.class,
|
||||
W32APIOptions.DEFAULT_OPTIONS);
|
||||
|
||||
/**
|
||||
* The ExtCreateRegion function creates a region from the specified region and transformation data.
|
||||
* @param lpXform
|
||||
* Pointer to an XFORM structure that defines the transformation to be performed on the region. If this pointer is NULL,
|
||||
* the identity transformation is used.
|
||||
* @param nCount
|
||||
* Specifies the number of bytes pointed to by lpRgnData.
|
||||
* @param lpRgnData
|
||||
* Pointer to a RGNDATA structure that contains the region data in logical units.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the value of the region.
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
public HRGN ExtCreateRegion(Pointer lpXform, int nCount, RGNDATA lpRgnData);
|
||||
|
||||
/**
|
||||
* The CombineRgn function combines two regions and stores the result in a third region.
|
||||
* The two regions are combined according to the specified mode.
|
||||
* @param hrgnDest
|
||||
* Handle to a new region with dimensions defined by combining two other regions.
|
||||
* @param hrgnSrc1
|
||||
* Handle to the first of two regions to be combined.
|
||||
* @param hrgnSrc2
|
||||
* Handle to the second of two regions to be combined.
|
||||
* @param fnCombineMode
|
||||
* Specifies a mode indicating how the two regions will be combined.
|
||||
* @return
|
||||
* The return value specifies the type of the resulting region.
|
||||
*/
|
||||
int CombineRgn(HRGN hrgnDest, HRGN hrgnSrc1, HRGN hrgnSrc2,
|
||||
int fnCombineMode);
|
||||
|
||||
/**
|
||||
* The CreateRectRgn function creates a rectangular region.
|
||||
* @param nLeftRect
|
||||
* Specifies the x-coordinate of the upper-left corner of the region in logical units.
|
||||
* @param nTopRect
|
||||
* Specifies the y-coordinate of the upper-left corner of the region in logical units.
|
||||
* @param nRightRect
|
||||
* Specifies the x-coordinate of the lower-right corner of the region in logical units.
|
||||
* @param nBottomRect
|
||||
* Specifies the y-coordinate of the lower-right corner of the region in logical units.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the handle to the region.
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HRGN CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect,
|
||||
int nBottomRect);
|
||||
|
||||
/**
|
||||
* The CreateRoundRectRgn function creates a rectangular region with rounded corners.
|
||||
* @param nLeftRect
|
||||
* Specifies the x-coordinate of the upper-left corner of the region in logical units.
|
||||
* @param nTopRect
|
||||
* Specifies the y-coordinate of the upper-left corner of the region in logical units.
|
||||
* @param nRightRect
|
||||
* Specifies the x-coordinate of the lower-right corner of the region in logical units.
|
||||
* @param nBottomRect
|
||||
* Specifies the y-coordinate of the lower-right corner of the region in logical units.
|
||||
* @param nWidthEllipse
|
||||
* Specifies the width of the ellipse used to create the rounded corners in logical units.
|
||||
* @param nHeightEllipse
|
||||
* Specifies the height of the ellipse used to create the rounded corners in logical units.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the handle to the region.
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HRGN CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect,
|
||||
int nBottomRect, int nWidthEllipse, int nHeightEllipse);
|
||||
|
||||
/**
|
||||
* The CreatePolyPolygonRgn function creates a region consisting of a series
|
||||
* of polygons. The polygons can overlap.
|
||||
* @param lppt
|
||||
* Pointer to an array of POINT structures that define the vertices of the polygons in logical units.
|
||||
* The polygons are specified consecutively. Each polygon is presumed closed and each vertex is
|
||||
* specified only once.
|
||||
* @param lpPolyCounts
|
||||
* Pointer to an array of integers, each of which specifies the number of points in one of the polygons
|
||||
* in the array pointed to by lppt.
|
||||
* @param nCount
|
||||
* Specifies the total number of integers in the array pointed to by lpPolyCounts.
|
||||
* @param fnPolyFillMode
|
||||
* Specifies the fill mode used to determine which pixels are in the region.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the handle to the region.
|
||||
* If the function fails, the return value is zero.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HRGN CreatePolyPolygonRgn(WinUser.POINT[] lppt, int[] lpPolyCounts,
|
||||
int nCount, int fnPolyFillMode);
|
||||
|
||||
/**
|
||||
* The SetRectRgn function converts a region into a rectangular region with the specified coordinates.
|
||||
* @param hrgn
|
||||
* Handle to the region.
|
||||
* @param nLeftRect
|
||||
* Specifies the x-coordinate of the upper-left corner of the rectangular region in logical units.
|
||||
* @param nTopRect
|
||||
* Specifies the y-coordinate of the upper-left corner of the rectangular region in logical units.
|
||||
* @param nRightRect
|
||||
* Specifies the x-coordinate of the lower-right corner of the rectangular region in logical units.
|
||||
* @param nBottomRect
|
||||
* Specifies the y-coordinate of the lower-right corner of the rectangular region in logical units.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean SetRectRgn(HRGN hrgn, int nLeftRect, int nTopRect, int nRightRect,
|
||||
int nBottomRect);
|
||||
|
||||
/**
|
||||
* The SetPixel function sets the pixel at the specified coordinates to the specified color.
|
||||
* @param hDC
|
||||
* Handle to the device context.
|
||||
* @param x
|
||||
* Specifies the x-coordinate, in logical units, of the point to be set.
|
||||
* @param y
|
||||
* Specifies the y-coordinate, in logical units, of the point to be set.
|
||||
* @param crColor
|
||||
* Specifies the color to be used to paint the point. To create a COLORREF color value, use the RGB macro.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the RGB value that the function sets the pixel to.
|
||||
* This value may differ from the color specified by crColor; that occurs when an exact match for the
|
||||
* specified color cannot be found. If the function fails, the return value is 1. To get extended error
|
||||
* information, call GetLastError. This can be the following value.
|
||||
*/
|
||||
int SetPixel(HDC hDC, int x, int y, int crColor);
|
||||
|
||||
/**
|
||||
* The CreateCompatibleDC function creates a memory device context (DC) compatible with the specified device.
|
||||
* @param hDC
|
||||
* Handle to an existing DC. If this handle is NULL, the function creates a memory DC compatible with the
|
||||
* application's current screen.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the handle to a memory DC.
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HDC CreateCompatibleDC(HDC hDC);
|
||||
|
||||
/**
|
||||
* The DeleteDC function deletes the specified device context (DC).
|
||||
* @param hDC
|
||||
* Handle to the device context.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean DeleteDC(HDC hDC);
|
||||
|
||||
/**
|
||||
* The CreateDIBitmap function creates a compatible bitmap (DDB) from a DIB and, optionally,
|
||||
* sets the bitmap bits.
|
||||
* @param hDC
|
||||
* Handle to a device context.
|
||||
* @param lpbmih
|
||||
* Pointer to a bitmap information header structure, which may be one of those shown in the following table.
|
||||
* @param fdwInit
|
||||
* Specifies how the system initializes the bitmap bits.
|
||||
* @param lpbInit
|
||||
* Pointer to an array of bytes containing the initial bitmap data.
|
||||
* @param lpbmi
|
||||
* Pointer to a BITMAPINFO structure that describes the dimensions and color format of
|
||||
* the array pointed to by the lpbInit parameter.
|
||||
* @param fuUsage
|
||||
* Specifies whether the bmiColors member of the BITMAPINFO structure was initialized and, if so,
|
||||
* whether bmiColors contains explicit red, green, blue (RGB) values or palette indexes. The
|
||||
* fuUsage parameter must be one of the following values.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a handle to the compatible bitmap.
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HBITMAP CreateDIBitmap(HDC hDC, BITMAPINFOHEADER lpbmih, int fdwInit,
|
||||
Pointer lpbInit, BITMAPINFO lpbmi, int fuUsage);
|
||||
|
||||
/**
|
||||
* The CreateDIBSection function creates a DIB that applications can write to directly.
|
||||
* The function gives you a pointer to the location of the bitmap bit values. You can supply
|
||||
* a handle to a file-mapping object that the function will use to create the bitmap, or you
|
||||
* can let the system allocate the memory for the bitmap.
|
||||
* @param hDC
|
||||
* Handle to a device context. If the value of iUsage is DIB_PAL_COLORS, the function uses this
|
||||
* device context's logical palette to initialize the DIB colors.
|
||||
* @param pbmi
|
||||
* Pointer to a BITMAPINFO structure that specifies various attributes of the DIB, including
|
||||
* the bitmap dimensions and colors.
|
||||
* @param iUsage
|
||||
* Specifies the type of data contained in the bmiColors array member of the BITMAPINFO structure
|
||||
* pointed to by pbmi (either logical palette indexes or literal RGB values).
|
||||
* @param ppvBits
|
||||
* Pointer to a variable that receives a pointer to the location of the DIB bit values.
|
||||
* @param hSection
|
||||
* Handle to a file-mapping object that the function will use to create the DIB. This parameter can be NULL.
|
||||
* @param dwOffset
|
||||
* Specifies the offset from the beginning of the file-mapping object referenced by hSection where storage
|
||||
* for the bitmap bit values is to begin.
|
||||
* @return
|
||||
* Specifies the offset from the beginning of the file-mapping object referenced by hSection where storage
|
||||
* for the bitmap bit values is to begin.
|
||||
*/
|
||||
HBITMAP CreateDIBSection(HDC hDC, BITMAPINFO pbmi, int iUsage,
|
||||
PointerByReference ppvBits, Pointer hSection, int dwOffset);
|
||||
|
||||
/**
|
||||
* The CreateCompatibleBitmap function creates a bitmap compatible with the device that is
|
||||
* associated with the specified device context.
|
||||
* @param hDC
|
||||
* Handle to a device context.
|
||||
* @param width
|
||||
* Specifies the bitmap width, in pixels.
|
||||
* @param height
|
||||
* Specifies the bitmap height, in pixels.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a handle to the compatible bitmap (DDB).
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HBITMAP CreateCompatibleBitmap(HDC hDC, int width, int height);
|
||||
|
||||
/**
|
||||
* The SelectObject function selects an object into the specified device context (DC).
|
||||
* The new object replaces the previous object of the same type.
|
||||
* @param hDC
|
||||
* Handle to the DC.
|
||||
* @param hGDIObj
|
||||
* Handle to the object to be selected.
|
||||
* @return
|
||||
* If the selected object is not a region and the function succeeds, the return value
|
||||
* is a handle to the object being replaced. If the selected object is a region and the
|
||||
* function succeeds, the return value is one of the REGION values.
|
||||
*/
|
||||
HANDLE SelectObject(HDC hDC, HANDLE hGDIObj);
|
||||
|
||||
/**
|
||||
* The DeleteObject function deletes a logical pen, brush, font, bitmap, region, or palette,
|
||||
* freeing all system resources associated with the object. After the object is deleted, the
|
||||
* specified handle is no longer valid.
|
||||
* @param hObject
|
||||
* Handle to a logical pen, brush, font, bitmap, region, or palette.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the specified handle is not valid or is currently selected into a DC, the return value is zero.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean DeleteObject(HANDLE hObject);
|
||||
|
||||
/** The GetDeviceCaps function retrieves device-specific information for
|
||||
* the specified device.
|
||||
* @param hdc A handle to the DC.
|
||||
* @param nIndex The item to be returned.
|
||||
* @return
|
||||
* The return value specifies the value of the desired item. When
|
||||
* <i>nIndex</i> is <code>BITSPIXEL</code> and the device has 15bpp or
|
||||
* 16bpp, the return value is 16.
|
||||
*/
|
||||
int GetDeviceCaps(HDC hdc, int nIndex);
|
||||
|
||||
/** The GetDIBits function retrieves the bits fo the specified compatible
|
||||
* bitmap and copies them into a buffer as a DIB using the specified
|
||||
* format.
|
||||
* @param hdc A handle to the device context.
|
||||
* @param hbmp A handle to the bitmap. This must be a compatible bitmap
|
||||
* (DDB).
|
||||
* @param uStartScan The first scan line to retrieve
|
||||
* @param cScanLines The number of scan lines to retrieve.
|
||||
* @param lpvBits A pointer to a buffer to receive the bitmap data. If
|
||||
* this parameter is <code>null</code>, the function passes the dimensions
|
||||
* and format of the bitmap to the {@link BITMAPINFO} structure pointed to
|
||||
* by the <i>lpbi</i> parameter.
|
||||
* @param lpbi A pointer to a {@link BITMAPINFO} structure that specifies
|
||||
* the desired format for the DIB data.
|
||||
* @param uUsage The format of the bmiColors member of the {@link
|
||||
* BITMAPINFO} structure.
|
||||
*/
|
||||
int GetDIBits(HDC hdc, HBITMAP hbmp, int uStartScan, int cScanLines, Pointer lpvBits, BITMAPINFO lpbi, int uUsage);
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, 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.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
|
||||
/**
|
||||
* Ported from Guid.h.
|
||||
* Microsoft Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface Guid {
|
||||
|
||||
public static class GUID extends Structure {
|
||||
|
||||
public static class ByReference extends GUID implements Structure.ByReference {
|
||||
public ByReference() {
|
||||
}
|
||||
|
||||
public ByReference(GUID guid) {
|
||||
super(guid.getPointer());
|
||||
|
||||
Data1 = guid.Data1;
|
||||
Data2 = guid.Data2;
|
||||
Data3 = guid.Data3;
|
||||
Data4 = guid.Data4;
|
||||
}
|
||||
|
||||
public ByReference(Pointer memory) {
|
||||
super(memory);
|
||||
}
|
||||
}
|
||||
|
||||
public GUID() {
|
||||
|
||||
}
|
||||
|
||||
public GUID(Pointer memory) {
|
||||
super(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
public GUID(byte[] data) {
|
||||
if (data.length != 16) {
|
||||
throw new IllegalArgumentException("Invalid data length: " + data.length);
|
||||
}
|
||||
|
||||
long data1Temp = data[3] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= data[2] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= data[1] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= data[0] & 0xff;
|
||||
Data1 = (int) data1Temp;
|
||||
|
||||
int data2Temp = data[5] & 0xff;
|
||||
data2Temp <<= 8;
|
||||
data2Temp |= data[4] & 0xff;
|
||||
Data2 = (short) data2Temp;
|
||||
|
||||
int data3Temp = data[7] & 0xff;
|
||||
data3Temp <<= 8;
|
||||
data3Temp |= data[6] & 0xff;
|
||||
Data3 = (short) data3Temp;
|
||||
|
||||
Data4[0] = data[8];
|
||||
Data4[1] = data[9];
|
||||
Data4[2] = data[10];
|
||||
Data4[3] = data[11];
|
||||
Data4[4] = data[12];
|
||||
Data4[5] = data[13];
|
||||
Data4[6] = data[14];
|
||||
Data4[7] = data[15];
|
||||
}
|
||||
|
||||
public int Data1;
|
||||
public short Data2;
|
||||
public short Data3;
|
||||
public byte[] Data4 = new byte[8];
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "Data1", "Data2", "Data3", "Data4" });
|
||||
}
|
||||
}
|
||||
}
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais
Referência em uma Nova Issue
Bloquear um usuário