You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2016/02/25 00:56:29 UTC

[28/36] lucy-clownfish git commit: More liberal Py to Cfish Obj conversion.

More liberal Py to Cfish Obj conversion.

When converting a Python argument to Clownfish `Obj*`, allow conversion
from Python dict, list, string, integer, and other types -- instead of
just checking to confirm that the argument is already a Clownfish Obj.


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/b05965ca
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/b05965ca
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/b05965ca

Branch: refs/heads/py_exp13
Commit: b05965cafb60362badf530872dc81a304b9db761
Parents: 73635f2
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Sat Feb 6 09:41:59 2016 -0800
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Wed Feb 24 15:36:07 2016 -0800

----------------------------------------------------------------------
 compiler/src/CFCPyMethod.c    | 3 ++-
 runtime/python/cfext/CFBind.c | 7 ++++---
 2 files changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b05965ca/compiler/src/CFCPyMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPyMethod.c b/compiler/src/CFCPyMethod.c
index d8128c2..ea97d6a 100644
--- a/compiler/src/CFCPyMethod.c
+++ b/compiler/src/CFCPyMethod.c
@@ -464,7 +464,8 @@ S_gen_decrefs(CFCParamList *param_list, int first_tick) {
         const char *micro_sym = CFCVariable_get_name(var);
         const char *specifier = CFCType_get_specifier(type);
 
-        if (strcmp(specifier, "cfish_String") == 0
+        if (strcmp(specifier, "cfish_Obj") == 0
+             || strcmp(specifier, "cfish_String") == 0
              || strcmp(specifier, "cfish_Vector") == 0
              || strcmp(specifier, "cfish_Hash") == 0
             ) {

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b05965ca/runtime/python/cfext/CFBind.c
----------------------------------------------------------------------
diff --git a/runtime/python/cfext/CFBind.c b/runtime/python/cfext/CFBind.c
index a1e47eb..cd77078 100644
--- a/runtime/python/cfext/CFBind.c
+++ b/runtime/python/cfext/CFBind.c
@@ -294,12 +294,13 @@ S_convert_obj(PyObject *py_obj, CFBindArg *arg, bool nullable) {
             return 0;
         }
     }
-    PyTypeObject *py_type = S_get_cached_py_type(arg->klass);
-    if (!PyObject_TypeCheck(py_obj, py_type)) {
+
+    bool success = S_maybe_py_to_cfish(py_obj, arg->klass, true, nullable,
+                                       NULL, arg->ptr);
+    if (!success) {
         PyErr_SetString(PyExc_TypeError, "Invalid argument type");
         return 0;
     }
-    *((PyObject**)arg->ptr) = py_obj;
     return 1;
 }