Changeset 274 for trunk/idl-compiler


Ignore:
Timestamp:
Mar 26, 2007, 9:40:01 PM (18 years ago)
Author:
cinc
Message:

H file emitter is getting into shape...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/idl-compiler/h-emitter_c/h_file_emitter.c

    r273 r274  
    109109}
    110110
    111 static void emitClassDataStruct(PPARSEINFO pLocalPI, PINTERFACE pif)
     111static void emitClassDataStructs(PPARSEINFO pLocalPI, PINTERFACE pif)
    112112{
    113113  int a;
     
    125125    }
    126126  fprintf(fh, "}%sClassData\n\n", pif->chrName);
     127
     128  fprintf(fh, "NOMEXTERN struct %sCClassDataStructure {\n", pif->chrName);
     129  fprintf(fh, "   nomMethodTabs parentMtab;\n");
     130  fprintf(fh, "   nomDToken instanceDataToken;\n");
     131  fprintf(fh, "} NOMDLINK %sCClassData;\n\n", pif->chrName);
     132
    127133}
    128134
     
    274280};
    275281
     282static void emitNewMacro(PPARSEINFO pLocalPI, PINTERFACE pif)
     283{
     284  FILE* fh=pLocalPI->outFile;
     285
     286  fprintf(fh, "/*\n * Class creation function\n */\n");
     287  fprintf(fh, "NOMEXTERN NOMClass * NOMLINK %sNewClass(gulong clsMajorVersion, gulong clsMinorVersion);\n\n",
     288          pif->chrName);
     289 
     290  fprintf(fh, "#define _%s (%s*)%sClassData.classObject\n\n",
     291          pif->chrName, pif->chrMetaClass, pif->chrName);
     292 
     293  fprintf(fh, "/*\n * New macro for WPObject\n */\n\n");
     294  fprintf(fh, "#define %sNew() \\\n", pif->chrName);
     295  fprintf(fh, "        ((%s*)_nomNew((_%s ? _%s : ", pif->chrName, pif->chrName, pif->chrName);
     296  fprintf(fh, "(%s*)%sNewClass(%s_MajorVersion, %s_MinorVersion)), (void*) 0))\n\n",
     297          pif->chrName, pif->chrName, pif->chrName, pif->chrName);
     298
     299}
     300
     301static void emitParentClassMethods(PPARSEINFO pLocalPI, PINTERFACE pif)
     302{
     303  FILE* fh=pLocalPI->outFile;
     304  PINTERFACE pifParent=pif;
     305
     306  while((pifParent=getParentInterface(pifParent))!=NULLHANDLE)
     307    {
     308      GPtrArray *pArray;
     309      int a;
     310      /* Do this parents methods */
     311      pArray=pifParent->pMethodArray;
     312      for(a=0;a<pArray->len;a++)
     313        {
     314          PMETHOD pm=(PMETHOD)g_ptr_array_index(pArray, a);
     315
     316          fprintf(fh, "#define %s_%s \\\n", pif->chrName, pm->chrName);
     317          fprintf(fh, "        %s_%s \n", pifParent->chrName, pm->chrName);
     318        }
     319    }
     320  fprintf(fh, "\n");
     321}
     322
    276323static void emitHFileFooter(PPARSEINFO pLocalPI, PINTERFACE pif)
    277324{
     
    300347          emitParentHeader(pLocalPI, pif);
    301348          emitClassVersion(pLocalPI, pif);
    302           emitClassDataStruct(pLocalPI, pif);
     349          emitClassDataStructs(pLocalPI, pif);
     350          emitNewMacro(pLocalPI, pif);
    303351          emitObjectCheckFunction(pLocalPI, pif);
    304352          emitNewMethods(pLocalPI, pif);
     353          emitParentClassMethods(pLocalPI, pif);
    305354          emitHFileFooter(pLocalPI, pif);
    306355        }
Note: See TracChangeset for help on using the changeset viewer.