]> rtime.felk.cvut.cz Git - frescor/frsh-forb.git/blob - src/forb/forb-idl/forb-idl-c-skels.c
Get rid of the most of other warnings
[frescor/frsh-forb.git] / src / forb / forb-idl / forb-idl-c-skels.c
1 #include "config.h"
2
3 #include "forb-idl-c-backend.h"
4
5 #include <string.h>
6
7 typedef struct {
8         OIDL_C_Info *ci;
9         GSList      *oplist;
10         int          curlevel;
11 } CBESkelInterfaceTraverseInfo;
12
13 typedef struct {
14         char     *iface_id;
15         char     *opname;
16         IDL_tree  op;
17         int       idx;
18 } CBESkelOpInfo;
19
20 static void cbe_skel_do_interface(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci);
21
22 static void
23 ck_output_poastuff(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci)
24 {
25   if( !tree || (tree->declspec & IDLF_DECLSPEC_PIDL)!=0 ) 
26     return;
27
28   switch(IDL_NODE_TYPE(tree)) {
29   case IDLN_MODULE:
30     ck_output_poastuff(IDL_MODULE(tree).definition_list, rinfo, ci);
31     break;
32   case IDLN_LIST:
33     {
34       IDL_tree sub;
35       for(sub = tree; sub; sub = IDL_LIST(sub).next) {
36         ck_output_poastuff(IDL_LIST(sub).data, rinfo, ci);
37       }
38     }
39     break;
40   case IDLN_INTERFACE:
41     cbe_skel_do_interface(tree, rinfo, ci);
42     break;
43   default:
44     break;
45   }
46 }
47
48 /* static gint */
49 /* cbe_skel_compare_op_dcls(CBESkelOpInfo *op1, CBESkelOpInfo *op2) */
50 /* { */
51 /*   return strcmp(op1->opname, op2->opname); */
52 /* } */
53
54 /* static void */
55 /* cbe_skel_free_op_info(CBESkelOpInfo *op) */
56 /* { */
57 /*   g_free(op->opname); */
58 /*   g_free(op->iface_id); */
59 /*   g_free(op); */
60 /* } */
61
62 /* static void */
63 /* cbe_skel_interface_add_relayer (IDL_tree intf, CBESkelInterfaceTraverseInfo *iti) */
64 /* { */
65 /*   CBESkelOpInfo *newopi; */
66 /*   IDL_tree curitem, curdcl, curattr, curattrdcl; */
67 /*   char *iface_id; */
68 /*   int   idx = 0; */
69
70 /*   iface_id = */
71 /*     IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(intf).ident), */
72 /*                          "_", 0); */
73
74 /*   for(curitem = IDL_INTERFACE(intf).body; curitem; */
75 /*       curitem = IDL_LIST(curitem).next) { */
76 /*     curdcl = IDL_LIST(curitem).data; */
77
78 /*     switch(IDL_NODE_TYPE(curdcl)) { */
79 /*     case IDLN_OP_DCL: */
80 /*       newopi = g_new0(CBESkelOpInfo, 1); */
81 /*       newopi->iface_id = g_strdup(iface_id); */
82 /*       newopi->opname = g_strdup(IDL_IDENT(IDL_OP_DCL(curdcl).ident).str); */
83 /*       newopi->idx = idx++; */
84 /*       iti->oplist = g_slist_insert_sorted(iti->oplist, newopi, */
85 /*                                        (GCompareFunc)cbe_skel_compare_op_dcls); */
86 /*       break; */
87 /*     case IDLN_ATTR_DCL: */
88 /*       for(curattr = IDL_ATTR_DCL(curdcl).simple_declarations; */
89 /*        curattr; curattr = IDL_LIST(curattr).next) { */
90 /*      curattrdcl = IDL_LIST(curattr).data; */
91
92 /*      newopi = g_new0(CBESkelOpInfo, 1); */
93 /*      newopi->iface_id = g_strdup(iface_id); */
94 /*      newopi->opname = g_strdup_printf("_get_%s", IDL_IDENT(curattrdcl).str); */
95 /*      newopi->idx = idx++; */
96 /*      iti->oplist = g_slist_insert_sorted(iti->oplist, newopi, */
97 /*                                          (GCompareFunc)cbe_skel_compare_op_dcls); */
98 /*      if(!IDL_ATTR_DCL(curdcl).f_readonly) { */
99 /*        newopi = g_new0(CBESkelOpInfo, 1); */
100 /*        newopi->iface_id = g_strdup(iface_id); */
101 /*        newopi->opname = g_strdup_printf("_set_%s", IDL_IDENT(curattrdcl).str); */
102 /*        newopi->idx = idx++; */
103 /*        iti->oplist = g_slist_insert_sorted(iti->oplist, newopi, */
104 /*                                            (GCompareFunc)cbe_skel_compare_op_dcls); */
105 /*      } */
106 /*       } */
107 /*       break; */
108 /*     default: */
109 /*       break; */
110 /*     } */
111 /*   } */
112
113 /*   g_free(iface_id); */
114 /* } */
115
116 /* static void */
117 /* cbe_skel_interface_print_relayers(const CBESkelInterfaceTraverseInfo *iti) */
118 /* { */
119 /*   CBESkelInterfaceTraverseInfo subiti = *iti; */
120 /*   GSList *curnode; */
121 /*   CBESkelOpInfo *opi; */
122 /*   char curchar; */
123
124 /*   curnode = iti->oplist; */
125 /*   subiti.curlevel = iti->curlevel+1; */
126 /*   fprintf(iti->ci->fh, "switch(opname[%d]) {\n", iti->curlevel); */
127 /*   while(curnode) { */
128 /*     opi = (CBESkelOpInfo *)curnode->data; */
129 /*     if(iti->curlevel > strlen(opi->opname)) { */
130 /*       curnode = g_slist_next(curnode); */
131 /*       continue; */
132 /*     } */
133 /*     curchar = opi->opname[iti->curlevel]; */
134 /*     if(curchar) */
135 /*       fprintf(iti->ci->fh, "case '%c':\n", curchar); */
136 /*     else */
137 /*       fprintf(iti->ci->fh, "case '\\0':\n"); */
138 /*     subiti.oplist = NULL; */
139 /*     while(curnode && ((CBESkelOpInfo *)curnode->data)->opname[iti->curlevel] */
140 /*        == curchar) { */
141 /*       subiti.oplist = g_slist_append(subiti.oplist, curnode->data); */
142 /*       curnode = g_slist_next(curnode); */
143 /*     } */
144
145 /*     if(g_slist_length(subiti.oplist) > 1) { */
146 /*       if(curchar) */
147 /*      cbe_skel_interface_print_relayers(&subiti); */
148 /*       else */
149 /*      g_error("two ops with same name!!!!"); */
150 /*     } else { */
151 /*       if(strlen(opi->opname + iti->curlevel)) */
152 /*      fprintf(iti->ci->fh, "if(strcmp((opname + %d), \"%s\")) break;\n", */
153 /*              iti->curlevel + 1, opi->opname + iti->curlevel+1); */
154 /*       fprintf(iti->ci->fh, "*impl = (gpointer)servant->vepv->%s_epv->%s;\n", */
155 /*            opi->iface_id, opi->opname); */
156 /*       fprintf(iti->ci->fh, "{Forb_IInterface *volatile _t_=&%s__iinterface;*m_data = (gpointer)&_t_->methods._buffer [%d];}\n", */
157 /*            opi->iface_id, opi->idx); */
158 /*       fprintf(iti->ci->fh, "return (ForbSmallSkeleton)_FORB_skel_small_%s_%s;\n", */
159 /*            opi->iface_id, opi->opname); */
160 /*     } */
161 /*     fprintf(iti->ci->fh, "break;\n"); */
162 /*     g_slist_free(subiti.oplist); */
163 /*   } */
164 /*   fprintf(iti->ci->fh, "default: break; \n}\n"); */
165 /* } */
166
167 /* static void */
168 /* cbe_skel_interface_print_relayer(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci) */
169 /* { */
170 /*   char *id; */
171 /*   CBESkelInterfaceTraverseInfo iti; */
172
173 /*   id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(tree).ident), "_", 0); */
174 /*   fprintf(ci->fh, "static ForbSmallSkeleton get_skel_small_%s(POA_%s *servant,\nconst char *opname," */
175 /*        "gpointer *m_data, gpointer *impl)\n{\n", id, id); */
176
177 /*   iti.ci = ci; */
178 /*   iti.oplist = NULL; */
179 /*   iti.curlevel = 0; */
180
181 /*   IDL_tree_traverse_parents(tree, */
182 /*                          (GFunc)cbe_skel_interface_add_relayer, &iti); */
183
184 /*   cbe_skel_interface_print_relayers(&iti); */
185
186 /*   g_slist_foreach(iti.oplist, (GFunc)cbe_skel_free_op_info, NULL); */
187 /*   g_slist_free(iti.oplist); */
188
189 /*   fprintf(ci->fh, "return NULL;\n"); */
190 /*   fprintf(ci->fh, "}\n\n"); */
191
192 /*   g_free(id); */
193 /* } */
194
195 typedef struct {
196         OIDL_C_Info *ci;
197         const char  *for_id;
198 } CBESkelVEPVMapTraverseInfo;
199
200 /* static void */
201 /* cbe_skel_interface_print_vepvmap_offsets (IDL_tree node, CBESkelVEPVMapTraverseInfo *ti) */
202 /* { */
203 /*      char *id; */
204 /*      id = IDL_ns_ident_to_qstring (IDL_IDENT_TO_NS (IDL_INTERFACE (node).ident), "_", 0); */
205 /*      fprintf (ti->ci->fh, "(CORBA_unsigned_long) %s__classid,\n", id); */
206 /*      fprintf (ti->ci->fh, "FORB_VEPV_OFFSET (POA_%s__vepv, %s_epv),\n", ti->for_id, id); */
207 /*      g_free (id); */
208 /* } */
209
210 /**
211  * If the type specified in @a type_spec is dynamically allocated
212  * (such as string, sequence or object reference), the parameters of
213  * this type must be freed after they are not needed. For input
214  * parameter this is after the implementation is called, for out and
215  * inout return parameters after the returned value is serialized.
216  */
217 static void free_memory_if_needed(IDL_tree type_spec, const char *name, int n, OIDL_C_Info *ci)
218 {
219   type_spec = forb_cbe_get_typespec(type_spec);
220   /* forb_idl_print_node(type_spec, 7); */
221   switch(IDL_NODE_TYPE(type_spec)) {
222   case IDLN_TYPE_STRING:
223   case IDLN_TYPE_WIDE_STRING:
224     fprintf(ci->fh, "    ");
225     fprintf(ci->fh, "forb_free(%s);\n", name);
226     break;
227   case IDLN_TYPE_ARRAY:
228     break;
229   case IDLN_TYPE_SEQUENCE: {
230     char *dot = n==2?"->":".";
231     IDL_tree simple_type = forb_cbe_get_typespec(IDL_TYPE_SEQUENCE(type_spec).simple_type_spec);
232
233     fprintf(ci->fh, "    if (CORBA_sequence_get_release(%s%s)) {\n",
234             n==2?"":"&",name);
235     if (IDLN_NATIVE == IDL_NODE_TYPE(simple_type)) {
236       fprintf(ci->fh, "      int i;\n"
237                       "      for (i=0; i<%s%s_length; i++)\n"
238                       "          %s_free(%s%s_buffer[i]);\n",
239               name, dot, forb_cbe_get_typespec_str(IDL_NATIVE(type_spec).ident),
240               name, dot);
241     }
242     fprintf(ci->fh, "      forb_free(%s%s_buffer);\n"
243                     "    }\n", name, dot);
244     if (n==2) {
245             fprintf(ci->fh, "    ");
246             fprintf(ci->fh, "forb_free(%s);\n", name);
247     }
248     break;
249   }
250   case IDLN_NATIVE:
251     fprintf(ci->fh, "    ");
252     fprintf(ci->fh, "%s_free(%s);\n",
253             forb_cbe_get_typespec_str(IDL_NATIVE(type_spec).ident),
254             name);
255     return;
256   case IDLN_INTERFACE:
257     fprintf(ci->fh, "    ");
258     fprintf(ci->fh, "forb_object_release(%s);\n", name);
259     break;
260   default:
261     break;
262   }
263
264 }
265
266 static void ck_output_op_skel(IDL_tree op, char *intf_id, OIDL_Run_Info *rinfo, OIDL_C_Info *ci)
267 {
268         char *id, *id_plain;
269         IDL_tree sub;
270         gboolean  has_retval/* , has_args */;
271         const char *const seq_init = " = {0,0,NULL}";
272
273         has_retval = IDL_OP_DCL (op).op_type_spec != NULL;
274         /* has_args   = IDL_OP_DCL (op).parameter_dcls != NULL; */
275         
276         id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_OP_DCL(op).ident), "_", 0);
277         id_plain = IDL_IDENT(IDL_OP_DCL(op).ident).str;
278         fprintf(ci->fh, "static void\n"
279                 "forb_skel_%s(FORB_CDR_Codec *cin, FORB_CDR_Codec *cout, %s _obj, struct forb_env *env)\n"
280                 "{\n",
281                 id, intf_id);
282 /*      fprintf(ci->fh, "  if (_obj->interface != %s_interface) {\n", intf_id); */
283 /*      fprintf(ci->fh, "    env->major = FORB_EX_BAD_OPERATION;\n" */
284 /*                      "    return;\n" */
285 /*                      "  }\n"); */
286         fprintf(ci->fh, "  if (_%s_impl(_obj) && _%s_impl(_obj)->%s) {\n", intf_id, intf_id, id_plain);
287
288         /* Declare variables for parameters */
289         for (sub = IDL_OP_DCL (op).parameter_dcls; sub; sub = IDL_LIST (sub).next) {
290                 IDL_tree        parm = IDL_LIST (sub).data;
291                 IDL_ParamRole   role;
292                 IDL_tree        ts = forb_cbe_get_typespec(parm);
293                 gboolean        isSlice;
294                 int             n;
295                 char            *name = IDL_IDENT(IDL_PARAM_DCL(parm).simple_declarator).str;
296                 role = oidl_attr_to_paramrole(IDL_PARAM_DCL(parm).attr);
297                 n = oidl_param_info (ts, role, &isSlice);
298
299                 fprintf(ci->fh, "    ");
300                 forb_cbe_write_typespec(ci->fh, IDL_PARAM_DCL(parm).param_type_spec);
301                 fprintf(ci->fh, " %s%s%s;\n",
302                         n == 2 ? "*":"",
303                         name,
304                         (n < 2 && IDL_NODE_TYPE(ts) == IDLN_TYPE_SEQUENCE)?seq_init : "");
305         }
306         if (has_retval) {
307                 fprintf (ci->fh, "    ");
308                 forb_cbe_write_param_typespec (ci->fh, op);
309                 fprintf (ci->fh, " _forb_ret;\n"); /* TODO: seq_init */
310         }
311
312         /* Deserialize in parameters */
313         for (sub = IDL_OP_DCL (op).parameter_dcls; sub; sub = IDL_LIST (sub).next) {
314                 IDL_tree        parm = IDL_LIST (sub).data;
315                 IDL_ParamRole   role;
316                 role = oidl_attr_to_paramrole(IDL_PARAM_DCL(parm).attr);
317                 if (role == DATA_IN || role == DATA_INOUT) {
318                         char *name = IDL_IDENT(IDL_PARAM_DCL(parm).simple_declarator).str;
319                         fprintf(ci->fh, "    if (!");
320                         forb_cbe_write_typespec(ci->fh, IDL_PARAM_DCL(parm).param_type_spec);
321                         fprintf(ci->fh, "_deserialize(cin, &%s)) {\n", name);
322                         fprintf(ci->fh, "      env->major = FORB_EX_MARSHAL; goto exception;\n    }\n");
323                 }
324         }
325
326         /* Call the implementation */
327         fprintf(ci->fh, "    ");
328         if (has_retval)
329                 fprintf(ci->fh, "_forb_ret = ");
330         fprintf(ci->fh, "_%s_impl(_obj)->%s(_obj, ",
331                 intf_id, id_plain);
332         for (sub = IDL_OP_DCL (op).parameter_dcls; sub; sub = IDL_LIST (sub).next) {
333                 IDL_tree        parm = IDL_LIST (sub).data;
334                 IDL_ParamRole   role;
335                 IDL_tree        ts = forb_cbe_get_typespec(parm);
336                 gboolean        isSlice;
337                 int             n;
338                 char            *name = IDL_IDENT(IDL_PARAM_DCL(parm).simple_declarator).str;
339                 role = oidl_attr_to_paramrole(IDL_PARAM_DCL(parm).attr);
340                 n = oidl_param_info (ts, role, &isSlice);
341
342                 fprintf(ci->fh, "%s%s, ", n?"&":"", name);
343         }
344         fprintf(ci->fh, "env);\n");
345         fprintf(ci->fh,
346                 "    if (forb_exception_occurred(env)) goto exception;\n");
347         if (has_retval) {
348           fprintf(ci->fh, "    ");
349           forb_cbe_write_typespec(ci->fh, IDL_OP_DCL(op).op_type_spec);
350           fprintf(ci->fh, "_serialize(cout, &_forb_ret);\n");
351         }
352         for (sub = IDL_OP_DCL (op).parameter_dcls; sub; sub = IDL_LIST (sub).next) {
353                 IDL_tree        parm = IDL_LIST (sub).data;
354                 IDL_ParamRole   role;
355                 IDL_tree        ts = forb_cbe_get_typespec(parm);
356                 gboolean        isSlice;
357                 int             n;
358                 char            *name = IDL_IDENT(IDL_PARAM_DCL(parm).simple_declarator).str;
359                 role = oidl_attr_to_paramrole(IDL_PARAM_DCL(parm).attr);
360                 n = oidl_param_info (ts, role, &isSlice);
361                 if (role == DATA_OUT || role == DATA_INOUT) {
362                   fprintf(ci->fh, "    ");
363                   forb_cbe_write_typespec(ci->fh, IDL_PARAM_DCL(parm).param_type_spec);
364                   fprintf(ci->fh, "_serialize(cout, %s%s);\n", n==2?"":"&", name);
365                 }
366         }
367         fprintf(ci->fh, "exception:;\n");
368
369         /* Free all dynamically allocated parameteres and retvals */
370         if (has_retval) {
371                 free_memory_if_needed(IDL_OP_DCL(op).op_type_spec, "_forb_ret", 0, ci);
372         }
373         for (sub = IDL_OP_DCL (op).parameter_dcls; sub; sub = IDL_LIST (sub).next) {
374                 IDL_tree        parm = IDL_LIST (sub).data;
375                 char *name = IDL_IDENT(IDL_PARAM_DCL(parm).simple_declarator).str;
376                 IDL_ParamRole   role;
377                 IDL_tree        ts = forb_cbe_get_typespec(parm);
378                 gboolean        isSlice;
379                 int             n;
380                 role = oidl_attr_to_paramrole(IDL_PARAM_DCL(parm).attr);
381                 n = oidl_param_info (ts, role, &isSlice);
382                 free_memory_if_needed(IDL_PARAM_DCL(parm).param_type_spec, name, n, ci);
383         }
384
385         fprintf(ci->fh, "  } else {\n");
386         fprintf(ci->fh, "    env->major = FORB_EX_NO_IMPLEMENT;\n");
387         fprintf(ci->fh, "  }\n");
388         fprintf(ci->fh, "}\n\n");
389         g_free(id);
390 }
391
392 static void
393 cbe_skel_do_interface(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci)
394 {
395   char *id;
396   IDL_tree pnt;
397   IDL_tree sub;
398   //int i;
399   //CBESkelVEPVMapTraverseInfo ti;
400   int num_methods = 0;
401
402   /* PIDL methods dont have normal skel functions. */
403   for ( pnt=tree; pnt; pnt=IDL_NODE_UP(pnt) ) {
404       if ( pnt->declspec & IDLF_DECLSPEC_PIDL )
405         return;
406   }
407
408   id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(tree).ident), "_", 0);
409
410   fprintf(ci->fh, "#define _%s_impl(obj) ((struct forb_%s_impl*)(obj)->implementation)\n\n", id, id);
411   fprintf(ci->fh, "static const struct forb_interface %s_interface;\n\n", id);
412   
413   for(sub = IDL_INTERFACE(tree).body; sub; sub = IDL_LIST(sub).next) {
414     IDL_tree cur = IDL_LIST(sub).data;
415     
416     switch(IDL_NODE_TYPE(cur)) {
417     case IDLN_OP_DCL:
418       ck_output_op_skel(cur, id, rinfo, ci);
419       num_methods++;
420       break;
421     default:
422       break;
423     }
424   }
425
426   fprintf(ci->fh, "static const forb_skel_func %s_skeletons[%d] = {\n",
427           id, num_methods);
428   for(sub = IDL_INTERFACE(tree).body; sub; sub = IDL_LIST(sub).next) {
429     IDL_tree cur = IDL_LIST(sub).data;
430     
431     switch(IDL_NODE_TYPE(cur)) {
432     case IDLN_OP_DCL: {
433       char *op_id;
434       op_id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_OP_DCL(cur).ident), "_", 0);
435       fprintf(ci->fh, "  forb_skel_%s,\n", op_id);
436       g_free(op_id);
437       break;
438     }
439     default:
440       break;
441     }
442   }
443   fprintf(ci->fh, "};\n\n");
444
445   fprintf(ci->fh, "static const struct forb_interface %s_interface = {\n", id);
446   fprintf(ci->fh, "  .name = \"%s\",\n", id);
447   fprintf(ci->fh, "  .num_methods = %d,\n", num_methods);
448   fprintf(ci->fh, "  .skeletons = %s_skeletons,\n", id);
449   fprintf(ci->fh, "  .type_hash = 0 /* not implemented */\n");
450   fprintf(ci->fh, "};\n\n");
451
452 /*   fprintf(ci->fh, "void forb_register_%s_interface(void)\n" */
453 /*                "{\n" */
454 /*                "  forb_register_interface(&%s_interface);\n" */
455 /*                "}\n\n", id, id); */
456
457   fprintf(ci->fh, "%s forb_%s_new(forb_orb orb, const struct forb_%s_impl *impl,"
458                   "void *instance_data)\n"
459                   "{\n"
460                   "  %s obj = forb_object_new(orb, NULL, 0);\n"
461                   "  if (obj) {\n"
462                   "    obj->instance_data = instance_data;\n"
463                   "    obj->implementation = impl;\n"
464                   "    obj->interface = &%s_interface;\n"
465                   "  }\n"
466                   "  return obj;\n"
467           "}\n\n", id, id, id, id, id);
468   fprintf(ci->fh, "\n");
469   
470
471 /*   cbe_skel_interface_print_relayer(tree, rinfo, ci); */
472
473 /*   fprintf(ci->fh, */
474 /*        "void POA_%s__init(PortableServer_Servant servant,\nCORBA_Environment *env)\n", */
475 /*        id); */
476 /*   fprintf(ci->fh, "{\n"); */
477 /*   fprintf(ci->fh,"  static PortableServer_ClassInfo class_info = {"); */
478
479 /*   fprintf(ci->fh, "NULL, (Forb_small_impl_finder)&get_skel_small_%s, ", id); */
480
481 /*   fprintf(ci->fh,"\"%s\", &%s__classid, NULL, &%s__iinterface};\n", */
482 /*        IDL_IDENT(IDL_INTERFACE(tree).ident).repo_id, id, id); */
483
484 /*   fprintf(ci->fh,"  PortableServer_ServantBase__init (" */
485 /*               "       ((PortableServer_ServantBase *)servant), env);\n"); */
486
487 /*   for(curitem = IDL_INTERFACE(tree).inheritance_spec; curitem; */
488 /*       curitem = IDL_LIST(curitem).next) { */
489 /*     id2 = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_LIST(curitem).data), */
490 /*                                "_", 0); */
491 /*     fprintf(ci->fh, "  POA_%s__init(servant, env);\n", id2); */
492 /*     g_free(id2); */
493 /*   } */
494
495   /* registering after other __inits() makes the classids increment nicely. */
496 /*   fprintf (ci->fh, "   Forb_skel_class_register (&class_info,\n"); */
497 /*   fprintf (ci->fh, "   (PortableServer_ServantBase *)servant, POA_%s__fini,\n", id); */
498 /*   fprintf (ci->fh, "   FORB_VEPV_OFFSET (POA_%s__vepv, %s_epv),\n", id, id); */
499 /*   ti.for_id = id; ti.ci = ci; */
500 /*   IDL_tree_traverse_parents_full (tree, (GFunc) cbe_skel_interface_print_vepvmap_offsets, &ti, FALSE); */
501 /*   fprintf (ci->fh, "   (CORBA_unsigned_long) 0);"); */
502
503 /*   fprintf(ci->fh, "}\n\n"); */
504
505 /*   fprintf(ci->fh, */
506 /*        "void POA_%s__fini(PortableServer_Servant servant,\nCORBA_Environment *env)\n", */
507 /*        id); */
508 /*   fprintf(ci->fh, "{\n"); */
509 /*   if(IDL_INTERFACE(tree).inheritance_spec) */
510 /*     { */
511 /*       for(i = IDL_list_length(IDL_INTERFACE(tree).inheritance_spec) - 1; */
512 /*        i >= 0; i--) { */
513 /*      curitem = IDL_list_nth(IDL_INTERFACE(tree).inheritance_spec, i); */
514 /*      id2 = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_LIST(curitem).data), */
515 /*                                    "_", 0); */
516 /*      /\* XXX fixme - this is going to call ServantBase__fini multiple times *\/ */
517 /*      fprintf(ci->fh, "  POA_%s__fini(servant, env);\n", */
518 /*              id2); */
519 /*      g_free(id2); */
520 /*       } */
521 /*     } */
522 /*   fprintf(ci->fh, "  PortableServer_ServantBase__fini(servant, env);\n"); */
523 /*   fprintf(ci->fh, "}\n\n"); */
524
525   g_free(id);
526 }
527
528 void
529 forb_idl_output_c_skeletons (IDL_tree       tree,
530                               OIDL_Run_Info *rinfo,
531                               OIDL_C_Info   *ci)
532 {
533         fprintf (ci->fh, OIDL_C_WARNING);
534 /*      fprintf (ci->fh, "#include <string.h>\n"); */
535 /*      fprintf (ci->fh, "#define FORB2_STUBS_API\n"); */
536         fprintf (ci->fh, "#include \"%s.h\"\n\n", ci->base_name);
537         fprintf(ci->fh, "#include <forb/cdr.h>\n");
538         fprintf(ci->fh, "#include <forb/forb-internal.h>\n");
539         fprintf(ci->fh, "#include <forb/object.h>\n\n");
540
541         ck_output_poastuff (tree, rinfo, ci);
542 }