Leaked source code of windows server 2003
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.

178 lines
4.4 KiB

  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1989-1999 Microsoft Corporation
  3. Module Name:
  4. dtable.cxx
  5. Abstract:
  6. Dispatch table class implementation.
  7. Notes:
  8. History:
  9. Oct-01-1993 VibhasC Created.
  10. ----------------------------------------------------------------------------*/
  11. /****************************************************************************
  12. * include files
  13. ***************************************************************************/
  14. #include "becls.hxx"
  15. #pragma hdrstop
  16. /****************************************************************************
  17. * local definitions
  18. ***************************************************************************/
  19. /****************************************************************************
  20. * local data
  21. ***************************************************************************/
  22. /****************************************************************************
  23. * externs
  24. ***************************************************************************/
  25. /****************************************************************************/
  26. void
  27. DISPATCH_TABLE::RegisterProcedure(
  28. node_skl * pProc,
  29. DISPATCH_TABLE_FLAGS Flags )
  30. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  31. Routine Description:
  32. Register a procedure into the dispatch table.
  33. Arguments:
  34. pProc - The procedure node to be registered.
  35. Flags - Additional information flags.
  36. Return Value:
  37. None.
  38. Notes:
  39. if the flags field indicates a pure interpreter procedure, then
  40. the node pointer is really a pointer to a name, and not a node_skl
  41. ----------------------------------------------------------------------------*/
  42. {
  43. PNAME pProcName;
  44. node_skl * pN = pProc;
  45. DISPATCH_TABLE_ENTRY * pDEntry;
  46. pProcName = pProc->GetSymName();
  47. pN = pProc;
  48. //
  49. // Allocate a dispatch table entry.
  50. //
  51. pDEntry = new DISPATCH_TABLE_ENTRY;
  52. pDEntry->pName = pProcName;
  53. pDEntry->Flags = Flags;
  54. pDEntry->pNode = pN;
  55. AddElement( (IDICTELEMENT) pDEntry );
  56. }
  57. DISPATCH_TABLE::~DISPATCH_TABLE()
  58. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  59. Routine Description:
  60. The destructor.
  61. Arguments:
  62. None.
  63. Return Value:
  64. NA.
  65. Notes:
  66. ----------------------------------------------------------------------------*/
  67. {
  68. short i = 0;
  69. short Count = GetNumberOfElements();
  70. DISPATCH_TABLE_ENTRY * pDEntry;
  71. //
  72. // remove the dispatch table entries. The procedure name is NOT
  73. // owned by the dipatch table, DO NOT delete it. Just delete the
  74. // dispatch table entry.
  75. //
  76. for( i = 0; i < Count; ++i )
  77. {
  78. pDEntry = (DISPATCH_TABLE_ENTRY *)GetElement( (IDICTKEY)i );
  79. delete pDEntry;
  80. }
  81. }
  82. unsigned short
  83. DISPATCH_TABLE::GetProcList(
  84. ITERATOR& DTableEntryList,
  85. DISPATCH_TABLE_FLAGS Flags )
  86. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  87. Routine Description:
  88. Return a list of all procedures which conform to the specified dispatch
  89. table flags.
  90. Arguments:
  91. DTableEntryList - A pre-allocated iterator for receiving the list of
  92. dispatch table entries.
  93. Flags - flags which determine what entries will be picked up.
  94. Return Value:
  95. A count of the number of procedures in the list.
  96. Notes:
  97. The flags field is a filter for the dispatch table entries. Only those
  98. dispatch table entries which have conforming properties are returned in
  99. the list.
  100. There are 2 types of entries:
  101. normal (call with DTF_NONE) and interpreter (call with DTF_INTERPRETER).
  102. The way it works is that
  103. - call with DTF_NONE returns DTF_NONEs or DTF_PICKLING_PROCs
  104. - call with DTF_INTERPRETER returns DTF_INTERPRETERs or DTF_PICKLING_PROCs
  105. ----------------------------------------------------------------------------*/
  106. {
  107. short ListCount,
  108. i,
  109. Count;
  110. DISPATCH_TABLE_ENTRY * pDEntry;
  111. for( ListCount = 0, i = 0, Count = GetNumberOfElements();
  112. i < Count;
  113. ++i
  114. )
  115. {
  116. pDEntry = (DISPATCH_TABLE_ENTRY *)GetElement( (IDICTKEY)i );
  117. if( (pDEntry->Flags & Flags ) == Flags )
  118. {
  119. ITERATOR_INSERT( DTableEntryList, pDEntry );
  120. ListCount++;
  121. }
  122. }
  123. return ListCount;
  124. }