/* vi:set ts=8 sts=4 sw=4: * * VIM - Vi IMproved by Bram Moolenaar * * Ruby interface by Shugo Maeda * with improvements by SegPhault (Ryan Paul) * with improvements by Jon Maken * * Do ":help uganda" in Vim to read copying and usage conditions. * Do ":help credits" in Vim to see a list of people who contributed. * See README.txt for an overview of the Vim source code. */#ifdef HAVE_CONFIG_H#include"auto/config.h"#endif#include<stdio.h>#include<string.h>#ifdef _WIN32# if !defined(DYNAMIC_RUBY_VER) || (DYNAMIC_RUBY_VER < 18)# define NT# endif# ifndef DYNAMIC_RUBY# define IMPORT /* For static dll usage __declspec(dllimport) */# define RUBYEXTERN __declspec(dllimport)# endif#endif#ifndef RUBYEXTERN# define RUBYEXTERN extern#endif#ifdef DYNAMIC_RUBY/* * This is tricky. In ruby.h there is (inline) function rb_class_of() * definition. This function use these variables. But we want function to * use dll_* variables. */# define rb_cFalseClass (*dll_rb_cFalseClass)# define rb_cFixnum (*dll_rb_cFixnum)# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 20# define rb_cFloat (*dll_rb_cFloat)# endif# define rb_cNilClass (*dll_rb_cNilClass)# define rb_cSymbol (*dll_rb_cSymbol)# define rb_cTrueClass (*dll_rb_cTrueClass)# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18/* * On ver 1.8, all Ruby functions are exported with "__declspec(dllimport)" * in ruby.h. But it causes trouble for these variables, because it is * defined in this file. When defined this RUBY_EXPORT it modified to * "extern" and be able to avoid this problem. */# define RUBY_EXPORT# endif#if !(defined(WIN32) || defined(_WIN64))#include<dlfcn.h># define HINSTANCE void*# define RUBY_PROC void*# define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL)# define symbol_from_dll dlsym# define close_dll dlclose#else# define RUBY_PROC FARPROC# define load_dll vimLoadLib# define symbol_from_dll GetProcAddress# define close_dll FreeLibrary#endif#endif /* ifdef DYNAMIC_RUBY *//* suggested by Ariya Mizutani */#if (_MSC_VER == 1200)# undef _WIN32_WINNT#endif#if (defined(RUBY_VERSION) && RUBY_VERSION >= 19) \ || (defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19)# define RUBY19_OR_LATER 1#endif#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19/* Ruby 1.9 defines a number of static functions which use rb_num2long and * rb_int2big */# define rb_num2long rb_num2long_stub# define rb_int2big rb_int2big_stub#endif#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19 \ && VIM_SIZEOF_INT < VIM_SIZEOF_LONG/* Ruby 1.9 defines a number of static functions which use rb_fix2int and * rb_num2int if VIM_SIZEOF_INT < VIM_SIZEOF_LONG (64bit) */# define rb_fix2int rb_fix2int_stub# define rb_num2int rb_num2int_stub#endif#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER == 21/* Ruby 2.1 adds new GC called