1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 /**************************************************************************/
5 /* a type parameter list */
11 extern unsigned int g_uCodePage;
28 void Init(BinStr* bounds, LPCUTF8 name, DWORD attrs)
31 ULONG cTemp = (ULONG)strlen(name)+1;
33 m_wzName = pwzName = new WCHAR[cTemp];
36 memset(pwzName,0,sizeof(WCHAR)*cTemp);
37 WszMultiByteToWideChar(g_uCodePage,0,name,-1,pwzName,cTemp);
41 BinStr* Bounds() { return m_pbsBounds; };
42 LPCWSTR Name() { return m_wzName; };
43 DWORD Attrs() { return m_dwAttrs; };
44 CustomDescrList* CAList() { return &m_lstCA; };
49 CustomDescrList m_lstCA;
54 TyParList(DWORD a, BinStr* b, LPCUTF8 n, TyParList* nx = NULL)
56 bound = (b == NULL) ? new BinStr() : b;
57 bound->appendInt32(0); // zero terminator
58 attrs = a; name = n; next = nx;
62 if( bound) delete bound;
64 // To avoid excessive stack usage (especially in debug builds), we break the next chain
65 // and delete as we traverse the link list
66 TyParList *pCur = next;
69 TyParList *pTmp = pCur->next;
79 for(n = 1; (tp = tp->next) != NULL; n++);
82 int IndexOf(LPCUTF8 name)
87 for(n=0; tp != NULL; n++, tp = tp->next)
91 if(name == NULL) ret = n;
95 if(name == NULL) continue;
96 if(0 == strcmp(name,tp->name)) ret = n;
103 #pragma warning(push)
104 #pragma warning(disable:6211) // "Leaking memory 'b' due to an exception. Consider using a local catch block to clean up memory"
105 #endif /*_PREFAST_ */
107 int ToArray(BinStr ***bounds, LPCWSTR** names, DWORD **attrs)
110 BinStr **b = new BinStr* [n];
111 LPCWSTR *nam = new LPCWSTR [n];
112 DWORD *attr = attrs ? new DWORD [n] : NULL;
113 TyParList *tp = this;
117 ULONG cTemp = (ULONG)strlen(tp->name)+1;
118 WCHAR* wzDllName = new WCHAR [cTemp];
119 // Convert name to UNICODE
120 memset(wzDllName,0,sizeof(WCHAR)*cTemp);
121 WszMultiByteToWideChar(g_uCodePage,0,tp->name,-1,wzDllName,cTemp);
122 nam[i] = (LPCWSTR)wzDllName;
126 tp->bound = 0; // to avoid deletion by destructor
141 int ToArray(TyParDescr **ppTPD)
144 TyParDescr *pTPD = NULL;
147 pTPD = new TyParDescr[n];
151 TyParList *tp = this;
154 pTPD[i].Init(tp->bound,tp->name,tp->attrs);
155 tp->bound = 0; // to avoid deletion by destructor
164 TyParList* Next() { return next; };
165 BinStr* Bound() { return bound; };
173 typedef TyParList* pTyParList;