From 960aadacebf146cdb68506237a5d758b022ce9fd Mon Sep 17 00:00:00 2001 From: Robert Shearman Date: Thu, 1 Dec 2005 12:34:39 +0100 Subject: [PATCH] Introduce a variable "elemdesc" to eliminate some long common expressions. Move the contents of the second arguments loop inside the first. Move the MSFT_ReadLEDWords so that it is the last statement in the loop since it is one of the iterators. --- dlls/oleaut32/typelib.c | 82 ++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 43 deletions(-) diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c index 03cc6abda6c..59fd9ba9146 100644 --- a/dlls/oleaut32/typelib.c +++ b/dlls/oleaut32/typelib.c @@ -1780,14 +1780,15 @@ MSFT_DoFuncs(TLBContext* pcx, for ( j = 0 ; j < pFuncRec->nrargs ; j++ ) { - TYPEDESC* lpArgTypeDesc = 0; + TYPEDESC *lpArgTypeDesc; + ELEMDESC *elemdesc = &(*pptfd)->funcdesc.lprgelemdescParam[j]; MSFT_GetTdesc(pcx, paraminfo.DataType, - &(*pptfd)->funcdesc.lprgelemdescParam[j].tdesc, + &elemdesc->tdesc, pTI); - (*pptfd)->funcdesc.lprgelemdescParam[j].u.paramdesc.wParamFlags = paraminfo.Flags; + elemdesc->u.paramdesc.wParamFlags = paraminfo.Flags; /* name */ if (paraminfo.oName == -1) @@ -1800,17 +1801,9 @@ MSFT_DoFuncs(TLBContext* pcx, MSFT_ReadName( pcx, paraminfo.oName ); TRACE_(typelib)("param[%d] = %s\n", j, debugstr_w((*pptfd)->pParamDesc[j].Name)); - /* SEEK value = jump to offset, - * from there jump to the end of record, - * go back by (j-1) arguments - */ - MSFT_ReadLEDWords( ¶minfo , - sizeof(MSFT_ParameterInfo), pcx, - recoffset + reclength - ((pFuncRec->nrargs - j - 1) - * sizeof(MSFT_ParameterInfo))); - lpArgTypeDesc = - & ((*pptfd)->funcdesc.lprgelemdescParam[j].tdesc); + lpArgTypeDesc = &elemdesc->tdesc; + /* resolve referenced type if any */ while ( lpArgTypeDesc != NULL ) { switch ( lpArgTypeDesc->vt ) @@ -1834,8 +1827,40 @@ MSFT_DoFuncs(TLBContext* pcx, lpArgTypeDesc = NULL; } } - } + /* default value */ + if ( (elemdesc->u.paramdesc.wParamFlags & PARAMFLAG_FHASDEFAULT) && + (pFuncRec->FKCCIC & 0x1000) ) + { + INT* pInt = (INT *)((char *)pFuncRec + + reclength - + (pFuncRec->nrargs * 4 + 1) * sizeof(INT) ); + + PARAMDESC* pParamDesc = &elemdesc->u.paramdesc; + + pParamDesc->pparamdescex = TLB_Alloc(sizeof(PARAMDESCEX)); + pParamDesc->pparamdescex->cBytes = sizeof(PARAMDESCEX); + + MSFT_ReadValue(&(pParamDesc->pparamdescex->varDefaultValue), + pInt[j], pcx); + } + /* custom info */ + if ( nrattributes > 7 + j && pFuncRec->FKCCIC & 0x80 ) + { + MSFT_CustData(pcx, + pFuncRec->OptAttr[7+j], + &(*pptfd)->pParamDesc[j].pCustData); + } + + /* SEEK value = jump to offset, + * from there jump to the end of record, + * go back by (j-1) arguments + */ + MSFT_ReadLEDWords( ¶minfo , + sizeof(MSFT_ParameterInfo), pcx, + recoffset + reclength - ((pFuncRec->nrargs - j - 1) + * sizeof(MSFT_ParameterInfo))); + } /* parameter is the return value! */ if ( paraminfo.Flags & PARAMFLAG_FRETVAL ) @@ -1873,35 +1898,6 @@ MSFT_DoFuncs(TLBContext* pcx, } } } - - /* second time around */ - for(j=0;jnrargs;j++) - { - /* default value */ - if ( (PARAMFLAG_FHASDEFAULT & - (*pptfd)->funcdesc.lprgelemdescParam[j].u.paramdesc.wParamFlags) && - ((pFuncRec->FKCCIC) & 0x1000) ) - { - INT* pInt = (INT *)((char *)pFuncRec + - reclength - - (pFuncRec->nrargs * 4 + 1) * sizeof(INT) ); - - PARAMDESC* pParamDesc = & (*pptfd)->funcdesc.lprgelemdescParam[j].u.paramdesc; - - pParamDesc->pparamdescex = TLB_Alloc(sizeof(PARAMDESCEX)); - pParamDesc->pparamdescex->cBytes = sizeof(PARAMDESCEX); - - MSFT_ReadValue(&(pParamDesc->pparamdescex->varDefaultValue), - pInt[j], pcx); - } - /* custom info */ - if ( nrattributes > 7 + j && pFuncRec->FKCCIC & 0x80 ) - { - MSFT_CustData(pcx, - pFuncRec->OptAttr[7+j], - &(*pptfd)->pParamDesc[j].pCustData); - } - } } /* scode is not used: archaic win16 stuff FIXME: right? */