Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

135 lines
2.5 KiB

  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1989-1999 Microsoft Corporation
  3. Module Name:
  4. treg.cxx
  5. Abstract:
  6. This file implements the type registry for header file generation.
  7. Notes:
  8. History:
  9. Oc-23-1993 VibhasC Created.
  10. ----------------------------------------------------------------------------*/
  11. #pragma warning ( disable : 4514 )
  12. /****************************************************************************
  13. * include files
  14. ***************************************************************************/
  15. #include "becls.hxx"
  16. #pragma hdrstop
  17. node_skl *
  18. TREGISTRY::IsRegistered(
  19. node_skl * pType )
  20. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  21. Routine Description:
  22. Register a type with the type registry.
  23. Arguments:
  24. pType - A pointer to the type being registered.
  25. Return Value:
  26. The node that gets registered.
  27. Notes:
  28. ----------------------------------------------------------------------------*/
  29. {
  30. Dict_Status Status = Dict_Find( pType );
  31. switch( Status )
  32. {
  33. case EMPTY_DICTIONARY:
  34. case ITEM_NOT_FOUND:
  35. return (node_skl *)0;
  36. default:
  37. return (node_skl *)Dict_Curr_Item();
  38. }
  39. }
  40. node_skl *
  41. TREGISTRY::Register(
  42. node_skl * pType )
  43. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  44. Routine Description:
  45. Register a type with the dictionary.
  46. Arguments:
  47. pType - A pointer to the type node.
  48. Return Value:
  49. The final inserted type.
  50. Notes:
  51. ----------------------------------------------------------------------------*/
  52. {
  53. if( !IsRegistered( pType ) )
  54. {
  55. Dict_Insert( (pUserType) pType );
  56. return pType;
  57. }
  58. return (node_skl *)pType;
  59. }
  60. short
  61. TREGISTRY::GetListOfTypes(
  62. ITERATOR& ListIter )
  63. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  64. Routine Description:
  65. Get the list of types in this registry.
  66. Arguments:
  67. ListIter - A pre- constructed iterator where the list of types is
  68. returned.
  69. Return Value:
  70. The count of the number of items.
  71. Notes:
  72. ----------------------------------------------------------------------------*/
  73. {
  74. node_skl * pN;
  75. Dict_Status Status;
  76. short Count = 0;
  77. // Get to the top of the dictionary.
  78. Status = Dict_Next( (pUserType)0 );
  79. // make sure we start with a clean iterator
  80. ITERATOR_DISCARD( ListIter );
  81. // Iterate till the entire dictionary is looked at.
  82. while( SUCCESS == Status )
  83. {
  84. pN = (node_skl *)Dict_Curr_Item();
  85. ITERATOR_INSERT( ListIter, pN );
  86. Count++;
  87. Status = Dict_Next( (pUserType)pN );
  88. }
  89. return Count;
  90. }