Ignore:
Timestamp:
Nov 26, 2006, 7:07:59 PM (19 years ago)
Author:
cinc
Message:

Corrected return typespec for overriden methods in *.ih files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ORBit2-2.14.0/src/idl-compiler/orbit-idl-c-skelimpl.c

    r117 r118  
    5555  char* chrOverridenMethodName;
    5656} InheritedOutputInfo;
     57
     58typedef struct {
     59  FILE *of;
     60  IDL_tree realif;
     61  char* chrOverridenMethodName;
     62  char* chrClassName;
     63} InheritedOutputInfo2;
    5764
    5865static const char *passnames[] = {
     
    223230}
    224231
    225 #if 0
    226 static
    227 void VoyagerWriteParamsForParentCall (FILE       *of,
    228                                       IDL_tree    op)
    229 {
    230   IDL_tree  sub;
    231  
    232   g_assert (IDL_NODE_TYPE(op) == IDLN_OP_DCL);
    233  
    234   fprintf (of, "(nomSelf, ");
    235    
    236   for (sub = IDL_OP_DCL (op).parameter_dcls; sub; sub = IDL_LIST (sub).next) {
    237     IDL_tree parm = IDL_LIST (sub).data;
    238     fprintf (of, "/**/ %s, ", IDL_IDENT (IDL_PARAM_DCL (parm).simple_declarator).str);
    239   }
    240   fprintf (of, " ev)");
    241 }
    242 #endif
    243 
    244 
    245232/*
    246233  This function is called for each parent to check if the current parent introduced the
     
    249236 */
    250237static
    251 void VoyagerDoWriteParamsForOverridenMethod(IDL_tree curif, InheritedOutputInfo *ioi)
     238void VoyagerDoWriteOverridenMethodDeclaration(IDL_tree curif, InheritedOutputInfo2 *ioi)
    252239{
    253240  IDL_tree curitem;
     
    271258         
    272259          g_assert (IDL_NODE_TYPE(curop) == IDLN_OP_DCL);
     260
     261          /* return typespec */
     262          orbit_cbe_write_param_typespec (ioi->of, curop);
     263         
     264          /* The methodname */
     265          fprintf (ioi->of, " %s%s_%s", "NOMLINK impl_",
     266                   ioi->chrClassName, overridenMethodName);
     267         
     268          fprintf (ioi->of, "(%s* nomSelf, ", ioi->chrClassName);
    273269         
    274270          /* Write the params including the typespec */         
     
    278274            orbit_cbe_write_param_typespec (ioi->of, parm);
    279275           
    280             fprintf (ioi->of, " %s,\n", IDL_IDENT (IDL_PARAM_DCL (parm).simple_declarator).str);
     276            fprintf (ioi->of, " %s, ", IDL_IDENT (IDL_PARAM_DCL (parm).simple_declarator).str);
    281277          }
    282278        }
     
    295291*/
    296292static void
    297 VoyagerWriteParamsForOverridenMethod(FILE       *of,
    298                                           IDL_tree    op,
    299                                           const char *nom_prefix,
    300                                           gboolean    for_epv)
    301 {
     293VoyagerWriteOverridenMethodDeclaration(FILE       *of,
     294                                     IDL_tree    op,
     295                                     const char *nom_prefix,
     296                                     gboolean    for_epv)
     297{
     298  char     *id;
    302299  char * id2;
    303300  char * ptr;
     
    305302
    306303  g_assert (IDL_NODE_TYPE(op) == IDLN_OP_DCL);
     304
     305  id = IDL_ns_ident_to_qstring (
     306                                IDL_IDENT_TO_NS (IDL_INTERFACE (
     307                                IDL_get_parent_node (op, IDLN_INTERFACE, NULL)).ident), "_", 0);
    307308
    308309  id2=g_strdup(IDL_IDENT (IDL_OP_DCL (op).ident).str);
     
    313314 
    314315  if(IDL_INTERFACE(tmptree).inheritance_spec) {
    315     InheritedOutputInfo ioi;
     316    InheritedOutputInfo2 ioi;
    316317   
    317318    ioi.of = of;
    318319    ioi.realif = tmptree;
    319320    ioi.chrOverridenMethodName=id2;
    320     IDL_tree_traverse_parents(IDL_INTERFACE(tmptree).inheritance_spec, (GFunc)VoyagerDoWriteParamsForOverridenMethod, &ioi);
     321    ioi.chrClassName=id; /* The current class name. In the called function the parent is searched introducing the method.
     322                            When this parent is found, the current class info isn't easy to get again but it's needed. */
     323
     324    IDL_tree_traverse_parents(IDL_INTERFACE(tmptree).inheritance_spec, (GFunc)VoyagerDoWriteOverridenMethodDeclaration, &ioi);
    321325  }
    322326  g_free(id2);
     327  g_free(id);
    323328}
    324329
     
    802807#if USE_LIBIDL_CODE   
    803808            fprintf(ski->of, "static ");
    804 #else
    805             fprintf(ski->of, "NOM_Scope ");
     809            fprintf(ski->of, " impl_%s(impl_POA_%s *servant,\n", id, id2);
    806810#endif
    807             orbit_cbe_write_param_typespec(ski->of, ski->tree);
    808 #if USE_LIBIDL_CODE   
    809             fprintf(ski->of, " impl_%s(impl_POA_%s *servant,\n", id, id2);
    810 #else
    811             if(bOverriden)
    812               fprintf(ski->of, " NOMLINK impl_%s_%s(%s *nomSelf,\n",
    813                       id2, gstr->str, id2);
    814             else
    815               fprintf(ski->of, " NOMLINK impl_%s_%s(%s *nomSelf,\n",
    816                       id2, IDL_IDENT(IDL_OP_DCL(ski->tree).ident).str, id2);
    817 #endif
     811
    818812            /* Output the params */
    819813            if(bOverriden)
    820814              {
    821                 fprintf(ski->of, "/* Params should end here ... */\n");
     815                /* Overriden method */
     816                fprintf(ski->of, "NOM_Scope ");
     817#if 0
     818                fprintf(ski->of, " NOMLINK impl_%s_%s(%s *nomSelf,\n",
     819                        id2, gstr->str, id2);
     820#endif
    822821                op = ski->tree;
    823                 VoyagerWriteParamsForOverridenMethod(ski->of,
    824                                                      op,
    825                                                      "",
    826                                                      FALSE);
     822                VoyagerWriteOverridenMethodDeclaration(ski->of,
     823                                                       op,
     824                                                       "",
     825                                                       FALSE);
    827826
    828827                for(curitem = IDL_OP_DCL(ski->tree).parameter_dcls;
     
    834833            else
    835834              {
     835                fprintf(ski->of, "NOM_Scope ");
     836
     837                orbit_cbe_write_param_typespec(ski->of, ski->tree);
     838                fprintf(ski->of, " NOMLINK impl_%s_%s(%s *nomSelf,\n",
     839                        id2, IDL_IDENT(IDL_OP_DCL(ski->tree).ident).str, id2);
     840
    836841                op = ski->tree;
    837842                for(curitem = IDL_OP_DCL(ski->tree).parameter_dcls;
Note: See TracChangeset for help on using the changeset viewer.