summaryrefslogtreecommitdiffstats
path: root/gvim/vim-7.2/7.2.336
blob: a6765922fb374a0e7873d7fd6c41efbb7a477572 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
To: vim-dev@vim.org
Subject: Patch 7.2.336
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.2.336
Problem:    MzScheme interface can't evaluate an expression.
Solution:   Add mzeval(). (Sergey Khorev)
Files:	    runtime/doc/eval.txt, runtime/doc/if_mzsch.txt,
	    runtime/doc/usr_41.txt, src/eval.c, src/if_mzsch.c,
	    src/proto/eval.pro, src/proto/if_mzsch.pro,
	    src/testdir/Make_dos.mak, src/testdir/Make_ming.mak,
	    src/testdir/Makefile, src/testdir/main.aap, src/testdir/test1.in,
	    src/testdir/test70.in, src/testdir/test70.ok


*** ../vim-7.2.335/runtime/doc/eval.txt	2009-11-17 12:20:30.000000000 +0100
--- runtime/doc/eval.txt	2010-01-19 15:30:50.000000000 +0100
***************
*** 1815,1825 ****
  				List	match and submatches of {pat} in {expr}
  matchstr( {expr}, {pat}[, {start}[, {count}]])
  				String	{count}'th match of {pat} in {expr}
! max({list})			Number	maximum value of items in {list}
! min({list})			Number	minimum value of items in {list}
! mkdir({name} [, {path} [, {prot}]])
  				Number	create directory {name}
  mode( [expr])			String	current editing mode
  nextnonblank( {lnum})		Number	line nr of non-blank line >= {lnum}
  nr2char( {expr})		String	single char with ASCII value {expr}
  pathshorten( {expr})		String	shorten directory names in a path
--- 1821,1832 ----
  				List	match and submatches of {pat} in {expr}
  matchstr( {expr}, {pat}[, {start}[, {count}]])
  				String	{count}'th match of {pat} in {expr}
! max( {list})			Number	maximum value of items in {list}
! min( {list})			Number	minimum value of items in {list}
! mkdir( {name} [, {path} [, {prot}]])
  				Number	create directory {name}
  mode( [expr])			String	current editing mode
+ mzeval( {expr})			any	evaluate |MzScheme| expression
  nextnonblank( {lnum})		Number	line nr of non-blank line >= {lnum}
  nr2char( {expr})		String	single char with ASCII value {expr}
  pathshorten( {expr})		String	shorten directory names in a path
***************
*** 4090,4095 ****
--- 4103,4125 ----
  		"c" or "n".
  		Also see |visualmode()|.
  
+ mzeval({expr})							*mzeval()*
+ 		Evaluate MzScheme expression {expr} and return its result
+ 		convert to Vim data structures.
+ 		Numbers and strings are returned as they are.
+ 		Pairs (including lists and improper lists) and vectors are
+ 		returned as Vim |Lists|.
+ 		Hash tables are represented as Vim |Dictionary| type with keys
+ 		converted to strings.
+ 		All other types are converted to string with display function.
+ 		Examples: >
+ 		    :mz (define l (list 1 2 3))
+ 		    :mz (define h (make-hash)) (hash-set! h "list" l)
+ 		    :echo mzeval("l")
+ 		    :echo mzeval("h")
+ <
+ 		{only available when compiled with the |+mzscheme| feature}
+ 
  nextnonblank({lnum})					*nextnonblank()*
  		Return the line number of the first line at or below {lnum}
  		that is not blank.  Example: >
*** ../vim-7.2.335/runtime/doc/if_mzsch.txt	2009-06-24 17:51:01.000000000 +0200
--- runtime/doc/if_mzsch.txt	2010-01-19 15:33:00.000000000 +0100
***************
*** 1,4 ****
! *if_mzsch.txt*  For Vim version 7.2.  Last change: 2009 Jun 24
  
  
  		  VIM REFERENCE MANUAL    by Sergey Khorev
--- 1,4 ----
! *if_mzsch.txt*  For Vim version 7.2.  Last change: 2010 Jan 19
  
  
  		  VIM REFERENCE MANUAL    by Sergey Khorev
***************
*** 9,16 ****
  1. Commands				|mzscheme-commands|
  2. Examples				|mzscheme-examples|
  3. Threads				|mzscheme-threads|
