PageRenderTime 33ms CodeModel.GetById 11ms app.highlight 18ms RepoModel.GetById 1ms app.codeStats 0ms

/Mono.Cecil/PInvokeInfo.cs

http://github.com/jbevain/cecil
C# | 120 lines | 87 code | 24 blank | 9 comment | 0 complexity | aa30e073e92e2e59869ad3a611c569be MD5 | raw file
  1//
  2// Author:
  3//   Jb Evain (jbevain@gmail.com)
  4//
  5// Copyright (c) 2008 - 2015 Jb Evain
  6// Copyright (c) 2008 - 2011 Novell, Inc.
  7//
  8// Licensed under the MIT/X11 license.
  9//
 10
 11namespace Mono.Cecil {
 12
 13	public sealed class PInvokeInfo {
 14
 15		ushort attributes;
 16		string entry_point;
 17		ModuleReference module;
 18
 19		public PInvokeAttributes Attributes {
 20			get { return (PInvokeAttributes) attributes; }
 21			set { attributes = (ushort) value; }
 22		}
 23
 24		public string EntryPoint {
 25			get { return entry_point; }
 26			set { entry_point = value; }
 27		}
 28
 29		public ModuleReference Module {
 30			get { return module; }
 31			set { module = value; }
 32		}
 33
 34		#region PInvokeAttributes
 35
 36		public bool IsNoMangle {
 37			get { return attributes.GetAttributes ((ushort) PInvokeAttributes.NoMangle); }
 38			set { attributes = attributes.SetAttributes ((ushort) PInvokeAttributes.NoMangle, value); }
 39		}
 40
 41		public bool IsCharSetNotSpec {
 42			get { return attributes.GetMaskedAttributes((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetNotSpec); }
 43			set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetNotSpec, value); }
 44		}
 45
 46		public bool IsCharSetAnsi {
 47			get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetAnsi); }
 48			set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetAnsi, value); }
 49		}
 50
 51		public bool IsCharSetUnicode {
 52			get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetUnicode); }
 53			set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetUnicode, value); }
 54		}
 55
 56		public bool IsCharSetAuto {
 57			get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetAuto); }
 58			set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetAuto, value); }
 59		}
 60
 61		public bool SupportsLastError {
 62			get { return attributes.GetAttributes ((ushort) PInvokeAttributes.SupportsLastError); }
 63			set { attributes = attributes.SetAttributes ((ushort) PInvokeAttributes.SupportsLastError, value); }
 64		}
 65
 66		public bool IsCallConvWinapi {
 67			get { return attributes.GetMaskedAttributes((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvWinapi); }
 68			set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvWinapi, value); }
 69		}
 70
 71		public bool IsCallConvCdecl {
 72			get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvCdecl); }
 73			set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvCdecl, value); }
 74		}
 75
 76		public bool IsCallConvStdCall {
 77			get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvStdCall); }
 78			set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvStdCall, value); }
 79		}
 80
 81		public bool IsCallConvThiscall {
 82			get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvThiscall); }
 83			set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvThiscall, value); }
 84		}
 85
 86		public bool IsCallConvFastcall {
 87			get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvFastcall); }
 88			set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvFastcall, value); }
 89		}
 90
 91		public bool IsBestFitEnabled {
 92			get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFitEnabled); }
 93			set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFitEnabled, value); }
 94		}
 95
 96		public bool IsBestFitDisabled {
 97			get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFitDisabled); }
 98			set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFitDisabled, value); }
 99		}
100
101		public bool IsThrowOnUnmappableCharEnabled {
102			get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.ThrowOnUnmappableCharMask, (ushort) PInvokeAttributes.ThrowOnUnmappableCharEnabled); }
103			set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.ThrowOnUnmappableCharMask, (ushort) PInvokeAttributes.ThrowOnUnmappableCharEnabled, value); }
104		}
105
106		public bool IsThrowOnUnmappableCharDisabled {
107			get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.ThrowOnUnmappableCharMask, (ushort) PInvokeAttributes.ThrowOnUnmappableCharDisabled); }
108			set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.ThrowOnUnmappableCharMask, (ushort) PInvokeAttributes.ThrowOnUnmappableCharDisabled, value); }
109		}
110
111		#endregion
112
113		public PInvokeInfo (PInvokeAttributes attributes, string entryPoint, ModuleReference module)
114		{
115			this.attributes = (ushort) attributes;
116			this.entry_point = entryPoint;
117			this.module = module;
118		}
119	}
120}