MonoArrayMethod.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. //
  2. // System.Reflection/MonoMethod.cs
  3. // The class used to represent methods from the mono runtime.
  4. //
  5. // Author:
  6. // Paolo Molaro ([email protected])
  7. //
  8. // (C) 2001 Ximian, Inc. http://www.ximian.com
  9. //
  10. //
  11. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  12. //
  13. // Permission is hereby granted, free of charge, to any person obtaining
  14. // a copy of this software and associated documentation files (the
  15. // "Software"), to deal in the Software without restriction, including
  16. // without limitation the rights to use, copy, modify, merge, publish,
  17. // distribute, sublicense, and/or sell copies of the Software, and to
  18. // permit persons to whom the Software is furnished to do so, subject to
  19. // the following conditions:
  20. //
  21. // The above copyright notice and this permission notice shall be
  22. // included in all copies or substantial portions of the Software.
  23. //
  24. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  28. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  29. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  30. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  31. //
  32. #if MONO_FEATURE_SRE
  33. using System;
  34. using System.Globalization;
  35. using System.Runtime.CompilerServices;
  36. using System.Runtime.InteropServices;
  37. namespace System.Reflection {
  38. [StructLayout (LayoutKind.Sequential)]
  39. internal class MonoArrayMethod: MethodInfo {
  40. #pragma warning disable 649
  41. internal RuntimeMethodHandle mhandle;
  42. internal Type parent;
  43. internal Type ret;
  44. internal Type[] parameters;
  45. internal string name;
  46. internal int table_idx;
  47. internal CallingConventions call_conv;
  48. #pragma warning restore 649
  49. internal MonoArrayMethod (Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) {
  50. name = methodName;
  51. parent = arrayClass;
  52. ret = returnType;
  53. parameters = (Type[])parameterTypes.Clone();
  54. call_conv = callingConvention;
  55. }
  56. [MonoTODO("Always returns this")]
  57. public override MethodInfo GetBaseDefinition() {
  58. return this; /* FIXME */
  59. }
  60. public override Type ReturnType {
  61. get {
  62. return ret;
  63. }
  64. }
  65. [MonoTODO("Not implemented. Always returns null")]
  66. public override ICustomAttributeProvider ReturnTypeCustomAttributes {
  67. get {return null;}
  68. }
  69. [MonoTODO("Not implemented. Always returns zero")]
  70. public override MethodImplAttributes GetMethodImplementationFlags() {
  71. return (MethodImplAttributes)0;
  72. }
  73. [MonoTODO("Not implemented. Always returns an empty array")]
  74. public override ParameterInfo[] GetParameters()
  75. {
  76. return GetParametersInternal ();
  77. }
  78. internal override ParameterInfo[] GetParametersInternal ()
  79. {
  80. return EmptyArray<ParameterInfo>.Value;
  81. }
  82. [MonoTODO("Not implemented. Always returns 0")]
  83. internal override int GetParametersCount ()
  84. {
  85. return 0;
  86. }
  87. [MonoTODO("Not implemented")]
  88. public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) {
  89. throw new NotImplementedException ();
  90. }
  91. public override RuntimeMethodHandle MethodHandle {
  92. get {return mhandle;}
  93. }
  94. [MonoTODO("Not implemented. Always returns zero")]
  95. public override MethodAttributes Attributes {
  96. get {
  97. return (MethodAttributes)0;
  98. }
  99. }
  100. public override Type ReflectedType {
  101. get {
  102. return parent;
  103. }
  104. }
  105. public override Type DeclaringType {
  106. get {
  107. return parent;
  108. }
  109. }
  110. public override string Name {
  111. get {
  112. return name;
  113. }
  114. }
  115. public override bool IsDefined (Type attributeType, bool inherit) {
  116. return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
  117. }
  118. public override object[] GetCustomAttributes( bool inherit) {
  119. return MonoCustomAttrs.GetCustomAttributes (this, inherit);
  120. }
  121. public override object[] GetCustomAttributes( Type attributeType, bool inherit) {
  122. return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
  123. }
  124. public override string ToString () {
  125. string parms = String.Empty;
  126. ParameterInfo[] p = GetParameters ();
  127. for (int i = 0; i < p.Length; ++i) {
  128. if (i > 0)
  129. parms = parms + ", ";
  130. parms = parms + p [i].ParameterType.Name;
  131. }
  132. if (ReturnType != null)
  133. return ReturnType.Name+" "+Name+"("+parms+")";
  134. else
  135. return "void "+Name+"("+parms+")";
  136. }
  137. }
  138. }
  139. #endif