Hi,

2016/3/25 Fri 8:20:06 UTC+9 Ken Takata wrote:
> Hi Bram,
> 
> 2016/3/25 Fri 5:58:36 UTC+9 Bram Moolenaar wrote:
> > Patch 7.4.1646
> > Problem:    Using Python vim.bindeval() on a partial doesn't work. (Nikolai
> >             Pavlov)
> > Solution:   Add VAR_PARTIAL support in Python.
> > Files:      src/if_py_both.h
> 
> Maybe we also need VAR_PARTIAL support in if_mzsch.

I wrote a patch for this.  Unfortunately, I think I found an existing bug.
func_ref() and func_unref() are not called in if_mzsch.c.
Maybe we need to add a custom type for holding a funcref like if_python.
I don't know how to do it...

--- a/src/if_mzsch.c
+++ b/src/if_mzsch.c
@@ -3109,6 +3109,7 @@ vim_to_mzscheme_impl(typval_T *vim_value
        MZ_GC_VAR_IN_REG(0, funcname);
        MZ_GC_REG();
 
+       /* FIXME: func_ref() and func_unref() are needed. */
        funcname = scheme_make_byte_string((char *)vim_value->vval.v_string);
        MZ_GC_CHECK();
        result = scheme_make_closed_prim_w_arity(vim_funcref, funcname,
@@ -3117,6 +3118,30 @@ vim_to_mzscheme_impl(typval_T *vim_value
 
        MZ_GC_UNREG();
     }
+    else if (vim_value->v_type == VAR_PARTIAL)
+    {
+       if (vim_value->vval.v_partial == NULL)
+           result = scheme_null;
+       else
+       {
+           Scheme_Object *funcname = NULL;
+
+           MZ_GC_DECL_REG(1);
+           MZ_GC_VAR_IN_REG(0, funcname);
+           MZ_GC_REG();
+
+           /* FIXME: func_ref() and func_unref() are needed. */
+           /* TODO: Support pt_dict and pt_argv. */
+           funcname = scheme_make_byte_string(
+                   (char *)vim_value->vval.v_partial->pt_name);
+           MZ_GC_CHECK();
+           result = scheme_make_closed_prim_w_arity(vim_funcref, funcname,
+                   (const char *)BYTE_STRING_VALUE(funcname), 0, -1);
+           MZ_GC_CHECK();
+
+           MZ_GC_UNREG();
+       }
+    }
     else if (vim_value->v_type == VAR_SPECIAL)
     {
        if (vim_value->vval.v_number <= VVAL_TRUE)


Regards,
Ken Takata

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui