]> rtime.felk.cvut.cz Git - frescor/frsh-forb.git/blob - src/forb/src/tests/executor_calls.c
896c2d9a1f1db4a91f17d8b37748a03521854081
[frescor/frsh-forb.git] / src / forb / src / tests / executor_calls.c
1 /*
2  * This file was generated by forb-idl but now it is a test
3  */
4
5 #include <string.h>
6 #include <forb/forb-internal.h>
7 #include <forb/request.h>
8 #include <forb/iop.h>
9 #include <forb/cdr.h>
10 #include <forb/object.h>
11
12 #include "myinterface.h"
13
14 #define ex_on_fail(command, ex) if (!(command)) do { ev->major = (ex); goto exception; } while(0)
15 #define FORB_REQEST_HDR_SIZE (forb_iop_MESSAGE_HEADER_SIZE + forb_iop_REQUEST_HEADER_SIZE)
16
17 #define _myinterface_impl(obj) ((struct forb_myinterface_impl*)(obj)->implementation)
18
19 CORBA_long myinterface_add(myinterface _obj, const CORBA_long a, const CORBA_long b, CORBA_Environment *ev)
20 {
21   CORBA_long _forb_retval;
22   executor *exec_current;
23   if (ev) ev->major = FORB_EX_NONE;
24   /* local object */
25   if (forb_object_is_local(_obj)) {
26     if (!_obj->interface ||
27         strncmp(_obj->interface->name, "myinterface", 11) != 0) {
28       ev->major = FORB_EX_BAD_OPERATION;
29       return _forb_retval;
30     }
31     if (!forb_get_current_executor(exec_current) && (forb_object_get_executor(_obj) == exec_current))
32       /* direct invocation */
33       _forb_retval = _myinterface_impl(_obj)->add(_obj, a, b, ev);
34     } else {
35       /* TODO inter-thread invocation*/
36     }
37   } else {
38     /* remote object - the same as before */
39     forb_request_t req;
40     ex_on_fail(forb_request_init(&req, _obj) == 0, FORB_EX_INTERNAL);
41     forb_iop_prepare_request(&req, "myinterface", FORB_METHOD_INDEX(myinterface_add), ev);
42     if (forb_exception_occurred(ev)) goto exception;
43     ex_on_fail(CORBA_long_serialize(&req.cdr_request, &a), FORB_EX_IMP_LIMIT);
44     ex_on_fail(CORBA_long_serialize(&req.cdr_request, &b), FORB_EX_IMP_LIMIT);
45     forb_request_send(&req, ev);
46     if (forb_exception_occurred(ev)) goto exception;
47     forb_request_wait_for_reply(&req);
48     if (forb_exception_occurred(ev)) goto exception;
49     CORBA_long_deserialize(req.cdr_reply, &_forb_retval);
50     forb_request_signal_processed(&req);
51 exception:
52     forb_request_destroy(&req);
53   }
54   return _forb_retval;
55 }
56