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.

2196 lines
76 KiB

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