Ignore:
Timestamp:
Jan 18, 2007, 9:41:30 PM (19 years ago)
Author:
cinc
Message:

Fixed class creation crash with explicit metaclasses not having any new methods.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/nom/src/nombuildclass.c

    r177 r196  
    538538#warning !!!!! Change this when nomID is a GQuark !!!!!
    539539  nomClassParent=_nomFindClassFromName(NOMClassMgrObject, *sci->nomExplicitMetaId, majorVersion, minorVersion, NULLHANDLE);
    540  
     540    printf("  2 ----------------- %d %x %s %s\n", __LINE__, nomClassParent, *sci->nomClassId, *sci->nomExplicitMetaId);
    541541  if(!nomClassParent)
    542542    return NULLHANDLE;
     
    549549    return NULLHANDLE;
    550550
    551  
    552551  /* Mabe we should just copy the whole struct here? */
    553552  nomClass->mtab=nomClassParent->mtab;
     
    713712  nomMethodTabs psmTab;
    714713  /* Print some info for debbuging */
    715   nomPrintf("\n%d: Entering %s to build class %s. ---> SCMO: %x (NOMClassManagerObject)\n",
    716             __LINE__, __FUNCTION__, *sci->nomClassId, NULL /*NOMClassMgrObject*/);
    717   nomPrintf("cds: %x nomClassObject: %x\n", sci->nomCds, sci->nomCds->nomClassObject);
     714  nomPrintf("\n%d: Entering %s to build class %s. ---> SCMO: 0x%x (NOMClassManagerObject)\n",
     715            __LINE__, __FUNCTION__, *sci->nomClassId, NOMClassMgrObject);
     716  nomPrintf("d: cds: 0x%x nomClassObject: 0x%x\n", __LINE__, sci->nomCds, sci->nomCds->nomClassObject);
    718717#endif
    719718
     
    775774#endif
    776775
    777   /* Do we want to build SOMObject the mother of all classes? */
     776  /* Do we want to build NOMObject the mother of all classes? */
    778777  if(!strcmp(*sci->nomClassId, "NOMObject")){
    779778#ifdef DEBUG_NOMBUILDCLASS
     
    782781    priv_buildNOMObjectClassInfo(ulReserved, sci, /* yes */
    783782                                 ulMajorVersion, ulMinorVersion);
    784     return NULLHANDLE; /* We can't return a SOMClass for SOMObject because SOMClass isn't
    785                           built yet. */
     783    return NULLHANDLE; /* We can't return a SOMClass for SOMObject because SOMClass isn't built yet. */
    786784  }
    787785
     
    835833       or an explicit meta class if given. */
    836834#ifdef DEBUG_NOMBUILDCLASS
    837     nomPrintf("Class %x (ncpParent->mtab->nomClassName: %s) is not a NOMClass\n", ncpParent, ncpParent->mtab->nomClassName);
     835    nomPrintf("%d: Class %x (ncpParent->mtab->nomClassName: %s) is not a NOMClass\n",
     836              __LINE__, ncpParent, ncpParent->mtab->nomClassName);
    838837#endif
    839838
     
    849848        nomPrintf("sci->nomExplicitMetaId is set\n");
    850849#endif
    851        
    852 
    853 
     850   
    854851        nomClass= priv_buildWithExplicitMetaClass(ulReserved, sci,
    855852                                                  ulMajorVersion, ulMinorVersion);
    856853        if(nomClass){
    857854#ifdef DEBUG_NOMBUILDCLASS
    858           nomPrintf("%s: class is %x\n", nomClass->mtab->nomClassName, nomClass);
     855          nomPrintf("%d: %s: class is 0x%x\n", __LINE__, nomClass->mtab->nomClassName, nomClass);
    859856#endif   
    860857          _nomInit(nomClass, NULLHANDLE);
     
    884881  /* Child of some NOMClass */
    885882
    886 
    887883  /**** From this point we are building a new class object (derived from NOMClass ****/
    888884  ulMemSize=sizeof(NOMClassPriv)-sizeof(nomMethodTab); /* start size class struct */
     
    890886  /* Calculate size of new class object */
    891887#ifdef DEBUG_NOMBUILDCLASS
    892   nomPrintf("Parent class %x (ncpParent->mtab->nomClassName: %s) is a NOMClass (or derived)\n",
    893             ncpParent, ncpParent->mtab->nomClassName);
    894   nomPrintf("ncParent->mtab->mtabSize: %d\n", ncpParent->mtab->mtabSize);
     888  nomPrintf("%d: Parent class 0x%x (ncpParent->mtab->nomClassName: %s) is a NOMClass (or derived)\n",
     889            __LINE__, ncpParent, ncpParent->mtab->nomClassName);
     890  nomPrintf("      ncParent->mtab->mtabSize: %d\n", ncpParent->mtab->mtabSize);
    895891#endif
    896892  mtabSize=ncpParent->mtab->mtabSize+sizeof(nomMethodProc*)*(sci->ulNumStaticMethods)+sizeof(NOMClass*);/* ulNumStaticMethods is correct here!
     
    903899 
    904900#ifdef DEBUG_NOMBUILDCLASS
    905   nomPrintf("%s mtabSize is: %d, ulParentDataSize is: %d\n", *sci->nomClassId, mtabSize, ulParentDataSize);
    906 #endif
    907 
    908 
    909   /* Alloc class struct using SOMCalloc. This means the struct is allocated in shared mem */
     901  nomPrintf("%d: %s mtabSize is: %d, ulParentDataSize is: %d\n", __LINE__, *sci->nomClassId, mtabSize, ulParentDataSize);
     902#endif
     903
     904
     905  /* Alloc class struct using NOMCalloc. This means the struct is allocated in shared mem */
    910906  if((nClass=(NOMClassPriv*)NOMCalloc(1, ulMemSize))==NULLHANDLE)
    911907    return NULLHANDLE;
    912908
    913   /* Get mem for method thunking code */
    914   nClass->mThunk=NOMMalloc(sizeof(nomMethodThunk)*sci->ulNumStaticMethods);
    915   if(!nClass->mThunk) {
    916     NOMFree(nClass);
    917     return NULLHANDLE;
     909  if(0!=sci->ulNumStaticMethods){
     910    /* Get mem for method thunking code */
     911    nClass->mThunk=NOMMalloc(sizeof(nomMethodThunk)*sci->ulNumStaticMethods);
     912    if(!nClass->mThunk) {
     913      NOMFree(nClass);
     914      return NULLHANDLE;
     915    }
    918916  }
    919917
     
    932930  addMethodAndDataToThisPrivClassStruct( nClass, ncpParent, sci) ;
    933931
    934   /* Resolve ovverrides if any */
    935   //#warning !!!!! no resolving of overriden methods here !!!!!
     932  /* Resolve overrides if any */
    936933  priv_resolveOverrideMethods(nClass, sci);
    937934
    938935  nomClass->mtab=nClass->mtab; 
    939 #ifdef DEBUG_nOMBUILDCLASS
    940   nomPrintf("mtab: %x\n", nClass->mtab);
     936#ifdef DEBUG_NOMBUILDCLASS
     937  nomPrintf("%d: mtab: %x\n", __LINE__, nClass->mtab);
    941938#endif
    942939  sci->nomCds->nomClassObject=nomClass; /* Put class pointer in static struct */
     
    963960
    964961#ifdef DEBUG_NOMBUILDCLASS
    965   nomPrintf("New class ptr (class object): %x (NOMClassPriv: %x) for %s\n", nomClass, nClass, *sci->nomClassId);
     962  nomPrintf("%d: New class ptr (class object): %x (NOMClassPriv: %x) for %s\n", __LINE__, nomClass, nClass, *sci->nomClassId);
    966963#endif
    967964
     
    982979#include <cwsomcls.h>
    983980#include <somclassmanager.h>
    984 /********************************************************/
    985 /*  Internal functions                                  */
    986 /********************************************************/
    987 
    988 /* String manager functions */
    989 static BOOL priv_addSomIdToIdList(PSOM_ENV pEnv, somIdItem * sid)
    990 {
    991   somIdItem *tmpList;
    992 
    993   if(!sid || !pEnv)
    994     return FALSE;
    995 
    996   if(NO_ERROR != priv_requestSomEnvMutex(pEnv))
    997      return FALSE;
    998 
    999   if(!pEnv->livingSomIds)
    1000     {
    1001       /* Add first class */
    1002       pEnv->livingSomIds=sid;
    1003       priv_releaseSomEnvMutex(pEnv);
    1004       return TRUE;
    1005     }
    1006   tmpList=sid;
    1007  
    1008   tmpList->next=(somIdItem*)pEnv->livingSomIds;
    1009   pEnv->livingSomIds=tmpList;
    1010   pEnv->ulNumRegIds++;
    1011 
    1012   priv_releaseSomEnvMutex(pEnv);
    1013   return TRUE;
    1014 }
    1015 
    1016 /* This returns the ID of a string, this means the hash of this string if
    1017    already registered. */
    1018 static somIdItem* priv_findSomIdInList(PSOM_ENV pEnv, string aString)
    1019 {
    1020   somIdItem *tmpItem;
    1021   ULONG ulHash;
    1022 
    1023   if(!pEnv|| aString)
    1024     return 0;
    1025 
    1026   ulHash=calculateNameHash(aString);
    1027 
    1028   if(NO_ERROR != priv_requestSomEnvMutex(pEnv))
    1029     return NULL;
    1030 
    1031   tmpItem=pEnv->livingSomIds;
    1032   while(tmpItem)
    1033     {
    1034       if(tmpItem->id == ulHash) {
    1035         priv_releaseSomEnvMutex(pEnv);
    1036         return tmpItem;  /* We have found the string return somId */
    1037       }
    1038       tmpItem=tmpItem->next;
    1039     };
    1040   priv_releaseSomEnvMutex(pEnv);
    1041 
    1042   return NULL; /* No id yet. */
    1043 }
    1044 
    1045981/********************************************************/
    1046982/*   Toolkit functions, exported                        */
     
    11021038  *sID=(char*)sid;
    11031039  return sID;
    1104 }
    1105 
    1106 /* Returns the total number of ids that have been registered so far, */
    1107 unsigned long SOMLINK somTotalRegIds(void)
    1108 {
    1109   long numIds;
    1110 
    1111   if(NO_ERROR != priv_requestSomEnvMutex(pGlobalSomEnv))
    1112     return 0;
    1113 
    1114   numIds=pGlobalSomEnv->ulNumRegIds;
    1115   priv_releaseSomEnvMutex(pGlobalSomEnv);
    1116 
    1117   return numIds;
    11181040}
    11191041
Note: See TracChangeset for help on using the changeset viewer.