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.

522 lines
15 KiB

  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1989-1999 Microsoft Corporation
  3. Module Name:
  4. btcls.hxx
  5. Abstract:
  6. Contains definitions for base type related code generation class
  7. definitions.
  8. Notes:
  9. History:
  10. VibhasC Jul-29-1993 Created.
  11. ----------------------------------------------------------------------------*/
  12. #ifndef __BTCLS_HXX__
  13. #define __BTCLS_HXX__
  14. #include "nulldefs.h"
  15. extern "C"
  16. {
  17. #include <stdio.h>
  18. }
  19. #include "ndrcls.hxx"
  20. #include "ndr64tkn.h"
  21. class RESOURCE;
  22. void
  23. GenRangeFormatString(
  24. FORMAT_STRING* pFormatString,
  25. node_range_attr* pRangeAttr,
  26. unsigned char uFlags,
  27. FORMAT_CHARACTER format
  28. );
  29. /////////////////////////////////////////////////////////////////////////////
  30. // the base type code generation class.
  31. /////////////////////////////////////////////////////////////////////////////
  32. //
  33. // This class corresponds to a base type. All base types are clubbed together
  34. // into this class, since they share a whole lot of properties.
  35. //
  36. class CG_BASETYPE : public CG_NDR
  37. {
  38. private:
  39. public:
  40. //
  41. // The constructor.
  42. //
  43. CG_BASETYPE(
  44. node_skl * pBT,
  45. XLAT_SIZE_INFO & Info) // packing and size info
  46. : CG_NDR( pBT, Info )
  47. {
  48. SetSStubAllocLocation(
  49. S_STUB_ALLOC_LOCATION_UNKNOWN );
  50. SetSStubAllocType( S_STUB_ALLOC_TYPE_NONE );
  51. SetSStubInitNeed( S_STUB_INIT_NOT_NEEDED );
  52. }
  53. virtual
  54. void Visit( CG_VISITOR *pVisitor )
  55. {
  56. pVisitor->Visit( this );
  57. }
  58. //
  59. // VARDESC generation routine
  60. //
  61. virtual
  62. CG_STATUS GetTypeDesc(TYPEDESC * &ptd, CCB * pCCB);
  63. //
  64. // Get and set methods.
  65. //
  66. virtual
  67. ID_CG GetCGID()
  68. {
  69. return ID_CG_BT;
  70. }
  71. //
  72. // Marshall a base type.
  73. //
  74. virtual
  75. CG_STATUS GenMarshall( CCB * pCCB );
  76. virtual
  77. CG_STATUS GenUnMarshall( CCB * pCCB );
  78. //
  79. // Format string routines for base types.
  80. //
  81. virtual
  82. void GenNdrFormat( CCB * pCCB );
  83. //
  84. // This method is called to generate offline portions of a types
  85. // format string.
  86. //
  87. virtual
  88. void GenNdrParamOffline( CCB* pCCB )
  89. {
  90. if ( GetRangeAttribute() )
  91. {
  92. GenNdrFormat( pCCB );
  93. }
  94. }
  95. virtual
  96. void GenNdrParamDescription( CCB * pCCB );
  97. virtual
  98. void GetNdrParamAttributes(
  99. CCB * pCCB,
  100. PARAM_ATTRIBUTES *attributes );
  101. virtual
  102. void GenNdrParamDescriptionOld( CCB * pCCB )
  103. {
  104. pCCB->GetProcFormatString()->
  105. PushFormatChar( GetFormatChar() );
  106. }
  107. //
  108. // CG_ENUM redefines the GetFormatChar* methods.
  109. //
  110. virtual
  111. FORMAT_CHARACTER GetFormatChar( CCB * pCCB = 0 );
  112. virtual
  113. FORMAT_CHARACTER GetSignedFormatChar();
  114. virtual
  115. NDR64_FORMAT_CHARACTER GetNDR64FormatChar( CCB * pCCB = 0 );
  116. virtual
  117. NDR64_FORMAT_CHARACTER GetNDR64SignedFormatChar();
  118. char * GetTypeName();
  119. long FixedBufferSize( CCB * pCCB );
  120. BOOL InterpreterMustFree( CCB * )
  121. {
  122. return GetFormatChar() != FC_ENUM16;
  123. }
  124. //
  125. // This routine adjusts the stack size for the basetype, based upon the
  126. // current machine and environment. Needed for computing the stack
  127. // offsets in the NDR format string conformance descripions for top level
  128. // attributed arrays/pointers.
  129. //
  130. void IncrementStackOffset( long * pOffset );
  131. // end format string routines
  132. virtual
  133. BOOL IsSimpleType()
  134. {
  135. return TRUE;
  136. }
  137. BOOL HasAFixedBufferSize()
  138. {
  139. return TRUE;
  140. }
  141. virtual
  142. bool IsHomogeneous(FORMAT_CHARACTER format)
  143. {
  144. return GetFormatChar() == format;
  145. }
  146. virtual
  147. CG_STATUS S_GenInitOutLocals( CCB * pCCB );
  148. /////////////////////////////////////////////////////////////////////
  149. virtual
  150. CG_STATUS MarshallAnalysis( ANALYSIS_INFO * pAna );
  151. virtual
  152. CG_STATUS UnMarshallAnalysis( ANALYSIS_INFO * pAna );
  153. virtual
  154. CG_STATUS S_OutLocalAnalysis( ANALYSIS_INFO * pAna );
  155. virtual
  156. CG_STATUS FollowerMarshallAnalysis( ANALYSIS_INFO * )
  157. {
  158. return CG_OK;
  159. }
  160. virtual
  161. CG_STATUS FollowerUnMarshallAnalysis( ANALYSIS_INFO * )
  162. {
  163. return CG_OK;
  164. }
  165. };
  166. /////////////////////////////////////////////////////////////////////////////
  167. // the int3264 code generation class.
  168. /////////////////////////////////////////////////////////////////////////////
  169. //
  170. // This class corresponds to an __int3264. This inherits from the basetypes,
  171. // Note that we use this node only when __int3264 generated for a 64b platform,
  172. // otherwise ilcore will manufacture a basetype node.
  173. // Once we have a CG_INT3264, it behaves like an enum - due to difference in
  174. // memory and wire sizes it makes things complex etc.
  175. //
  176. class CG_INT3264 : public CG_BASETYPE
  177. {
  178. private:
  179. void * _pCTI;
  180. public:
  181. //
  182. // The constructor.
  183. //
  184. CG_INT3264 (
  185. node_skl * pBT,
  186. XLAT_SIZE_INFO & Info
  187. ) :
  188. CG_BASETYPE( pBT, Info ), _pCTI( 0 )
  189. {}
  190. //
  191. // Get and set methods.
  192. //
  193. virtual
  194. ID_CG GetCGID()
  195. {
  196. return ID_CG_INT3264;
  197. }
  198. virtual
  199. void Visit( CG_VISITOR *pVisitor )
  200. {
  201. pVisitor->Visit( this );
  202. }
  203. };
  204. /////////////////////////////////////////////////////////////////////////////
  205. // the enum code generation class.
  206. /////////////////////////////////////////////////////////////////////////////
  207. //
  208. // This class corresponds to an enum. This inherits from the basetypes,
  209. // since they share a whole lot of properties.
  210. //
  211. class CG_ENUM : public CG_BASETYPE
  212. {
  213. private:
  214. void * _pCTI;
  215. public:
  216. //
  217. // The constructor.
  218. //
  219. CG_ENUM (
  220. node_skl * pBT,
  221. XLAT_SIZE_INFO & Info
  222. ) :
  223. CG_BASETYPE( pBT, Info ), _pCTI( 0 )
  224. {
  225. }
  226. //
  227. // Get and set methods.
  228. //
  229. BOOL IsEnumLong()
  230. {
  231. return GetWireSize() != 2;
  232. }
  233. virtual
  234. ID_CG GetCGID()
  235. {
  236. return ID_CG_ENUM;
  237. }
  238. virtual
  239. void Visit( CG_VISITOR *pVisitor )
  240. {
  241. pVisitor->Visit( this );
  242. }
  243. //
  244. // Generate typeinfo
  245. //
  246. virtual
  247. CG_STATUS GenTypeInfo( CCB * pCCB);
  248. virtual
  249. CG_STATUS GetTypeDesc(TYPEDESC * &ptd, CCB * pCCB)
  250. {
  251. return CG_NDR::GetTypeDesc(ptd, pCCB);
  252. };
  253. virtual
  254. FORMAT_CHARACTER GetFormatChar( CCB* pCCB = 0 );
  255. virtual
  256. FORMAT_CHARACTER GetSignedFormatChar();
  257. virtual
  258. NDR64_FORMAT_CHARACTER GetNDR64FormatChar( CCB* pCCB = 0 );
  259. virtual
  260. NDR64_FORMAT_CHARACTER GetNDR64SignedFormatChar();
  261. };
  262. /////////////////////////////////////////////////////////////////////////////
  263. // the error_status_t code generation class.
  264. /////////////////////////////////////////////////////////////////////////////
  265. //
  266. // This class corresponds to an error_status_t. This inherits from the basetypes,
  267. // since they share a whole lot of properties.
  268. //
  269. class CG_ERROR_STATUS_T : public CG_BASETYPE
  270. {
  271. private:
  272. public:
  273. //
  274. // The constructor.
  275. //
  276. CG_ERROR_STATUS_T(
  277. node_skl * pBT,
  278. XLAT_SIZE_INFO & Info )
  279. : CG_BASETYPE( pBT, Info )
  280. {
  281. }
  282. //
  283. // Get and set methods.
  284. //
  285. virtual
  286. ID_CG GetCGID()
  287. {
  288. return ID_CG_ERROR_STATUS_T;
  289. }
  290. virtual
  291. void Visit( CG_VISITOR *pVisitor )
  292. {
  293. pVisitor->Visit( this );
  294. }
  295. virtual
  296. FORMAT_CHARACTER GetFormatChar( CCB * pCCB = 0 );
  297. virtual
  298. FORMAT_CHARACTER GetSignedFormatChar()
  299. {
  300. MIDL_ASSERT(0);
  301. return FC_ZERO;
  302. }
  303. virtual
  304. NDR64_FORMAT_CHARACTER GetNDR64FormatChar( CCB * pCCB = 0 );
  305. virtual
  306. NDR64_FORMAT_CHARACTER GetNDR64SignedFormatChar()
  307. {
  308. MIDL_ASSERT(0);
  309. return FC64_ZERO;
  310. }
  311. };
  312. /////////////////////////////////////////////////////////////////////////////
  313. // the error_status_t code generation class.
  314. /////////////////////////////////////////////////////////////////////////////
  315. //
  316. // This class corresponds to an error_status_t. This inherits from the basetypes,
  317. // since they share a whole lot of properties.
  318. //
  319. class CG_HRESULT : public CG_BASETYPE
  320. {
  321. private:
  322. public:
  323. //
  324. // The constructor.
  325. //
  326. CG_HRESULT(
  327. node_skl * pBT,
  328. XLAT_SIZE_INFO & Info )
  329. : CG_BASETYPE( pBT, Info )
  330. {
  331. }
  332. //
  333. // Get and set methods.
  334. //
  335. virtual
  336. ID_CG GetCGID()
  337. {
  338. return ID_CG_HRESULT;
  339. }
  340. virtual
  341. void Visit( CG_VISITOR *pVisitor )
  342. {
  343. pVisitor->Visit( this );
  344. }
  345. virtual
  346. FORMAT_CHARACTER GetFormatChar( CCB * )
  347. {
  348. return FC_LONG;
  349. }
  350. virtual
  351. FORMAT_CHARACTER GetSignedFormatChar()
  352. {
  353. MIDL_ASSERT(0);
  354. return FC_ZERO;
  355. }
  356. virtual
  357. NDR64_FORMAT_CHARACTER GetNDR64FormatChar( CCB * )
  358. {
  359. return FC64_INT32;
  360. }
  361. virtual
  362. NDR64_FORMAT_CHARACTER GetNDR64SignedFormatChar()
  363. {
  364. MIDL_ASSERT(0);
  365. return FC64_ZERO;
  366. }
  367. };
  368. /////////////////////////////////////////////////////////////////////////////
  369. // the cs_tag parameter code generation class.
  370. /////////////////////////////////////////////////////////////////////////////
  371. class CG_CS_TAG : public CG_NDR
  372. {
  373. private:
  374. NDR_CS_TAG_FLAGS Flags;
  375. public:
  376. CG_CS_TAG(
  377. node_skl * pBT,
  378. XLAT_SIZE_INFO & Info,
  379. BOOL fIsSTag,
  380. BOOL fIsDRTag,
  381. BOOL fIsRTag )
  382. : CG_NDR( pBT, Info )
  383. {
  384. Flags.STag = (unsigned char) ( fIsSTag ? 1 : 0 );
  385. Flags.DRTag = (unsigned char) ( fIsDRTag ? 1 : 0 );
  386. Flags.RTag = (unsigned char) ( fIsRTag ? 1 : 0 );
  387. }
  388. virtual
  389. ID_CG GetCGID()
  390. {
  391. return ID_CG_CS_TAG;
  392. }
  393. virtual
  394. void Visit( CG_VISITOR *pVisitor )
  395. {
  396. pVisitor->Visit( this );
  397. }
  398. virtual
  399. void GenNdrFormat( CCB * pCCB );
  400. };
  401. #endif // __BTCLS_HXX__