Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Remove unusedPythonMethodAttribute#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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall 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 deletionssrc/runtime/interop.cs
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionssrc/runtime/typemanager.cs
View file
Open in desktop
Original file line numberDiff line numberDiff 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 DownExpand 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 deletionssrc/runtime/typemethod.cs
View file
Open in desktop

This file was deleted.


[8]ページ先頭

©2009-2025 Movatter.jp