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

Commitf92a26b

Browse files
committed
Added a few cleanups based on feedback.
1 parent46de53e commitf92a26b

File tree

3 files changed

+19
-24
lines changed

3 files changed

+19
-24
lines changed

‎src/runtime/Runtime.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,12 +1836,6 @@ internal static void SetNoSiteFlag()
18361836
return*Delegates.Py_NoSiteFlag;
18371837
});
18381838
}
1839-
1840-
internalstaticuintPyTuple_GetSize(BorrowedReferencetuple)
1841-
{
1842-
IntPtrr=Delegates.PyTuple_Size(tuple);
1843-
return(uint)r.ToInt32();
1844-
}
18451839
}
18461840

18471841
internalclassBadPythonDllException: MissingMethodException

‎src/runtime/TypeManager.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ static PyTuple GetBaseTypeTuple(Type clrType)
374374
returnnewPyTuple(bases);
375375
}
376376

377-
internalstaticNewReferenceCreateSubType(BorrowedReferencepy_name,IList<ClassBase>py_base_type,IList<Type>interfaces,BorrowedReferencedictRef)
377+
internalstaticNewReferenceCreateSubType(BorrowedReferencepy_name,ClassBasepy_base_type,IList<Type>interfaces,BorrowedReferencedictRef)
378378
{
379379
// Utility to create a subtype of a managed type with the ability for the
380380
// a python subtype able to override the managed implementation
@@ -415,9 +415,7 @@ internal static NewReference CreateSubType(BorrowedReference py_name, IList<Clas
415415
}
416416

417417
// create the new managed type subclassing the base managed type
418-
varbaseClass=py_base_type.FirstOrDefault();
419-
420-
returnReflectedClrType.CreateSubclass(baseClass,interfaces,name,
418+
returnReflectedClrType.CreateSubclass(py_base_type,interfaces,name,
421419
ns:(string?)namespaceStr,
422420
assembly:(string?)assembly,
423421
dict:dictRef);

‎src/runtime/Types/MetaType.cs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,34 +84,37 @@ public static NewReference tp_new(BorrowedReference tp, BorrowedReference args,
8484

8585
// Extract interface types and base class types.
8686
varinterfaces=newList<Type>();
87-
varbaseType=newList<ClassBase>();
8887

89-
varcnt=Runtime.PyTuple_GetSize(bases);
88+
// More than one base type case be declared, but an exception will be thrown
89+
// if more than one is a class/not an interface.
90+
varbaseTypes=newList<ClassBase>();
9091

91-
for(uinti=0;i<cnt;i++)
92+
varbaseClassCount=Runtime.PyTuple_Size(bases);
93+
94+
for(ninti=0;i<baseClassCount;i++)
9295
{
93-
varbase_type2=Runtime.PyTuple_GetItem(bases,(int)i);
94-
varcb2=(ClassBase)GetManagedObject(base_type2);
95-
if(cb2!=null)
96+
varbaseTypeIt=Runtime.PyTuple_GetItem(bases,(int)i);
97+
98+
if(GetManagedObject(baseTypeIt)isClassBaseclassBaseIt)
9699
{
97-
if(cb2.type.Valid&&cb2.type.Value.IsInterface)
98-
interfaces.Add(cb2.type.Value);
99-
elsebaseType.Add(cb2);
100+
if(classBaseIt.type.Valid&&classBaseIt.type.Value.IsInterface)
101+
interfaces.Add(classBaseIt.type.Value);
102+
elsebaseTypes.Add(classBaseIt);
100103
}
101104
}
102105
// if the base type count is 0, there might still be interfaces to implement.
103-
if(baseType.Count==0)
106+
if(baseTypes.Count==0)
104107
{
105-
baseType.Add(newClassBase(typeof(object)));
108+
baseTypes.Add(newClassBase(typeof(object)));
106109
}
107110

108111
// Multiple inheritance is not supported, unless the other types are interfaces
109-
if(baseType.Count>1)
112+
if(baseTypes.Count>1)
110113
{
111114
returnExceptions.RaiseTypeError("cannot use multiple inheritance with managed classes");
112115
}
113116

114-
varcb=baseType[0];
117+
varcb=baseTypes[0];
115118
try
116119
{
117120
if(!cb.CanSubclass())
@@ -140,7 +143,7 @@ public static NewReference tp_new(BorrowedReference tp, BorrowedReference args,
140143
usingvarclsDict=newPyDict(dict);
141144
if(clsDict.HasKey("__assembly__")||clsDict.HasKey("__namespace__"))
142145
{
143-
returnTypeManager.CreateSubType(name,baseType,interfaces,clsDict);
146+
returnTypeManager.CreateSubType(name,baseTypes[0],interfaces,clsDict);
144147
}
145148
}
146149

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp