Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Logical changes from sdpython/pythonnet3
refactored all logical changes from just appending  python3.5 to everything
Removed some debug code from original changes, and cleaned up some changes
  • Loading branch information
vmuriart committed Feb 23, 2016
commit 489ca813eec542898eaf3de419450c574368478a
38 changes: 37 additions & 1 deletion src/runtime/interop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,12 @@ public static int magic() {
public static int tp_print = 0;
public static int tp_getattr = 0;
public static int tp_setattr = 0;
public static int tp_compare = 0; /* tp_reserved in Python 3 */

#if (PYTHON35)
public static int tp_as_async = 0; /* tp_reserved, tp_compare in Python 3 */
#else
public static int tp_reserved = 0; /* tp_reserved, tp_compare in Python 3 */
#endif
public static int tp_repr = 0;

/* Method suites for standard classes */
Expand Down Expand Up @@ -329,6 +334,10 @@ public static int magic() {
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
/* Added in release 2.5 */
public static int nb_index = 0;
#endif
#if (PYTHON35)
public static int nb_matrix_multiply;
public static int nb_inplace_matrix_multiply;
#endif
//} PyNumberMethods;
//typedef struct {
Expand Down Expand Up @@ -356,6 +365,14 @@ public static int magic() {
public static int bf_getsegcount = 0;
public static int bf_getcharbuffer = 0;
#endif
#if (PYTHON35)
//typedef struct {
public static int am_await = 0;
public static int am_aiter = 0;
public static int am_anext = 0;
// } PyAsyncMethods
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are in the wrong place. They should be between ht_type and as_number.

#endif

#if (PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
// This addition is not actually noted in the 2.6.5 object.h
public static int bf_getbuffer = 0;
Expand Down Expand Up @@ -456,7 +473,11 @@ public static void FreeModuleDef(IntPtr ptr) {
public static int m_doc = 0;
public static int m_size = 0;
public static int m_methods = 0;
#if (PYTHON35)
public static int m_slots = 0;
#else
public static int m_reload = 0;
#endif
public static int m_traverse = 0;
public static int m_clear = 0;
public static int m_free = 0;
Expand Down Expand Up @@ -574,7 +595,11 @@ static Interop() {
pmap["tp_print"] = p["PrintFunc"];
pmap["tp_getattr"] = p["BinaryFunc"];
pmap["tp_setattr"] = p["ObjObjArgFunc"];
#if (PYTHON35)
//pmap["tp_as_async"] = p["IntObjArgFunc"];
#else
pmap["tp_compare"] = p["ObjObjFunc"];
#endif
pmap["tp_repr"] = p["UnaryFunc"];
pmap["tp_hash"] = p["UnaryFunc"];
pmap["tp_call"] = p["TernaryFunc"];
Expand Down Expand Up @@ -640,6 +665,10 @@ static Interop() {
pmap["nb_index"] = p["UnaryFunc"];
#endif

#if (PYTHON35)
pmap["nb_matrix_multiply"] = p["BinaryFunc"];
pmap["nb_inplace_matrix_multiply"] = p["BinaryFunc"];
#endif
pmap["sq_length"] = p["InquiryFunc"];
pmap["sq_concat"] = p["BinaryFunc"];
pmap["sq_repeat"] = p["IntArgFunc"];
Expand All @@ -660,6 +689,13 @@ static Interop() {
pmap["bf_getsegcount"] = p["ObjObjFunc"];
pmap["bf_getcharbuffer"] = p["IntObjArgFunc"];

#if (PYTHON35)
pmap["am_await"] = p["UnaryFunc"];
pmap["am_aiter"] = p["UnaryFunc"];
pmap["am_anext"] = p["UnaryFunc"];
pmap["tp_finalize"] = p["DestructorFunc"];
#endif

pmap["__import__"] = p["TernaryFunc"];
}

Expand Down
10 changes: 10 additions & 0 deletions src/runtime/runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ public class Runtime {
public const string pyversion = "3.4";
public const int pyversionnumber = 34;
#endif
#if (PYTHON35)
public const string pyversion = "3.5";
public const int pyversionnumber = 35;
#endif
#if ! (PYTHON23 || PYTHON24 || PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#error You must define one of PYTHON23 to PYTHON35
#endif
Expand Down Expand Up @@ -173,6 +177,9 @@ public class Runtime {
#if (PYTHON34)
internal const string dllBase = "python3.4";
#endif
#if (PYTHON35)
internal const string dllBase = "python3.5";
#endif
#else
#if (PYTHON32)
internal const string dllBase = "python32";
Expand All @@ -183,6 +190,9 @@ public class Runtime {
#if (PYTHON34)
internal const string dllBase = "python34";
#endif
#if (PYTHON35)
internal const string dllBase = "python35";
#endif
#endif

#if (PYTHON_WITH_PYDEBUG)
Expand Down
5 changes: 5 additions & 0 deletions src/runtime/typemanager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,11 @@ internal static IntPtr AllocateTypeObject(string name) {
Marshal.WriteIntPtr(type, TypeOffset.tp_as_buffer, temp);
#endif

#if(PYTHON35)
temp = new IntPtr(ptr + TypeOffset.am_await);
Marshal.WriteIntPtr(type, TypeOffset.tp_as_async, temp);
#endif

return type;
}

Expand Down