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.

1183 lines
39 KiB

  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1989-1999 Microsoft Corporation
  3. Module Name:
  4. arraycls.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 __ARRAYCLS_HXX__
  13. #define __ARRAYCLS_HXX__
  14. #pragma warning ( disable : 4238 4239 )
  15. #include "nulldefs.h"
  16. extern "C"
  17. {
  18. #include <stdio.h>
  19. }
  20. #include "fldattr.hxx"
  21. #include "ndrcls.hxx"
  22. //
  23. // Ndr routines used by array and union classes for generation of attribute
  24. // (size_is, length_is, switch_is, etc.) descriptions.
  25. //
  26. void
  27. GenNdrFormatAttributeDescription( CCB * pCCB,
  28. expr_node* pMinExpr,
  29. expr_node* pSizeExpr,
  30. BOOL IsPointer,
  31. BOOL IsUnion,
  32. BOOL IsVaryingArray,
  33. BOOL IsMultiDArray,
  34. BOOL fGenCorrelationDesc,
  35. unsigned char uFlags = 0
  36. );
  37. void
  38. GenNdrFormatComplexAttributeDescription( CCB * pCCB,
  39. expr_node * pMinExpr,
  40. expr_node * pSizeExpr,
  41. long StackTopDisplacement,
  42. char * PrintPrefix,
  43. BOOL IsPointer );
  44. class CG_CONF_ATTRIBUTE;
  45. class FIELD_ATTRIBUTE_INFO;
  46. // for now, define CG_ACT here.
  47. typedef enum _cgact
  48. {
  49. CG_ACT_MARSHALL,
  50. CG_ACT_SIZING,
  51. CG_ACT_UNMARSHALL,
  52. CG_ACT_FREE,
  53. CG_ACT_FOLLOWER_MARSHALL,
  54. CG_ACT_FOLLOWER_SIZING,
  55. CG_ACT_FOLLOWER_UNMARSHALL,
  56. CG_ACT_FOLLOWER_FREE,
  57. CG_ACT_OUT_ALLOCATE
  58. } CG_ACT;
  59. // for now, put these info classes here:
  60. class CG_CONF_ATTRIBUTE
  61. {
  62. private:
  63. expr_node * pMinIsExpr;
  64. expr_node * pSizeIsExpr;
  65. public:
  66. CG_CONF_ATTRIBUTE( FIELD_ATTR_INFO * pFAInfo )
  67. {
  68. pMinIsExpr = pFAInfo->pMinIsExpr;
  69. pSizeIsExpr = pFAInfo->pSizeIsExpr;
  70. }
  71. CG_CONF_ATTRIBUTE( CG_CONF_ATTRIBUTE * pNode )
  72. {
  73. *this = *pNode;
  74. }
  75. expr_node * GetMinIsExpr()
  76. {
  77. return pMinIsExpr;
  78. }
  79. expr_node * GetSizeIsExpr()
  80. {
  81. return pSizeIsExpr;
  82. }
  83. //
  84. // Ndr format string routine.
  85. //
  86. void GenFormatStringConformanceDescription(
  87. CCB * pCCB,
  88. BOOL IsPointer,
  89. BOOL IsMultiDArray );
  90. };
  91. class CG_VARY_ATTRIBUTE
  92. {
  93. private:
  94. expr_node * pFirstIsExpr;
  95. expr_node * pLengthIsExpr;
  96. protected:
  97. CG_VARY_ATTRIBUTE( const CG_VARY_ATTRIBUTE & Node )
  98. {
  99. *this = Node;
  100. }
  101. public:
  102. CG_VARY_ATTRIBUTE( FIELD_ATTR_INFO * pFAInfo )
  103. {
  104. pFirstIsExpr = pFAInfo->pFirstIsExpr;
  105. pLengthIsExpr = pFAInfo->pLengthIsExpr;
  106. }
  107. CG_VARY_ATTRIBUTE( CG_VARY_ATTRIBUTE * pNode )
  108. {
  109. *this = *pNode;
  110. }
  111. expr_node * GetFirstIsExpr()
  112. {
  113. return pFirstIsExpr;
  114. }
  115. expr_node * GetLengthIsExpr()
  116. {
  117. return pLengthIsExpr;
  118. }
  119. //
  120. // Ndr format string routine.
  121. //
  122. void GenFormatStringVarianceDescription(
  123. CCB * pCCB,
  124. BOOL IsPointer,
  125. BOOL IsVaryingArray,
  126. BOOL IsMultiDArray );
  127. };
  128. #include "ptrcls.hxx"
  129. /////////////////////////////////////////////////////////////////////////////
  130. // the array type code generation class.
  131. /////////////////////////////////////////////////////////////////////////////
  132. //
  133. // This is the base class for all the array CG classes
  134. //
  135. class CG_ARRAY : public CG_NDR, public CG_CONF_ATTRIBUTE, public CG_CLONEABLE
  136. {
  137. private:
  138. unsigned short Dimensions;
  139. BOOL fHasFollower;
  140. BOOL fIsInMultiDim;
  141. BOOL fIsDupedSizePtr;
  142. BOOL fForcedComplex;
  143. PTRTYPE PtrKind;
  144. RESOURCE * pIndexResource;
  145. RESOURCE * pPtrResource;
  146. RESOURCE * pSizeResource;
  147. RESOURCE * pLengthResource;
  148. RESOURCE * pFirstResource;
  149. RESOURCE * pMinResource;
  150. RESOURCE * pInLocalResource;
  151. long ElementDescriptionOffset;
  152. node_cs_char * pCSUserType; // user type for cs_char arrays
  153. protected:
  154. CG_ARRAY(
  155. const CG_ARRAY & Node ) :
  156. CG_NDR( Node ),
  157. CG_CONF_ATTRIBUTE( Node )
  158. {
  159. Dimensions = Node.Dimensions;
  160. fHasFollower = Node.fHasFollower;
  161. fIsInMultiDim = Node.fIsInMultiDim;
  162. fIsDupedSizePtr = Node.fIsDupedSizePtr;
  163. fForcedComplex = Node.fForcedComplex;
  164. PtrKind = Node.PtrKind;
  165. pIndexResource = NULL;
  166. if ( NULL != Node.pIndexResource )
  167. pIndexResource = (RESOURCE*)( Node.pIndexResource->Clone() );
  168. pPtrResource = NULL;
  169. if ( NULL != Node.pPtrResource )
  170. pPtrResource = (RESOURCE*)( Node.pPtrResource->Clone() );
  171. pSizeResource = NULL;
  172. if ( NULL != Node.pSizeResource )
  173. pSizeResource = (RESOURCE*)( Node.pSizeResource->Clone() );
  174. pLengthResource = NULL;
  175. if ( NULL != Node.pLengthResource )
  176. pLengthResource = (RESOURCE*)( Node.pLengthResource->Clone() );
  177. pFirstResource = NULL;
  178. if ( NULL != Node.pFirstResource )
  179. pFirstResource = (RESOURCE*)( Node.pFirstResource->Clone() );
  180. pMinResource = NULL;
  181. if ( NULL != Node.pMinResource )
  182. pMinResource = (RESOURCE*)( Node.pMinResource->Clone() );
  183. pInLocalResource = NULL;
  184. if ( NULL != Node.pInLocalResource )
  185. pInLocalResource = (RESOURCE*)( Node.pInLocalResource->Clone() );
  186. ElementDescriptionOffset = Node.ElementDescriptionOffset;
  187. pCSUserType = Node.pCSUserType;
  188. }
  189. public:
  190. //
  191. // The constructor.
  192. //
  193. CG_ARRAY(
  194. node_skl * pBT,// array in typegraph
  195. FIELD_ATTR_INFO * pFA,
  196. unsigned short Dim,// number of dimensions
  197. XLAT_SIZE_INFO & Info // wire alignment, etc
  198. ) :
  199. CG_NDR( pBT, Info ),
  200. CG_CONF_ATTRIBUTE( pFA ),
  201. fForcedComplex( FALSE )
  202. {
  203. SetDimensions( Dim );
  204. ResetHasFollower();
  205. SetIndexResource( 0 );
  206. SetPtrResource( 0 );
  207. SetSizeResource( 0 );
  208. SetLengthResource( 0 );
  209. SetFirstResource( 0 );
  210. SetMinResource( 0 );
  211. SetInLocalResource( 0 );
  212. SetIsInMultiDim( FALSE );
  213. SetElementDescriptionOffset(-1);
  214. SetIsDupedSizePtr( FALSE );
  215. SetCSUserType( 0 );
  216. }
  217. virtual
  218. CG_CLASS * Clone()
  219. {
  220. return new CG_ARRAY(*this);
  221. }
  222. virtual
  223. void Visit( CG_VISITOR *pVisitor )
  224. {
  225. pVisitor->Visit( this );
  226. }
  227. BOOL IsForcedComplex() { return fForcedComplex; };
  228. void ForceComplex() { fForcedComplex = TRUE ; };
  229. //
  230. // Get and set methods.
  231. //
  232. PTRTYPE GetPtrType()
  233. {
  234. return PtrKind;
  235. }
  236. PTRTYPE SetPtrType( PTRTYPE p )
  237. {
  238. return (PtrKind = p);
  239. }
  240. RESOURCE * SetInLocalResource( RESOURCE * pR )
  241. {
  242. return pInLocalResource = pR;
  243. }
  244. RESOURCE * GetInLocalResource()
  245. {
  246. return pInLocalResource;
  247. }
  248. RESOURCE * SetPtrResource( RESOURCE * pR )
  249. {
  250. return pPtrResource = pR;
  251. }
  252. RESOURCE * GetPtrResource()
  253. {
  254. return pPtrResource;
  255. }
  256. RESOURCE * SetMinResource( RESOURCE * pR )
  257. {
  258. return pMinResource = pR;
  259. }
  260. RESOURCE * GetMinResource()
  261. {
  262. return pMinResource;
  263. }
  264. RESOURCE * SetSizeResource( RESOURCE * pR )
  265. {
  266. return pSizeResource = pR;
  267. }
  268. RESOURCE * GetSizeResource()
  269. {
  270. return pSizeResource;
  271. }
  272. RESOURCE * SetLengthResource( RESOURCE * pR )
  273. {
  274. return pLengthResource = pR;
  275. }
  276. RESOURCE * GetLengthResource()
  277. {
  278. return pLengthResource;
  279. }
  280. RESOURCE * SetFirstResource( RESOURCE * pR )
  281. {
  282. return pFirstResource = pR;
  283. }
  284. RESOURCE * GetFirstResource()
  285. {
  286. return pFirstResource;
  287. }
  288. RESOURCE * SetIndexResource( RESOURCE * pR )
  289. {
  290. return pIndexResource = pR;
  291. }
  292. RESOURCE * GetIndexResource()
  293. {
  294. return pIndexResource;
  295. }
  296. void SetElementDescriptionOffset( long Offset )
  297. {
  298. ElementDescriptionOffset = Offset;
  299. }
  300. long GetElementDescriptionOffset()
  301. {
  302. return ElementDescriptionOffset;
  303. }
  304. void ResetHasFollower()
  305. {
  306. fHasFollower = 0;
  307. }
  308. BOOL SetHasFollower()
  309. {
  310. fHasFollower = 1;
  311. return TRUE;
  312. }
  313. BOOL HasFollower()
  314. {
  315. return (BOOL)( fHasFollower == 1);
  316. }
  317. unsigned short SetDimensions( unsigned short Dim )
  318. {
  319. return ( Dimensions = Dim );
  320. }
  321. unsigned short GetDimensions()
  322. {
  323. return Dimensions;
  324. }
  325. void SetIsInMultiDim( BOOL fSet )
  326. {
  327. fIsInMultiDim = fSet;
  328. }
  329. BOOL IsInMultiDim()
  330. {
  331. return fIsInMultiDim;
  332. }
  333. void SetIsDupedSizePtr( BOOL fSet )
  334. {
  335. fIsDupedSizePtr = fSet;
  336. }
  337. BOOL IsDupedSizePtr()
  338. {
  339. return fIsDupedSizePtr;
  340. }
  341. void SetCSUserType( node_cs_char *p )
  342. {
  343. pCSUserType = p;
  344. }
  345. node_cs_char * GetCSUserType( )
  346. {
  347. return pCSUserType;
  348. }
  349. PNAME GetCSUserTypeName()
  350. {
  351. if ( !pCSUserType )
  352. return NULL;
  353. return pCSUserType->GetUserTypeName();
  354. }
  355. long GetCSElementSize()
  356. {
  357. MIDL_ASSERT( NULL != pCSUserType );
  358. return pCSUserType->GetElementSize();
  359. }
  360. virtual
  361. BOOL IsArray()
  362. {
  363. return TRUE;
  364. }
  365. virtual
  366. BOOL IsFixedArray()
  367. {
  368. return FALSE;
  369. }
  370. //
  371. // Is this a multidimensional array with > 1 dimension conformant and/or
  372. // varying.
  373. //
  374. BOOL IsMultiConfOrVar();
  375. //
  376. // Is the array complex by Ndr Engine standards.
  377. //
  378. virtual
  379. BOOL IsComplex();
  380. //
  381. // Ndr format string generation method. Redefined by all classes which
  382. // inherit CG_ARRAY.
  383. //
  384. virtual
  385. void GenNdrFormat( CCB * )
  386. {
  387. MIDL_ASSERT(0);
  388. }
  389. //
  390. // Handles common steps for array Ndr format string generation.
  391. //
  392. BOOL GenNdrFormatArrayProlog( CCB * pCCB );
  393. //
  394. // Generates the format string for the layout.
  395. //
  396. BOOL GenNdrFormatArrayLayout( CCB * pCCB );
  397. //
  398. // Generates the pointer layout.
  399. //
  400. virtual
  401. void GenNdrFormatArrayPointerLayout( CCB * pCCB,
  402. BOOL fNoPP );
  403. //
  404. // Generate the format string description for a complex array. Shared
  405. // by all array classes.
  406. //
  407. void GenNdrFormatComplex( CCB * pCCB );
  408. //
  409. // Generate the FC_CSARRAY prolog if this is an international char array
  410. //
  411. void GenNdrCSArrayProlog( CCB *pCCB );
  412. virtual
  413. BOOL ShouldFreeOffline();
  414. virtual
  415. void GenFreeInline( CCB * pCCB );
  416. //
  417. // Determine an array's element size.
  418. //
  419. long GetElementSize();
  420. virtual
  421. long FixedBufferSize( CCB * )
  422. {
  423. return -1;
  424. }
  425. virtual
  426. CG_STATUS MarshallAnalysis( ANALYSIS_INFO * pAna );
  427. virtual
  428. CG_STATUS FollowerMarshallAnalysis( ANALYSIS_INFO * pAna );
  429. virtual
  430. CG_STATUS UnMarshallAnalysis( ANALYSIS_INFO * pAna );
  431. virtual
  432. CG_STATUS S_OutLocalAnalysis( ANALYSIS_INFO * pAna );
  433. virtual
  434. CG_STATUS FollowerUnMarshallAnalysis( ANALYSIS_INFO * pAna );
  435. virtual
  436. BOOL NeedsMaxCountMarshall()
  437. {
  438. return FALSE;
  439. }
  440. virtual
  441. BOOL NeedsFirstAndLengthMarshall()
  442. {
  443. return FALSE;
  444. }
  445. virtual
  446. BOOL NeedsExplicitFirst()
  447. {
  448. return FALSE;
  449. }
  450. BOOL HasPointer();
  451. expr_node * FinalFirstExpression( CCB * pCCB );
  452. expr_node * FinalSizeExpression( CCB * pCCB );
  453. expr_node * FinalLengthExpression( CCB * pCCB );
  454. CG_STATUS DimByDimMarshallAnalysis( ANALYSIS_INFO * pAna );
  455. CG_STATUS DimByDimUnMarshallAnalysis( ANALYSIS_INFO * pAna );
  456. CG_NDR * GetBasicCGClass();
  457. virtual
  458. BOOL IsBlockCopyPossible();
  459. BOOL IsArrayOfRefPointers();
  460. BOOL MustBeAllocatedOnUnMarshall( CCB * pCCB );
  461. virtual
  462. CG_STATUS S_GenInitOutLocals( CCB * pCCB );
  463. virtual
  464. CG_STATUS GenRefChecks( CCB * pCCB );
  465. virtual
  466. CG_STATUS RefCheckAnalysis( ANALYSIS_INFO * pAna );
  467. virtual
  468. CG_STATUS InLocalAnalysis( ANALYSIS_INFO * pAna );
  469. virtual
  470. CG_STATUS S_GenInitInLocals( CCB * pCCB );
  471. };
  472. //
  473. // This class corresponds to a vanilla array type.
  474. //
  475. class CG_FIXED_ARRAY : public CG_ARRAY
  476. {
  477. private:
  478. public:
  479. //
  480. // The constructor.
  481. //
  482. CG_FIXED_ARRAY(
  483. node_skl * pBT, // array in typegraph
  484. FIELD_ATTR_INFO * pFA,
  485. unsigned short dim, // dimensions
  486. XLAT_SIZE_INFO & Info // wire align.
  487. ) :
  488. CG_ARRAY( pBT, pFA, dim, Info )
  489. {
  490. }
  491. virtual
  492. CG_CLASS * Clone()
  493. {
  494. return new CG_FIXED_ARRAY(*this);
  495. }
  496. //
  497. // TYPEDESC generation routine
  498. //
  499. virtual
  500. CG_STATUS GetTypeDesc(TYPEDESC * &ptd, CCB * pCCB);
  501. virtual
  502. ID_CG GetCGID()
  503. {
  504. return ID_CG_ARRAY;
  505. }
  506. virtual
  507. void Visit( CG_VISITOR *pVisitor )
  508. {
  509. pVisitor->Visit( this );
  510. }
  511. //
  512. // Get and set methods.
  513. //
  514. //
  515. // Generate the format string.
  516. //
  517. void GenNdrFormat( CCB * pCCB );
  518. long FixedBufferSize( CCB * pCCB );
  519. BOOL InterpreterMustFree( CCB * ) { return TRUE; }
  520. unsigned long GetNumOfElements()
  521. {
  522. MIDL_ASSERT( GetSizeIsExpr()->IsConstant() );
  523. return (ulong) GetSizeIsExpr()->GetValue();
  524. }
  525. virtual
  526. BOOL IsFixedArray()
  527. {
  528. return TRUE;
  529. }
  530. virtual
  531. BOOL HasAFixedBufferSize()
  532. {
  533. return TRUE;
  534. }
  535. virtual
  536. expr_node * PresentedSizeExpression( CCB * pCCB );
  537. virtual
  538. expr_node * PresentedLengthExpression( CCB * )
  539. {
  540. return GetSizeIsExpr();
  541. }
  542. virtual
  543. expr_node * PresentedFirstExpression( CCB * )
  544. {
  545. return new expr_constant( 0L );
  546. }
  547. virtual
  548. CG_STATUS MarshallAnalysis( ANALYSIS_INFO * pAna );
  549. virtual
  550. CG_STATUS FollowerMarshallAnalysis( ANALYSIS_INFO * pAna );
  551. };
  552. //
  553. // This class corresponds to a conformant array type.
  554. //
  555. class CG_CONFORMANT_ARRAY : public CG_ARRAY
  556. {
  557. private:
  558. public:
  559. //
  560. // The constructor.
  561. //
  562. CG_CONFORMANT_ARRAY(
  563. node_skl * pBT, // array in typegraph
  564. FIELD_ATTR_INFO * pFA, // attribute data
  565. unsigned short dim, // dimensions
  566. XLAT_SIZE_INFO & Info // wire alignment
  567. ) :
  568. CG_ARRAY( pBT, pFA, dim, Info )
  569. {
  570. }
  571. CG_CONFORMANT_ARRAY(
  572. CG_SIZE_POINTER * pCG // pointer node to clone from
  573. ) :
  574. CG_ARRAY( pCG->GetType(),
  575. &FIELD_ATTR_INFO(),
  576. 1,
  577. XLAT_SIZE_INFO( (CG_NDR *) pCG->GetChild()) )
  578. {
  579. *((CG_NDR *)this) = *((CG_NDR *)pCG);
  580. *((CG_CONF_ATTRIBUTE *)this) = *((CG_CONF_ATTRIBUTE *)pCG);
  581. SetSizesAndAlignments( XLAT_SIZE_INFO( (CG_NDR*) pCG->GetChild() ));
  582. SetIsDupedSizePtr( TRUE );
  583. SetCSUserType( pCG->GetCSUserType() );
  584. }
  585. virtual
  586. CG_CLASS * Clone()
  587. {
  588. return new CG_CONFORMANT_ARRAY(*this);
  589. }
  590. virtual
  591. ID_CG GetCGID()
  592. {
  593. return ID_CG_CONF_ARRAY;
  594. }
  595. virtual
  596. void Visit( CG_VISITOR *pVisitor )
  597. {
  598. pVisitor->Visit( this );
  599. }
  600. //
  601. // TYPEDESC generation routine
  602. //
  603. virtual
  604. CG_STATUS GetTypeDesc(TYPEDESC * &ptd, CCB * pCCB);
  605. //
  606. // Get and set methods.
  607. //
  608. //
  609. // Generate the format string.
  610. //
  611. void GenNdrFormat( CCB * pCCB );
  612. virtual
  613. BOOL NeedsMaxCountMarshall()
  614. {
  615. return TRUE;
  616. }
  617. virtual
  618. expr_node * PresentedSizeExpression( CCB * pCCB );
  619. };
  620. //
  621. // This class corresponds to a varying array type.
  622. //
  623. class CG_VARYING_ARRAY : public CG_ARRAY,
  624. public CG_VARY_ATTRIBUTE
  625. {
  626. private:
  627. protected:
  628. CG_VARYING_ARRAY(
  629. const CG_VARYING_ARRAY & Node ) :
  630. CG_ARRAY( Node ) ,
  631. CG_VARY_ATTRIBUTE( Node )
  632. {
  633. }
  634. public:
  635. //
  636. // The constructor.
  637. //
  638. CG_VARYING_ARRAY(
  639. node_skl * pBT, // array in typegraph
  640. FIELD_ATTR_INFO * pFA, // attribute data
  641. unsigned short dim, // dimensions
  642. XLAT_SIZE_INFO & Info // wire alignment
  643. ) :
  644. CG_ARRAY( pBT, pFA, dim, Info ),
  645. CG_VARY_ATTRIBUTE( pFA )
  646. {
  647. }
  648. virtual
  649. CG_CLASS * Clone()
  650. {
  651. return new CG_VARYING_ARRAY(*this);
  652. }
  653. virtual
  654. ID_CG GetCGID()
  655. {
  656. return ID_CG_VAR_ARRAY;
  657. }
  658. virtual
  659. void Visit( CG_VISITOR *pVisitor )
  660. {
  661. pVisitor->Visit( this );
  662. }
  663. BOOL IsVarying()
  664. {
  665. return TRUE;
  666. }
  667. virtual
  668. BOOL IsFixedArray()
  669. {
  670. return TRUE;
  671. }
  672. //
  673. // Get and set methods.
  674. //
  675. //
  676. // Generate the format string.
  677. //
  678. void GenNdrFormat( CCB * pCCB );
  679. unsigned long GetNumOfElements()
  680. {
  681. MIDL_ASSERT( GetSizeIsExpr()->IsConstant() );
  682. return (ulong) GetSizeIsExpr()->GetValue();
  683. }
  684. virtual
  685. BOOL NeedsFirstAndLengthMarshall()
  686. {
  687. return TRUE;
  688. }
  689. virtual
  690. BOOL NeedsExplicitFirst()
  691. {
  692. return TRUE;
  693. }
  694. virtual
  695. expr_node * PresentedLengthExpression( CCB * pCCB );
  696. virtual
  697. expr_node * PresentedFirstExpression( CCB * pCCB );
  698. virtual
  699. CG_STATUS MarshallAnalysis( ANALYSIS_INFO * pAna );
  700. };
  701. //
  702. // This class corresponds to a conformant varying array type.
  703. //
  704. class CG_CONFORMANT_VARYING_ARRAY : public CG_ARRAY,
  705. public CG_VARY_ATTRIBUTE
  706. {
  707. private:
  708. public:
  709. //
  710. // The constructor.
  711. //
  712. CG_CONFORMANT_VARYING_ARRAY(
  713. node_skl * pBT, // array in typegraph
  714. FIELD_ATTR_INFO * pFA, // attribute data
  715. unsigned short dim, // dimensions
  716. XLAT_SIZE_INFO & Info // wire alignment
  717. ) :
  718. CG_ARRAY( pBT, pFA, dim, Info ),
  719. CG_VARY_ATTRIBUTE( pFA )
  720. {
  721. }
  722. CG_CONFORMANT_VARYING_ARRAY(
  723. CG_SIZE_LENGTH_POINTER * pCG // pointer node to clone from
  724. ) :
  725. //
  726. // We must pass in a null node_skl type so
  727. // that the code generator can identify this
  728. // as a manufactured conformant array.
  729. //
  730. CG_ARRAY( pCG->GetType(),
  731. &FIELD_ATTR_INFO(),
  732. 1,
  733. XLAT_SIZE_INFO( (CG_NDR *) pCG->GetChild()) ),
  734. CG_VARY_ATTRIBUTE( pCG )
  735. {
  736. *((CG_NDR *)this) = *((CG_NDR *)pCG);
  737. *((CG_CONF_ATTRIBUTE *)this) = *((CG_CONF_ATTRIBUTE *)pCG);
  738. SetSizesAndAlignments( XLAT_SIZE_INFO( (CG_NDR*) pCG->GetChild() ));
  739. SetIsDupedSizePtr( TRUE );
  740. SetCSUserType( pCG->GetCSUserType() );
  741. }
  742. virtual
  743. CG_CLASS * Clone()
  744. {
  745. return new CG_CONFORMANT_VARYING_ARRAY(*this);
  746. }
  747. virtual
  748. ID_CG GetCGID()
  749. {
  750. return ID_CG_CONF_VAR_ARRAY;
  751. }
  752. virtual
  753. void Visit( CG_VISITOR *pVisitor )
  754. {
  755. pVisitor->Visit( this );
  756. }
  757. //
  758. // Get and set methods.
  759. //
  760. //
  761. // Generate the format string.
  762. //
  763. void GenNdrFormat( CCB * pCCB );
  764. virtual
  765. BOOL NeedsMaxCountMarshall()
  766. {
  767. return TRUE;
  768. }
  769. virtual
  770. BOOL NeedsFirstAndLengthMarshall()
  771. {
  772. return TRUE;
  773. }
  774. virtual
  775. BOOL NeedsExplicitFirst()
  776. {
  777. return TRUE;
  778. }
  779. virtual
  780. expr_node * PresentedSizeExpression( CCB * pCCB );
  781. virtual
  782. expr_node * PresentedLengthExpression( CCB * pCCB );
  783. virtual
  784. expr_node * PresentedFirstExpression( CCB * pCCB );
  785. };
  786. //
  787. // This class corresponds to a string array type.
  788. //
  789. class CG_STRING_ARRAY : public CG_ARRAY
  790. {
  791. private:
  792. protected:
  793. CG_STRING_ARRAY(
  794. const CG_STRING_ARRAY & Node ) :
  795. CG_ARRAY( Node )
  796. {
  797. }
  798. public:
  799. //
  800. // The constructor.
  801. //
  802. CG_STRING_ARRAY(
  803. node_skl * pBT, // array in typegraph
  804. FIELD_ATTR_INFO * pFA, // attribute data
  805. unsigned short dim, // dimensions
  806. XLAT_SIZE_INFO & Info // wire alignment
  807. ) :
  808. CG_ARRAY( pBT, pFA, dim, Info )
  809. {
  810. }
  811. virtual
  812. CG_CLASS * Clone()
  813. {
  814. return new CG_STRING_ARRAY(*this);
  815. }
  816. virtual
  817. ID_CG GetCGID()
  818. {
  819. return ID_CG_STRING_ARRAY;
  820. }
  821. virtual
  822. void Visit( CG_VISITOR *pVisitor )
  823. {
  824. pVisitor->Visit( this );
  825. }
  826. BOOL IsVarying()
  827. {
  828. return TRUE;
  829. }
  830. virtual
  831. BOOL IsFixed()
  832. {
  833. return TRUE;
  834. }
  835. BOOL IsStringableStruct()
  836. {
  837. CG_NDR * pChild = (CG_NDR *) GetChild();
  838. return (pChild->GetCGID() != ID_CG_BT);
  839. }
  840. //
  841. //
  842. // Get and set methods.
  843. //
  844. //
  845. // Generate the format string.
  846. //
  847. void GenNdrFormat( CCB * pCCB );
  848. virtual
  849. expr_node * PresentedSizeExpression( CCB * pCCB );
  850. virtual
  851. CG_STATUS MarshallAnalysis( ANALYSIS_INFO * pAna );
  852. };
  853. //
  854. // This class corresponds to a conformant varying array type.
  855. //
  856. class CG_CONFORMANT_STRING_ARRAY : public CG_ARRAY
  857. {
  858. private:
  859. public:
  860. //
  861. // The constructor.
  862. //
  863. CG_CONFORMANT_STRING_ARRAY(
  864. node_skl * pBT, // array in typegraph
  865. FIELD_ATTR_INFO * pFA, // attribute data
  866. unsigned short dim, // dimensions
  867. XLAT_SIZE_INFO & Info // wire alignment
  868. ) :
  869. CG_ARRAY( pBT, pFA, dim, Info )
  870. {
  871. }
  872. virtual
  873. CG_CLASS * Clone()
  874. {
  875. return new CG_CONFORMANT_STRING_ARRAY(*this);
  876. }
  877. virtual
  878. ID_CG GetCGID()
  879. {
  880. return ID_CG_CONF_STRING_ARRAY;
  881. }
  882. virtual
  883. void Visit( CG_VISITOR *pVisitor )
  884. {
  885. pVisitor->Visit( this );
  886. }
  887. BOOL IsStringableStruct()
  888. {
  889. CG_NDR * pChild = (CG_NDR *) GetChild();
  890. return (pChild->GetCGID() != ID_CG_BT);
  891. }
  892. BOOL IsComplex()
  893. {
  894. return IsStringableStruct();
  895. }
  896. //
  897. // Get and set methods.
  898. //
  899. //
  900. // Generate the format string.
  901. //
  902. void GenNdrFormat( CCB * pCCB );
  903. virtual
  904. expr_node * PresentedSizeExpression( CCB * pCCB );
  905. };
  906. //
  907. // New 64bit NDR arrays types
  908. //
  909. #define DECLARE_COMPLEX_ARRAY_CG_CLASS( NEWTYPE, BASETYPE ) \
  910. class NEWTYPE : public BASETYPE \
  911. { \
  912. protected: \
  913. NEWTYPE( const NEWTYPE & Node ) : \
  914. BASETYPE( Node ) {} \
  915. public: \
  916. NEWTYPE( node_skl *pType, \
  917. FIELD_ATTR_INFO * pFA, \
  918. unsigned short dim, \
  919. XLAT_SIZE_INFO & Info ) : \
  920. BASETYPE( pType, \
  921. pFA, \
  922. dim, \
  923. Info ) \
  924. { \
  925. ForceComplex(); \
  926. } \
  927. virtual CG_CLASS* Clone() { return new NEWTYPE(*this); } \
  928. virtual void Visit( CG_VISITOR *pVisitor ) { pVisitor->Visit( this ); } \
  929. }; \
  930. // Fixed arrays
  931. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_COMPLEX_FIXED_ARRAY, CG_FIXED_ARRAY )
  932. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_FORCED_COMPLEX_FIXED_ARRAY, CG_COMPLEX_FIXED_ARRAY )
  933. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_FULL_COMPLEX_FIXED_ARRAY, CG_COMPLEX_FIXED_ARRAY )
  934. // Conformant arrays
  935. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_COMPLEX_CONFORMANT_ARRAY, CG_CONFORMANT_ARRAY )
  936. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_FORCED_COMPLEX_CONFORMANT_ARRAY, CG_COMPLEX_CONFORMANT_ARRAY )
  937. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_FULL_COMPLEX_CONFORMANT_ARRAY, CG_COMPLEX_CONFORMANT_ARRAY )
  938. // Varying arrays
  939. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_COMPLEX_VARYING_ARRAY, CG_VARYING_ARRAY )
  940. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_FORCED_COMPLEX_VARYING_ARRAY, CG_COMPLEX_VARYING_ARRAY )
  941. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_FULL_COMPLEX_VARYING_ARRAY, CG_COMPLEX_VARYING_ARRAY )
  942. // conformant varying arrays
  943. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_COMPLEX_CONFORMANT_VARYING_ARRAY, CG_CONFORMANT_VARYING_ARRAY )
  944. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_FORCED_COMPLEX_CONFORMANT_VARYING_ARRAY, CG_COMPLEX_CONFORMANT_VARYING_ARRAY )
  945. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_FULL_COMPLEX_CONFORMANT_VARYING_ARRAY, CG_COMPLEX_CONFORMANT_VARYING_ARRAY )
  946. #endif // __ARRAYCLS_HXX__