diff --git a/src/embed_tests/TestPythonEngineProperties.cs b/src/embed_tests/TestPythonEngineProperties.cs
index 01c6ae7e3..76177d05a 100644
--- a/src/embed_tests/TestPythonEngineProperties.cs
+++ b/src/embed_tests/TestPythonEngineProperties.cs
@@ -146,7 +146,7 @@ public void SetProgramName()
[Test]
public void SetPythonPath()
{
- if (Runtime.Runtime.pyversion == "2.7")
+ if (Runtime.Runtime._pyversion == "2.7")
{
// Assert.Skip outputs as a warning (ie. pending to fix)
Assert.Pass();
@@ -166,7 +166,7 @@ public void SetPythonPath()
[Test]
public void SetPythonPathExceptionOn27()
{
- if (Runtime.Runtime.pyversion != "2.7")
+ if (Runtime.Runtime._pyversion != "2.7")
{
Assert.Pass();
}
diff --git a/src/runtime/CustomMarshaler.cs b/src/runtime/CustomMarshaler.cs
index 90bb77a71..b51911816 100644
--- a/src/runtime/CustomMarshaler.cs
+++ b/src/runtime/CustomMarshaler.cs
@@ -91,13 +91,13 @@ public static int GetUnicodeByteLength(IntPtr p)
var len = 0;
while (true)
{
- int c = Runtime.UCS == 2
+ int c = Runtime._UCS == 2
? Marshal.ReadInt16(p, len * 2)
: Marshal.ReadInt32(p, len * 4);
if (c == 0)
{
- return len * Runtime.UCS;
+ return len * Runtime._UCS;
}
checked
{
@@ -163,7 +163,7 @@ public override IntPtr MarshalManagedToNative(object managedObj)
}
int totalStrLength = argv.Sum(arg => arg.Length + 1);
- int memSize = argv.Length * IntPtr.Size + totalStrLength * Runtime.UCS;
+ int memSize = argv.Length * IntPtr.Size + totalStrLength * Runtime._UCS;
IntPtr mem = Marshal.AllocHGlobal(memSize);
try
diff --git a/src/runtime/Python.Runtime.csproj b/src/runtime/Python.Runtime.csproj
index 9999f8303..82825a626 100644
--- a/src/runtime/Python.Runtime.csproj
+++ b/src/runtime/Python.Runtime.csproj
@@ -20,12 +20,14 @@
false
..\pythonnet.snk
-
+
+
+
PYTHON2;PYTHON27;UCS4
true
diff --git a/src/runtime/runtime.cs b/src/runtime/runtime.cs
index 90c56817a..8f730a855 100644
--- a/src/runtime/runtime.cs
+++ b/src/runtime/runtime.cs
@@ -80,8 +80,14 @@ public static IntPtr GetProcAddress(IntPtr dllHandle, string name)
///
public class Runtime
{
+ // C# compiler copies constants to the assemblies that references this library.
+ // We needs to replace all public constants to static readonly fields to allow
+ // binary substitution of different Python.Runtime.dll builds in a target application.
+
+ public static int UCS => _UCS;
+
#if UCS4
- public const int UCS = 4;
+ internal const int _UCS = 4;
///
/// EntryPoint to be used in DllImport to map to correct Unicode
@@ -89,7 +95,7 @@ public class Runtime
///
private const string PyUnicodeEntryPoint = "PyUnicodeUCS4_";
#elif UCS2
- public const int UCS = 2;
+ internal const int _UCS = 2;
///
/// EntryPoint to be used in DllImport to map to correct Unicode
@@ -100,32 +106,39 @@ public class Runtime
#error You must define either UCS2 or UCS4!
#endif
+ // C# compiler copies constants to the assemblies that references this library.
+ // We needs to replace all public constants to static readonly fields to allow
+ // binary substitution of different Python.Runtime.dll builds in a target application.
+
+ public string pyversion => _pyversion;
+ public string pyver => _pyver;
+
#if PYTHON27
- public const string pyversion = "2.7";
- public const string pyver = "27";
+ internal const string _pyversion = "2.7";
+ internal const string _pyver = "27";
#elif PYTHON33
- public const string pyversion = "3.3";
- public const string pyver = "33";
+ internal const string _pyversion = "3.3";
+ internal const string _pyver = "33";
#elif PYTHON34
- public const string pyversion = "3.4";
- public const string pyver = "34";
+ internal const string _pyversion = "3.4";
+ internal const string _pyver = "34";
#elif PYTHON35
- public const string pyversion = "3.5";
- public const string pyver = "35";
+ internal const string _pyversion = "3.5";
+ internal const string _pyver = "35";
#elif PYTHON36
- public const string pyversion = "3.6";
- public const string pyver = "36";
+ internal const string _pyversion = "3.6";
+ internal const string _pyver = "36";
#elif PYTHON37 // TODO: Add `interop37.cs` after PY37 is released
- public const string pyversion = "3.7";
- public const string pyver = "37";
+ internal const string _pyversion = "3.7";
+ internal const string _pyver = "37";
#else
#error You must define one of PYTHON33 to PYTHON37 or PYTHON27
#endif
#if MONO_LINUX || MONO_OSX // Linux/macOS use dotted version string
- internal const string dllBase = "python" + pyversion;
+ internal const string dllBase = "python" + _pyversion;
#else // Windows
- internal const string dllBase = "python" + pyver;
+ internal const string dllBase = "python" + _pyver;
#endif
#if PYTHON_WITH_PYDEBUG
@@ -139,13 +152,19 @@ public class Runtime
internal const string dllWithPyMalloc = "";
#endif
+ // C# compiler copies constants to the assemblies that references this library.
+ // We needs to replace all public constants to static readonly fields to allow
+ // binary substitution of different Python.Runtime.dll builds in a target application.
+
+ public static readonly string PythonDLL = _PythonDll;
+
#if PYTHON_WITHOUT_ENABLE_SHARED
- public const string PythonDll = "__Internal";
+ internal const string _PythonDll = "__Internal";
#else
- public const string PythonDll = dllBase + dllWithPyDebug + dllWithPyMalloc;
+ internal const string _PythonDll = dllBase + dllWithPyDebug + dllWithPyMalloc;
#endif
- public static readonly int pyversionnumber = Convert.ToInt32(pyver);
+ public static readonly int pyversionnumber = Convert.ToInt32(_pyver);
// set to true when python is finalizing
internal static object IsFinalizingLock = new object();
@@ -162,7 +181,7 @@ public class Runtime
///
/// Encoding to use to convert Unicode to/from Managed to Native
///
- internal static readonly Encoding PyEncoding = UCS == 2 ? Encoding.Unicode : Encoding.UTF32;
+ internal static readonly Encoding PyEncoding = _UCS == 2 ? Encoding.Unicode : Encoding.UTF32;
///
/// Initialize the runtime...
@@ -279,9 +298,9 @@ internal static void Initialize()
Error = new IntPtr(-1);
IntPtr dllLocal = IntPtr.Zero;
- if (PythonDll != "__Internal")
+ if (_PythonDll != "__Internal")
{
- dllLocal = NativeMethods.LoadLibrary(PythonDll);
+ dllLocal = NativeMethods.LoadLibrary(_PythonDll);
}
_PyObject_NextNotImplemented = NativeMethods.GetProcAddress(dllLocal, "_PyObject_NextNotImplemented");
#if !(MONO_LINUX || MONO_OSX)
@@ -549,7 +568,7 @@ internal static unsafe long Refcount(IntPtr op)
/// Limit this function usage for Testing and Py_Debug builds
///
/// PyObject Ptr
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void Py_IncRef(IntPtr ob);
///
@@ -557,160 +576,160 @@ internal static unsafe long Refcount(IntPtr op)
/// Limit this function usage for Testing and Py_Debug builds
///
/// PyObject Ptr
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void Py_DecRef(IntPtr ob);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void Py_Initialize();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int Py_IsInitialized();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void Py_Finalize();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr Py_NewInterpreter();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void Py_EndInterpreter(IntPtr threadState);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyThreadState_New(IntPtr istate);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyThreadState_Get();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyThread_get_key_value(IntPtr key);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyThread_get_thread_ident();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyThread_set_key_value(IntPtr key, IntPtr value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyThreadState_Swap(IntPtr key);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyGILState_Ensure();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PyGILState_Release(IntPtr gs);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyGILState_GetThisThreadState();
#if PYTHON3
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
public static extern int Py_Main(
int argc,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StrArrayMarshaler))] string[] argv
);
#elif PYTHON2
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
public static extern int Py_Main(int argc, string[] argv);
#endif
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PyEval_InitThreads();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyEval_ThreadsInitialized();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PyEval_AcquireLock();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PyEval_ReleaseLock();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PyEval_AcquireThread(IntPtr tstate);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PyEval_ReleaseThread(IntPtr tstate);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyEval_SaveThread();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PyEval_RestoreThread(IntPtr tstate);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyEval_GetBuiltins();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyEval_GetGlobals();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyEval_GetLocals();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr Py_GetProgramName();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void Py_SetProgramName(IntPtr name);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr Py_GetPythonHome();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void Py_SetPythonHome(IntPtr home);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr Py_GetPath();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void Py_SetPath(IntPtr home);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr Py_GetVersion();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr Py_GetPlatform();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr Py_GetCopyright();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr Py_GetCompiler();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr Py_GetBuildInfo();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyRun_SimpleString(string code);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyRun_String(string code, IntPtr st, IntPtr globals, IntPtr locals);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyEval_EvalCode(IntPtr co, IntPtr globals, IntPtr locals);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr Py_CompileString(string code, string file, IntPtr tok);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyImport_ExecCodeModule(string name, IntPtr code);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyCFunction_NewEx(IntPtr ml, IntPtr self, IntPtr mod);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyCFunction_Call(IntPtr func, IntPtr args, IntPtr kw);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyClass_New(IntPtr bases, IntPtr dict, IntPtr name);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyInstance_New(IntPtr cls, IntPtr args, IntPtr kw);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyInstance_NewRaw(IntPtr cls, IntPtr dict);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyMethod_New(IntPtr func, IntPtr self, IntPtr cls);
@@ -774,44 +793,44 @@ internal static bool PyObject_IsIterable(IntPtr pointer)
return tp_iter != IntPtr.Zero;
}
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyObject_HasAttrString(IntPtr pointer, string name);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyObject_GetAttrString(IntPtr pointer, string name);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyObject_SetAttrString(IntPtr pointer, string name, IntPtr value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyObject_HasAttr(IntPtr pointer, IntPtr name);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyObject_GetAttr(IntPtr pointer, IntPtr name);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyObject_SetAttr(IntPtr pointer, IntPtr name, IntPtr value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyObject_GetItem(IntPtr pointer, IntPtr key);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyObject_SetItem(IntPtr pointer, IntPtr key, IntPtr value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyObject_DelItem(IntPtr pointer, IntPtr key);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyObject_GetIter(IntPtr op);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyObject_CallObject(IntPtr pointer, IntPtr args);
#if PYTHON3
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyObject_RichCompareBool(IntPtr value1, IntPtr value2, int opid);
internal static int PyObject_Compare(IntPtr value1, IntPtr value2)
@@ -839,47 +858,47 @@ internal static int PyObject_Compare(IntPtr value1, IntPtr value2)
return -1;
}
#elif PYTHON2
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyObject_Compare(IntPtr value1, IntPtr value2);
#endif
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyObject_IsInstance(IntPtr ob, IntPtr type);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyObject_IsSubclass(IntPtr ob, IntPtr type);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyCallable_Check(IntPtr pointer);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyObject_IsTrue(IntPtr pointer);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyObject_Not(IntPtr pointer);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyObject_Size(IntPtr pointer);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyObject_Hash(IntPtr op);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyObject_Repr(IntPtr pointer);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyObject_Str(IntPtr pointer);
#if PYTHON3
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl,
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "PyObject_Str")]
internal static extern IntPtr PyObject_Unicode(IntPtr pointer);
#elif PYTHON2
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyObject_Unicode(IntPtr pointer);
#endif
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyObject_Dir(IntPtr pointer);
@@ -888,21 +907,21 @@ internal static int PyObject_Compare(IntPtr value1, IntPtr value2)
//====================================================================
#if PYTHON3
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl,
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "PyNumber_Long")]
internal static extern IntPtr PyNumber_Int(IntPtr ob);
#elif PYTHON2
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_Int(IntPtr ob);
#endif
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_Long(IntPtr ob);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_Float(IntPtr ob);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern bool PyNumber_Check(IntPtr ob);
internal static bool PyInt_Check(IntPtr ob)
@@ -928,32 +947,32 @@ internal static IntPtr PyInt_FromInt64(long value)
}
#if PYTHON3
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl,
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "PyLong_FromLong")]
private static extern IntPtr PyInt_FromLong(IntPtr value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl,
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "PyLong_AsLong")]
internal static extern int PyInt_AsLong(IntPtr value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl,
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "PyLong_FromString")]
internal static extern IntPtr PyInt_FromString(string value, IntPtr end, int radix);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl,
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "PyLong_GetMax")]
internal static extern int PyInt_GetMax();
#elif PYTHON2
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr PyInt_FromLong(IntPtr value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyInt_AsLong(IntPtr value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyInt_FromString(string value, IntPtr end, int radix);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyInt_GetMax();
#endif
@@ -962,34 +981,34 @@ internal static bool PyLong_Check(IntPtr ob)
return PyObject_TYPE(ob) == PyLongType;
}
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyLong_FromLong(long value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyLong_FromUnsignedLong(uint value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyLong_FromDouble(double value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyLong_FromLongLong(long value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyLong_FromUnsignedLongLong(ulong value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyLong_FromString(string value, IntPtr end, int radix);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyLong_AsLong(IntPtr value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern uint PyLong_AsUnsignedLong(IntPtr value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern long PyLong_AsLongLong(IntPtr value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern ulong PyLong_AsUnsignedLongLong(IntPtr value);
internal static bool PyFloat_Check(IntPtr ob)
@@ -997,88 +1016,88 @@ internal static bool PyFloat_Check(IntPtr ob)
return PyObject_TYPE(ob) == PyFloatType;
}
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyFloat_FromDouble(double value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyFloat_FromString(IntPtr value, IntPtr junk);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern double PyFloat_AsDouble(IntPtr ob);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_Add(IntPtr o1, IntPtr o2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_Subtract(IntPtr o1, IntPtr o2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_Multiply(IntPtr o1, IntPtr o2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_Divide(IntPtr o1, IntPtr o2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_And(IntPtr o1, IntPtr o2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_Xor(IntPtr o1, IntPtr o2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_Or(IntPtr o1, IntPtr o2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_Lshift(IntPtr o1, IntPtr o2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_Rshift(IntPtr o1, IntPtr o2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_Power(IntPtr o1, IntPtr o2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_Remainder(IntPtr o1, IntPtr o2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_InPlaceAdd(IntPtr o1, IntPtr o2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_InPlaceSubtract(IntPtr o1, IntPtr o2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_InPlaceMultiply(IntPtr o1, IntPtr o2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_InPlaceDivide(IntPtr o1, IntPtr o2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_InPlaceAnd(IntPtr o1, IntPtr o2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_InPlaceXor(IntPtr o1, IntPtr o2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_InPlaceOr(IntPtr o1, IntPtr o2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_InPlaceLshift(IntPtr o1, IntPtr o2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_InPlaceRshift(IntPtr o1, IntPtr o2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_InPlacePower(IntPtr o1, IntPtr o2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_InPlaceRemainder(IntPtr o1, IntPtr o2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_Negative(IntPtr o1);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_Positive(IntPtr o1);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyNumber_Invert(IntPtr o1);
@@ -1086,49 +1105,49 @@ internal static bool PyFloat_Check(IntPtr ob)
// Python sequence API
//====================================================================
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern bool PySequence_Check(IntPtr pointer);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PySequence_GetItem(IntPtr pointer, int index);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PySequence_SetItem(IntPtr pointer, int index, IntPtr value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PySequence_DelItem(IntPtr pointer, int index);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PySequence_GetSlice(IntPtr pointer, int i1, int i2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PySequence_SetSlice(IntPtr pointer, int i1, int i2, IntPtr v);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PySequence_DelSlice(IntPtr pointer, int i1, int i2);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PySequence_Size(IntPtr pointer);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PySequence_Contains(IntPtr pointer, IntPtr item);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PySequence_Concat(IntPtr pointer, IntPtr other);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PySequence_Repeat(IntPtr pointer, int count);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PySequence_Index(IntPtr pointer, IntPtr item);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PySequence_Count(IntPtr pointer, IntPtr value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PySequence_Tuple(IntPtr pointer);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PySequence_List(IntPtr pointer);
@@ -1153,10 +1172,10 @@ internal static IntPtr PyString_FromString(string value)
}
#if PYTHON3
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyBytes_FromString(string op);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyBytes_Size(IntPtr op);
internal static IntPtr PyBytes_AS_STRING(IntPtr ob)
@@ -1164,23 +1183,23 @@ internal static IntPtr PyBytes_AS_STRING(IntPtr ob)
return ob + BytesOffset.ob_sval;
}
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl,
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "PyUnicode_FromStringAndSize")]
internal static extern IntPtr PyString_FromStringAndSize(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string value,
int size
);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyUnicode_FromStringAndSize(IntPtr value, int size);
#elif PYTHON2
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyString_FromStringAndSize(string value, int size);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyString_AsString(IntPtr op);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyString_Size(IntPtr pointer);
#endif
@@ -1190,13 +1209,13 @@ internal static bool PyUnicode_Check(IntPtr ob)
}
#if PYTHON3
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyUnicode_FromObject(IntPtr ob);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyUnicode_FromEncodedObject(IntPtr ob, IntPtr enc, IntPtr err);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyUnicode_FromKindAndData(
int kind,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UcsMarshaler))] string s,
@@ -1205,42 +1224,42 @@ int size
internal static IntPtr PyUnicode_FromUnicode(string s, int size)
{
- return PyUnicode_FromKindAndData(UCS, s, size);
+ return PyUnicode_FromKindAndData(_UCS, s, size);
}
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyUnicode_GetSize(IntPtr ob);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyUnicode_AsUnicode(IntPtr ob);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyUnicode_FromOrdinal(int c);
#elif PYTHON2
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl,
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl,
EntryPoint = PyUnicodeEntryPoint + "FromObject")]
internal static extern IntPtr PyUnicode_FromObject(IntPtr ob);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl,
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl,
EntryPoint = PyUnicodeEntryPoint + "FromEncodedObject")]
internal static extern IntPtr PyUnicode_FromEncodedObject(IntPtr ob, IntPtr enc, IntPtr err);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl,
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl,
EntryPoint = PyUnicodeEntryPoint + "FromUnicode")]
internal static extern IntPtr PyUnicode_FromUnicode(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UcsMarshaler))] string s,
int size
);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl,
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl,
EntryPoint = PyUnicodeEntryPoint + "GetSize")]
internal static extern int PyUnicode_GetSize(IntPtr ob);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl,
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl,
EntryPoint = PyUnicodeEntryPoint + "AsUnicode")]
internal static extern IntPtr PyUnicode_AsUnicode(IntPtr ob);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl,
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl,
EntryPoint = PyUnicodeEntryPoint + "FromOrdinal")]
internal static extern IntPtr PyUnicode_FromOrdinal(int c);
#endif
@@ -1279,7 +1298,7 @@ internal static string GetManagedString(IntPtr op)
IntPtr p = PyUnicode_AsUnicode(op);
int length = PyUnicode_GetSize(op);
- int size = length * UCS;
+ int size = length * _UCS;
var buffer = new byte[size];
Marshal.Copy(p, buffer, 0, size);
return PyEncoding.GetString(buffer, 0, size);
@@ -1298,52 +1317,52 @@ internal static bool PyDict_Check(IntPtr ob)
return PyObject_TYPE(ob) == PyDictType;
}
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyDict_New();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyDictProxy_New(IntPtr dict);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyDict_GetItem(IntPtr pointer, IntPtr key);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyDict_GetItemString(IntPtr pointer, string key);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyDict_SetItem(IntPtr pointer, IntPtr key, IntPtr value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyDict_SetItemString(IntPtr pointer, string key, IntPtr value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyDict_DelItem(IntPtr pointer, IntPtr key);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyDict_DelItemString(IntPtr pointer, string key);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyMapping_HasKey(IntPtr pointer, IntPtr key);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyDict_Keys(IntPtr pointer);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyDict_Values(IntPtr pointer);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyDict_Items(IntPtr pointer);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyDict_Copy(IntPtr pointer);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyDict_Update(IntPtr pointer, IntPtr other);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PyDict_Clear(IntPtr pointer);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyDict_Size(IntPtr pointer);
@@ -1356,37 +1375,37 @@ internal static bool PyList_Check(IntPtr ob)
return PyObject_TYPE(ob) == PyListType;
}
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyList_New(int size);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyList_AsTuple(IntPtr pointer);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyList_GetItem(IntPtr pointer, int index);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyList_SetItem(IntPtr pointer, int index, IntPtr value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyList_Insert(IntPtr pointer, int index, IntPtr value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyList_Append(IntPtr pointer, IntPtr value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyList_Reverse(IntPtr pointer);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyList_Sort(IntPtr pointer);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyList_GetSlice(IntPtr pointer, int start, int end);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyList_SetSlice(IntPtr pointer, int start, int end, IntPtr value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyList_Size(IntPtr pointer);
@@ -1399,19 +1418,19 @@ internal static bool PyTuple_Check(IntPtr ob)
return PyObject_TYPE(ob) == PyTupleType;
}
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyTuple_New(int size);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyTuple_GetItem(IntPtr pointer, int index);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyTuple_SetItem(IntPtr pointer, int index, IntPtr value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyTuple_GetSlice(IntPtr pointer, int start, int end);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyTuple_Size(IntPtr pointer);
@@ -1431,7 +1450,7 @@ internal static bool PyIter_Check(IntPtr pointer)
return tp_iternext != IntPtr.Zero && tp_iternext != _PyObject_NextNotImplemented;
}
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyIter_Next(IntPtr pointer);
@@ -1439,47 +1458,47 @@ internal static bool PyIter_Check(IntPtr pointer)
// Python module API
//====================================================================
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyModule_New(string name);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern string PyModule_GetName(IntPtr module);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyModule_GetDict(IntPtr module);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern string PyModule_GetFilename(IntPtr module);
#if PYTHON3
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyModule_Create2(IntPtr module, int apiver);
#endif
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyImport_Import(IntPtr name);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyImport_ImportModule(string name);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyImport_ReloadModule(IntPtr module);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyImport_AddModule(string name);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyImport_GetModuleDict();
#if PYTHON3
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PySys_SetArgvEx(
int argc,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StrArrayMarshaler))] string[] argv,
int updatepath
);
#elif PYTHON2
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PySys_SetArgvEx(
int argc,
string[] argv,
@@ -1487,10 +1506,10 @@ int updatepath
);
#endif
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PySys_GetObject(string name);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PySys_SetObject(string name, IntPtr ob);
@@ -1503,10 +1522,10 @@ internal static bool PyType_Check(IntPtr ob)
return PyObject_TypeCheck(ob, PyTypeType);
}
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PyType_Modified(IntPtr type);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern bool PyType_IsSubtype(IntPtr t1, IntPtr t2);
internal static bool PyObject_TypeCheck(IntPtr ob, IntPtr tp)
@@ -1515,37 +1534,37 @@ internal static bool PyObject_TypeCheck(IntPtr ob, IntPtr tp)
return (t == tp) || PyType_IsSubtype(t, tp);
}
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyType_GenericNew(IntPtr type, IntPtr args, IntPtr kw);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyType_GenericAlloc(IntPtr type, int n);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyType_Ready(IntPtr type);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr _PyType_Lookup(IntPtr type, IntPtr name);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyObject_GenericGetAttr(IntPtr obj, IntPtr name);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyObject_GenericSetAttr(IntPtr obj, IntPtr name, IntPtr value);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr _PyObject_GetDictPtr(IntPtr obj);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyObject_GC_New(IntPtr tp);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PyObject_GC_Del(IntPtr tp);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PyObject_GC_Track(IntPtr tp);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PyObject_GC_UnTrack(IntPtr tp);
@@ -1553,13 +1572,13 @@ internal static bool PyObject_TypeCheck(IntPtr ob, IntPtr tp)
// Python memory API
//====================================================================
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyMem_Malloc(int size);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyMem_Realloc(IntPtr ptr, int size);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PyMem_Free(IntPtr ptr);
@@ -1567,40 +1586,40 @@ internal static bool PyObject_TypeCheck(IntPtr ob, IntPtr tp)
// Python exception API
//====================================================================
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PyErr_SetString(IntPtr ob, string message);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PyErr_SetObject(IntPtr ob, IntPtr message);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyErr_SetFromErrno(IntPtr ob);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PyErr_SetNone(IntPtr ob);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyErr_ExceptionMatches(IntPtr exception);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyErr_GivenExceptionMatches(IntPtr ob, IntPtr val);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PyErr_NormalizeException(IntPtr ob, IntPtr val, IntPtr tb);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyErr_Occurred();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PyErr_Fetch(ref IntPtr ob, ref IntPtr val, ref IntPtr tb);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PyErr_Restore(IntPtr ob, IntPtr val, IntPtr tb);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PyErr_Clear();
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PyErr_Print();
@@ -1608,10 +1627,10 @@ internal static bool PyObject_TypeCheck(IntPtr ob, IntPtr tp)
// Miscellaneous
//====================================================================
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyMethod_Self(IntPtr ob);
- [DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyMethod_Function(IntPtr ob);
}
}