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.

1972 lines
68 KiB

  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1989-1999 Microsoft Corporation
  3. Module Name:
  4. ccb.hxx
  5. Abstract:
  6. Code generation control block.
  7. Notes:
  8. History:
  9. Aug-15-1993 VibhasC Created.
  10. ----------------------------------------------------------------------------*/
  11. #ifndef __CCB_HXX__
  12. #define __CCB_HXX__
  13. #include "nodeskl.hxx"
  14. #include "listhndl.hxx"
  15. #include "stream.hxx"
  16. #include "resdict.hxx"
  17. #include "dtable.hxx"
  18. #include "frmtstr.hxx"
  19. #include "treg.hxx"
  20. #include "sdesc.hxx"
  21. #include "paddict.hxx"
  22. #include "listhndl.hxx"
  23. #include "ndrtypes.h"
  24. class CG_NDR;
  25. class CG_HANDLE;
  26. class RESOURCE;
  27. class expr_node;
  28. class CG_INTERFACE;
  29. class CG_FILE;
  30. class CG_ENCODE_PROC;
  31. class CG_QUALIFIED_POINTER;
  32. class CG_IUNKNOWN_OBJECT_INTERFACE;
  33. class CG_OBJECT_INTERFACE;
  34. class CG_PARAM;
  35. class CG_PROC;
  36. class CG_FIELD;
  37. class GenNdr64Format;
  38. //
  39. // some typedefs for entities used within the code gen controller block.
  40. //
  41. typedef unsigned int PROCNUM;
  42. typedef unsigned long RPC_FLAGS;
  43. typedef IndexedStringList CsTypeList;
  44. typedef IndexedStringList CsTagRoutineList;
  45. typedef IndexedList NotifyRoutineList;
  46. //
  47. // This class is for managing context rundown and generic binding routine
  48. // indexes used in the Stub Descriptor structure.
  49. //
  50. #define MGR_INDEX_TABLE_SIZE 256
  51. #define EXPR_INDEX_TABLE_SIZE 65535
  52. #define OSF_MODE 0
  53. #define MSEXT_MODE 1
  54. /////////////////////////////////////////////////////////////////////////////
  55. // This definition specifies a context for a registered expr eval routines.
  56. // For some reason I couldn't get it work in cgcommon.hxx (rkk)
  57. /////////////////////////////////////////////////////////////////////////////
  58. typedef struct expr_EVAL_CONTEXT
  59. {
  60. CG_NDR * pContainer;
  61. expr_node * pMinExpr;
  62. expr_node * pSizeExpr;
  63. char * pRoutineName;
  64. char * pPrintPrefix;
  65. unsigned long Displacement;
  66. } EXPR_EVAL_CONTEXT;
  67. typedef enum _TYPE_ENCODE_FLAGS
  68. {
  69. TYPE_ENCODE_FLAGS_NONE
  70. ,TYPE_ENCODE_WITH_IMPL_HANDLE
  71. } TYPE_ENCODE_FLAGS;
  72. typedef struct _TYPE_ENCODE_INFO
  73. {
  74. PNAME pName;
  75. TYPE_ENCODE_FLAGS Flags;
  76. } TYPE_ENCODE_INFO;
  77. class CCB_RTN_INDEX_MGR
  78. {
  79. private:
  80. char * NameId[ MGR_INDEX_TABLE_SIZE ];
  81. long NextIndex;
  82. public:
  83. CCB_RTN_INDEX_MGR()
  84. {
  85. //
  86. // The zeroth entry is reserved or invalid.
  87. //
  88. NameId[0] = NULL;
  89. NextIndex = 1;
  90. }
  91. long Lookup( char * pName );
  92. char * Lookup( long Index );
  93. long GetIndex() { return NextIndex; }
  94. BOOL IsEmpty() { return NextIndex == 1; }
  95. };
  96. class CCB_EXPR_INDEX_MGR
  97. {
  98. private:
  99. char * NameId[ EXPR_INDEX_TABLE_SIZE ];
  100. long Offset[ EXPR_INDEX_TABLE_SIZE ];
  101. long NextIndex;
  102. public:
  103. CCB_EXPR_INDEX_MGR()
  104. {
  105. //
  106. // The zeroth entry is reserved or invalid.
  107. //
  108. NameId[0] = NULL;
  109. NextIndex = 1;
  110. }
  111. long Lookup( char * pName );
  112. char * Lookup( long Index );
  113. long GetIndex() { return NextIndex; }
  114. BOOL IsEmpty() { return NextIndex == 1; }
  115. void SetOffset(long Index, long lOffset) {Offset[Index] = lOffset;}
  116. long GetOffset(long Index) { return Offset[Index]; }
  117. };
  118. /////////////////////////////////////////////////////////////////////////////
  119. //
  120. // This class is a captive class for the code generation controller block.
  121. // Stores running expression stuff for inline stubs.
  122. //
  123. /////////////////////////////////////////////////////////////////////////////
  124. class CCBexprINFO
  125. {
  126. private:
  127. expr_node * pSrcExpr;
  128. expr_node * pDestExpr;
  129. public:
  130. //
  131. // The constructor.
  132. //
  133. CCBexprINFO()
  134. {
  135. SetSrcExpression( 0 );
  136. SetDestExpression( 0 );
  137. }
  138. //
  139. // Get and set methods.
  140. //
  141. expr_node * SetSrcExpression( expr_node * pSrc )
  142. {
  143. return (pSrcExpr = pSrc);
  144. }
  145. expr_node * GetSrcExpression()
  146. {
  147. return pSrcExpr;
  148. }
  149. expr_node * SetDestExpression( expr_node * pDest )
  150. {
  151. return (pDestExpr = pDest);
  152. }
  153. expr_node * GetDestExpression()
  154. {
  155. return pDestExpr;
  156. }
  157. };
  158. struct ICreateTypeInfo;
  159. struct ICreateTypeLib;
  160. struct tagVARDESC;
  161. typedef tagVARDESC VARDESC;
  162. struct tagTYPEDESC;
  163. typedef tagTYPEDESC TYPEDESC;
  164. /////////////////////////////////////////////////////////////////////////////
  165. //
  166. // This class defines the code generation control block.
  167. //
  168. /////////////////////////////////////////////////////////////////////////////
  169. class CCB
  170. {
  171. private:
  172. class VTableLayOutInfo
  173. {
  174. public:
  175. CG_CLASS* pLayOutNode;
  176. ICreateTypeInfo* pTypeInfo;
  177. VTableLayOutInfo( CG_CLASS* pIf,
  178. ICreateTypeInfo* pInfo)
  179. :
  180. pLayOutNode(pIf),
  181. pTypeInfo(pInfo)
  182. {
  183. }
  184. ~VTableLayOutInfo()
  185. {
  186. }
  187. };
  188. gplistmgr VTableLayOutList;
  189. // Is pointee to be deferred in code generation.
  190. unsigned long fDeferPointee : 1;
  191. // Has At least one deferred pointee.
  192. unsigned long fAtLeastOneDeferredPointee : 1;
  193. // This flag indicates memory allocated for the entity being
  194. // marshalled / unmarshalled.
  195. unsigned long fMemoryAllocDone: 1;
  196. // This flag indicates a reference allocated.
  197. unsigned long fRefAllocDone : 1;
  198. // This flag indicates a return context
  199. unsigned long fReturnContext : 1;
  200. // Are we in a callback proc?
  201. unsigned long fInCallback : 1;
  202. // Generate a call thru the epv only. Corresponds to the -use_epv
  203. // on midl command line.
  204. unsigned long fMEpV : 1;
  205. unsigned long fNoDefaultEpv : 1;
  206. // Generate MIDL 1.0 style names. No mangling.
  207. unsigned long fOldNames : 1;
  208. unsigned long Mode : 2; // OSF_MODE or MSEXT_MODE
  209. // REVIEW: As best I can tell fRpcSSSwitchSet is passed to the analysis
  210. // package which then does nothing with it.
  211. unsigned long fRpcSSSwitchSet : 1;
  212. unsigned long fMustCheckAllocationError : 1;
  213. unsigned long fMustCheckEnum : 1;
  214. unsigned long fMustCheckRef : 1;
  215. unsigned long fMustCheckBounds : 1;
  216. unsigned long fMustCheckStubData : 1;
  217. unsigned long fInObjectInterface : 1;
  218. unsigned long fInterpretedRoutinesUseGenHandle : 1;
  219. unsigned long fExprEvalExternEmitted : 1;
  220. unsigned long fQuintupleExternEmitted : 1;
  221. unsigned long fQuadrupleExternEmitted : 1;
  222. unsigned long fRundownExternEmitted : 1;
  223. unsigned long fGenericHExternEmitted : 1;
  224. unsigned long fSkipFormatStreamGeneration : 1;
  225. unsigned long fTypePicklingInfoEmitted : 1;
  226. //
  227. // stream to write the generated code into.
  228. //
  229. ISTREAM * pStream;
  230. //
  231. // current file (client stub, etc)
  232. // REVIEW: We may be able to merge pStream/pFile
  233. //
  234. CG_FILE * pFile;
  235. //
  236. // optimization options in effect.
  237. //
  238. OPTIM_OPTION OptimOption;
  239. //
  240. // Store the current CG_INTERFACE node
  241. //
  242. CG_INTERFACE * pInterfaceCG;
  243. //
  244. // Store the current CG_FILE node
  245. //
  246. CG_FILE * pFileCG;
  247. //
  248. // Store the IUnknown's CG_OBJECT_INTERFACE node
  249. //
  250. CG_IUNKNOWN_OBJECT_INTERFACE * pIUnknownCG;
  251. //
  252. // Store the IClassFactory's CG_OBJECT_INTERFACE node
  253. //
  254. CG_OBJECT_INTERFACE * pIClassfCG;
  255. //
  256. // Store the interface name.
  257. //
  258. PNAME pInterfaceName;
  259. //
  260. // store the interface version.
  261. //
  262. unsigned short MajorVersion;
  263. unsigned short MinorVersion;
  264. //
  265. // The current procedure number is stored to emit the descriptor structure.
  266. //
  267. PROCNUM CurrentProcNum;
  268. PROCNUM CurrentVarNum;
  269. //
  270. // Store rpc flags. As of now, this field assumes a value only when
  271. // datagram specific attributes are applied. Otherwise it is 0. Keep
  272. // the type of this the same as in the actual rpc_message field.
  273. //
  274. RPC_FLAGS RpcFlags;
  275. //
  276. // Keep the default allocation and free routine names. These may
  277. // be overriden by the parameters / types or procedures depending
  278. // upon user specifications. Any code generation node which overrides
  279. // the default names, is responsible for restoring it back.
  280. // The default allocation routine is midl_user_allocate and the default
  281. // free is MIDL_user_free for now.
  282. //
  283. PNAME pAllocRtnName;
  284. PNAME pFreeRtnName;
  285. //
  286. // This is set of names of internal rpc api that we need to call to
  287. // perform our job. We store these names in order to make it easy to
  288. // call a different api set if necessary, as long as the stub-runtime
  289. // call paradigm stays the same.
  290. //
  291. PNAME pGetBufferRtnName;
  292. PNAME pSendReceiveRtnName;
  293. PNAME pFreeBufferRtnName;
  294. //
  295. // This field stores the current resource dictionary data base. The
  296. // data base is NOT owned by this class and must NOT be deleted by this
  297. // class either.
  298. //
  299. RESOURCE_DICT_DATABASE * pResDictDatabase;
  300. //
  301. // The standard stub descriptor resource available for use by both the
  302. // client and server stub.
  303. //
  304. RESOURCE * pStubDescResource;
  305. //
  306. // This field is a class keeping the current expressions to be used during
  307. // generation pass.
  308. //
  309. CCBexprINFO ExprInfo;
  310. //
  311. // These registries represent various types that get registered during
  312. // code generation, for the purpose of generating the prototypes during
  313. // header generation.
  314. TREGISTRY * pGenericHandleRegistry;
  315. TREGISTRY * pContextHandleRegistry;
  316. TREGISTRY * pPresentedTypeRegistry;
  317. TREGISTRY * pRepAsWireTypeRegistry;
  318. TREGISTRY * pQuintupleRegistry;
  319. TREGISTRY * pExprEvalRoutineRegistry;
  320. TREGISTRY * pSizingRoutineRegistry;
  321. TREGISTRY * pMarshallRoutineRegistry;
  322. TREGISTRY * pUnMarshallRoutineRegistry;
  323. TREGISTRY * pMemorySizingRoutineRegistry;
  324. TREGISTRY * pFreeRoutineRegistry;
  325. // REVIEW, do we really need five type pickling registries?
  326. TREGISTRY * pTypeAlignSizeRegistry;
  327. TREGISTRY * pTypeEncodeRegistry;
  328. TREGISTRY * pTypeDecodeRegistry;
  329. TREGISTRY * pTypeFreeRegistry;
  330. IndexedList * pPickledTypeList;
  331. TREGISTRY * pProcEncodeDecodeRegistry;
  332. TREGISTRY * pCallAsRoutineRegistry;
  333. TREGISTRY * pRecPointerFixupRegistry;
  334. // This stores the interface wide implicit handle ID Node.
  335. node_skl * pImplicitHandleIDNode;
  336. //
  337. // Current code generation phase.
  338. //
  339. CGPHASE CodeGenPhase;
  340. //
  341. // Current code generation side (client/server).
  342. //
  343. CGSIDE CodeGenSide;
  344. //
  345. // The type format string. Shared across mulitple interfaces and identical
  346. // for client and server.
  347. //
  348. FORMAT_STRING * pFormatString;
  349. //
  350. // The proc/param format string. Used only for fully interpreted stubs.
  351. //
  352. FORMAT_STRING * pProcFormatString;
  353. //
  354. // Format string for expression evaluator. Used in post Windows 2000 only
  355. FORMAT_STRING * pExprFormatString;
  356. // The current embedding context. We increment this to indicate if we are
  357. // in a top level or embedded context.
  358. short EmbeddingLevel;
  359. // This indicates the ptr indirection level. Each pointer must note its
  360. // indirection level and then bump this field to indicate to the next
  361. // pointer its (that pointer's) level.
  362. short IndirectionLevel;
  363. //
  364. // This field is set by CG_PROC and all procedure CG classes. It is
  365. // then used by the array classes when computing their conformance and/or
  366. // variance descriptions for the new Ndr format strings.
  367. //
  368. CG_NDR * pCGNodeContext;
  369. //
  370. // This is the currently active region field if one if active.
  371. //
  372. CG_FIELD * pCurrentRegionField;
  373. //
  374. // Param/Field placeholder.
  375. //
  376. CG_NDR * pPlaceholderClass;
  377. CG_PARAM * pCurrentParam;
  378. // The stub descriptor structure.
  379. SDESCMGR SSDescMgr;
  380. SDESCMGR CSDescMgr;
  381. RESOURCE * PtrToPtrInBuffer;
  382. //
  383. // Generic Binding and Context Rundown routine index managers.
  384. //
  385. CCB_RTN_INDEX_MGR * pGenericIndexMgr;
  386. CCB_RTN_INDEX_MGR * pContextIndexMgr;
  387. //
  388. // Expression evaluation routine index manager.
  389. //
  390. CCB_RTN_INDEX_MGR * pExprEvalIndexMgr;
  391. CCB_EXPR_INDEX_MGR * pExprFrmtStrIndexMgr;
  392. //
  393. // Transmited As routine index manager.
  394. //
  395. CCB_RTN_INDEX_MGR * pTransmitAsIndexMgr; // prototypes
  396. CCB_RTN_INDEX_MGR * pRepAsIndexMgr; // prototypes
  397. QuintupleDict * pQuintupleDictionary; // routines
  398. QuadrupleDict * pQuadrupleDictionary; // routines
  399. // List of international character types
  400. CsTypeList CsTypes;
  401. CsTagRoutineList CsTagRoutines;
  402. //
  403. // Dictionary kept for unknown represent as types to do padding
  404. // and sizing macros.
  405. //
  406. RepAsPadExprDict * pRepAsPadExprDictionary;
  407. RepAsSizeDict * pRepAsSizeDictionary;
  408. // Keep the current prefix to generate the proper code for
  409. // embedded stuff.
  410. char * pPrefix;
  411. //
  412. // These keeps track of the total memory and buffer size of all currently
  413. // imbeding structures. For NDR format string generation, a struct or
  414. // array node will check this field when generating it's pointer layout
  415. // field so it knows how much to add to its offset fields.
  416. //
  417. long ImbedingMemSize;
  418. long ImbedingBufSize;
  419. CG_QUALIFIED_POINTER * pCurrentSizePointer;
  420. long InterpreterOutSize;
  421. // members used for TypeInfo generation
  422. ICreateTypeLib * pCreateTypeLib;
  423. ICreateTypeInfo * pCreateTypeInfo;
  424. char * szDllName;
  425. BOOL fInDispinterface;
  426. unsigned long lcid;
  427. // notify and notify_flag procs.
  428. NotifyRoutineList NotifyProcList;
  429. GenNdr64Format * pNdr64Format;
  430. public:
  431. //
  432. // The constructors.
  433. //
  434. CCB( PNAME pGBRtnName,
  435. PNAME pSRRtnName,
  436. PNAME pFBRtnName,
  437. OPTIM_OPTION OptimOption,
  438. BOOL fManagerEpvFlag,
  439. BOOL fNoDefaultEpv,
  440. BOOL fOldNames,
  441. unsigned long Mode,
  442. BOOL fRpcSSSwitchSetInCompiler,
  443. BOOL fMustCheckAllocError,
  444. BOOL fMustCheckRefPtrs,
  445. BOOL fMustCheckEnumValues,
  446. BOOL fMustCheckBoundValues,
  447. BOOL fCheckStubData
  448. );
  449. unsigned long SetLcid(unsigned long l)
  450. {
  451. return (lcid = l);
  452. }
  453. unsigned long GetLcid(void)
  454. {
  455. return lcid;
  456. }
  457. void SetInterpretedRoutinesUseGenHandle()
  458. {
  459. fInterpretedRoutinesUseGenHandle = 1;
  460. }
  461. BOOL GetInterpretedRoutinesUseGenHandle()
  462. {
  463. return (BOOL)(fInterpretedRoutinesUseGenHandle == 1);
  464. }
  465. BOOL GetExprEvalExternEmitted()
  466. {
  467. return (BOOL)(fExprEvalExternEmitted == 1);
  468. }
  469. void SetExprEvalExternEmitted()
  470. {
  471. fExprEvalExternEmitted = 1;
  472. }
  473. BOOL GetQuintupleExternEmitted()
  474. {
  475. return (BOOL)(fQuintupleExternEmitted == 1);
  476. }
  477. CsTypeList & GetCsTypeList()
  478. {
  479. return CsTypes;
  480. }
  481. CsTagRoutineList & GetCsTagRoutineList()
  482. {
  483. return CsTagRoutines;
  484. }
  485. void SetQuintupleExternEmitted()
  486. {
  487. fQuintupleExternEmitted = 1;
  488. }
  489. BOOL GetQuadrupleExternEmitted()
  490. {
  491. return (BOOL)(fQuadrupleExternEmitted == 1);
  492. }
  493. void SetQuadrupleExternEmitted()
  494. {
  495. fQuadrupleExternEmitted = 1;
  496. }
  497. BOOL GetRundownExternEmitted()
  498. {
  499. return (BOOL)(fRundownExternEmitted == 1);
  500. }
  501. void SetRundownExternEmitted()
  502. {
  503. fRundownExternEmitted = 1;
  504. }
  505. BOOL GetGenericHExternEmitted()
  506. {
  507. return (BOOL)(fGenericHExternEmitted == 1);
  508. }
  509. void SetGenericHExternEmitted()
  510. {
  511. fGenericHExternEmitted = 1;
  512. }
  513. // REVIEW: Straigten out the dependencies between ccb.hxx and filecls.cxx
  514. // to make these inline
  515. BOOL GetMallocAndFreeStructExternEmitted();
  516. /*
  517. {
  518. return pFile->GetMallocAndFreeStructExternEmitted();
  519. }
  520. */
  521. void SetMallocAndFreeStructExternEmitted();
  522. /*
  523. {
  524. pFile->SetMallocAndFreeStructExternEmitted();
  525. }
  526. */
  527. void ClearOptionalExternFlags()
  528. {
  529. fExprEvalExternEmitted = 0;
  530. fQuintupleExternEmitted = 0;
  531. fQuadrupleExternEmitted = 0;
  532. fRundownExternEmitted = 0;
  533. fGenericHExternEmitted = 0;
  534. fTypePicklingInfoEmitted = 0;
  535. }
  536. BOOL GetSkipFormatStreamGeneration()
  537. {
  538. return (BOOL)(fSkipFormatStreamGeneration == 1);
  539. }
  540. void SetSkipFormatStreamGeneration( BOOL Has )
  541. {
  542. fSkipFormatStreamGeneration = Has ? 1 : 0;
  543. }
  544. void SetMustCheckAllocationError( BOOL f )
  545. {
  546. fMustCheckAllocationError = f;
  547. }
  548. BOOL MustCheckAllocationError()
  549. {
  550. return (BOOL)(fMustCheckAllocationError == 1);
  551. }
  552. void SetMustCheckRef( BOOL f )
  553. {
  554. fMustCheckRef = f;
  555. }
  556. BOOL MustCheckRef()
  557. {
  558. return (BOOL)(fMustCheckRef == 1);
  559. }
  560. void SetMustCheckEnum( BOOL f )
  561. {
  562. fMustCheckEnum = f;
  563. }
  564. BOOL MustCheckEnum()
  565. {
  566. return (BOOL)(fMustCheckEnum == 1);
  567. }
  568. void SetMustCheckBounds( BOOL f )
  569. {
  570. fMustCheckBounds = f;
  571. }
  572. BOOL MustCheckBounds()
  573. {
  574. return (BOOL)(fMustCheckBounds == 1);
  575. }
  576. SDESC * SetSStubDescriptor( PNAME AllocRtnName,
  577. PNAME FreeRtnName,
  578. PNAME RundownRtnName )
  579. {
  580. return SSDescMgr.Register( AllocRtnName,
  581. FreeRtnName,
  582. RundownRtnName );
  583. }
  584. SDESC * SetCStubDescriptor( PNAME AllocRtnName,
  585. PNAME FreeRtnName,
  586. PNAME RundownRtnName )
  587. {
  588. return CSDescMgr.Register( AllocRtnName,
  589. FreeRtnName,
  590. RundownRtnName );
  591. }
  592. //
  593. // Get and set of members.
  594. //
  595. void SetMustCheckStubData( BOOL f )
  596. {
  597. fMustCheckStubData = f;
  598. }
  599. BOOL IsMustCheckStubDataSpecified()
  600. {
  601. return (BOOL) fMustCheckStubData;
  602. }
  603. void SetRpcSSSwitchSet( BOOL f)
  604. {
  605. fRpcSSSwitchSet = f;
  606. }
  607. BOOL IsRpcSSSwitchSet()
  608. {
  609. return fRpcSSSwitchSet;
  610. }
  611. void SetMode( unsigned long M )
  612. {
  613. Mode = M;
  614. }
  615. unsigned long GetMode()
  616. {
  617. return Mode;
  618. }
  619. bool InOSFMode()
  620. {
  621. return OSF_MODE == GetMode();
  622. }
  623. void SetOldNames( unsigned long Flag )
  624. {
  625. fOldNames = Flag;
  626. }
  627. BOOL IsOldNames()
  628. {
  629. return (BOOL)( fOldNames == 1 );
  630. }
  631. BOOL IsMEpV()
  632. {
  633. return (BOOL)( fMEpV == 1 );
  634. }
  635. BOOL IsNoDefaultEpv()
  636. {
  637. return (BOOL)( fNoDefaultEpv == 1 );
  638. }
  639. char * SetPrefix( char * pP )
  640. {
  641. return (pPrefix = pP);
  642. }
  643. char * GetPrefix()
  644. {
  645. return pPrefix;
  646. }
  647. unsigned long SetReturnContext()
  648. {
  649. return (fReturnContext = 1);
  650. }
  651. unsigned long ResetReturnContext()
  652. {
  653. return (fReturnContext = 0);
  654. }
  655. BOOL IsReturnContext()
  656. {
  657. return (fReturnContext == 1);
  658. }
  659. void SetCurrentSizePointer( CG_QUALIFIED_POINTER * pPtr )
  660. {
  661. pCurrentSizePointer = pPtr;
  662. }
  663. CG_QUALIFIED_POINTER * GetCurrentSizePointer()
  664. {
  665. return pCurrentSizePointer;
  666. }
  667. void SetMemoryAllocDone()
  668. {
  669. fMemoryAllocDone = 1;
  670. }
  671. void ResetMemoryAllocDone()
  672. {
  673. fMemoryAllocDone = 0;
  674. }
  675. void SetRefAllocDone()
  676. {
  677. fRefAllocDone = 1;
  678. }
  679. void ResetRefAllocDone()
  680. {
  681. fRefAllocDone = 0;
  682. }
  683. BOOL IsMemoryAllocDone()
  684. {
  685. return (BOOL)(fMemoryAllocDone == 1);
  686. }
  687. BOOL IsRefAllocDone()
  688. {
  689. return (fRefAllocDone == 1);
  690. }
  691. unsigned long SetHasAtLeastOneDeferredPointee()
  692. {
  693. return (fAtLeastOneDeferredPointee = 1);
  694. }
  695. unsigned long ResetHasAtLeastOneDeferredPointee()
  696. {
  697. return (fAtLeastOneDeferredPointee = 0);
  698. }
  699. BOOL HasAtLeastOneDeferredPointee()
  700. {
  701. return (fAtLeastOneDeferredPointee == 1);
  702. }
  703. unsigned long SetDeferPointee()
  704. {
  705. return (fDeferPointee = 1);
  706. }
  707. unsigned long ResetDeferPointee()
  708. {
  709. return (fDeferPointee = 0);
  710. }
  711. BOOL IsPointeeDeferred()
  712. {
  713. return (fDeferPointee == 1);
  714. }
  715. void ClearInCallback()
  716. {
  717. fInCallback = 0;
  718. }
  719. void SetInCallback()
  720. {
  721. fInCallback = 1;
  722. }
  723. BOOL IsInCallback()
  724. {
  725. return (fInCallback == 1);
  726. }
  727. node_skl * SetImplicitHandleIDNode( node_skl * pID )
  728. {
  729. return (pImplicitHandleIDNode = pID);
  730. }
  731. node_skl * GetImplicitHandleIDNode()
  732. {
  733. return pImplicitHandleIDNode;
  734. }
  735. BOOL IsInObjectInterface()
  736. {
  737. return fInObjectInterface;
  738. }
  739. void SetInObjectInterface( BOOL fInObj )
  740. {
  741. fInObjectInterface = fInObj;
  742. }
  743. short ResetEmbeddingLevel()
  744. {
  745. return (EmbeddingLevel = 0);
  746. }
  747. // bumps up embedding level, but returns the old one.
  748. short PushEmbeddingLevel()
  749. {
  750. return EmbeddingLevel++;
  751. }
  752. // pops embedding level but returns the current one.
  753. short PopEmbeddingLevel()
  754. {
  755. if( EmbeddingLevel > 0 )
  756. return EmbeddingLevel--;
  757. else
  758. return EmbeddingLevel;
  759. }
  760. short GetCurrentEmbeddingLevel()
  761. {
  762. return EmbeddingLevel;
  763. }
  764. short SetCurrentEmbeddingLevel( short E)
  765. {
  766. return (EmbeddingLevel = E);
  767. }
  768. short ResetIndirectionLevel()
  769. {
  770. return (IndirectionLevel = 0);
  771. }
  772. // This pushes the indirection level, but returns the current one.
  773. short PushIndirectionLevel()
  774. {
  775. return IndirectionLevel++;
  776. }
  777. // This pops the indirection Level but returns the current one.
  778. short PopIndirectionLevel()
  779. {
  780. if( IndirectionLevel > 0 )
  781. return IndirectionLevel--;
  782. else
  783. return IndirectionLevel;
  784. }
  785. short GetCurrentIndirectionLevel()
  786. {
  787. return IndirectionLevel;
  788. }
  789. ISTREAM * GetStream()
  790. {
  791. return pStream;
  792. }
  793. ISTREAM * SetStream( ISTREAM * S, CG_FILE *file )
  794. {
  795. pFile = file;
  796. return (pStream = S);
  797. }
  798. void SetVersion( unsigned short Major,
  799. unsigned short Minor
  800. )
  801. {
  802. MajorVersion = Major;
  803. MinorVersion = Minor;
  804. }
  805. void GetVersion( unsigned short * pMaj,
  806. unsigned short * pMin
  807. )
  808. {
  809. if( pMaj ) *pMaj = MajorVersion;
  810. if( pMin ) *pMin = MinorVersion;
  811. }
  812. CG_INTERFACE * SetInterfaceCG( CG_INTERFACE *pCG )
  813. {
  814. return (pInterfaceCG = pCG);
  815. }
  816. CG_INTERFACE * GetInterfaceCG()
  817. {
  818. return pInterfaceCG;
  819. }
  820. CG_FILE * SetFileCG( CG_FILE *pCG )
  821. {
  822. return (pFileCG = pCG);
  823. }
  824. CG_FILE * GetFileCG()
  825. {
  826. return pFileCG;
  827. }
  828. CG_IUNKNOWN_OBJECT_INTERFACE * SetIUnknownCG( CG_IUNKNOWN_OBJECT_INTERFACE *pCG )
  829. {
  830. return (pIUnknownCG = pCG);
  831. }
  832. CG_IUNKNOWN_OBJECT_INTERFACE * GetIUnknownCG()
  833. {
  834. return pIUnknownCG;
  835. }
  836. CG_OBJECT_INTERFACE * SetIClassfCG( CG_OBJECT_INTERFACE *pCG )
  837. {
  838. return (pIClassfCG = pCG);
  839. }
  840. CG_OBJECT_INTERFACE * GetIClassfCG()
  841. {
  842. return pIClassfCG;
  843. }
  844. PNAME SetInterfaceName( PNAME pIN )
  845. {
  846. return (pInterfaceName = pIN);
  847. }
  848. PNAME GetInterfaceName()
  849. {
  850. return pInterfaceName;
  851. }
  852. OPTIM_OPTION SetOptimOption( OPTIM_OPTION OpO )
  853. {
  854. return (OptimOption = OpO);
  855. }
  856. OPTIM_OPTION GetOptimOption()
  857. {
  858. return OptimOption;
  859. }
  860. PROCNUM SetProcNum( unsigned short n )
  861. {
  862. return (CurrentProcNum = n);
  863. }
  864. PROCNUM GetProcNum()
  865. {
  866. return CurrentProcNum;
  867. }
  868. PROCNUM SetVarNum( unsigned short n )
  869. {
  870. return (CurrentVarNum = n);
  871. }
  872. PROCNUM GetVarNum()
  873. {
  874. return CurrentVarNum;
  875. }
  876. RPC_FLAGS SetRpcFlags( RPC_FLAGS F )
  877. {
  878. return (RpcFlags = F);
  879. }
  880. RPC_FLAGS GetRpcFlags()
  881. {
  882. return RpcFlags;
  883. }
  884. void SetAllocFreeRtnNamePair(
  885. PNAME pAllocN,
  886. PNAME pFreeN )
  887. {
  888. pAllocRtnName = pAllocN;
  889. pFreeRtnName = pFreeN;
  890. }
  891. PNAME GetAllocRtnName()
  892. {
  893. return pAllocRtnName;
  894. }
  895. PNAME GetFreeRtnName()
  896. {
  897. return pFreeRtnName;
  898. }
  899. long LookupRundownRoutine( char * pName )
  900. {
  901. long RetCode;
  902. if ( ! strcmp(pName,"") )
  903. RetCode = INVALID_RUNDOWN_ROUTINE_INDEX;
  904. else
  905. RetCode = pContextIndexMgr->Lookup( pName );
  906. return RetCode;
  907. }
  908. BOOL HasRundownRoutines()
  909. {
  910. return ! pContextIndexMgr->IsEmpty();
  911. }
  912. BOOL HasExprEvalRoutines()
  913. {
  914. return ! pExprEvalIndexMgr->IsEmpty();
  915. }
  916. BOOL HasExprFormatString()
  917. {
  918. return ( NULL != pExprFrmtStrIndexMgr );
  919. }
  920. BOOL HasQuintupleRoutines()
  921. {
  922. return GetQuintupleDictionary()->GetCount() != 0;
  923. }
  924. BOOL HasQuadrupleRoutines()
  925. {
  926. return GetQuadrupleDictionary()->GetCount() != 0;
  927. }
  928. BOOL HasCsTypes()
  929. {
  930. return CsTypes.NonNull();
  931. }
  932. void OutputRundownRoutineTable();
  933. void OutputExprEvalRoutineTable();
  934. void OutputOldExprEvalRoutine(EXPR_EVAL_CONTEXT *pExprEvalContext);
  935. void OutputRegisteredExprEvalRoutines();
  936. void OutputQuintupleTable();
  937. void OutputTransmitAsQuintuple( void * pQContext );
  938. void OutputRepAsQuintuple( void * pQContext );
  939. void OutputQuintupleRoutines();
  940. void OutputQuadrupleTable();
  941. void OutputCsRoutineTables();
  942. void OutputSimpleRoutineTable( CCB_RTN_INDEX_MGR * pIndexMgr,
  943. char * TypeName,
  944. char * VarName );
  945. void OutputExpressionFormatString();
  946. void OutputExternsToMultipleInterfaceTables();
  947. void OutputMultipleInterfaceTables();
  948. CCB_RTN_INDEX_MGR * GetGenericIndexMgr()
  949. {
  950. return pGenericIndexMgr;
  951. }
  952. CCB_RTN_INDEX_MGR * GetExprEvalIndexMgr()
  953. {
  954. return pExprEvalIndexMgr;
  955. }
  956. CCB_EXPR_INDEX_MGR * GetExprFrmtStrIndexMgr()
  957. {
  958. if (pExprFrmtStrIndexMgr == NULL )
  959. {
  960. pExprFrmtStrIndexMgr = new CCB_EXPR_INDEX_MGR();
  961. }
  962. return pExprFrmtStrIndexMgr;
  963. }
  964. CCB_RTN_INDEX_MGR * GetTransmitAsIndexMgr()
  965. {
  966. return pTransmitAsIndexMgr;
  967. }
  968. CCB_RTN_INDEX_MGR * GetRepAsIndexMgr()
  969. {
  970. return pRepAsIndexMgr;
  971. }
  972. long LookupBindingRoutine( char * pName )
  973. {
  974. return pGenericIndexMgr->Lookup( pName );
  975. }
  976. void OutputBindingRoutines();
  977. void OutputMallocAndFreeStruct();
  978. BOOL HasBindingRoutines( CG_HANDLE * pImplicitHandle );
  979. RESOURCE_DICT_DATABASE * SetResDictDatabase( RESOURCE_DICT_DATABASE * p )
  980. {
  981. return ( pResDictDatabase = p );
  982. }
  983. RESOURCE_DICT_DATABASE * GetResDictDatabase()
  984. {
  985. return pResDictDatabase;
  986. }
  987. void GetListOfLocalResources( ITERATOR& Iter )
  988. {
  989. GetResDictDatabase()->
  990. GetLocalResourceDict()->
  991. GetListOfResources( Iter );
  992. }
  993. void GetListOfParamResources( ITERATOR& Iter )
  994. {
  995. GetResDictDatabase()->
  996. GetParamResourceDict()->
  997. GetListOfResources( Iter );
  998. }
  999. void GetListOfTransientResources( ITERATOR& Iter )
  1000. {
  1001. GetResDictDatabase()->
  1002. GetTransientResourceDict()->
  1003. GetListOfResources( Iter );
  1004. }
  1005. RESOURCE * GetParamResource( PNAME p )
  1006. {
  1007. return GetResDictDatabase()->
  1008. GetParamResourceDict()->Search( p );
  1009. }
  1010. RESOURCE * GetLocalResource( PNAME p )
  1011. {
  1012. return GetResDictDatabase()->
  1013. GetLocalResourceDict()->Search( p );
  1014. }
  1015. RESOURCE * GetTransientResource( PNAME pResName )
  1016. {
  1017. return
  1018. pResDictDatabase->
  1019. GetTransientResourceDict()->Search(
  1020. pResName );
  1021. }
  1022. RESOURCE * GetGlobalResource( PNAME p )
  1023. {
  1024. return GetResDictDatabase()->
  1025. GetLocalResourceDict()->Search( p );
  1026. }
  1027. RESOURCE * AddParamResource( PNAME p, node_skl *pT )
  1028. {
  1029. return DoAddResource(
  1030. GetResDictDatabase()->
  1031. GetParamResourceDict(), p, pT );
  1032. }
  1033. RESOURCE * AddTransientResource( PNAME p, node_skl *pT )
  1034. {
  1035. return DoAddResource(
  1036. GetResDictDatabase()->
  1037. GetTransientResourceDict(), p, pT );
  1038. }
  1039. void ClearTransientResourceDict()
  1040. {
  1041. pResDictDatabase->
  1042. GetTransientResourceDict()->Clear();
  1043. }
  1044. void ClearParamResourceDict()
  1045. {
  1046. pResDictDatabase->
  1047. GetParamResourceDict()->Clear();
  1048. }
  1049. RESOURCE * DoAddResource( RESOURCE_DICT * pResDict,
  1050. PNAME pName,
  1051. node_skl * pType
  1052. );
  1053. //
  1054. // Get one of the standard resources.
  1055. //
  1056. RESOURCE * GetStandardResource( STANDARD_RES_ID ResID );
  1057. //
  1058. // This routine sets the names of the stub runtime interface routines.
  1059. // This routine can take any parameter which is 0, and will not overwrite
  1060. // the runtime routine name for that functionality, allowing the caller to
  1061. // selectively change the runtime routine for a functionality easily.
  1062. //
  1063. void SetRuntimeRtnNames(
  1064. PNAME pGBRtnName,
  1065. PNAME pSRRtnName,
  1066. PNAME pFBRtnName )
  1067. {
  1068. if( pGBRtnName ) pGetBufferRtnName = pGBRtnName;
  1069. if( pSRRtnName ) pSendReceiveRtnName = pSRRtnName;
  1070. if( pFBRtnName ) pFreeBufferRtnName = pFBRtnName;
  1071. }
  1072. PNAME GetGetBufferRtnName()
  1073. {
  1074. return pGetBufferRtnName;
  1075. }
  1076. PNAME GetSendReceiveRtnName()
  1077. {
  1078. return pSendReceiveRtnName;
  1079. }
  1080. PNAME GetFreeBufferRtnName()
  1081. {
  1082. return pFreeBufferRtnName;
  1083. }
  1084. expr_node * SetSourceExpression( expr_node * pSrcExpr )
  1085. {
  1086. return (ExprInfo.SetSrcExpression( pSrcExpr ) );
  1087. }
  1088. expr_node * GetSourceExpression()
  1089. {
  1090. return ExprInfo.GetSrcExpression();
  1091. }
  1092. expr_node * SetDestExpression( expr_node * pDestExpr )
  1093. {
  1094. return (ExprInfo.SetDestExpression( pDestExpr ) );
  1095. }
  1096. expr_node * GetDestExpression()
  1097. {
  1098. return ExprInfo.GetDestExpression();
  1099. }
  1100. node_skl * RegisterGenericHandleType( node_skl * pType )
  1101. {
  1102. return pGenericHandleRegistry->Register( pType );
  1103. }
  1104. node_skl * RegisterContextHandleType( node_skl * pType )
  1105. {
  1106. return pContextHandleRegistry->Register( pType );
  1107. }
  1108. node_skl * RegisterRepAsWireType( node_skl * pType )
  1109. {
  1110. return pRepAsWireTypeRegistry->Register( pType );
  1111. }
  1112. node_skl * RegisterPresentedType( node_skl * pType )
  1113. {
  1114. return pPresentedTypeRegistry->Register( pType );
  1115. }
  1116. node_skl * RegisterExprEvalRoutine( node_skl * pType )
  1117. {
  1118. return pExprEvalRoutineRegistry->Register( pType );
  1119. }
  1120. node_skl * RegisterQuintuple( void * pContext )
  1121. {
  1122. return pQuintupleRegistry->Register( (node_skl *)pContext );
  1123. }
  1124. QuintupleDict * GetQuintupleDictionary()
  1125. {
  1126. return pQuintupleDictionary;
  1127. }
  1128. QuadrupleDict * GetQuadrupleDictionary()
  1129. {
  1130. return pQuadrupleDictionary;
  1131. }
  1132. RepAsPadExprDict * GetRepAsPadExprDict()
  1133. {
  1134. return pRepAsPadExprDictionary;
  1135. }
  1136. RepAsSizeDict * GetRepAsSizeDict()
  1137. {
  1138. return pRepAsSizeDictionary;
  1139. }
  1140. node_skl * RegisterSizingRoutineForType( node_skl * pType )
  1141. {
  1142. return pSizingRoutineRegistry->Register( pType );
  1143. }
  1144. node_skl * RegisterMarshallRoutineForType( node_skl * pType )
  1145. {
  1146. return pMarshallRoutineRegistry->Register( pType );
  1147. }
  1148. node_skl * RegisterUnMarshallRoutineForType( node_skl * pType )
  1149. {
  1150. return pUnMarshallRoutineRegistry->Register( pType );
  1151. }
  1152. node_skl * RegisterMemorySizingRoutineForType( node_skl * pType )
  1153. {
  1154. return pMemorySizingRoutineRegistry->Register( pType );
  1155. }
  1156. node_skl * RegisterFreeRoutineForType( node_skl * pType )
  1157. {
  1158. return pFreeRoutineRegistry->Register( pType );
  1159. }
  1160. node_skl * RegisterTypeAlignSize( TYPE_ENCODE_INFO * pTEInfo )
  1161. {
  1162. // cheat by casting.
  1163. return pTypeAlignSizeRegistry->Register(
  1164. (node_skl *) pTEInfo );
  1165. }
  1166. node_skl * RegisterTypeEncode( TYPE_ENCODE_INFO * pTEInfo )
  1167. {
  1168. // cheat by casting.
  1169. return pTypeEncodeRegistry->Register(
  1170. (node_skl *) pTEInfo );
  1171. }
  1172. node_skl * RegisterTypeDecode( TYPE_ENCODE_INFO * pTEInfo )
  1173. {
  1174. return pTypeDecodeRegistry->Register(
  1175. (node_skl *) pTEInfo );
  1176. }
  1177. node_skl * RegisterTypeFree( TYPE_ENCODE_INFO * pTEInfo )
  1178. {
  1179. return pTypeFreeRegistry->Register(
  1180. (node_skl *) pTEInfo );
  1181. }
  1182. ulong RegisterPickledType( CG_TYPE_ENCODE *type )
  1183. {
  1184. return pPickledTypeList->Insert( type );
  1185. }
  1186. node_skl * RegisterEncodeDecodeProc( CG_ENCODE_PROC * pProc )
  1187. {
  1188. return pProcEncodeDecodeRegistry->Register(
  1189. (node_skl *)pProc );
  1190. }
  1191. node_skl * RegisterCallAsRoutine( node_proc * pProc )
  1192. {
  1193. return pCallAsRoutineRegistry->Register( pProc );
  1194. }
  1195. TREGISTRY * GetRecPointerFixupRegistry()
  1196. {
  1197. return pRecPointerFixupRegistry;
  1198. }
  1199. short GetListOfRecPointerFixups( ITERATOR& I )
  1200. {
  1201. return pRecPointerFixupRegistry->GetListOfTypes( I );
  1202. }
  1203. void RegisterRecPointerForFixup(
  1204. CG_NDR * pNdr,
  1205. long AbsoluteOffset );
  1206. void FixupRecPointers();
  1207. unsigned short RegisterNotify( CG_PROC * pNotifyProc )
  1208. {
  1209. return (unsigned short)
  1210. ITERATOR_INSERT( NotifyProcList, pNotifyProc );
  1211. }
  1212. BOOL GetListOfNotifyTableEntries( ITERATOR& I )
  1213. {
  1214. I.Discard();
  1215. I.Clone(&NotifyProcList);
  1216. return I.NonNull();
  1217. }
  1218. short GetListOfGenHdlTypes( ITERATOR& I )
  1219. {
  1220. return pGenericHandleRegistry->GetListOfTypes( I );
  1221. }
  1222. short GetListOfCtxtHdlTypes( ITERATOR& I )
  1223. {
  1224. return pContextHandleRegistry->GetListOfTypes( I );
  1225. }
  1226. short GetListOfRepAsWireTypes( ITERATOR& I )
  1227. {
  1228. return pRepAsWireTypeRegistry->GetListOfTypes( I );
  1229. }
  1230. short GetListOfPresentedTypes( ITERATOR& I )
  1231. {
  1232. return pPresentedTypeRegistry->GetListOfTypes( I );
  1233. }
  1234. short GetListOfExprEvalRoutines( ITERATOR& I )
  1235. {
  1236. return pExprEvalRoutineRegistry->GetListOfTypes( I );
  1237. }
  1238. short GetListOfQuintuples( ITERATOR& I )
  1239. {
  1240. return pQuintupleRegistry->GetListOfTypes( I );
  1241. }
  1242. short GetListOfSizingRoutineTypes( ITERATOR& I )
  1243. {
  1244. return pSizingRoutineRegistry->GetListOfTypes( I );
  1245. }
  1246. short GetListOfMarshallingRoutineTypes( ITERATOR& I )
  1247. {
  1248. return pMarshallRoutineRegistry->GetListOfTypes( I );
  1249. }
  1250. short GetListOfUnMarshallingRoutineTypes( ITERATOR& I )
  1251. {
  1252. return pUnMarshallRoutineRegistry->GetListOfTypes( I );
  1253. }
  1254. short GetListOfMemorySizingRoutineTypes( ITERATOR& I )
  1255. {
  1256. return pMemorySizingRoutineRegistry->GetListOfTypes( I );
  1257. }
  1258. short GetListOfFreeRoutineTypes( ITERATOR& I )
  1259. {
  1260. return pFreeRoutineRegistry->GetListOfTypes( I );
  1261. }
  1262. short GetListOfTypeAlignSizeTypes( ITERATOR& I )
  1263. {
  1264. return pTypeAlignSizeRegistry->GetListOfTypes( I );
  1265. }
  1266. short GetListOfTypeEncodeTypes( ITERATOR& I )
  1267. {
  1268. return pTypeEncodeRegistry->GetListOfTypes( I );
  1269. }
  1270. short GetListOfTypeDecodeTypes( ITERATOR& I )
  1271. {
  1272. return pTypeDecodeRegistry->GetListOfTypes( I );
  1273. }
  1274. short GetListOfTypeFreeTypes( ITERATOR& I )
  1275. {
  1276. return pTypeFreeRegistry->GetListOfTypes( I );
  1277. }
  1278. IndexedList & GetListOfPickledTypes()
  1279. {
  1280. return *pPickledTypeList;
  1281. }
  1282. short GetListOfEncodeDecodeProcs( ITERATOR& I )
  1283. {
  1284. return pProcEncodeDecodeRegistry->GetListOfTypes(I);
  1285. }
  1286. short GetListOfCallAsRoutines( ITERATOR& I )
  1287. {
  1288. return pCallAsRoutineRegistry->GetListOfTypes( I );
  1289. }
  1290. //
  1291. // miscellaneous methods.
  1292. //
  1293. void InitForNewProc(
  1294. PROCNUM PNum,
  1295. RPC_FLAGS Flags,
  1296. PNAME pAllocN,
  1297. PNAME pFreeN,
  1298. RESOURCE_DICT_DATABASE * pRDDB )
  1299. {
  1300. SetProcNum( ( unsigned short ) PNum );
  1301. SetRpcFlags( Flags );
  1302. SetAllocFreeRtnNamePair( pAllocN, pFreeN );
  1303. SetResDictDatabase( pRDDB );
  1304. }
  1305. //
  1306. // This method generates a mangled name out of the interface and
  1307. // version number. The user provided string is appended to the
  1308. // mangled part. The memory area is allocated by this routine using
  1309. // new, but freed by the caller.
  1310. //
  1311. char * GenMangledName();
  1312. //
  1313. // set stub descriptor resource.
  1314. //
  1315. RESOURCE * SetStubDescResource();
  1316. RESOURCE * GetStubDescResource()
  1317. {
  1318. return pStubDescResource;
  1319. }
  1320. //
  1321. // Set and get the format string.
  1322. //
  1323. void SetFormatString( FORMAT_STRING * pFS )
  1324. {
  1325. pFormatString = pFS;
  1326. }
  1327. FORMAT_STRING * GetFormatString()
  1328. {
  1329. return pFormatString;
  1330. }
  1331. void SetProcFormatString( FORMAT_STRING * pFS )
  1332. {
  1333. pProcFormatString = pFS;
  1334. }
  1335. FORMAT_STRING * GetProcFormatString()
  1336. {
  1337. return pProcFormatString;
  1338. }
  1339. void SetExprFormatString( FORMAT_STRING * pFS )
  1340. {
  1341. pExprFormatString = pFS;
  1342. }
  1343. FORMAT_STRING * GetExprFormatString()
  1344. {
  1345. return pExprFormatString;
  1346. }
  1347. //
  1348. // Set and get the code generation phase.
  1349. //
  1350. void SetCodeGenPhase( CGPHASE phase )
  1351. {
  1352. CodeGenPhase = phase;
  1353. }
  1354. CGPHASE GetCodeGenPhase()
  1355. {
  1356. return CodeGenPhase;
  1357. }
  1358. //
  1359. // Set and get the code generation side.
  1360. //
  1361. void SetCodeGenSide( CGSIDE side )
  1362. {
  1363. CodeGenSide = side;
  1364. }
  1365. CGSIDE GetCodeGenSide()
  1366. {
  1367. return CodeGenSide;
  1368. }
  1369. //
  1370. // Set and Get current code generation node context.
  1371. //
  1372. CG_NDR * SetCGNodeContext( CG_NDR * pNewCGNodeContext )
  1373. {
  1374. CG_NDR * pOldCGNodeContext;
  1375. pOldCGNodeContext = pCGNodeContext;
  1376. pCGNodeContext = pNewCGNodeContext;
  1377. return pOldCGNodeContext;
  1378. }
  1379. CG_NDR * GetCGNodeContext()
  1380. {
  1381. return pCGNodeContext;
  1382. }
  1383. //
  1384. // Region stuff
  1385. //
  1386. CG_FIELD * GetCurrentRegionField()
  1387. {
  1388. return pCurrentRegionField;
  1389. }
  1390. CG_FIELD * StartRegion()
  1391. {
  1392. CG_FIELD *pOldRegionField = pCurrentRegionField;
  1393. pCurrentRegionField = (CG_FIELD*) GetLastPlaceholderClass();
  1394. return pOldRegionField;
  1395. }
  1396. void EndRegion( CG_FIELD *pOldRegionField )
  1397. {
  1398. pCurrentRegionField = pOldRegionField;
  1399. }
  1400. //
  1401. // Set and Get current placeholder class.
  1402. //
  1403. CG_NDR * SetLastPlaceholderClass( CG_NDR * pNew )
  1404. {
  1405. CG_NDR * pOld;
  1406. pOld = pPlaceholderClass;
  1407. pPlaceholderClass = pNew;
  1408. return pOld;
  1409. }
  1410. CG_NDR * GetLastPlaceholderClass()
  1411. {
  1412. return pPlaceholderClass;
  1413. }
  1414. void SetCurrentParam( CG_PARAM * pCurrent )
  1415. {
  1416. pCurrentParam = pCurrent;
  1417. }
  1418. CG_PARAM * GetCurrentParam()
  1419. {
  1420. return pCurrentParam;
  1421. }
  1422. RESOURCE * SetPtrToPtrInBuffer( RESOURCE * p)
  1423. {
  1424. return (PtrToPtrInBuffer = p);
  1425. }
  1426. RESOURCE * GetPtrToPtrInBuffer()
  1427. {
  1428. return PtrToPtrInBuffer;
  1429. }
  1430. void SetImbedingMemSize( long Size )
  1431. {
  1432. ImbedingMemSize = Size;
  1433. }
  1434. long GetImbedingMemSize()
  1435. {
  1436. return ImbedingMemSize;
  1437. }
  1438. void SetImbedingBufSize( long Size )
  1439. {
  1440. ImbedingBufSize = Size;
  1441. }
  1442. long GetImbedingBufSize()
  1443. {
  1444. return ImbedingBufSize;
  1445. }
  1446. void SetInterpreterOutSize( long Size )
  1447. {
  1448. InterpreterOutSize = Size;
  1449. }
  1450. long GetInterpreterOutSize()
  1451. {
  1452. return InterpreterOutSize;
  1453. }
  1454. PNAME GenTRNameOffLastParam( char * Prefix );
  1455. // methods for generating typeinfo
  1456. void SetCreateTypeLib(ICreateTypeLib * p)
  1457. {
  1458. pCreateTypeLib = p;
  1459. }
  1460. void SetCreateTypeInfo(ICreateTypeInfo * p)
  1461. {
  1462. pCreateTypeInfo = p;
  1463. }
  1464. ICreateTypeLib * GetCreateTypeLib()
  1465. {
  1466. return pCreateTypeLib;
  1467. }
  1468. ICreateTypeInfo * GetCreateTypeInfo()
  1469. {
  1470. return pCreateTypeInfo;
  1471. }
  1472. void SetDllName(char * sz)
  1473. {
  1474. szDllName = sz;
  1475. }
  1476. char * GetDllName()
  1477. {
  1478. return szDllName;
  1479. }
  1480. void SetInDispinterface(BOOL f)
  1481. {
  1482. fInDispinterface = f;
  1483. }
  1484. BOOL IsInDispinterface()
  1485. {
  1486. return fInDispinterface;
  1487. }
  1488. BOOL SaveVTableLayOutInfo(
  1489. CG_CLASS* pIf,
  1490. ICreateTypeInfo* pInfo
  1491. )
  1492. {
  1493. BOOL fRet = FALSE;
  1494. VTableLayOutInfo* pNew = new VTableLayOutInfo(pIf, pInfo);
  1495. if (pNew)
  1496. {
  1497. fRet = (VTableLayOutList.Insert(pNew) == STATUS_OK);
  1498. if (!fRet)
  1499. {
  1500. delete pNew;
  1501. }
  1502. }
  1503. return fRet;
  1504. }
  1505. BOOL GetNextVTableLayOutInfo (
  1506. CG_CLASS** ppIf,
  1507. ICreateTypeInfo** ppInfo
  1508. )
  1509. {
  1510. VTableLayOutInfo* pTmp = 0;
  1511. if (VTableLayOutList.GetNext((void**)&pTmp) == STATUS_OK)
  1512. {
  1513. *ppIf = pTmp->pLayOutNode;
  1514. *ppInfo = pTmp->pTypeInfo;
  1515. delete pTmp;
  1516. return TRUE;
  1517. }
  1518. return FALSE;
  1519. }
  1520. void InitVTableLayOutList()
  1521. {
  1522. VTableLayOutList.Init();
  1523. }
  1524. void DiscardVTableLayOutList()
  1525. {
  1526. VTableLayOutList.Discard();
  1527. }
  1528. void SetTypePicklingInfoEmitted()
  1529. {
  1530. fTypePicklingInfoEmitted = 1;
  1531. }
  1532. BOOL HasTypePicklingInfoBeenEmitted()
  1533. {
  1534. return (BOOL) fTypePicklingInfoEmitted;
  1535. }
  1536. GenNdr64Format * GetNdr64Format()
  1537. {
  1538. return pNdr64Format;
  1539. }
  1540. void SetNdr64Format( GenNdr64Format * pNewFormat )
  1541. {
  1542. pNdr64Format = pNewFormat;
  1543. }
  1544. };
  1545. #endif // __CCB_HXX__