! 4. The Vim access procedures		|mzscheme-vim|
! 5. Dynamic loading			|mzscheme-dynamic|
  
  {Vi does not have any of these commands}
  
--- 9,17 ----
  1. Commands				|mzscheme-commands|
  2. Examples				|mzscheme-examples|
  3. Threads				|mzscheme-threads|
! 4. Vim access from MzScheme		|mzscheme-vim|
! 5. mzeval() Vim function		|mzscheme-mzeval|
! 6. Dynamic loading			|mzscheme-dynamic|
  
  {Vi does not have any of these commands}
  
***************
*** 142,148 ****
  GUI version.
  
  ==============================================================================
! 5. VIM Functions					*mzscheme-vim*
  
  							*mzscheme-vimext*
  The 'vimext' module provides access to procedures defined in the MzScheme
--- 143,149 ----
  GUI version.
  
  ==============================================================================
! 4. Vim access from MzScheme				*mzscheme-vim*
  
  							*mzscheme-vimext*
  The 'vimext' module provides access to procedures defined in the MzScheme
***************
*** 231,237 ****
      (set-cursor (line . col) [window])  Set cursor position.
  
  ==============================================================================
! 5. Dynamic loading				    *mzscheme-dynamic* *E815*
  
  On MS-Windows the MzScheme libraries can be loaded dynamically. The |:version|
  output then includes |+mzscheme/dyn|.
--- 232,244 ----
      (set-cursor (line . col) [window])  Set cursor position.
  
  ==============================================================================
! 5. mzeval() Vim function				    *mzscheme-mzeval*
! 
! To facilitate bi-directional interface, you can use |mzeval| function to
! evaluate MzScheme expressions and pass their values to VimL.
! 
! ==============================================================================
! 6. Dynamic loading				    *mzscheme-dynamic* *E815*
  
  On MS-Windows the MzScheme libraries can be loaded dynamically. The |:version|
  output then includes |+mzscheme/dyn|.
*** ../vim-7.2.335/runtime/doc/usr_41.txt	2008-08-09 19:36:54.000000000 +0200
--- runtime/doc/usr_41.txt	2010-01-19 15:29:01.000000000 +0100
***************
*** 868,873 ****
--- 868,875 ----
  	taglist()		get list of matching tags
  	tagfiles()		get a list of tags files
  
+ 	mzeval()		evaluate |MzScheme| expression
+ 
  ==============================================================================
  *41.7*	Defining a function
  
*** ../vim-7.2.335/src/eval.c	2010-01-19 12:46:51.000000000 +0100
--- src/eval.c	2010-01-19 15:48:12.000000000 +0100
***************
*** 433,439 ****
  static long list_find_nr __ARGS((list_T *l, long idx, int *errorp));
  static long list_idx_of_item __ARGS((list_T *l, listitem_T *item));
  static void list_append __ARGS((list_T *l, listitem_T *item));
- static int list_append_tv __ARGS((list_T *l, typval_T *tv));
  static int list_append_number __ARGS((list_T *l, varnumber_T n));
  static int list_insert_tv __ARGS((list_T *l, typval_T *tv, listitem_T *item));
  static int list_extend __ARGS((list_T	*l1, list_T *l2, listitem_T *bef));
--- 433,438 ----
***************
*** 448,459 ****
  static void set_ref_in_item __ARGS((typval_T *tv, int copyID));
  static void dict_unref __ARGS((dict_T *d));
  static void dict_free __ARGS((dict_T *d, int recurse));
- static dictitem_T *dictitem_alloc __ARGS((char_u *key));
  static dictitem_T *dictitem_copy __ARGS((dictitem_T *org));
  static void dictitem_remove __ARGS((dict_T *dict, dictitem_T *item));
- static void dictitem_free __ARGS((dictitem_T *item));
  static dict_T *dict_copy __ARGS((dict_T *orig, int deep, int copyID));
- static int dict_add __ARGS((dict_T *d, dictitem_T *item));
  static long dict_len __ARGS((dict_T *d));
  static dictitem_T *dict_find __ARGS((dict_T *d, char_u *key, int len));
  static char_u *dict2string __ARGS((typval_T *tv, int copyID));
