|
Karsten Hopp |
32e4e7 |
To: vim-dev@vim.org
|
|
Karsten Hopp |
32e4e7 |
Subject: Patch 7.2.374
|
|
Karsten Hopp |
32e4e7 |
Fcc: outbox
|
|
Karsten Hopp |
32e4e7 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
32e4e7 |
Mime-Version: 1.0
|
|
Karsten Hopp |
32e4e7 |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
32e4e7 |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
32e4e7 |
------------
|
|
Karsten Hopp |
32e4e7 |
|
|
Karsten Hopp |
32e4e7 |
Patch 7.2.374
|
|
Karsten Hopp |
32e4e7 |
Problem: Ruby eval() doesn't understand Vim types.
|
|
Karsten Hopp |
32e4e7 |
Solution: Add the vim_to_ruby() function. (George Gensure)
|
|
Karsten Hopp |
32e4e7 |
Files: src/eval.c, src/if_ruby.c
|
|
Karsten Hopp |
32e4e7 |
|
|
Karsten Hopp |
32e4e7 |
|
|
Karsten Hopp |
32e4e7 |
*** ../vim-7.2.373/src/eval.c 2010-01-19 15:51:29.000000000 +0100
|
|
Karsten Hopp |
32e4e7 |
--- src/eval.c 2010-02-24 15:36:40.000000000 +0100
|
|
Karsten Hopp |
32e4e7 |
***************
|
|
Karsten Hopp |
32e4e7 |
*** 5872,5878 ****
|
|
Karsten Hopp |
32e4e7 |
return item1 == NULL && item2 == NULL;
|
|
Karsten Hopp |
32e4e7 |
}
|
|
Karsten Hopp |
32e4e7 |
|
|
Karsten Hopp |
32e4e7 |
! #if defined(FEAT_PYTHON) || defined(FEAT_MZSCHEME) || defined(PROTO)
|
|
Karsten Hopp |
32e4e7 |
/*
|
|
Karsten Hopp |
32e4e7 |
* Return the dictitem that an entry in a hashtable points to.
|
|
Karsten Hopp |
32e4e7 |
*/
|
|
Karsten Hopp |
32e4e7 |
--- 5872,5879 ----
|
|
Karsten Hopp |
32e4e7 |
return item1 == NULL && item2 == NULL;
|
|
Karsten Hopp |
32e4e7 |
}
|
|
Karsten Hopp |
32e4e7 |
|
|
Karsten Hopp |
32e4e7 |
! #if defined(FEAT_RUBY) || defined(FEAT_PYTHON) || defined(FEAT_MZSCHEME) \
|
|
Karsten Hopp |
32e4e7 |
! || defined(PROTO)
|
|
Karsten Hopp |
32e4e7 |
/*
|
|
Karsten Hopp |
32e4e7 |
* Return the dictitem that an entry in a hashtable points to.
|
|
Karsten Hopp |
32e4e7 |
*/
|
|
Karsten Hopp |
32e4e7 |
*** ../vim-7.2.373/src/if_ruby.c 2010-02-18 15:51:25.000000000 +0100
|
|
Karsten Hopp |
32e4e7 |
--- src/if_ruby.c 2010-02-24 15:45:15.000000000 +0100
|
|
Karsten Hopp |
32e4e7 |
***************
|
|
Karsten Hopp |
32e4e7 |
*** 660,679 ****
|
|
Karsten Hopp |
32e4e7 |
return Qnil;
|
|
Karsten Hopp |
32e4e7 |
}
|
|
Karsten Hopp |
32e4e7 |
|
|
Karsten Hopp |
32e4e7 |
static VALUE vim_evaluate(VALUE self UNUSED, VALUE str)
|
|
Karsten Hopp |
32e4e7 |
{
|
|
Karsten Hopp |
32e4e7 |
#ifdef FEAT_EVAL
|
|
Karsten Hopp |
32e4e7 |
! char_u *value = eval_to_string((char_u *)StringValuePtr(str), NULL, TRUE);
|
|
Karsten Hopp |
32e4e7 |
|
|
Karsten Hopp |
32e4e7 |
! if (value != NULL)
|
|
Karsten Hopp |
32e4e7 |
{
|
|
Karsten Hopp |
32e4e7 |
! VALUE val = rb_str_new2((char *)value);
|
|
Karsten Hopp |
32e4e7 |
! vim_free(value);
|
|
Karsten Hopp |
32e4e7 |
! return val;
|
|
Karsten Hopp |
32e4e7 |
}
|
|
Karsten Hopp |
32e4e7 |
! else
|
|
Karsten Hopp |
32e4e7 |
#endif
|
|
Karsten Hopp |
32e4e7 |
- return Qnil;
|
|
Karsten Hopp |
32e4e7 |
}
|
|
Karsten Hopp |
32e4e7 |
|
|
Karsten Hopp |
32e4e7 |
static VALUE buffer_new(buf_T *buf)
|
|
Karsten Hopp |
32e4e7 |
--- 660,747 ----
|
|
Karsten Hopp |
32e4e7 |
return Qnil;
|
|
Karsten Hopp |
32e4e7 |
}
|
|
Karsten Hopp |
32e4e7 |
|
|
Karsten Hopp |
32e4e7 |
+ #ifdef FEAT_EVAL
|
|
Karsten Hopp |
32e4e7 |
+ static VALUE vim_to_ruby(typval_T *tv)
|
|
Karsten Hopp |
32e4e7 |
+ {
|
|
Karsten Hopp |
32e4e7 |
+ VALUE result = Qnil;
|
|
Karsten Hopp |
32e4e7 |
+
|
|
Karsten Hopp |
32e4e7 |
+ if (tv->v_type == VAR_STRING)
|
|
Karsten Hopp |
32e4e7 |
+ {
|
|
Karsten Hopp |
32e4e7 |
+ result = rb_str_new2((char *)tv->vval.v_string);
|
|
Karsten Hopp |
32e4e7 |
+ }
|
|
Karsten Hopp |
32e4e7 |
+ else if (tv->v_type == VAR_NUMBER)
|
|
Karsten Hopp |
32e4e7 |
+ {
|
|
Karsten Hopp |
32e4e7 |
+ result = INT2NUM(tv->vval.v_number);
|
|
Karsten Hopp |
32e4e7 |
+ }
|
|
Karsten Hopp |
32e4e7 |
+ # ifdef FEAT_FLOAT
|
|
Karsten Hopp |
32e4e7 |
+ else if (tv->v_type == VAR_FLOAT)
|
|
Karsten Hopp |
32e4e7 |
+ {
|
|
Karsten Hopp |
32e4e7 |
+ result = rb_float_new(tv->vval.v_float);
|
|
Karsten Hopp |
32e4e7 |
+ }
|
|
Karsten Hopp |
32e4e7 |
+ # endif
|
|
Karsten Hopp |
32e4e7 |
+ else if (tv->v_type == VAR_LIST)
|
|
Karsten Hopp |
32e4e7 |
+ {
|
|
Karsten Hopp |
32e4e7 |
+ list_T *list = tv->vval.v_list;
|
|
Karsten Hopp |
32e4e7 |
+ listitem_T *curr;
|
|
Karsten Hopp |
32e4e7 |
+
|
|
Karsten Hopp |
32e4e7 |
+ result = rb_ary_new();
|
|
Karsten Hopp |
32e4e7 |
+
|
|
Karsten Hopp |
32e4e7 |
+ if (list != NULL)
|
|
Karsten Hopp |
32e4e7 |
+ {
|
|
Karsten Hopp |
32e4e7 |
+ for (curr = list->lv_first; curr != NULL; curr = curr->li_next)
|
|
Karsten Hopp |
32e4e7 |
+ {
|
|
Karsten Hopp |
32e4e7 |
+ rb_ary_push(result, vim_to_ruby(&curr->li_tv));
|
|
Karsten Hopp |
32e4e7 |
+ }
|
|
Karsten Hopp |
32e4e7 |
+ }
|
|
Karsten Hopp |
32e4e7 |
+ }
|
|
Karsten Hopp |
32e4e7 |
+ else if (tv->v_type == VAR_DICT)
|
|
Karsten Hopp |
32e4e7 |
+ {
|
|
Karsten Hopp |
32e4e7 |
+ result = rb_hash_new();
|
|
Karsten Hopp |
32e4e7 |
+
|
|
Karsten Hopp |
32e4e7 |
+ if (tv->vval.v_dict != NULL)
|
|
Karsten Hopp |
32e4e7 |
+ {
|
|
Karsten Hopp |
32e4e7 |
+ hashtab_T *ht = &tv->vval.v_dict->dv_hashtab;
|
|
Karsten Hopp |
32e4e7 |
+ long_u todo = ht->ht_used;
|
|
Karsten Hopp |
32e4e7 |
+ hashitem_T *hi;
|
|
Karsten Hopp |
32e4e7 |
+ dictitem_T *di;
|
|
Karsten Hopp |
32e4e7 |
+
|
|
Karsten Hopp |
32e4e7 |
+ for (hi = ht->ht_array; todo > 0; ++hi)
|
|
Karsten Hopp |
32e4e7 |
+ {
|
|
Karsten Hopp |
32e4e7 |
+ if (!HASHITEM_EMPTY(hi))
|
|
Karsten Hopp |
32e4e7 |
+ {
|
|
Karsten Hopp |
32e4e7 |
+ --todo;
|
|
Karsten Hopp |
32e4e7 |
+
|
|
Karsten Hopp |
32e4e7 |
+ di = dict_lookup(hi);
|
|
Karsten Hopp |
32e4e7 |
+ rb_hash_aset(result, rb_str_new2((char *)hi->hi_key),
|
|
Karsten Hopp |
32e4e7 |
+ vim_to_ruby(&di->di_tv));
|
|
Karsten Hopp |
32e4e7 |
+ }
|
|
Karsten Hopp |
32e4e7 |
+ }
|
|
Karsten Hopp |
32e4e7 |
+ }
|
|
Karsten Hopp |
32e4e7 |
+ } /* else return Qnil; */
|
|
Karsten Hopp |
32e4e7 |
+
|
|
Karsten Hopp |
32e4e7 |
+ return result;
|
|
Karsten Hopp |
32e4e7 |
+ }
|
|
Karsten Hopp |
32e4e7 |
+ #endif
|
|
Karsten Hopp |
32e4e7 |
+
|
|
Karsten Hopp |
32e4e7 |
static VALUE vim_evaluate(VALUE self UNUSED, VALUE str)
|
|
Karsten Hopp |
32e4e7 |
{
|
|
Karsten Hopp |
32e4e7 |
#ifdef FEAT_EVAL
|
|
Karsten Hopp |
32e4e7 |
! typval_T *tv;
|
|
Karsten Hopp |
32e4e7 |
! VALUE result;
|
|
Karsten Hopp |
32e4e7 |
|
|
Karsten Hopp |
32e4e7 |
! tv = eval_expr((char_u *)StringValuePtr(str), NULL);
|
|
Karsten Hopp |
32e4e7 |
! if (tv == NULL)
|
|
Karsten Hopp |
32e4e7 |
{
|
|
Karsten Hopp |
32e4e7 |
! return Qnil;
|
|
Karsten Hopp |
32e4e7 |
}
|
|
Karsten Hopp |
32e4e7 |
! result = vim_to_ruby(tv);
|
|
Karsten Hopp |
32e4e7 |
!
|
|
Karsten Hopp |
32e4e7 |
! free_tv(tv);
|
|
Karsten Hopp |
32e4e7 |
!
|
|
Karsten Hopp |
32e4e7 |
! return result;
|
|
Karsten Hopp |
32e4e7 |
! #else
|
|
Karsten Hopp |
32e4e7 |
! return Qnil;
|
|
Karsten Hopp |
32e4e7 |
#endif
|
|
Karsten Hopp |
32e4e7 |
}
|
|
Karsten Hopp |
32e4e7 |
|
|
Karsten Hopp |
32e4e7 |
static VALUE buffer_new(buf_T *buf)
|
|
Karsten Hopp |
32e4e7 |
*** ../vim-7.2.373/src/version.c 2010-02-24 15:25:13.000000000 +0100
|
|
Karsten Hopp |
32e4e7 |
--- src/version.c 2010-02-24 15:46:57.000000000 +0100
|
|
Karsten Hopp |
32e4e7 |
***************
|
|
Karsten Hopp |
32e4e7 |
*** 683,684 ****
|
|
Karsten Hopp |
32e4e7 |
--- 683,686 ----
|
|
Karsten Hopp |
32e4e7 |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
32e4e7 |
+ /**/
|
|
Karsten Hopp |
32e4e7 |
+ 374,
|
|
Karsten Hopp |
32e4e7 |
/**/
|
|
Karsten Hopp |
32e4e7 |
|
|
Karsten Hopp |
32e4e7 |
--
|
|
Karsten Hopp |
32e4e7 |
ARTHUR: (as the MAN next to him is squashed by a sheep) Knights! Run away!
|
|
Karsten Hopp |
32e4e7 |
Midst echoing shouts of "run away" the KNIGHTS retreat to cover with the odd
|
|
Karsten Hopp |
32e4e7 |
cow or goose hitting them still. The KNIGHTS crouch down under cover.
|
|
Karsten Hopp |
32e4e7 |
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
|
|
Karsten Hopp |
32e4e7 |
|
|
Karsten Hopp |
32e4e7 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
32e4e7 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
32e4e7 |
\\\ download, build and distribute -- http://www.A-A-P.org ///
|
|
Karsten Hopp |
32e4e7 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|