

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
11 messages in net.java.dev.jna.usersRe: [jna-users] Fwd: https://jna.dev....| From | Sent On | Attachments |
|---|---|---|
| Timothy Wall | Feb 29, 2008 5:14 am | |
| Paul Loy | Feb 29, 2008 6:10 am | |
| Timothy Wall | Feb 29, 2008 7:07 am | |
| Timothy Wall | Feb 29, 2008 7:46 am | |
| Diego | Feb 29, 2008 8:15 am | |
| Emmanuel Pirsch | Feb 29, 2008 8:55 am | |
| Duncan McGregor | Feb 29, 2008 9:41 am | |
| Jøran Vagnby Lillesand | Mar 1, 2008 3:49 am | |
| Timothy Wall | Mar 2, 2008 6:10 am | |
| Hackett, Mark | May 8, 2008 5:41 am | .html |
| Timothy Wall | May 9, 2008 11:19 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: [jna-users] Fwd: https://jna.dev.java.net/#demos | Actions... |
|---|---|---|
| From: | Timothy Wall (twal...@dev.java.net) | |
| Date: | Feb 29, 2008 7:46:02 am | |
| List: | net.java.dev.jna.users | |
See comments below.
On Feb 29, 2008, at 10:08 AM, Timothy Wall wrote:
(Forwarded to JNA users list on behalf of Mr Hackett)
Begin forwarded message:
From: mark...@metoffice.gov.uk [mailto:mark...@metoffice.gov.uk] Sent: Friday, February 29, 2008 6:09 PM To: feed...@java-net.dev.java.net Subject: RE: https://jna.dev.java.net/#demos
It may be I need to show you where the issue is, so here's the simplest example from your docs:
4. Declare a Java interface to hold the native library methods by extending the Library interface. Following is an example of mapping for the Windows kernel32 library.
package com.sun.jna.examples.win32;
import com.sun.jna.*;
// kernel32.dll uses the __stdcall calling convention (check the function // declaration for "WINAPI"), so extend StdCallLibrary // Most C libraries will just extend com.sun.jna.Library, public interface Kernel32 extends StdCallLibrary { // Method declarations, constant and structure definitions go here }
If the comment about "__stdcall ==> StdCallLibrary, anything else ==> Library" isn't clear, feel free to suggest alternatives. I didn't score a perfect 800 on my SAT verbal.
5. In your interface, allocate an instance of the native library using the Native.loadLibrary(Class) method, providing the native library interface you defined in step (4).
Kernel32 INSTANCE = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class);
[OK, so where does it go? there's no other declaration of what class/interface/doodad but it doesn't go inside the declaration of #4.]
"5. In your interface, ..." ? The interface declaration of #4 is the item under discussion, so the INSTANCE field *does* go inside that declaration. Suggestions for improved wording are welcome.
6. Declare methods that mirror the functions in the target library by defining Java methods with the same name and argument types as the native function
public static class SYSTEMTIME extends Structure { public short wYear; public short wMonth; public short wDayOfWeek; public short wDay; public short wHour; public short wMinute; public short wSecond; public short wMilliseconds; }
[and where does this go? Nothing said. New class? New interface? Same as #5 (compounding the questions for #5...)]
Same as #5, although this is not absolutely required. If you follow the overview in the Javadoc API, the "Structure" section describes the definition placement. Again, you're welcome to submit improvements.
7. You can now invoke methods on the library instance just like any other Java class. For a more extensive example, see the WindowUtils and ShapedWindowDemo classes.
[Yeah, but the class I did look at (FileMonitor, 'cos I'm on linux), it doesn't call Native.loadLibrary. So that doesn't answer my queries above]
Those are examples of *using* library mappings. Examples of library mappings themselves are Kernel32, User32, X11, Xrender, et al. and are often platform-specific.








.html