| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 34d8d35 commit abbe870
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -503,7 +503,7 @@ public static PyObject ReloadModule(PyObject module) | |||
| 503 | 503 | /// </remarks> | |
| 504 | 504 | public static PyObject ModuleFromString(string name, string code) | |
| 505 | 505 | { | |
| 506 | - IntPtr c = Runtime.Py_CompileString(code, "none", (IntPtr)257); | ||
| 506 | + IntPtr c = Runtime.Py_CompileString(code, "none", (int)RunFlagType.File); | ||
| 507 | 507 | Runtime.CheckExceptionOccurred(); | |
| 508 | 508 | IntPtr m = Runtime.PyImport_ExecCodeModule(name, c); | |
| 509 | 509 | Runtime.CheckExceptionOccurred(); | |
@@ -512,7 +512,7 @@ public static PyObject ModuleFromString(string name, string code) | |||
| 512 | 512 | ||
| 513 | 513 | public static PyObject Compile(string code, string filename = "", RunFlagType mode = RunFlagType.File) | |
| 514 | 514 | { | |
| 515 | - var flag = (IntPtr)mode; | ||
| 515 | + var flag = (int)mode; | ||
| 516 | 516 | IntPtr ptr = Runtime.Py_CompileString(code, filename, flag); | |
| 517 | 517 | Runtime.CheckExceptionOccurred(); | |
| 518 | 518 | return new PyObject(ptr); | |
@@ -610,7 +610,7 @@ internal static PyObject RunString(string code, IntPtr? globals, IntPtr? locals, | |||
| 610 | 610 | } | |
| 611 | 611 | } | |
| 612 | 612 | ||
| 613 | - public enum RunFlagType | ||
| 613 | + public enum RunFlagType : int | ||
| 614 | 614 | { | |
| 615 | 615 | Single = 256, | |
| 616 | 616 | File = 257, /* Py_file_input */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -763,8 +763,36 @@ public static extern int Py_Main( | |||
| 763 | 763 | [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] | |
| 764 | 764 | internal static extern IntPtr PyEval_EvalCode(IntPtr co, IntPtr globals, IntPtr locals); | |
| 765 | 765 | ||
| 766 | + #if PYTHON2 | ||
| 767 | + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] | ||
| 768 | + internal static extern IntPtr Py_CompileString(string code, string file, int start); | ||
| 769 | + #else | ||
| 770 | + /// <summary> | ||
| 771 | + /// Return value: New reference. | ||
| 772 | + /// This is a simplified interface to Py_CompileStringFlags() below, leaving flags set to NULL. | ||
| 773 | + /// </summary> | ||
| 774 | + internal static IntPtr Py_CompileString(string str, string file, int start) | ||
| 775 | + { | ||
| 776 | + return Py_CompileStringFlags(str, file, start, IntPtr.Zero); | ||
| 777 | + } | ||
| 778 | + | ||
| 779 | + /// <summary> | ||
| 780 | + /// Return value: New reference. | ||
| 781 | + /// This is a simplified interface to Py_CompileStringExFlags() below, with optimize set to -1. | ||
| 782 | + /// </summary> | ||
| 783 | + internal static IntPtr Py_CompileStringFlags(string str, string file, int start, IntPtr flags) | ||
| 784 | + { | ||
| 785 | + return Py_CompileStringExFlags(str, file, start, flags, -1); | ||
| 786 | + } | ||
| 787 | + | ||
| 788 | + /// <summary> | ||
| 789 | + /// Return value: New reference. | ||
| 790 | + /// Like Py_CompileStringObject(), but filename is a byte string decoded from the filesystem encoding(os.fsdecode()). | ||
| 791 | + /// </summary> | ||
| 792 | + /// <returns></returns> | ||
| 766 | 793 | [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] | |
| 767 | - internal static extern IntPtr Py_CompileString(string code, string file, IntPtr tok); | ||
| 794 | + internal static extern IntPtr Py_CompileStringExFlags(string str, string file, int start, IntPtr flags, int optimize); | ||
| 795 | + #endif | ||
| 768 | 796 | ||
| 769 | 797 | [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] | |
| 770 | 798 | internal static extern IntPtr PyImport_ExecCodeModule(string name, IntPtr code); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments