]> rtime.felk.cvut.cz Git - frescor/forb.git/blob - src/tests/executor_calls.c
forb: End of header index removed from stub.
[frescor/forb.git] / 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     forb_request_t req;
38     ex_on_fail(forb_request_init(&req, _obj, "myinterface", FORB_METHOD_INDEX(myinterface_add)) == 0, FORB_EX_INTERNAL);
39     forb_iop_prepare_request(&req, ev);
40     if (forb_exception_occurred(ev)) goto exception;
41     ex_on_fail(CORBA_long_serialize(&req.cdr_request, &a), FORB_EX_IMP_LIMIT);
42     ex_on_fail(CORBA_long_serialize(&req.cdr_request, &b), FORB_EX_IMP_LIMIT);
43     forb_request_send(&req, ev);
44     if (forb_exception_occurred(ev)) goto exception;
45     forb_request_wait_for_reply(&req);
46     if (forb_exception_occurred(ev)) goto exception;
47     CORBA_long_deserialize(req.cdr_reply, &_forb_retval);
48     forb_request_signal_processed(&req);
49 exception:
50     forb_request_destroy(&req);
51   }
52   return _forb_retval;
53 }
54