Ignore:
Timestamp:
Feb 3, 2007, 11:01:41 PM (19 years ago)
Author:
cinc
Message:

Changes...

File:
1 edited

Legend:

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

    r210 r221  
    4949/********************************************************/
    5050
    51 /* Define if you want to have messages from somBuildClass() and friends */
     51/* Define if you want to have messages from nomBuildClass() and friends */
    5252//#define DEBUG_NOMBUILDCLASS
    5353/* Define if you want to have messages from building NOMObject */
     
    5959    #define BUILDNOMCLASS_ENTER nomPrintf("\n%d: *** entering %s...\n",__LINE__,  __FUNCTION__);
    6060    #define BUILDNOMCLASS_LEAVE nomPrintf("%d: *** Leaving %s...\n\n",__LINE__,  __FUNCTION__);
     61    #define DBG_BUILDNOMCLASS(a, b,...)   if(a) nomPrintf("%d: " b , __LINE__,  __VA_ARGS__);
    6162#else
    6263    #define BUILDNOMCLASS_ENTER
    6364    #define BUILDNOMCLASS_LEAVE
     65    #define DBG_BUILDNOMCLASS(a, b,...)
    6466#endif
    6567
     
    101103
    102104  /* Calculate size of new class object */
    103 #ifdef DEBUG_BUILDNOMCLASS
    104   nomPrintf("%d: ncParent->mtab->mtabSize: %d\n", __LINE__, ncpParent->mtab->mtabSize);
    105 #endif
     105  DBG_BUILDNOMCLASS(TRUE, "ncParent->mtab->mtabSize: %d\n", ncpParent->mtab->mtabSize);
    106106
    107107  mtabSize=ncpParent->mtab->mtabSize+sizeof(nomMethodProc*)*(sci->ulNumStaticMethods)+sizeof(NOMClass*);/* numStaticMethods is correct here!
     
    114114  gulParentDataSize=ncpParent->mtab->ulInstanceSize; /* Parent instance size. This is the mtab pointer + instance vars */
    115115
    116 #ifdef DEBUG_BUILDNOMCLASS
    117   nomPrintf("%d: mtabSize is: %d, ulParentDataSize is: %d (instance vars + mtab ptr)\n",
    118             __LINE__, mtabSize, gulParentDataSize);
    119   nomPrintf("%d: sci->numStaticMethods: %d\n", __LINE__, sci->ulNumStaticMethods);
    120 #endif
     116  DBG_BUILDNOMCLASS(TRUE,"mtabSize is: %d, ulParentDataSize is: %d (instance vars + mtab ptr)\n",
     117                    mtabSize, gulParentDataSize);
     118  DBG_BUILDNOMCLASS(TRUE, "sci->numStaticMethods: %d\n", sci->ulNumStaticMethods);
    121119
    122120  /* Alloc private class struct using SOMCalloc. */
     
    124122    return NULLHANDLE;
    125123
    126   /* Get mem for method thunking code */
    127   nClass->mThunk=NOMMalloc(sizeof(nomMethodThunk)*sci->ulNumStaticMethods);
    128   if(!nClass->mThunk) {
    129     NOMFree(nClass);
    130     return NULLHANDLE;
    131   }
    132 
     124  /* Get mem for method thunking code. This assembler code is needed so the indirect
     125     jump to the methods from the object pointer which is known does work. For each class
     126     an individual thunking code must be calculated because the number of instance
     127     variables is not defined. */
     128#if 0
     129  //Moved to addMethodAndDataToThisPrivClassStruct()
     130  if(0!=sci->ulNumStaticMethods){
     131    nClass->mThunk=NOMMalloc(sizeof(nomMethodThunk)*sci->ulNumStaticMethods);
     132    if(!nClass->mThunk) {
     133      NOMFree(nClass);
     134      return NULLHANDLE;
     135    }
     136  }
     137#endif
    133138  /* The size of each instance of this class. A NOM object has a method tab pointer
    134139     at the beginning followed by the instance variables. */
     
    142147     mtab-entries[] to our new one before adding our own methods.
    143148     sci will be saved in nClass->sci */
    144 #warning !!!!! Move mem alloc for thunking into this func !!!!!
    145   addMethodAndDataToThisPrivClassStruct( nClass, ncpParent, sci);
     149  //#warning !!!!! Move mem alloc for thunking into this func !!!!!
     150  if(!addMethodAndDataToThisPrivClassStruct( nClass, ncpParent, sci)){
     151    NOMFree(nClass);
     152    return NULLHANDLE;
     153  };
    146154
    147155  /**********************************/
     
    261269  pGlobalNomEnv->nomObjectMetaClass=(NOMClass*)nomClass->mtab->entries[0];
    262270
    263 #ifdef DEBUG_BUILDNOMCLASS
    264   nomPrintf("%d: mtab: %x New class ptr (class object SOMClass): %x (SOMClassPriv: %x) for %s\n",
    265             __LINE__, nomClass->mtab, nomClass, nClass, *sci->nomClassId);
    266 #endif
     271    DBG_BUILDNOMCLASS(TRUE, "mtab: %x New class ptr (class object SOMClass): %x (SOMClassPriv: %x) for %s\n",
     272                      nomClass->mtab, nomClass, nClass, *sci->nomClassId);
    267273
    268274  pGlobalNomEnv->defaultMetaClass=nomClass;
     
    274280#endif
    275281
    276 
    277282  /* Run initialization code if any */
    278283  _nomInit(nomClass, NULLHANDLE);
Note: See TracChangeset for help on using the changeset viewer.