3
#include "orbit-idl-c-backend.h"
10
} CBESkelInterfaceTraverseInfo;
19
static void ck_output_skels(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci, int *idx);
20
static void ck_output_poastuff(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci);
23
orbit_idl_output_c_skeletons(OIDL_Output_Tree *tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci)
25
fprintf(ci->fh, "/*\n"
26
" * This file was generated by orbit-idl - DO NOT EDIT!\n"
28
fprintf(ci->fh, "#include <string.h>\n");
29
fprintf(ci->fh, "#define ORBIT2_STUBS_API\n");
30
fprintf(ci->fh, "#include \"%s.h\"\n\n", ci->base_name);
32
ck_output_skels(tree->tree, rinfo, ci, NULL);
33
ck_output_poastuff(tree->tree, rinfo, ci);
36
static void ck_output_skel(IDL_tree tree, OIDL_C_Info *ci);
37
static void ck_output_small_skel(IDL_tree tree, OIDL_C_Info *ci, int *idx);
38
static void ck_output_except(IDL_tree tree, OIDL_C_Info *ci);
41
ck_output_skels(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci, int *idx)
43
if ( !tree || (tree->declspec & IDLF_DECLSPEC_PIDL) )
47
switch(IDL_NODE_TYPE(tree)) {
49
ck_output_skels(IDL_MODULE(tree).definition_list, rinfo, ci, idx);
54
for(sub = tree; sub; sub = IDL_LIST(sub).next) {
55
ck_output_skels(IDL_LIST(sub).data, rinfo, ci, idx);
61
OIDL_Attr_Info *ai = tree->data;
65
for(curitem = IDL_ATTR_DCL(tree).simple_declarations; curitem; curitem = IDL_LIST(curitem).next) {
66
ai = IDL_LIST(curitem).data->data;
68
ck_output_skels(ai->op1, rinfo, ci, idx);
70
ck_output_skels(ai->op2, rinfo, ci, idx);
74
case IDLN_INTERFACE: {
76
ck_output_skels(IDL_INTERFACE(tree).body, rinfo, ci, &real_idx);
80
if (rinfo->small_skels)
81
ck_output_small_skel(tree, ci, idx);
83
ck_output_skel(tree, ci);
86
if (!rinfo->small_skels)
87
ck_output_except(tree, ci);
96
cbe_print_var_dcl(FILE *of, IDL_tree tree)
98
IDL_tree rawts = NULL /* Quiet gcc */, ts;
99
IDL_ParamRole role = 0 /* Quiet gcc */;
100
gchar *id = NULL /* Quiet gcc */, *ts_str;
104
if (IDL_NODE_TYPE(tree) == IDLN_OP_DCL) {
105
rawts = IDL_OP_DCL(tree).op_type_spec;
107
id = "_ORBIT_retval";
108
} else if (IDL_NODE_TYPE(tree) == IDLN_PARAM_DCL) {
109
rawts = IDL_PARAM_DCL(tree).param_type_spec;
110
role = oidl_attr_to_paramrole(IDL_PARAM_DCL(tree).attr);
111
id = IDL_IDENT(IDL_PARAM_DCL(tree).simple_declarator).str;
113
g_error("Unexpected tree node");
115
ts = orbit_cbe_get_typespec( rawts );
116
ts_str = orbit_cbe_get_typespec_str(ts);
117
n = oidl_param_info(ts, role, &isSlice);
119
if ( IDL_NODE_TYPE(ts)==IDLN_TYPE_ARRAY )
123
fprintf(of, "%s %s;\n", ts_str, id);
126
fprintf(of, "%s_slice *%s;\n", ts_str, id);
129
fprintf(of, "%s_slice *_ref_%s; %s_slice **%s = &_ref_%s;\n", ts_str, id, ts_str, id, id);
138
fprintf(of, "%s %s;\n", ts_str, id);
141
if ( role == DATA_RETURN)
142
fprintf(of, "%s *%s;\n", ts_str, id);
144
fprintf(of, "%s _val_%s; %s *%s = &_val_%s;\n", ts_str, id, ts_str, id, id);
147
fprintf(of, "%s *_ref_%s; %s **%s = &_ref_%s;\n", ts_str, id, ts_str, id, id);
150
g_assert_not_reached();
158
cbe_skel_op_dcl_print_call_param(IDL_tree tree, OIDL_C_Info *ci)
160
gchar *id = IDL_IDENT(IDL_PARAM_DCL(tree).simple_declarator).str;
163
ts = orbit_cbe_get_typespec(IDL_PARAM_DCL(tree).param_type_spec);
164
if ( IDL_NODE_TYPE(ts)==IDLN_TYPE_ARRAY
165
&& IDL_PARAM_DCL(tree).attr == IDL_PARAM_IN) {
166
gchar *ts_str = orbit_cbe_get_typespec_str(ts);
167
fprintf(ci->fh, "(const %s_slice*)", ts_str);
170
fprintf(ci->fh, "%s", id);
173
static void cbe_skel_op_params_free(IDL_tree tree, OIDL_C_Info *ci);
174
static void cbe_skel_op_dcl_print_call_param(IDL_tree tree, OIDL_C_Info *ci);
177
ck_output_skel(IDL_tree tree, OIDL_C_Info *ci)
179
char *opname, *ifname;
180
IDL_tree intf, curitem;
183
intf = IDL_get_parent_node(tree, IDLN_INTERFACE, NULL);
185
opname = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_OP_DCL(tree).ident), "_", 0);
186
ifname = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(intf).ident), "_", 0);
188
fprintf(ci->fh, "void _ORBIT_skel_%s(POA_%s * _ORBIT_servant, GIOPRecvBuffer *_ORBIT_recv_buffer, CORBA_Environment *ev, ",
190
orbit_cbe_op_write_proto(ci->fh, tree, "_impl_", TRUE);
191
fprintf(ci->fh, ")\n");
192
fprintf(ci->fh, "{\n");
193
fprintf(ci->fh, "register guchar *_ORBIT_buf_end G_GNUC_UNUSED = _ORBIT_recv_buffer->end;\n");
197
if(IDL_OP_DCL(tree).op_type_spec)
198
cbe_print_var_dcl(ci->fh, tree);
199
for(curitem = IDL_OP_DCL(tree).parameter_dcls; curitem; curitem = IDL_LIST(curitem).next) {
200
IDL_tree param = IDL_LIST(curitem).data;
201
cbe_print_var_dcl(ci->fh, param);
204
if(IDL_OP_DCL(tree).context_expr)
205
fprintf(ci->fh, "struct CORBA_Context_type _ctx;\n");
208
fprintf(ci->fh, "{ /* demarshalling */\n");
209
fprintf(ci->fh, "register guchar *_ORBIT_curptr G_GNUC_UNUSED;\n");
211
orbit_cbe_alloc_tmpvars(oi->in_skels, ci);
212
c_demarshalling_generate(oi->in_skels, ci, TRUE, FALSE);
214
fprintf(ci->fh, "}\n");
217
if(IDL_OP_DCL(tree).op_type_spec)
218
fprintf(ci->fh, "_ORBIT_retval = ");
219
fprintf(ci->fh, "_impl_%s(_ORBIT_servant, ", IDL_IDENT(IDL_OP_DCL(tree).ident).str);
220
for(curitem = IDL_OP_DCL(tree).parameter_dcls; curitem; curitem = IDL_LIST(curitem).next) {
221
cbe_skel_op_dcl_print_call_param(IDL_LIST(curitem).data, ci);
222
fprintf(ci->fh, ", ");
224
if(IDL_OP_DCL(tree).context_expr)
225
fprintf(ci->fh, "&_ctx, ");
226
fprintf(ci->fh, "ev);\n");
228
if(!IDL_OP_DCL(tree).f_oneway) {
229
fprintf(ci->fh, "{ /* marshalling */\n");
230
fprintf(ci->fh, "register GIOPSendBuffer *_ORBIT_send_buffer;\n");
232
fprintf(ci->fh, "_ORBIT_send_buffer = giop_send_buffer_use_reply(_ORBIT_recv_buffer->connection->giop_version,"
233
"giop_recv_buffer_get_request_id(_ORBIT_recv_buffer), ev->_major);\n");
235
fprintf(ci->fh, "if(_ORBIT_send_buffer) {\n");
236
fprintf(ci->fh, "if (ev->_major == CORBA_NO_EXCEPTION) {\n");
237
orbit_cbe_alloc_tmpvars(oi->out_skels, ci);
239
c_marshalling_generate(oi->out_skels, ci, TRUE);
241
if(IDL_OP_DCL(tree).raises_expr) {
244
fprintf(ci->fh, "} else if (ev->_major == CORBA_USER_EXCEPTION) { \n");
245
fprintf(ci->fh, "static const ORBit_exception_marshal_info _ORBIT_user_exceptions[] = { ");
246
for(curitem = IDL_OP_DCL(tree).raises_expr; curitem;
247
curitem = IDL_LIST(curitem).next) {
249
IDL_tree curnode = IDL_LIST(curitem).data;
251
id = orbit_cbe_get_typespec_str(curnode);
252
fprintf(ci->fh, "{(const CORBA_TypeCode)&TC_%s_struct, (gpointer)_ORBIT_%s_marshal},",
257
fprintf(ci->fh, "{CORBA_OBJECT_NIL, NULL}};\n");
258
fprintf(ci->fh, "ORBit_send_user_exception(_ORBIT_send_buffer, ev, _ORBIT_user_exceptions);\n");
261
fprintf(ci->fh, "} else\n");
262
fprintf(ci->fh, "ORBit_send_system_exception(_ORBIT_send_buffer, ev);\n");
264
fprintf(ci->fh, "giop_send_buffer_write(_ORBIT_send_buffer, _ORBIT_recv_buffer->connection);\n");
265
fprintf(ci->fh, "giop_send_buffer_unuse(_ORBIT_send_buffer);\n");
266
fprintf(ci->fh, "}\n");
268
fprintf(ci->fh, "}\n");
271
cbe_skel_op_params_free(tree, ci);
273
fprintf(ci->fh, "}\n");
280
ck_output_small_skel(IDL_tree tree, OIDL_C_Info *ci, int *idx)
282
char *opname, *ifname;
284
gboolean has_args, has_retval;
286
g_return_if_fail (idx != NULL);
288
intf = IDL_get_parent_node(tree, IDLN_INTERFACE, NULL);
289
has_args = IDL_OP_DCL(tree).parameter_dcls != NULL;
290
has_retval = IDL_OP_DCL(tree).op_type_spec != NULL;
292
opname = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_OP_DCL(tree).ident), "_", 0);
293
ifname = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(intf).ident), "_", 0);
295
fprintf(ci->fh, "void _ORBIT_skel_small_%s("
296
"POA_%s *_o_servant, "
297
"gpointer _o_retval,"
299
"CORBA_Context _o_ctx,"
300
"CORBA_Environment *_o_ev,\n", opname, ifname);
301
orbit_cbe_op_write_proto(ci->fh, tree, "_impl_", TRUE);
302
fprintf(ci->fh, ")\n");
303
fprintf(ci->fh, "{\n");
306
fprintf(ci->fh, "*(");
307
orbit_cbe_write_param_typespec(ci->fh, tree);
308
fprintf(ci->fh, " *)_o_retval = ");
311
fprintf(ci->fh, "_impl_%s(_o_servant, ", IDL_IDENT(IDL_OP_DCL(tree).ident).str);
313
cbe_small_unflatten_args (tree, ci->fh, "_o_args");
315
if(IDL_OP_DCL(tree).context_expr)
316
fprintf(ci->fh, "_o_ctx, ");
318
fprintf(ci->fh, "_o_ev);\n");
320
fprintf (ci->fh, "}\n");
329
ck_output_except(IDL_tree tree, OIDL_C_Info *ci)
332
OIDL_Except_Info *ei;
337
id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_EXCEPT_DCL(tree).ident), "_", 0);
339
fprintf(ci->fh, "void\n_ORBIT_%s_marshal(GIOPSendBuffer *_ORBIT_send_buffer, CORBA_Environment *ev)\n", id);
340
fprintf(ci->fh, "{\n");
341
if(IDL_EXCEPT_DCL(tree).members) {
342
orbit_cbe_alloc_tmpvars(ei->demarshal, ci);
343
fprintf(ci->fh, "%s *_ORBIT_exdata = ev->_any._value;\n", id);
344
c_marshalling_generate(ei->marshal, ci, FALSE);
347
fprintf(ci->fh, "}\n");
353
NOTE: we no longer use {free_internal}. Instead, any data we
354
do not want to free is tagged as such at run-time
355
at the time we reference it.
356
See ORBit/docs/orbit-mem2.txt.
359
cbe_skel_param_subfree(IDL_tree tree, OIDL_C_Info *ci)
363
if(IDL_NODE_TYPE(tree) != IDLN_PARAM_DCL) {
364
id = orbit_cbe_get_typespec_str(tree);
365
varname = "_ORBIT_retval";
367
id = orbit_cbe_get_typespec_str(IDL_PARAM_DCL(tree).param_type_spec);
368
varname = IDL_IDENT(IDL_PARAM_DCL(tree).simple_declarator).str;
370
fprintf(ci->fh, "%s__freekids(%s, NULL);\n", id, varname);
375
cbe_op_retval_free(IDL_tree tree, OIDL_C_Info *ci)
379
ts = orbit_cbe_get_typespec(tree);
381
switch(IDL_NODE_TYPE(ts)) {
382
case IDLN_TYPE_UNION:
383
case IDLN_TYPE_STRUCT:
384
if(orbit_cbe_type_is_fixed_length(ts))
386
case IDLN_TYPE_SEQUENCE:
387
case IDLN_TYPE_STRING:
388
case IDLN_TYPE_ARRAY:
391
case IDLN_TYPE_OBJECT:
393
case IDLN_FORWARD_DCL:
394
fprintf(ci->fh, "CORBA_Object_release(" ORBIT_RETVAL_VAR_NAME ", ev);\n");
399
fprintf(ci->fh, "CORBA_free(" ORBIT_RETVAL_VAR_NAME ");\n");
403
cbe_skel_op_param_has_sequence(IDL_tree ts)
405
gboolean has_seq = FALSE, subhas;
406
IDL_tree curitem, sn;
408
ts = orbit_cbe_get_typespec(ts);
410
switch(IDL_NODE_TYPE(ts)) {
411
case IDLN_TYPE_UNION:
412
for(curitem = IDL_TYPE_UNION(ts).switch_body; curitem;
413
curitem = IDL_LIST(curitem).next) {
414
sn = IDL_MEMBER(IDL_CASE_STMT(IDL_LIST(curitem).data).element_spec).type_spec;
415
subhas = cbe_skel_op_param_has_sequence(sn);
416
has_seq = has_seq || subhas;
420
case IDLN_TYPE_STRUCT:
421
for(curitem = IDL_TYPE_STRUCT(ts).member_list; curitem;
422
curitem = IDL_LIST(curitem).next) {
423
sn = IDL_MEMBER(IDL_LIST(curitem).data).type_spec;
424
subhas = cbe_skel_op_param_has_sequence(sn);
425
has_seq = has_seq || subhas;
429
case IDLN_TYPE_ARRAY:
430
return cbe_skel_op_param_has_sequence(IDL_TYPE_DCL(IDL_get_parent_node(ts, IDLN_TYPE_DCL, NULL)).type_spec);
432
case IDLN_TYPE_SEQUENCE:
440
cbe_op_param_free(IDL_tree tree, OIDL_C_Info *ci, gboolean is_skels)
444
ts = orbit_cbe_get_typespec(tree);
445
if ( orbit_cbe_type_is_fixed_length(ts) )
448
switch(IDL_PARAM_DCL(tree).attr) {
451
switch(IDL_NODE_TYPE(ts)) {
452
case IDLN_TYPE_UNION:
453
case IDLN_TYPE_STRUCT:
454
case IDLN_TYPE_ARRAY:
456
case IDLN_TYPE_SEQUENCE:
457
/* ANY and SEQUENCE always have allocated sub-memory that must
458
* be freed, regardless of the underlying types */
459
cbe_skel_param_subfree(tree, ci);
461
case IDLN_TYPE_OBJECT:
463
case IDLN_FORWARD_DCL:
464
fprintf(ci->fh, "CORBA_Object_release(%s, ev);\n",
465
IDL_IDENT(IDL_PARAM_DCL(tree).simple_declarator).str);
472
switch(IDL_NODE_TYPE(ts)) {
473
case IDLN_TYPE_OBJECT:
475
fprintf(ci->fh, "CORBA_Object_release(*%s, ev);\n",
476
IDL_IDENT(IDL_PARAM_DCL(tree).simple_declarator).str);
479
fprintf(ci->fh, "CORBA_free(*%s);\n",
480
IDL_IDENT(IDL_PARAM_DCL(tree).simple_declarator).str);
483
case IDL_PARAM_INOUT:
484
switch(IDL_NODE_TYPE(ts)) {
485
case IDLN_TYPE_OBJECT:
487
fprintf(ci->fh, "CORBA_Object_release(*%s, ev);\n",
488
IDL_IDENT(IDL_PARAM_DCL(tree).simple_declarator).str);
491
cbe_skel_param_subfree(tree, ci);
500
cbe_skel_op_params_free(IDL_tree tree, OIDL_C_Info *ci)
504
/* We have to free the params from last to first */
505
fprintf(ci->fh, "if(ev->_major == CORBA_NO_EXCEPTION)\n{\n");
506
for(curitem = IDL_list_nth(IDL_OP_DCL(tree).parameter_dcls, IDL_list_length(IDL_OP_DCL(tree).parameter_dcls) - 1);
507
curitem; curitem = IDL_LIST(curitem).prev)
511
param = IDL_LIST(curitem).data;
512
if(IDL_PARAM_DCL(param).attr == IDL_PARAM_OUT)
513
cbe_op_param_free(param, ci, TRUE);
516
if(IDL_OP_DCL(tree).op_type_spec)
517
cbe_op_retval_free(IDL_OP_DCL(tree).op_type_spec, ci);
518
fprintf(ci->fh, "}\n");
520
/* Concious decision made to not send back an exception to report the problem - if they are sending us total junk,
521
then it is probably not even a compliant ORB that needs to know. The real reason is that it would complicate the
522
code a lot, just to handle this corner case */
523
if(IDL_OP_DCL(tree).context_expr)
524
fprintf(ci->fh, "_context_demarshal_error: ORBit_Context_server_free(&_ctx);\n");
525
for(curitem = IDL_list_nth(IDL_OP_DCL(tree).parameter_dcls, IDL_list_length(IDL_OP_DCL(tree).parameter_dcls) - 1);
526
curitem; curitem = IDL_LIST(curitem).prev)
530
param = IDL_LIST(curitem).data;
531
if(IDL_PARAM_DCL(param).attr != IDL_PARAM_OUT)
533
fprintf(ci->fh, "%s_demarshal_error:\n", IDL_IDENT(IDL_PARAM_DCL(param).simple_declarator).str);
534
cbe_op_param_free(param, ci, TRUE);
537
if(IDL_OP_DCL(tree).parameter_dcls)
538
fprintf(ci->fh, "_ORBIT_demarshal_error:\n");
542
/*****************************************/
543
static void cbe_skel_do_interface(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci);
546
ck_output_poastuff(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci)
548
if( !tree || (tree->declspec & IDLF_DECLSPEC_PIDL)!=0 )
551
switch(IDL_NODE_TYPE(tree)) {
553
ck_output_poastuff(IDL_MODULE(tree).definition_list, rinfo, ci);
558
for(sub = tree; sub; sub = IDL_LIST(sub).next) {
559
ck_output_poastuff(IDL_LIST(sub).data, rinfo, ci);
564
cbe_skel_do_interface(tree, rinfo, ci);
571
/* Blatantly copied from the old IDL compiler. (A few fixes to the
572
get_skel generation stuff to do proper checking of the opname...) */
576
cbe_skel_print_skelptr(FILE *of, IDL_tree tree)
581
switch(IDL_NODE_TYPE(tree)) {
583
id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_OP_DCL(tree).ident),
585
fprintf(of, " skel_%s,\n", id);
588
id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(IDL_get_parent_node(tree, IDLN_INTERFACE, NULL)).ident),
590
for(curitem = IDL_ATTR_DCL(tree).simple_declarations;
591
curitem; curitem = IDL_LIST(curitem).data) {
592
fprintf(of, " skel_%s__get_%s,\n", id,
593
IDL_IDENT(IDL_LIST(curitem).data).str);
594
if(!IDL_ATTR_DCL(tree).f_readonly)
595
fprintf(of, " skel_%s__set_%s,\n", id,
596
IDL_IDENT(IDL_LIST(curitem).data).str);
607
cbe_skel_compare_op_dcls(CBESkelOpInfo *op1, CBESkelOpInfo *op2)
609
return strcmp(op1->opname, op2->opname);
613
cbe_skel_free_op_info(CBESkelOpInfo *op)
616
g_free(op->iface_id);
621
cbe_skel_interface_add_relayer(IDL_tree intf, CBESkelInterfaceTraverseInfo *iti)
623
CBESkelOpInfo *newopi;
624
IDL_tree curitem, curdcl, curattr, curattrdcl;
629
IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(intf).ident),
632
for(curitem = IDL_INTERFACE(intf).body; curitem;
633
curitem = IDL_LIST(curitem).next) {
634
curdcl = IDL_LIST(curitem).data;
636
switch(IDL_NODE_TYPE(curdcl)) {
638
newopi = g_new0(CBESkelOpInfo, 1);
639
newopi->iface_id = g_strdup(iface_id);
640
newopi->opname = g_strdup(IDL_IDENT(IDL_OP_DCL(curdcl).ident).str);
642
iti->oplist = g_slist_insert_sorted(iti->oplist, newopi,
643
(GCompareFunc)cbe_skel_compare_op_dcls);
646
for(curattr = IDL_ATTR_DCL(curdcl).simple_declarations;
647
curattr; curattr = IDL_LIST(curattr).next) {
648
curattrdcl = IDL_LIST(curattr).data;
650
newopi = g_new0(CBESkelOpInfo, 1);
651
newopi->iface_id = g_strdup(iface_id);
652
newopi->opname = g_strdup_printf("_get_%s", IDL_IDENT(curattrdcl).str);
654
iti->oplist = g_slist_insert_sorted(iti->oplist, newopi,
655
(GCompareFunc)cbe_skel_compare_op_dcls);
656
if(!IDL_ATTR_DCL(curdcl).f_readonly) {
657
newopi = g_new0(CBESkelOpInfo, 1);
658
newopi->iface_id = g_strdup(iface_id);
659
newopi->opname = g_strdup_printf("_set_%s", IDL_IDENT(curattrdcl).str);
661
iti->oplist = g_slist_insert_sorted(iti->oplist, newopi,
662
(GCompareFunc)cbe_skel_compare_op_dcls);
675
cbe_skel_interface_print_relayers(const CBESkelInterfaceTraverseInfo *iti)
677
CBESkelInterfaceTraverseInfo subiti = *iti;
682
curnode = iti->oplist;
683
subiti.curlevel = iti->curlevel+1;
684
fprintf(iti->ci->fh, "switch(opname[%d]) {\n", iti->curlevel);
686
opi = (CBESkelOpInfo *)curnode->data;
687
if(iti->curlevel > strlen(opi->opname)) {
688
curnode = g_slist_next(curnode);
691
curchar = opi->opname[iti->curlevel];
693
fprintf(iti->ci->fh, "case '%c':\n", curchar);
695
fprintf(iti->ci->fh, "case '\\0':\n");
696
subiti.oplist = NULL;
697
while(curnode && ((CBESkelOpInfo *)curnode->data)->opname[iti->curlevel]
699
subiti.oplist = g_slist_append(subiti.oplist, curnode->data);
700
curnode = g_slist_next(curnode);
703
if(g_slist_length(subiti.oplist) > 1) {
705
cbe_skel_interface_print_relayers(&subiti);
707
g_error("two ops with same name!!!!");
709
if(strlen(opi->opname + iti->curlevel))
710
fprintf(iti->ci->fh, "if(strcmp((opname + %d), \"%s\")) break;\n",
711
iti->curlevel + 1, opi->opname + iti->curlevel+1);
712
fprintf(iti->ci->fh, "*impl = (gpointer)servant->vepv->%s_epv->%s;\n",
713
opi->iface_id, opi->opname);
715
fprintf(iti->ci->fh, "*m_data = (gpointer)&%s__iinterface.methods._buffer [%d];\n",
716
opi->iface_id, opi->idx);
717
fprintf(iti->ci->fh, "return (ORBitSmallSkeleton)_ORBIT_skel_small_%s_%s;\n",
718
opi->iface_id, opi->opname);
720
fprintf(iti->ci->fh, "return (ORBitSkeleton)_ORBIT_skel_%s_%s;\n",
721
opi->iface_id, opi->opname);
723
fprintf(iti->ci->fh, "break;\n");
724
g_slist_free(subiti.oplist);
726
fprintf(iti->ci->fh, "default: break; \n}\n");
730
cbe_skel_interface_print_relayer(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci)
733
CBESkelInterfaceTraverseInfo iti;
735
id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(tree).ident), "_", 0);
736
if (rinfo->small_skels) {
737
fprintf(ci->fh, "static ORBitSmallSkeleton get_skel_small_%s(POA_%s *servant,\nconst char *opname,"
738
"gpointer *m_data, gpointer *impl)\n{\n", id, id);
740
fprintf(ci->fh, "static ORBitSkeleton get_skel_%s(POA_%s *servant,\nGIOPRecvBuffer *_ORBIT_recv_buffer,\ngpointer *impl)\n{\n", id, id);
741
fprintf(ci->fh, "gchar *opname = giop_recv_buffer_get_opname(_ORBIT_recv_buffer);\n\n");
747
iti.small = rinfo->small_skels;
749
IDL_tree_traverse_parents(tree,
750
(GFunc)cbe_skel_interface_add_relayer, &iti);
752
cbe_skel_interface_print_relayers(&iti);
754
g_slist_foreach(iti.oplist, (GFunc)cbe_skel_free_op_info, NULL);
755
g_slist_free(iti.oplist);
757
fprintf(ci->fh, "return NULL;\n");
758
fprintf(ci->fh, "}\n\n");
765
cbe_skel_interface_print_initializer(IDL_tree node,
770
g_assert(IDL_NODE_TYPE(node) == IDLN_INTERFACE);
772
/* Print the operations defined for this interface, but in current's
775
id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(node).ident),
778
fprintf(ci->fh, "obj->vepv[%s__classid] = servant->vepv->%s_epv;\n", id, id);
785
cbe_skel_interface_print_vepvmap_line(IDL_tree node, OIDL_C_Info *ci)
788
id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(node).ident),
790
fprintf(ci->fh, "class_info.vepvmap[%s__classid]"
791
" = (((char*)&(fakevepv->%s_epv)) - ((char*)(fakevepv)))/sizeof(GFunc);\n",
797
cbe_skel_do_interface(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci)
800
IDL_tree curitem, pnt;
803
/* PIDL methods dont have normal skel functions. */
804
for ( pnt=tree; pnt; pnt=IDL_NODE_UP(pnt) ) {
805
if ( pnt->declspec & IDLF_DECLSPEC_PIDL )
809
id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(tree).ident), "_", 0);
811
cbe_skel_interface_print_relayer(tree, rinfo, ci);
814
"void POA_%s__init(PortableServer_Servant servant,\nCORBA_Environment *env)\n",
816
fprintf(ci->fh, "{\n");
817
fprintf(ci->fh," static PortableServer_ClassInfo class_info = {");
819
if (rinfo->small_skels)
820
fprintf(ci->fh, "NULL, (ORBit_small_impl_finder)&get_skel_small_%s, ", id);
822
fprintf(ci->fh, "(ORBit_impl_finder)&get_skel_%s, NULL, ", id);
824
fprintf(ci->fh,"\"%s\", &%s__classid, NULL, &%s__iinterface};\n",
825
IDL_IDENT(IDL_INTERFACE(tree).ident).repo_id, id, id);
826
fprintf(ci->fh, " POA_%s__vepv *fakevepv = NULL;", id);
830
"((PortableServer_ServantBase*)servant)->vepv[0]->finalize";
831
fprintf(ci->fh, "if ( %s == 0 ) { ", finref);
832
fprintf(ci->fh, "%s = POA_%s__fini;\n", finref, id);
833
fprintf(ci->fh, "}\n");
836
" PortableServer_ServantBase__init(((PortableServer_ServantBase *)servant), env);\n");
838
for(curitem = IDL_INTERFACE(tree).inheritance_spec; curitem;
839
curitem = IDL_LIST(curitem).next) {
840
id2 = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_LIST(curitem).data),
842
fprintf(ci->fh, " POA_%s__init(servant, env);\n", id2);
845
/* registering after other __inits() makes the classids increment nicely. */
846
fprintf(ci->fh, " ORBit_classinfo_register(&class_info);\n");
847
/* Set classinfo after other __inits() for most derived interface. */
848
fprintf(ci->fh, " ORBIT_SERVANT_SET_CLASSINFO(servant,&class_info);\n");
849
fprintf(ci->fh, "\nif (!class_info.vepvmap) {\n");
850
fprintf(ci->fh, " class_info.vepvmap = g_new0 (ORBit_VepvIdx, %s__classid + 1);\n", id);
851
IDL_tree_traverse_parents(tree, (GFunc) cbe_skel_interface_print_vepvmap_line, ci);
852
fprintf(ci->fh, "}\n");
854
fprintf(ci->fh, "}\n\n");
857
"void POA_%s__fini(PortableServer_Servant servant,\nCORBA_Environment *env)\n",
859
fprintf(ci->fh, "{\n");
860
if(IDL_INTERFACE(tree).inheritance_spec)
862
for(i = IDL_list_length(IDL_INTERFACE(tree).inheritance_spec) - 1;
864
curitem = IDL_list_nth(IDL_INTERFACE(tree).inheritance_spec, i);
865
id2 = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_LIST(curitem).data),
867
/* XXX fixme - this is going to call ServantBase__fini multiple times */
868
fprintf(ci->fh, " POA_%s__fini(servant, env);\n",
873
fprintf(ci->fh, " PortableServer_ServantBase__fini(servant, env);\n");
874
fprintf(ci->fh, "}\n\n");