MarshalInfo.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. //
  2. // MarshalInfo.cs
  3. //
  4. // Author:
  5. // Jb Evain (jbevain@gmail.com)
  6. //
  7. // Copyright (c) 2008 - 2011 Jb Evain
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. using System;
  29. namespace Mono.Cecil {
  30. public class MarshalInfo {
  31. internal NativeType native;
  32. public NativeType NativeType {
  33. get { return native; }
  34. set { native = value; }
  35. }
  36. public MarshalInfo (NativeType native)
  37. {
  38. this.native = native;
  39. }
  40. }
  41. public sealed class ArrayMarshalInfo : MarshalInfo {
  42. internal NativeType element_type;
  43. internal int size_parameter_index;
  44. internal int size;
  45. internal int size_parameter_multiplier;
  46. public NativeType ElementType {
  47. get { return element_type; }
  48. set { element_type = value; }
  49. }
  50. public int SizeParameterIndex {
  51. get { return size_parameter_index; }
  52. set { size_parameter_index = value; }
  53. }
  54. public int Size {
  55. get { return size; }
  56. set { size = value; }
  57. }
  58. public int SizeParameterMultiplier {
  59. get { return size_parameter_multiplier; }
  60. set { size_parameter_multiplier = value; }
  61. }
  62. public ArrayMarshalInfo ()
  63. : base (NativeType.Array)
  64. {
  65. element_type = NativeType.None;
  66. size_parameter_index = -1;
  67. size = -1;
  68. size_parameter_multiplier = -1;
  69. }
  70. }
  71. public sealed class CustomMarshalInfo : MarshalInfo {
  72. internal Guid guid;
  73. internal string unmanaged_type;
  74. internal TypeReference managed_type;
  75. internal string cookie;
  76. public Guid Guid {
  77. get { return guid; }
  78. set { guid = value; }
  79. }
  80. public string UnmanagedType {
  81. get { return unmanaged_type; }
  82. set { unmanaged_type = value; }
  83. }
  84. public TypeReference ManagedType {
  85. get { return managed_type; }
  86. set { managed_type = value; }
  87. }
  88. public string Cookie {
  89. get { return cookie; }
  90. set { cookie = value; }
  91. }
  92. public CustomMarshalInfo ()
  93. : base (NativeType.CustomMarshaler)
  94. {
  95. }
  96. }
  97. public sealed class SafeArrayMarshalInfo : MarshalInfo {
  98. internal VariantType element_type;
  99. public VariantType ElementType {
  100. get { return element_type; }
  101. set { element_type = value; }
  102. }
  103. public SafeArrayMarshalInfo ()
  104. : base (NativeType.SafeArray)
  105. {
  106. element_type = VariantType.None;
  107. }
  108. }
  109. public sealed class FixedArrayMarshalInfo : MarshalInfo {
  110. internal NativeType element_type;
  111. internal int size;
  112. public NativeType ElementType {
  113. get { return element_type; }
  114. set { element_type = value; }
  115. }
  116. public int Size {
  117. get { return size; }
  118. set { size = value; }
  119. }
  120. public FixedArrayMarshalInfo ()
  121. : base (NativeType.FixedArray)
  122. {
  123. element_type = NativeType.None;
  124. }
  125. }
  126. public sealed class FixedSysStringMarshalInfo : MarshalInfo {
  127. internal int size;
  128. public int Size {
  129. get { return size; }
  130. set { size = value; }
  131. }
  132. public FixedSysStringMarshalInfo ()
  133. : base (NativeType.FixedSysString)
  134. {
  135. size = -1;
  136. }
  137. }
  138. }