Updated typelib loader. Typelib contents can be stored as multibyte

strings. However, they are always returned to the application as BSTR,
e.g. UNICODE strings. All strings are now stored as BSTR instead of
ASCII strings.
This commit is contained in:
Francois Jacques 2000-10-25 21:24:53 +00:00 committed by Alexandre Julliard
parent cabee39f3c
commit d1082dcaa1
1 changed files with 115 additions and 92 deletions

View File

@ -165,7 +165,10 @@ QueryPathOfRegTypeLib(
hr = S_OK; hr = S_OK;
} }
} }
TRACE_(typelib)("%s not found\n", szTypeLibKey);
if (hr != S_OK)
TRACE_(typelib)("%s not found\n", szTypeLibKey);
return hr; return hr;
} }
@ -368,7 +371,7 @@ typedef struct tagTLBImpLib
{ {
int offset; /* offset in the file */ int offset; /* offset in the file */
GUID guid; /* libid */ GUID guid; /* libid */
PCHAR name; /* name; */ BSTR name; /* name; */
struct tagITypeLibImpl *pImpTypeLib; /* pointer to loaded typelib */ struct tagITypeLibImpl *pImpTypeLib; /* pointer to loaded typelib */
struct tagTLBImpLib * next; struct tagTLBImpLib * next;
} TLBImpLib; } TLBImpLib;
@ -379,13 +382,14 @@ typedef struct tagITypeLibImpl
ICOM_VFIELD(ITypeLib2); ICOM_VFIELD(ITypeLib2);
UINT ref; UINT ref;
TLIBATTR LibAttr; /* guid,lcid,syskind,version,flags */ TLIBATTR LibAttr; /* guid,lcid,syskind,version,flags */
/* type libs seem to store the doc strings in ascii
* so why should we do it in unicode? /* strings can be stored in tlb as multibyte strings BUT they are *always*
*/ * exported to the application as a UNICODE string.
PCHAR Name; */
PCHAR DocString; BSTR Name;
PCHAR HelpFile; BSTR DocString;
PCHAR HelpStringDll; BSTR HelpFile;
BSTR HelpStringDll;
unsigned long dwHelpContext; unsigned long dwHelpContext;
int TypeInfoCount; /* nr of typeinfo's in librarry */ int TypeInfoCount; /* nr of typeinfo's in librarry */
struct tagITypeInfoImpl *pTypeInfo; /* linked list of type info data */ struct tagITypeInfoImpl *pTypeInfo; /* linked list of type info data */
@ -405,7 +409,7 @@ static ITypeLib2* ITypeLib2_Constructor(LPVOID pLib, DWORD dwTLBLength);
/* internal Parameter data */ /* internal Parameter data */
typedef struct tagTLBParDesc typedef struct tagTLBParDesc
{ {
PCHAR Name; BSTR Name;
int ctCustData; int ctCustData;
TLBCustData * pCustData; /* linked list to cust data; */ TLBCustData * pCustData; /* linked list to cust data; */
} TLBParDesc; } TLBParDesc;
@ -414,12 +418,12 @@ typedef struct tagTLBParDesc
typedef struct tagTLBFuncDesc typedef struct tagTLBFuncDesc
{ {
FUNCDESC funcdesc; /* lots of info on the function and its attributes. */ FUNCDESC funcdesc; /* lots of info on the function and its attributes. */
PCHAR Name; /* the name of this function */ BSTR Name; /* the name of this function */
TLBParDesc *pParamDesc; /* array with name and custom data */ TLBParDesc *pParamDesc; /* array with name and custom data */
int helpcontext; int helpcontext;
int HelpStringContext; int HelpStringContext;
PCHAR HelpString; BSTR HelpString;
PCHAR Entry; /* if its Hiword==0, it numeric; -1 is not present*/ BSTR Entry; /* if its Hiword==0, it numeric; -1 is not present*/
int ctCustData; int ctCustData;
TLBCustData * pCustData; /* linked list to cust data; */ TLBCustData * pCustData; /* linked list to cust data; */
struct tagTLBFuncDesc * next; struct tagTLBFuncDesc * next;
@ -429,10 +433,10 @@ typedef struct tagTLBFuncDesc
typedef struct tagTLBVarDesc typedef struct tagTLBVarDesc
{ {
VARDESC vardesc; /* lots of info on the variable and its attributes. */ VARDESC vardesc; /* lots of info on the variable and its attributes. */
PCHAR Name; /* the name of this variable */ BSTR Name; /* the name of this variable */
int HelpContext; int HelpContext;
int HelpStringContext; /* fixme: where? */ int HelpStringContext; /* fixme: where? */
PCHAR HelpString; BSTR HelpString;
int ctCustData; int ctCustData;
TLBCustData * pCustData;/* linked list to cust data; */ TLBCustData * pCustData;/* linked list to cust data; */
struct tagTLBVarDesc * next; struct tagTLBVarDesc * next;
@ -462,8 +466,8 @@ typedef struct tagITypeInfoImpl
/* type libs seem to store the doc strings in ascii /* type libs seem to store the doc strings in ascii
* so why should we do it in unicode? * so why should we do it in unicode?
*/ */
PCHAR Name; BSTR Name;
PCHAR DocString; BSTR DocString;
unsigned long dwHelpContext; unsigned long dwHelpContext;
unsigned long dwHelpStringContext; unsigned long dwHelpStringContext;
@ -501,7 +505,7 @@ static void dump_TLBFuncDesc(TLBFuncDesc * pfd)
{ {
while (pfd) while (pfd)
{ {
TRACE("%s(%u)\n", pfd->Name, pfd->funcdesc.cParams); TRACE("%s(%u)\n", debugstr_w(pfd->Name), pfd->funcdesc.cParams);
pfd = pfd->next; pfd = pfd->next;
}; };
} }
@ -509,7 +513,7 @@ static void dump_TLBVarDesc(TLBVarDesc * pvd)
{ {
while (pvd) while (pvd)
{ {
TRACE("%s\n", pvd->Name); TRACE("%s\n", debugstr_w(pvd->Name));
pvd = pvd->next; pvd = pvd->next;
}; };
} }
@ -559,7 +563,7 @@ static void dump_TypeInfo(ITypeInfoImpl * pty)
TRACE("fct:%u var:%u impl:%u\n", TRACE("fct:%u var:%u impl:%u\n",
pty->TypeAttr.cFuncs, pty->TypeAttr.cVars, pty->TypeAttr.cImplTypes); pty->TypeAttr.cFuncs, pty->TypeAttr.cVars, pty->TypeAttr.cImplTypes);
TRACE("parent tlb:%p index in TLB:%u\n",pty->pTypeLib, pty->index); TRACE("parent tlb:%p index in TLB:%u\n",pty->pTypeLib, pty->index);
TRACE("%s %s\n", pty->Name, pty->DocString); TRACE("%s %s\n", debugstr_w(pty->Name), debugstr_w(pty->DocString));
dump_TLBFuncDesc(pty->funclist); dump_TLBFuncDesc(pty->funclist);
dump_TLBVarDesc(pty->varlist); dump_TLBVarDesc(pty->varlist);
dump_TLBRefType(pty->impltypelist); dump_TLBRefType(pty->impltypelist);
@ -592,23 +596,6 @@ static void * TLB_Alloc(unsigned size)
return ret; return ret;
} }
/* candidate for a more global appearance... */
static BSTR TLB_DupAtoBstr(PCHAR Astr)
{
int len;
BSTR bstr;
DWORD *pdw ;
if(!Astr)
return NULL;
len=strlen(Astr);
pdw =TLB_Alloc((len+3)*sizeof(OLECHAR));
pdw[0]=(len)*sizeof(OLECHAR);
bstr=(BSTR)&( pdw[1]);
lstrcpyAtoW( bstr, Astr);
TRACE("copying %s to (%p)\n", Astr, bstr);
return bstr;
}
static void TLB_Free(void * ptr) static void TLB_Free(void * ptr)
{ {
HeapFree(GetProcessHeap(), 0, ptr); HeapFree(GetProcessHeap(), 0, ptr);
@ -647,10 +634,13 @@ static void TLB_ReadGuid( GUID *pGuid, int offset, TLBContext *pcx)
TLB_Read(pGuid, sizeof(GUID), pcx, pcx->pTblDir->pGuidTab.offset+offset ); TLB_Read(pGuid, sizeof(GUID), pcx, pcx->pTblDir->pGuidTab.offset+offset );
} }
PCHAR TLB_ReadName( TLBContext *pcx, int offset) BSTR TLB_ReadName( TLBContext *pcx, int offset)
{ {
char * name; char * name;
TLBNameIntro niName; TLBNameIntro niName;
int lengthInChars;
WCHAR* pwstring = NULL;
BSTR bstrName = NULL;
TLB_Read(&niName, sizeof(niName), pcx, TLB_Read(&niName, sizeof(niName), pcx,
pcx->pTblDir->pNametab.offset+offset); pcx->pTblDir->pNametab.offset+offset);
@ -658,13 +648,33 @@ PCHAR TLB_ReadName( TLBContext *pcx, int offset)
name=TLB_Alloc((niName.namelen & 0xff) +1); name=TLB_Alloc((niName.namelen & 0xff) +1);
TLB_Read(name, (niName.namelen & 0xff), pcx, DO_NOT_SEEK); TLB_Read(name, (niName.namelen & 0xff), pcx, DO_NOT_SEEK);
name[niName.namelen & 0xff]='\0'; name[niName.namelen & 0xff]='\0';
TRACE("%s\n", debugstr_a(name));
return name; lengthInChars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED | MB_ERR_INVALID_CHARS,
name, -1, NULL, NULL);
/* no invalid characters in string */
if (lengthInChars)
{
pwstring = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*lengthInChars);
/* don't check for invalid character since this has been done previously */
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, pwstring, lengthInChars);
bstrName = SysAllocStringLen(pwstring, lengthInChars);
lengthInChars = SysStringLen(bstrName);
HeapFree(GetProcessHeap(), 0, pwstring);
}
TRACE("%s %d\n", debugstr_w(bstrName), lengthInChars);
return bstrName;
} }
PCHAR TLB_ReadString( TLBContext *pcx, int offset)
BSTR TLB_ReadString( TLBContext *pcx, int offset)
{ {
char * string; char * string;
INT16 length; INT16 length;
int lengthInChars;
BSTR bstr = NULL;
if(offset<0) return NULL; if(offset<0) return NULL;
TLB_Read(&length, sizeof(INT16), pcx, pcx->pTblDir->pStringtab.offset+offset); TLB_Read(&length, sizeof(INT16), pcx, pcx->pTblDir->pStringtab.offset+offset);
@ -672,8 +682,25 @@ PCHAR TLB_ReadString( TLBContext *pcx, int offset)
string=TLB_Alloc(length +1); string=TLB_Alloc(length +1);
TLB_Read(string, length, pcx, DO_NOT_SEEK); TLB_Read(string, length, pcx, DO_NOT_SEEK);
string[length]='\0'; string[length]='\0';
TRACE("%s\n", debugstr_a(string));
return string; lengthInChars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED | MB_ERR_INVALID_CHARS,
string, -1, NULL, NULL);
/* no invalid characters in string */
if (lengthInChars)
{
WCHAR* pwstring = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*lengthInChars);
/* don't check for invalid character since this has been done previously */
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, string, -1, pwstring, lengthInChars);
bstr = SysAllocStringLen(pwstring, lengthInChars);
lengthInChars = SysStringLen(bstr);
HeapFree(GetProcessHeap(), 0, pwstring);
}
TRACE("%s %d\n", debugstr_w(bstr), lengthInChars);
return bstr;
} }
/* /*
* read a value and fill a VARIANT structure * read a value and fill a VARIANT structure
@ -790,12 +817,12 @@ static int TLB_CustData( TLBContext *pcx, int offset, TLBCustData** ppCustData )
static void TLB_GetTdesc(TLBContext *pcx, INT type,TYPEDESC * pTd ) static void TLB_GetTdesc(TLBContext *pcx, INT type,TYPEDESC * pTd )
{ {
TRACE("\n");
if(type <0) if(type <0)
pTd->vt=type & VT_TYPEMASK; pTd->vt=type & VT_TYPEMASK;
else else
*pTd=pcx->pLibInfo->pTypeDesc[type/(2*sizeof(INT))]; *pTd=pcx->pLibInfo->pTypeDesc[type/(2*sizeof(INT))];
TRACE("vt type = %X\n", pTd->vt);
} }
static void TLB_DoFuncs(TLBContext *pcx, int cFuncs, int cVars, static void TLB_DoFuncs(TLBContext *pcx, int cFuncs, int cVars,
int offset, TLBFuncDesc ** pptfd) int offset, TLBFuncDesc ** pptfd)
@ -854,7 +881,7 @@ static void TLB_DoFuncs(TLBContext *pcx, int cFuncs, int cVars,
pFuncRec->OptAttr[1]) ; pFuncRec->OptAttr[1]) ;
if(nrattributes>2){ if(nrattributes>2){
if(pFuncRec->FKCCIC & 0x2000) if(pFuncRec->FKCCIC & 0x2000)
(*pptfd)->Entry = (char *) pFuncRec->OptAttr[2] ; (*pptfd)->Entry = (WCHAR*) pFuncRec->OptAttr[2] ;
else else
(*pptfd)->Entry = TLB_ReadString(pcx, (*pptfd)->Entry = TLB_ReadString(pcx,
pFuncRec->OptAttr[2]); pFuncRec->OptAttr[2]);
@ -1083,7 +1110,7 @@ ITypeInfoImpl * TLB_DoTypeInfo(
/* name, eventually add to a hash table */ /* name, eventually add to a hash table */
ptiRet->Name=TLB_ReadName(pcx, tiBase.NameOffset); ptiRet->Name=TLB_ReadName(pcx, tiBase.NameOffset);
TRACE("reading %s\n", ptiRet->Name); TRACE("reading %s\n", debugstr_w(ptiRet->Name));
/* help info */ /* help info */
ptiRet->DocString=TLB_ReadString(pcx, tiBase.docstringoffs); ptiRet->DocString=TLB_ReadString(pcx, tiBase.docstringoffs);
ptiRet->dwHelpStringContext=tiBase.helpstringcontext; ptiRet->dwHelpStringContext=tiBase.helpstringcontext;
@ -1112,7 +1139,7 @@ ITypeInfoImpl * TLB_DoTypeInfo(
TLB_CustData(pcx, tiBase.oCustData, &ptiRet->pCustData); TLB_CustData(pcx, tiBase.oCustData, &ptiRet->pCustData);
TRACE("%s guid: %s kind:%s\n", TRACE("%s guid: %s kind:%s\n",
ptiRet->Name, debugstr_w(ptiRet->Name),
debugstr_guid(&ptiRet->TypeAttr.guid), debugstr_guid(&ptiRet->TypeAttr.guid),
typekind_desc[ptiRet->TypeAttr.typekind]); typekind_desc[ptiRet->TypeAttr.typekind]);
@ -1560,7 +1587,7 @@ static HRESULT WINAPI ITypeLib2_fnGetTypeInfoOfGuid(
} }
} }
TRACE("-- found (%p, %s)\n", ppTLBTInfo, ppTLBTInfo->Name); TRACE("-- found (%p, %s)\n", ppTLBTInfo, debugstr_w(ppTLBTInfo->Name));
*ppTInfo = (ITypeInfo*)ppTLBTInfo; *ppTInfo = (ITypeInfo*)ppTLBTInfo;
ITypeInfo_AddRef(*ppTInfo); ITypeInfo_AddRef(*ppTInfo);
@ -1621,13 +1648,13 @@ static HRESULT WINAPI ITypeLib2_fnGetDocumentation(
This, index, pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile); This, index, pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile);
if(index<0){ /* documentation for the typelib */ if(index<0){ /* documentation for the typelib */
if(pBstrName) if(pBstrName)
*pBstrName=TLB_DupAtoBstr(This->Name); *pBstrName=SysAllocString(This->Name);
if(pBstrDocString) if(pBstrDocString)
*pBstrDocString=TLB_DupAtoBstr(This->DocString); *pBstrDocString=SysAllocString(This->DocString);
if(pdwHelpContext) if(pdwHelpContext)
*pdwHelpContext=This->dwHelpContext; *pdwHelpContext=This->dwHelpContext;
if(pBstrHelpFile) if(pBstrHelpFile)
*pBstrHelpFile=TLB_DupAtoBstr(This->HelpFile); *pBstrHelpFile=SysAllocString(This->HelpFile);
}else {/* for a typeinfo */ }else {/* for a typeinfo */
result=ITypeLib2_fnGetTypeInfo(iface, index, &pTInfo); result=ITypeLib2_fnGetTypeInfo(iface, index, &pTInfo);
if(SUCCEEDED(result)){ if(SUCCEEDED(result)){
@ -1658,32 +1685,30 @@ static HRESULT WINAPI ITypeLib2_fnIsName(
TLBFuncDesc *pFInfo; TLBFuncDesc *pFInfo;
TLBVarDesc *pVInfo; TLBVarDesc *pVInfo;
int i; int i;
PCHAR astr= HEAP_strdupWtoA( GetProcessHeap(), 0, szNameBuf ); UINT nNameBufLen = SysStringLen(szNameBuf);
TRACE("(%p)->(%s,%08lx,%p)\n", This, debugstr_w(szNameBuf), lHashVal, TRACE("(%p)->(%s,%08lx,%p)\n", This, debugstr_w(szNameBuf), lHashVal,
pfName); pfName);
*pfName=TRUE; *pfName=TRUE;
if(!strcmp(astr,This->Name)) goto ITypeLib2_fnIsName_exit;
for(pTInfo=This->pTypeInfo;pTInfo;pTInfo=pTInfo->next){ for(pTInfo=This->pTypeInfo;pTInfo;pTInfo=pTInfo->next){
if(!strcmp(astr,pTInfo->Name)) goto ITypeLib2_fnIsName_exit; if(!memcmp(szNameBuf,pTInfo->Name, nNameBufLen)) goto ITypeLib2_fnIsName_exit;
for(pFInfo=pTInfo->funclist;pFInfo;pFInfo=pFInfo->next) { for(pFInfo=pTInfo->funclist;pFInfo;pFInfo=pFInfo->next) {
if(!strcmp(astr,pFInfo->Name)) goto ITypeLib2_fnIsName_exit; if(!memcmp(szNameBuf,pFInfo->Name, nNameBufLen)) goto ITypeLib2_fnIsName_exit;
for(i=0;i<pFInfo->funcdesc.cParams;i++) for(i=0;i<pFInfo->funcdesc.cParams;i++)
if(!strcmp(astr,pFInfo->pParamDesc[i].Name)) if(!memcmp(szNameBuf,pFInfo->pParamDesc[i].Name, nNameBufLen))
goto ITypeLib2_fnIsName_exit; goto ITypeLib2_fnIsName_exit;
} }
for(pVInfo=pTInfo->varlist;pVInfo;pVInfo=pVInfo->next) for(pVInfo=pTInfo->varlist;pVInfo;pVInfo=pVInfo->next)
if(!strcmp(astr,pVInfo->Name)) goto ITypeLib2_fnIsName_exit; if(!memcmp(szNameBuf,pVInfo->Name, nNameBufLen)) goto ITypeLib2_fnIsName_exit;
} }
*pfName=FALSE; *pfName=FALSE;
ITypeLib2_fnIsName_exit: ITypeLib2_fnIsName_exit:
TRACE("(%p)slow! search for %s: %s found!\n", This, TRACE("(%p)slow! search for %s: %s found!\n", This,
debugstr_a(astr), *pfName?"NOT":""); debugstr_w(szNameBuf), *pfName?"NOT":"");
HeapFree( GetProcessHeap(), 0, astr );
return S_OK; return S_OK;
} }
@ -1706,17 +1731,19 @@ static HRESULT WINAPI ITypeLib2_fnFindName(
TLBFuncDesc *pFInfo; TLBFuncDesc *pFInfo;
TLBVarDesc *pVInfo; TLBVarDesc *pVInfo;
int i,j = 0; int i,j = 0;
PCHAR astr= HEAP_strdupWtoA( GetProcessHeap(), 0, szNameBuf );
UINT nNameBufLen = SysStringLen(szNameBuf);
for(pTInfo=This->pTypeInfo;pTInfo && j<*pcFound; pTInfo=pTInfo->next){ for(pTInfo=This->pTypeInfo;pTInfo && j<*pcFound; pTInfo=pTInfo->next){
if(!strcmp(astr,pTInfo->Name)) goto ITypeLib2_fnFindName_exit; if(!memcmp(szNameBuf,pTInfo->Name, nNameBufLen)) goto ITypeLib2_fnFindName_exit;
for(pFInfo=pTInfo->funclist;pFInfo;pFInfo=pFInfo->next) { for(pFInfo=pTInfo->funclist;pFInfo;pFInfo=pFInfo->next) {
if(!strcmp(astr,pFInfo->Name)) goto ITypeLib2_fnFindName_exit; if(!memcmp(szNameBuf,pFInfo->Name,nNameBufLen)) goto ITypeLib2_fnFindName_exit;
for(i=0;i<pFInfo->funcdesc.cParams;i++) for(i=0;i<pFInfo->funcdesc.cParams;i++)
if(!strcmp(astr,pFInfo->pParamDesc[i].Name)) if(!memcmp(szNameBuf,pFInfo->pParamDesc[i].Name,nNameBufLen))
goto ITypeLib2_fnFindName_exit; goto ITypeLib2_fnFindName_exit;
} }
for(pVInfo=pTInfo->varlist;pVInfo;pVInfo=pVInfo->next) ; for(pVInfo=pTInfo->varlist;pVInfo;pVInfo=pVInfo->next) ;
if(!strcmp(astr,pVInfo->Name)) goto ITypeLib2_fnFindName_exit; if(!memcmp(szNameBuf,pVInfo->Name, nNameBufLen)) goto ITypeLib2_fnFindName_exit;
continue; continue;
ITypeLib2_fnFindName_exit: ITypeLib2_fnFindName_exit:
ITypeInfo_AddRef((ITypeInfo*)pTInfo); ITypeInfo_AddRef((ITypeInfo*)pTInfo);
@ -1724,11 +1751,10 @@ ITypeLib2_fnFindName_exit:
j++; j++;
} }
TRACE("(%p)slow! search for %d with %s: found %d TypeInfo's!\n", TRACE("(%p)slow! search for %d with %s: found %d TypeInfo's!\n",
This, *pcFound, debugstr_a(astr), j); This, *pcFound, debugstr_w(szNameBuf), j);
*pcFound=j; *pcFound=j;
HeapFree( GetProcessHeap(), 0, astr );
return S_OK; return S_OK;
} }
@ -1823,11 +1849,11 @@ static HRESULT WINAPI ITypeLib2_fnGetDocumentation2(
{ {
/* documentation for the typelib */ /* documentation for the typelib */
if(pbstrHelpString) if(pbstrHelpString)
*pbstrHelpString=TLB_DupAtoBstr(This->DocString); *pbstrHelpString=SysAllocString(This->DocString);
if(pdwHelpStringContext) if(pdwHelpStringContext)
*pdwHelpStringContext=This->dwHelpContext; *pdwHelpStringContext=This->dwHelpContext;
if(pbstrHelpStringDll) if(pbstrHelpStringDll)
*pbstrHelpStringDll=TLB_DupAtoBstr(This->HelpStringDll); *pbstrHelpStringDll=SysAllocString(This->HelpStringDll);
} }
else else
{ {
@ -2069,9 +2095,9 @@ static HRESULT WINAPI ITypeInfo_fnGetNames( ITypeInfo2 *iface, MEMBERID memid,
for(i=0; i<cMaxNames && i <= pFDesc->funcdesc.cParams; i++) for(i=0; i<cMaxNames && i <= pFDesc->funcdesc.cParams; i++)
{ {
if(!i) if(!i)
*rgBstrNames=TLB_DupAtoBstr(pFDesc->Name); *rgBstrNames=SysAllocString(pFDesc->Name);
else else
rgBstrNames[i]=TLB_DupAtoBstr(pFDesc->pParamDesc[i-1].Name); rgBstrNames[i]=SysAllocString(pFDesc->pParamDesc[i-1].Name);
} }
*pcNames=i; *pcNames=i;
} }
@ -2080,7 +2106,7 @@ static HRESULT WINAPI ITypeInfo_fnGetNames( ITypeInfo2 *iface, MEMBERID memid,
for(pVDesc=This->varlist; pVDesc && pVDesc->vardesc.memid != memid; pVDesc=pVDesc->next); for(pVDesc=This->varlist; pVDesc && pVDesc->vardesc.memid != memid; pVDesc=pVDesc->next);
if(pVDesc) if(pVDesc)
{ {
*rgBstrNames=TLB_DupAtoBstr(pVDesc->Name); *rgBstrNames=SysAllocString(pVDesc->Name);
*pcNames=1; *pcNames=1;
} }
else else
@ -2190,33 +2216,30 @@ static HRESULT WINAPI ITypeInfo_fnGetIDsOfNames( ITypeInfo2 *iface,
TLBFuncDesc * pFDesc; TLBFuncDesc * pFDesc;
TLBVarDesc * pVDesc; TLBVarDesc * pVDesc;
HRESULT ret=S_OK; HRESULT ret=S_OK;
PCHAR aszName= HEAP_strdupWtoA( GetProcessHeap(), 0, *rgszNames); UINT nNameLen = SysStringLen(*rgszNames);
TRACE("(%p) Name %s cNames %d\n", This, debugstr_a(aszName),
TRACE("(%p) Name %s cNames %d\n", This, debugstr_w(*rgszNames),
cNames); cNames);
for(pFDesc=This->funclist; pFDesc; pFDesc=pFDesc->next) { for(pFDesc=This->funclist; pFDesc; pFDesc=pFDesc->next) {
int i, j; int i, j;
if( !strcmp(aszName, pFDesc->Name)) { if( !memcmp(*rgszNames, pFDesc->Name, nNameLen)) {
if(cNames) *pMemId=pFDesc->funcdesc.memid; if(cNames) *pMemId=pFDesc->funcdesc.memid;
for(i=1; i < cNames; i++){ for(i=1; i < cNames; i++){
PCHAR aszPar= HEAP_strdupWtoA( GetProcessHeap(), 0, UINT nParamLen = SysStringLen(rgszNames[i]);
rgszNames[i]);
for(j=0; j<pFDesc->funcdesc.cParams; j++) for(j=0; j<pFDesc->funcdesc.cParams; j++)
if(strcmp(aszPar,pFDesc->pParamDesc[j].Name)) if(memcmp(rgszNames[i],pFDesc->pParamDesc[j].Name, nParamLen))
break; break;
if( j<pFDesc->funcdesc.cParams) if( j<pFDesc->funcdesc.cParams)
pMemId[i]=j; pMemId[i]=j;
else else
ret=DISP_E_UNKNOWNNAME; ret=DISP_E_UNKNOWNNAME;
HeapFree( GetProcessHeap(), 0, aszPar);
}; };
HeapFree (GetProcessHeap(), 0, aszName);
return ret; return ret;
} }
} }
for(pVDesc=This->varlist; pVDesc; pVDesc=pVDesc->next) { for(pVDesc=This->varlist; pVDesc; pVDesc=pVDesc->next) {
if( !strcmp(aszName, pVDesc->Name)) { if( !memcmp(*rgszNames, pVDesc->Name, nNameLen)) {
if(cNames) *pMemId=pVDesc->vardesc.memid; if(cNames) *pMemId=pVDesc->vardesc.memid;
HeapFree (GetProcessHeap(), 0, aszName);
return ret; return ret;
} }
} }
@ -2277,13 +2300,13 @@ static HRESULT WINAPI ITypeInfo_fnGetDocumentation( ITypeInfo2 *iface,
This, memid, pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile); This, memid, pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile);
if(memid==MEMBERID_NIL){ /* documentation for the typeinfo */ if(memid==MEMBERID_NIL){ /* documentation for the typeinfo */
if(pBstrName) if(pBstrName)
*pBstrName=TLB_DupAtoBstr(This->Name); *pBstrName=SysAllocString(This->Name);
if(pBstrDocString) if(pBstrDocString)
*pBstrDocString=TLB_DupAtoBstr(This->DocString); *pBstrDocString=SysAllocString(This->DocString);
if(pdwHelpContext) if(pdwHelpContext)
*pdwHelpContext=This->dwHelpContext; *pdwHelpContext=This->dwHelpContext;
if(pBstrHelpFile) if(pBstrHelpFile)
*pBstrHelpFile=TLB_DupAtoBstr(This->DocString);/* FIXME */ *pBstrHelpFile=SysAllocString(This->DocString);/* FIXME */
return S_OK; return S_OK;
}else {/* for a member */ }else {/* for a member */
for(pFDesc=This->funclist; pFDesc; pFDesc=pFDesc->next) for(pFDesc=This->funclist; pFDesc; pFDesc=pFDesc->next)
@ -2359,7 +2382,7 @@ static HRESULT WINAPI ITypeInfo_fnGetRefTypeInfo(
(LPTYPELIB *)&pTypeLib); (LPTYPELIB *)&pTypeLib);
if(!SUCCEEDED(result)) if(!SUCCEEDED(result))
{ {
BSTR libnam=TLB_DupAtoBstr(pRefType->pImpTLInfo->name); BSTR libnam=SysAllocString(pRefType->pImpTLInfo->name);
result=LoadTypeLib(libnam, (LPTYPELIB *)&pTypeLib); result=LoadTypeLib(libnam, (LPTYPELIB *)&pTypeLib);
SysFreeString(libnam); SysFreeString(libnam);
} }
@ -2743,34 +2766,34 @@ static HRESULT WINAPI ITypeInfo2_fnGetDocumentation2(
*/ */
if(memid==MEMBERID_NIL){ /* documentation for the typeinfo */ if(memid==MEMBERID_NIL){ /* documentation for the typeinfo */
if(pbstrHelpString) if(pbstrHelpString)
*pbstrHelpString=TLB_DupAtoBstr(This->Name); *pbstrHelpString=SysAllocString(This->Name);
if(pdwHelpStringContext) if(pdwHelpStringContext)
*pdwHelpStringContext=This->dwHelpStringContext; *pdwHelpStringContext=This->dwHelpStringContext;
if(pbstrHelpStringDll) if(pbstrHelpStringDll)
*pbstrHelpStringDll= *pbstrHelpStringDll=
TLB_DupAtoBstr(This->pTypeLib->HelpStringDll);/* FIXME */ SysAllocString(This->pTypeLib->HelpStringDll);/* FIXME */
return S_OK; return S_OK;
}else {/* for a member */ }else {/* for a member */
for(pFDesc=This->funclist; pFDesc; pFDesc=pFDesc->next) for(pFDesc=This->funclist; pFDesc; pFDesc=pFDesc->next)
if(pFDesc->funcdesc.memid==memid){ if(pFDesc->funcdesc.memid==memid){
if(pbstrHelpString) if(pbstrHelpString)
*pbstrHelpString=TLB_DupAtoBstr(pFDesc->HelpString); *pbstrHelpString=SysAllocString(pFDesc->HelpString);
if(pdwHelpStringContext) if(pdwHelpStringContext)
*pdwHelpStringContext=pFDesc->HelpStringContext; *pdwHelpStringContext=pFDesc->HelpStringContext;
if(pbstrHelpStringDll) if(pbstrHelpStringDll)
*pbstrHelpStringDll= *pbstrHelpStringDll=
TLB_DupAtoBstr(This->pTypeLib->HelpStringDll);/* FIXME */ SysAllocString(This->pTypeLib->HelpStringDll);/* FIXME */
return S_OK; return S_OK;
} }
for(pVDesc=This->varlist; pVDesc; pVDesc=pVDesc->next) for(pVDesc=This->varlist; pVDesc; pVDesc=pVDesc->next)
if(pVDesc->vardesc.memid==memid){ if(pVDesc->vardesc.memid==memid){
if(pbstrHelpString) if(pbstrHelpString)
*pbstrHelpString=TLB_DupAtoBstr(pVDesc->HelpString); *pbstrHelpString=SysAllocString(pVDesc->HelpString);
if(pdwHelpStringContext) if(pdwHelpStringContext)
*pdwHelpStringContext=pVDesc->HelpStringContext; *pdwHelpStringContext=pVDesc->HelpStringContext;
if(pbstrHelpStringDll) if(pbstrHelpStringDll)
*pbstrHelpStringDll= *pbstrHelpStringDll=
TLB_DupAtoBstr(This->pTypeLib->HelpStringDll);/* FIXME */ SysAllocString(This->pTypeLib->HelpStringDll);/* FIXME */
return S_OK; return S_OK;
} }
} }