MonoArrayMethod.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. using System;
  33. using System.Globalization;
  34. using System.Runtime.CompilerServices;
  35. using System.Runtime.InteropServices;
  36. namespace System.Reflection {
  37. [StructLayout (LayoutKind.Sequential)]
  38. internal class MonoArrayMethod: MethodInfo {
  39. #pragma warning disable 649
  40. internal RuntimeMethodHandle mhandle;
  41. internal Type parent;
  42. internal Type ret;
  43. internal Type[] parameters;
  44. internal string name;
  45. internal int table_idx;
  46. internal CallingConventions call_conv;
  47. #pragma warning restore 649
  48. internal MonoArrayMethod (Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) {
  49. name = methodName;
  50. parent = arrayClass;
  51. ret = returnType;
  52. parameters = (Type[])parameterTypes.Clone();
  53. call_conv = callingConvention;
  54. }
  55. [MonoTODO("Always returns this")]
  56. public override MethodInfo GetBaseDefinition() {
  57. return this; /* FIXME */
  58. }
  59. public override Type ReturnType {
  60. get {
  61. return ret;
  62. }
  63. }
  64. [MonoTODO("Not implemented. Always returns null")]
  65. public override ICustomAttributeProvider ReturnTypeCustomAttributes {
  66. get {return null;}
  67. }
  68. [MonoTODO("Not implemented. Always returns zero")]
  69. public override MethodImplAttributes GetMethodImplementationFlags() {
  70. return (MethodImplAttributes)0;
  71. }
  72. [MonoTODO("Not implemented. Always returns an empty array")]
  73. public override ParameterInfo[] GetParameters() {
  74. return new ParameterInfo [0];
  75. }
  76. [MonoTODO("Not implemented. Always returns 0")]
  77. internal override int GetParameterCount ()
  78. {
  79. return 0;
  80. }
  81. [MonoTODO("Not implemented")]
  82. public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) {
  83. throw new NotImplementedException ();
  84. }
  85. public override RuntimeMethodHandle MethodHandle {
  86. get {return mhandle;}
  87. }
  88. [MonoTODO("Not implemented. Always returns zero")]
  89. public override MethodAttributes Attributes {
  90. get {
  91. return (MethodAttributes)0;
  92. }
  93. }
  94. public override Type ReflectedType {
  95. get {
  96. return parent;
  97. }
  98. }
  99. public override Type DeclaringType {
  100. get {
  101. return parent;
  102. }
  103. }
  104. public override string Name {
  105. get {
  106. return name;
  107. }
  108. }
  109. public override bool IsDefined (Type attributeType, bool inherit) {
  110. return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
  111. }
  112. public override object[] GetCustomAttributes( bool inherit) {
  113. return MonoCustomAttrs.GetCustomAttributes (this, inherit);
  114. }
  115. public override object[] GetCustomAttributes( Type attributeType, bool inherit) {
  116. return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
  117. }
  118. public override string ToString () {
  119. string parms = String.Empty;
  120. ParameterInfo[] p = GetParameters ();
  121. for (int i = 0; i < p.Length; ++i) {
  122. if (i > 0)
  123. parms = parms + ", ";
  124. parms = parms + p [i].ParameterType.Name;
  125. }
  126. if (ReturnType != null)
  127. return ReturnType.Name+" "+Name+"("+parms+")";
  128. else
  129. return "void "+Name+"("+parms+")";
  130. }
  131. }
  132. }