Created
August 11, 2013 07:03
-
-
Save joker1007/6203801 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -r f6cacdc34495 src/Makefile | |
--- a/src/Makefile Wed Aug 07 21:13:23 2013 +0200 | |
+++ b/src/Makefile Sun Aug 11 16:00:41 2013 +0900 | |
@@ -1483,6 +1483,7 @@ | |
$(PYTHON_SRC) $(PYTHON3_SRC) \ | |
$(TCL_SRC) \ | |
$(RUBY_SRC) \ | |
+ $(MRUBY_SRC) \ | |
$(SNIFF_SRC) \ | |
$(WORKSHOP_SRC) \ | |
$(WSDEBUG_SRC) | |
@@ -1490,7 +1491,7 @@ | |
TAGS_SRC = *.c *.cpp if_perl.xs | |
EXTRA_SRC = hangulin.c if_lua.c if_mzsch.c auto/if_perl.c if_perlsfio.c \ | |
- if_python.c if_python3.c if_tcl.c if_ruby.c if_sniff.c \ | |
+ if_python.c if_python3.c if_tcl.c if_ruby.c if_mruby.c if_sniff.c \ | |
gui_beval.c workshop.c wsdebug.c integration.c netbeans.c | |
# Unittest files | |
@@ -1569,6 +1570,8 @@ | |
$(PYTHON3_OBJ) \ | |
$(TCL_OBJ) \ | |
$(RUBY_OBJ) \ | |
+ $(MRUBY_OBJ) \ | |
+ $(MRUBY) \ | |
$(OS_EXTRA_OBJ) \ | |
$(WORKSHOP_OBJ) \ | |
$(NETBEANS_OBJ) \ | |
@@ -1605,6 +1608,7 @@ | |
if_python.pro \ | |
if_python3.pro \ | |
if_ruby.pro \ | |
+ if_mruby.pro \ | |
main.pro \ | |
mark.pro \ | |
memfile.pro \ | |
@@ -2615,6 +2619,9 @@ | |
objects/if_ruby.o: if_ruby.c | |
$(CCC) $(RUBY_CFLAGS) -o $@ if_ruby.c | |
+objects/if_mruby.o: if_mruby.c | |
+ $(CCC) $(MRUBY_CFLAGS) -o $@ if_mruby.c $(MRUBY) $(MRUBY_LIBS) | |
+ | |
objects/if_sniff.o: if_sniff.c | |
$(CCC) -o $@ if_sniff.c | |
@@ -3139,6 +3146,10 @@ | |
ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \ | |
gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \ | |
arabic.h version.h | |
+objects/if_mruby.o: if_mruby.c auto/config.h vim.h feature.h os_unix.h auto/osdef.h \ | |
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \ | |
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \ | |
+ arabic.h version.h | |
objects/if_sniff.o: if_sniff.c vim.h auto/config.h feature.h os_unix.h \ | |
auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \ | |
regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \ | |
diff -r f6cacdc34495 src/config.h.in | |
--- a/src/config.h.in Wed Aug 07 21:13:23 2013 +0200 | |
+++ b/src/config.h.in Sun Aug 11 16:00:41 2013 +0900 | |
@@ -353,6 +353,9 @@ | |
/* Define if you want to include the Ruby interpreter. */ | |
#undef FEAT_RUBY | |
+/* Define if you want to include the mruby interpreter. */ | |
+#undef FEAT_MRUBY | |
+ | |
/* Define for linking via dlopen() or LoadLibrary() */ | |
#undef DYNAMIC_RUBY | |
diff -r f6cacdc34495 src/config.mk.in | |
--- a/src/config.mk.in Wed Aug 07 21:13:23 2013 +0200 | |
+++ b/src/config.mk.in Sun Aug 11 16:00:41 2013 +0900 | |
@@ -96,6 +96,13 @@ | |
RUBY_CFLAGS = @RUBY_CFLAGS@ | |
RUBY_LIBS = @RUBY_LIBS@ | |
+MRUBY = @MRUBY@ | |
+MRUBY_SRC = @MRUBY_SRC@ | |
+MRUBY_OBJ = @MRUBY_OBJ@ | |
+MRUBY_PRO = @MRUBY_PRO@ | |
+MRUBY_CFLAGS = @MRUBY_CFLAGS@ | |
+MRUBY_LIBS = @MRUBY_LIBS@ | |
+ | |
SNIFF_SRC = @SNIFF_SRC@ | |
SNIFF_OBJ = @SNIFF_OBJ@ | |
diff -r f6cacdc34495 src/configure.in | |
--- a/src/configure.in Wed Aug 07 21:13:23 2013 +0200 | |
+++ b/src/configure.in Sun Aug 11 16:00:41 2013 +0900 | |
@@ -1722,6 +1722,47 @@ | |
AC_SUBST(RUBY_CFLAGS) | |
AC_SUBST(RUBY_LIBS) | |
+AC_MSG_CHECKING(--enable-mrubyinterp argument) | |
+AC_ARG_ENABLE(mrubyinterp, | |
+ [ --enable-mrubyinterp[=OPTS] Include mruby interpreter. [default=no] [OPTS=no/yes]], , | |
+ [enable_mrubyinterp="no"]) | |
+AC_MSG_RESULT($enable_mrubyinterp) | |
+if test "$enable_mrubyinterp" = "yes"; then | |
+ AC_MSG_CHECKING(--with-libmruby argument) | |
+ AC_SUBST(vi_cv_path_libmruby) | |
+ AC_ARG_WITH(libmruby, [ --with-libmruby=MRUBY path of the libmruby], | |
+ LIBMRUBY="$withval"; vi_cv_path_libmruby="$withval"; AC_MSG_RESULT($LIBMRUBY), | |
+ LIBMRUBY="lib"; AC_MSG_RESULT(defaulting to $LIBMRUBY)) | |
+ AC_PATH_PROG(vi_cv_path_libmruby, $LIBMRUBY) | |
+ | |
+ if test -f "$vi_cv_path_libmruby"; then | |
+ MRUBY_LIBS="-lm" | |
+ MRUBY="$LIBMRUBY" | |
+ fi | |
+ | |
+ AC_MSG_CHECKING(--with-mruby-include argument) | |
+ AC_ARG_WITH(mruby-include, [ --with-libmruby=MRUBY_INC path of the libmruby header directory], | |
+ MRUBY_INCLUDE="$withval"; AC_MSG_RESULT($MRUBY_INCLUDE), | |
+ MRUBY_INCLUDE="include"; AC_MSG_RESULT(defaulting to $MRUBY_INCLUDE)) | |
+ | |
+ if test -d "$MRUBY_INCLUDE"; then | |
+ MRUBY_CFLAGS="-I$MRUBY_INCLUDE" | |
+ fi | |
+ | |
+ if test "X$MRUBY" != "X" -a "X$MRUBY_CFLAGS" != "X"; then | |
+ MRUBY_SRC="if_mruby.c" | |
+ MRUBY_OBJ="objects/if_mruby.o" | |
+ MRUBY_PRO="if_mruby.pro" | |
+ AC_DEFINE(FEAT_MRUBY) | |
+ fi | |
+fi | |
+AC_SUBST(MRUBY) | |
+AC_SUBST(MRUBY_SRC) | |
+AC_SUBST(MRUBY_OBJ) | |
+AC_SUBST(MRUBY_PRO) | |
+AC_SUBST(MRUBY_CFLAGS) | |
+AC_SUBST(MRUBY_LIBS) | |
+ | |
AC_MSG_CHECKING(--enable-cscope argument) | |
AC_ARG_ENABLE(cscope, | |
[ --enable-cscope Include cscope interface.], , | |
diff -r f6cacdc34495 src/ex_cmds.h | |
--- a/src/ex_cmds.h Wed Aug 07 21:13:23 2013 +0200 | |
+++ b/src/ex_cmds.h Sun Aug 11 16:00:41 2013 +0900 | |
@@ -785,6 +785,8 @@ | |
NEEDARG|EXTRA|NOTRLCOM), | |
EX(CMD_runtime, "runtime", ex_runtime, | |
BANG|NEEDARG|FILES|TRLBAR|SBOXOK|CMDWIN), | |
+EX(CMD_mruby, "mruby", ex_mruby, | |
+ RANGE|EXTRA|NEEDARG|CMDWIN), | |
EX(CMD_ruby, "ruby", ex_ruby, | |
RANGE|EXTRA|NEEDARG|CMDWIN), | |
EX(CMD_rubydo, "rubydo", ex_rubydo, | |
diff -r f6cacdc34495 src/ex_docmd.c | |
--- a/src/ex_docmd.c Wed Aug 07 21:13:23 2013 +0200 | |
+++ b/src/ex_docmd.c Sun Aug 11 16:00:41 2013 +0900 | |
@@ -289,6 +289,9 @@ | |
# define ex_rubydo ex_ni | |
# define ex_rubyfile ex_ni | |
#endif | |
+#ifndef FEAT_MRUBY | |
+# define ex_mruby ex_script_ni | |
+#endif | |
#ifndef FEAT_SNIFF | |
# define ex_sniff ex_ni | |
#endif | |
diff -r f6cacdc34495 src/if_mruby.c | |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
+++ b/src/if_mruby.c Sun Aug 11 16:00:41 2013 +0900 | |
@@ -0,0 +1,55 @@ | |
+#ifdef HAVE_CONFIG_H | |
+# include "auto/config.h" | |
+#endif | |
+ | |
+#include <stdio.h> | |
+#include <string.h> | |
+ | |
+#include <mruby.h> | |
+#include <mruby/data.h> | |
+#include <mruby/proc.h> | |
+#include <mruby/compile.h> | |
+ | |
+#include "vim.h" | |
+#include "version.h" | |
+ | |
+static int mruby_initialized = 0; | |
+static int ensure_mruby_initialized(void); | |
+static mrb_state* vimMrb; | |
+ | |
+void ex_mruby(exarg_T *eap) | |
+{ | |
+ char *script = NULL; | |
+ mrbc_context *cxt; | |
+ | |
+ script = (char *)script_get(eap, eap->arg); | |
+ if (!eap->skip && ensure_mruby_initialized()) | |
+ { | |
+ cxt = mrbc_context_new(vimMrb); | |
+ if (script == NULL) { | |
+ puts((char *)eap->arg); | |
+ mrb_load_string_cxt(vimMrb, (char *)eap->arg, cxt); | |
+ mrbc_context_free(vimMrb, cxt); | |
+ } else { | |
+ EMSG(_("no mruby script")); | |
+ } | |
+ } | |
+ vim_free(script); | |
+} | |
+ | |
+static int ensure_mruby_initialized(void) | |
+{ | |
+ if (!mruby_initialized) | |
+ { | |
+ vimMrb = mrb_open(); | |
+ mruby_initialized = 1; | |
+ return mruby_initialized; | |
+ } else { | |
+ return mruby_initialized; | |
+ } | |
+} | |
+ | |
+void mruby_end() | |
+{ | |
+ mrb_close(vimMrb); | |
+} | |
diff -r f6cacdc34495 src/main.aap | |
--- a/src/main.aap Wed Aug 07 21:13:23 2013 +0200 | |
+++ b/src/main.aap Sun Aug 11 16:00:41 2013 +0900 | |
@@ -347,6 +347,7 @@ | |
$PYTHON_SRC | |
$TCL_SRC | |
$RUBY_SRC | |
+ $MRUBY_SRC | |
$SNIFF_SRC | |
$WORKSHOP_SRC | |
diff -r f6cacdc34495 src/main.c | |
--- a/src/main.c Wed Aug 07 21:13:23 2013 +0200 | |
+++ b/src/main.c Sun Aug 11 16:00:41 2013 +0900 | |
@@ -1478,6 +1478,9 @@ | |
#ifdef FEAT_RUBY | |
ruby_end(); | |
#endif | |
+#ifdef FEAT_MRUBY | |
+ mruby_end(); | |
+#endif | |
#ifdef FEAT_PYTHON | |
python_end(); | |
#endif | |
diff -r f6cacdc34495 src/proto.h | |
--- a/src/proto.h Wed Aug 07 21:13:23 2013 +0200 | |
+++ b/src/proto.h Sun Aug 11 16:00:41 2013 +0900 | |
@@ -196,6 +196,9 @@ | |
# ifdef FEAT_RUBY | |
# include "if_ruby.pro" | |
# endif | |
+# ifdef FEAT_MRUBY | |
+# include "if_mruby.pro" | |
+# endif | |
/* Ugly solution for "BalloonEval" not being defined while it's used in some | |
* .pro files. */ | |
diff -r f6cacdc34495 src/proto/if_mruby.pro | |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
+++ b/src/proto/if_mruby.pro Sun Aug 11 16:00:41 2013 +0900 | |
@@ -0,0 +1,4 @@ | |
+/* if_mruby.c */ | |
+void mruby_end __ARGS((void)); | |
+void ex_mruby __ARGS((exarg_T *eap)); | |
+/* vim: set ft=c : */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment