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
This repository was archived by the owner on Jul 22, 2023. It is now read-only.
/pythonnetPublic archive
forked frompythonnet/pythonnet

Commitf27d7be

Browse files
committed
Make NETSTANDARD the default
Drops also- Custom XDecref/XIncref (should be readded)- Remote object handling for .NET Framework
1 parente933e79 commitf27d7be

File tree

6 files changed

+33
-193
lines changed

6 files changed

+33
-193
lines changed

‎Python.Runtime/codegenerator.cs

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,40 @@ namespace Python.Runtime
1313
/// </summary>
1414
internalclassCodeGenerator
1515
{
16-
privateAssemblyBuilderaBuilder;
17-
privateModuleBuildermBuilder;
16+
privateAssemblyBuilder_aBuilder=null;
1817

19-
internalCodeGenerator()
18+
privateAssemblyBuilderaBuilder
19+
{
20+
get
21+
{
22+
if(_aBuilder==null)
23+
{
24+
varaname=newAssemblyName{Name="__CodeGenerator_Assembly"};
25+
varaa=AssemblyBuilderAccess.Run;
26+
27+
_aBuilder=Thread.GetDomain().DefineDynamicAssembly(aname,aa);
28+
}
29+
30+
return_aBuilder;
31+
}
32+
}
33+
34+
privateModuleBuilder_mBuilder=null;
35+
privateModuleBuildermBuilder
2036
{
21-
varaname=newAssemblyName{Name="__CodeGenerator_Assembly"};
22-
varaa=AssemblyBuilderAccess.Run;
37+
get
38+
{
39+
if(_mBuilder==null)
40+
{
41+
_mBuilder=aBuilder.DefineDynamicModule("__CodeGenerator_Module");
42+
}
43+
44+
return_mBuilder;
45+
}
46+
}
2347

24-
aBuilder=Thread.GetDomain().DefineDynamicAssembly(aname,aa);
25-
mBuilder=aBuilder.DefineDynamicModule("__CodeGenerator_Module");
48+
internalCodeGenerator()
49+
{
2650
}
2751

2852
/// <summary>

‎Python.Runtime/converter.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,7 @@ internal static IntPtr ToPython(object value, Type type)
156156
varpyderived=valueasIPythonDerivedType;
157157
if(null!=pyderived)
158158
{
159-
#ifNETSTANDARD
160159
returnClassDerivedObject.ToPython(pyderived);
161-
#else
162-
// if object is remote don't do this
163-
if(!System.Runtime.Remoting.RemotingServices.IsTransparentProxy(pyderived))
164-
{
165-
returnClassDerivedObject.ToPython(pyderived);
166-
}
167-
#endif
168160
}
169161

170162
// hmm - from Python, we almost never care what the declared

‎Python.Runtime/nativecall.cs

Lines changed: 0 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ namespace Python.Runtime
2323
/// </summary>
2424
internalclassNativeCall
2525
{
26-
#ifNETSTANDARD
2726
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
2827
privatedelegatevoidVoid_1_Delegate(IntPtra1);
2928

@@ -48,132 +47,5 @@ public static int Int_Call_3(IntPtr fp, IntPtr a1, IntPtr a2, IntPtr a3)
4847
vard=Marshal.GetDelegateForFunctionPointer<Interop.ObjObjArgFunc>(fp);
4948
returnd(a1,a2,a3);
5049
}
51-
#else
52-
privatestaticAssemblyBuilderaBuilder;
53-
privatestaticModuleBuildermBuilder;
54-
55-
publicstaticINativeCallImpl;
56-
57-
staticNativeCall()
58-
{
59-
// The static constructor is responsible for generating the
60-
// assembly and the methods that implement the IJW thunks.
61-
//
62-
// To do this, we actually use reflection on the INativeCall
63-
// interface (defined below) and generate the required thunk
64-
// code based on the method signatures.
65-
66-
varaname=newAssemblyName{Name="e__NativeCall_Assembly"};
67-
varaa=AssemblyBuilderAccess.Run;
68-
69-
aBuilder=Thread.GetDomain().DefineDynamicAssembly(aname,aa);
70-
mBuilder=aBuilder.DefineDynamicModule("e__NativeCall_Module");
71-
72-
varta=TypeAttributes.Public;
73-
TypeBuildertBuilder=mBuilder.DefineType("e__NativeCall",ta);
74-
75-
TypeiType=typeof(INativeCall);
76-
tBuilder.AddInterfaceImplementation(iType);
77-
78-
// Use reflection to loop over the INativeCall interface methods,
79-
// calling GenerateThunk to create a managed thunk for each one.
80-
81-
foreach(MethodInfomethodiniType.GetMethods())
82-
{
83-
GenerateThunk(tBuilder,method);
84-
}
85-
86-
TypetheType=tBuilder.CreateType();
87-
88-
Impl=(INativeCall)Activator.CreateInstance(theType);
89-
}
90-
91-
privatestaticvoidGenerateThunk(TypeBuildertb,MethodInfomethod)
92-
{
93-
ParameterInfo[]pi=method.GetParameters();
94-
intcount=pi.Length;
95-
intargc=count-1;
96-
97-
varargs=newType[count];
98-
for(vari=0;i<count;i++)
99-
{
100-
args[i]=pi[i].ParameterType;
101-
}
102-
103-
MethodBuildermb=tb.DefineMethod(
104-
method.Name,
105-
MethodAttributes.Public|
106-
MethodAttributes.Virtual,
107-
method.ReturnType,
108-
args
109-
);
110-
111-
// Build the method signature for the actual native function.
112-
// This is essentially the signature of the wrapper method
113-
// minus the first argument (the passed in function pointer).
114-
115-
varnargs=newType[argc];
116-
for(vari=1;i<count;i++)
117-
{
118-
nargs[i-1]=args[i];
119-
}
120-
121-
// IL generation: the (implicit) first argument of the method
122-
// is the 'this' pointer and the second is the function pointer.
123-
// This code pushes the real args onto the stack, followed by
124-
// the function pointer, then the calli opcode to make the call.
125-
126-
ILGeneratoril=mb.GetILGenerator();
127-
128-
for(vari=0;i<argc;i++)
129-
{
130-
il.Emit(OpCodes.Ldarg_S,i+2);
131-
}
132-
133-
il.Emit(OpCodes.Ldarg_1);
134-
135-
il.EmitCalli(OpCodes.Calli,
136-
CallingConvention.Cdecl,
137-
method.ReturnType,
138-
nargs
139-
);
140-
141-
il.Emit(OpCodes.Ret);
142-
143-
tb.DefineMethodOverride(mb,method);
144-
}
145-
146-
147-
publicstaticvoidVoid_Call_1(IntPtrfp,IntPtra1)
148-
{
149-
Impl.Void_Call_1(fp,a1);
150-
}
151-
152-
publicstaticIntPtrCall_3(IntPtrfp,IntPtra1,IntPtra2,IntPtra3)
153-
{
154-
returnImpl.Call_3(fp,a1,a2,a3);
155-
}
156-
157-
publicstaticintInt_Call_3(IntPtrfp,IntPtra1,IntPtra2,IntPtra3)
158-
{
159-
returnImpl.Int_Call_3(fp,a1,a2,a3);
160-
}
161-
#endif
162-
}
163-
164-
#if!NETSTANDARD
165-
/// <summary>
166-
/// Defines native call signatures to be generated by NativeCall.
167-
/// </summary>
168-
publicinterfaceINativeCall
169-
{
170-
voidVoid_Call_0(IntPtrfuncPtr);
171-
172-
voidVoid_Call_1(IntPtrfuncPtr,IntPtrarg1);
173-
174-
intInt_Call_3(IntPtrfuncPtr,IntPtrt,IntPtrn,IntPtrv);
175-
176-
IntPtrCall_3(IntPtrfuncPtr,IntPtra1,IntPtra2,IntPtra3);
17750
}
178-
#endif
17951
}

‎Python.Runtime/polyfill/ReflectionPolifills.csrenamed to‎Python.Runtime/polyfill/ReflectionPolyfills.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
namespacePython.Runtime
66
{
7-
#ifNETSTANDARD
8-
publicstaticclassReflectionPolifills
7+
publicstaticclassReflectionPolyfills
98
{
109
publicstaticAssemblyBuilderDefineDynamicAssembly(thisAppDomainappDomain,AssemblyNameassemblyName,AssemblyBuilderAccessassemblyBuilderAccess)
1110
{
@@ -17,5 +16,4 @@ public static Type CreateType(this TypeBuilder typeBuilder)
1716
returntypeBuilder.GetTypeInfo().GetType();
1817
}
1918
}
20-
#endif
2119
}

‎Python.Runtime/runtime.cs

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -492,60 +492,14 @@ internal static Type[] PythonArgsToTypeArray(IntPtr arg, bool mangleObjects)
492492
/// </summary>
493493
internalstaticunsafevoidXIncref(IntPtrop)
494494
{
495-
#ifPYTHON_WITH_PYDEBUG||NETSTANDARD
496495
Py_IncRef(op);
497496
return;
498-
#else
499-
varp=(void*)op;
500-
if((void*)0!=p)
501-
{
502-
if(Is32Bit)
503-
{
504-
(*(int*)p)++;
505-
}
506-
else
507-
{
508-
(*(long*)p)++;
509-
}
510-
}
511-
#endif
512497
}
513498

514499
internalstaticunsafevoidXDecref(IntPtrop)
515500
{
516-
#ifPYTHON_WITH_PYDEBUG||NETSTANDARD
517501
Py_DecRef(op);
518502
return;
519-
#else
520-
varp=(void*)op;
521-
if((void*)0!=p)
522-
{
523-
if(Is32Bit)
524-
{
525-
--(*(int*)p);
526-
}
527-
else
528-
{
529-
--(*(long*)p);
530-
}
531-
if((*(int*)p)==0)
532-
{
533-
// PyObject_HEAD: struct _typeobject *ob_type
534-
void* t= Is32Bit
535-
?(void*)(*((uint*)p+1))
536-
:(void*)(*((ulong*)p+1));
537-
// PyTypeObject: destructor tp_dealloc
538-
void*f= Is32Bit
539-
?(void*)(*((uint*)t+6))
540-
:(void*)(*((ulong*)t+6));
541-
if((void*)0==f)
542-
{
543-
return;
544-
}
545-
NativeCall.Impl.Void_Call_1(newIntPtr(f),op);
546-
}
547-
}
548-
#endif
549503
}
550504

551505
internalstaticunsafelongRefcount(IntPtrop)

‎Python.Test.Embed/TestDomainReload.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//
1212
// Unfortunately this means no continuous integration testing for this case.
1313
//
14-
#if!NETSTANDARD&&!NETCOREAPP
14+
#ifNETFX
1515
namespacePython.EmbeddingTest
1616
{
1717
classTestDomainReload

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp