summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2015-01-30 01:42:49 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2015-01-31 00:35:56 +0200
commit98c4bc3facff901a38cdbc2df99ee5da17ba3f2e (patch)
tree0137a13fff24444b9114f8ab8c53ed794a0d70f7
parent32bade19d952c23c2fd499050abb17cb80dc7559 (diff)
downloadmicropython-98c4bc3facff901a38cdbc2df99ee5da17ba3f2e.tar.gz
micropython-98c4bc3facff901a38cdbc2df99ee5da17ba3f2e.zip
py: Add MICROPY_PY_ALL_SPECIAL_METHODS and __iadd__ special method under it.
-rw-r--r--py/mpconfig.h6
-rw-r--r--py/objtype.c8
-rw-r--r--py/qstrdefs.h3
-rw-r--r--unix/mpconfigport.h1
4 files changed, 15 insertions, 3 deletions
diff --git a/py/mpconfig.h b/py/mpconfig.h
index b54bd65442..e8c8fcc596 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -376,6 +376,12 @@ typedef double mp_float_t;
#define MICROPY_PY_BUILTINS_PROPERTY (1)
#endif
+// Whether to support complete set of special methods
+// for user classes, otherwise only the most used
+#ifndef MICROPY_PY_ALL_SPECIAL_METHODS
+#define MICROPY_PY_ALL_SPECIAL_METHODS (0)
+#endif
+
// Whether to support compile function
#ifndef MICROPY_PY_BUILTINS_COMPILE
#define MICROPY_PY_BUILTINS_COMPILE (0)
diff --git a/py/objtype.c b/py/objtype.c
index 53408a07ed..f905831f20 100644
--- a/py/objtype.c
+++ b/py/objtype.c
@@ -378,9 +378,11 @@ const qstr mp_binary_op_method_name[] = {
MP_BINARY_OP_INPLACE_XOR,
MP_BINARY_OP_INPLACE_AND,
MP_BINARY_OP_INPLACE_LSHIFT,
- MP_BINARY_OP_INPLACE_RSHIFT,
- MP_BINARY_OP_INPLACE_ADD,
- MP_BINARY_OP_INPLACE_SUBTRACT,
+ MP_BINARY_OP_INPLACE_RSHIFT,*/
+ #if MICROPY_PY_ALL_SPECIAL_METHODS
+ [MP_BINARY_OP_INPLACE_ADD] = MP_QSTR___iadd__,
+ #endif
+ /*MP_BINARY_OP_INPLACE_SUBTRACT,
MP_BINARY_OP_INPLACE_MULTIPLY,
MP_BINARY_OP_INPLACE_FLOOR_DIVIDE,
MP_BINARY_OP_INPLACE_TRUE_DIVIDE,
diff --git a/py/qstrdefs.h b/py/qstrdefs.h
index 23c25072d9..ffb2bf0321 100644
--- a/py/qstrdefs.h
+++ b/py/qstrdefs.h
@@ -75,6 +75,9 @@ Q(__eq__)
Q(__le__)
Q(__ge__)
Q(__reversed__)
+#if MICROPY_PY_ALL_SPECIAL_METHODS
+Q(__iadd__)
+#endif
Q(micropython)
Q(bytecode)
diff --git a/unix/mpconfigport.h b/unix/mpconfigport.h
index 42650ebabf..a0366d9c6b 100644
--- a/unix/mpconfigport.h
+++ b/unix/mpconfigport.h
@@ -59,6 +59,7 @@
#define MICROPY_PY_BUILTINS_FROZENSET (1)
#define MICROPY_PY_BUILTINS_COMPILE (1)
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
+#define MICROPY_PY_ALL_SPECIAL_METHODS (1)
#define MICROPY_PY_SYS_EXIT (1)
#define MICROPY_PY_SYS_PLATFORM "linux"
#define MICROPY_PY_SYS_MAXSIZE (1)