Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

782 lines
21 KiB

  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1989-1999 Microsoft Corporation
  3. Module Name:
  4. output.cxx
  5. Abstract:
  6. Low level output routines for midl.
  7. Notes:
  8. History:
  9. Sep-18-1993 VibhasC Created.
  10. ----------------------------------------------------------------------------*/
  11. #pragma warning ( disable : 4127 )
  12. /****************************************************************************
  13. * include files
  14. ***************************************************************************/
  15. #include "becls.hxx"
  16. #pragma hdrstop
  17. #if 0
  18. Notes
  19. A few general rules followed throughout the file.
  20. 1. Never emit tab other than thru the stream.
  21. 2. Never emit a new line other than thru the stream.
  22. 3. Emitting a new line is the responsibility of the entity that wants
  23. itself to be emitted on a new line. Therefore, say each local
  24. variable in the stub needs to be on a new line, then the routine
  25. responsible for emitting the local variable will be responsible
  26. for setting the new line.
  27. #endif // 0
  28. /****************************************************************************
  29. * local definitions
  30. ***************************************************************************/
  31. #define NDR_UP_DECISION_RTN_NAME "NdrSH_UPDecision"
  32. #define NDR_TLUP_DECISION_RTN_NAME "NdrSH_TLUPDecision"
  33. #define NDR_TLUP_DECISION_RTN_B_ONLY "NdrSH_TLUPDecisionBuffer"
  34. #define NDR_IF_ALLOC_RTN_NAME "NdrSH_IfAlloc"
  35. #define NDR_IF_ALLOC_REF_RTN_NAME "NdrSH_IfAllocRef"
  36. #define NDR_IF_ALLOC_COPY_RTN_NAME "NdrSH_IfAllocCopy"
  37. #define NDR_IF_ALLOC_SET_RTN_NAME "NdrSH_IfAllocSet"
  38. #define NDR_IF_COPY_RTN_NAME "NdrSH_IfCopy"
  39. #define NDR_COPY_RTN_NAME "NdrSH_Copy"
  40. #define NDR_CONF_STRING_HDR_MARSHALL "NdrSH_MarshConfStringHdr"
  41. #define NDR_CONF_STRING_HDR_UNMARSHALL "NdrSH_UnMarshConfStringHdr"
  42. #define NDR_C_CTXT_HDL_MARSHALL "NdrSH_MarshCCtxtHdl"
  43. #define NDR_C_CTXT_HDL_UNMARSHALL "NdrSH_UnMarshCCtxtHdl"
  44. #define NDR_S_CTXT_HDL_MARSHALL "NdrSH_MarshSCtxtHdl"
  45. #define NDR_S_CTXT_HDL_UNMARSHALL "NdrSH_UnMarshSCtxtHdl"
  46. #define NDR_IF_FREE_RTN_NAME "NdrSH_IfFree"
  47. #define NDR_CONF_STR_M_RTN_NAME "NdrSH_ConfStringMarshall"
  48. #define NDR_CONF_STR_UN_RTN_NAME "NdrSH_ConfStringUnMarshall"
  49. #define NDR_MAP_COMM_FAULT_RTN_NAME "NdrMapCommAndFaultStatus"
  50. /****************************************************************************
  51. * local data
  52. ***************************************************************************/
  53. /****************************************************************************
  54. * externs
  55. ***************************************************************************/
  56. void
  57. Out_UPDecision(
  58. CCB * pCCB,
  59. expr_node * pPtrInBuffer,
  60. expr_node * pPtrInMemory )
  61. {
  62. expr_proc_call * pProc = new expr_proc_call( NDR_UP_DECISION_RTN_NAME );
  63. expr_node * pStubMsg= pCCB->GetStandardResource( ST_RES_STUB_MESSAGE_VARIABLE );
  64. pStubMsg = MakeAddressExpressionNoMatterWhat( pStubMsg );
  65. pProc->SetParam( new expr_param( pStubMsg ));
  66. pPtrInBuffer = MakeRefExprOutOfDeref( pPtrInBuffer );
  67. pProc->SetParam( new expr_param( pPtrInBuffer ) );
  68. pProc->SetParam( new expr_param( MakeCastExprPtrToPtrToUChar(pPtrInMemory) ) );
  69. Out_If( pCCB, pProc );
  70. }
  71. void
  72. Out_TLUPDecision(
  73. CCB * pCCB,
  74. expr_node * ,
  75. expr_node * pPtrInMemory )
  76. {
  77. expr_proc_call * pProc = new expr_proc_call( NDR_TLUP_DECISION_RTN_NAME );
  78. expr_node * pStubMsg= pCCB->GetStandardResource( ST_RES_STUB_MESSAGE_VARIABLE );
  79. pStubMsg = MakeAddressExpressionNoMatterWhat( pStubMsg );
  80. pProc->SetParam( new expr_param( pStubMsg ) );
  81. pProc->SetParam( new expr_param( MakeCastExprPtrToPtrToUChar( pPtrInMemory) ) );
  82. Out_If( pCCB, pProc );
  83. }
  84. void
  85. Out_TLUPDecisionBufferOnly(
  86. CCB * pCCB,
  87. expr_node * ,
  88. expr_node * pPtrInMemory )
  89. {
  90. expr_proc_call * pProc = new expr_proc_call( NDR_TLUP_DECISION_RTN_B_ONLY );
  91. expr_node * pStubMsg= pCCB->GetStandardResource( ST_RES_STUB_MESSAGE_VARIABLE );
  92. pStubMsg = MakeAddressExpressionNoMatterWhat( pStubMsg );
  93. pProc->SetParam( new expr_param( pStubMsg ) );
  94. pProc->SetParam( new expr_param( MakeCastExprPtrToPtrToUChar( pPtrInMemory ) ) );
  95. Out_If( pCCB, pProc );
  96. }
  97. void
  98. Out_IfAlloc(
  99. CCB * pCCB,
  100. expr_node * pPtrInMemory,
  101. expr_node * ,
  102. expr_node * pExprCount )
  103. {
  104. expr_proc_call * pProc = new expr_proc_call( NDR_IF_ALLOC_RTN_NAME );
  105. expr_node * pStubMsg= pCCB->GetStandardResource( ST_RES_STUB_MESSAGE_VARIABLE );
  106. pStubMsg = MakeAddressExpressionNoMatterWhat( pStubMsg );
  107. pProc->SetParam( new expr_param( pStubMsg ));
  108. pPtrInMemory = MakeAddressExpressionNoMatterWhat( pPtrInMemory );
  109. pProc->SetParam( new expr_param( MakeCastExprPtrToPtrToUChar( pPtrInMemory ) ));
  110. pProc->SetParam( new expr_param( pExprCount ));
  111. pCCB->GetStream()->NewLine();
  112. pProc->PrintCall( pCCB->GetStream(), 0, 0 );
  113. }
  114. void
  115. Out_If_IfAlloc(
  116. CCB * pCCB,
  117. expr_node * pPtrInMemory,
  118. expr_node * ,
  119. expr_node * pExprCount )
  120. {
  121. expr_proc_call * pProc = new expr_proc_call( NDR_IF_ALLOC_RTN_NAME );
  122. expr_node * pStubMsg= pCCB->GetStandardResource( ST_RES_STUB_MESSAGE_VARIABLE );
  123. pStubMsg = MakeAddressExpressionNoMatterWhat( pStubMsg );
  124. pProc->SetParam( new expr_param( pStubMsg ));
  125. pPtrInMemory = MakeAddressExpressionNoMatterWhat( pPtrInMemory );
  126. pProc->SetParam( new expr_param( MakeCastExprPtrToPtrToUChar( pPtrInMemory ) ));
  127. pProc->SetParam( new expr_param( pExprCount ));
  128. pCCB->GetStream()->NewLine();
  129. Out_If( pCCB, pProc );
  130. // pProc->PrintCall( pCCB->GetStream(), 0, 0 );
  131. }
  132. void
  133. Out_If_IfAllocRef(
  134. CCB * pCCB,
  135. expr_node * pPtrInMemory,
  136. expr_node * ,
  137. expr_node * pExprCount )
  138. {
  139. expr_proc_call * pProc = new expr_proc_call( NDR_IF_ALLOC_REF_RTN_NAME );
  140. expr_node * pStubMsg= pCCB->GetStandardResource( ST_RES_STUB_MESSAGE_VARIABLE );
  141. pStubMsg = MakeAddressExpressionNoMatterWhat( pStubMsg );
  142. pProc->SetParam( new expr_param( pStubMsg ));
  143. pPtrInMemory = MakeAddressExpressionNoMatterWhat( pPtrInMemory );
  144. pProc->SetParam( new expr_param( MakeCastExprPtrToPtrToUChar( pPtrInMemory ) ));
  145. pProc->SetParam( new expr_param( pExprCount ));
  146. pCCB->GetStream()->NewLine();
  147. Out_If( pCCB, pProc );
  148. // pProc->PrintCall( pCCB->GetStream(), 0, 0 );
  149. }
  150. void
  151. Out_Alloc(
  152. CCB * pCCB,
  153. expr_node * pPtrInMemory,
  154. expr_node * ,
  155. expr_node * pExprCount )
  156. {
  157. expr_proc_call * pProc;
  158. expr_node * pExpr;
  159. if( pCCB->MustCheckAllocationError() )
  160. {
  161. expr_node * pStubMsg
  162. = pCCB->GetStandardResource( ST_RES_STUB_MESSAGE_VARIABLE );
  163. pStubMsg = MakeAddressExpressionNoMatterWhat( pStubMsg );
  164. pProc = new expr_proc_call( ENGINE_CHECKED_ALLOC_RTN_NAME );
  165. pProc->SetParam( new expr_param( pStubMsg ) );
  166. }
  167. else
  168. pProc = new expr_proc_call( STUB_MSG_ALLOCATE_RTN_NAME );
  169. pProc->SetParam( new expr_param( pExprCount ));
  170. pExpr = new expr_assign( pPtrInMemory, pProc );
  171. pCCB->GetStream()->NewLine();
  172. pExpr->PrintCall( pCCB->GetStream(), 0, 0 );
  173. }
  174. void
  175. Out_IfAllocSet(
  176. CCB * pCCB,
  177. expr_node * pPtrInMemory,
  178. expr_node * ,
  179. expr_node * pExprCount )
  180. {
  181. expr_proc_call * pProc = new expr_proc_call( NDR_IF_ALLOC_SET_RTN_NAME );
  182. expr_node * pStubMsg= pCCB->GetStandardResource( ST_RES_STUB_MESSAGE_VARIABLE );
  183. pStubMsg = MakeAddressExpressionNoMatterWhat( pStubMsg );
  184. pProc->SetParam( new expr_param( pStubMsg ));
  185. pProc->SetParam( new expr_param( MakeCastExprPtrToPtrToUChar( pPtrInMemory )));
  186. pProc->SetParam( new expr_param( pExprCount ));
  187. pCCB->GetStream()->NewLine();
  188. pProc->PrintCall( pCCB->GetStream(), 0, 0 );
  189. }
  190. void
  191. Out_AllocSet(
  192. CCB * pCCB,
  193. expr_node * pPtrInMemory,
  194. expr_node * pBuffer,
  195. expr_node * pExprCount )
  196. {
  197. expr_proc_call * pProc = new expr_proc_call( MIDL_MEMSET_RTN_NAME );
  198. expr_node * pExpr;
  199. Out_Alloc( pCCB, pPtrInMemory, pBuffer, pExprCount );
  200. pExpr = new expr_u_deref( pPtrInMemory );
  201. pProc->SetParam( new expr_param( pExpr ) );
  202. pProc->SetParam( new expr_param( pExprCount ) );
  203. pProc->SetParam( new expr_param( new expr_constant(0L) ) );
  204. pCCB->GetStream()->NewLine();
  205. pProc->PrintCall( pCCB->GetStream(), 0, 0 );
  206. }
  207. void
  208. Out_IfCopy(
  209. CCB * pCCB,
  210. expr_node * pPtrInMemory,
  211. expr_node * ,
  212. expr_node * pExprCount )
  213. {
  214. expr_proc_call * pProc = new expr_proc_call( NDR_IF_COPY_RTN_NAME );
  215. expr_node * pStubMsg= pCCB->GetStandardResource( ST_RES_STUB_MESSAGE_VARIABLE );
  216. pStubMsg = MakeAddressExpressionNoMatterWhat( pStubMsg );
  217. pProc->SetParam( new expr_param( pStubMsg ));
  218. pProc->SetParam( new expr_param( MakeCastExprPtrToPtrToUChar( pPtrInMemory ) ));
  219. pProc->SetParam( new expr_param( pExprCount ));
  220. pCCB->GetStream()->NewLine();
  221. pProc->PrintCall( pCCB->GetStream(), 0, 0 );
  222. }
  223. void
  224. Out_IfAllocCopy(
  225. CCB * pCCB,
  226. expr_node * pPtrInMemory,
  227. expr_node * ,
  228. expr_node * pExprCount )
  229. {
  230. expr_proc_call * pProc = new expr_proc_call( NDR_IF_ALLOC_COPY_RTN_NAME );
  231. expr_node * pStubMsg= pCCB->GetStandardResource( ST_RES_STUB_MESSAGE_VARIABLE );
  232. pStubMsg = MakeAddressExpressionNoMatterWhat( pStubMsg );
  233. pProc->SetParam( new expr_param( pStubMsg ));
  234. pProc->SetParam( new expr_param( MakeCastExprPtrToPtrToUChar( pPtrInMemory )));
  235. pProc->SetParam( new expr_param( pExprCount ));
  236. pCCB->GetStream()->NewLine();
  237. pProc->PrintCall( pCCB->GetStream(), 0, 0 );
  238. }
  239. void
  240. Out_Copy(
  241. CCB * pCCB,
  242. expr_node * pDest,
  243. expr_node * pSource,
  244. expr_node * pExprCount,
  245. expr_node * pAssign )
  246. {
  247. expr_proc_call * pProc = new expr_proc_call( NDR_COPY_RTN_NAME );
  248. pProc->SetParam( new expr_param( pDest ));
  249. pProc->SetParam( new expr_param( pSource ));
  250. pProc->SetParam( new expr_param( pExprCount ));
  251. pCCB->GetStream()->NewLine();
  252. if( pAssign )
  253. {
  254. Out_PlusEquals( pCCB, pAssign, pProc );
  255. }
  256. else
  257. {
  258. pProc->PrintCall( pCCB->GetStream(), 0, 0 );
  259. }
  260. }
  261. void
  262. Out_IfFree(
  263. CCB * pCCB,
  264. expr_node * pSrc )
  265. {
  266. expr_proc_call * pProc = new expr_proc_call( NDR_IF_FREE_RTN_NAME );
  267. expr_node * pStubMsg= pCCB->GetStandardResource( ST_RES_STUB_MESSAGE_VARIABLE );
  268. pStubMsg = MakeAddressExpressionNoMatterWhat( pStubMsg );
  269. pProc->SetParam( new expr_param( pStubMsg ) );
  270. pProc->SetParam( new expr_param( MakeCastExprPtrToUChar( pSrc ) ) );
  271. pCCB->GetStream()->NewLine();
  272. pProc->PrintCall( pCCB->GetStream(), 0, 0 );
  273. }
  274. void
  275. Out_ConfStringHdr(
  276. CCB * pCCB,
  277. expr_node * pDest,
  278. expr_node * pSize,
  279. expr_node * pLength,
  280. BOOL fMarsh )
  281. {
  282. PNAME pName;
  283. if( fMarsh == TRUE )
  284. {
  285. pName = NDR_CONF_STRING_HDR_MARSHALL;
  286. }
  287. else
  288. pName = NDR_CONF_STRING_HDR_UNMARSHALL;
  289. expr_proc_call * pProc = new expr_proc_call( pName );
  290. pProc->SetParam( new expr_param( pDest ) );
  291. pProc->SetParam( new expr_param( pSize ) );
  292. pProc->SetParam( new expr_param( pLength ) );
  293. pCCB->GetStream()->NewLine();
  294. pProc->PrintCall( pCCB->GetStream(), 0, 0 );
  295. }
  296. void
  297. Out_CContextMarshall(
  298. CCB * pCCB,
  299. expr_node * pDest,
  300. expr_node * pSource )
  301. {
  302. expr_proc_call * pProc = new expr_proc_call( NDR_C_CTXT_HDL_MARSHALL );
  303. expr_node * pExpr;
  304. pProc->SetParam( new expr_param( pSource ) );
  305. pProc->SetParam( new expr_param( pDest ) );
  306. pExpr = new expr_assign( pDest, pProc );
  307. pCCB->GetStream()->NewLine();
  308. pExpr->PrintCall( pCCB->GetStream(), 0, 0 );
  309. }
  310. void
  311. Out_SContextMarshall(
  312. CCB * pCCB,
  313. expr_node * pDest,
  314. expr_node * pSource,
  315. expr_node * pRDRtn )
  316. {
  317. expr_proc_call * pProc = new expr_proc_call( NDR_S_CTXT_HDL_MARSHALL );
  318. expr_node * pExpr;
  319. pProc->SetParam( new expr_param( pSource ) );
  320. pProc->SetParam( new expr_param( pDest ) );
  321. pProc->SetParam( new expr_param( pRDRtn ) );
  322. pExpr = new expr_assign( pDest, pProc );
  323. pCCB->GetStream()->NewLine();
  324. pExpr->PrintCall( pCCB->GetStream(), 0, 0 );
  325. }
  326. void
  327. Out_CContextUnMarshall(
  328. CCB * pCCB,
  329. expr_node * pDest,
  330. expr_node * pSource,
  331. expr_node * pHandle,
  332. expr_node * pDRep )
  333. {
  334. expr_proc_call * pProc = new expr_proc_call( NDR_C_CTXT_HDL_UNMARSHALL );
  335. expr_node * pExpr;
  336. pProc->SetParam( new expr_param( pDest ) );
  337. pProc->SetParam( new expr_param( pHandle ) );
  338. pProc->SetParam( new expr_param( pSource ) );
  339. pProc->SetParam( new expr_param( pDRep ) );
  340. pExpr = new expr_assign( pSource, pProc );
  341. pCCB->GetStream()->NewLine();
  342. pExpr->PrintCall( pCCB->GetStream(), 0, 0 );
  343. }
  344. void
  345. Out_SContextUnMarshall(
  346. CCB * pCCB,
  347. expr_node * pDest,
  348. expr_node * pSource,
  349. expr_node * pDRep )
  350. {
  351. expr_proc_call * pProc = new expr_proc_call( NDR_S_CTXT_HDL_UNMARSHALL );
  352. expr_node * pExpr;
  353. pProc->SetParam( new expr_param( pSource ) );
  354. pProc->SetParam( new expr_param( pDRep ) );
  355. pExpr = new expr_assign( pDest, pProc );
  356. pCCB->GetStream()->NewLine();
  357. pExpr->PrintCall( pCCB->GetStream(), 0, 0 );
  358. }
  359. void
  360. Out_RaiseException(
  361. CCB * pCCB,
  362. PNAME pExceptionName)
  363. {
  364. expr_proc_call * pProc = new expr_proc_call( "RpcRaiseException" );
  365. pProc->SetParam( new expr_param( new expr_variable( pExceptionName ) ) );
  366. pCCB->GetStream()->NewLine();
  367. pProc->PrintCall( pCCB->GetStream(), 0, 0 );
  368. }
  369. void
  370. Out_RpcTryFinally(
  371. CCB * pCCB )
  372. {
  373. ISTREAM * pStream = pCCB->GetStream();
  374. pStream->NewLine();
  375. pStream->Write( "RpcTryFinally" );
  376. pStream->IndentInc();
  377. pStream->NewLine();
  378. pStream->Write( '{' );
  379. }
  380. void
  381. Out_RpcFinally(
  382. CCB * pCCB )
  383. {
  384. ISTREAM * pStream = pCCB->GetStream();
  385. pStream->NewLine();
  386. pStream->Write( '}' );
  387. pStream->IndentDec();
  388. pStream->NewLine();
  389. pStream->Write( "RpcFinally" );
  390. pStream->IndentInc();
  391. pStream->NewLine();
  392. pStream->Write('{');
  393. }
  394. void
  395. Out_RpcEndFinally(
  396. CCB * pCCB )
  397. {
  398. ISTREAM * pStream = pCCB->GetStream();
  399. pStream->NewLine();
  400. pStream->Write( '}' );
  401. pStream->IndentDec();
  402. pStream->NewLine();
  403. pStream->Write( "RpcEndFinally" );
  404. pStream->NewLine();
  405. }
  406. void
  407. Out_RpcTryExcept( CCB * pCCB )
  408. {
  409. ISTREAM * pStream = pCCB->GetStream();
  410. pStream->NewLine();
  411. pStream->Write( "RpcTryExcept" );
  412. pStream->IndentInc();
  413. pStream->NewLine();
  414. pStream->Write( '{' );
  415. }
  416. void
  417. Out_RpcExcept(
  418. CCB * pCCB,
  419. char * pFilterString )
  420. {
  421. ISTREAM * pStream = pCCB->GetStream();
  422. pStream->NewLine();
  423. pStream->Write('}');
  424. pStream->IndentDec();
  425. pStream->NewLine();
  426. pStream->Write( "RpcExcept( " );
  427. pStream->Write( pFilterString );
  428. pStream->Write( " )" );
  429. pStream->IndentInc();
  430. pStream->NewLine();
  431. pStream->Write( '{' );
  432. }
  433. void
  434. Out_RpcEndExcept( CCB * pCCB )
  435. {
  436. ISTREAM * pStream = pCCB->GetStream();
  437. pStream->NewLine();
  438. pStream->Write( '}' );
  439. pStream->IndentDec();
  440. pStream->NewLine();
  441. pStream->Write( "RpcEndExcept" );
  442. }
  443. void
  444. Out_CallNdrMapCommAndFaultStatus(
  445. CCB * pCCB,
  446. expr_node * pAddrOfStubMsg,
  447. expr_node * StatRes,
  448. expr_node * pCommExpr,
  449. expr_node * pFaultExpr )
  450. {
  451. node_skl * pType;
  452. expr_proc_call * pProc = new expr_proc_call( NDR_MAP_COMM_FAULT_RTN_NAME );
  453. expr_node * pExpr;
  454. expr_variable * pExceptionCode = new expr_variable( "RpcExceptionCode()",0);
  455. pAddrOfStubMsg = MakeExpressionOfCastToTypeName( PSTUB_MESSAGE_TYPE_NAME,
  456. pAddrOfStubMsg );
  457. GetBaseTypeNode( &pType, SIGN_UNSIGNED, SIZE_LONG, TYPE_INT );
  458. pCommExpr = MakeExpressionOfCastPtrToType( pType, pCommExpr );
  459. pFaultExpr = MakeExpressionOfCastPtrToType( pType, pFaultExpr );
  460. pProc->SetParam( new expr_param( pAddrOfStubMsg ));
  461. pProc->SetParam( new expr_param( pCommExpr ));
  462. pProc->SetParam( new expr_param( pFaultExpr ));
  463. pProc->SetParam( new expr_param( pExceptionCode ));
  464. pExpr = new expr_assign( StatRes, pProc );
  465. Out_If( pCCB, pExpr );
  466. Out_RaiseException( pCCB, ((RESOURCE * )StatRes)->GetResourceName() );
  467. Out_Endif(pCCB);
  468. }
  469. void
  470. Out_CallToXmit(
  471. CCB * pCCB,
  472. PNAME XmittedTypeName,
  473. expr_node * pPresented,
  474. expr_node * pTransmitted )
  475. {
  476. ISTREAM * pStream = pCCB->GetStream();
  477. char * p = new char [strlen( XmittedTypeName )+10+1];
  478. strcpy( p, XmittedTypeName );
  479. strcat( p, "_to_xmit" );
  480. expr_proc_call * pProc = new expr_proc_call( p );
  481. pProc->SetParam( new expr_param( pPresented ) );
  482. pProc->SetParam( new expr_param(
  483. MakeAddressExpressionNoMatterWhat( pTransmitted ) ));
  484. pStream->NewLine();
  485. pProc->PrintCall( pStream, 0, 0 );
  486. }
  487. void
  488. Out_CallFromXmit(
  489. CCB * pCCB,
  490. PNAME XmittedTypeName,
  491. expr_node * pPresented,
  492. expr_node * pTransmitted )
  493. {
  494. ISTREAM * pStream = pCCB->GetStream();
  495. char * p = new char [strlen( XmittedTypeName )+10+1];
  496. strcpy( p, XmittedTypeName );
  497. strcat( p, "_from_xmit" );
  498. expr_proc_call * pProc = new expr_proc_call( p );
  499. pProc->SetParam( new expr_param( pTransmitted ));
  500. pProc->SetParam( new expr_param( pPresented ) );
  501. pStream->NewLine();
  502. pProc->PrintCall( pStream, 0, 0 );
  503. }
  504. void
  505. Out_CallFreeXmit(
  506. CCB * pCCB,
  507. PNAME XmittedTypeName,
  508. expr_node * pTransmitted )
  509. {
  510. ISTREAM * pStream = pCCB->GetStream();
  511. char * p = new char [strlen( XmittedTypeName )+15+1];
  512. strcpy( p, XmittedTypeName );
  513. strcat( p, "_free_xmit" );
  514. expr_proc_call * pProc = new expr_proc_call( p );
  515. pProc->SetParam( new expr_param( pTransmitted ) );
  516. pStream->NewLine();
  517. pProc->PrintCall( pStream, 0, 0 );
  518. }
  519. void
  520. Out_CallFreeInst(
  521. CCB * pCCB,
  522. PNAME XmittedTypeName,
  523. expr_node * pPresented )
  524. {
  525. ISTREAM * pStream = pCCB->GetStream();
  526. char * p = new char [strlen( XmittedTypeName )+15+1];
  527. strcpy( p, XmittedTypeName );
  528. strcat( p, "_free_inst" );
  529. expr_proc_call * pProc = new expr_proc_call( p );
  530. pProc->SetParam( new expr_param( pPresented ) );
  531. pStream->NewLine();
  532. pProc->PrintCall( pStream, 0, 0 );
  533. }
  534. void
  535. Out_StringMarshall(
  536. CCB * pCCB,
  537. expr_node * pMemory,
  538. expr_node * pCount,
  539. expr_node * pSize )
  540. {
  541. expr_proc_call * pProc = new expr_proc_call( NDR_CONF_STR_M_RTN_NAME );
  542. expr_node * pStubMsg= pCCB->GetStandardResource( ST_RES_STUB_MESSAGE_VARIABLE );
  543. ISTREAM * pStream = pCCB->GetStream();
  544. pStubMsg = MakeAddressExpressionNoMatterWhat( pStubMsg );
  545. pProc->SetParam( new expr_param( pStubMsg ));
  546. pProc->SetParam( new expr_param( MakeCastExprPtrToUChar( pMemory ) ) );
  547. pProc->SetParam( new expr_param( pCount ) );
  548. pProc->SetParam( new expr_param( pSize ) );
  549. pStream->NewLine();
  550. pProc->PrintCall( pStream, 0, 0 );
  551. }
  552. void
  553. Out_StringUnMarshall(
  554. CCB * pCCB,
  555. expr_node * pMemory,
  556. expr_node * pSize )
  557. {
  558. expr_proc_call * pProc = new expr_proc_call( NDR_CONF_STR_UN_RTN_NAME );
  559. expr_node * pStubMsg= pCCB->GetStandardResource( ST_RES_STUB_MESSAGE_VARIABLE );
  560. ISTREAM * pStream = pCCB->GetStream();
  561. pStubMsg = MakeAddressExpressionNoMatterWhat( pStubMsg );
  562. pProc->SetParam( new expr_param( pStubMsg ));
  563. pProc->SetParam( new expr_param( MakeAddressExpressionNoMatterWhat( MakeCastExprPtrToPtrToUChar( pMemory ) )) );
  564. pProc->SetParam( new expr_param( pSize ) );
  565. pStream->NewLine();
  566. pProc->PrintCall( pStream, 0, 0 );
  567. }
  568. char *
  569. MakeRtnName(
  570. char * pBuffer, // if 0 it means allocate anew buffer and return.
  571. char * pName,
  572. int Code )
  573. {
  574. char * p;
  575. switch( Code )
  576. {
  577. case NC_SIZE_RTN_NAME: p = "Sizing"; break;
  578. case NC_MARSHALL_RTN_NAME: p = "Marshall"; break;
  579. case NC_UNMARSHALL_RTN_NAME: p = "UnMarshall"; break;
  580. case NC_MEMSIZE_RTN_NAME: p = "MemSize"; break;
  581. case NC_FREE_RTN_NAME: p = "Free"; break;
  582. }
  583. if( !pBuffer )
  584. {
  585. pBuffer = new char[ strlen( pName ) + // name of structure
  586. 1 + // underscore.
  587. strlen( p ) + // name of rtn
  588. 1 // 0 terminator.
  589. ];
  590. }
  591. sprintf( pBuffer, "%s_%s", pName, p );
  592. return pBuffer;
  593. }
  594. void
  595. Out_TypeAlignSizePrototypes(
  596. CCB * pCCB,
  597. ITERATOR& I )
  598. {
  599. TYPE_ENCODE_INFO *p;
  600. ISTREAM * pStream = pCCB->GetStream();
  601. // The iterator items are really a set of name pointers.
  602. pStream->NewLine();
  603. while( ITERATOR_GETNEXT( I, p ) )
  604. {
  605. GenStdMesPrototype(
  606. pCCB,
  607. p->pName,
  608. TYPE_ALIGN_SIZE_CODE,
  609. (p->Flags == TYPE_ENCODE_WITH_IMPL_HANDLE));
  610. pStream->Write(';');
  611. pStream->NewLine();
  612. }
  613. }
  614. void
  615. Out_TypeEncodePrototypes(
  616. CCB * pCCB,
  617. ITERATOR& I )
  618. {
  619. TYPE_ENCODE_INFO *p;
  620. ISTREAM * pStream = pCCB->GetStream();
  621. // The iterator items are really a set of name pointers.
  622. pStream->NewLine();
  623. while( ITERATOR_GETNEXT( I, p ) )
  624. {
  625. GenStdMesPrototype(
  626. pCCB,
  627. p->pName,
  628. TYPE_ENCODE_CODE,
  629. (p->Flags == TYPE_ENCODE_WITH_IMPL_HANDLE));
  630. pStream->Write(';');
  631. pStream->NewLine();
  632. }
  633. }
  634. void
  635. Out_TypeDecodePrototypes(
  636. CCB * pCCB,
  637. ITERATOR& I )
  638. {
  639. TYPE_ENCODE_INFO *p;
  640. ISTREAM * pStream = pCCB->GetStream();
  641. // The iterator items are really a set of name pointers.
  642. pStream->NewLine();
  643. while( ITERATOR_GETNEXT( I, p ) )
  644. {
  645. GenStdMesPrototype(
  646. pCCB,
  647. p->pName,
  648. TYPE_DECODE_CODE,
  649. (p->Flags == TYPE_ENCODE_WITH_IMPL_HANDLE));
  650. pStream->Write(';');
  651. pStream->NewLine();
  652. }
  653. }
  654. void
  655. Out_TypeFreePrototypes(
  656. CCB * pCCB,
  657. ITERATOR& I )
  658. {
  659. // Freeing is not supported for the v1 interpreter
  660. if ( ! ( pCCB->GetOptimOption() & OPTIMIZE_INTERPRETER_V2 ) )
  661. return;
  662. TYPE_ENCODE_INFO *p;
  663. ISTREAM * pStream = pCCB->GetStream();
  664. // The iterator items are really a set of name pointers.
  665. pStream->NewLine();
  666. while( ITERATOR_GETNEXT( I, p ) )
  667. {
  668. GenStdMesPrototype(
  669. pCCB,
  670. p->pName,
  671. TYPE_FREE_CODE,
  672. (p->Flags == TYPE_ENCODE_WITH_IMPL_HANDLE));
  673. pStream->Write(';');
  674. pStream->NewLine();
  675. }
  676. }