]> rtime.felk.cvut.cz Git - orte.git/blob - orte/libjorte/createSubInfo.c
d9190042b7d1e3815f49546808b5eb88153c1d4e
[orte.git] / orte / libjorte / createSubInfo.c
1 /* createSubInfo.c  */
2
3 #include <jni.h>
4 #include "orte.h"
5 #include "jorte/4all.h"
6 #include "jorte/jorte_protos_api.h"
7
8 jobject createSubInfo(JNIEnv *env, const ORTESubInfo *sinfo)
9 {
10   jclass    cls;
11   jobject   obj;
12   jmethodID mid;
13
14   //
15   int flag_ok = 0;
16
17   do
18   {
19     // find cls
20     cls = findClass(env, "org.ocera.orte.types.SubInfo");
21     if(cls == 0)
22     {
23       #ifdef TEST_STAGE
24         printf(":!c: cls = NULL \n");
25       #endif
26       break;
27     }
28     // call object constructor
29     mid = (*env)->GetMethodID(env, cls, "<init>", "()V");
30     if(mid == 0)
31     {
32       #ifdef TEST_STAGE
33         printf(":!c: constructor failed! \n");
34       #endif
35       break;
36     }
37     // create new object
38     obj = (*env)->NewObject(env, cls, mid);
39     if(obj == 0)
40     {
41       #ifdef TEST_STAGE
42         printf(":!c: obj = NULL \n");
43       #endif
44       break;
45     }
46 /////////////////////////////////////////////////
47     // set topic
48     if(!setTopic(env,cls,obj,sinfo->topic))
49     {
50       #ifdef TEST_STAGE
51         printf(":!c: seTopic() failed! \n");
52       #endif
53       break;
54     }
55     // set type
56     if(!setType(env,cls,obj,sinfo->type))
57     {
58       #ifdef TEST_STAGE
59         printf(":!c: seType() failed! \n");
60       #endif
61       break;
62     }
63 /////////////////////////////////////////////////
64
65     flag_ok = 1;
66   } while(0);
67
68   if(!flag_ok)
69   {
70     //detach...()
71     return NULL;
72   }
73
74 return obj;
75 }