Ignore:
Timestamp:
Apr 9, 2008, 10:22:08 PM (17 years ago)
Author:
cinc
Message:

Portability patches for Windows, Linux, Darwin by Bird.

Location:
trunk/idl-compiler/ih-emitter_c
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/idl-compiler/ih-emitter_c/ih_file_emitter.c

    r293 r326  
    3232*
    3333* ***** END LICENSE BLOCK ***** */
    34 #include <os2.h>
     34#ifdef __OS2__
     35# include <os2.h>
     36#endif /* __OS2__ */
     37
    3538#include <stdlib.h>
    3639#include <string.h>
     
    8083            fprintf(fh, "  %s;\n", piv->chrName);
    8184    }
    82   fprintf(fh, "}%sData;\n\n", pif->chrName);
     85#ifdef _MSC_VER
     86  if(!a)
     87    fprintf(fh, "  int iDummy;\n"); /* HACK ALERT! */
     88#endif
     89  fprintf(fh, "} %sData;\n\n", pif->chrName);
    8390}
    8491
     
    8693{
    8794  FILE* fh=pLocalPI->outFile;
    88   GPtrArray *pArray=pif->pInstanceVarArray;;
     95  GPtrArray *pArray=pif->pInstanceVarArray;
    8996  int a;
    9097
     
    116123
    117124  fprintf(fh, "/*** Class data structures ***/\n");
    118   fprintf(fh, "struct %sClassDataStructure %sClassData = {0};\n", pif->chrName, pif->chrName );
    119   fprintf(fh, "static struct %sCClassDataStructure %sCClassData = {0};\n\n",
     125  fprintf(fh, "NOMDLLEXPORT struct %sClassDataStructure %sClassData = {0};\n", pif->chrName, pif->chrName );
     126  fprintf(fh, "NOMDLLEXPORT struct %sCClassDataStructure %sCClassData = {0};\n\n",
    120127          pif->chrName, pif->chrName);
    121128}
     
    126133NOMEXTERN gboolean NOMLINK objectCheckFunc_WPRootFolder(WPRootFolder *nomSelf, gchar* chrMethodName)
    127134{
    128 if(!nomIsObj(nomSelf) || !_nomIsANoClsCheck(nomSelf , WPRootFolderClassData.classObject, NULLHANDLE))
     135if(!nomIsObj(nomSelf) || !_nomIsANoClsCheck(nomSelf , WPRootFolderClassData.classObject, NULL))
    129136  {
    130137  nomPrintObjectPointerError(nomSelf, "WPRootFolder", chrMethodName);
     
    170177      fprintf(fh, "\",\n");     
    171178    }
     179#ifdef _MSC_VER
     180  if(!a)
     181    fprintf(fh, "  NULL\n");
     182#endif
    172183}
    173184
     
    187198      fprintf(fh, "#if !defined(_decl_impl_%s_%s_)\n", pif->chrName, pm->chrName);
    188199      fprintf(fh, "#define _decl_impl_%s_%s_ 1\n", pif->chrName, pm->chrName);
    189       fprintf(fh, "NOM_Scope ");
     200      fprintf(fh, "NOMDLLEXPORT NOM_Scope ");
    190201      emitReturnType(pLocalPI, pif, pm);
    191202      fprintf(fh, " NOMLINK impl_%s_%s(%s *nomSelf,\n", pif->chrName, pm->chrName, pif->chrName);
     
    238249        }
    239250
    240       fprintf(fh, "NOM_Scope ");
     251      fprintf(fh, "NOMDLLEXPORT NOM_Scope ");
    241252      emitReturnType(pLocalPI, pif, pm);
    242253      fprintf(fh, " NOMLINK impl_%s_%s(%s* nomSelf,\n", pif->chrName, pom->chrName, pif->chrName);
     
    271282  fprintf(fh, "static nomOverridenMethodDesc nomOverridenMethods%s[] = {\n", pif->chrName);
    272283
     284  pArray=pif->pOverrideArray;
     285
    273286  for(a=0;a<pArray->len;a++)
    274287    {
     
    289302      fprintf(fh, "  },\n");
    290303    }
    291     fprintf(fh, "};\n\n");
     304#ifdef _MSC_VER
     305  if(!a)
     306    fprintf(fh, "  { NULL, NULL, NULL }\n");
     307#endif
     308  fprintf(fh, "};\n\n");
    292309}
    293310
     
    316333      fprintf(fh, "},\n");
    317334    }
     335#ifdef _MSC_VER
     336  if(!a)
     337    fprintf(fh, "  { NULL, NULL, NULL, NULL, NULL }\n");
     338#endif
    318339  fprintf(fh, "};\n\n");
    319340}
     
    344365      /* Emit the parents. We have to output them sorted beginning from the
    345366         leftmost parent. */
    346       while(pifParent->chrParent && (pifParent=findInterfaceFromName(pifParent->chrParent))!=NULLHANDLE)
     367      while(pifParent->chrParent && (pifParent=findInterfaceFromName(pifParent->chrParent))!=NULL)
    347368        {
    348369          g_ptr_array_add(pArray, (gpointer) pifParent);
     
    372393  PINTERFACE pifParent=pif;
    373394
    374   while(pifParent->chrParent && (pifParent=findInterfaceFromName(pifParent->chrParent))!=NULLHANDLE)
     395  while(pifParent->chrParent && (pifParent=findInterfaceFromName(pifParent->chrParent))!=NULL)
    375396    ulRet++;
    376397
     
    498519    }
    499520  fprintf(fh, "#include \"nomgc.h\"\n");
     521  fprintf(fh, "#ifdef NOM_%s_IMPLEMENTATION_FILE\n", pif->chrName);
     522  fprintf(fh, "NOMDLLEXPORT\n");
     523  fprintf(fh, "#else\n");
     524  fprintf(fh, "NOMDLLIMPORT\n");
     525  fprintf(fh, "#endif\n");
    500526  fprintf(fh, "NOMClass* NOMLINK %sNewClass(gulong ulMajor, gulong ulMinor)\n", pif->chrName);
    501527  fprintf(fh, "{\n");
     
    516542  fprintf(fh, "    nomEndRegisterDLLWithGC(hReg);\n");
    517543  fprintf(fh, "    }\n");
     544  fprintf(fh, "#elif defined(_WIN32)\n");
     545  fprintf(fh, " /* FIXME: check this up with the GC. */\n");
     546  fprintf(fh, "#elif defined(__APPLE__)\n");
     547  fprintf(fh, "# warning FIXME: Check out GC/dylib.\n");
     548  fprintf(fh, "#elif defined(__linux__)\n");
     549  fprintf(fh, "# warning FIXME: Check out GC/so on linux.\n");
    518550  fprintf(fh, "#else\n");
    519551  fprintf(fh, "#error DLL must be registered with the garbage collector!\n");
     
    562594              //printInterface(pif);
    563595              chrTemp=g_strconcat(pif->chrFileStem, ".ih", NULL);
    564               if((pLocalPI->outFile=openOutfile(gScanner, chrTemp))!=NULLHANDLE)
     596              if((pLocalPI->outFile=openOutfile(gScanner, chrTemp))!=NULL)
    565597                {
    566598                  emitIHFileHeader(pLocalPI, pif);
Note: See TracChangeset for help on using the changeset viewer.