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 */
/* 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 */
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);
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