Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
7214d2111a8d86f5b185deba29e35cb8c9e1f3cb
[simgrid.git] / src / jmsg_task.c
1 /* Functions related to the java task instances.                            */
2
3 /* Copyright (c) 2007, 2009, 2010. The SimGrid Team.
4  * All rights reserved.                                                     */
5
6 /* This program is free software; you can redistribute it and/or modify it
7   * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #include "jmsg.h"
10 #include "jmsg_task.h"
11 #include "jxbt_utilities.h"
12
13 void jtask_bind(jobject jtask, m_task_t task, JNIEnv * env)
14 {
15   jfieldID id = jxbt_get_sfield(env, "simgrid/msg/Task", "bind", "J");
16
17   if (!id)
18     return;
19
20   (*env)->SetLongField(env, jtask, id, (jlong) (long) (task));
21 }
22
23 m_task_t jtask_to_native_task(jobject jtask, JNIEnv * env)
24 {
25   jfieldID id = jxbt_get_sfield(env, "simgrid/msg/Task", "bind", "J");
26
27   if (!id)
28     return NULL;
29
30   return (m_task_t) (long) (*env)->GetLongField(env, jtask, id);
31 }
32
33 jboolean jtask_is_valid(jobject jtask, JNIEnv * env)
34 {
35   jfieldID id = jxbt_get_sfield(env, "simgrid/msg/Task", "bind", "J");
36
37   if (!id)
38     return JNI_FALSE;
39
40   return (*env)->GetLongField(env, jtask, id) ? JNI_TRUE : JNI_FALSE;
41 }