--- 447,455 ----
***************
*** 628,633 ****
--- 624,632 ----
  static void f_mkdir __ARGS((typval_T *argvars, typval_T *rettv));
  #endif
  static void f_mode __ARGS((typval_T *argvars, typval_T *rettv));
+ #ifdef FEAT_MZSCHEME
+ static void f_mzeval __ARGS((typval_T *argvars, typval_T *rettv));
+ #endif
  static void f_nextnonblank __ARGS((typval_T *argvars, typval_T *rettv));
  static void f_nr2char __ARGS((typval_T *argvars, typval_T *rettv));
  static void f_pathshorten __ARGS((typval_T *argvars, typval_T *rettv));
***************
*** 764,770 ****
  static int var_check_ro __ARGS((int flags, char_u *name));
  static int var_check_fixed __ARGS((int flags, char_u *name));
  static int tv_check_lock __ARGS((int lock, char_u *name));
- static void copy_tv __ARGS((typval_T *from, typval_T *to));
  static int item_copy __ARGS((typval_T *from, typval_T *to, int deep, int copyID));
  static char_u *find_option_end __ARGS((char_u **arg, int *opt_flags));
  static char_u *trans_function_name __ARGS((char_u **pp, int skip, int flags, funcdict_T *fd));
--- 763,768 ----
***************
*** 6155,6161 ****
   * Append typval_T "tv" to the end of list "l".
   * Return FAIL when out of memory.
   */
!     static int
  list_append_tv(l, tv)
      list_T	*l;
      typval_T	*tv;
--- 6153,6159 ----
   * Append typval_T "tv" to the end of list "l".
   * Return FAIL when out of memory.
   */
!     int
  list_append_tv(l, tv)
      list_T	*l;
      typval_T	*tv;
***************
*** 6812,6818 ****
   * Note that the value of the item "di_tv" still needs to be initialized!
   * Returns NULL when out of memory.
   */
