92
33
orbit_cbe_write_param_typespec (of, tree);
93
34
fprintf (of, " " ORBIT_RETVAL_VAR_NAME ";\n");
96
fprintf (of, "#ifndef ORBIT_STUB_DEBUG_LOCAL\n");
101
curitem = IDL_get_parent_node(tree, IDLN_INTERFACE, 0);
103
id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(curitem).ident),
106
fprintf (ci->fh, "if (ORBIT_STUB_IsBypass (_obj, %s__classid)) {\n", id);
107
fprintf (ci->fh, "POA_%s__epv *%s;\n", id, ORBIT_EPV_VAR_NAME);
108
fprintf (ci->fh, "ORBIT_STUB_PreCall (_obj);\n");
109
fprintf (ci->fh, "%s = (POA_%s__epv *) ORBIT_STUB_GetEpv (_obj, %s__classid);\n",
110
ORBIT_EPV_VAR_NAME, id, id);
112
fprintf (ci->fh, "if (!%s->%s) {\n", ORBIT_EPV_VAR_NAME, IDL_IDENT (IDL_OP_DCL (tree).ident).str);
113
fprintf (ci->fh, "CORBA_exception_set_system (ev, ex_CORBA_NO_IMPLEMENT, CORBA_COMPLETED_NO);\n");
114
fprintf (ci->fh, "return %s;\n}\n", IDL_OP_DCL (tree).op_type_spec ? ORBIT_RETVAL_VAR_NAME :"");
116
fprintf (ci->fh, "%s%s->%s (ORBIT_STUB_GetServant (_obj), ",
117
IDL_OP_DCL (tree).op_type_spec? ORBIT_RETVAL_VAR_NAME " = ":"",
119
IDL_IDENT (IDL_OP_DCL (tree).ident).str);
122
for(curitem = IDL_OP_DCL(tree).parameter_dcls; curitem;
123
curitem = IDL_LIST(curitem).next) {
124
fprintf(ci->fh, "%s, ",
125
IDL_IDENT(IDL_PARAM_DCL(IDL_LIST(curitem).data).simple_declarator).str);
127
if(IDL_OP_DCL(tree).context_expr)
128
fprintf(ci->fh, "_ctx, ");
130
fprintf(ci->fh, "ev);\n");
132
fprintf(ci->fh, "ORBIT_STUB_PostCall (_obj);\n");
135
fprintf (of, " } else\n");
136
fprintf (of, "#endif /* ORBIT_STUB_DEBUG_LOCAL */\n");
137
fprintf (of, " { /* remote marshal */\n");
140
cbe_small_flatten_args (tree, of, "_args");
142
fprintf (of, "ORBit_small_invoke_stub (_obj, "
143
"&%s__iinterface.methods._buffer [%d], ", id, *idx);
146
fprintf (of, "&_ORBIT_retval, ");
148
fprintf (of, "NULL, ");
151
fprintf (of, "_args, ");
153
fprintf (of, "NULL, ");
155
if (IDL_OP_DCL(tree).context_expr)
156
fprintf(ci->fh, "_ctx, ");
158
fprintf(ci->fh, "NULL, ");
37
fprintf (ci->fh, "POA_%s__epv *%s;\n", iface_id, ORBIT_EPV_VAR_NAME);
38
fprintf (ci->fh, "gpointer _ORBIT_servant;\n");
41
fprintf (ci->fh, "if ((%s = ORBit_c_stub_invoke\n", ORBIT_EPV_VAR_NAME);
42
fprintf (ci->fh, " (_obj, %s__classid, &_ORBIT_servant,\n", iface_id);
43
fprintf (ci->fh, " G_STRUCT_OFFSET (POA_%s__epv, %s)))) {\n",
44
iface_id, IDL_IDENT (IDL_OP_DCL (tree).ident).str);
46
fprintf (ci->fh, "if (ORBit_small_flags & ORBIT_SMALL_FAST_LOCALS && \n");
47
fprintf (ci->fh, " ORBIT_STUB_IsBypass (_obj, %s__classid) && \n", iface_id);
48
fprintf (ci->fh, " (%s = (POA_%s__epv*) ORBIT_STUB_GetEpv (_obj, %s__classid))->%s) {\n",
49
ORBIT_EPV_VAR_NAME, iface_id, iface_id, IDL_IDENT (IDL_OP_DCL (tree).ident).str);
51
fprintf (ci->fh, "ORBIT_STUB_PreCall (_obj);\n");
53
fprintf (ci->fh, "%s%s->%s (_ORBIT_servant, ",
54
IDL_OP_DCL (tree).op_type_spec? ORBIT_RETVAL_VAR_NAME " = ":"",
56
IDL_IDENT (IDL_OP_DCL (tree).ident).str);
58
for (node = IDL_OP_DCL (tree).parameter_dcls; node; node = IDL_LIST (node).next)
59
fprintf (ci->fh, "%s, ",
60
IDL_IDENT (IDL_PARAM_DCL (IDL_LIST (node).data).simple_declarator).str);
62
if (IDL_OP_DCL (tree).context_expr)
63
fprintf (ci->fh, "_ctx, ");
65
fprintf (ci->fh, "ev);\n");
67
fprintf (ci->fh, "ORBit_stub_post_invoke (_obj, %s);\n", ORBIT_EPV_VAR_NAME);
69
fprintf (of, " } else { /* remote marshal */\n");
72
/* remote invocation part */
74
orbit_cbe_flatten_args (tree, of, "_args");
76
fprintf (of, "ORBit_c_stub_invoke (_obj, "
77
"&%s__iinterface.methods, %d, ", iface_id, *idx);
80
fprintf (of, "&_ORBIT_retval, ");
82
fprintf (of, "NULL, ");
85
fprintf (of, "_args, ");
87
fprintf (of, "NULL, ");
89
if (IDL_OP_DCL (tree).context_expr)
90
fprintf (ci->fh, "_ctx, ");
92
fprintf (ci->fh, "NULL, ");
160
fprintf (of, "ev);\n\n");
96
fprintf (of, "%s__classid, G_STRUCT_OFFSET (POA_%s__epv, %s),\n",
97
iface_id, iface_id, IDL_IDENT (IDL_OP_DCL (tree).ident).str);
98
fprintf (of, "(ORBitSmallSkeleton) _ORBIT_skel_small_%s);\n\n", opname);
167
101
fprintf (of, "return " ORBIT_RETVAL_VAR_NAME ";\n");
169
103
fprintf (of, "}\n");
174
static void cs_output_stub(IDL_tree tree, OIDL_C_Info *ci);
175
static void cs_output_except(IDL_tree tree, OIDL_C_Info *ci);
177
/* Very similar to cs_output_small_stubs */
179
cs_output_stubs(IDL_tree tree, OIDL_C_Info *ci)
111
cs_output_stubs (IDL_tree tree,
183
switch(IDL_NODE_TYPE(tree)) {
185
cs_output_stubs(IDL_MODULE(tree).definition_list, ci);
190
for(sub = tree; sub; sub = IDL_LIST(sub).next) {
191
cs_output_stubs(IDL_LIST(sub).data, ci);
197
OIDL_Attr_Info *ai = tree->data;
118
switch (IDL_NODE_TYPE (tree)) {
120
cs_output_stubs (IDL_MODULE (tree).definition_list, ci, idx);
125
for (sub = tree; sub; sub = IDL_LIST (sub).next)
126
cs_output_stubs (IDL_LIST (sub).data, ci, idx);
129
case IDLN_ATTR_DCL: {
201
for(curitem = IDL_ATTR_DCL(tree).simple_declarations; curitem; curitem = IDL_LIST(curitem).next) {
202
ai = IDL_LIST(curitem).data->data;
132
for (node = IDL_ATTR_DCL (tree).simple_declarations; node; node = IDL_LIST (node).next) {
135
ai = IDL_LIST (node).data->data;
204
cs_output_stubs(ai->op1, ci);
206
cs_output_stubs(ai->op2, ci);
211
cs_output_stubs(IDL_INTERFACE(tree).body, ci);
214
cs_output_stub(tree, ci);
216
case IDLN_EXCEPT_DCL:
217
cs_output_except(tree, ci);
224
/* Here's the fun part ;-) */
225
static void cs_stub_alloc_params(IDL_tree tree, OIDL_C_Info *ci);
226
static void cs_free_inout_params(IDL_tree tree, OIDL_C_Info *ci);
227
static void cs_stub_print_return(IDL_tree tree, OIDL_C_Info *ci);
230
cs_output_stub(IDL_tree tree, OIDL_C_Info *ci)
237
if ( oidl_tree_is_pidl(tree) )
240
orbit_cbe_op_write_proto(ci->fh, tree, "", FALSE);
241
fprintf(ci->fh, "{\n");
242
if(IDL_OP_DCL(tree).raises_expr) {
244
fprintf(ci->fh, "const ORBit_exception_demarshal_info _ORBIT_user_exceptions[] = { ");
245
for(curitem = IDL_OP_DCL(tree).raises_expr; curitem;
246
curitem = IDL_LIST(curitem).next) {
248
IDL_tree curnode = IDL_LIST(curitem).data;
250
id = orbit_cbe_get_typespec_str(curnode);
251
fprintf(ci->fh, "{(const CORBA_TypeCode)&TC_%s_struct, (gpointer)_ORBIT_%s_demarshal},",
255
fprintf(ci->fh, "{CORBA_OBJECT_NIL, NULL}};\n");
258
if(IDL_OP_DCL(tree).context_expr) {
260
fprintf(ci->fh, "const ORBit_ContextMarshalItem _context_items[] = {\n");
262
for(curitem = IDL_OP_DCL(tree).context_expr; curitem; curitem = IDL_LIST(curitem).next) {
263
fprintf(ci->fh, "{%lu, \"%s\"},\n", (unsigned long)strlen(IDL_STRING(IDL_LIST(curitem).data).value) + 1,
264
IDL_STRING(IDL_LIST(curitem).data).value);
266
fprintf(ci->fh, "};\n");
269
fprintf(ci->fh, "register CORBA_unsigned_long _ORBIT_request_id;\n");
270
fprintf(ci->fh, "register CORBA_char *_ORBIT_system_exception_ex = ex_CORBA_COMM_FAILURE;\n");
271
fprintf(ci->fh, "register CORBA_completion_status _ORBIT_completion_status = CORBA_COMPLETED_NO;\n");
272
fprintf(ci->fh, "register GIOPSendBuffer *_ORBIT_send_buffer = NULL;\n");
273
if(!IDL_OP_DCL(tree).f_oneway)
275
fprintf(ci->fh, "register GIOPRecvBuffer *_ORBIT_recv_buffer = NULL;\n");
276
fprintf(ci->fh, "GIOPMessageQueueEntry _ORBIT_mqe;\n");
278
fprintf(ci->fh, "register GIOPConnection *_cnx;\n");
279
fprintf(ci->fh, "register guchar *_ORBIT_buf_end;\n");
281
if(oi->out_stubs) /* Lame hack to ensure we get _ORBIT_retval available */
282
orbit_cbe_alloc_tmpvars(oi->out_stubs, ci);
284
/* Check if we can do a direct call, and if so, do it */
289
curitem = IDL_get_parent_node(tree, IDLN_INTERFACE, 0);
291
id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(curitem).ident),
293
fprintf(ci->fh, "if(ORBIT_STUB_IsBypass(_obj,%s__classid))\n{\n", id);
295
fprintf(ci->fh, "ORBit_POAInvocation invoke_rec;\n");
298
fprintf(ci->fh, "POA_%s__epv *_epv=(POA_%s__epv*)ORBIT_STUB_GetEpv(_obj,%s__classid);\n",
300
fprintf(ci->fh, "ORBit_POAInvocation _invoke_rec;\n");
301
fprintf(ci->fh, "ORBIT_STUB_PreCall(_obj, _invoke_rec);\n");
302
fprintf(ci->fh, "%s _epv->%s(ORBIT_STUB_GetServant(_obj), ",
303
IDL_OP_DCL(tree).op_type_spec?"_ORBIT_retval = ":"",
304
IDL_IDENT(IDL_OP_DCL(tree).ident).str);
306
for(curitem = IDL_OP_DCL(tree).parameter_dcls; curitem;
307
curitem = IDL_LIST(curitem).next) {
308
fprintf(ci->fh, "%s, ",
309
IDL_IDENT(IDL_PARAM_DCL(IDL_LIST(curitem).data).simple_declarator).str);
311
if(IDL_OP_DCL(tree).context_expr)
312
fprintf(ci->fh, "_ctx, ");
314
fprintf(ci->fh, "ev);\n");
316
fprintf(ci->fh, "ORBIT_STUB_PostCall(_obj, _invoke_rec);\n");
317
fprintf(ci->fh, "return %s;\n}\n", IDL_OP_DCL(tree).op_type_spec?"_ORBIT_retval":"");
320
fprintf(ci->fh, "_cnx = ORBit_object_get_connection(_obj);\n");
321
fprintf(ci->fh, "if(!_cnx) goto _ORBIT_system_exception;\n");
323
if(!IDL_OP_DCL(tree).f_oneway) /* For location forwarding */
325
fprintf(ci->fh, "_ORBIT_retry_request:\n");
326
fprintf(ci->fh, "_ORBIT_recv_buffer = NULL;\n");
329
fprintf(ci->fh, "_ORBIT_send_buffer = NULL;\n");
330
fprintf(ci->fh, "_ORBIT_completion_status = CORBA_COMPLETED_NO;\n");
332
if(sizeof(gpointer) > sizeof(CORBA_unsigned_long))
333
fprintf(ci->fh, "_ORBIT_request_id = giop_get_request_id();\n");
335
fprintf(ci->fh, "_ORBIT_request_id = GPOINTER_TO_UINT(g_alloca(0));\n");
337
fprintf(ci->fh, "{ /* marshalling */\n");
338
fprintf(ci->fh, "static const struct { CORBA_unsigned_long len; char opname[%lu]; } _ORBIT_operation_name_data = { %lu, \"%s\" };\n",
339
/* We align it now instead of at runtime */
340
ALIGN_VALUE(strlen(IDL_IDENT(IDL_OP_DCL(tree).ident).str) + 1, sizeof(CORBA_unsigned_long)),
341
(unsigned long)strlen(IDL_IDENT(IDL_OP_DCL(tree).ident).str) + 1,
342
IDL_IDENT(IDL_OP_DCL(tree).ident).str);
343
fprintf(ci->fh, "const struct iovec _ORBIT_operation_vec = {(gpointer)&_ORBIT_operation_name_data, %lu};\n",
344
sizeof(CORBA_unsigned_long) +
345
ALIGN_VALUE(strlen(IDL_IDENT(IDL_OP_DCL(tree).ident).str) + 1,
346
sizeof(CORBA_unsigned_long)));
348
orbit_cbe_alloc_tmpvars(oi->in_stubs, ci);
350
fprintf(ci->fh, "_ORBIT_send_buffer = \n");
351
fprintf(ci->fh, "giop_send_buffer_use_request(_cnx->giop_version, _ORBIT_request_id, %s,\n",
352
IDL_OP_DCL(tree).f_oneway?"CORBA_FALSE":"CORBA_TRUE");
353
fprintf(ci->fh, "&(_obj->oki->object_key_vec), &_ORBIT_operation_vec, NULL /* &ORBit_default_principal_iovec */);\n\n");
354
fprintf(ci->fh, "_ORBIT_system_exception_ex = ex_CORBA_COMM_FAILURE;\n");
355
fprintf(ci->fh, "if(!_ORBIT_send_buffer) goto _ORBIT_system_exception;\n");
357
c_marshalling_generate(oi->in_stubs, ci, TRUE);
359
if(!IDL_OP_DCL(tree).f_oneway)
361
fprintf(ci->fh, "giop_recv_list_setup_queue_entry(&_ORBIT_mqe, _cnx, GIOP_REPLY, _ORBIT_request_id);\n");
362
fprintf(ci->fh, "if(giop_send_buffer_write(_ORBIT_send_buffer, _cnx)) { giop_recv_list_destroy_queue_entry(&_ORBIT_mqe); goto _ORBIT_system_exception; }\n");
365
fprintf(ci->fh, "if(giop_send_buffer_write(_ORBIT_send_buffer, _cnx)) goto _ORBIT_system_exception;\n");
366
fprintf(ci->fh, "_ORBIT_completion_status = CORBA_COMPLETED_MAYBE;\n");
367
fprintf(ci->fh, "giop_send_buffer_unuse(_ORBIT_send_buffer); _ORBIT_send_buffer = NULL;\n");
368
fprintf(ci->fh, "}\n");
370
if(!IDL_OP_DCL(tree).f_oneway) {
371
/* free inout params as needed */
372
cs_free_inout_params(tree, ci);
374
fprintf(ci->fh, "{ /* demarshalling */\n");
377
fprintf(ci->fh, "register guchar *_ORBIT_curptr G_GNUC_UNUSED;\n");
379
fprintf(ci->fh, "_ORBIT_recv_buffer = giop_recv_buffer_get(&_ORBIT_mqe, TRUE);\n");
381
fprintf(ci->fh, "if(!_ORBIT_recv_buffer) goto _ORBIT_system_exception;\n");
382
fprintf(ci->fh, "_ORBIT_buf_end = _ORBIT_recv_buffer->end;\n");
383
fprintf(ci->fh, "_ORBIT_completion_status = CORBA_COMPLETED_YES;\n");
385
fprintf(ci->fh, "if(giop_recv_buffer_reply_status(_ORBIT_recv_buffer) != GIOP_NO_EXCEPTION) goto _ORBIT_msg_exception;\n");
387
cs_stub_alloc_params(tree, ci);
389
c_demarshalling_generate(oi->out_stubs, ci, FALSE, FALSE);
391
fprintf(ci->fh, "giop_recv_buffer_unuse(_ORBIT_recv_buffer);\n");
392
cs_stub_print_return (tree, ci);
395
fprintf(ci->fh, "return;\n");
397
if(!IDL_OP_DCL(tree).f_oneway) {
400
for(curitem = IDL_list_nth(IDL_OP_DCL(tree).parameter_dcls, IDL_list_length(IDL_OP_DCL(tree).parameter_dcls) - 1);
401
curitem; curitem = IDL_LIST(curitem).prev)
405
param = IDL_LIST(curitem).data;
406
if(IDL_PARAM_DCL(param).attr != IDL_PARAM_IN)
408
fprintf(ci->fh, "%s_demarshal_error:\n", IDL_IDENT(IDL_PARAM_DCL(param).simple_declarator).str);
409
cbe_op_param_free(param, ci, FALSE);
413
if(IDL_OP_DCL(tree).op_type_spec)
415
fprintf(ci->fh, "%s_demarshal_error:\n", ORBIT_RETVAL_VAR_NAME);
416
cbe_op_retval_free(IDL_OP_DCL(tree).op_type_spec, ci);
419
fprintf(ci->fh, "_ORBIT_demarshal_error:\n");
420
fprintf(ci->fh, "_ORBIT_system_exception_ex = ex_CORBA_MARSHAL;\n");
422
fprintf(ci->fh, "_ORBIT_system_exception:\n");
423
#ifdef BACKWARDS_COMPAT_0_4
424
fprintf(ci->fh, "CORBA_exception_set_system(ev, _ORBIT_system_exception_ex, _ORBIT_completion_status);\n");
425
fprintf(ci->fh, "giop_recv_buffer_unuse(_ORBIT_recv_buffer);\n");
426
fprintf(ci->fh, "giop_send_buffer_unuse(_ORBIT_send_buffer);\n");
428
fprintf(ci->fh, "ORBit_handle_system_exception(ev, _ORBIT_system_exception_ex, _ORBIT_completion_status, %s, _ORBIT_send_buffer);\n",
429
IDL_OP_DCL(tree).f_oneway?"NULL":"_ORBIT_recv_buffer");
431
if(IDL_OP_DCL(tree).op_type_spec)
432
/* This will avoid warning about uninitialized memory while
433
* compiling the stubs with no extra code size cost */
434
fprintf(ci->fh, "#if defined(__GNUC__) && defined(__OPTIMIZE__)\n"
436
"#endif\n", ORBIT_RETVAL_VAR_NAME);
438
cs_stub_print_return (tree, ci);
440
if(!IDL_OP_DCL(tree).f_oneway) {
441
fprintf(ci->fh, "_ORBIT_msg_exception:\n");
442
/* deal with LOCATION_FORWARD exceptions */
443
fprintf(ci->fh, "if(giop_recv_buffer_reply_status(_ORBIT_recv_buffer) == GIOP_LOCATION_FORWARD) {\n");
444
#ifdef BACKWARDS_COMPAT_0_4
445
fprintf(ci->fh, "if (_obj->forward_locations != NULL) ORBit_delete_profiles(_obj->forward_locations);\n");
446
fprintf(ci->fh, "_obj->forward_locations = ORBit_demarshal_IOR(_ORBIT_recv_buffer);\n");
447
fprintf(ci->fh, "_cnx = ORBit_object_get_forwarded_connection(_obj);\n");
448
fprintf(ci->fh, "giop_recv_buffer_unuse(_ORBIT_recv_buffer);\n");
450
fprintf(ci->fh, "_cnx = ORBit_handle_location_forward(_ORBIT_recv_buffer, _obj);\n");
452
fprintf(ci->fh, "\ngoto _ORBIT_retry_request;\n");
453
fprintf(ci->fh, "} else {\n");
455
fprintf(ci->fh, "ORBit_handle_exception(_ORBIT_recv_buffer, ev, %s, _obj->orb);\n",
456
IDL_OP_DCL(tree).raises_expr?"_ORBIT_user_exceptions":"NULL");
457
fprintf(ci->fh, "giop_recv_buffer_unuse(_ORBIT_recv_buffer);\n");
458
cs_stub_print_return (tree, ci);
459
fprintf(ci->fh, "}\n}\n");
462
fprintf(ci->fh, "}\n");
465
static void cs_stub_print_return(IDL_tree tree, OIDL_C_Info *ci)
467
if(IDL_OP_DCL(tree).op_type_spec)
468
fprintf(ci->fh, "return %s;\n", ORBIT_RETVAL_VAR_NAME);
470
fprintf(ci->fh, "return;\n");
474
cbe_stub_op_param_alloc(FILE *of, IDL_tree node, GString *tmpstr)
478
IDL_tree ts = orbit_cbe_get_typespec(node);
481
n = oidl_param_info(node,
482
oidl_attr_to_paramrole(IDL_PARAM_DCL(node).attr),
487
if(((n - 1) <= 0) && IDL_NODE_TYPE(ts) != IDLN_TYPE_ARRAY)
490
switch(IDL_NODE_TYPE(ts)) {
491
case IDLN_TYPE_ARRAY:
492
if((IDL_PARAM_DCL(node).attr != IDL_PARAM_OUT)
493
|| orbit_cbe_type_is_fixed_length(ts))
497
case IDLN_TYPE_SEQUENCE:
499
if(IDL_PARAM_DCL(node).attr == IDL_PARAM_INOUT)
502
case IDLN_TYPE_UNION:
503
case IDLN_TYPE_STRUCT:
504
if(orbit_cbe_type_is_fixed_length(ts))
510
g_string_assign(tmpstr, "");
511
for(i = 0; i < n - 1; i++)
512
g_string_append_c(tmpstr, '*');
514
g_string_append_printf(tmpstr, "%s",
515
IDL_IDENT(IDL_PARAM_DCL(node).simple_declarator).str);
517
id = orbit_cbe_get_typespec_str(IDL_PARAM_DCL(node).param_type_spec);
518
fprintf(of, "%s = %s__alloc();\n", tmpstr->str, id);
137
cs_output_stubs (ai->op1, ci, idx);
140
cs_output_stubs (ai->op2, ci, idx);
144
case IDLN_INTERFACE: {
147
cs_output_stubs (IDL_INTERFACE (tree).body, ci, &real_idx);
151
cs_output_stub (tree, ci, idx);
523
cbe_stub_op_retval_alloc(FILE *of, IDL_tree node, GString *tmpstr)
527
IDL_tree ts = orbit_cbe_get_typespec(node);
529
n = oidl_param_numptrs(node, DATA_RETURN);
532
&& (IDL_NODE_TYPE(ts) != IDLN_TYPE_ARRAY))
535
g_string_assign(tmpstr, ORBIT_RETVAL_VAR_NAME );
537
switch(IDL_NODE_TYPE(ts)) {
538
case IDLN_TYPE_UNION:
539
case IDLN_TYPE_STRUCT:
540
if(orbit_cbe_type_is_fixed_length(ts))
543
case IDLN_TYPE_SEQUENCE:
544
case IDLN_TYPE_ARRAY:
550
id = orbit_cbe_get_typespec_str(node);
551
fprintf(of, "%s = %s__alloc();\n", tmpstr->str, id);
556
cs_stub_alloc_params(IDL_tree tree, OIDL_C_Info *ci)
558
IDL_tree curitem, param;
559
GString *tmpstr = g_string_new(NULL);
561
if(IDL_OP_DCL(tree).op_type_spec)
562
cbe_stub_op_retval_alloc(ci->fh, IDL_OP_DCL(tree).op_type_spec,
565
for(curitem = IDL_OP_DCL(tree).parameter_dcls; curitem;
566
curitem = IDL_LIST(curitem).next) {
568
param = IDL_LIST(curitem).data;
570
if(IDL_PARAM_DCL(param).attr == IDL_PARAM_INOUT
571
|| IDL_PARAM_DCL(param).attr == IDL_PARAM_OUT)
572
cbe_stub_op_param_alloc(ci->fh, param, tmpstr);
575
g_string_free(tmpstr, TRUE);
578
/* This param freeing stuff really could be done better - perhaps shared code with the skels generation. */
580
cbe_stub_op_param_free(FILE *of, IDL_tree node, GString *tmpstr)
586
ts = orbit_cbe_get_typespec(IDL_PARAM_DCL(node).param_type_spec);
587
n = oidl_param_numptrs(node, DATA_INOUT);
588
g_string_assign(tmpstr, "");
590
if(IDL_NODE_TYPE(ts) == IDLN_TYPE_STRUCT
591
|| IDL_NODE_TYPE(ts) == IDLN_TYPE_UNION)
594
for(i = 0; i < n; i++)
595
g_string_append_c(tmpstr, '*');
597
g_string_append_printf(tmpstr, "%s",
598
IDL_IDENT(IDL_PARAM_DCL(node).simple_declarator).str);
599
switch(IDL_NODE_TYPE(ts)) {
601
fprintf(of, "if((%s)._release) CORBA_free((%s)._value);\n",
602
tmpstr->str, tmpstr->str);
603
fprintf(of, "CORBA_Object_release((%s)._type, ev);\n", tmpstr->str);
605
case IDLN_TYPE_SEQUENCE:
606
fprintf(of, "if((%s)._release) CORBA_free((%s)._buffer);\n",
607
tmpstr->str, tmpstr->str);
609
case IDLN_TYPE_STRUCT:
610
case IDLN_TYPE_UNION:
611
case IDLN_TYPE_ARRAY:
612
if(orbit_cbe_type_is_fixed_length(ts))
614
id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_TYPE_STRUCT(ts).ident), "_", 0);
615
fprintf(of, "%s__freekids(%s, NULL);\n", id, tmpstr->str);
618
case IDLN_TYPE_STRING:
619
fprintf(of, "CORBA_free(%s);\n", tmpstr->str);
622
case IDLN_FORWARD_DCL:
623
case IDLN_TYPE_OBJECT:
624
case IDLN_TYPE_TYPECODE:
625
fprintf(of, "CORBA_Object_release(%s, ev);\n", tmpstr->str);
628
g_assert(orbit_cbe_type_is_fixed_length(node));
634
cs_free_inout_params(IDL_tree tree, OIDL_C_Info *ci)
639
tmpstr = g_string_new(NULL);
640
for(curitem = IDL_OP_DCL(tree).parameter_dcls; curitem; curitem = IDL_LIST(curitem).next) {
643
curparam = IDL_LIST(curitem).data;
645
if(IDL_PARAM_DCL(curparam).attr != IDL_PARAM_INOUT) continue;
647
cbe_stub_op_param_free(ci->fh, curparam, tmpstr);
649
g_string_free(tmpstr, TRUE);
653
cs_output_except(IDL_tree tree, OIDL_C_Info *ci)
656
OIDL_Except_Info *ei;
658
if ( oidl_tree_is_pidl(tree) )
664
id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_EXCEPT_DCL(tree).ident), "_", 0);
666
fprintf(ci->fh, "gboolean\n_ORBIT_%s_demarshal(GIOPRecvBuffer *_ORBIT_recv_buffer, CORBA_Environment *ev)\n", id);
667
fprintf(ci->fh, "{\n");
668
if(IDL_EXCEPT_DCL(tree).members) {
669
fprintf(ci->fh, "register guchar *_ORBIT_curptr;\n");
670
fprintf(ci->fh, "register guchar *_ORBIT_buf_end = _ORBIT_recv_buffer->end;\n");
671
orbit_cbe_alloc_tmpvars(ei->demarshal, ci);
672
fprintf(ci->fh, "%s *_ORBIT_exdata;\n", id);
673
c_demarshalling_generate(ei->demarshal, ci, FALSE, FALSE);
676
fprintf(ci->fh, "CORBA_exception_set(ev, CORBA_USER_EXCEPTION, TC_%s_struct.repo_id, %s);\n",
677
id, IDL_EXCEPT_DCL(tree).members?"_ORBIT_exdata":"NULL");
679
fprintf(ci->fh, "return FALSE;");
681
fprintf(ci->fh, "_ORBIT_demarshal_error:\nreturn TRUE;\n");
683
fprintf(ci->fh, "}\n");
159
orbit_idl_output_c_stubs (IDL_tree tree,
160
OIDL_Run_Info *rinfo,
163
fprintf (ci->fh, OIDL_C_WARNING);
164
fprintf (ci->fh, "#include <string.h>\n");
165
fprintf (ci->fh, "#define ORBIT2_STUBS_API\n");
166
fprintf (ci->fh, "#include \"%s.h\"\n\n", ci->base_name);
168
cs_output_stubs (tree, ci, NULL);