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.

1194 lines
40 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. virtual
  552. bool IsHomogeneous(FORMAT_CHARACTER format)
  553. {
  554. if ( ((CG_NDR *)GetChild())->IsSimpleType() )
  555. {
  556. MIDL_ASSERT( dynamic_cast<CG_BASETYPE *>(GetChild() ) );
  557. return ((CG_BASETYPE *)GetChild())->IsHomogeneous(format);
  558. }
  559. return FALSE;
  560. }
  561. };
  562. //
  563. // This class corresponds to a conformant array type.
  564. //
  565. class CG_CONFORMANT_ARRAY : public CG_ARRAY
  566. {
  567. private:
  568. public:
  569. //
  570. // The constructor.
  571. //
  572. CG_CONFORMANT_ARRAY(
  573. node_skl * pBT, // array in typegraph
  574. FIELD_ATTR_INFO * pFA, // attribute data
  575. unsigned short dim, // dimensions
  576. XLAT_SIZE_INFO & Info // wire alignment
  577. ) :
  578. CG_ARRAY( pBT, pFA, dim, Info )
  579. {
  580. }
  581. CG_CONFORMANT_ARRAY(
  582. CG_SIZE_POINTER * pCG // pointer node to clone from
  583. ) :
  584. CG_ARRAY( pCG->GetType(),
  585. &FIELD_ATTR_INFO(),
  586. 1,
  587. XLAT_SIZE_INFO( (CG_NDR *) pCG->GetChild()) )
  588. {
  589. *((CG_NDR *)this) = *((CG_NDR *)pCG);
  590. *((CG_CONF_ATTRIBUTE *)this) = *((CG_CONF_ATTRIBUTE *)pCG);
  591. SetSizesAndAlignments( XLAT_SIZE_INFO( (CG_NDR*) pCG->GetChild() ));
  592. SetIsDupedSizePtr( TRUE );
  593. SetCSUserType( pCG->GetCSUserType() );
  594. }
  595. virtual
  596. CG_CLASS * Clone()
  597. {
  598. return new CG_CONFORMANT_ARRAY(*this);
  599. }
  600. virtual
  601. ID_CG GetCGID()
  602. {
  603. return ID_CG_CONF_ARRAY;
  604. }
  605. virtual
  606. void Visit( CG_VISITOR *pVisitor )
  607. {
  608. pVisitor->Visit( this );
  609. }
  610. //
  611. // TYPEDESC generation routine
  612. //
  613. virtual
  614. CG_STATUS GetTypeDesc(TYPEDESC * &ptd, CCB * pCCB);
  615. //
  616. // Get and set methods.
  617. //
  618. //
  619. // Generate the format string.
  620. //
  621. void GenNdrFormat( CCB * pCCB );
  622. virtual
  623. BOOL NeedsMaxCountMarshall()
  624. {
  625. return TRUE;
  626. }
  627. virtual
  628. expr_node * PresentedSizeExpression( CCB * pCCB );
  629. };
  630. //
  631. // This class corresponds to a varying array type.
  632. //
  633. class CG_VARYING_ARRAY : public CG_ARRAY,
  634. public CG_VARY_ATTRIBUTE
  635. {
  636. private:
  637. protected:
  638. CG_VARYING_ARRAY(
  639. const CG_VARYING_ARRAY & Node ) :
  640. CG_ARRAY( Node ) ,
  641. CG_VARY_ATTRIBUTE( Node )
  642. {
  643. }
  644. public:
  645. //
  646. // The constructor.
  647. //
  648. CG_VARYING_ARRAY(
  649. node_skl * pBT, // array in typegraph
  650. FIELD_ATTR_INFO * pFA, // attribute data
  651. unsigned short dim, // dimensions
  652. XLAT_SIZE_INFO & Info // wire alignment
  653. ) :
  654. CG_ARRAY( pBT, pFA, dim, Info ),
  655. CG_VARY_ATTRIBUTE( pFA )
  656. {
  657. }
  658. virtual
  659. CG_CLASS * Clone()
  660. {
  661. return new CG_VARYING_ARRAY(*this);
  662. }
  663. virtual
  664. ID_CG GetCGID()
  665. {
  666. return ID_CG_VAR_ARRAY;
  667. }
  668. virtual
  669. void Visit( CG_VISITOR *pVisitor )
  670. {
  671. pVisitor->Visit( this );
  672. }
  673. BOOL IsVarying()
  674. {
  675. return TRUE;
  676. }
  677. virtual
  678. BOOL IsFixedArray()
  679. {
  680. return TRUE;
  681. }
  682. //
  683. // Get and set methods.
  684. //
  685. //
  686. // Generate the format string.
  687. //
  688. void GenNdrFormat( CCB * pCCB );
  689. unsigned long GetNumOfElements()
  690. {
  691. MIDL_ASSERT( GetSizeIsExpr()->IsConstant() );
  692. return (ulong) GetSizeIsExpr()->GetValue();
  693. }
  694. virtual
  695. BOOL NeedsFirstAndLengthMarshall()
  696. {
  697. return TRUE;
  698. }
  699. virtual
  700. BOOL NeedsExplicitFirst()
  701. {
  702. return TRUE;
  703. }
  704. virtual
  705. expr_node * PresentedLengthExpression( CCB * pCCB );
  706. virtual
  707. expr_node * PresentedFirstExpression( CCB * pCCB );
  708. virtual
  709. CG_STATUS MarshallAnalysis( ANALYSIS_INFO * pAna );
  710. };
  711. //
  712. // This class corresponds to a conformant varying array type.
  713. //
  714. class CG_CONFORMANT_VARYING_ARRAY : public CG_ARRAY,
  715. public CG_VARY_ATTRIBUTE
  716. {
  717. private:
  718. public:
  719. //
  720. // The constructor.
  721. //
  722. CG_CONFORMANT_VARYING_ARRAY(
  723. node_skl * pBT, // array in typegraph
  724. FIELD_ATTR_INFO * pFA, // attribute data
  725. unsigned short dim, // dimensions
  726. XLAT_SIZE_INFO & Info // wire alignment
  727. ) :
  728. CG_ARRAY( pBT, pFA, dim, Info ),
  729. CG_VARY_ATTRIBUTE( pFA )
  730. {
  731. }
  732. CG_CONFORMANT_VARYING_ARRAY(
  733. CG_SIZE_LENGTH_POINTER * pCG // pointer node to clone from
  734. ) :
  735. //
  736. // We must pass in a null node_skl type so
  737. // that the code generator can identify this
  738. // as a manufactured conformant array.
  739. //
  740. CG_ARRAY( pCG->GetType(),
  741. &FIELD_ATTR_INFO(),
  742. 1,
  743. XLAT_SIZE_INFO( (CG_NDR *) pCG->GetChild()) ),
  744. CG_VARY_ATTRIBUTE( pCG )
  745. {
  746. *((CG_NDR *)this) = *((CG_NDR *)pCG);
  747. *((CG_CONF_ATTRIBUTE *)this) = *((CG_CONF_ATTRIBUTE *)pCG);
  748. SetSizesAndAlignments( XLAT_SIZE_INFO( (CG_NDR*) pCG->GetChild() ));
  749. SetIsDupedSizePtr( TRUE );
  750. SetCSUserType( pCG->GetCSUserType() );
  751. }
  752. virtual
  753. CG_CLASS * Clone()
  754. {
  755. return new CG_CONFORMANT_VARYING_ARRAY(*this);
  756. }
  757. virtual
  758. ID_CG GetCGID()
  759. {
  760. return ID_CG_CONF_VAR_ARRAY;
  761. }
  762. virtual
  763. void Visit( CG_VISITOR *pVisitor )
  764. {
  765. pVisitor->Visit( this );
  766. }
  767. //
  768. // Get and set methods.
  769. //
  770. //
  771. // Generate the format string.
  772. //
  773. void GenNdrFormat( CCB * pCCB );
  774. virtual
  775. BOOL NeedsMaxCountMarshall()
  776. {
  777. return TRUE;
  778. }
  779. virtual
  780. BOOL NeedsFirstAndLengthMarshall()
  781. {
  782. return TRUE;
  783. }
  784. virtual
  785. BOOL NeedsExplicitFirst()
  786. {
  787. return TRUE;
  788. }
  789. virtual
  790. expr_node * PresentedSizeExpression( CCB * pCCB );
  791. virtual
  792. expr_node * PresentedLengthExpression( CCB * pCCB );
  793. virtual
  794. expr_node * PresentedFirstExpression( CCB * pCCB );
  795. };
  796. //
  797. // This class corresponds to a string array type.
  798. //
  799. class CG_STRING_ARRAY : public CG_ARRAY
  800. {
  801. private:
  802. protected:
  803. CG_STRING_ARRAY(
  804. const CG_STRING_ARRAY & Node ) :
  805. CG_ARRAY( Node )
  806. {
  807. }
  808. public:
  809. //
  810. // The constructor.
  811. //
  812. CG_STRING_ARRAY(
  813. node_skl * pBT, // array in typegraph
  814. FIELD_ATTR_INFO * pFA, // attribute data
  815. unsigned short dim, // dimensions
  816. XLAT_SIZE_INFO & Info // wire alignment
  817. ) :
  818. CG_ARRAY( pBT, pFA, dim, Info )
  819. {
  820. }
  821. virtual
  822. CG_CLASS * Clone()
  823. {
  824. return new CG_STRING_ARRAY(*this);
  825. }
  826. virtual
  827. ID_CG GetCGID()
  828. {
  829. return ID_CG_STRING_ARRAY;
  830. }
  831. virtual
  832. void Visit( CG_VISITOR *pVisitor )
  833. {
  834. pVisitor->Visit( this );
  835. }
  836. BOOL IsVarying()
  837. {
  838. return TRUE;
  839. }
  840. virtual
  841. BOOL IsFixed()
  842. {
  843. return TRUE;
  844. }
  845. BOOL IsStringableStruct()
  846. {
  847. CG_NDR * pChild = (CG_NDR *) GetChild();
  848. return (pChild->GetCGID() != ID_CG_BT);
  849. }
  850. //
  851. //
  852. // Get and set methods.
  853. //
  854. //
  855. // Generate the format string.
  856. //
  857. void GenNdrFormat( CCB * pCCB );
  858. virtual
  859. expr_node * PresentedSizeExpression( CCB * pCCB );
  860. virtual
  861. CG_STATUS MarshallAnalysis( ANALYSIS_INFO * pAna );
  862. };
  863. //
  864. // This class corresponds to a conformant varying array type.
  865. //
  866. class CG_CONFORMANT_STRING_ARRAY : public CG_ARRAY
  867. {
  868. private:
  869. public:
  870. //
  871. // The constructor.
  872. //
  873. CG_CONFORMANT_STRING_ARRAY(
  874. node_skl * pBT, // array in typegraph
  875. FIELD_ATTR_INFO * pFA, // attribute data
  876. unsigned short dim, // dimensions
  877. XLAT_SIZE_INFO & Info // wire alignment
  878. ) :
  879. CG_ARRAY( pBT, pFA, dim, Info )
  880. {
  881. }
  882. virtual
  883. CG_CLASS * Clone()
  884. {
  885. return new CG_CONFORMANT_STRING_ARRAY(*this);
  886. }
  887. virtual
  888. ID_CG GetCGID()
  889. {
  890. return ID_CG_CONF_STRING_ARRAY;
  891. }
  892. virtual
  893. void Visit( CG_VISITOR *pVisitor )
  894. {
  895. pVisitor->Visit( this );
  896. }
  897. BOOL IsStringableStruct()
  898. {
  899. CG_NDR * pChild = (CG_NDR *) GetChild();
  900. return (pChild->GetCGID() != ID_CG_BT);
  901. }
  902. BOOL IsComplex()
  903. {
  904. return IsStringableStruct();
  905. }
  906. //
  907. // Get and set methods.
  908. //
  909. //
  910. // Generate the format string.
  911. //
  912. void GenNdrFormat( CCB * pCCB );
  913. virtual
  914. expr_node * PresentedSizeExpression( CCB * pCCB );
  915. };
  916. //
  917. // New 64bit NDR arrays types
  918. //
  919. #define DECLARE_COMPLEX_ARRAY_CG_CLASS( NEWTYPE, BASETYPE ) \
  920. class NEWTYPE : public BASETYPE \
  921. { \
  922. protected: \
  923. NEWTYPE( const NEWTYPE & Node ) : \
  924. BASETYPE( Node ) {} \
  925. public: \
  926. NEWTYPE( node_skl *pType, \
  927. FIELD_ATTR_INFO * pFA, \
  928. unsigned short dim, \
  929. XLAT_SIZE_INFO & Info ) : \
  930. BASETYPE( pType, \
  931. pFA, \
  932. dim, \
  933. Info ) \
  934. { \
  935. ForceComplex(); \
  936. } \
  937. virtual CG_CLASS* Clone() { return new NEWTYPE(*this); } \
  938. virtual void Visit( CG_VISITOR *pVisitor ) { pVisitor->Visit( this ); } \
  939. }; \
  940. // Fixed arrays
  941. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_COMPLEX_FIXED_ARRAY, CG_FIXED_ARRAY )
  942. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_FORCED_COMPLEX_FIXED_ARRAY, CG_COMPLEX_FIXED_ARRAY )
  943. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_FULL_COMPLEX_FIXED_ARRAY, CG_COMPLEX_FIXED_ARRAY )
  944. // Conformant arrays
  945. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_COMPLEX_CONFORMANT_ARRAY, CG_CONFORMANT_ARRAY )
  946. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_FORCED_COMPLEX_CONFORMANT_ARRAY, CG_COMPLEX_CONFORMANT_ARRAY )
  947. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_FULL_COMPLEX_CONFORMANT_ARRAY, CG_COMPLEX_CONFORMANT_ARRAY )
  948. // Varying arrays
  949. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_COMPLEX_VARYING_ARRAY, CG_VARYING_ARRAY )
  950. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_FORCED_COMPLEX_VARYING_ARRAY, CG_COMPLEX_VARYING_ARRAY )
  951. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_FULL_COMPLEX_VARYING_ARRAY, CG_COMPLEX_VARYING_ARRAY )
  952. // conformant varying arrays
  953. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_COMPLEX_CONFORMANT_VARYING_ARRAY, CG_CONFORMANT_VARYING_ARRAY )
  954. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_FORCED_COMPLEX_CONFORMANT_VARYING_ARRAY, CG_COMPLEX_CONFORMANT_VARYING_ARRAY )
  955. DECLARE_COMPLEX_ARRAY_CG_CLASS( CG_FULL_COMPLEX_CONFORMANT_VARYING_ARRAY, CG_COMPLEX_CONFORMANT_VARYING_ARRAY )
  956. #endif // __ARRAYCLS_HXX__