

![]() | 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: |
2 messages in net.java.dev.jna.usersRe: [jna-users] How to map a variable...| From | Sent On | Attachments |
|---|---|---|
| Mélanie Bats | Jun 25, 2009 8:58 am | |
| Timothy Wall | Jun 25, 2009 10:38 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] How to map a variable argument list? | Actions... |
|---|---|---|
| From: | Timothy Wall (twal...@dev.java.net) | |
| Date: | Jun 25, 2009 10:38:38 am | |
| List: | net.java.dev.jna.users | |
On Jun 25, 2009, at 11:59 AM, Mélanie Bats wrote:
Hello,
I need to map a C function of the Statemate API that contains a variable
argument list to Java function.
In the Statemate API documentation, the C function is defined as :
Call the following function to create a list of Statemate elements :
stm_list_create (e1, e2,..., end_of_list, &status);
In this syntax:
* e1 and e2 The element IDs that constitute the list. They are of type
stm_id which is defined in h file to :
typedef long long stm_id;
* end_of_list A constant, defined in dataport.h, that signifies the end
of the parameter sequence of list items. In the h file the constant is
defined like this :
#define end_of_list ((char *)-1) /* end of parameter list in function */
final Pointer end_of_list = Pointer.createConstant(-1);
/* stm_create_list */
* status The function return status.
* the function will return a stm_list defined in h file to :
typedef char *stm_list; /* general structure of lists */
Use a Pointer or PointerType until you need something more specific.
A sample of usage of this function could be :
stm_id act_id; stm_list list; int status; // Get the id of the element A1
defined in model
act_id = stm_r_ac("A1", &status); // Create a list that contains one
element which is A1
list = stm_list_create(act_id, end_of_list, &status);
I tried to map the function to :
String[] stm_list_create(long[] ac_id, IntByReference status);
This is the same as passing "int64_t*, int*", which will fail. You can use Java varags, e.g.
Pointer stm_list_create(long e1, long e2, Object...);
Then you call it the same way you would in C, passing your flag and ByReference status at the end.
and to call it :
long act_id = StatemateDataPortLibrary.INSTANCE.stm_r_ac("TOP_CHART",
status);
long[] var_args = { act_id, -1 };
String[] mylist =
StatemateDataPortLibrary.INSTANCE.stm_list_create(var_args, status);
but it generates an error... EXCEPTION_ACCESS_VIOLATION.
Does somebody know how to do this?
Thanks for your help,
Mélanie







