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.

124 lines
3.1 KiB

  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1989-1999 Microsoft Corporation
  3. Module Name:
  4. pungent.cxx
  5. Abstract:
  6. Implementations of the pointer cg class unmarshalling methods.
  7. Notes:
  8. The pointer unmarshalling is a bit tricky, so put into another file.
  9. History:
  10. Dec-10-1993 VibhasC Created
  11. ----------------------------------------------------------------------------*/
  12. /****************************************************************************
  13. * include files
  14. ***************************************************************************/
  15. #include "becls.hxx"
  16. #pragma hdrstop
  17. /****************************************************************************
  18. * local definitions
  19. ***************************************************************************/
  20. /****************************************************************************
  21. * local data
  22. ***************************************************************************/
  23. /****************************************************************************
  24. * externs
  25. ***************************************************************************/
  26. /****************************************************************************/
  27. //
  28. // This method is also supposed to init any embedded pointers.
  29. //
  30. CG_STATUS
  31. CG_POINTER::GenAllocateForUnMarshall(
  32. CCB * pCCB )
  33. {
  34. if( IsRef() )
  35. {
  36. Out_If_IfAllocRef(pCCB,
  37. pCCB->GetDestExpression(),
  38. pCCB->GetSourceExpression(),
  39. // FinalSizeExpression( pCCB )
  40. new expr_constant( 4L )
  41. );
  42. }
  43. else
  44. {
  45. Out_If_IfAlloc(pCCB,
  46. pCCB->GetDestExpression(),
  47. pCCB->GetSourceExpression(),
  48. // FinalSizeExpression( pCCB )
  49. new expr_constant( 4L )
  50. );
  51. }
  52. Out_Assign( pCCB,
  53. MakeDereferentExpressionIfNecessary(pCCB->GetDestExpression()),
  54. new expr_constant( 0L ) );
  55. Out_Endif( pCCB );
  56. return CG_OK;
  57. }
  58. void
  59. CG_POINTER::PointerChecks(
  60. CCB * pCCB )
  61. {
  62. short CILevel = pCCB->GetCurrentIndirectionLevel();
  63. short CELevel = pCCB->GetCurrentEmbeddingLevel();
  64. BOOL fClientSideTopLevelPtr = FALSE;
  65. if( !IsRef() )
  66. {
  67. if( (pCCB->GetCodeGenSide() == CGSIDE_CLIENT ) && (CILevel == 0) &&
  68. !pCCB->IsReturnContext()
  69. )
  70. fClientSideTopLevelPtr = TRUE;
  71. if( fClientSideTopLevelPtr )
  72. {
  73. Out_Comment( pCCB, "(Check TopLevelPtrInBufferOnly )" );
  74. Out_TLUPDecisionBufferOnly( pCCB,
  75. pCCB->GetPtrToPtrInBuffer(),
  76. MakeAddressOfPointer( pCCB->GetDestExpression() ) );
  77. }
  78. else if( CELevel == 0 )
  79. {
  80. Out_Comment( pCCB, "if( CheckTopLevelPtrInBufferAndMem )" );
  81. Out_TLUPDecision( pCCB,
  82. pCCB->GetPtrToPtrInBuffer(),
  83. MakeAddressOfPointer(pCCB->GetDestExpression()));
  84. }
  85. else
  86. {
  87. Out_UPDecision( pCCB,
  88. pCCB->GetPtrToPtrInBuffer(),
  89. MakeAddressOfPointer(pCCB->GetDestExpression()));
  90. }
  91. }
  92. }
  93. void
  94. CG_POINTER::EndPointerChecks(
  95. CCB * pCCB )
  96. {
  97. // If it is a ref pointer, no checks were made in the first place.
  98. if( !IsRef() )
  99. Out_Endif( pCCB );
  100. }