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.

1656 lines
52 KiB

  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1989-1999 Microsoft Corporation
  3. Module Name:
  4. ptrcls.hxx
  5. Abstract:
  6. Contains definitions for base type related code generation class
  7. definitions.
  8. Notes:
  9. History:
  10. GregJen Sep-30-1993 Created.
  11. ----------------------------------------------------------------------------*/
  12. #ifndef __PTRCLS_HXX__
  13. #define __PTRCLS_HXX__
  14. #pragma warning ( disable : 4238 4239 )
  15. #include "nulldefs.h"
  16. extern "C"
  17. {
  18. #include <stdio.h>
  19. }
  20. #include "ndrcls.hxx"
  21. #include "arraycls.hxx"
  22. // forwards
  23. class CG_TYPEDEF;
  24. /////////////////////////////////////////////////////////////////////////////
  25. // the pointer type code generation classes.
  26. /////////////////////////////////////////////////////////////////////////////
  27. //
  28. // This class corresponds to a vanilla pointer type.
  29. //
  30. class CG_POINTER : public CG_NDR, public CG_CLONEABLE
  31. {
  32. private:
  33. unsigned long fPointerShouldFree : 1;
  34. unsigned long fIsInMultiSized : 1;
  35. unsigned char FormatAttr;
  36. // the kind of the pointer (ref, unique or full)
  37. PTRTYPE PtrKind;
  38. //
  39. // allocate attributes (defined in acfattr.hxx)
  40. //
  41. short AllocateDetails;
  42. //
  43. // For Ndr format string generation. The offset of the pointee in the
  44. // format string. We can't just get the pointee's offset in the format
  45. // string by asking the CG_POINTER's child it's offset into the format
  46. // string, because size and length pointers produce their pointee format
  47. // string by creating temporary array CG classes. Thus their real CG
  48. // child will not have the correct offset in the format string, we must
  49. // record it here instead.
  50. //
  51. long PointeeFormatStringOffset;
  52. //
  53. // If we point to an array of cs_chars, the CG node for the array doesn't
  54. // get generated until we start generating the format string so save the
  55. // user type here
  56. //
  57. node_cs_char * pCSUserType;
  58. public:
  59. //
  60. // The constructor.
  61. //
  62. CG_POINTER(
  63. node_skl * pBT,
  64. PTRTYPE p,
  65. short AD )
  66. : CG_NDR( pBT, XLAT_SIZE_INFO( (unsigned short)SIZEOF_MEM_PTR(),
  67. (unsigned short)SIZEOF_WIRE_PTR(),
  68. SIZEOF_MEM_PTR(),
  69. SIZEOF_WIRE_PTR() ) )
  70. {
  71. SetPtrType( p );
  72. PointeeFormatStringOffset = -1;
  73. SetAllocateDetails( AD );
  74. SetPointerShouldFree( 1 );
  75. SetIsInMultiSized( FALSE );
  76. SetFormatAttr( 0 );
  77. SetCSUserType( 0 );
  78. }
  79. CG_POINTER(
  80. CG_POINTER * pNode
  81. )
  82. : CG_NDR( pNode->GetType(), XLAT_SIZE_INFO( (unsigned short)SIZEOF_MEM_PTR(),
  83. (unsigned short)SIZEOF_WIRE_PTR(),
  84. SIZEOF_MEM_PTR(),
  85. SIZEOF_WIRE_PTR() ) )
  86. {
  87. *this = *pNode;
  88. }
  89. virtual
  90. CG_CLASS * Clone()
  91. {
  92. return new CG_POINTER( *this );
  93. }
  94. virtual
  95. void Visit( CG_VISITOR *pVisitor )
  96. {
  97. pVisitor->Visit( this );
  98. }
  99. //
  100. // TYPEDESC generation routine
  101. //
  102. virtual
  103. CG_STATUS GetTypeDesc(TYPEDESC * &ptd, CCB * pCCB);
  104. virtual
  105. ID_CG GetCGID()
  106. {
  107. return ID_CG_PTR;
  108. }
  109. //
  110. // Get and Set methods.
  111. //
  112. PTRTYPE GetPtrType()
  113. {
  114. return PtrKind;
  115. }
  116. PTRTYPE SetPtrType( PTRTYPE p )
  117. {
  118. return (PtrKind = p);
  119. }
  120. short GetAllocateDetails()
  121. {
  122. return AllocateDetails;
  123. }
  124. short SetAllocateDetails( short AD )
  125. {
  126. return (AllocateDetails = AD);
  127. }
  128. void SetFormatAttr( unsigned char Attr )
  129. {
  130. FormatAttr = Attr;
  131. }
  132. unsigned char GetFormatAttr()
  133. {
  134. return FormatAttr;
  135. }
  136. void SetCSUserType( node_cs_char *p)
  137. {
  138. pCSUserType = p;
  139. }
  140. node_cs_char * GetCSUserType()
  141. {
  142. return pCSUserType;
  143. }
  144. //
  145. // individual synthesized queries
  146. //
  147. BOOL IsAllocateAllNodes()
  148. {
  149. return (BOOL)
  150. (IS_ALLOCATE(AllocateDetails,
  151. ALLOCATE_ALL_NODES) );
  152. }
  153. BOOL IsAllocateDontFree()
  154. {
  155. return (BOOL)
  156. (IS_ALLOCATE(AllocateDetails,
  157. ALLOCATE_DONT_FREE ) );
  158. }
  159. void SetPointerShouldFree( unsigned long Flag )
  160. {
  161. fPointerShouldFree = Flag;
  162. }
  163. BOOL ShouldPointerFree()
  164. {
  165. return (BOOL)(fPointerShouldFree == 1);
  166. }
  167. BOOL IsRef()
  168. {
  169. return (PtrKind == PTR_REF);
  170. }
  171. BOOL IsUnique()
  172. {
  173. return (PtrKind == PTR_UNIQUE);
  174. }
  175. BOOL IsFull()
  176. {
  177. return (PtrKind == PTR_FULL);
  178. }
  179. virtual
  180. BOOL IsPointer()
  181. {
  182. return TRUE;
  183. }
  184. virtual
  185. BOOL IsPipeOrPipeReference()
  186. {
  187. if (GetChild())
  188. return ((CG_NDR*)GetChild())->IsPipeOrPipeReference();
  189. else
  190. return FALSE;
  191. }
  192. //
  193. // Common shortcuts.
  194. //
  195. BOOL IsPointerToBaseType();
  196. BOOL IsPointerToPointer();
  197. BOOL IsBasicRefPointer();
  198. //
  199. // Is this a sized pointer of sized pointers.
  200. //
  201. BOOL IsMultiSize();
  202. void SetIsInMultiSized( BOOL fSet )
  203. {
  204. fIsInMultiSized = fSet;
  205. }
  206. BOOL IsInMultiSized()
  207. {
  208. return fIsInMultiSized;
  209. }
  210. //
  211. // Get number of dimensions if this is a sized pointer of sized pointers.
  212. //
  213. long SizedDimensions();
  214. // server side stuff.
  215. virtual
  216. CG_STATUS S_GenInitOutLocals( CCB * pCCB );
  217. //
  218. // Ndr format string generation method.
  219. //
  220. virtual
  221. void GenNdrFormat( CCB * pCCB );
  222. //
  223. // Generate the description of the pointer when imbeded. Shared by
  224. // all classes which inherit CG_POINTER.
  225. //
  226. long GenNdrFormatEmbedded( CCB * pCCB )
  227. {
  228. SetFormatStringOffset(
  229. pCCB->GetFormatString()->GetCurrentOffset() );
  230. // 0 means pointee not generated yet.
  231. return GenNdrFormatAlways( pCCB );
  232. }
  233. //
  234. // This routine always generates the format string for a pointer. Used
  235. // by GenNdrFormat and GenNdrImbededFormat().
  236. // It returns the (absolute) pointee offset.
  237. //
  238. virtual
  239. long GenNdrFormatAlways( CCB * pCCB );
  240. void RegisterRecPointerForFixup(
  241. CCB * pCCB,
  242. long OffsetAt );
  243. //
  244. // This method is called to generate offline portions of a types
  245. // format string.
  246. //
  247. virtual
  248. void GenNdrParamOffline( CCB * pCCB );
  249. //
  250. // Ndr format string generation for the pointee.
  251. //
  252. virtual
  253. void GenNdrFormatPointee( CCB * pCCB );
  254. //
  255. // Prolog stuff for all classes which inherit CG_POINTER
  256. //
  257. void GenNdrPointerType( CCB * pCCB );
  258. void GetTypeAndFlags( CCB *pCCB, NDR64_POINTER_FORMAT *format );
  259. virtual
  260. BOOL ShouldFreeOffline();
  261. virtual
  262. void GenFreeInline( CCB * pCCB );
  263. //
  264. // Get and Set methods for the PointeeFormatStringOffset member.
  265. //
  266. void SetPointeeFormatStringOffset( long offset )
  267. {
  268. PointeeFormatStringOffset = offset;
  269. }
  270. long GetPointeeFormatStringOffset()
  271. {
  272. return PointeeFormatStringOffset;
  273. }
  274. //////////////////////////////////////////////////////////////////
  275. virtual
  276. CG_STATUS MarshallAnalysis( ANALYSIS_INFO * pAna );
  277. virtual
  278. CG_STATUS SizeAnalysis( ANALYSIS_INFO * )
  279. {
  280. return CG_OK;
  281. }
  282. virtual
  283. CG_STATUS UnMarshallAnalysis( ANALYSIS_INFO * pAna );
  284. long FixedBufferSize( CCB * pCCB );
  285. BOOL InterpreterMustFree( CCB * ) { return TRUE; }
  286. BOOL InterpreterAllocatesOnStack( CCB * pCCB,
  287. CG_PARAM * pMyParam,
  288. long * pAllocSize );
  289. virtual
  290. CG_STATUS S_OutLocalAnalysis( ANALYSIS_INFO * pAna );
  291. virtual
  292. expr_node * GenBindOrUnBindExpression( CCB * pCCB, BOOL fBind );
  293. CG_STATUS PtrMarshallAnalysis( ANALYSIS_INFO * pAna );
  294. CG_STATUS PteMarshallAnalysis( ANALYSIS_INFO * pAna );
  295. virtual
  296. CG_STATUS CorePteMarshallAnalysis( ANALYSIS_INFO * pAna )
  297. {
  298. if (GetChild())
  299. {
  300. return ((CG_NDR *)GetChild())->MarshallAnalysis( pAna );
  301. }
  302. return CG_OK;
  303. }
  304. CG_STATUS PtrUnMarshallAnalysis( ANALYSIS_INFO * pAna );
  305. CG_STATUS PteUnMarshallAnalysis( ANALYSIS_INFO * pAna );
  306. virtual
  307. CG_STATUS FollowerMarshallAnalysis( ANALYSIS_INFO * pAna );
  308. virtual
  309. CG_STATUS FollowerUnMarshallAnalysis( ANALYSIS_INFO * pAna );
  310. virtual
  311. CG_STATUS GenConfVarianceEtcUnMarshall( CCB * )
  312. {
  313. return CG_OK;
  314. }
  315. virtual
  316. CG_STATUS CorePteUnMarshallAnalysis( ANALYSIS_INFO * pAna )
  317. {
  318. if ( GetChild() )
  319. return ((CG_NDR *)GetChild())->UnMarshallAnalysis( pAna );
  320. else
  321. return CG_OK;
  322. }
  323. virtual
  324. U_ACTION RecommendUAction( SIDE CurrentSide,
  325. BOOL fMemoryAllocated,
  326. BOOL fRefAllocated,
  327. BOOL fBufferReUsePossible,
  328. UAFLAGS AdditionalFlags );
  329. BOOL IsQualifiedPointer()
  330. {
  331. return (GetCGID() != ID_CG_PTR );
  332. }
  333. virtual
  334. CG_STATUS GenAllocateForUnMarshall( CCB * pCCB );
  335. void PointerChecks( CCB * pCCB );
  336. void EndPointerChecks( CCB * pCCB );
  337. expr_node * FinalSizeExpression( CCB * pCCB );
  338. expr_node * FinalLengthExpression( CCB * pCCB );
  339. expr_node * FinalFirstExpression( CCB * pCCB );
  340. virtual
  341. CG_STATUS GenRefChecks( CCB * pCCB );
  342. virtual
  343. CG_STATUS InLocalAnalysis( ANALYSIS_INFO * pAna );
  344. virtual
  345. CG_STATUS S_GenInitInLocals( CCB * pCCB );
  346. };
  347. //
  348. // This class corresponds to a byte_counted pointer type.
  349. //
  350. class CG_BYTE_COUNT_POINTER : public CG_POINTER
  351. {
  352. private:
  353. // the byte count param
  354. node_param * pByteCountParam;
  355. public:
  356. //
  357. // The constructor.
  358. //
  359. CG_BYTE_COUNT_POINTER(
  360. node_skl * pBT,
  361. PTRTYPE p,
  362. node_param * pParam )
  363. : CG_POINTER( pBT, p, 0 )
  364. {
  365. SetByteCountParam( pParam );
  366. }
  367. CG_BYTE_COUNT_POINTER(
  368. CG_BYTE_COUNT_POINTER * pNode
  369. )
  370. : CG_POINTER( pNode->GetType(),
  371. pNode->GetPtrType(),
  372. pNode->GetAllocateDetails() )
  373. {
  374. *this = *pNode;
  375. }
  376. virtual
  377. CG_CLASS * Clone()
  378. {
  379. return new CG_BYTE_COUNT_POINTER( *this );
  380. }
  381. virtual
  382. void Visit( CG_VISITOR *pVisitor )
  383. {
  384. pVisitor->Visit( this );
  385. }
  386. virtual
  387. ID_CG GetCGID()
  388. {
  389. return ID_CG_BC_PTR;
  390. }
  391. void GenNdrFormat( CCB * pCCB );
  392. //
  393. // Get and Set methods.
  394. //
  395. node_param * GetByteCountParam()
  396. {
  397. return pByteCountParam;
  398. }
  399. node_param * SetByteCountParam( node_param * p )
  400. {
  401. return (pByteCountParam = p);
  402. }
  403. };
  404. //
  405. // This class corresponds to an [ignore]'d pointer type.
  406. // It is also used to help with marshaling handle_t in the -Oi interpreter
  407. // and -Os old style of parameter descriptors.
  408. // It derives from CG_NDR, but is really just a filler.
  409. //
  410. class CG_IGNORED_POINTER : public CG_NDR
  411. {
  412. private:
  413. public:
  414. //
  415. // The constructor.
  416. //
  417. CG_IGNORED_POINTER(
  418. node_skl * pBT )
  419. : CG_NDR( pBT, XLAT_SIZE_INFO( (unsigned short)
  420. SIZEOF_MEM_PTR(), // MA
  421. (unsigned short)SIZEOF_WIRE_PTR(), // WA
  422. SIZEOF_MEM_PTR(), // MS
  423. SIZEOF_WIRE_PTR() ) )// WS
  424. {
  425. }
  426. CG_IGNORED_POINTER(
  427. CG_IGNORED_POINTER * pNode
  428. )
  429. : CG_NDR( pNode->GetType(),
  430. XLAT_SIZE_INFO( (unsigned short)
  431. SIZEOF_MEM_PTR(), // MA
  432. (unsigned short)SIZEOF_WIRE_PTR(), // WA
  433. SIZEOF_MEM_PTR(), // MS
  434. SIZEOF_WIRE_PTR() ) // WS
  435. )
  436. {
  437. *pNode = *this;
  438. }
  439. virtual
  440. CG_CLASS * Clone()
  441. {
  442. return new CG_IGNORED_POINTER( *this );
  443. }
  444. virtual
  445. ID_CG GetCGID()
  446. {
  447. return ID_CG_IGN_PTR;
  448. }
  449. virtual
  450. void Visit( CG_VISITOR *pVisitor )
  451. {
  452. pVisitor->Visit( this );
  453. }
  454. //
  455. // Ndr format string generation method.
  456. //
  457. virtual
  458. void GenNdrFormat( CCB * pCCB )
  459. {
  460. pCCB->GetFormatString()->
  461. PushFormatChar( FC_IGNORE );
  462. }
  463. };
  464. ////////////////////////////////////////////////////////////////////////////
  465. // This class corresponds to a string pointer type.
  466. ////////////////////////////////////////////////////////////////////////////
  467. class CG_QUALIFIED_POINTER : public CG_POINTER
  468. {
  469. private:
  470. RESOURCE * pSizeResource;
  471. RESOURCE * pLengthResource;
  472. RESOURCE * pFirstResource;
  473. RESOURCE * pMinResource;
  474. unsigned long fUsedInArray;
  475. long Dimension;
  476. public:
  477. CG_QUALIFIED_POINTER( const CG_QUALIFIED_POINTER & Node ) :
  478. CG_POINTER( Node )
  479. {
  480. pSizeResource = Node.pSizeResource;
  481. if (NULL != pSizeResource)
  482. pSizeResource = (RESOURCE*)pSizeResource->Clone();
  483. pLengthResource = Node.pLengthResource;
  484. if (NULL != pLengthResource)
  485. pLengthResource = (RESOURCE*)pLengthResource->Clone();
  486. pFirstResource = Node.pFirstResource;
  487. if (NULL != pFirstResource)
  488. pFirstResource = (RESOURCE*)pFirstResource->Clone();
  489. pMinResource = Node.pMinResource;
  490. if (NULL != pMinResource)
  491. pMinResource = (RESOURCE*)pMinResource->Clone();
  492. fUsedInArray = Node.fUsedInArray;
  493. Dimension = Node.Dimension;
  494. }
  495. CG_QUALIFIED_POINTER( node_skl * pBT,
  496. PTRTYPE p,
  497. short AD )
  498. : CG_POINTER( pBT, p, AD )
  499. {
  500. pSizeResource = 0;
  501. pLengthResource = 0;
  502. pFirstResource = 0;
  503. pMinResource = 0;
  504. fUsedInArray = 0;
  505. SetDimension(0);
  506. }
  507. CG_QUALIFIED_POINTER(
  508. CG_QUALIFIED_POINTER * pNode )
  509. : CG_POINTER( pNode->GetType(),
  510. pNode->GetPtrType(),
  511. pNode->GetAllocateDetails() )
  512. {
  513. *this = *pNode;
  514. }
  515. virtual
  516. CG_CLASS * Clone()
  517. {
  518. return new CG_QUALIFIED_POINTER( *this );
  519. }
  520. virtual
  521. void Visit( CG_VISITOR *pVisitor )
  522. {
  523. pVisitor->Visit( this );
  524. }
  525. void SetUsedInArray()
  526. {
  527. fUsedInArray = 1;
  528. }
  529. BOOL IsUsedInArray()
  530. {
  531. return (BOOL)(fUsedInArray == 1);
  532. }
  533. RESOURCE * SetSizeResource( RESOURCE * pR )
  534. {
  535. return pSizeResource = pR;
  536. }
  537. RESOURCE * GetSizeResource()
  538. {
  539. return pSizeResource;
  540. }
  541. RESOURCE * SetLengthResource( RESOURCE * pR )
  542. {
  543. return pLengthResource = pR;
  544. }
  545. RESOURCE * GetLengthResource()
  546. {
  547. return pLengthResource;
  548. }
  549. RESOURCE * SetFirstResource( RESOURCE * pR )
  550. {
  551. return pFirstResource = pR;
  552. }
  553. RESOURCE * GetFirstResource()
  554. {
  555. return pFirstResource;
  556. }
  557. void SetDimension( long Dim )
  558. {
  559. Dimension = Dim;
  560. }
  561. long GetDimension()
  562. {
  563. return Dimension;
  564. }
  565. virtual
  566. CG_STATUS CorePteMarshallAnalysis( ANALYSIS_INFO * pAna );
  567. virtual
  568. CG_STATUS CorePteUnMarshallAnalysis( ANALYSIS_INFO * pAna );
  569. virtual
  570. BOOL NeedsMaxCountMarshall()
  571. {
  572. return FALSE;
  573. }
  574. virtual
  575. BOOL NeedsFirstAndLengthMarshall()
  576. {
  577. return FALSE;
  578. }
  579. virtual
  580. BOOL NeedsExplicitFirst()
  581. {
  582. return TRUE;
  583. }
  584. virtual
  585. expr_node * GetQPFirstIsExpression()
  586. {
  587. return pFirstResource;
  588. }
  589. virtual
  590. expr_node * GetQPLengthIsExpression()
  591. {
  592. return pLengthResource;
  593. }
  594. virtual
  595. expr_node * GetQPMinIsExpression()
  596. {
  597. return pMinResource;
  598. }
  599. virtual
  600. expr_node * GetQPSizeIsExpression()
  601. {
  602. return pSizeResource;
  603. }
  604. };
  605. class CG_STRING_POINTER : public CG_QUALIFIED_POINTER
  606. {
  607. BOOL fIsBSTR;
  608. public:
  609. //
  610. // The constructor.
  611. //
  612. CG_STRING_POINTER(
  613. node_skl * pBT,
  614. PTRTYPE p,
  615. short AD )
  616. : CG_QUALIFIED_POINTER( pBT, p, AD ),
  617. fIsBSTR( FALSE )
  618. {
  619. }
  620. CG_STRING_POINTER( CG_STRING_POINTER * pNode )
  621. : CG_QUALIFIED_POINTER( pNode )
  622. {
  623. *this = *pNode;
  624. }
  625. virtual
  626. CG_CLASS * Clone()
  627. {
  628. return new CG_STRING_POINTER( *this );
  629. }
  630. virtual
  631. ID_CG GetCGID()
  632. {
  633. //
  634. // For regular string pointers only (not for
  635. // sized string pointers), we have a different
  636. // CG id for string structs. This is for all
  637. // of the places that we check for a GetCGID()
  638. // of ID_CG_STRING_PTR when it shouldn't apply
  639. // for stringable structs.
  640. //
  641. return IsStringableStruct() ?
  642. ID_CG_STRUCT_STRING_PTR :
  643. ID_CG_STRING_PTR;
  644. }
  645. virtual
  646. void Visit( CG_VISITOR *pVisitor )
  647. {
  648. pVisitor->Visit( this );
  649. }
  650. BOOL IsStringableStruct()
  651. {
  652. CG_NDR * pChild = (CG_NDR *) GetChild();
  653. // pChild could be NULL if the CG node hasn't been
  654. // completely constructed yet.
  655. // The check for NULL keeps GetCGID from being called
  656. // on a NULL object (and crashing).
  657. return (NULL == pChild || pChild->GetCGID() != ID_CG_BT);
  658. }
  659. BOOL IsBStr()
  660. {
  661. return fIsBSTR;
  662. }
  663. void SetBStr()
  664. {
  665. fIsBSTR = TRUE;
  666. }
  667. //
  668. // TYPEDESC generation routine
  669. //
  670. virtual
  671. CG_STATUS GetTypeDesc(TYPEDESC * &ptd, CCB * pCCB);
  672. //
  673. // Ndr format string generation method.
  674. //
  675. virtual
  676. void GenNdrFormat( CCB * pCCB );
  677. //
  678. // This routine always generates the format string for a pointer. Used
  679. // by GenNdrFormat and GenNdrImbededFormat().
  680. //
  681. virtual
  682. long GenNdrFormatAlways( CCB * pCCB );
  683. //
  684. // Ndr format string generation for the pointee.
  685. //
  686. virtual
  687. void GenNdrFormatPointee( CCB * pCCB );
  688. virtual
  689. CG_STATUS GenConfVarianceEtcUnMarshall( CCB * pCCB );
  690. virtual
  691. BOOL NeedsMaxCountMarshall()
  692. {
  693. return TRUE;
  694. }
  695. virtual
  696. expr_node * GetQPFirstIsExpression()
  697. {
  698. return new expr_constant( 0L );
  699. }
  700. virtual
  701. expr_node * GetQPMinIsExpression()
  702. {
  703. return new expr_constant( 0L );
  704. }
  705. virtual
  706. BOOL NeedsFirstAndLengthMarshall()
  707. {
  708. return TRUE;
  709. }
  710. virtual
  711. BOOL NeedsExplicitFirst()
  712. {
  713. return FALSE;
  714. }
  715. virtual
  716. expr_node * PresentedSizeExpression( CCB * pCCB );
  717. virtual
  718. expr_node * PresentedLengthExpression( CCB * pCCB );
  719. virtual
  720. expr_node * PresentedFirstExpression( CCB * )
  721. {
  722. return new expr_constant(0L);
  723. }
  724. };
  725. //
  726. // This class corresponds to a sized string pointer type.
  727. //
  728. class CG_SIZE_STRING_POINTER : public CG_STRING_POINTER,
  729. public CG_CONF_ATTRIBUTE
  730. {
  731. private:
  732. public:
  733. //
  734. // The constructor.
  735. //
  736. CG_SIZE_STRING_POINTER(
  737. node_skl * pBT,
  738. PTRTYPE p,
  739. short AD ,
  740. FIELD_ATTR_INFO * pFA )
  741. : CG_STRING_POINTER( pBT, p, AD ),
  742. CG_CONF_ATTRIBUTE( pFA )
  743. {
  744. }
  745. CG_SIZE_STRING_POINTER(
  746. CG_SIZE_STRING_POINTER * pNode )
  747. : CG_STRING_POINTER( pNode ),
  748. CG_CONF_ATTRIBUTE( pNode )
  749. {
  750. *this = *pNode;
  751. }
  752. virtual
  753. ID_CG GetCGID()
  754. {
  755. return ID_CG_SIZE_STRING_PTR;
  756. }
  757. virtual
  758. void Visit( CG_VISITOR *pVisitor )
  759. {
  760. pVisitor->Visit( this );
  761. }
  762. virtual
  763. CG_CLASS * Clone()
  764. {
  765. return new CG_SIZE_STRING_POINTER( *this );
  766. }
  767. //
  768. // Ndr format string generation method.
  769. //
  770. virtual
  771. void GenNdrFormat( CCB * pCCB );
  772. //
  773. // This routine always generates the format string for a pointer. Used
  774. // by GenNdrFormat and GenNdrImbededFormat().
  775. //
  776. virtual
  777. long GenNdrFormatAlways( CCB * pCCB );
  778. //
  779. // Ndr format string generation for the pointee.
  780. //
  781. virtual
  782. void GenNdrFormatPointee( CCB * pCCB );
  783. virtual
  784. expr_node * GetQPFirstIsExpression()
  785. {
  786. return new expr_constant(0L);
  787. }
  788. virtual
  789. expr_node * GetQPMinIsExpression()
  790. {
  791. return new expr_constant(0L);
  792. }
  793. virtual
  794. expr_node * PresentedSizeExpression( CCB * pCCB );
  795. };
  796. //
  797. // This class corresponds to a sized pointer type.
  798. //
  799. class CG_SIZE_POINTER : public CG_QUALIFIED_POINTER,
  800. public CG_CONF_ATTRIBUTE
  801. {
  802. private:
  803. CG_ARRAY * pPointee;
  804. public:
  805. //
  806. // The constructor.
  807. //
  808. CG_SIZE_POINTER(
  809. node_skl * pBT,
  810. PTRTYPE p,
  811. short AD ,
  812. FIELD_ATTR_INFO * pFA )
  813. : CG_QUALIFIED_POINTER( pBT, p, AD ),
  814. CG_CONF_ATTRIBUTE( pFA )
  815. {
  816. pPointee = 0;
  817. }
  818. CG_SIZE_POINTER( CG_SIZE_POINTER * pNode )
  819. : CG_QUALIFIED_POINTER( pNode ),
  820. CG_CONF_ATTRIBUTE( pNode )
  821. {
  822. *this = *pNode;
  823. }
  824. virtual
  825. ID_CG GetCGID()
  826. {
  827. return ID_CG_SIZE_PTR;
  828. }
  829. virtual
  830. void Visit( CG_VISITOR *pVisitor )
  831. {
  832. pVisitor->Visit( this );
  833. }
  834. virtual
  835. CG_CLASS * Clone()
  836. {
  837. return new CG_SIZE_POINTER( *this );
  838. }
  839. void SetPointee( CG_ARRAY * P )
  840. {
  841. pPointee = P;
  842. }
  843. CG_ARRAY * GetPointee()
  844. {
  845. return pPointee;
  846. }
  847. //
  848. // Sized pointers use inherited CG_POINTER GenNdrFormat virtual method.
  849. //
  850. //
  851. // Ndr format string generation for the pointee.
  852. //
  853. void GenNdrFormatPointee( CCB * pCCB );
  854. virtual
  855. BOOL NeedsMaxCountMarshall()
  856. {
  857. return TRUE;
  858. }
  859. virtual
  860. BOOL NeedsFirstAndLengthMarshall()
  861. {
  862. return FALSE;
  863. }
  864. virtual
  865. expr_node * GetQPFirstIsExpression()
  866. {
  867. return new expr_constant(0L);
  868. }
  869. virtual
  870. expr_node * GetQPLengthIsExpression()
  871. {
  872. return new expr_constant(0L);
  873. }
  874. virtual
  875. expr_node * GetQPMinIsExpression()
  876. {
  877. return GetMinIsExpr();
  878. }
  879. virtual
  880. expr_node * GetQPSizeIsExpression()
  881. {
  882. return GetSizeIsExpr();
  883. }
  884. virtual
  885. expr_node * PresentedSizeExpression( CCB * pCCB );
  886. virtual
  887. expr_node * PresentedFirstExpression( CCB * )
  888. {
  889. return new expr_constant( 0L );
  890. }
  891. };
  892. //
  893. // This class corresponds to a lengthed pointer type.
  894. //
  895. class CG_LENGTH_POINTER : public CG_QUALIFIED_POINTER,
  896. public CG_VARY_ATTRIBUTE
  897. {
  898. private:
  899. public:
  900. //
  901. // The constructor.
  902. //
  903. CG_LENGTH_POINTER(
  904. node_skl * pBT,
  905. PTRTYPE p,
  906. short AD ,
  907. FIELD_ATTR_INFO * pFA )
  908. : CG_QUALIFIED_POINTER( pBT, p, AD ),
  909. CG_VARY_ATTRIBUTE( pFA )
  910. {
  911. }
  912. CG_LENGTH_POINTER(
  913. CG_LENGTH_POINTER * pNode
  914. )
  915. : CG_QUALIFIED_POINTER( pNode ),
  916. CG_VARY_ATTRIBUTE( pNode )
  917. {
  918. *this = *pNode;
  919. }
  920. virtual
  921. ID_CG GetCGID()
  922. {
  923. return ID_CG_LENGTH_PTR;
  924. }
  925. virtual
  926. void Visit( CG_VISITOR *pVisitor )
  927. {
  928. pVisitor->Visit( this );
  929. }
  930. virtual
  931. CG_CLASS * Clone()
  932. {
  933. return new CG_LENGTH_POINTER( *this );
  934. }
  935. virtual
  936. BOOL NeedsMaxCountMarshall()
  937. {
  938. return FALSE;
  939. }
  940. virtual
  941. BOOL NeedsFirstAndLengthMarshall()
  942. {
  943. return TRUE;
  944. }
  945. virtual
  946. expr_node * GetQPFirstIsExpression()
  947. {
  948. return GetFirstIsExpr();
  949. }
  950. virtual
  951. expr_node * GetQPLengthIsExpression()
  952. {
  953. return GetLengthIsExpr();
  954. }
  955. virtual
  956. expr_node * GetQPMinIsExpression()
  957. {
  958. return new expr_constant(0L);
  959. }
  960. virtual
  961. expr_node * GetQPSizeIsExpression()
  962. {
  963. return new expr_constant(0L);
  964. }
  965. virtual
  966. expr_node * PresentedLengthExpression( CCB * pCCB );
  967. virtual
  968. expr_node * PresentedFirstExpression( CCB * pCCB );
  969. };
  970. //
  971. // This class corresponds to a sized and lengthed pointer type.
  972. //
  973. class CG_SIZE_LENGTH_POINTER : public CG_QUALIFIED_POINTER,
  974. public CG_CONF_ATTRIBUTE,
  975. public CG_VARY_ATTRIBUTE
  976. {
  977. private:
  978. CG_ARRAY * pPointee;
  979. public:
  980. //
  981. // The constructor.
  982. //
  983. CG_SIZE_LENGTH_POINTER(
  984. node_skl * pBT,
  985. PTRTYPE p,
  986. short AD,
  987. FIELD_ATTR_INFO * pFA )
  988. : CG_QUALIFIED_POINTER( pBT, p, AD ),
  989. CG_CONF_ATTRIBUTE( pFA ),
  990. CG_VARY_ATTRIBUTE( pFA )
  991. {
  992. pPointee = 0;
  993. }
  994. CG_SIZE_LENGTH_POINTER(
  995. CG_SIZE_LENGTH_POINTER * pNode )
  996. : CG_QUALIFIED_POINTER( pNode ),
  997. CG_CONF_ATTRIBUTE( pNode ),
  998. CG_VARY_ATTRIBUTE( pNode )
  999. {
  1000. *this = *pNode;
  1001. }
  1002. virtual
  1003. ID_CG GetCGID()
  1004. {
  1005. return ID_CG_SIZE_LENGTH_PTR;
  1006. }
  1007. virtual
  1008. void Visit( CG_VISITOR *pVisitor )
  1009. {
  1010. pVisitor->Visit( this );
  1011. }
  1012. virtual
  1013. CG_CLASS * Clone()
  1014. {
  1015. return new CG_SIZE_LENGTH_POINTER( *this );
  1016. }
  1017. void SetPointee( CG_ARRAY * P )
  1018. {
  1019. pPointee = P;
  1020. }
  1021. CG_ARRAY * GetPointee()
  1022. {
  1023. return pPointee;
  1024. }
  1025. //
  1026. // Size-Length pointers use inherited CG_POINTER GenNdrFormat
  1027. // virtual method.
  1028. //
  1029. //
  1030. // Ndr format string generation for the pointee.
  1031. //
  1032. void GenNdrFormatPointee( CCB * pCCB );
  1033. virtual
  1034. BOOL NeedsMaxCountMarshall()
  1035. {
  1036. return TRUE;
  1037. }
  1038. virtual
  1039. BOOL NeedsFirstAndLengthMarshall()
  1040. {
  1041. return TRUE;
  1042. }
  1043. virtual
  1044. expr_node * GetQPFirstIsExpression()
  1045. {
  1046. return GetFirstIsExpr();
  1047. }
  1048. virtual
  1049. expr_node * GetQPLengthIsExpression()
  1050. {
  1051. return GetLengthIsExpr();
  1052. }
  1053. virtual
  1054. expr_node * GetQPMinIsExpression()
  1055. {
  1056. return GetMinIsExpr();
  1057. }
  1058. virtual
  1059. expr_node * GetQPSizeIsExpression()
  1060. {
  1061. return GetSizeIsExpr();
  1062. }
  1063. virtual
  1064. expr_node * PresentedSizeExpression( CCB * pCCB );
  1065. virtual
  1066. expr_node * PresentedLengthExpression( CCB * pCCB );
  1067. virtual
  1068. expr_node * PresentedFirstExpression( CCB * pCCB );
  1069. };
  1070. //
  1071. // This class corresponds to an interface pointer type.
  1072. // interface with iid_is() corresponse to CG_IIDIS_INTERFACE_POINTER
  1073. //
  1074. class CG_INTERFACE_POINTER : public CG_POINTER
  1075. {
  1076. private:
  1077. node_interface * pMyIntf;
  1078. CG_TYPEDEF* pAlias;
  1079. public:
  1080. //
  1081. // The constructor.
  1082. //
  1083. CG_INTERFACE_POINTER(node_skl * pBT,
  1084. node_interface * pInt )
  1085. : CG_POINTER( pBT, PTR_REF, 0 ),
  1086. pAlias(0)
  1087. {
  1088. SetTheInterface( pInt );
  1089. }
  1090. CG_INTERFACE_POINTER(
  1091. CG_INTERFACE_POINTER * pNode
  1092. )
  1093. : CG_POINTER( pNode->GetType(), PTR_REF, 0 ),
  1094. pAlias(0)
  1095. {
  1096. *this = *pNode;
  1097. }
  1098. virtual
  1099. CG_TYPEDEF* GetTypeAlias() { return pAlias; };
  1100. virtual
  1101. void SetTypeAlias( CG_TYPEDEF* pDef ) { pAlias = pDef; };
  1102. virtual
  1103. CG_STATUS GetTypeDesc(TYPEDESC * &ptd, CCB * pCCB);
  1104. virtual
  1105. CG_STATUS GenTypeInfo(CCB * pCCB);
  1106. virtual
  1107. void * CheckImportLib();
  1108. virtual
  1109. ID_CG GetCGID()
  1110. {
  1111. return ID_CG_INTERFACE_PTR;
  1112. }
  1113. virtual
  1114. void Visit( CG_VISITOR *pVisitor )
  1115. {
  1116. pVisitor->Visit( this );
  1117. }
  1118. virtual
  1119. CG_CLASS* Clone()
  1120. {
  1121. return new CG_INTERFACE_POINTER( *this );
  1122. }
  1123. virtual
  1124. void GenNdrFormat( CCB * pCCB );
  1125. // This routine always generates the format string for a pointer. Used
  1126. // by GenNdrFormat and GenNdrImbededFormat().
  1127. //
  1128. virtual
  1129. long GenNdrFormatAlways( CCB * pCCB );
  1130. //
  1131. // Inherited from CG_NDR.
  1132. //
  1133. BOOL ShouldFreeOffline()
  1134. {
  1135. return TRUE;
  1136. }
  1137. node_interface * SetTheInterface( node_interface * pI )
  1138. {
  1139. return ( pMyIntf = pI );
  1140. }
  1141. node_interface * GetTheInterface()
  1142. {
  1143. return pMyIntf;
  1144. }
  1145. virtual
  1146. BOOL IsInterfacePointer()
  1147. {
  1148. return TRUE;
  1149. }
  1150. virtual
  1151. CG_STATUS S_OutLocalAnalysis( ANALYSIS_INFO * pAna );
  1152. virtual
  1153. CG_STATUS MarshallAnalysis( ANALYSIS_INFO * pAna );
  1154. virtual
  1155. CG_STATUS UnMarshallAnalysis( ANALYSIS_INFO * )
  1156. {
  1157. return CG_OK;
  1158. }
  1159. virtual
  1160. CG_STATUS RefCheckAnalysis( ANALYSIS_INFO * )
  1161. {
  1162. return CG_OK;
  1163. }
  1164. virtual
  1165. CG_STATUS InLocalAnalysis( ANALYSIS_INFO * )
  1166. {
  1167. return CG_OK;
  1168. }
  1169. virtual
  1170. CG_STATUS S_GenInitOutLocals( CCB * pCCB );
  1171. virtual
  1172. CG_STATUS S_GenInitInLocals( CCB * )
  1173. {
  1174. return CG_OK;
  1175. }
  1176. virtual
  1177. CG_STATUS GenRefChecks( CCB * )
  1178. {
  1179. return CG_OK;
  1180. }
  1181. void GenNdrFormatForGuid( CCB * pCCB );
  1182. //
  1183. // Ndr format string generation for the pointee.
  1184. //
  1185. virtual
  1186. void GenNdrFormatPointee( CCB * )
  1187. {
  1188. }
  1189. };
  1190. //
  1191. // This class corresponds to an interface pointer with iid_is() attribute
  1192. // Note that the base class can be an interface OR a void *
  1193. //
  1194. class
  1195. CG_IIDIS_INTERFACE_POINTER : public CG_POINTER
  1196. {
  1197. private:
  1198. expr_node * pIIDExpr;
  1199. node_skl * pMyBase;
  1200. CG_TYPEDEF* pAlias;
  1201. public:
  1202. //
  1203. // Get and Set methods.
  1204. //
  1205. CG_IIDIS_INTERFACE_POINTER(node_skl * pBT,
  1206. node_skl * pInt,
  1207. expr_node * pIIDEx)
  1208. : CG_POINTER( pBT, PTR_REF, 0 ),
  1209. pAlias(0)
  1210. {
  1211. SetIIDExpr( pIIDEx );
  1212. SetBaseInterface( pInt );
  1213. }
  1214. CG_IIDIS_INTERFACE_POINTER(
  1215. CG_IIDIS_INTERFACE_POINTER * pNode
  1216. )
  1217. : CG_POINTER( pNode->GetType(), PTR_REF, 0 ),
  1218. pAlias(0)
  1219. {
  1220. *this = *pNode;
  1221. }
  1222. virtual
  1223. CG_TYPEDEF* GetTypeAlias() { return pAlias; };
  1224. virtual
  1225. void SetTypeAlias( CG_TYPEDEF* pDef ) { pAlias = pDef; };
  1226. virtual
  1227. CG_STATUS GetTypeDesc(TYPEDESC * &ptd, CCB * pCCB);
  1228. virtual
  1229. CG_STATUS GenTypeInfo(CCB * pCCB);
  1230. virtual
  1231. void * CheckImportLib();
  1232. virtual
  1233. ID_CG GetCGID()
  1234. {
  1235. return ID_CG_IIDIS_INTERFACE_PTR;
  1236. }
  1237. expr_node * SetIIDExpr( expr_node * pE )
  1238. {
  1239. return ( pIIDExpr = pE );
  1240. }
  1241. expr_node * GetIIDExpr()
  1242. {
  1243. return pIIDExpr;
  1244. }
  1245. virtual
  1246. BOOL IsInterfacePointer()
  1247. {
  1248. return TRUE;
  1249. }
  1250. virtual
  1251. void Visit( CG_VISITOR *pVisitor )
  1252. {
  1253. pVisitor->Visit( this );
  1254. }
  1255. virtual
  1256. CG_CLASS* Clone()
  1257. {
  1258. return new CG_IIDIS_INTERFACE_POINTER( *this );
  1259. }
  1260. virtual
  1261. void GenNdrFormat( CCB * pCCB );
  1262. // This routine always generates the format string for a pointer. Used
  1263. // by GenNdrFormat and GenNdrImbededFormat().
  1264. //
  1265. virtual
  1266. long GenNdrFormatAlways( CCB * pCCB );
  1267. //
  1268. // Inherited from CG_NDR.
  1269. //
  1270. BOOL ShouldFreeOffline()
  1271. {
  1272. return TRUE;
  1273. }
  1274. node_skl * SetBaseInterface( node_skl * pI )
  1275. {
  1276. return ( pMyBase = pI );
  1277. }
  1278. node_skl * GetBaseInterface()
  1279. {
  1280. return pMyBase;
  1281. }
  1282. virtual
  1283. CG_STATUS S_OutLocalAnalysis( ANALYSIS_INFO * pAna );
  1284. virtual
  1285. CG_STATUS MarshallAnalysis( ANALYSIS_INFO * pAna );
  1286. virtual
  1287. CG_STATUS UnMarshallAnalysis( ANALYSIS_INFO * )
  1288. {
  1289. return CG_OK;
  1290. }
  1291. virtual
  1292. CG_STATUS RefCheckAnalysis( ANALYSIS_INFO * )
  1293. {
  1294. return CG_OK;
  1295. }
  1296. virtual
  1297. CG_STATUS InLocalAnalysis( ANALYSIS_INFO * )
  1298. {
  1299. return CG_OK;
  1300. }
  1301. virtual
  1302. CG_STATUS S_GenInitOutLocals( CCB * pCCB );
  1303. virtual
  1304. CG_STATUS S_GenInitInLocals( CCB * )
  1305. {
  1306. return CG_OK;
  1307. }
  1308. virtual
  1309. CG_STATUS GenRefChecks( CCB * )
  1310. {
  1311. return CG_OK;
  1312. }
  1313. virtual
  1314. void GenNdrFormatPointee( CCB * )
  1315. {
  1316. }
  1317. };
  1318. //
  1319. // New 64bit NDR pointer types.
  1320. //
  1321. #define DECLARE_COMPLEX_POINTER_CG_CLASS( NEWTYPE, BASETYPE ) \
  1322. class NEWTYPE : public BASETYPE \
  1323. { \
  1324. protected: \
  1325. NEWTYPE( const NEWTYPE & Node ) : \
  1326. BASETYPE( Node ) {} \
  1327. public: \
  1328. NEWTYPE( node_skl *pType, \
  1329. PTRTYPE p, \
  1330. short AD, \
  1331. FIELD_ATTR_INFO * pFA ) : \
  1332. BASETYPE( pType, \
  1333. p, \
  1334. AD, \
  1335. pFA ) \
  1336. { \
  1337. } \
  1338. virtual CG_CLASS* Clone() { return new NEWTYPE(*this); } \
  1339. virtual void Visit( CG_VISITOR *pVisitor ) { pVisitor->Visit( this ); } \
  1340. };
  1341. // Conformant pointers
  1342. DECLARE_COMPLEX_POINTER_CG_CLASS( CG_COMPLEX_SIZE_POINTER, CG_SIZE_POINTER )
  1343. DECLARE_COMPLEX_POINTER_CG_CLASS( CG_FORCED_COMPLEX_SIZE_POINTER, CG_COMPLEX_SIZE_POINTER )
  1344. DECLARE_COMPLEX_POINTER_CG_CLASS( CG_FULL_COMPLEX_SIZE_POINTER, CG_COMPLEX_SIZE_POINTER )
  1345. // Varying pointers
  1346. DECLARE_COMPLEX_POINTER_CG_CLASS( CG_COMPLEX_LENGTH_POINTER, CG_LENGTH_POINTER )
  1347. DECLARE_COMPLEX_POINTER_CG_CLASS( CG_FORCED_COMPLEX_LENGTH_POINTER, CG_COMPLEX_LENGTH_POINTER )
  1348. DECLARE_COMPLEX_POINTER_CG_CLASS( CG_FULL_COMPLEX_LENGTH_POINTER, CG_COMPLEX_LENGTH_POINTER )
  1349. // Conformant varying pointers
  1350. DECLARE_COMPLEX_POINTER_CG_CLASS( CG_COMPLEX_SIZE_LENGTH_POINTER, CG_SIZE_LENGTH_POINTER )
  1351. DECLARE_COMPLEX_POINTER_CG_CLASS( CG_FORCED_COMPLEX_SIZE_LENGTH_POINTER, CG_COMPLEX_SIZE_LENGTH_POINTER )
  1352. DECLARE_COMPLEX_POINTER_CG_CLASS( CG_FULL_COMPLEX_SIZE_LENGTH_POINTER, CG_COMPLEX_SIZE_LENGTH_POINTER )
  1353. #endif // __PTRCLS_HXX__