Refine the code for PCD tools.
[mirror_edk2.git] / Tools / Source / PcdTools / org / tianocore / pcd / entity / UsageInstance.java
CommitLineData
878ddf1f 1/** @file\r
2 UsageInstance class.\r
3\r
4 This class indicate an usage instance for a PCD token. This instance maybe a module\r
5 or platform setting. When a module produce or cosume a PCD token, then this module\r
6 is an usage instance for this PCD token.\r
bc262841 7\r
878ddf1f 8Copyright (c) 2006, Intel Corporation\r
9All rights reserved. This program and the accompanying materials\r
10are licensed and made available under the terms and conditions of the BSD License\r
11which accompanies this distribution. The full text of the license may be found at\r
12http://opensource.org/licenses/bsd-license.php\r
bc262841 13\r
878ddf1f 14THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
15WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
16\r
bc262841 17**/\r
d14ebb43 18package org.tianocore.pcd.entity;\r
878ddf1f 19\r
d14ebb43 20import org.tianocore.pcd.entity.CommonDefinition;\r
21import org.tianocore.pcd.entity.UsageIdentification;\r
878ddf1f 22\r
23/**\r
24 This class indicate an usage instance for a PCD token. This instance maybe a module\r
25 or platform setting. When a module produce or cosume a PCD token, then this module\r
26 is an usage instance for this PCD token.\r
27**/\r
28public class UsageInstance {\r
38ee8d9e 29 ///\r
30 /// This parent that this usage instance belongs to.\r
31 ///\r
eece174a 32 public Token parentToken;\r
38ee8d9e 33\r
34 ///\r
eece174a 35 /// ModuleIdentification for Usage Instance\r
bc262841 36 ///\r
d14ebb43 37 public UsageIdentification usageId;\r
38ee8d9e 38\r
39 ///\r
eece174a 40 /// Arch also is a key for a UsageInstance\r
bc262841 41 ///\r
eece174a 42 public String arch;\r
38ee8d9e 43\r
44 ///\r
bc262841 45 /// The PCD type defined for module\r
46 ///\r
eece174a 47 public Token.PCD_TYPE modulePcdType;\r
38ee8d9e 48\r
49 ///\r
bc262841 50 /// The value of the PCD in this usage instance.\r
51 ///\r
eece174a 52 public String datum;\r
38ee8d9e 53\r
54 ///\r
55 /// The maxDatumSize could be different for same PCD in different module\r
56 /// But this case is allow for FeatureFlag, FixedAtBuild, PatchableInModule\r
57 /// type.\r
bc262841 58 ///\r
eece174a 59 public int maxDatumSize;\r
38ee8d9e 60\r
61 ///\r
62 /// Autogen string for header file.\r
63 ///\r
eece174a 64 public String hAutogenStr;\r
38ee8d9e 65\r
66 ///\r
67 /// Auotgen string for C code file.\r
bc262841 68 ///\r
eece174a 69 public String cAutogenStr;\r
38ee8d9e 70\r
71 /**\r
eece174a 72 Constructure function for UsageInstance\r
bc262841 73\r
eece174a 74 @param parentToken The token instance for this usgaInstance\r
f28c0830 75 @param usageId The identification for usage instance\r
eece174a 76 @param modulePcdType The PCD type for this usage instance\r
77 @param value The value of this PCD in this usage instance\r
78 @param maxDatumSize The max datum size of this PCD in this usage\r
79 instance.\r
80 **/\r
81 public UsageInstance(Token parentToken,\r
d14ebb43 82 UsageIdentification usageId,\r
eece174a 83 Token.PCD_TYPE modulePcdType,\r
eece174a 84 String value,\r
85 int maxDatumSize) {\r
38ee8d9e 86 this.parentToken = parentToken;\r
d14ebb43 87 this.usageId = usageId;\r
38ee8d9e 88 this.modulePcdType = modulePcdType;\r
38ee8d9e 89 this.datum = value;\r
90 this.maxDatumSize = maxDatumSize;\r
91 }\r
92\r
93 /**\r
94 Get the primary key for usage instance array for every token.\r
bc262841 95\r
d14ebb43 96 @param usageId The identification of UsageInstance\r
bc262841 97\r
eece174a 98 @retval String The primary key for this usage instance\r
99 **/\r
d14ebb43 100 public static String getPrimaryKey(UsageIdentification usageId) {\r
101 return usageId.toString();\r
38ee8d9e 102 }\r
103\r
104 /**\r
105 Get primary key string for this usage instance\r
bc262841 106\r
38ee8d9e 107 @return String primary key string\r
108 **/\r
109 public String getPrimaryKey() {\r
d14ebb43 110 return UsageInstance.getPrimaryKey(usageId);\r
38ee8d9e 111 }\r
112\r
113 /**\r
114 Judget whether current module is PEI driver\r
bc262841 115\r
eece174a 116 @return boolean whether current module is PEI driver\r
117 **/\r
38ee8d9e 118 public boolean isPeiPhaseComponent() {\r
d14ebb43 119 int moduleType = CommonDefinition.getModuleType(usageId.moduleType);\r
eece174a 120\r
136adffc 121 if ((moduleType == CommonDefinition.ModuleTypePeiCore) ||\r
122 (moduleType == CommonDefinition.ModuleTypePeim)) {\r
38ee8d9e 123 return true;\r
124 }\r
125 return false;\r
126 }\r
127\r
128 /**\r
eece174a 129 Judge whether current module is DXE driver.\r
bc262841 130\r
eece174a 131 @return boolean whether current module is DXE driver\r
132 **/\r
133 public boolean isDxePhaseComponent() {\r
d14ebb43 134 int moduleType = CommonDefinition.getModuleType(usageId.moduleType);\r
eece174a 135\r
136 if ((moduleType == CommonDefinition.ModuleTypeDxeDriver) ||\r
137 (moduleType == CommonDefinition.ModuleTypeDxeRuntimeDriver) ||\r
138 (moduleType == CommonDefinition.ModuleTypeDxeSalDriver) ||\r
139 (moduleType == CommonDefinition.ModuleTypeDxeSmmDriver) ||\r
140 (moduleType == CommonDefinition.ModuleTypeUefiDriver) ||\r
141 (moduleType == CommonDefinition.ModuleTypeUefiApplication)\r
142 ) {\r
143 return true;\r
144 }\r
145 return false;\r
146 }\r
147\r
148 /**\r
149 Generate autogen string for header file and C code file.\r
bc262841 150\r
38ee8d9e 151 @param isBuildUsedLibrary whether the autogen is for library.\r
eece174a 152 **/\r
153 public void generateAutoGen(boolean isBuildUsedLibrary) {\r
51da9e80 154 String guidStringCName = null;\r
155 boolean isByteArray = false;\r
156 String printDatum = null;\r
157 String tokenNumberString = null;\r
38ee8d9e 158\r
159 hAutogenStr = "";\r
160 cAutogenStr = "";\r
161\r
162 if (this.modulePcdType == Token.PCD_TYPE.DYNAMIC_EX) {\r
eece174a 163 //\r
164 // For DYNAMIC_EX type PCD, use original token number in SPD or FPD to generate autogen\r
bc262841 165 //\r
51da9e80 166 tokenNumberString = Long.toString(parentToken.dynamicExTokenNumber, 16);\r
38ee8d9e 167 } else {\r
eece174a 168 //\r
169 // For Others type PCD, use autogenerated token number to generate autogen\r
bc262841 170 //\r
51da9e80 171 tokenNumberString = Long.toString(parentToken.tokenNumber, 16);\r
38ee8d9e 172 }\r
173\r
eece174a 174 hAutogenStr += String.format("#define _PCD_TOKEN_%s 0x%s\r\n", parentToken.cName, tokenNumberString);\r
175\r
176 //\r
177 // Judge the value of this PCD is byte array type\r
bc262841 178 //\r
2435723a 179 if (!isBuildUsedLibrary && !parentToken.isDynamicPCD) {\r
180 if (datum.trim().charAt(0) == '{') {\r
181 isByteArray = true;\r
182 }\r
183 }\r
184\r
eece174a 185 //\r
186 // "ULL" should be added to value's tail for UINT64 value\r
bc262841 187 //\r
1cf9cdcc 188 if (parentToken.datumType == Token.DATUM_TYPE.UINT64) {\r
189 printDatum = this.datum + "ULL";\r
190 } else {\r
191 printDatum = this.datum;\r
192 }\r
193\r
38ee8d9e 194 switch (modulePcdType) {\r
195 case FEATURE_FLAG:\r
11eb278a 196 //\r
197 // Example autogen string for following generation:\r
198 // "extern const BOOLEAN _gPcd_FixedAtBuild_PcdSampleToken";\r
199 // \r
bc262841 200 hAutogenStr += String.format("extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n",\r
16d3e132 201 parentToken.cName);\r
11eb278a 202 //\r
203 // Example autogen string for following generation:\r
204 // "#define _PCD_GET_MODE_8_PcdSampleToken _gPcd_FixedAtBuild_PcdSampleToken";\r
205 // \r
57a38e69 206 hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",\r
bc262841 207 Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
16d3e132 208 parentToken.cName,\r
209 parentToken.cName);\r
11eb278a 210 //\r
211 // Example autogen string for following generation:\r
212 // "//#define _PCD_SET_MODE_8_PcdSampleToken ASSERT(FALSE) If is not allowed to set value...";\r
213 // \r
57a38e69 214 hAutogenStr += String.format("//#define _PCD_SET_MODE_%s_%s ASSERT(FALSE) If is not allowed to set value for a FEATURE_FLAG PCD\r\n",\r
bc262841 215 Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
57a38e69 216 parentToken.cName);\r
16d3e132 217\r
218 if (!isBuildUsedLibrary) {\r
11eb278a 219 //\r
220 // Example autogen string for following generation:\r
221 // "#define _PCD_VALUE_PcdSampleToken 0x1000"\r
222 // \r
bc262841 223 hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",\r
224 parentToken.cName,\r
1cf9cdcc 225 printDatum);\r
11eb278a 226 //\r
227 // Example autogen string for following generation:\r
228 // "GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_PcdSampleToken = _PCD_VALUE_PcdSampleToken;"\r
229 // \r
38ee8d9e 230 cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r
231 parentToken.cName,\r
232 parentToken.cName);\r
38ee8d9e 233 }\r
234 break;\r
235 case FIXED_AT_BUILD:\r
16d3e132 236 if (isByteArray) {\r
11eb278a 237 //\r
238 // Example autogen string for following generation:\r
239 // "extern const BOOLEAN _gPcd_FixedAtBuild_PcdSampleToken";\r
240 // \r
16d3e132 241 hAutogenStr += String.format("extern const UINT8 _gPcd_FixedAtBuild_%s[];\r\n",\r
242 parentToken.cName);\r
11eb278a 243 //\r
244 // Example autogen string for following generation:\r
245 // "#define _PCD_GET_MODE_8_PcdSampleToken (VOID*)_gPcd_FixedAtBuild_PcdSampleToken";\r
246 // \r
bc262841 247 hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s (VOID*)_gPcd_FixedAtBuild_%s\r\n",\r
16d3e132 248 Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
249 parentToken.cName,\r
250 parentToken.cName);\r
251 } else {\r
11eb278a 252 //\r
253 // Example autogen string for following generation:\r
254 // "extern const UINT8 _gPcd_FixedAtBuild_PcdSampleToken";\r
255 // \r
38ee8d9e 256 hAutogenStr += String.format("extern const %s _gPcd_FixedAtBuild_%s;\r\n",\r
257 Token.getAutogendatumTypeString(parentToken.datumType),\r
258 parentToken.cName);\r
11eb278a 259 //\r
260 // Example autogen string for following generation:\r
261 // "#define _PCD_GET_MODE_8_PcdSampleToken _gPcd_FixedAtBuild_PcdSampleToken";\r
262 // \r
bc262841 263 hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",\r
38ee8d9e 264 Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
265 parentToken.cName,\r
266 parentToken.cName);\r
16d3e132 267 }\r
268\r
11eb278a 269 //\r
270 // Example autogen string for following generation:\r
271 // "//#define _PCD_SET_MODE_8_PcdSampleToken ASSERT(FALSE) If is not allowed to set value...";\r
272 // \r
57a38e69 273 hAutogenStr += String.format("//#define _PCD_SET_MODE_%s_%s ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD\r\n",\r
bc262841 274 Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
57a38e69 275 parentToken.cName);\r
16d3e132 276 if (!isBuildUsedLibrary) {\r
9efa2da0 277 if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
278 if (isByteArray) {\r
11eb278a 279 //\r
280 // Example autogen string for following generation:\r
281 // "#define _PCD_VALUE_PcdSampleToken (VOID*)_gPcd_FixedAtBuild_PcdSampleToken"\r
282 // \r
bc262841 283 hAutogenStr += String.format("#define _PCD_VALUE_%s (VOID*)_gPcd_FixedAtBuild_%s\r\n",\r
284 parentToken.cName,\r
9efa2da0 285 parentToken.cName);\r
11eb278a 286 //\r
287 // Example autogen string for following generation:\r
288 // "GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_PcdSampleToken[] = 'dfdf';"\r
289 // \r
9efa2da0 290 cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_%s[] = %s;\r\n",\r
291 parentToken.cName,\r
292 printDatum);\r
293 } else {\r
11eb278a 294 //\r
295 // Example autogen string for following generation:\r
296 // "#define _PCD_VALUE_PcdSampleToken 0x222"\r
297 // \r
bc262841 298 hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",\r
299 parentToken.cName,\r
9efa2da0 300 printDatum);\r
11eb278a 301 //\r
302 // Example autogen string for following generation:\r
303 // "GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r
304 // \r
9efa2da0 305 cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r
306 Token.getAutogendatumTypeString(parentToken.datumType),\r
307 parentToken.cName,\r
308 parentToken.cName);\r
309 }\r
2435723a 310 } else {\r
11eb278a 311 //\r
312 // Example autogen string for following generation:\r
313 // "#define _PCD_VALUE_PcdSampleToken 0x222"\r
314 // \r
bc262841 315 hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",\r
316 parentToken.cName,\r
9efa2da0 317 printDatum);\r
11eb278a 318 //\r
319 // Example autogen string for following generation:\r
320 // "GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r
321 // \r
2435723a 322 cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r
323 Token.getAutogendatumTypeString(parentToken.datumType),\r
324 parentToken.cName,\r
325 parentToken.cName);\r
2435723a 326 }\r
38ee8d9e 327 }\r
328 break;\r
329 case PATCHABLE_IN_MODULE:\r
16d3e132 330 if (isByteArray) {\r
11eb278a 331 //\r
332 // Example autogen string for following generation:\r
333 // "extern UINT8 _gPcd_BinaryPatch_PcdSampleToken[];"\r
334 // \r
16d3e132 335 hAutogenStr += String.format("extern UINT8 _gPcd_BinaryPatch_%s[];\r\n",\r
336 parentToken.cName);\r
11eb278a 337 //\r
338 // Example autogen string for following generation:\r
339 // "#define _PCD_GET_MODE_8_PcdSampleToken (VOID*)_gPcd_BinaryPatch_PcdSampleToken"\r
340 // \r
57a38e69 341 hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s (VOID*)_gPcd_BinaryPatch_%s\r\n",\r
16d3e132 342 Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
343 parentToken.cName,\r
bc262841 344 parentToken.cName);\r
16d3e132 345 } else {\r
11eb278a 346 //\r
347 // Example autogen string for following generation:\r
348 // "extern UINT8 _gPcd_BinaryPatch_PcdSampleToken;"\r
349 // \r
38ee8d9e 350 hAutogenStr += String.format("extern %s _gPcd_BinaryPatch_%s;\r\n",\r
351 Token.getAutogendatumTypeString(parentToken.datumType),\r
352 parentToken.cName);\r
11eb278a 353 //\r
354 // Example autogen string for following generation:\r
355 // "#define _PCD_GET_MODE_8_PcdSampleToken _gPcd_BinaryPatch_PcdSampleToken"\r
356 // \r
57a38e69 357 hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s _gPcd_BinaryPatch_%s\r\n",\r
38ee8d9e 358 Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
359 parentToken.cName,\r
bc262841 360 parentToken.cName);\r
16d3e132 361 }\r
362\r
57a38e69 363 //\r
364 // Generate _PCD_SET_MODE_xx macro for using set BinaryPatch value via PcdSet macro\r
bc262841 365 //\r
57a38e69 366 if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
11eb278a 367 //\r
368 // Example autogen string for following generation:\r
369 // "#define _PCD_SET_MODE_8_PcdSampleToken(SizeOfBuffer, Buffer) CopyMem (_gPcd_BinaryPatch_PcdSampleToken, (Buffer), (SizeOfBuffer))"\r
370 // \r
57a38e69 371 hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) CopyMem (_gPcd_BinaryPatch_%s, (Buffer), (SizeOfBuffer))\r\n",\r
372 Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
373 parentToken.cName,\r
374 parentToken.cName);\r
375 } else {\r
11eb278a 376 //\r
377 // Example autogen string for following generation:\r
378 // "#define _PCD_SET_MODE_8_PcdSampleToken(Value) (_gPcd_BinaryPatch_PcdSampleToken = (Value))"\r
379 // \r
57a38e69 380 hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value) (_gPcd_BinaryPatch_%s = (Value))\r\n",\r
381 Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
382 parentToken.cName,\r
383 parentToken.cName);\r
384 }\r
bc262841 385\r
16d3e132 386 if (!isBuildUsedLibrary) {\r
11eb278a 387 //\r
388 // Example autogen string for following generation:\r
389 // "#define _PCD_VALUE_PcdSampleToken 0x111"\r
390 // \r
bc262841 391 hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",\r
392 parentToken.cName,\r
1cf9cdcc 393 printDatum);\r
2435723a 394 if (isByteArray) {\r
11eb278a 395 //\r
396 // Example autogen string for following generation:\r
397 // "GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r
398 // \r
2435723a 399 cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_%s[] = _PCD_VALUE_%s;\r\n",\r
400 parentToken.cName,\r
401 parentToken.cName);\r
2435723a 402 } else {\r
11eb278a 403 //\r
404 // Example autogen string for following generation:\r
405 // "GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r
406 // \r
2435723a 407 cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED %s _gPcd_BinaryPatch_%s = _PCD_VALUE_%s;\r\n",\r
408 Token.getAutogendatumTypeString(parentToken.datumType),\r
409 parentToken.cName,\r
410 parentToken.cName);\r
2435723a 411 }\r
38ee8d9e 412 }\r
413\r
414 break;\r
415 case DYNAMIC:\r
11eb278a 416 //\r
417 // Example autogen string for following generation:\r
418 // "#define _PCD_GET_MODE_8_PcdSampleToken LibPcdGet%s(_PCD_TOKEN_PcdSampleToken)"\r
419 // \r
57a38e69 420 hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s LibPcdGet%s(_PCD_TOKEN_%s)\r\n",\r
38ee8d9e 421 Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
422 parentToken.cName,\r
423 Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
424 parentToken.cName);\r
57a38e69 425 if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
11eb278a 426 //\r
427 // Example autogen string for following generation:\r
428 // "#define _PCD_SET_MODE_8_PcdSampleToken(SizeOfBuffer, Buffer) LibPcdSet%s(_PCD_TOKEN_PcdSampleToken, (SizeOfBuffer), (Buffer))"\r
429 // \r
57a38e69 430 hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) LibPcdSet%s(_PCD_TOKEN_%s, (SizeOfBuffer), (Buffer))\r\n",\r
431 Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
432 parentToken.cName,\r
433 Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
434 parentToken.cName);\r
435 } else {\r
11eb278a 436 //\r
437 // Example autogen string for following generation:\r
438 // "#define _PCD_SET_MODE_8_PcdSampleToken(Value) LibPcdSet%s(_PCD_TOKEN_PcdSampleToken, (Value))"\r
439 // \r
57a38e69 440 hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value) LibPcdSet%s(_PCD_TOKEN_%s, (Value))\r\n",\r
441 Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
442 parentToken.cName,\r
443 Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
444 parentToken.cName);\r
445 }\r
38ee8d9e 446 break;\r
447 case DYNAMIC_EX:\r
11e7b0f6 448 guidStringCName = "_gPcd_TokenSpaceGuid_" +\r
449 parentToken.tokenSpaceName.toString().replaceAll("-", "_");\r
57a38e69 450\r
11eb278a 451 //\r
452 // Example autogen string for following generation:\r
453 // "#define _PCD_GET_MODE_8_PcdSampleToken LibPcdGetEx%s(&_gPcd_TokenSpaceGuid_00_00_00, _PCD_TOKEN_PcdSampleToken)"\r
454 // \r
57a38e69 455 hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s LibPcdGetEx%s(&%s, _PCD_TOKEN_%s)\r\n",\r
38ee8d9e 456 Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
457 parentToken.cName,\r
458 Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
a49b34c0 459 guidStringCName,\r
38ee8d9e 460 parentToken.cName);\r
461\r
57a38e69 462 if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
11eb278a 463 //\r
464 // Example autogen string for following generation:\r
465 // "#define _PCD_SET_MODE_8_PcdSampleToken(SizeOfBuffer, Buffer) LibPcdSetEx%s(&_gPcd_TokenSpaceGuid_00_00_00, _PCD_TOKEN_PcdSampleToken, (SizeOfBuffer), (Buffer))"\r
466 // \r
57a38e69 467 hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, _PCD_TOKEN_%s, (SizeOfBuffer), (Buffer))\r\n",\r
468 Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
469 parentToken.cName,\r
470 Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
471 guidStringCName,\r
472 parentToken.cName);\r
473 } else {\r
11eb278a 474 //\r
475 // Example autogen string for following generation:\r
476 // "#define _PCD_SET_MODE_8_PcdSampleToken(Value) LibPcdSetEx%s(&_gPcd_TokenSpaceGuid_00_00_00, _PCD_TOKEN_PcdSampleToken, (Value))"\r
477 //\r
57a38e69 478 hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value) LibPcdSetEx%s(&%s, _PCD_TOKEN_%s, (Value))\r\n",\r
479 Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
480 parentToken.cName,\r
481 Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
482 guidStringCName,\r
483 parentToken.cName);\r
484\r
485 }\r
38ee8d9e 486 break;\r
487 }\r
488 }\r
489\r
490 /**\r
491 Get the autogen string for header file.\r
bc262841 492\r
38ee8d9e 493 @return The string of header file.\r
494 **/\r
495 public String getHAutogenStr() {\r
496 return hAutogenStr;\r
497 }\r
878ddf1f 498\r
38ee8d9e 499 /**\r
500 Get the autogen string for C code file.\r
bc262841 501\r
38ee8d9e 502 @return The string of C Code file.\r
503 **/\r
504 public String getCAutogenStr() {\r
505 return cAutogenStr;\r
878ddf1f 506 }\r
878ddf1f 507}\r
508\r