Changeset 249


Ignore:
Timestamp:
Mar 11, 2007, 12:49:25 AM (18 years ago)
Author:
cinc
Message:

Provide parameter info for methods for runtime type information.

Location:
trunk/ORBit2-2.14.0/src/idl-compiler
Files:
3 edited

Legend:

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

    r92 r249  
    7777gulong orbit_cbe_get_typespec_size(IDL_tree tree);
    7878
     79void orbit_cbe_voyager_write_param_typespec(FILE *of, IDL_tree tree);
    7980#endif
  • trunk/ORBit2-2.14.0/src/idl-compiler/orbit-idl-c-skelimpl.c

    r205 r249  
    2222
    2323/* Used to count the static methods of a class. This is kind of a hack.
    24    I would loce to put it into CBESkelImplInfo but his struct is copied
     24   I would love to put it into CBESkelImplInfo but his struct is copied
    2525   everywhere and given as a copy to subprocedures. */
    2626static gulong ulNumStaticMethods[10];
     
    292292*/
    293293static void
    294 VoyagerWriteOverridenMethodDeclaration(FILE       *of,
    295                                      IDL_tree    op,
     294VoyagerWriteOverridenMethodDeclaration(FILE       *of, IDL_tree    op,
    296295                                     const char *nom_prefix,
    297296                                     gboolean    for_epv)
     
    365364}
    366365
     366/*
     367  This function outputs the parameter type of methods without the 'const'
     368  qualifier.
     369 */
     370static void VoyagerOutputParamTypes(CBESkelImplInfo *ski)
     371{
     372  if(IDLN_PARAM_DCL!=IDL_NODE_TYPE(ski->tree))
     373    return;
     374
     375  orbit_cbe_voyager_write_param_typespec(ski->of, ski->tree);
     376 
     377}
    367378
    368379static void
     
    385396        case IDLN_INTERFACE:
    386397                cbe_ski_do_interface(ski);
    387 #if 0
    388         if(whichPass==ski->pass)
    389           ulCurInterface++;
    390         else{
    391           whichPass=ski->pass;
    392           ulCurInterface=0;
    393         }
    394 #endif
    395398        //        printf("%d: pass --->%d %d %d\n", __LINE__, ski->pass, whichPass, ulCurInterface);
    396399                break;
     
    818821                /* Overriden method */
    819822                fprintf(ski->of, "NOM_Scope ");
    820 #if 0
    821                 fprintf(ski->of, " NOMLINK impl_%s_%s(%s *nomSelf,\n",
    822                         id2, gstr->str, id2);
    823 #endif
    824823                op = ski->tree;
    825                 VoyagerWriteOverridenMethodDeclaration(ski->of,
    826                                                        op,
    827                                                        "",
    828                                                        FALSE);
     824                VoyagerWriteOverridenMethodDeclaration(ski->of, op, "", FALSE);
    829825
    830826                for(curitem = IDL_OP_DCL(ski->tree).parameter_dcls;
     
    888884                  ioi.realif = tmptree;
    889885                  ioi.chrOverridenMethodName=gstr->str;
    890                   IDL_tree_traverse_parents(IDL_INTERFACE(tmptree).inheritance_spec, (GFunc)VoyagerOutputIntroducingClass, &ioi);
     886                  IDL_tree_traverse_parents(IDL_INTERFACE(tmptree).inheritance_spec,
     887                                            (GFunc)VoyagerOutputIntroducingClass, &ioi);
    891888                }
    892889                fprintf(ski->of, ":%s\";\n",gstr->str); /* Output the method name */
     
    904901                  ioi.realif = tmptree;
    905902                  ioi.chrOverridenMethodName=gstr->str;
    906                   IDL_tree_traverse_parents(IDL_INTERFACE(tmptree).inheritance_spec, (GFunc)VoyagerWriteParamsForParentCall, &ioi);
     903                  IDL_tree_traverse_parents(IDL_INTERFACE(tmptree).inheritance_spec,
     904                                            (GFunc)VoyagerWriteParamsForParentCall, &ioi);
    907905                }
    908906                fprintf(ski->of, "ev)");
     
    916914                  ioi.realif = tmptree;
    917915                  ioi.chrOverridenMethodName=gstr->str;
    918                   IDL_tree_traverse_parents(IDL_INTERFACE(tmptree).inheritance_spec, (GFunc)VoyagerOutputParentMethodSpec, &ioi);
     916                  IDL_tree_traverse_parents(IDL_INTERFACE(tmptree).inheritance_spec,
     917                                            (GFunc)VoyagerOutputParentMethodSpec, &ioi);
    919918                }
    920919                fprintf(ski->of, ") \\\n    %s_parent_resolved)", id);
     
    929928                  ioi.realif = tmptree;
    930929                  ioi.chrOverridenMethodName=gstr->str;
    931                   IDL_tree_traverse_parents(IDL_INTERFACE(tmptree).inheritance_spec, (GFunc)VoyagerOutputIntroducingClass, &ioi);
     930                  IDL_tree_traverse_parents(IDL_INTERFACE(tmptree).inheritance_spec,
     931                                            (GFunc)VoyagerOutputIntroducingClass, &ioi);
    932932                }
    933933                fprintf(ski->of, "*)nomSelf, ");
     
    939939                  ioi.realif = tmptree;
    940940                  ioi.chrOverridenMethodName=gstr->str;
    941                   IDL_tree_traverse_parents(IDL_INTERFACE(tmptree).inheritance_spec, (GFunc)VoyagerWriteParamsForParentCall, &ioi);
     941                  IDL_tree_traverse_parents(IDL_INTERFACE(tmptree).inheritance_spec,
     942                                            (GFunc)VoyagerWriteParamsForParentCall, &ioi);
    942943                }
    943944                fprintf(ski->of, "ev)");
     
    952953                      id2, IDL_IDENT(IDL_OP_DCL(ski->tree).ident).str);
    953954            }
     955
     956            /* Output the parameter info */
     957            if(!bOverriden)
     958              {
     959                int a=0;
     960                IDL_tree tmptree;
     961
     962                tmptree = IDL_get_parent_node(ski->tree, IDLN_INTERFACE, NULL);
     963
     964                fprintf(ski->of, "static nomParmInfo nomParm_%s = {\n", id);
     965
     966                /* Output number of parameters */
     967                for(curitem = IDL_OP_DCL(ski->tree).parameter_dcls;
     968                    curitem; curitem = IDL_LIST(curitem).next) {
     969                  a++; /* Count parameters */
     970                }
     971                fprintf(ski->of, "  %d,  /* Number of parameters */\n", a);
     972
     973                /* Output return type */
     974                fprintf(ski->of, "  /* Return type (%s: %s line %d)*/\n  \"", __FILE__, __FUNCTION__, __LINE__);
     975                orbit_cbe_write_param_typespec(ski->of, ski->tree);
     976                fprintf(ski->of, "\",\n  {");
     977
     978                op = ski->tree;
     979                for(curitem = IDL_OP_DCL(ski->tree).parameter_dcls;
     980                    curitem; curitem = IDL_LIST(curitem).next) {
     981                  subski.tree = IDL_LIST(curitem).data;
     982                 
     983                  fprintf(ski->of, "  \"");
     984                  if(IDLN_PARAM_DCL==IDL_NODE_TYPE(subski.tree))
     985                    VoyagerOutputParamTypes(&subski);
     986                  fprintf(ski->of, "\",\n");
     987                }
     988                fprintf(ski->of, "}};\n");
     989              }
     990
    954991            if(ptr!=NULL)
    955992                *ptr='_';
     
    9841021                id2 = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(curitem).ident), "_", 0);
    9851022
    986         /* Check for our specailly marked NOM-only methods. Don't output them, they are handled
     1023        /* Check for our specially marked NOM-only methods. Don't output them, they are handled
    9871024           specially. */
    9881025          if(!strstr(id, NOM_INSTANCEVAR_STRING) &&
     
    9941031            fprintf(ski->of, "  &nomFullIdString_%s_%s,  /* char *chrMethodDescriptor */\n",
    9951032                    id2, IDL_IDENT(IDL_OP_DCL(ski->tree).ident).str);
    996             fprintf(ski->of, "  (nomMethodProc*)  impl_%s_%s\n", id2, IDL_IDENT(IDL_OP_DCL(ski->tree).ident).str);
     1033            fprintf(ski->of, "  (nomMethodProc*)  impl_%s_%s,\n", id2, IDL_IDENT(IDL_OP_DCL(ski->tree).ident).str);
     1034            fprintf(ski->of, "  &nomParm_%s_%s\n", id2, IDL_IDENT(IDL_OP_DCL(ski->tree).ident).str);
    9971035            fprintf(ski->of, "},\n");
    9981036
     
    10841122
    10851123
    1086         /* Check for our specailly marked NOM-only methods. Don't output them, they are handled
     1124        /* Check for our specially marked NOM-only methods. Don't output them, they are handled
    10871125           specially. */
    10881126        if(!strstr(IDL_IDENT(ident).str, NOM_INSTANCEVAR_STRING) &&
     
    12341272}
    12351273
     1274/*
     1275  CW: When doing a pass we first end here for each interface. By calling
     1276  cbe_ski_do_list() all nodes are traversed and the subfunctions are called
     1277  accordingly.
     1278
     1279 */
    12361280static void
    12371281cbe_ski_do_interface(CBESkelImplInfo *ski)
     
    12621306                IDL_tree_traverse_parents(ski->tree, (GFunc)&cbe_ski_do_inherited_methods, ski);
    12631307       
    1264 
    12651308        break;
    12661309      }
  • trunk/ORBit2-2.14.0/src/idl-compiler/orbit-idl-c-utils.c

    r92 r249  
    407407}
    408408
     409/*
     410  This is almost the same like orbit_cbe_write_param_typespec_str(). We only omit the
     411  'const' qualifier because we only need the parameter type.
     412 */
     413static char *
     414orbit_cbe_voyager_write_param_typespec_str(IDL_tree ts, IDL_ParamRole role)
     415{
     416        int      i, n;
     417        gboolean isSlice;
     418        char    *name;
     419        GString *str = g_string_sized_new (23);
     420        IDL_tree typedef_spec;
     421        char *typedef_name;
     422
     423        n = oidl_param_info (ts, role, &isSlice);
     424        name = orbit_cbe_get_typespec_str (ts);
     425
     426        if ( role == DATA_IN ) {
     427                /* We want to check if this is a typedef for CORBA_string so we can do special handling
     428                 * in that case.
     429                 */
     430                typedef_spec = orbit_cbe_get_typespec (ts);
     431                typedef_name = orbit_cbe_get_typespec_str (typedef_spec);
     432
     433                g_string_printf (str, "%s",
     434                                 !strcmp (typedef_name, "CORBA_string") ?
     435                                 "CORBA_char *" : name);
     436
     437                g_free (typedef_name);
     438        } else
     439                g_string_printf (str, "%s", name);
     440
     441        g_free (name);
     442
     443        if ( isSlice )
     444                g_string_append (str, "_slice");
     445
     446        for (i = 0; i < n; i++)
     447                g_string_append_c (str, '*');
     448
     449        return g_string_free (str, FALSE);
     450}
     451
     452/*
     453  This helper just writes the typespec of a parameter to a method without any
     454  'const' qualifier.
     455 */
     456void
     457orbit_cbe_voyager_write_param_typespec(FILE *of, IDL_tree tree) {
     458    IDL_tree            ts = NULL /* Quiet gcc */;
     459    IDL_ParamRole       role = 0 /* Quiet gcc */;
     460    char *str;
     461
     462    switch ( IDL_NODE_TYPE(tree) ) {
     463    case IDLN_PARAM_DCL: /* one of the parameters */
     464        ts = IDL_PARAM_DCL(tree).param_type_spec;
     465        role = oidl_attr_to_paramrole(IDL_PARAM_DCL(tree).attr);
     466        break;
     467    default:
     468        g_assert_not_reached();
     469    }
     470
     471    str = orbit_cbe_voyager_write_param_typespec_str (ts, role);
     472    fprintf (of, str);
     473    g_free (str);
     474}
     475
    409476static void
    410477orbit_cbe_write_param_typespec_raw (FILE *of, IDL_tree ts, IDL_ParamRole role)
Note: See TracChangeset for help on using the changeset viewer.