khorser avatar khorser committed e47be32

make it work with all MzScheme/Racket versions, add funcref doc

Comments (0)

Files changed (16)

runtime/doc/if_mzsch.txt

 3. Threads				|mzscheme-threads|
 4. Vim access from MzScheme		|mzscheme-vim|
 5. mzeval() Vim function		|mzscheme-mzeval|
-6. Dynamic loading			|mzscheme-dynamic|
+6. Using Function references		|mzscheme-funcref|
+7. Dynamic loading			|mzscheme-dynamic|
 
 {Vi does not have any of these commands}
 
 Based on the work of Brent Fulgham.
 Dynamic loading added by Sergey Khorev
 
-For downloading MzScheme and other info:
-	http://www.plt-scheme.org/software/mzscheme/
-
-Note: On FreeBSD you should use the "drscheme" port.
+MzScheme and PLT Scheme names have been rebranded as Racket. For more
+information please check http://racket-lang.org
 
 ==============================================================================
 1. Commands						*mzscheme-commands*
 evaluate MzScheme expressions and pass their values to VimL.
 
 ==============================================================================
-6. Dynamic loading				    *mzscheme-dynamic* *E815*
+6. Using Function references				    *mzscheme-funcref*
+
+MzScheme interface allows use of |Funcref|s so you can call Vim functions
+directly from Scheme. For instance: >
+    function! MyAdd2(arg)
+	return a:arg + 2
+    endfunction
+
+    mz (define f2 (vim-eval "function(\"MyAdd2\")"))
+
+    mz (f2 7)
+<
+
+==============================================================================
+7. Dynamic loading				    *mzscheme-dynamic* *E815*
 
 On MS-Windows the MzScheme libraries can be loaded dynamically. The |:version|
 output then includes |+mzscheme/dyn|.
+function! MyFunc()
+    return 123
+endfunction
+
+function! MyFunc2(arg)
+    return a:arg + 2
+endfunction
+
+function! MyFunc3(arg)
+    return a:arg + [4, "E"]
+endfunction
+
+function! MyFunc4(arg)
+    return a:arg . "At"
+endfunction
+
+MzScheme
+mz (define f (vim-eval "function(\"MyFunc\")"))
+mz (define f2 (vim-eval "function(\"MyFunc2\")"))
+mz (define f3 (vim-eval "function(\"MyFunc3\")"))
+mz (define f4 (vim-eval "function(\"MyFunc4\")"))
+" intersperse lines below with :mz (collect-garbage)
+:MzScheme
+:e if_cscope.c
+:spli if_mzsch.c
+:mz (define b (vim-curr-buff))
+:mz (define b2 (vim-get-buff-by-name "if_mzsch.c"))
+:mz (vim-get-buff-line-list 1 2 b2)
+:mz (vim-get-buff-line-list 1 2 b)
+:mz (vim-buff-valid? b)
+:mz (vim-buff-valid? b2)
+:bw
+:mz (vim-buff-valid? b)
+:mz (vim-buff-valid? b2)
+call "%VS100COMNTOOLS%\vsvars32.bat" x86
+nmake -f Make_mvc.mak GUI=yes CSCOPE=yes MZSCHEME=%DEVLIBS%\mz209 DYNAMIC_MZSCHEME=no MZSCHEME_VER=209_000 %*
+
+call "%VS100COMNTOOLS%\vsvars32.bat" x86
+nmake -f Make_mvc.mak GUI=yes CSCOPE=yes MZSCHEME=%DEVLIBS%\mz209 DYNAMIC_MZSCHEME=yes MZSCHEME_VER=209_000 %*
+call "%VS100COMNTOOLS%\vsvars32.bat" x86
+nmake -f Make_mvc.mak GUI=yes CSCOPE=yes MZSCHEME=%DEVLIBS%\mz372 DYNAMIC_MZSCHEME=no MZSCHEME_VER=372_000 %*
+call "%VS100COMNTOOLS%\vsvars32.bat" x86
+nmake -f Make_mvc.mak GUI=yes CSCOPE=yes MZSCHEME=%DEVLIBS%\mz372 DYNAMIC_MZSCHEME=yes MZSCHEME_VER=372_000 %*
+call "%VS100COMNTOOLS%\vsvars32.bat" x86
+nmake -f Make_mvc.mak GUI=yes CSCOPE=yes MZSCHEME=%DEVLIBS%\mz372 DYNAMIC_MZSCHEME=no MZSCHEME_VER=3m372_000 %*
+call "%VS100COMNTOOLS%\vsvars32.bat" x86
+nmake -f Make_mvc.mak GUI=yes CSCOPE=yes MZSCHEME=%DEVLIBS%\mz423 DYNAMIC_MZSCHEME=no MZSCHEME_VER=_6ncbi0 %*
+call "%VS100COMNTOOLS%\vsvars32.bat" x86
+::del /f /s /q ObjGZ
+::nmake -f Make_mvc.mak clean
+nmake -f Make_mvc.mak GUI=yes CSCOPE=yes MZSCHEME=%DEVLIBS%\mz423 DYNAMIC_MZSCHEME=yes MZSCHEME_VER=_6ncbi0 %*
+call "%VS100COMNTOOLS%\vsvars32.bat" x86
+::del /f /s /q ObjGZ
+::nmake -f Make_mvc.mak clean
+nmake -f Make_mvc.mak GUI=yes CSCOPE=yes MZSCHEME=%DEVLIBS%\mz423 DYNAMIC_MZSCHEME=no MZSCHEME_VER=3m_6ncbi0 %*
+call "%VS100COMNTOOLS%\vsvars32.bat" x86
+nmake -f Make_mvc.mak GUI=yes CSCOPE=yes MZSCHEME=%DEVLIBS%\Racket DYNAMIC_MZSCHEME=no MZSCHEME_VER=3m_8avmg8 %*
+set PATH=%DEVLIBS%\mingw\bin;%PATH%
+mingw32-make -f Make_ming.mak GUI=yes CSCOPE=yes MZSCHEME=%DEVLIBS%/plt4 DYNAMIC_MZSCHEME=no MZSCHEME_VER=3m_6ncbi0 MZSCHEME_GENERATE_BASE=yes MZSCHEME_PRECISE_GC=yes %*
+:: REPLACE _MSC_VER with defined(WIN32) in schthread.h!!!
+set PATH=%DEVLIBS%\mingw\bin;%PATH%
+mingw32-make -f Make_ming.mak GUI=yes CSCOPE=yes MZSCHEME=%DEVLIBS%/Racket DYNAMIC_MZSCHEME=no MZSCHEME_VER=3m_8avmg8 MZSCHEME_GENERATE_BASE=yes MZSCHEME_PRECISE_GC=yes MZSCHEME_USE_RACKET=yes %*
 # define BUFFER_REF(buf) (vim_mz_buffer *)((buf)->b_mzscheme_ref)
 #endif
 
