Changeset 280


Ignore:
Timestamp:
Mar 30, 2007, 10:31:24 PM (18 years ago)
Author:
cinc
Message:

A load of fixes.

Location:
trunk/idl-compiler
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/idl-compiler/c/emitter.c

    r278 r280  
    5454    {
    5555      int b;
     56      gchar *chrType;
    5657      PMETHODPARAM pm=(PMETHODPARAM)g_ptr_array_index(pArray, a);
     58
     59      chrType= pm->chrType;
     60
     61      /* For old IDL files using orbit IDL compiler */
     62      if(!strcmp(pm->chrType, "string"))
     63        chrType="CORBA_char*";
     64      if(!strcmp(pm->chrType, "long"))
     65        chrType="CORBA_long";
    5766
    5867      switch(pm->uiDirection)
    5968        {
    6069        case PARM_DIRECTION_IN:
    61           fprintf(fh, "    const %s", pm->chrType);
     70          fprintf(fh, "    const %s", chrType);
    6271          break;
    6372        case PARM_DIRECTION_OUT:
    64           fprintf(fh, "    %s*", pm->chrType);
     73          fprintf(fh, "    %s*", chrType);
    6574          break;
    6675        case PARM_DIRECTION_INOUT:
    67 
     76          fprintf(fh, "    %s*", chrType);
    6877          break;
    6978        default:
    70           fprintf(fh, "    %s*", pm->chrType);
     79
    7180          break;
    7281        }
     
    91100    }
    92101}
     102
     103/**
     104   This function emits the return type of a method. It translates CORBA identifiers
     105   into another representation e.g. long->glong. At the moment it's used to be compatible
     106   with old source written using the orbit IDL compiler.
     107 */
     108void emitReturnType(PPARSEINFO pLocalPI, PINTERFACE pif, PMETHOD pm)
     109{
     110  FILE* fh=pLocalPI->outFile;
     111  int b;
     112  gchar* chrType;
     113
     114  chrType= pm->mpReturn.chrType;
     115
     116  /* Support for orbit IDL files */
     117  if(!strcmp(pm->mpReturn.chrType, "long"))
     118    chrType="CORBA_long";
     119  else if(!strcmp(pm->mpReturn.chrType, "boolean"))
     120    chrType="CORBA_boolean";
     121
     122  fprintf(fh, "%s", chrType);
     123  for(b=0;b<pm->mpReturn.uiStar;b++)
     124    fprintf(fh, "*");
     125}
  • trunk/idl-compiler/c/nom-idl-compiler.c

    r278 r280  
    548548    }
    549549
     550#if 0
    550551  for(a=0; a<argc; a++)
    551552    {
    552553      g_message("arg %d: %s", a, argv[a]);
    553554    }
    554 
     555#endif
    555556 
    556557  /*** Create output path name ****/
  • trunk/idl-compiler/h-emitter_c/h_file_emitter.c

    r278 r280  
    8080  /* Include header of parent */
    8181  if(pifParent){
    82     char* chrTemp=strlwr(g_strdup(pifParent->chrName));
    8382    fprintf(fh, "/* Include for the parent class */\n");
    84     fprintf(fh, "#include \"%s.h\"\n\n", chrTemp);
    85     g_free(chrTemp);
     83    if(pifParent->chrFileStem)
     84      fprintf(fh, "#include \"%s.h\"\n\n", pifParent->chrFileStem);
    8685  }
    8786}
     
    110109      fprintf(fh, "    nomMToken %s;\n", pm->chrName);
    111110    }
    112   fprintf(fh, "}%sClassData\n\n", pif->chrName);
     111  fprintf(fh, "}%sClassData;\n\n", pif->chrName);
    113112
    114113  fprintf(fh, "NOMEXTERN struct %sCClassDataStructure {\n", pif->chrName);
     
    124123  FILE* fh=pLocalPI->outFile;
    125124
    126   fprintf(fh, "/* This function is used to check if a given object is valid and the\n");
    127   fprintf(fh, "   object supports the method */\n");
    128   fprintf(fh, "NOMEXTERN gboolean NOMLINK nomCheckObjectPtr(NOMObject *nomSelf, NOMClass* nomClass, gchar* chrMethodName, CORBA_Environment *ev);\n\n");
     125  if(strcmp(pif->chrName , "NOMObject"))
     126    {
     127      fprintf(fh, "/* This function is used to check if a given object is valid and the\n");
     128      fprintf(fh, "   object supports the method */\n");
     129      fprintf(fh, "NOMEXTERN gboolean NOMLINK nomCheckObjectPtr(NOMObject *nomSelf, NOMClass* nomClass, gchar* chrMethodName, CORBA_Environment *ev);\n\n");
     130    }
     131  else
     132    {
     133      fprintf(fh, "/* This function is used to check if the given object is valid and a NOMObject */\n");
     134      fprintf(fh, "NOMEXTERN gboolean NOMLINK nomCheckNOMObjectPtr(NOMObject *nomSelf, NOMClass* nomClass, gchar* chrMethodName, CORBA_Environment *ev);\n\n");
     135    }
    129136}
    130137
     
    157164      emitMethodParams(pLocalPI, pif, pm->pParamArray);
    158165
    159       fprintf(fh, "    Corba_Environment *ev);\n");
    160       fprintf(fh, "typedef nomTP_%s_%s *nomTD_%s_%s\n", pif->chrName,  pm->chrName,
     166      fprintf(fh, "    CORBA_Environment *ev);\n");
     167      fprintf(fh, "typedef nomTP_%s_%s *nomTD_%s_%s;\n", pif->chrName,  pm->chrName,
    161168              pif->chrName,  pm->chrName);
    162169      fprintf(fh, "/* define the name for this method */\n");
     
    173180      /* Do parameters */
    174181      emitMethodParams(pLocalPI, pif, pm->pParamArray);
    175       fprintf(fh, "    Corba_Environment *ev);\n");
     182      fprintf(fh, "    CORBA_Environment *ev);\n");
    176183
    177184      fprintf(fh, "#define %s_%s(nomSelf,", pif->chrName, pm->chrName);
     
    193200      emitMethodParamsNoTypes(pLocalPI, pif, pm->pParamArray);
    194201      fprintf(fh, " ev) \\\n");
    195       fprintf(fh, "        (nomCheckObjectPtr((NOMObject*)nomSelf, %sClassData.classObject,",pif->chrName);
     202      if(strcmp(pif->chrName , "NOMObject"))
     203        fprintf(fh, "        (nomCheckObjectPtr((NOMObject*)nomSelf, %sClassData.classObject,",pif->chrName);
     204      else
     205        fprintf(fh, "        (nomCheckNOMObjectPtr(nomSelf, %sClassData.classObject,",pif->chrName);
    196206      fprintf(fh, "\"%s_%s\", ev) ? \\\n", pif->chrName, pm->chrName);
    197207
     
    200210      /* Do parameters */
    201211      emitMethodParamsNoTypes(pLocalPI, pif, pm->pParamArray);
    202       fprintf(fh, " ev)) : (gpointer) NULL)\n");
     212      fprintf(fh, " ev)) : (%s", pm->mpReturn.chrType);
     213      for(b=0;b<pm->mpReturn.uiStar;b++)
     214        fprintf(fh, "*");
     215      fprintf(fh, ") NULL)\n");
    203216      fprintf(fh, "#endif\n");
    204217      fprintf(fh, "#else /* NOM_NO_PARAM_CHECK */\n");
     
    285298          chrTemp=g_strconcat(pif->chrFileStem, ".h", NULL);
    286299
    287           printInterface(pif);
     300          //printInterface(pif);
    288301          if((pLocalPI->outFile=openOutfile(gScanner, chrTemp))!=NULLHANDLE)
    289302            {
  • trunk/idl-compiler/ih-emitter_c/ih_file_emitter.c

    r279 r280  
    103103      PMETHODPARAM piv=(PMETHODPARAM)g_ptr_array_index(pArray, a);
    104104     
    105       fprintf(fh, "#define  _%s (nomThis->%s);\n", piv->chrName, piv->chrName);
     105      fprintf(fh, "#define  _%s (nomThis->%s)\n", piv->chrName, piv->chrName);
    106106    }
    107107  fprintf(fh, "\n");
     
    187187      fprintf(fh, "#if !defined(_decl_impl_%s_%s_)\n", pif->chrName, pm->chrName);
    188188      fprintf(fh, "#define _decl_impl_%s_%s_ 1\n", pif->chrName, pm->chrName);
    189       fprintf(fh, "NOM_Scope %s ", pm->mpReturn.chrType);
    190       fprintf(fh, "NOMLINK impl_%s_%s(%s *nomSelf,\n", pif->chrName, pm->chrName, pif->chrName);
     189      fprintf(fh, "NOM_Scope ");
     190      emitReturnType(pLocalPI, pif, pm);
     191      fprintf(fh, " NOMLINK impl_%s_%s(%s *nomSelf,\n", pif->chrName, pm->chrName, pif->chrName);
    191192      /* Do parameters */
    192193      emitMethodParams(pLocalPI, pif, pm->pParamArray);
     
    202203      fprintf(fh, "  \"%s\", /* Return type */\n  {\n", pm->mpReturn.chrType);
    203204      emitMethodParamStrings(pLocalPI, pif, pm->pParamArray);
    204       fprintf(fh, "  }\n}\n");
     205      fprintf(fh, "  }\n};\n");
    205206
    206207      fprintf(fh, "#endif /* _decl_impl_%s_%s_ */\n\n", pif->chrName, pm->chrName);
     
    252253      emitMethodParamsNoTypes(pLocalPI, pif, pm->pParamArray);
    253254      fprintf(fh, " ev) \\\n");
    254       fprintf(fh, "        (((nomTD_%s_%s) \\\n", pif->chrName, pom->chrName);
     255      fprintf(fh, "        (((nomTD_%s_%s) \\\n", pifIntroduced->chrName, pom->chrName);
    255256
    256257      fprintf(fh, "        %s_%s_parent_resolved)((%s*)nomSelf,",
     
    269270
    270271  fprintf(fh, "/* Table of the overriden methods by this class */\n");
    271   fprintf(fh, "static nomOverridenMethodDesc nomOverridenMethodsWPRootFolder[] = {\n");
     272  fprintf(fh, "static nomOverridenMethodDesc nomOverridenMethods%s[] = {\n", pif->chrName);
    272273
    273274  for(a=0;a<pArray->len;a++)
     
    324325  FILE* fh=pLocalPI->outFile;
    325326
    326   fprintf(fh, "/* The meta class for this class */\n");
    327   fprintf(fh, "static char * nomIdStringMetaClass_%s = \"%s\";\n\n", pif->chrName, pif->chrMetaClass);
     327  if(pif->chrMetaClass)
     328    {
     329      fprintf(fh, "/* The meta class for this class */\n");
     330      fprintf(fh, "static char * nomIdStringMetaClass_%s = \"%s\";\n\n", pif->chrName, pif->chrMetaClass);
     331    }
    328332}
    329333
     
    347351  int a;
    348352
    349   fprintf(fh, "/* Array of parent names (chain of parents) */\n");
    350   fprintf(fh, "static char* nomParentClassNames%s[]=\n{\n", pif->chrName);
    351   /* Emit the parents. We have to output them sorted beginning from the
    352      leftmost parent. */
    353   while(pifParent->chrParent && (pifParent=findInterfaceFromName(pifParent->chrParent))!=NULLHANDLE)
    354     {
    355       g_ptr_array_add(pArray, (gpointer) pifParent);
    356     }
    357 
    358   for(a=pArray->len-1; a>=0; a--)
    359     {
    360       pifParent=(PINTERFACE)g_ptr_array_index(pArray, a);
    361       fprintf(fh, "  \"%s\",\n", pifParent->chrName);
    362     }
    363   g_ptr_array_free(pArray, TRUE);
    364   fprintf(fh, "};\n\n");
    365 
    366   fprintf(fh, "static char * nomIdString_Parent_%s = \"%s\";\n\n", pif->chrParent, pif->chrParent);
    367 
    368   fprintf(fh, "/* Array of parent IDs (direct parents, for now NOM only support single inheritance) */\n");
    369   fprintf(fh, "static nomID nomParentClasses%s[]=\n", pif->chrName);
    370   fprintf(fh, "{\n");
    371   fprintf(fh, "  &nomIdString_Parent_%s,\n", pif->chrParent);
    372   fprintf(fh, "};\n\n");
     353  if(pif->chrParent)
     354    {
     355      fprintf(fh, "/* Array of parent names (chain of parents) */\n");
     356      fprintf(fh, "static char* nomParentClassNames%s[]=\n{\n", pif->chrName);
     357      /* Emit the parents. We have to output them sorted beginning from the
     358         leftmost parent. */
     359      while(pifParent->chrParent && (pifParent=findInterfaceFromName(pifParent->chrParent))!=NULLHANDLE)
     360        {
     361          g_ptr_array_add(pArray, (gpointer) pifParent);
     362        }
     363     
     364      for(a=pArray->len-1; a>=0; a--)
     365        {
     366          pifParent=(PINTERFACE)g_ptr_array_index(pArray, a);
     367          fprintf(fh, "  \"%s\",\n", pifParent->chrName);
     368        }
     369      g_ptr_array_free(pArray, TRUE);
     370      fprintf(fh, "};\n\n");
     371     
     372      fprintf(fh, "static char * nomIdString_Parent_%s = \"%s\";\n\n", pif->chrParent, pif->chrParent);
     373     
     374      fprintf(fh, "/* Array of parent IDs (direct parents, for now NOM only support single inheritance) */\n");
     375      fprintf(fh, "static nomID nomParentClasses%s[]=\n", pif->chrName);
     376      fprintf(fh, "{\n");
     377      fprintf(fh, "  &nomIdString_Parent_%s,\n", pif->chrParent);
     378      fprintf(fh, "};\n\n");
     379    }
    373380}
    374381
     
    443450  FILE* fh=pLocalPI->outFile;
    444451
     452  fprintf(fh, "/* Identify this class */\n");
     453  fprintf(fh, "static char * nomIdString_%s = \"%s\";\n\n", pif->chrName, pif->chrName);
     454
    445455  fprintf(fh, "static nomStaticClassInfo %sSCI = {\n", pif->chrName);
    446456  fprintf(fh, "  0,               /* Version */\n");
     
    461471  fprintf(fh, "  (nomStaticMethodDesc*)&nomStaticMethods%s,\n", pif->chrName);
    462472  if(pif->chrParent)
     473    {
    463474    fprintf(fh, "  nomParentClasses%s,\n", pif->chrName);
     475    fprintf(fh, "  nomParentClassNames%s, /* Name of all the parent classes in chain */\n", pif->chrName);
     476    }
    464477  else
    465     fprintf(fh, "  NULL,\n");
    466   fprintf(fh, "  nomParentClassNames%s, /* Name of all the parent classes in chain */\n", pif->chrName);
     478    {
     479      fprintf(fh, "    (void*)NULL,\n");
     480      fprintf(fh, "    (void*)NULL,\n");
     481    }
     482
    467483  fprintf(fh, "  %ld,                /* Number of parents in the chain of classes */\n",
    468484          getNumberOfParentsInChain( pLocalPI,  pif));
     
    521537              pif->chrMetaClass, pif->chrMetaClass, pif->chrMetaClass);
    522538    }
    523   fprintf(fh, "  %sNewClass(%s_MajorVersion, %s_MinorVersion);\n",
    524           pif->chrParent, pif->chrParent, pif->chrParent);
     539  if(pif->chrParent)
     540    {
     541      fprintf(fh, "  /* Create the parent class */\n");
     542      fprintf(fh, "  %sNewClass(%s_MajorVersion, %s_MinorVersion);\n",
     543              pif->chrParent, pif->chrParent, pif->chrParent);
     544    }
    525545  fprintf(fh, "  result = nomBuildClass(1, &%sSCI, ulMajor, ulMinor);\n\n", pif->chrName);
    526546  fprintf(fh, "  return result;\n");
     
    548568          gchar*  chrTemp;
    549569
    550           printInterface(pif);
     570          //printInterface(pif);
    551571         
    552572          chrTemp=g_strconcat(pif->chrFileStem, ".ih", NULL);
  • trunk/idl-compiler/include/parser.h

    r278 r280  
    183183void emitMethodParams(PPARSEINFO pLocalPI, PINTERFACE pif, GPtrArray *pArray);
    184184void emitMethodParamsNoTypes(PPARSEINFO pLocalPI, PINTERFACE pif, GPtrArray *pArray);
     185void emitReturnType(PPARSEINFO pLocalPI, PINTERFACE pif, PMETHOD pm);
    185186
    186187/* In printdata.c */
Note: See TracChangeset for help on using the changeset viewer.