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/nombuildclass.c

    r210 r221  
    3232*
    3333* ***** END LICENSE BLOCK ***** */
     34/** \file
     35    This File contains most of the magic to create classes for NOM.
     36 */
    3437
    3538#define INCL_DOS
     
    320323
    321324
    322 /*
     325/**
    323326  - This function builds the nomMethodTab of class nClass.
    324327  - Calculates the method thunks
     
    328331  methods.
    329332 */
    330 void addMethodAndDataToThisPrivClassStruct(NOMClassPriv* nClass, NOMClassPriv* ncpParent, nomStaticClassInfo *sci)
     333boolean addMethodAndDataToThisPrivClassStruct(NOMClassPriv* nClass, NOMClassPriv* ncpParent, nomStaticClassInfo *sci)
    331334{
    332335  BYTE * mem;
     
    334337
    335338BUILDNOMCLASS_ENTER
     339
     340  /* Get mem for method thunking code. This assembler code is needed so the indirect
     341     jump to the methods from the object pointer which is known does work. For each class
     342     an individual thunking code must be calculated because the number of instance
     343     variables is not defined. */
     344  if(0!=sci->ulNumStaticMethods){
     345    nClass->mThunk=NOMMalloc(sizeof(nomMethodThunk)*sci->ulNumStaticMethods);
     346    if(!nClass->mThunk)
     347      return FALSE;
     348  }
    336349
    337350  nClass->sci=sci;   /* Save static class info for internal use */
     
    347360  nClass->parentMtabStruct.mtab=(nomMethodTab*)&nClass->thisMtab;
    348361 
    349 #ifdef DEBUG_NOMBUILDCLASS
    350   nomPrintf("nClass->mtabList.next: %x\n", nClass->mtabList.next);
    351 #endif
     362  DBG_NOMBUILDCLASS(TRUE, "nClass->mtabList.next: %x\n", nClass->mtabList.next);
    352363 
    353364  /* There're some parents. Copy parent mtab data into new mtab. */
     
    367378  /* Add class struct of this class. This includes the proc adresses. */
    368379  if(sci->ulNumStaticMethods) {
    369 #ifdef DEBUG_NOMBUILDCLASS
    370     nomPrintf("copy own data: %d (classptr+numProcs*procpointersize) from %x (cds, classDataStruct of %x) to %x (our mtab part)\n",
    371               sizeof(NOMClass*)+sci->ulNumStaticMethods*sizeof(nomMethodProc*),
    372               sci->nomCds, sci->nomCds->nomClassObject, mem);
    373 #endif
     380    DBG_NOMBUILDCLASS(TRUE,
     381                      "copy own data: %d (classptr+numProcs*procpointersize) from %x (cds, classDataStruct of %x) to %x (our mtab part)\n",
     382                      sizeof(NOMClass*)+sci->ulNumStaticMethods*sizeof(nomMethodProc*),
     383                      sci->nomCds, sci->nomCds->nomClassObject, mem);
     384
    374385    nClass->entries0=(NOMClass**)mem; /* Our part in the mtab starts here. We need this position to insert the class object pointer
    375386                                         later. */
     
    396407  sci->ccds->instanceDataToken=&nClass->thunk;
    397408
    398   BUILDNOMCLASS_LEAVE
     409  BUILDNOMCLASS_LEAVE;
     410  return TRUE;
    399411}
    400412
     
    530542  if((nClass=(NOMClassPriv*)NOMCalloc(1, ulMemSize))==NULLHANDLE)
    531543    return NULLHANDLE;
    532 
     544#if 0
     545  //Moved to addMethodAndDataToThisPrivClassStruct()
    533546  /* Get mem for method thunking code */
    534547  if(0!=sci->ulNumStaticMethods){
     
    539552    }
    540553  }
     554#endif
     555
    541556  /* Add class struct of this class.
    542557     This includes
     
    544559     -add the parent mtab info to the new built mtab
    545560  */
    546   addMethodAndDataToThisPrivClassStruct( nClass, ncpParent, sci) ;
    547 
     561  if(!addMethodAndDataToThisPrivClassStruct( nClass, ncpParent, sci)){
     562    NOMFree(nClass);
     563    return NULLHANDLE;
     564  };
     565 
    548566  DBG_NOMBUILDCLASS(TRUE, "%s:  mtab: %x\n", __FUNCTION__, nClass->mtab);
    549567
     
    598616  nomClassMeta=_nomFindClassFromName(NOMClassMgrObject, *sci->nomExplicitMetaId, majorVersion, minorVersion, NULLHANDLE);
    599617
    600 #ifdef DEBUG_NOMBUILDCLASS
    601   nomPrintf("%d: %x %s %s\n", __LINE__, nomClassMeta, *sci->nomClassId, *sci->nomExplicitMetaId);
    602 #endif
     618    DBG_NOMBUILDCLASS(TRUE, "%x %s %s\n", nomClassMeta, *sci->nomClassId, *sci->nomExplicitMetaId);
    603619
    604620  if(!nomClassMeta)
     
    632648                            nomClass);
    633649 
    634 #ifdef DEBUG_NOMBUILDCLASS
    635   nomPrintf("%d: New class Object (child of NOMClass): %x \n", __LINE__, nomClass);
    636 #endif
     650  DBG_NOMBUILDCLASS(TRUE, "New class Object (child of NOMClass): %x \n", nomClass);
    637651
    638652  /* nomClassReady() is called in nomBuildClass() */
     
    802816}
    803817
    804 
     818/**
     819   Build a class for NOM from the data generated from the IDL compiler and
     820   compiled into the DLL.
     821 */
    805822NOMEXTERN NOMClass * NOMLINK nomBuildClass(gulong ulReserved,
    806823                                           nomStaticClassInfo *sci,
     
    886903    priv_buildNOMObjectClassInfo(ulReserved, sci, /* yes */
    887904                                 ulMajorVersion, ulMinorVersion);
    888     return NULLHANDLE; /* We can't return a SOMClass for SOMObject because SOMClass isn't built yet. */
     905    return NULLHANDLE; /* We can't return a NOMClass for NOMObject because NOMClass isn't built yet. */
    889906  }
    890907
     
    907924    ncpParent=priv_findPrivClassInGlobalClassListFromName(pGlobalNomEnv,
    908925                                                          **(sci->nomIdAllParents)); /* This may also return a class not derived
    909                                                                                         from SOMClass */
     926                                                                                        from NOMClass */
    910927#endif
    911928    if(!ncpParent)
     
    10081025    return NULLHANDLE;
    10091026
     1027#if 0
     1028  //Moved to addMethodAndDataToThisPrivClassStruct()
    10101029  if(0!=sci->ulNumStaticMethods){
    10111030    /* Get mem for method thunking code */
     
    10161035    }
    10171036  }
     1037#endif
    10181038
    10191039  nClass->ulClassSize=sci->ulInstanceDataSize+ulParentDataSize;
    10201040
    10211041  if((nomClass=(NOMClass*)NOMCalloc(1, sci->ulInstanceDataSize+ulParentDataSize))==NULLHANDLE) {
    1022     NOMFree(nClass->mThunk);
     1042    //NOMFree(nClass->mThunk);
    10231043    NOMFree(nClass);
    10241044    return NULLHANDLE;
     
    10281048
    10291049  /* Add class struct of this class. This includes resolving the method adresses. */
    1030   addMethodAndDataToThisPrivClassStruct( nClass, ncpParent, sci) ;
     1050  if(!addMethodAndDataToThisPrivClassStruct( nClass, ncpParent, sci)){
     1051    NOMFree(nClass);
     1052    NOMFree(nomClass);
     1053    return NULLHANDLE;
     1054  };
    10311055
    10321056  /* Resolve overrides if any */
     
    10471071  nClass->mtab->nomClassName=*sci->nomClassId;
    10481072  nClass->mtab->ulInstanceSize=sci->ulInstanceDataSize+ulParentDataSize; /* Size of instance data of this class and all
    1049                                                                         parent classes. This isn't actually allocated for this class
    1050                                                                         object but the entry is used when creating the objects. */
     1073                                                                            parent classes. This isn't actually allocated
     1074                                                                            for this class object but the entry is used
     1075                                                                            when creating the objects. */
    10511076  fillCClassDataStructParentMtab(sci, nClass, nomClass);
    10521077
Note: See TracChangeset for help on using the changeset viewer.