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

Missing parameters in templates of overriden methods fixed.

File:
1 edited

Legend:

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

    r115 r116  
    77  IDL_tree realif;
    88  char* chrOverridenMethodName;
    9 } InheritedOutputInfo;
     9  char* chrClassName;
     10} InheritedOutputInfo2;
    1011
    1112static void
    12 VoyagerOutputOverridenMethodTemplate(IDL_tree curif, InheritedOutputInfo *ioi)
     13VoyagerOutputOverridenMethodTemplate(IDL_tree curif, InheritedOutputInfo2 *ioi)
    1314{
    1415  char *id, *realid;
     
    6061
    6162static
    62 void VoyagerWriteParamsForParentCall(IDL_tree curif, InheritedOutputInfo *ioi)
     63void VoyagerWriteParamsForParentCall(IDL_tree curif, InheritedOutputInfo2 *ioi)
    6364{
    6465  IDL_tree curitem;
     
    100101                                gboolean    for_epv)
    101102{
    102   IDL_tree  sub;
    103103  char     *id;
    104104  char * id2;
     
    124124    fprintf (of, "nomSelf, ");
    125125
    126 
    127126    tmptree = IDL_get_parent_node(op, IDLN_INTERFACE, NULL);
    128127
    129128    if(IDL_INTERFACE(tmptree).inheritance_spec) {
    130       InheritedOutputInfo ioi;
     129      InheritedOutputInfo2 ioi;
    131130     
    132131      ioi.of = of;
    133132      ioi.realif = tmptree;
    134133      ioi.chrOverridenMethodName=id2;
     134      ioi.chrOverridenMethodName="";
    135135      IDL_tree_traverse_parents(IDL_INTERFACE(tmptree).inheritance_spec, (GFunc)VoyagerWriteParamsForParentCall, &ioi);
    136136    }
    137137
    138 #if 0
    139         for (sub = IDL_OP_DCL (op).parameter_dcls; sub; sub = IDL_LIST (sub).next) {
    140                 IDL_tree parm = IDL_LIST (sub).data;
    141 
    142                 //orbit_cbe_write_param_typespec (of, parm);
    143                 fprintf (of, " %s, ", IDL_IDENT (IDL_PARAM_DCL (parm).simple_declarator).str);
    144         }
    145 #endif
    146138    g_free(id2);
    147139        g_free (id);
    148140        fprintf (of, " ev);\n");
    149141}
     142
     143static
     144void VoyagerDoWriteParamsForOverridenMethod(IDL_tree curif, InheritedOutputInfo2 *ioi)
     145{
     146  IDL_tree curitem;
     147  char* overridenMethodName;
     148
     149  if(curif == ioi->realif)
     150    return;
     151
     152  overridenMethodName=ioi->chrOverridenMethodName;
     153
     154  for(curitem = IDL_INTERFACE(curif).body; curitem; curitem = IDL_LIST(curitem).next) {
     155    IDL_tree curop = IDL_LIST(curitem).data;
     156
     157    switch(IDL_NODE_TYPE(curop)) {
     158    case IDLN_OP_DCL:
     159      {
     160        /* Check if the current method (introduced by some parent) is the one to be
     161           overriden. */
     162        if(!strcmp(overridenMethodName, IDL_IDENT(IDL_OP_DCL(curop).ident).str)){
     163          IDL_tree  sub;
     164         
     165          g_assert (IDL_NODE_TYPE(curop) == IDLN_OP_DCL);
     166
     167          /* return typespec */
     168          orbit_cbe_write_param_typespec (ioi->of, curop);
     169         
     170          /* The methodname */
     171          fprintf (ioi->of, " %s%s_%s", "NOMLINK impl_",
     172                   ioi->chrClassName, overridenMethodName);
     173         
     174          fprintf (ioi->of, "(%s* nomSelf, ", ioi->chrClassName);
     175         
     176          /* Write the params including the typespec */         
     177          for (sub = IDL_OP_DCL (curop).parameter_dcls; sub; sub = IDL_LIST (sub).next) {
     178            IDL_tree parm = IDL_LIST (sub).data;
     179           
     180            orbit_cbe_write_param_typespec (ioi->of, parm);
     181           
     182            fprintf (ioi->of, " %s, ", IDL_IDENT (IDL_PARAM_DCL (parm).simple_declarator).str);
     183          }
     184         
     185          if (IDL_OP_DCL (curop).context_expr)
     186            fprintf (ioi->of, "CORBA_Context _ctx, ");
     187         
     188          fprintf (ioi->of, "CORBA_Environment *ev)");
     189        }
     190        break;
     191      }
     192        default:
     193          break;
     194    }
     195  }
     196}
     197
     198void VoyagerWriteParamsForOverridenMethod(FILE       *of,
     199                                IDL_tree    op,
     200                                const char *nom_prefix,
     201                                gboolean    for_epv)
     202{
     203  char     *id;
     204  char * id2;
     205  char * ptr;
     206  IDL_tree tmptree;
     207
     208  g_assert (IDL_NODE_TYPE(op) == IDLN_OP_DCL);
     209 
     210  id = IDL_ns_ident_to_qstring (
     211                                IDL_IDENT_TO_NS (IDL_INTERFACE (
     212                                IDL_get_parent_node (op, IDLN_INTERFACE, NULL)).ident), "_", 0);
     213
     214    id2=g_strdup(IDL_IDENT (IDL_OP_DCL (op).ident).str);
     215    if((ptr=strstr(id2, NOM_OVERRIDE_STRING))!=NULL)
     216       *ptr='\0';
     217
     218    tmptree = IDL_get_parent_node(op, IDLN_INTERFACE, NULL);
     219
     220    if(IDL_INTERFACE(tmptree).inheritance_spec) {
     221      InheritedOutputInfo2 ioi;
     222     
     223      ioi.of = of;
     224      ioi.realif = tmptree;
     225      ioi.chrOverridenMethodName=id2;
     226      ioi.chrClassName=id; /* The current class name. In the called function the parent is searched introducing the method.
     227                            When this parent is found, the current class info isn't easy to get again but it's needed. */
     228      IDL_tree_traverse_parents(IDL_INTERFACE(tmptree).inheritance_spec, (GFunc)VoyagerDoWriteParamsForOverridenMethod, &ioi);
     229    }
     230    g_free(id2);
     231        g_free (id);
     232}
     233
    150234
    151235static void
     
    225309        fprintf (of, "}\n");
    226310#else
    227     /* This is Voyager stuff... */
     311    /*** This is Voyager stuff... ***/
    228312    if(strstr(opname, NOM_INSTANCEVAR_STRING)==NULL &&
    229313       strstr(opname, NOM_OVERRIDE_STRING)==NULL)
     
    249333    if(strstr(opname, NOM_OVERRIDE_STRING)!=NULL)
    250334      {
    251         IDL_tree tmptree;
    252 
    253335        /* There's an overriden method here */
     336        fprintf (of, "\n/* %s, %s line %d */\n", __FILE__, __FUNCTION__, __LINE__);
    254337        fprintf (of, "NOM_Scope ");
    255338
    256         orbit_cbe_op_write_proto (of, tree, "NOMLINK impl_", FALSE);
     339        VoyagerWriteParamsForOverridenMethod (of, tree, "", FALSE);
    257340
    258341        fprintf (of, "\n{\n");
Note: See TracChangeset for help on using the changeset viewer.