MonoArrayMethod.cs 4.2 KB

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