1
1
// Licensed to the .NET Foundation under one or more agreements.
2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
+
3
4
// *****************************************************************************
4
5
// NSUtilPriv.h
5
6
//
6
7
// Helpers for converting namespace separators.
7
- //
8
8
// *****************************************************************************
9
9
10
10
#ifndef __NSUTILPRIV_H__
@@ -15,7 +15,6 @@ class SString;
15
15
16
16
struct ns
17
17
{
18
-
19
18
// *****************************************************************************
20
19
// Determine how many chars large a fully qualified name would be given the
21
20
// two parts of the name. The return value includes room for every character
43
42
int IsValidName ( // true if valid, false invalid.
44
43
LPCUTF8 szName); // Name to parse.
45
44
46
-
47
45
// *****************************************************************************
48
46
// Scan the string from the rear looking for the first valid separator. If
49
47
// found, return a pointer to it. Else return null. This code is smart enough
@@ -61,34 +59,22 @@ static
61
59
LPUTF8 FindSep ( // Pointer to separator or null.
62
60
LPCUTF8 szPath); // The path to look in.
63
61
64
-
65
62
// *****************************************************************************
66
63
// Take a path and find the last separator (nsFindSep), and then replace the
67
64
// separator with a '\0' and return a pointer to the name. So for example:
68
65
// a.b.c
69
66
// becomes two strings "a.b" and "c" and the return value points to "c".
70
67
// *****************************************************************************
71
- static
72
- WCHAR *SplitInline ( // Pointer to name portion.
73
- __inout __inout_z WCHAR *szPath); // The path to split.
74
-
75
68
static
76
69
LPUTF8 SplitInline ( // Pointer to name portion.
77
70
__inout __inout_z LPUTF8 szPath); // The path to split.
78
71
79
- static
80
- void SplitInline (
81
- __inout __inout_z LPWSTR szPath, // Path to split.
82
- LPCWSTR &szNameSpace, // Return pointer to namespace.
83
- LPCWSTR &szName); // Return pointer to name.
84
-
85
72
static
86
73
void SplitInline (
87
74
__inout __inout_z LPUTF8 szPath, // Path to split.
88
75
LPCUTF8 &szNameSpace, // Return pointer to namespace.
89
76
LPCUTF8 &szName); // Return pointer to name.
90
77
91
-
92
78
// *****************************************************************************
93
79
// Split the last parsable element from the end of the string as the name,
94
80
// the first part as the namespace.
@@ -109,7 +95,6 @@ int SplitPath( // true ok, false trunction.
109
95
_Out_writes_opt_ (cchName) LPUTF8 szName, // Output for name.
110
96
int cchName); // Max chars for output.
111
97
112
-
113
98
// *****************************************************************************
114
99
// Take two values and put them together in a fully qualified path using the
115
100
// correct separator.
@@ -128,31 +113,6 @@ int MakePath( // true ok, false truncation.
128
113
LPCUTF8 szNameSpace, // Namespace.
129
114
LPCUTF8 szName); // Name.
130
115
131
- static
132
- int MakePath ( // true ok, false truncation.
133
- _Out_writes_ (cchChars) WCHAR *szOut, // output path for name.
134
- int cchChars, // max chars for output path.
135
- LPCUTF8 szNameSpace, // Namespace.
136
- LPCUTF8 szName); // Name.
137
-
138
- static
139
- int MakePath ( // true ok, false out of memory
140
- CQuickBytes &qb, // Where to put results.
141
- LPCUTF8 szNameSpace, // Namespace for name.
142
- LPCUTF8 szName); // Final part of name.
143
-
144
- static
145
- int MakePath ( // true ok, false out of memory
146
- CQuickArray<WCHAR> &qa, // Where to put results.
147
- LPCUTF8 szNameSpace, // Namespace for name.
148
- LPCUTF8 szName); // Final part of name.
149
-
150
- static
151
- int MakePath ( // true ok, false out of memory
152
- CQuickBytes &qb, // Where to put results.
153
- const WCHAR *szNameSpace, // Namespace for name.
154
- const WCHAR *szName); // Final part of name.
155
-
156
116
static
157
117
void MakePath ( // throws on out of memory
158
118
SString &ssBuf, // Where to put results.
@@ -176,46 +136,12 @@ bool MakeAssemblyQualifiedName( // true o
176
136
int dwTypeName, // Number of characters (not including null)
177
137
const WCHAR *szAssemblyName, // Final part of name.
178
138
int dwAssemblyName); // Number of characters (not including null)
179
-
180
- static
181
- int MakeNestedTypeName ( // true ok, false out of memory
182
- CQuickBytes &qb, // Where to put results.
183
- LPCUTF8 szEnclosingName, // Full name for enclosing type
184
- LPCUTF8 szNestedName); // Full name for nested type
185
-
186
- static
187
- int MakeNestedTypeName ( // true ok, false truncation.
188
- _Out_writes_ (cchChars) LPUTF8 szOut, // output path for name.
189
- int cchChars, // max chars for output path.
190
- LPCUTF8 szEnclosingName, // Full name for enclosing type
191
- LPCUTF8 szNestedName); // Full name for nested type
192
-
193
- static
194
- void MakeNestedTypeName ( // throws on out of memory
195
- SString &ssBuf, // output path for name.
196
- const SString &ssEnclosingName, // Full name for enclosing type
197
- const SString &ssNestedName); // Full name for nested type
198
139
}; // struct ns
199
140
200
- #ifndef NAMESPACE_SEPARATOR_CHAR
201
141
#define NAMESPACE_SEPARATOR_CHAR ' .'
202
142
#define NAMESPACE_SEPARATOR_WCHAR W (' .' )
203
143
#define NAMESPACE_SEPARATOR_STR " ."
204
144
#define NAMESPACE_SEPARATOR_WSTR W (" ." )
205
- #define NAMESPACE_SEPARATOR_LEN 1
206
- #define ASSEMBLY_SEPARATOR_CHAR ' ,'
207
- #define ASSEMBLY_SEPARATOR_WCHAR W (' ,' )
208
- #define ASSEMBLY_SEPARATOR_STR " , "
209
- #define ASSEMBLY_SEPARATOR_WSTR W (" , " )
210
- #define ASSEMBLY_SEPARATOR_LEN 2
211
- #define NESTED_SEPARATOR_CHAR ' +'
212
- #define NESTED_SEPARATOR_WCHAR W (' +' )
213
- #define NESTED_SEPARATOR_STR " +"
214
- #define NESTED_SEPARATOR_WSTR W (" +" )
215
- #endif
216
-
217
- #define EMPTY_STR " "
218
- #define EMPTY_WSTR W (" " )
219
145
220
146
#define MAKE_FULL_PATH_ON_STACK_UTF8 (toptr, pnamespace, pname ) \
221
147
{ \
@@ -224,20 +150,11 @@ void MakeNestedTypeName( // throws on out of memory
224
150
ns::MakePath (toptr, __i##toptr, pnamespace, pname); \
225
151
}
226
152
227
- #define MAKE_FULL_PATH_ON_STACK_UNICODE (toptr, pnamespace, pname ) \
228
- { \
229
- int __i##toptr = ns::GetFullLength (pnamespace, pname); \
230
- toptr = (WCHAR *) alloca (__i##toptr * sizeof (WCHAR)); \
231
- ns::MakePath (toptr, __i##toptr, pnamespace, pname); \
232
- }
233
-
234
- #define MAKE_FULLY_QUALIFIED_NAME (pszFullyQualifiedName, pszNameSpace, pszName ) MAKE_FULL_PATH_ON_STACK_UTF8(pszFullyQualifiedName, pszNameSpace, pszName)
235
-
236
153
#define MAKE_FULLY_QUALIFIED_MEMBER_NAME (ptr, pszNameSpace, pszClassName, pszMemberName, pszSig ) \
237
154
{ \
238
155
int __i##ptr = ns::GetFullLength (pszNameSpace, pszClassName); \
239
156
__i##ptr += (pszMemberName ? (int ) strlen (pszMemberName) : 0 ); \
240
- __i##ptr += (NAMESPACE_SEPARATOR_LEN * 2 ) ; \
157
+ __i##ptr += (int ) strlen (NAMESPACE_SEPARATOR_STR) * 2 ; \
241
158
__i##ptr += (pszSig ? (int ) strlen (pszSig) : 0 ); \
242
159
ptr = (LPUTF8) alloca (__i##ptr); \
243
160
ns::MakePath (ptr, __i##ptr, pszNameSpace, pszClassName); \
@@ -252,12 +169,4 @@ void MakeNestedTypeName( // throws on out of memory
252
169
} \
253
170
}
254
171
255
- #ifdef _PREFAST_
256
- // need to eliminate the expansion of MAKE_FULLY_QUALIFIED_MEMBER_NAME in prefast
257
- // builds to prevent it complaining about the potential for NULLs to strlen and strcat
258
- #undef MAKE_FULLY_QUALIFIED_MEMBER_NAME
259
- // need to set ptr=NULL so we don't get a build error because ptr isn't inited in a couple cases
260
- #define MAKE_FULLY_QUALIFIED_MEMBER_NAME (ptr, pszNameSpace, pszClassName, pszMemberName, pszSig ) ptr=NULL ;
261
- #endif
262
-
263
- #endif
172
+ #endif // __NSUTILPRIV_H__
0 commit comments