Windows NT 4.0 source code leak
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.

2227 lines
51 KiB

4 years ago
  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. proccls.hxx
  5. Abstract:
  6. Contains definitions for procedure related code gen class definitions.
  7. Notes:
  8. History:
  9. VibhasC Jul-29-1993 Created.
  10. ----------------------------------------------------------------------------*/
  11. #ifndef __PROCCLS_HXX__
  12. #define __PROCCLS_HXX__
  13. #include "nulldefs.h"
  14. extern "C"
  15. {
  16. #include <stdio.h>
  17. #include <assert.h>
  18. }
  19. #include "ndrcls.hxx"
  20. #include "bindcls.hxx"
  21. #include "sdesc.hxx"
  22. class CG_PARAM;
  23. class CG_RETURN;
  24. class CG_ENCODE_PROC;
  25. class CG_TYPE_ENCODE_PROC;
  26. class CG_INTERFACE;
  27. /////////////////////////////////////////////////////////////////////////////
  28. // the procedure code generation class.
  29. /////////////////////////////////////////////////////////////////////////////
  30. //
  31. // This structure stores information corresponding to the procedure class
  32. // after analysis has been performed. This structure is specific to the proc
  33. // code generation class.
  34. //
  35. typedef struct
  36. {
  37. //
  38. // This field indicates the rpc buffer size property.
  39. //
  40. RPC_BUF_SIZE_PROPERTY fRpcBufSize : 3;
  41. //
  42. // This field indicates the rpc buffer size. If the buffer size property
  43. // was BSIZE_FIXED, then this is the exact number of bytes needed for the
  44. // rpc buffer. If the property is BSIZE_UPPER_BOUND, then this is the worst
  45. // case size of the rpc buffer needed. If this property is BSIZE_UNKNOWN
  46. // then the value of this field is the fixed part of the rpc buffer size
  47. // that can be determined at compile time.
  48. //
  49. RPC_BUFFER_SIZE RpcBufferSize;
  50. } PROC_OP_INFO;
  51. enum PROCKIND {
  52. PROC_VIRTUAL,
  53. PROC_PUREVIRTUAL,
  54. PROC_NONVIRTUAL,
  55. PROC_STATIC,
  56. PROC_DISPATCH,
  57. };
  58. //
  59. // This class corresponds to a procedure specified for remoting. This class
  60. // is responsible for gathering all the information relating to code gen for
  61. // a procedure and generating code for it. There are 2 kinds of procedures
  62. // known to mankind. Call and callback procedures. This class provides the
  63. // basis for both those procedure types. Most of the functionality of the
  64. // call and callback procedures is the same. The main difference is the side
  65. // that the code will be generated in.
  66. //
  67. class CG_PROC : public CG_NDR
  68. {
  69. private:
  70. //
  71. // Flags storing information about in and out params. The fHasShippedParam
  72. // field specifies that at least one param exists that is shipped. This
  73. // is different from fHasIn, because the proc may have an [in] handle_t
  74. // param which does not get shipped, so no buffer allocation for that is
  75. // necessary, yet such a param must be generated and initialized in the
  76. // server stub.
  77. //
  78. unsigned long fHasIn : 1;
  79. unsigned long fHasOut : 1;
  80. unsigned long fHasShippedParam : 1;
  81. unsigned long fHasStatuses : 1;
  82. unsigned long fNoCode : 1;
  83. unsigned long fOutLocalAnalysisDone : 1;
  84. unsigned long fHasFullPtr : 1;
  85. unsigned long fHasNotify : 1;
  86. unsigned long fHasNotifyFlag : 1;
  87. unsigned long fRpcSSSpecified : 1;
  88. unsigned long fMustRpcSSAllocate : 1;
  89. unsigned long fReturnsHRESULT : 1;
  90. unsigned long fHasPipes : 1;
  91. unsigned long fHookOleLocal : 1;
  92. unsigned long fSupressHeader : 1;
  93. //
  94. // This is used by type info generation to determine what the FUNKIND should be
  95. //
  96. unsigned uProckind;
  97. //
  98. // This field specifies the usage of the handle. This information really
  99. // needs to be kept only with the cg_proc since the proc is entity
  100. // responsible for the binding.
  101. //
  102. HANDLE_USAGE HandleUsage : 1;
  103. //
  104. // This is the optimisation information for all phases of the code
  105. // generator. The assumption is that code generation will be performed
  106. // immediately after the analysis, so there is no need for per phase
  107. // information.
  108. //
  109. PROC_OP_INFO OptimInfo[ CGPHASE_COUNT ];
  110. //
  111. // This field keeps track of the binding handle. Refer to the binding
  112. // handle class definition for more info on how it is used.
  113. // If the handle is explicit, then this is a pointer to a cg class which
  114. // will be part of the param list anyhow. If the handle is implicit, then
  115. // this is a pointer to a separately allocated binding handle class.
  116. // Also, this field is used in conjunction with the HandleUsage field,
  117. // which specifies the usage of the binding: explicit or implicit.
  118. CG_HANDLE * pHDLClass;
  119. //
  120. // This field specifies the usage of the handle. This information really
  121. // needs to be kept only with the cg_proc since the proc is entity
  122. // responsible for the binding.
  123. //
  124. CG_PARAM * pHandleUsage;
  125. //
  126. // This field specifies the procedure number. The proc num is the lexical
  127. // sequence number of the proc specified in the idl file, not counting the
  128. // callback procedures which have their own lexical sequence. This field
  129. // is an unsigned int to match the declaration in the rpc message.
  130. //
  131. unsigned int ProcNum;
  132. //
  133. // This field specifies the return type.
  134. // This is NULL if there is no return type. Otherwise, it points to a
  135. // CG_RETURN node which in turn points to the CG nodes for the return
  136. // type.
  137. //
  138. CG_RETURN * pReturn;
  139. // the optimization flags to use for this procedure
  140. OPTIM_OPTION OptimizationFlags;
  141. // The generated size expression generated out of the sizing pass of the
  142. // code generator.
  143. expr_node * pSizeExpr;
  144. RESOURCE * pBindingResource;
  145. RESOURCE * pStatusResource;
  146. // The stub descriptor for the procedure.
  147. SDESC * pSStubDescriptor;
  148. SDESC * pCStubDescriptor;
  149. long FormatStringParamStart;
  150. // the operation flags such as BROADCAST, IDEMPOTENT, etc in internal format
  151. unsigned int OperationBits;
  152. // the call_as name, if any
  153. char * pCallAsName;
  154. // pointer to MY interface node
  155. CG_INTERFACE * pMyInterfaceCG;
  156. short ContextHandleCount;
  157. FORMAT_STRING * pSavedFormatString;
  158. FORMAT_STRING * pSavedProcFormatString;
  159. short cRefSaved;
  160. CG_PROC * pCallAsType;
  161. public:
  162. //
  163. // The constructor.
  164. //
  165. CG_PROC(
  166. unsigned int ProcNum,
  167. node_skl * pProc,
  168. CG_HANDLE * pBH,
  169. CG_PARAM * pHU,
  170. BOOL fAtLeastOneIn,
  171. BOOL fAtLeastOneOut,
  172. BOOL fAtLeastOneShipped,
  173. BOOL fHasStatuses,
  174. BOOL fHasFullPtr,
  175. CG_RETURN * pReturn,
  176. OPTIM_OPTION OptimFlags,
  177. unsigned short OpBits );
  178. virtual
  179. unsigned GetProckind()
  180. {
  181. return uProckind;
  182. }
  183. virtual
  184. unsigned SetProckind(unsigned uKind)
  185. {
  186. return (uProckind = uKind);
  187. }
  188. CG_PROC * SetCallAsCG(CG_PROC * p)
  189. {
  190. return (pCallAsType = p);
  191. }
  192. CG_PROC * GetCallAsCG()
  193. {
  194. return (pCallAsType);
  195. }
  196. //
  197. // Generate typeinfo
  198. //
  199. virtual
  200. CG_STATUS GenTypeInfo( CCB * pCCB);
  201. void SetRpcSSSpecified( unsigned long f )
  202. {
  203. fRpcSSSpecified = f;
  204. }
  205. BOOL IsRpcSSSpecified()
  206. {
  207. return (BOOL)( fRpcSSSpecified == 1 );
  208. }
  209. void SetMustInvokeRpcSSAllocate( unsigned long f )
  210. {
  211. fMustRpcSSAllocate = f;
  212. }
  213. BOOL MustInvokeRpcSSAllocate()
  214. {
  215. return (BOOL)fMustRpcSSAllocate;
  216. }
  217. void SetOutLocalAnalysisDone()
  218. {
  219. fOutLocalAnalysisDone = 1;
  220. }
  221. BOOL IsOutLocalAnalysisDone()
  222. {
  223. return (BOOL)( fOutLocalAnalysisDone == 1);
  224. }
  225. RESOURCE * SetStatusResource( RESOURCE * pR )
  226. {
  227. return (pStatusResource = pR);
  228. }
  229. RESOURCE * GetStatusResource()
  230. {
  231. return pStatusResource;
  232. }
  233. RESOURCE * SetBindingResource( RESOURCE * pR )
  234. {
  235. return (pBindingResource = pR);
  236. }
  237. RESOURCE * GetBindingResource()
  238. {
  239. return pBindingResource;
  240. }
  241. SDESC * SetSStubDescriptor( SDESC * pSD )
  242. {
  243. return (pSStubDescriptor = pSD );
  244. }
  245. SDESC * GetSStubDescriptor()
  246. {
  247. return pSStubDescriptor;
  248. }
  249. SDESC * SetCStubDescriptor( SDESC * pSD )
  250. {
  251. return (pCStubDescriptor = pSD );
  252. }
  253. SDESC * GetCStubDescriptor()
  254. {
  255. return pCStubDescriptor;
  256. }
  257. OPTIM_OPTION SetOptimizationFlags( OPTIM_OPTION Opt )
  258. {
  259. return (OptimizationFlags = Opt );
  260. }
  261. OPTIM_OPTION GetOptimizationFlags()
  262. {
  263. return OptimizationFlags;
  264. }
  265. unsigned int SetOperationBits( unsigned int OpBits )
  266. {
  267. return (OperationBits = OpBits );
  268. }
  269. unsigned int GetOperationBits()
  270. {
  271. return OperationBits;
  272. }
  273. void GetCommAndFaultOffset( CCB * pCCB,
  274. long CommOffset[5],
  275. long FaultOffset[5] );
  276. void SetNoCode()
  277. {
  278. fNoCode = TRUE;
  279. }
  280. BOOL IsNoCode()
  281. {
  282. return fNoCode;
  283. }
  284. void SetHasNotify()
  285. {
  286. fHasNotify = TRUE;
  287. }
  288. void SetHasNotifyFlag()
  289. {
  290. fHasNotifyFlag = TRUE;
  291. }
  292. BOOL HasNotify()
  293. {
  294. return fHasNotify;
  295. }
  296. BOOL HasNotifyFlag()
  297. {
  298. return fHasNotifyFlag;
  299. }
  300. void SetReturnsHRESULT()
  301. {
  302. fReturnsHRESULT = TRUE;
  303. }
  304. BOOL ReturnsHRESULT()
  305. {
  306. return fReturnsHRESULT;
  307. }
  308. virtual
  309. CG_STATUS Pass1( ANALYSIS_INFO *pAna )
  310. {
  311. UNUSED( pAna );
  312. return CG_OK;
  313. }
  314. virtual
  315. ID_CG GetCGID()
  316. {
  317. return ID_CG_PROC;
  318. }
  319. virtual
  320. BOOL IsProc()
  321. {
  322. return TRUE;
  323. }
  324. virtual
  325. BOOL IsInherited()
  326. {
  327. return FALSE;
  328. }
  329. virtual
  330. BOOL IsDelegated()
  331. {
  332. return FALSE;
  333. }
  334. //
  335. // Get and set methods.
  336. //
  337. void SetFormatStringParamStart( long Offset )
  338. {
  339. FormatStringParamStart = Offset;
  340. }
  341. long GetFormatStringParamStart()
  342. {
  343. return FormatStringParamStart;
  344. }
  345. expr_node * SetSizeExpression( expr_node * pE )
  346. {
  347. return ( pSizeExpr = pE );
  348. }
  349. expr_node * GetSizeExpression()
  350. {
  351. return pSizeExpr;
  352. }
  353. unsigned int SetProcNum( unsigned int ProcNumber )
  354. {
  355. return (ProcNum = ProcNumber);
  356. }
  357. virtual
  358. unsigned int GetProcNum()
  359. {
  360. return ProcNum;
  361. }
  362. void SetContextHandleCount( short c )
  363. {
  364. ContextHandleCount = c;
  365. }
  366. short GetContextHandleCount()
  367. {
  368. return ContextHandleCount;
  369. }
  370. RPC_BUF_SIZE_PROPERTY SetRpcBufSizeProperty(
  371. RPC_BUF_SIZE_PROPERTY Prop,
  372. CGPHASE Phase )
  373. {
  374. return (OptimInfo[ Phase ].fRpcBufSize = Prop);
  375. }
  376. RPC_BUF_SIZE_PROPERTY GetRpcBufSizeProperty( CGPHASE Phase )
  377. {
  378. return OptimInfo[ Phase ].fRpcBufSize;
  379. }
  380. RPC_BUFFER_SIZE SetRpcBufferSize( RPC_BUFFER_SIZE Size,
  381. CGPHASE Phase
  382. )
  383. {
  384. return (OptimInfo[ Phase ].RpcBufferSize = Size);
  385. }
  386. RPC_BUFFER_SIZE GetRpcBufferSize( CGPHASE Phase )
  387. {
  388. return OptimInfo[ Phase ].RpcBufferSize;
  389. }
  390. CG_HANDLE * SetHandleClassPtr( CG_HANDLE * pHC )
  391. {
  392. return (pHDLClass = pHC);
  393. }
  394. CG_HANDLE * GetHandleClassPtr()
  395. {
  396. return pHDLClass;
  397. }
  398. CG_PARAM * SetHandleUsagePtr( CG_PARAM * pHU )
  399. {
  400. return (pHandleUsage = pHU);
  401. }
  402. CG_PARAM * GetHandleUsagePtr()
  403. {
  404. return pHandleUsage;
  405. }
  406. HANDLE_USAGE GetHandleUsage()
  407. {
  408. return (pHandleUsage)
  409. ? HU_EXPLICIT
  410. : HU_IMPLICIT;
  411. }
  412. CG_RETURN * SetReturnType( CG_RETURN * pRT )
  413. {
  414. return (pReturn = pRT);
  415. }
  416. CG_RETURN * GetReturnType()
  417. {
  418. return pReturn;
  419. }
  420. CG_INTERFACE * SetInterfaceNode( CG_INTERFACE * pIntf )
  421. {
  422. return (pMyInterfaceCG = pIntf);
  423. }
  424. CG_INTERFACE * GetInterfaceNode()
  425. {
  426. return pMyInterfaceCG;
  427. }
  428. char * GetInterfaceName();
  429. char * SetCallAsName( char * pName );
  430. char * GetCallAsName()
  431. {
  432. return pCallAsName;
  433. }
  434. char * GenMangledCallAsName( CCB * pCCB )
  435. {
  436. char * pName = new char[62];
  437. strcpy( pName, pCCB->GetInterfaceName() );
  438. strcat( pName, pCCB->GenMangledName() );
  439. strcat( pName, "_" );
  440. strcat( pName, pCallAsName );
  441. return pName;
  442. }
  443. void SetHasAtLeastOneShipped()
  444. {
  445. fHasShippedParam = 1;
  446. }
  447. void ResetHasAtLeastOneShipped()
  448. {
  449. fHasShippedParam = 0;
  450. }
  451. void SetHasAtLeastOneIn()
  452. {
  453. fHasIn = 1;
  454. }
  455. void SetHasAtLeastOneOut()
  456. {
  457. fHasOut = 1;
  458. }
  459. void ResetHasAtLeastOneIn()
  460. {
  461. fHasIn = 0;
  462. }
  463. void ResetHasAtLeastOneOut()
  464. {
  465. fHasOut = 0;
  466. }
  467. BOOL HasAtLeastOneShipped()
  468. {
  469. return (BOOL)(fHasShippedParam == 1);
  470. }
  471. BOOL HasAtLeastOneIn()
  472. {
  473. return (BOOL)(fHasIn == 1);
  474. }
  475. BOOL HasAtLeastOneOut()
  476. {
  477. return (BOOL)(fHasOut == 1);
  478. }
  479. BOOL HasPipes()
  480. {
  481. return (BOOL)(fHasPipes == 1);
  482. }
  483. BOOL SetHasPipes(BOOL f);
  484. BOOL IsHookOleLocal()
  485. {
  486. return (BOOL)(1 == fHookOleLocal);
  487. }
  488. BOOL SupressHeader()
  489. {
  490. return (BOOL)(1 == fSupressHeader);
  491. }
  492. void SetHookOleLocal()
  493. {
  494. fHookOleLocal = TRUE;
  495. }
  496. void SetSupressHeader()
  497. {
  498. fSupressHeader = TRUE;
  499. }
  500. virtual
  501. BOOL HasStatuses()
  502. {
  503. return (BOOL)(fHasStatuses);
  504. }
  505. BOOL HasFullPtr()
  506. {
  507. return ( fHasFullPtr );
  508. }
  509. BOOL SetHasFullPtr( BOOL f )
  510. {
  511. return ( fHasFullPtr = f );
  512. }
  513. BOOL HasReturn()
  514. {
  515. return (BOOL)(pReturn != NULL);
  516. }
  517. BOOL HasOuts()
  518. {
  519. return (HasAtLeastOneOut() || HasReturn());
  520. }
  521. BOOL HasInterpreterDeferredFree();
  522. BOOL IsNullCall()
  523. {
  524. return (!HasAtLeastOneIn() &&
  525. !HasAtLeastOneOut()&&
  526. !HasReturn()
  527. );
  528. }
  529. virtual
  530. BOOL HasEncode()
  531. {
  532. return FALSE;
  533. }
  534. virtual
  535. BOOL HasDecode()
  536. {
  537. return FALSE;
  538. }
  539. virtual
  540. BOOL HasAPicklingAttribute()
  541. {
  542. return FALSE;
  543. }
  544. //
  545. // Queries.
  546. //
  547. virtual
  548. BOOL IsAutoHandle()
  549. {
  550. return (GetHandleClassPtr() == 0);
  551. }
  552. virtual
  553. BOOL IsPrimitiveHandle()
  554. {
  555. return (!IsAutoHandle()) && GetHandleClassPtr()->IsPrimitiveHandle();
  556. }
  557. virtual
  558. BOOL IsGenericHandle()
  559. {
  560. return (!IsAutoHandle()) && GetHandleClassPtr()->IsGenericHandle();
  561. }
  562. virtual
  563. BOOL IsContextHandle()
  564. {
  565. return (!IsAutoHandle()) && GetHandleClassPtr()->IsContextHandle();
  566. }
  567. //
  568. // Generate the client and server stubs.
  569. //
  570. virtual
  571. CG_STATUS GenClientStub( CCB * pCCB );
  572. //
  573. // This method does size calculation analysis for the client side
  574. // marshalling.
  575. //
  576. //
  577. // This method performs binding related analysis on the client side.
  578. //
  579. virtual
  580. CG_STATUS C_BindingAnalysis( ANALYSIS_INFO * pAna );
  581. virtual
  582. CG_STATUS RefCheckAnalysis( ANALYSIS_INFO * pAna );
  583. //
  584. // Unmarshalling analysis for the server side.
  585. //
  586. // This pair of methods generates the prolog and epilog for the client
  587. // side marshall.
  588. //
  589. virtual
  590. CG_STATUS C_GenProlog( CCB * pCCB );
  591. virtual
  592. CG_STATUS C_GenBind( CCB * pCCB );
  593. virtual
  594. CG_STATUS GenSizing( CCB * pCCB );
  595. virtual
  596. CG_STATUS GenGetBuffer( CCB * pCCB );
  597. virtual
  598. CG_STATUS S_GenInitMarshall( CCB * pCCB );
  599. virtual
  600. CG_STATUS GenMarshall( CCB * pCCB );
  601. virtual
  602. CG_STATUS C_GenSendReceive( CCB * pCCB );
  603. virtual
  604. CG_STATUS GenUnMarshall( CCB * pCCB );
  605. virtual
  606. CG_STATUS C_GenUnBind( CCB * pCCB );
  607. virtual
  608. CG_STATUS GenFree( CCB * pCCB );
  609. virtual
  610. CG_STATUS C_GenFreeBuffer( CCB * pCCB );
  611. virtual
  612. CG_STATUS GenEpilog( CCB * pCCB );
  613. virtual
  614. CG_STATUS GenServerStub( CCB * pCCB );
  615. virtual
  616. CG_STATUS S_GenInitOutLocals( CCB * pCCB );
  617. virtual
  618. CG_STATUS S_GenInitTopLevelStuff( CCB * pCCB );
  619. virtual
  620. CG_STATUS S_GenProlog( CCB * pCCB );
  621. //
  622. // Format string routines for generating the format string and
  623. // the NDR calls.
  624. //
  625. virtual
  626. void GenNdrFormat( CCB * pCCB );
  627. void GenNdrFormatV1( CCB * pCCB );
  628. void SetupFormatStrings( CCB * pCCB );
  629. void UnsetupFormatStrings( CCB * pCCB );
  630. void GenNdrFormatProcInfo( CCB * pCCB );
  631. //
  632. // This routine generates the code for the "one call" Ndr case on the
  633. // client side.
  634. //
  635. virtual
  636. void GenNdrSingleClientCall( CCB * pCCB );
  637. expr_node * GenCoreNdrSingleClientCall( CCB * pCCB,
  638. int WhichRisc );
  639. //
  640. // This routine generates the code for the "one call" Ndr case on the
  641. // server side. It's actually 3 calls, but who's counting.
  642. //
  643. virtual
  644. void GenNdrSingleServerCall( CCB * pCCB );
  645. //
  646. // Outputs an old style "three call" server stub.
  647. //
  648. void GenNdrOldInterpretedServerStub( CCB * pCCB );
  649. //
  650. // Outputs a thunk stub to call the server routine. Thunk stub is called
  651. // from the interpreter, not the rpc runtime.
  652. //
  653. void GenNdrThunkInterpretedServerStub( CCB * pCCB );
  654. //
  655. // Outputs the locals for interpreted server stubs.
  656. //
  657. void GenNdrInterpretedServerLocals( CCB * pCCB );
  658. //
  659. // Outputs the param struct for interpreted server stubs.
  660. //
  661. void GenNdrInterpreterParamStruct(
  662. CCB * pCCB,
  663. BOOL fForAlpha = FALSE );
  664. //
  665. // Outputs the call to the manager routine for interpreted server stubs.
  666. //
  667. virtual
  668. void GenNdrInterpretedManagerCall( CCB * pCCB );
  669. virtual
  670. CG_STATUS C_XFormToProperFormat( CCB * pCCB )
  671. {
  672. UNUSED( pCCB );
  673. return CG_OK;
  674. }
  675. virtual
  676. CG_STATUS S_XFormToProperFormat( CCB * pCCB )
  677. {
  678. UNUSED( pCCB );
  679. return CG_OK;
  680. }
  681. virtual
  682. CG_STATUS S_GenCallManager( CCB * pCCB );
  683. //
  684. // Queries.
  685. //
  686. BOOL IsSizingCodeNeeded();
  687. BOOL MustUseSingleEngineCall( CCB * pCCB );
  688. BOOL UseOldInterpreterMode( CCB * pCCB );
  689. BOOL NeedsServerThunk( CCB * pCCB,
  690. CGSIDE Side );
  691. //
  692. // miscellaneous methods.
  693. //
  694. // Oi stack size, includes the return type.
  695. void GetTotalStackSize( CCB * pCCB,
  696. long * pSize,
  697. long * pAlphaSize,
  698. long * pMipsSize,
  699. long * pPpcSize,
  700. long * pMacSize );
  701. //
  702. // This method registers pre-allocated stub resources like the params,
  703. // standard local variables etc, with the corresponding resource dictionary
  704. // in the analysis block.
  705. //
  706. void C_PreAllocateResources( ANALYSIS_INFO * );
  707. virtual
  708. void S_PreAllocateResources( ANALYSIS_INFO * );
  709. virtual
  710. expr_node * GenBindOrUnBindExpression( CCB * pCCB, BOOL fBind );
  711. short GetInParamList( ITERATOR& );
  712. short GetOutParamList( ITERATOR& );
  713. CG_PARAM * SearchForBindingParam()
  714. {
  715. return (CG_PARAM *)GetHandleUsagePtr();
  716. }
  717. virtual
  718. CG_STATUS BufferAnalysis( ANALYSIS_INFO * pAna )
  719. {
  720. UNUSED( pAna );
  721. return CG_OK;
  722. }
  723. virtual
  724. CG_STATUS MarshallAnalysis( ANALYSIS_INFO * pAna );
  725. virtual
  726. CG_STATUS SizeAnalysis( ANALYSIS_INFO * pAna )
  727. {
  728. UNUSED( pAna );
  729. return CG_OK;
  730. }
  731. virtual
  732. CG_STATUS UnMarshallAnalysis( ANALYSIS_INFO * pAna );
  733. virtual
  734. CG_STATUS S_OutLocalAnalysis( ANALYSIS_INFO * pAna );
  735. void RpcSsPackageAnalysis( ANALYSIS_INFO * pAna );
  736. CG_STATUS C_GenMapCommAndFaultStatus( CCB * pCCB );
  737. CG_STATUS C_GenMapHRESULT( CCB * pCCB );
  738. CG_STATUS C_GenClearOutParams( CCB * pCCB );
  739. virtual
  740. CG_STATUS GenRefChecks( CCB * pCCB );
  741. virtual
  742. CG_STATUS InLocalAnalysis( ANALYSIS_INFO * pAna );
  743. virtual
  744. CG_STATUS S_GenInitInLocals( CCB * pCCB );
  745. unsigned int TranslateOpBitsIntoUnsignedInt();
  746. void GetCorrectAllocFreeRoutines(
  747. CCB * pCCB,
  748. BOOL fServer,
  749. char ** pAllocRtnName,
  750. char ** pFreeRtnName );
  751. CG_STATUS GenNotify( CCB * pCCB, BOOL fHasFlag );
  752. };
  753. /////////////////////////////////////////////////////////////////////////////
  754. // the callback proc code generation class.
  755. /////////////////////////////////////////////////////////////////////////////
  756. //
  757. // this is derived from the regular proc class
  758. class CG_CALLBACK_PROC: public CG_PROC
  759. {
  760. public:
  761. //
  762. // The constructor. Just call the proc constructor
  763. //
  764. CG_CALLBACK_PROC(
  765. unsigned int ProcNum,
  766. node_skl * pProc,
  767. CG_HANDLE * pBH,
  768. CG_PARAM * pHU,
  769. BOOL fAtLeastOneIn,
  770. BOOL fAtLeastOneOut,
  771. BOOL fAtLeastOneShipped,
  772. BOOL fHasStatuses,
  773. BOOL fHasFullPtr,
  774. CG_RETURN * pRT,
  775. OPTIM_OPTION OptimFlags,
  776. unsigned short OpBits )
  777. : CG_PROC( ProcNum,
  778. pProc,
  779. pBH,
  780. pHU,
  781. fAtLeastOneIn,
  782. fAtLeastOneOut,
  783. fAtLeastOneShipped,
  784. fHasStatuses,
  785. fHasFullPtr,
  786. pRT,
  787. OptimFlags,
  788. OpBits )
  789. {
  790. }
  791. virtual
  792. ID_CG GetCGID()
  793. {
  794. return ID_CG_CALLBACK_PROC;
  795. }
  796. CG_STATUS GenClientStub( CCB * pCCB );
  797. CG_STATUS GenServerStub( CCB * pCCB );
  798. virtual
  799. BOOL IsAutoHandle()
  800. {
  801. return FALSE;
  802. }
  803. virtual
  804. BOOL IsPrimitiveHandle()
  805. {
  806. return FALSE;
  807. }
  808. virtual
  809. BOOL IsGenericHandle()
  810. {
  811. return FALSE;
  812. }
  813. virtual
  814. BOOL IsContextHandle()
  815. {
  816. return FALSE;
  817. }
  818. };
  819. /////////////////////////////////////////////////////////////////////////////
  820. // the object proc code generation classes.
  821. /////////////////////////////////////////////////////////////////////////////
  822. //
  823. // this is derived from the regular proc class
  824. class CG_OBJECT_PROC: public CG_PROC
  825. {
  826. public:
  827. //
  828. // The constructor. Just call the proc constructor
  829. //
  830. CG_OBJECT_PROC(
  831. unsigned int ProcNum,
  832. node_skl * pProc,
  833. CG_HANDLE * pBH,
  834. CG_PARAM * pHU,
  835. BOOL fAtLeastOneIn,
  836. BOOL fAtLeastOneOut,
  837. BOOL fAtLeastOneShipped,
  838. BOOL fHasStatuses,
  839. BOOL fHasFullPtr,
  840. CG_RETURN * pRT,
  841. OPTIM_OPTION OptimFlags,
  842. unsigned short OpBits )
  843. : CG_PROC( ProcNum,
  844. pProc,
  845. pBH,
  846. pHU,
  847. fAtLeastOneIn,
  848. fAtLeastOneOut,
  849. fAtLeastOneShipped,
  850. fHasStatuses,
  851. fHasFullPtr,
  852. pRT,
  853. OptimFlags,
  854. OpBits )
  855. {
  856. }
  857. virtual
  858. ID_CG GetCGID()
  859. {
  860. return ID_CG_OBJECT_PROC;
  861. }
  862. virtual
  863. BOOL IsObject()
  864. {
  865. return TRUE;
  866. }
  867. virtual
  868. BOOL IsLocal()
  869. {
  870. return FALSE;
  871. }
  872. //
  873. // miscellaneous methods.
  874. //
  875. //
  876. // This method registers pre-allocated stub resources like the params,
  877. // standard local variables etc, with the corresponding resource dictionary
  878. // in the analysis block.
  879. //
  880. virtual
  881. CG_STATUS C_GenProlog( CCB * pCCB );
  882. virtual
  883. CG_STATUS C_GenBind( CCB * pCCB );
  884. virtual
  885. CG_STATUS GenGetBuffer( CCB * pCCB );
  886. virtual
  887. CG_STATUS C_GenSendReceive( CCB * pCCB );
  888. virtual
  889. CG_STATUS C_GenFreeBuffer( CCB * pCCB );
  890. virtual
  891. CG_STATUS C_GenUnBind( CCB * pCCB );
  892. virtual
  893. void S_PreAllocateResources( ANALYSIS_INFO * );
  894. virtual
  895. CG_STATUS S_GenProlog( CCB * pCCB );
  896. virtual
  897. CG_STATUS S_GenCallManager( CCB * pCCB );
  898. virtual
  899. CG_STATUS S_GenInitMarshall( CCB * pCCB );
  900. //
  901. // Outputs the call to the manager routine for interpreted server stubs.
  902. //
  903. virtual
  904. void GenNdrInterpretedManagerCall( CCB * pCCB );
  905. CG_STATUS PrintVtableEntry( CCB * pCCB);
  906. void Out_ServerStubProlog( CCB * pCCB,
  907. ITERATOR& LocalsList,
  908. ITERATOR& TransientList );
  909. void Out_ProxyFunctionPrototype(CCB *pCCB, PRTFLAGS F );
  910. void Out_StubFunctionPrototype(CCB *pCCB);
  911. CG_STATUS GenCMacro(CCB * pCCB );
  912. CG_STATUS GenComClassMemberFunction( CCB * pCCB );
  913. CG_STATUS ReGenComClassMemberFunction( CCB * pCCB );
  914. virtual
  915. BOOL IsDelegated()
  916. {
  917. return FALSE;
  918. }
  919. void OutProxyRoutineName( ISTREAM * pStream,
  920. BOOL fForcesDelegation );
  921. void OutStubRoutineName( ISTREAM * pStream );
  922. };
  923. // the class for inherited object procs
  924. class CG_INHERITED_OBJECT_PROC: public CG_OBJECT_PROC
  925. {
  926. public:
  927. //
  928. // The constructor. Just call the proc constructor
  929. //
  930. CG_INHERITED_OBJECT_PROC(
  931. unsigned int ProcNum,
  932. node_skl * pProc,
  933. CG_HANDLE * pBH,
  934. CG_PARAM * pHU,
  935. BOOL fAtLeastOneIn,
  936. BOOL fAtLeastOneOut,
  937. BOOL fAtLeastOneShipped,
  938. BOOL fHasStatuses,
  939. BOOL fHasFullPtr,
  940. CG_RETURN * pRT,
  941. OPTIM_OPTION OptimFlags,
  942. unsigned short OpBits )
  943. : CG_OBJECT_PROC( ProcNum,
  944. pProc,
  945. pBH,
  946. pHU,
  947. fAtLeastOneIn,
  948. fAtLeastOneOut,
  949. fAtLeastOneShipped,
  950. fHasStatuses,
  951. fHasFullPtr,
  952. pRT,
  953. OptimFlags,
  954. OpBits )
  955. {
  956. }
  957. virtual
  958. ID_CG GetCGID()
  959. {
  960. return ID_CG_INHERITED_OBJECT_PROC;
  961. }
  962. //
  963. // miscellaneous methods.
  964. //
  965. virtual
  966. BOOL IsInherited()
  967. {
  968. return TRUE;
  969. }
  970. virtual
  971. BOOL IsDelegated()
  972. {
  973. return TRUE;
  974. }
  975. //
  976. // This method registers pre-allocated stub resources like the params,
  977. // standard local variables etc, with the corresponding resource dictionary
  978. // in the analysis block.
  979. //
  980. };
  981. // the class for local object procs, whether inherited or not
  982. class CG_LOCAL_OBJECT_PROC: public CG_OBJECT_PROC
  983. {
  984. BOOL fInherited;
  985. public:
  986. //
  987. // The constructor. Just call the proc constructor
  988. //
  989. CG_LOCAL_OBJECT_PROC(
  990. unsigned int ProcNum,
  991. node_skl * pProc,
  992. BOOL fInh,
  993. OPTIM_OPTION OptimFlags )
  994. : CG_OBJECT_PROC( ProcNum,
  995. pProc,
  996. NULL,
  997. NULL,
  998. 0,
  999. 0,
  1000. 0,
  1001. 0,
  1002. 0,
  1003. NULL,
  1004. OptimFlags,
  1005. 0 )
  1006. {
  1007. fInherited = fInh;
  1008. }
  1009. virtual
  1010. ID_CG GetCGID()
  1011. {
  1012. return ID_CG_LOCAL_OBJECT_PROC;
  1013. }
  1014. //
  1015. // miscellaneous methods.
  1016. //
  1017. virtual
  1018. BOOL IsInherited()
  1019. {
  1020. return fInherited;
  1021. }
  1022. virtual
  1023. CG_STATUS GenClientStub( CCB * pCCB )
  1024. {
  1025. return CG_OK;
  1026. }
  1027. virtual
  1028. CG_STATUS GenServerStub( CCB * pCCB )
  1029. {
  1030. return CG_OK;
  1031. }
  1032. virtual
  1033. BOOL IsDelegated()
  1034. {
  1035. return TRUE;
  1036. }
  1037. virtual
  1038. BOOL IsLocal()
  1039. {
  1040. return TRUE;
  1041. }
  1042. };
  1043. class CG_IUNKNOWN_OBJECT_PROC : public CG_LOCAL_OBJECT_PROC
  1044. {
  1045. public:
  1046. //
  1047. // The constructor. Just call the proc constructor
  1048. //
  1049. CG_IUNKNOWN_OBJECT_PROC(
  1050. unsigned int ProcNum,
  1051. node_skl * pProc,
  1052. BOOL fInh,
  1053. OPTIM_OPTION OptimFlags )
  1054. : CG_LOCAL_OBJECT_PROC( ProcNum,
  1055. pProc,
  1056. fInh,
  1057. OptimFlags )
  1058. {
  1059. }
  1060. virtual
  1061. BOOL IsDelegated()
  1062. {
  1063. return FALSE;
  1064. }
  1065. };
  1066. /////////////////////////////////////////////////////////////////////////////
  1067. // the encode proc code generation class.
  1068. /////////////////////////////////////////////////////////////////////////////
  1069. //
  1070. // this is derived from the regular proc class
  1071. class CG_ENCODE_PROC: public CG_PROC
  1072. {
  1073. BOOL fHasEncode;
  1074. BOOL fHasDecode;
  1075. public:
  1076. //
  1077. // The constructor. Just call the proc constructor
  1078. //
  1079. CG_ENCODE_PROC(
  1080. unsigned int ProcNum,
  1081. node_skl * pProc,
  1082. CG_HANDLE * pBH,
  1083. CG_PARAM * pHU,
  1084. BOOL fAtLeastOneIn,
  1085. BOOL fAtLeastOneOut,
  1086. BOOL fAtLeastOneShipped,
  1087. BOOL fHasStatuses,
  1088. BOOL fHasFullPtr,
  1089. CG_RETURN * pRT,
  1090. OPTIM_OPTION OptimFlags,
  1091. unsigned short OpBits,
  1092. BOOL fEncode,
  1093. BOOL fDecode )
  1094. : CG_PROC( ProcNum,
  1095. pProc,
  1096. pBH,
  1097. pHU,
  1098. fAtLeastOneIn,
  1099. fAtLeastOneOut,
  1100. fAtLeastOneShipped,
  1101. fHasStatuses,
  1102. fHasFullPtr,
  1103. pRT,
  1104. OptimFlags,
  1105. OpBits )
  1106. {
  1107. fHasEncode = fEncode;
  1108. fHasDecode = fDecode;
  1109. }
  1110. virtual
  1111. ID_CG GetCGID()
  1112. {
  1113. return ID_CG_ENCODE_PROC;
  1114. }
  1115. virtual
  1116. BOOL HasEncode()
  1117. {
  1118. return fHasEncode;
  1119. }
  1120. virtual
  1121. BOOL HasDecode()
  1122. {
  1123. return fHasDecode;
  1124. }
  1125. virtual
  1126. BOOL HasAPicklingAttribute()
  1127. {
  1128. return TRUE;
  1129. }
  1130. // Generate the client side (the only side) of the encoding stub.
  1131. virtual
  1132. CG_STATUS GenClientStub( CCB * pCCB );
  1133. CG_STATUS GenMesProcEncodeDecodeCall( CCB * pCCB,
  1134. BOOL fAlpha );
  1135. virtual
  1136. CG_STATUS GenServerStub( CCB * pCCB )
  1137. {
  1138. UNUSED( pCCB );
  1139. return CG_OK;
  1140. }
  1141. };
  1142. /////////////////////////////////////////////////////////////////////////////
  1143. // the type encode code generation class.
  1144. /////////////////////////////////////////////////////////////////////////////
  1145. //
  1146. // this is derived from the regular proc class
  1147. class CG_TYPE_ENCODE_PROC: public CG_PROC
  1148. {
  1149. public:
  1150. //
  1151. // The constructor. Just call the proc constructor
  1152. //
  1153. CG_TYPE_ENCODE_PROC(
  1154. unsigned int ProcNum,
  1155. node_skl * pProc,
  1156. CG_HANDLE * pBH,
  1157. CG_PARAM * pHU,
  1158. BOOL fAtLeastOneIn,
  1159. BOOL fAtLeastOneOut,
  1160. BOOL fAtLeastOneShipped,
  1161. BOOL fHasStatuses,
  1162. BOOL fHasFullPtr,
  1163. CG_RETURN * pRT,
  1164. OPTIM_OPTION OptimFlags,
  1165. unsigned short OpBits )
  1166. : CG_PROC( ProcNum,
  1167. pProc,
  1168. pBH,
  1169. pHU,
  1170. fAtLeastOneIn,
  1171. fAtLeastOneOut,
  1172. fAtLeastOneShipped,
  1173. fHasStatuses,
  1174. fHasFullPtr,
  1175. pRT,
  1176. OptimFlags,
  1177. OpBits )
  1178. {
  1179. }
  1180. virtual
  1181. ID_CG GetCGID()
  1182. {
  1183. return ID_CG_TYPE_ENCODE_PROC;
  1184. }
  1185. // Generate the client side (the only side) of the encoding stub.
  1186. virtual
  1187. CG_STATUS GenClientStub( CCB * pCCB );
  1188. virtual
  1189. CG_STATUS GenServerStub( CCB * pCCB )
  1190. {
  1191. UNUSED( pCCB );
  1192. return CG_OK;
  1193. }
  1194. };
  1195. /////////////////////////////////////////////////////////////////////////////
  1196. // the parameter code generation class.
  1197. /////////////////////////////////////////////////////////////////////////////
  1198. typedef unsigned long PARAM_DIR_FLAGS;
  1199. #define IN_PARAM 0x1
  1200. #define OUT_PARAM 0x2
  1201. #define IN_OUT_PARAM (IN_PARAM | OUT_PARAM)
  1202. #define I386_STACK_SIZING 0x0
  1203. #define ALPHA_STACK_SIZING 0x1
  1204. #define MIPS_STACK_SIZING 0x2
  1205. #define PPC_STACK_SIZING 0x4
  1206. #define MAC_STACK_SIZING 0x8
  1207. //
  1208. // This structure stores information derived as a result of the analysis
  1209. // pass, for use by the code generator. This structure is specific to a
  1210. // parameter cg class.
  1211. //
  1212. typedef struct
  1213. {
  1214. //
  1215. // Note the params buffer size property. Useful for various optimisations,
  1216. // especially during server side unmarshall.
  1217. //
  1218. RPC_BUF_SIZE_PROPERTY fRpcBufSize : 3;
  1219. //
  1220. // The field tells whether the offset of this parameter on the wire is
  1221. // fixed relative to the last known good location of the (un)marshalling
  1222. // pointer. This can be used to do away with incrementing the buffer
  1223. // pointer after the (un)marshall if it is not necessary. It is useful
  1224. // to know the exact offset in the rpc buffer where the parameter will
  1225. // reside. During marshalling, the destination pointer can then be derived
  1226. // from a fixed offset w.r.t say the start of the marshalling buffer. The
  1227. // code generator may find that it does not need to keep track of postion
  1228. // within the rpc buffer and hence can do away with the need to increment
  1229. // the rpc buffer pointer at all. On the server side, it can pick up the
  1230. // parameters from known locations in the rpc buffer itself instead of
  1231. // explicitly unmarshalling into local variables and therefore needing to
  1232. // increment the rpc buffer pointer.
  1233. //
  1234. OFFSET_WRT_PTR_PROPERTY fOffsetWRTPtr : 1;
  1235. //
  1236. // This field specifies the offset w.r.t the last (param) property.
  1237. // Useful for the code generator to determine if it needs to update the
  1238. // buffer pointer during marshalling / unmarshalling. The actual value
  1239. // of offset wrt the end is not useful since we always generate code
  1240. // for offsert wrt the last known good position.
  1241. //
  1242. OFFSET_WRT_LAST_PROPERTY fOffsetWRTLast : 1;
  1243. //
  1244. // This field is the offset from the last known good location of the
  1245. // (un)marshalling buffer pointer.
  1246. //
  1247. OFFSET_WRT_PTR OffsetWRTPtr;
  1248. // Also keep the buffer size requirements for this parameter. If the
  1249. // parameter is fixed size, then this is the total buffer size needed
  1250. // else this is the worst case size. This field is useful on the
  1251. // marshalling side.
  1252. RPC_BUFFER_SIZE RpcBufferSize;
  1253. } PARAM_OP_INFO;
  1254. //
  1255. // The following defines the code generation class for the parameter.
  1256. //
  1257. class CG_PARAM : public CG_NDR
  1258. {
  1259. private:
  1260. //
  1261. // quick reference for finding the directional attributes on the
  1262. // parameter.
  1263. //
  1264. PARAM_DIR_FLAGS fDirAttrs : 2;
  1265. //
  1266. // A parameters buffer re-use property.
  1267. //
  1268. BUFFER_REUSE_PROPERTY fBufferReUse : 1;
  1269. //
  1270. // a flag to indicate that free inst rouitnes shouldn't be called.
  1271. //
  1272. unsigned long fDontCallFreeInst : 1;
  1273. //
  1274. // Does the interpreter have to size the param.
  1275. //
  1276. unsigned long fInterpreterMustSize : 1;
  1277. // Specifies the Engine-Ability of the param.
  1278. ENGINE_PROPERTY EngineProperty;
  1279. //
  1280. // Permanently stored optimisation information.
  1281. //
  1282. PARAM_OP_INFO OptimInfo[ CGPHASE_COUNT ];
  1283. //
  1284. // Final Expression to be passed to the server side stub procedure.
  1285. //
  1286. expr_node * pFinalExpression;
  1287. // The sizing expression.
  1288. expr_node * pSizeExpression;
  1289. // Resource for size / length if necessary.
  1290. RESOURCE * pSizeResource;
  1291. RESOURCE * pLengthResource;
  1292. RESOURCE * pFirstResource;
  1293. RESOURCE * pSubstitutePtrResource;
  1294. // The marshalling weight.
  1295. unsigned long MarshallWeight;
  1296. // the switch_is expression (if we have a non-encap union below)
  1297. expr_node * pSwitchExpr;
  1298. // For unions only.
  1299. long UnionFormatStringOffset;
  1300. // any comm/fault statuses we may have
  1301. unsigned short Statuses;
  1302. short ParamNumber;
  1303. public:
  1304. //
  1305. // The constructor.
  1306. //
  1307. CG_PARAM( node_skl * pParam,
  1308. PARAM_DIR_FLAGS Dir,
  1309. XLAT_SIZE_INFO & Info ,
  1310. expr_node * pSw,
  1311. unsigned short Stat );
  1312. //
  1313. // TYPEDESC generation routine
  1314. //
  1315. virtual
  1316. CG_STATUS GetTypeDesc(TYPEDESC * &ptd, CCB * pCCB);
  1317. //
  1318. // get and set methods.
  1319. //
  1320. virtual
  1321. ID_CG GetCGID()
  1322. {
  1323. return ID_CG_PARAM;
  1324. }
  1325. void SetParamNumber( short pn )
  1326. {
  1327. ParamNumber = pn;
  1328. }
  1329. short GetParamNumber()
  1330. {
  1331. assert( ParamNumber != -1 );
  1332. return ParamNumber;
  1333. }
  1334. long GetStackOffset( CCB * pCCB,
  1335. long Platform );
  1336. long GetStackSize();
  1337. expr_node * SetSwitchExpr( expr_node * pE )
  1338. {
  1339. return (pSwitchExpr = pE);
  1340. }
  1341. expr_node * GetSwitchExpr()
  1342. {
  1343. return pSwitchExpr;
  1344. }
  1345. void SetUnionFormatStringOffset( long offset )
  1346. {
  1347. UnionFormatStringOffset = offset;
  1348. }
  1349. long GetUnionFormatStringOffset()
  1350. {
  1351. return UnionFormatStringOffset;
  1352. }
  1353. virtual
  1354. unsigned short GetStatuses()
  1355. {
  1356. return Statuses;
  1357. }
  1358. virtual
  1359. BOOL HasStatuses()
  1360. {
  1361. return (BOOL)( Statuses != STATUS_NONE );
  1362. }
  1363. virtual
  1364. RESOURCE * SetSubstitutePtrResource( RESOURCE * pSR )
  1365. {
  1366. return pSubstitutePtrResource = pSR;
  1367. }
  1368. virtual
  1369. RESOURCE * GetSubstitutePtrResource()
  1370. {
  1371. return pSubstitutePtrResource;
  1372. }
  1373. virtual
  1374. RESOURCE * SetSizeResource( RESOURCE * pSR )
  1375. {
  1376. return pSizeResource = pSR;
  1377. }
  1378. virtual
  1379. RESOURCE * SetLengthResource( RESOURCE * pLR )
  1380. {
  1381. return pLengthResource = pLR;
  1382. }
  1383. virtual
  1384. RESOURCE * GetSizeResource()
  1385. {
  1386. return pSizeResource;
  1387. }
  1388. virtual
  1389. RESOURCE * GetLengthResource()
  1390. {
  1391. return pLengthResource;
  1392. }
  1393. virtual
  1394. RESOURCE * SetFirstResource( RESOURCE * pR)
  1395. {
  1396. return (pFirstResource = pR);
  1397. }
  1398. virtual
  1399. RESOURCE * GetFirstResource()
  1400. {
  1401. return pFirstResource;
  1402. }
  1403. unsigned long SetMarshallWeight( unsigned long W )
  1404. {
  1405. return (MarshallWeight = W);
  1406. }
  1407. unsigned long GetMarshallWeight()
  1408. {
  1409. return MarshallWeight;
  1410. }
  1411. ENGINE_PROPERTY InitEngineProperty( ENGINE_PROPERTY E )
  1412. {
  1413. return (EngineProperty &= E);
  1414. }
  1415. ENGINE_PROPERTY SetEngineProperty( ENGINE_PROPERTY E )
  1416. {
  1417. return (EngineProperty |= E);
  1418. }
  1419. BOOL GetDontCallFreeInst()
  1420. {
  1421. return (BOOL) fDontCallFreeInst;
  1422. }
  1423. void SetDontCallFreeInst( BOOL fDontCall )
  1424. {
  1425. fDontCallFreeInst = fDontCall ? 1 : 0;
  1426. }
  1427. BOOL IsEngineSizingPossible()
  1428. {
  1429. return
  1430. !((EngineProperty & (ENGINE_PROPERTY) E_SIZING_NOT_POSSIBLE) == (ENGINE_PROPERTY) E_SIZING_NOT_POSSIBLE);
  1431. }
  1432. BOOL IsEngineMarshallPossible()
  1433. {
  1434. return
  1435. !((EngineProperty & (ENGINE_PROPERTY) E_MARSHALL_NOT_POSSIBLE) == (ENGINE_PROPERTY) E_MARSHALL_NOT_POSSIBLE);
  1436. }
  1437. BOOL IsEngineUnMarshallPossible()
  1438. {
  1439. return
  1440. !((EngineProperty & (ENGINE_PROPERTY) E_UNMARSHALL_NOT_POSSIBLE) == (ENGINE_PROPERTY) E_UNMARSHALL_NOT_POSSIBLE);
  1441. }
  1442. BOOL IsOptional()
  1443. {
  1444. return(((node_param *)GetType())->IsOptional());
  1445. }
  1446. BOOL IsRetval()
  1447. {
  1448. return(((node_param *)GetType())->IsRetval());
  1449. }
  1450. expr_node * SetFinalExpression( expr_node * pR )
  1451. {
  1452. return (pFinalExpression = pR );
  1453. }
  1454. expr_node * GetFinalExpression()
  1455. {
  1456. return pFinalExpression;
  1457. }
  1458. expr_node * SetSizeExpression( expr_node * pR )
  1459. {
  1460. return (pSizeExpression = pR );
  1461. }
  1462. expr_node * GetSizeExpression()
  1463. {
  1464. return pSizeExpression;
  1465. }
  1466. BUFFER_REUSE_PROPERTY SetBufferReUseProperty( BUFFER_REUSE_PROPERTY R )
  1467. {
  1468. return (fBufferReUse = R);
  1469. }
  1470. BUFFER_REUSE_PROPERTY GetBufferReUseProperty()
  1471. {
  1472. return fBufferReUse;
  1473. }
  1474. OFFSET_WRT_PTR_PROPERTY SetOWRTPtrProperty(
  1475. OFFSET_WRT_PTR_PROPERTY P,
  1476. CGPHASE Phase )
  1477. {
  1478. return (OptimInfo[ Phase ].fOffsetWRTPtr = P );
  1479. }
  1480. OFFSET_WRT_PTR_PROPERTY GetOWRTPtrProperty(CGPHASE Phase)
  1481. {
  1482. return OptimInfo[ Phase ].fOffsetWRTPtr;
  1483. }
  1484. RPC_BUF_SIZE_PROPERTY SetRpcBufSizeProperty(
  1485. RPC_BUF_SIZE_PROPERTY P,
  1486. CGPHASE Phase )
  1487. {
  1488. return (OptimInfo[ Phase ].fRpcBufSize = P );
  1489. }
  1490. RPC_BUF_SIZE_PROPERTY GetRpcBufSizeProperty(CGPHASE Phase)
  1491. {
  1492. return OptimInfo[ Phase ].fRpcBufSize;
  1493. }
  1494. OFFSET_WRT_LAST_PROPERTY SetOWRTLastProperty(
  1495. OFFSET_WRT_LAST_PROPERTY P,
  1496. CGPHASE Phase )
  1497. {
  1498. return (OptimInfo[ Phase ].fOffsetWRTLast = P );
  1499. }
  1500. RPC_BUFFER_SIZE SetRpcBufferSize( RPC_BUFFER_SIZE S,
  1501. CGPHASE Phase )
  1502. {
  1503. return (OptimInfo[ Phase ].RpcBufferSize = S);
  1504. }
  1505. RPC_BUFFER_SIZE GetRpcBufferSize( CGPHASE Phase )
  1506. {
  1507. return OptimInfo[ Phase ].RpcBufferSize;
  1508. }
  1509. OFFSET_WRT_LAST_PROPERTY GetOWRTLastProperty(CGPHASE Phase)
  1510. {
  1511. return OptimInfo[ Phase ].fOffsetWRTLast;
  1512. }
  1513. OFFSET_WRT_PTR SetOffsetWRTPtr(
  1514. OFFSET_WRT_PTR O,
  1515. CGPHASE Phase )
  1516. {
  1517. return (OptimInfo[ Phase ].OffsetWRTPtr = O);
  1518. }
  1519. OFFSET_WRT_PTR GetOffsetWRTPtr( CGPHASE Phase )
  1520. {
  1521. return OptimInfo[ Phase ].OffsetWRTPtr;
  1522. }
  1523. //
  1524. // Queries
  1525. //
  1526. BOOL ShouldUseEngineSizing( CCB * pCCB )
  1527. {
  1528. return (pCCB->GetOptimOption() & OPTIMIZE_SIZE);
  1529. // return (BOOL) ((EngineProperty & E_USE_ENGINE_SIZING) != 0);
  1530. }
  1531. BOOL ShouldUseEngineMarshall( CCB * pCCB )
  1532. {
  1533. return (pCCB->GetOptimOption() & OPTIMIZE_SIZE);
  1534. // return (BOOL) ((EngineProperty & E_USE_ENGINE_MARSHALL) != 0);
  1535. }
  1536. BOOL ShouldUseEngineUnMarshall( CCB * pCCB )
  1537. {
  1538. return (pCCB->GetOptimOption() & OPTIMIZE_SIZE);
  1539. // return (BOOL) ((EngineProperty & E_USE_ENGINE_UNMARSHALL) != 0);
  1540. }
  1541. BOOL ShouldUseEngineFree( CCB * pCCB )
  1542. {
  1543. return (pCCB->GetOptimOption() & OPTIMIZE_SIZE);
  1544. // return (BOOL) ((EngineProperty & E_USE_ENGINE_UNMARSHALL) != 0);
  1545. }
  1546. //
  1547. // This method performs binding related analysis on the client side.
  1548. //
  1549. virtual
  1550. CG_STATUS C_BindingAnalysis( ANALYSIS_INFO * pAna )
  1551. {
  1552. UNUSED( pAna );
  1553. return CG_OK;
  1554. }
  1555. //
  1556. // Generate the client side marshalling code.
  1557. //
  1558. virtual
  1559. CG_STATUS GenMarshall( CCB * pCCB );
  1560. virtual
  1561. CG_STATUS GenUnMarshall( CCB * pCCB );
  1562. virtual
  1563. CG_STATUS GenSizing( CCB * pCCB );
  1564. virtual
  1565. CG_STATUS GenFree( CCB * pCCB );
  1566. CG_STATUS GenTypeEncodingStub( CCB * pCCB );
  1567. //
  1568. // Generate the server side unmarshalling code.
  1569. //
  1570. OFFSET_WRT_LAST_PROPERTY S_SetupOffsetWRTLast( CGPHASE Phase );
  1571. OFFSET_WRT_LAST_PROPERTY C_SetupOffsetWRTLast( CGPHASE Phase );
  1572. virtual
  1573. CG_STATUS S_GenInitOutLocals( CCB * pCCB );
  1574. virtual
  1575. CG_STATUS S_GenInitTopLevelStuff( CCB * pCCB );
  1576. //
  1577. // Format string routines for generating the format string and
  1578. // the NDR calls for a parameter.
  1579. //
  1580. virtual
  1581. void GenNdrFormat( CCB * pCCB );
  1582. void GenNdrFormatOld( CCB * pCCB );
  1583. void GenNdrMarshallCall( CCB * pCCB );
  1584. void GenNdrUnmarshallCall( CCB * pCCB );
  1585. void GenNdrBufferSizeCall( CCB * pCCB );
  1586. void GenNdrFreeCall( CCB * pCCB );
  1587. void GenNdrTopLevelAttributeSupport(
  1588. CCB * pCCB,
  1589. BOOL fForClearOut = FALSE );
  1590. //
  1591. // Queries.
  1592. //
  1593. BOOL IsParamIn()
  1594. {
  1595. return (BOOL)
  1596. ((fDirAttrs & IN_PARAM) == IN_PARAM);
  1597. }
  1598. BOOL IsParamOut()
  1599. {
  1600. return (BOOL)
  1601. ((fDirAttrs & OUT_PARAM) == OUT_PARAM);
  1602. }
  1603. //
  1604. // Should we use the new NDR engine to marshall/unmarshall a parameter.
  1605. // For now we pass the CCB since it contains optimization information.
  1606. // Later the analyzer will put optimization information in the CG_PARAM
  1607. // class.
  1608. //
  1609. BOOL UseNdrEngine( CCB * pCCB )
  1610. {
  1611. return (pCCB->GetOptimOption() & OPTIMIZE_SIZE);
  1612. }
  1613. //
  1614. // miscellaneous methods.
  1615. //
  1616. ALIGNMENT_PROPERTY GetExpectedAlignment();
  1617. virtual
  1618. expr_node * GenBindOrUnBindExpression( CCB * pCCB, BOOL fBind );
  1619. ////////////////////////////////////////////////////////////////////////////
  1620. virtual
  1621. CG_STATUS BufferAnalysis( ANALYSIS_INFO * pAna )
  1622. {
  1623. UNUSED( pAna );
  1624. return CG_OK;
  1625. }
  1626. virtual
  1627. CG_STATUS MarshallAnalysis( ANALYSIS_INFO * pAna );
  1628. virtual
  1629. CG_STATUS SizeAnalysis( ANALYSIS_INFO * pAna )
  1630. {
  1631. UNUSED( pAna );
  1632. return CG_OK;
  1633. }
  1634. virtual
  1635. CG_STATUS UnMarshallAnalysis( ANALYSIS_INFO * pAna );
  1636. virtual
  1637. CG_STATUS S_OutLocalAnalysis( ANALYSIS_INFO * pAna );
  1638. void RpcSsPackageAnalysis( ANALYSIS_INFO * pAna );
  1639. void InitParamMarshallAnalysis( ANALYSIS_INFO * pAna );
  1640. void InitParamUnMarshallAnalysis( ANALYSIS_INFO * pAna );
  1641. void ConsolidateParamMarshallAnalysis( ANALYSIS_INFO * pAna );
  1642. void ConsolidateParamUnMarshallAnalysis( ANALYSIS_INFO * pAna );
  1643. void FinalizeEngineUsage( ANALYSIS_INFO * pAna,
  1644. BOOL fMarshall );
  1645. virtual
  1646. CG_STATUS GenRefChecks( CCB * pCCB );
  1647. virtual
  1648. CG_STATUS S_GenInitInLocals( CCB * pCCB );
  1649. void SetInterpreterMustSize( BOOL f )
  1650. {
  1651. fInterpreterMustSize = f ? 1 : 0;
  1652. }
  1653. BOOL GetInterpreterMustSize()
  1654. {
  1655. return fInterpreterMustSize;
  1656. }
  1657. };
  1658. //
  1659. // The return-type code generation class
  1660. //
  1661. // This is a place-holder node for the return type, much like the param
  1662. // and field nodes. This way, info about marshalling/unmarshalling the
  1663. // return type doesn't need to clutter up the proc node.
  1664. //
  1665. // If the function has no return (or returns "void") then no CG_RETURN
  1666. // is generated for the function.
  1667. //
  1668. class CG_RETURN : public CG_PARAM
  1669. {
  1670. private:
  1671. // The rpc buffer size property.
  1672. RPC_BUF_SIZE_PROPERTY fRpcBufSize : 4;
  1673. // The buffer size.
  1674. RPC_BUFFER_SIZE RpcBufferSize;
  1675. public:
  1676. //
  1677. // The constructor.
  1678. //
  1679. CG_RETURN( node_skl * pRetType,
  1680. XLAT_SIZE_INFO & Info,
  1681. unsigned short Stat )
  1682. : CG_PARAM( pRetType,
  1683. OUT_PARAM,
  1684. Info,
  1685. NULL,
  1686. Stat )
  1687. {
  1688. }
  1689. //
  1690. // get and set methods.
  1691. //
  1692. virtual
  1693. ID_CG GetCGID()
  1694. {
  1695. return ID_CG_RETURN;
  1696. }
  1697. RPC_BUFFER_SIZE SetRpcBufferSize( RPC_BUFFER_SIZE Size,
  1698. CGPHASE Phase
  1699. )
  1700. {
  1701. UNUSED( Phase );
  1702. return (RpcBufferSize = Size);
  1703. }
  1704. RPC_BUFFER_SIZE GetRpcBufferSize( CGPHASE Phase )
  1705. {
  1706. UNUSED( Phase );
  1707. return RpcBufferSize;
  1708. }
  1709. virtual
  1710. CG_STATUS MarshallAnalysis( ANALYSIS_INFO * pAna );
  1711. virtual
  1712. CG_STATUS UnMarshallAnalysis( ANALYSIS_INFO * pAna );
  1713. virtual
  1714. CG_STATUS GenMarshall( CCB * pCCB );
  1715. virtual
  1716. CG_STATUS GenUnMarshall( CCB * pCCB );
  1717. virtual
  1718. CG_STATUS GenSizing( CCB * pCCB );
  1719. virtual
  1720. CG_STATUS GenFree( CCB * pCCB );
  1721. virtual
  1722. CG_STATUS S_GenInitOutLocals( CCB * pCCB );
  1723. virtual
  1724. CG_STATUS S_GenInitTopLevelStuff( CCB * pCCB );
  1725. void FinalizeEngineUsage( ANALYSIS_INFO * pAna,
  1726. BOOL fMarshall );
  1727. expr_node * GetFinalExpression();
  1728. };
  1729. #endif // __PROCCLS_HXX__