!     static dictitem_T *
  dictitem_alloc(key)
      char_u	*key;
  {
--- 6810,6816 ----
   * Note that the value of the item "di_tv" still needs to be initialized!
   * Returns NULL when out of memory.
   */
!     dictitem_T *
  dictitem_alloc(key)
      char_u	*key;
  {
***************
*** 6868,6874 ****
  /*
   * Free a dict item.  Also clears the value.
   */
!     static void
  dictitem_free(item)
      dictitem_T *item;
  {
--- 6866,6872 ----
  /*
   * Free a dict item.  Also clears the value.
   */
!     void
  dictitem_free(item)
      dictitem_T *item;
  {
***************
*** 6948,6954 ****
   * Add item "item" to Dictionary "d".
   * Returns FAIL when out of memory and when key already existed.
   */
!     static int
  dict_add(d, item)
      dict_T	*d;
      dictitem_T	*item;
--- 6946,6952 ----
   * Add item "item" to Dictionary "d".
   * Returns FAIL when out of memory and when key already existed.
   */
!     int
  dict_add(d, item)
      dict_T	*d;
      dictitem_T	*item;
***************
*** 7699,7704 ****
--- 7697,7705 ----
      {"mkdir",		1, 3, f_mkdir},
  #endif
      {"mode",		0, 1, f_mode},
+ #ifdef FEAT_MZSCHEME
+     {"mzeval",		1, 1, f_mzeval},
+ #endif
      {"nextnonblank",	1, 1, f_nextnonblank},
      {"nr2char",		1, 1, f_nr2char},
      {"pathshorten",	1, 1, f_pathshorten},
***************
*** 13591,13596 ****
--- 13592,13614 ----
      rettv->v_type = VAR_STRING;
  }
  
+ #ifdef FEAT_MZSCHEME
+ /*
+  * "mzeval()" function
+  */
+     static void
+ f_mzeval(argvars, rettv)
+     typval_T	*argvars;
+     typval_T	*rettv;
+ {
+     char_u	*str;
+     char_u	buf[NUMBUFLEN];
+ 
+     str = get_tv_string_buf(&argvars[0], buf);
+     do_mzeval(str, rettv);
+ }
+ #endif
+ 
  /*
   * "nextnonblank()" function
   */
***************
*** 19274,19280 ****
   * It is OK for "from" and "to" to point to the same item.  This is used to
   * make a copy later.
   */
!     static void
  copy_tv(from, to)
      typval_T *from;
      typval_T *to;
--- 19292,19298 ----
   * It is OK for "from" and "to" to point to the same item.  This is used to
   * make a copy later.
   */
!     void
  copy_tv(from, to)
      typval_T *from;
      typval_T *to;
*** ../vim-7.2.335/src/if_mzsch.c	2009-12-16 19:02:05.000000000 +0100
--- src/if_mzsch.c	2010-01-19 15:43:05.000000000 +0100
***************
*** 170,175 ****
--- 170,177 ----
  #ifdef FEAT_EVAL
  static Scheme_Object *vim_to_mzscheme(typval_T *vim_value, int depth,
  	Scheme_Hash_Table *visited);
+ static int mzscheme_to_vim(Scheme_Object *obj, typval_T *tv, int depth,
+ 	Scheme_Hash_Table *visited);
  #endif
  
  #ifdef MZ_PRECISE_GC
***************
*** 2733,2738 ****
--- 2735,2959 ----
      MZ_GC_UNREG();
      return result;
  }
+ 
+     static int
+ mzscheme_to_vim(Scheme_Object *obj, typval_T *tv, int depth,
+ 	Scheme_Hash_Table *visited)
+ {
+     int		status = OK;
+     typval_T	*found;
+     MZ_GC_CHECK();
+     if (depth > 100) /* limit the deepest recursion level */
+     {
+ 	tv->v_type = VAR_NUMBER;
+ 	tv->vval.v_number = 0;
+ 	return FAIL;
+     }
+ 
+     found = (typval_T *)scheme_hash_get(visited, obj);
+     if (found != NULL)
+ 	copy_tv(found, tv);
+     else if (SCHEME_VOIDP(obj))
+     {
+ 	tv->v_type = VAR_NUMBER;
+ 	tv->vval.v_number = 0;
+     }
+     else if (SCHEME_INTP(obj))
+     {
+ 	tv->v_type = VAR_NUMBER;
+ 	tv->vval.v_number = SCHEME_INT_VAL(obj);
+     }
+     else if (SCHEME_BOOLP(obj))
+     {
+ 	tv->v_type = VAR_NUMBER;
+ 	tv->vval.v_number = SCHEME_TRUEP(obj);
+     }
+ # ifdef FEAT_FLOAT
+     else if (SCHEME_DBLP(obj))
+     {
+ 	tv->v_type = VAR_FLOAT;
+ 	tv->vval.v_float = SCHEME_DBL_VAL(obj);
+     }
+ # endif
+     else if (SCHEME_STRINGP(obj))
+     {
+ 	tv->v_type = VAR_STRING;
+ 	tv->vval.v_string = vim_strsave((char_u *)SCHEME_STR_VAL(obj));
+     }
+     else if (SCHEME_VECTORP(obj) || SCHEME_NULLP(obj)
+ 	    || SCHEME_PAIRP(obj) || SCHEME_MUTABLE_PAIRP(obj))
+     {
+ 	list_T  *list = list_alloc();
+ 	if (list == NULL)
+ 	    status = FAIL;
+ 	else
+ 	{
+ 	    int		    i;
+ 	    Scheme_Object   *curr = NULL;
+ 	    Scheme_Object   *cval = NULL;
+ 	    /* temporary var to hold current element of vectors and pairs */
+ 	    typval_T	    *v;
+ 
+ 	    MZ_GC_DECL_REG(2);
+ 	    MZ_GC_VAR_IN_REG(0, curr);
+ 	    MZ_GC_VAR_IN_REG(1, cval);
+ 	    MZ_GC_REG();
+ 
+ 	    tv->v_type = VAR_LIST;
+ 	    tv->vval.v_list = list;
+ 	    ++list->lv_refcount;
+ 
+ 	    v = (typval_T *)alloc(sizeof(typval_T));
+ 	    if (v == NULL)
+ 		status = FAIL;
+ 	    else
+ 	    {
+ 		/* add the value in advance to allow handling of self-referencial
+ 		 * data structures */
+ 		typval_T    *visited_tv = (typval_T *)alloc(sizeof(typval_T));
+ 		copy_tv(tv, visited_tv);
+ 		scheme_hash_set(visited, obj, (Scheme_Object *)visited_tv);
+ 
+ 		if (SCHEME_VECTORP(obj))
+ 		{
+ 		    for (i = 0; i < SCHEME_VEC_SIZE(obj); ++i)
+ 		    {
+ 			cval = SCHEME_VEC_ELS(obj)[i];
+ 			status = mzscheme_to_vim(cval, v, depth + 1, visited);
+ 			if (status == FAIL)
+ 			    break;
+ 			status = list_append_tv(list, v);
+ 			clear_tv(v);
+ 			if (status == FAIL)
+ 			    break;
+ 		    }
+ 		}
+ 		else if (SCHEME_PAIRP(obj) || SCHEME_MUTABLE_PAIRP(obj))
+ 		{
+ 		    for (curr = obj;
+ 			    SCHEME_PAIRP(curr) || SCHEME_MUTABLE_PAIRP(curr);
+ 			    curr = SCHEME_CDR(curr))
+ 		    {
+ 			cval = SCHEME_CAR(curr);
+ 			status = mzscheme_to_vim(cval, v, depth + 1, visited);
+ 			if (status == FAIL)
+ 			    break;
+ 			status = list_append_tv(list, v);
+ 			clear_tv(v);
+ 			if (status == FAIL)
+ 			    break;
+ 		    }
+ 		    /* impoper list not terminated with null
+ 		     * need to handle the last element */
+ 		    if (status == OK && !SCHEME_NULLP(curr))
+ 		    {
+ 			status = mzscheme_to_vim(cval, v, depth + 1, visited);
+ 			if (status == OK)
+ 			{
+ 			    status = list_append_tv(list, v);
+ 			    clear_tv(v);
+ 			}
+ 		    }
+ 		}
+ 		/* nothing to do for scheme_null */
+ 		vim_free(v);
+ 	    }
+ 	    MZ_GC_UNREG();
+ 	}
+     }
+     else if (SCHEME_HASHTP(obj))
+     {
+ 	int		i;
+ 	dict_T		*dict;
+ 	Scheme_Object   *key = NULL;
+ 	Scheme_Object   *val = NULL;
+ 
+ 	MZ_GC_DECL_REG(2);
+ 	MZ_GC_VAR_IN_REG(0, key);
+ 	MZ_GC_VAR_IN_REG(1, val);
+ 	MZ_GC_REG();
+ 
+ 	dict = dict_alloc();
+ 	if (dict == NULL)
+ 	    status = FAIL;
+ 	else
+ 	{
+ 	    typval_T    *visited_tv = (typval_T *)alloc(sizeof(typval_T));
+ 
+ 	    tv->v_type = VAR_DICT;
+ 	    tv->vval.v_dict = dict;
+ 	    ++dict->dv_refcount;
+ 
+ 	    copy_tv(tv, visited_tv);
+ 	    scheme_hash_set(visited, obj, (Scheme_Object *)visited_tv);
+ 
+ 	    for (i = 0; i < ((Scheme_Hash_Table *)obj)->size; ++i)
+ 	    {
+ 		if (((Scheme_Hash_Table *) obj)->vals[i] != NULL)
+ 		{
+ 		    /* generate item for `diplay'ed Scheme key */
+ 		    dictitem_T  *item = dictitem_alloc((char_u *)string_to_line(
+ 				((Scheme_Hash_Table *) obj)->keys[i]));
+ 		    /* convert Scheme val to Vim and add it to the dict */
+ 		    if (mzscheme_to_vim(((Scheme_Hash_Table *) obj)->vals[i],
+ 				    &item->di_tv, depth + 1, visited) == FAIL
+ 			    || dict_add(dict, item) == FAIL)
+ 		    {
+ 			dictitem_free(item);
+ 			status = FAIL;
+ 			break;
+ 		    }
+ 		}
+ 
+ 	    }
+ 	}
+ 	MZ_GC_UNREG();
+     }
+     else
+     {
+ 	/* `display' any other value to string */
+ 	tv->v_type = VAR_STRING;
+ 	tv->vval.v_string = (char_u *)string_to_line(obj);
+     }
+     return status;
+ }
+ 
+     void
+ do_mzeval(char_u *str, typval_T *rettv)
+ {
+     int i;
+     Scheme_Object	*ret = NULL;
+     Scheme_Hash_Table	*visited = NULL;
+ 
+     MZ_GC_DECL_REG(2);
+     MZ_GC_VAR_IN_REG(0, ret);
+     MZ_GC_VAR_IN_REG(0, visited);
+     MZ_GC_REG();
+ 
+     if (mzscheme_init())
+     {
+ 	MZ_GC_UNREG();
+ 	return;
+     }
+ 
+     MZ_GC_CHECK();
+     visited = scheme_make_hash_table(SCHEME_hash_ptr);
+     MZ_GC_CHECK();
+ 
+     if (eval_with_exn_handling(str, do_eval, &ret) == OK)
+ 	mzscheme_to_vim(ret, rettv, 1, visited);
+ 
+     for (i = 0; i < visited->size; ++i)
+     {
+ 	/* free up remembered objects */
+ 	if (visited->vals[i] != NULL)
+ 	{
+ 	    free_tv((typval_T *)visited->vals[i]);
+ 	}
+     }
+ 
+     MZ_GC_UNREG();
+ }
  #endif
  
  /*
*** ../vim-7.2.335/src/proto/eval.pro	2009-09-30 15:15:33.000000000 +0200
--- src/proto/eval.pro	2010-01-19 15:45:39.000000000 +0100
***************
*** 47,56 ****
--- 47,60 ----
  void list_free __ARGS((list_T *l, int recurse));
  dictitem_T *dict_lookup __ARGS((hashitem_T *hi));
  char_u *list_find_str __ARGS((list_T *l, long idx));
+ int list_append_tv __ARGS((list_T *l, typval_T *tv));
  int list_append_dict __ARGS((list_T *list, dict_T *dict));
  int list_append_string __ARGS((list_T *l, char_u *str, int len));
  int garbage_collect __ARGS((void));
  dict_T *dict_alloc __ARGS((void));
+ dictitem_T *dictitem_alloc __ARGS((char_u *key));
+ void dictitem_free __ARGS((dictitem_T *item));
+ int dict_add __ARGS((dict_T *d, dictitem_T *item));
  int dict_add_nr_str __ARGS((dict_T *d, char *key, long nr, char_u *str));
  char_u *get_dict_string __ARGS((dict_T *d, char_u *key, int save));
  long get_dict_number __ARGS((dict_T *d, char_u *key));
***************
*** 77,82 ****
--- 81,87 ----
  void new_script_vars __ARGS((scid_T id));
  void init_var_dict __ARGS((dict_T *dict, dictitem_T *dict_var));
  void vars_clear __ARGS((hashtab_T *ht));
+ void copy_tv __ARGS((typval_T *from, typval_T *to));
  void ex_echo __ARGS((exarg_T *eap));
  void ex_echohl __ARGS((exarg_T *eap));
  void ex_execute __ARGS((exarg_T *eap));
*** ../vim-7.2.335/src/proto/if_mzsch.pro	2009-12-16 19:02:05.000000000 +0100
--- src/proto/if_mzsch.pro	2010-01-19 15:29:01.000000000 +0100
***************
*** 15,18 ****
--- 15,19 ----
  void *mzvim_eval_string __ARGS((char_u *str));
  int mzthreads_allowed __ARGS((void));
  void mzscheme_main __ARGS((void));
+ void do_mzeval __ARGS((char_u *str, typval_T *rettv));
  /* vim: set ft=c : */
*** ../vim-7.2.335/src/testdir/Make_dos.mak	2009-11-17 17:57:10.000000000 +0100
--- src/testdir/Make_dos.mak	2010-01-19 15:43:48.000000000 +0100
***************
*** 29,35 ****
  		test42.out test52.out test65.out test66.out test67.out \
  		test68.out test69.out
  
! SCRIPTS32 =	test50.out
  
  SCRIPTS_GUI = test16.out
  
--- 29,35 ----
  		test42.out test52.out test65.out test66.out test67.out \
  		test68.out test69.out
  
! SCRIPTS32 =	test50.out test70.out
  
  SCRIPTS_GUI = test16.out
  
*** ../vim-7.2.335/src/testdir/Make_ming.mak	2009-11-17 17:57:10.000000000 +0100
--- src/testdir/Make_ming.mak	2010-01-19 15:29:01.000000000 +0100
***************
*** 48,54 ****
  		test42.out test52.out test65.out test66.out test67.out \
  		test68.out test69.out
  
! SCRIPTS32 =	test50.out
  
  SCRIPTS_GUI = test16.out
  
--- 48,54 ----
  		test42.out test52.out test65.out test66.out test67.out \
  		test68.out test69.out
  
! SCRIPTS32 =	test50.out test70.out
  
  SCRIPTS_GUI = test16.out
  
***************
*** 78,83 ****
--- 78,84 ----
  	-$(DEL) small.vim
  	-$(DEL) tiny.vim
  	-$(DEL) mbyte.vim
+ 	-$(DEL) mzscheme.vim
  	-$(DEL) X*
  	-$(DEL) viminfo
  
*** ../vim-7.2.335/src/testdir/Makefile	2009-11-17 17:40:34.000000000 +0100
--- src/testdir/Makefile	2010-01-19 15:29:01.000000000 +0100
***************
*** 23,29 ****
  		test54.out test55.out test56.out test57.out test58.out \
  		test59.out test60.out test61.out test62.out test63.out \
  		test64.out test65.out test66.out test67.out test68.out \
! 		test69.out
  
  SCRIPTS_GUI = test16.out
  
--- 23,29 ----
  		test54.out test55.out test56.out test57.out test58.out \
  		test59.out test60.out test61.out test62.out test63.out \
  		test64.out test65.out test66.out test67.out test68.out \
! 		test69.out test70.out
  
  SCRIPTS_GUI = test16.out
  
***************
*** 44,53 ****
  $(SCRIPTS) $(SCRIPTS_GUI): $(VIMPROG)
  
  clean:
! 	-rm -rf *.out *.failed *.rej *.orig test.log tiny.vim small.vim mbyte.vim test.ok X* valgrind.pid* viminfo
  
  test1.out: test1.in
! 	-rm -f $*.failed tiny.vim small.vim mbyte.vim test.ok X* viminfo
  	$(VALGRIND) $(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in $*.in
  	@/bin/sh -c "if diff test.out $*.ok; \
  		then mv -f test.out $*.out; \
--- 44,53 ----
  $(SCRIPTS) $(SCRIPTS_GUI): $(VIMPROG)
  
  clean:
! 	-rm -rf *.out *.failed *.rej *.orig test.log tiny.vim small.vim mbyte.vim mzscheme.vim test.ok X* valgrind.pid* viminfo
  
  test1.out: test1.in
! 	-rm -f $*.failed tiny.vim small.vim mbyte.vim mzscheme.vim test.ok X* viminfo
  	$(VALGRIND) $(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in $*.in
  	@/bin/sh -c "if diff test.out $*.ok; \
  		then mv -f test.out $*.out; \
*** ../vim-7.2.335/src/testdir/main.aap	2004-06-13 21:05:31.000000000 +0200
--- src/testdir/main.aap	2010-01-19 15:29:01.000000000 +0100
***************
*** 32,42 ****
  $Scripts $ScriptsGUI: $VimProg
  
  clean:
! 	:del {r}{force} *.out test.log tiny.vim small.vim mbyte.vim test.ok X*
  
  # test1 is special, it checks for features
  test1.out: test1.in
! 	:del {force} test1.failed tiny.vim small.vim mbyte.vim
  	:sys {i} $VimProg -u unix.vim -U NONE --noplugin -s dotest.in test1.in
  	@if os.system("diff test.out test1.ok") != 0:
  		:error test1 FAILED - Something basic is wrong
--- 32,42 ----
  $Scripts $ScriptsGUI: $VimProg
  
  clean:
! 	:del {r}{force} *.out test.log tiny.vim small.vim mbyte.vim mzscheme.vim test.ok X*
  
  # test1 is special, it checks for features
  test1.out: test1.in
! 	:del {force} test1.failed tiny.vim small.vim mbyte.vim mzscheme.vim
  	:sys {i} $VimProg -u unix.vim -U NONE --noplugin -s dotest.in test1.in
  	@if os.system("diff test.out test1.ok") != 0:
  		:error test1 FAILED - Something basic is wrong
*** ../vim-7.2.335/src/testdir/test1.in	2004-06-13 20:19:23.000000000 +0200
--- src/testdir/test1.in	2010-01-19 15:38:44.000000000 +0100
***************
*** 13,18 ****
--- 13,19 ----
  
  If Vim was not compiled with the +multi_byte feature, the mbyte.vim script will be set like small.vim above.  mbyte.vim is sourced by tests that require the
  +multi_byte feature.
+ Similar logic is applied to the +mzscheme feature, using mzscheme.vim.
  
  STARTTEST
  :" Write a single line to test.out to check if testing works at all.
***************
*** 25,32 ****
--- 26,36 ----
  w! test.out
  qa!
  :w! mbyte.vim
+ :w! mzscheme.vim
  :" If +multi_byte feature supported, make mbyte.vim empty.
  :if has("multi_byte") | sp another | w! mbyte.vim | q | endif
+ :" If +mzscheme feature supported, make mzscheme.vim empty.
+ :if has("mzscheme") | sp another | w! mzscheme.vim | q | endif
  :" If +eval feature supported quit here, leaving tiny.vim and small.vim empty.
  :" Otherwise write small.vim to skip the test.
  :if 1 | q! | endif
*** ../vim-7.2.335/src/testdir/test70.in	2010-01-19 15:47:24.000000000 +0100
--- src/testdir/test70.in	2010-01-19 15:29:01.000000000 +0100
***************
*** 0 ****
--- 1,53 ----
+ Smoke test for MzScheme interface and mzeval() function
+ 
+ STARTTEST
+ :so mzscheme.vim
+ :set nocompatible viminfo+=nviminfo
+ :function! MzRequire()
+ :redir => l:mzversion
+ :mz (version)
+ :redir END
+ :if strpart(l:mzversion, 1, 1) < "4"
+ :" MzScheme versions < 4.x:
+ :mz (require (prefix vim- vimext))
+ :else
+ :" newer versions:
+ :mz (require (prefix-in vim- 'vimext))
+ :mz (require r5rs)
+ :endif
+ :endfunction
+ :silent call MzRequire()
+ :mz (define l '("item0" "dictionary with list OK" "item2"))
+ :mz (define h (make-hash))
+ :mz (hash-set! h "list" l)
+ /^1
+ :" change buffer contents
+ :mz (vim-set-buff-line (vim-eval "line('.')") "1 changed line 1")
+ :" scalar test
+ :let tmp_string = mzeval('"string"')
+ :let tmp_1000 = mzeval('1000')
+ :if tmp_string . tmp_1000 == "string1000"
+ :let scalar_res = "OK"
+ :else
+ :let scalar_res = "FAILED"
+ :endif
+ :call append(search("^1"), "scalar test " . scalar_res)
+ :" dictionary containing a list
+ :let tmp = mzeval("h")["list"][1]
+ :/^2/put =tmp
+ :" circular list (at the same time test lists containing lists)
+ :mz (set-car! (cddr l) l)
+ :let l2 = mzeval("h")["list"]
+ :if l2[2] == l2
+ :let res = "OK"
+ :else
+ :let res = "FAILED"
+ :endif
+ :call setline(search("^3"), "circular test " . res)
+ :?^1?,$w! test.out
+ :qa!
+ ENDTEST
+ 
+ 1 line 1
+ 2 line 2
+ 3 line 3
*** ../vim-7.2.335/src/testdir/test70.ok	2010-01-19 15:47:24.000000000 +0100
--- src/testdir/test70.ok	2010-01-19 15:29:01.000000000 +0100
***************
*** 0 ****
--- 1,5 ----
+ 1 changed line 1
+ scalar test OK
+ 2 line 2
+ dictionary with list OK
+ circular test OK
*** ../vim-7.2.335/src/version.c	2010-01-19 15:23:38.000000000 +0100
--- src/version.c	2010-01-19 15:46:44.000000000 +0100
***************
*** 683,684 ****
--- 683,686 ----
  {   /* Add new patch number below this line */
+ /**/
+     336,
  /**/

-- 
"Computers in the future may weigh no more than 1.5 tons."
                                   Popular Mechanics, 1949

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///