-#if MZSCHEME_VERSION_MAJOR < 299
-# define GUARANTEED_STRING_ARG(proc, num) GUARANTEE_STRING(proc, num)
-#else
-    static Scheme_Object *
-guaranteed_byte_string_arg(char *proc, int num, int argc, Scheme_Object **argv)
-{
-    if (SCHEME_BYTE_STRINGP(argv[num]))
-    {
-	return argv[num];
-    }
-    else if (SCHEME_CHAR_STRINGP(argv[num]))
-    {
-	Scheme_Object *tmp = NULL;
-	MZ_GC_DECL_REG(2);
-	MZ_GC_VAR_IN_REG(0, argv[num]);
-	MZ_GC_VAR_IN_REG(1, tmp);
-	MZ_GC_REG();
-	tmp = scheme_char_string_to_byte_string(argv[num]);
-	MZ_GC_UNREG();
-	return tmp;
-    }
-    else
-	scheme_wrong_type(proc, "string", num, argc, argv);
-    /* unreachable */
-    return scheme_void;
-}
-# define GUARANTEED_STRING_ARG(proc, num) guaranteed_byte_string_arg(proc, num, argc, argv)
-#endif
-
 #ifdef DYNAMIC_MZSCHEME
 static Scheme_Object *dll_scheme_eof;
 static Scheme_Object *dll_scheme_false;
 # endif
 # define scheme_gc_ptr_ok dll_scheme_gc_ptr_ok
 # if MZSCHEME_VERSION_MAJOR < 299
-#  undef scheme_get_sized_byte_string_output
 #  define scheme_get_sized_byte_string_output dll_scheme_get_sized_string_output
 # else
 #  define scheme_get_sized_byte_string_output \
 # define scheme_make_pair dll_scheme_make_pair
 # define scheme_make_prim_w_arity dll_scheme_make_prim_w_arity
 # if MZSCHEME_VERSION_MAJOR < 299
-#  undef scheme_make_byte_string
 #  define scheme_make_byte_string dll_scheme_make_string
-#  undef scheme_make_byte_string_output_port
 #  define scheme_make_byte_string_output_port dll_scheme_make_string_output_port
 # else
 #  define scheme_make_byte_string dll_scheme_make_byte_string
 }
 #endif /* DYNAMIC_MZSCHEME */
 
+#if MZSCHEME_VERSION_MAJOR < 299
+# define GUARANTEED_STRING_ARG(proc, num) GUARANTEE_STRING(proc, num)
+#else
+    static Scheme_Object *
+guaranteed_byte_string_arg(char *proc, int num, int argc, Scheme_Object **argv)
+{
+    if (SCHEME_BYTE_STRINGP(argv[num]))
+    {
+	return argv[num];
+    }
+    else if (SCHEME_CHAR_STRINGP(argv[num]))
+    {
+	Scheme_Object *tmp = NULL;
+	MZ_GC_DECL_REG(2);
+	MZ_GC_VAR_IN_REG(0, argv[num]);
+	MZ_GC_VAR_IN_REG(1, tmp);
+	MZ_GC_REG();
+	tmp = scheme_char_string_to_byte_string(argv[num]);
+	MZ_GC_UNREG();
+	return tmp;
+    }
+    else
+	scheme_wrong_type(proc, "string", num, argc, argv);
+    /* unreachable */
+    return scheme_void;
+}
+# define GUARANTEED_STRING_ARG(proc, num) guaranteed_byte_string_arg(proc, num, argc, argv)
+#endif
+
 /* need to put it here for dynamic stuff to work */
 #if defined(INCLUDE_MZSCHEME_BASE)
 # include "mzscheme_base.c"
 #else
 /* macros for compatibility with older versions */
 # define scheme_current_config() scheme_config
-# define scheme_make_byte_string scheme_make_string
-# define scheme_make_byte_string_output_port scheme_make_string_output_port
-# define scheme_get_sized_byte_string_output scheme_get_sized_string_output
 # define scheme_make_sized_byte_string scheme_make_sized_string
 # define scheme_format_utf8 scheme_format
+# ifndef DYNAMIC_MZSCHEME
+/* for dynamic MzScheme there will be separate definitions in if_mzsch.c */
+#  define scheme_get_sized_byte_string_output scheme_get_sized_string_output
+#  define scheme_make_byte_string scheme_make_string
+#  define scheme_make_byte_string_output_port scheme_make_string_output_port
+# endif
 
 # define SCHEME_BYTE_STRLEN_VAL SCHEME_STRLEN_VAL
 # define BYTE_STRING_VALUE(obj) ((char_u *)SCHEME_STR_VAL(obj))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.