Skip to content

Remove unused PythonMethodAttribute #1609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/runtime/interop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Text;

namespace Python.Runtime
{
Expand All @@ -31,15 +30,6 @@ public string DocString
private string docStr;
}

[Serializable]
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Delegate)]
internal class PythonMethodAttribute : Attribute
{
public PythonMethodAttribute()
{
}
}

[Serializable]
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Delegate)]
internal class ModuleFunctionAttribute : Attribute
Expand Down
39 changes: 0 additions & 39 deletions src/runtime/typemanager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ internal static unsafe PyType CreateType(Type impl)
Runtime.PyDict_SetItem(dict, PyIdentifier.__module__, mod);
mod.Dispose();

InitMethods(dict, impl);

dict.Dispose();

// The type has been modified after PyType_Ready has been called
Expand Down Expand Up @@ -806,43 +804,6 @@ static void InitializeSlot(IntPtr type, int slotOffset, ThunkInfo thunk, SlotsHo
}
}

/// <summary>
/// Given a dict of a newly allocated Python type object and a managed Type that
/// implements it, initialize any methods defined by the Type that need
/// to appear in the Python type __dict__ (based on custom attribute).
/// </summary>
private static void InitMethods(BorrowedReference typeDict, Type type)
{
Type marker = typeof(PythonMethodAttribute);

BindingFlags flags = BindingFlags.Public | BindingFlags.Static;
var addedMethods = new HashSet<string>();

while (type != null)
{
MethodInfo[] methods = type.GetMethods(flags);
foreach (MethodInfo method in methods)
{
if (!addedMethods.Contains(method.Name))
{
object[] attrs = method.GetCustomAttributes(marker, false);
if (attrs.Length > 0)
{
string method_name = method.Name;
var mi = new MethodInfo[1];
mi[0] = method;
MethodObject m = new TypeMethod(type, method_name, mi);
Runtime.PyDict_SetItemString(typeDict, method_name, m.ObjectReference);
m.DecrRefCount();
addedMethods.Add(method_name);
}
}
}
type = type.BaseType;
}
}


/// <summary>
/// Utility method to copy slots from a given type to another type.
/// </summary>
Expand Down
45 changes: 0 additions & 45 deletions src/runtime/typemethod.cs

This file was deleted.