]> rtime.felk.cvut.cz Git - frescor/frsh-forb.git/blob - src/forb/src/tests/executor_calls.c
Struct request adjusted for inter-executor invocation.
[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 #include <semaphore.h>
12
13 #include "myinterface.h"
14
15 #define ex_on_fail(command, ex) if (!(command)) do { ev->major = (ex); goto exception; } while(0)
16 #define FORB_REQEST_HDR_SIZE (forb_iop_MESSAGE_HEADER_SIZE + forb_iop_REQUEST_HEADER_SIZE)
17
18 #define _myinterface_impl(obj) ((struct forb_myinterface_impl*)(obj)->implementation)
19
20 CORBA_long myinterface_add(myinterface _obj, const CORBA_long a, const CORBA_long b, CORBA_Environment *ev)
21 {
22   CORBA_long _forb_retval;
23   forb_executor_t *exec_current;
24   if (ev) ev->major = FORB_EX_NONE;
25   /* local object */
26   if (forb_object_is_local(_obj) && !forb_get_current_executor(exec_current) && 
27                         (forb_object_get_executor(_obj) == exec_current)) {
28     if (!_obj->interface ||
29         strncmp(_obj->interface->name, "myinterface", 11) != 0) {
30       ev->major = FORB_EX_BAD_OPERATION;
31       return _forb_retval;
32     }
33     /* direct invocation */
34     _forb_retval = _myinterface_impl(_obj)->add(_obj, a, b, ev);
35   } else {
36     /* remote object - the same as before */
37     unsigned index;
38     forb_request_t req;
39     ex_on_fail(forb_request_init(&req, _obj, "myinterface", FORB_METHOD_INDEX(myinterface_add)) == 0, FORB_EX_INTERNAL);
40     forb_iop_prepare_request(&req, &index, ev);
41     if (forb_exception_occurred(ev)) goto exception;
42     ex_on_fail(CORBA_long_serialize(&req.cdr_request, &a), FORB_EX_IMP_LIMIT);
43     ex_on_fail(CORBA_long_serialize(&req.cdr_request, &b), FORB_EX_IMP_LIMIT);
44     forb_request_send(&req, index, ev);
45     if (forb_exception_occurred(ev)) goto exception;
46     forb_request_wait_for_reply(&req);
47     if (forb_exception_occurred(ev)) goto exception;
48     CORBA_long_deserialize(req.cdr_reply, &_forb_retval);
49     forb_request_signal_processed(&req);
50 exception:
51     forb_request_destroy(&req);
52   }
53   return _forb_retval;
54 }
55