Lines 60-65
Link Here
|
60 |
# define __OPENTRANSPORTPROVIDERS__ |
60 |
# define __OPENTRANSPORTPROVIDERS__ |
61 |
#endif |
61 |
#endif |
62 |
|
62 |
|
|
|
63 |
#ifndef StringValuePtr |
64 |
#define StringValuePtr(s) STR2CSTR(s) |
65 |
#endif |
66 |
#ifndef RARRAY_LEN |
67 |
#define RARRAY_LEN(s) RARRAY(s)->len |
68 |
#endif |
69 |
#ifndef RARRAY_PTR |
70 |
#define RARRAY_PTR(s) RARRAY(s)->ptr |
71 |
#endif |
72 |
#ifndef RSTRING_LEN |
73 |
#define RSTRING_LEN(s) RSTRING(s)->len |
74 |
#endif |
75 |
#ifndef RSTRING_PTR |
76 |
#define RSTRING_PTR(s) RSTRING(s)->ptr |
77 |
#endif |
78 |
|
63 |
#include "vim.h" |
79 |
#include "vim.h" |
64 |
#include "version.h" |
80 |
#include "version.h" |
65 |
|
81 |
|
Lines 129-135
Link Here
|
129 |
#define rb_str_concat dll_rb_str_concat |
145 |
#define rb_str_concat dll_rb_str_concat |
130 |
#define rb_str_new dll_rb_str_new |
146 |
#define rb_str_new dll_rb_str_new |
131 |
#define rb_str_new2 dll_rb_str_new2 |
147 |
#define rb_str_new2 dll_rb_str_new2 |
|
|
148 |
#if defined(RUBY_VERSION) && RUBY_VERSION >= 19 |
149 |
#define rb_errinfo dll_rb_errinfo |
150 |
#else |
132 |
#define ruby_errinfo (*dll_ruby_errinfo) |
151 |
#define ruby_errinfo (*dll_ruby_errinfo) |
|
|
152 |
#endif |
133 |
#define ruby_init dll_ruby_init |
153 |
#define ruby_init dll_ruby_init |
134 |
#define ruby_init_loadpath dll_ruby_init_loadpath |
154 |
#define ruby_init_loadpath dll_ruby_init_loadpath |
135 |
#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 |
155 |
#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 |
Lines 183-189
Link Here
|
183 |
static VALUE (*dll_rb_str_concat) (VALUE, VALUE); |
203 |
static VALUE (*dll_rb_str_concat) (VALUE, VALUE); |
184 |
static VALUE (*dll_rb_str_new) (const char*, long); |
204 |
static VALUE (*dll_rb_str_new) (const char*, long); |
185 |
static VALUE (*dll_rb_str_new2) (const char*); |
205 |
static VALUE (*dll_rb_str_new2) (const char*); |
|
|
206 |
#if defined(RUBY_VERSION) && RUBY_VERSION >= 19 |
207 |
static VALUE (*dll_rb_errinfo) (void); |
208 |
#else |
186 |
static VALUE *dll_ruby_errinfo; |
209 |
static VALUE *dll_ruby_errinfo; |
|
|
210 |
#endif |
187 |
static void (*dll_ruby_init) (void); |
211 |
static void (*dll_ruby_init) (void); |
188 |
static void (*dll_ruby_init_loadpath) (void); |
212 |
static void (*dll_ruby_init_loadpath) (void); |
189 |
#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 |
213 |
#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 |
Lines 245-251
Link Here
|
245 |
{"rb_str_concat", (RUBY_PROC*)&dll_rb_str_concat}, |
269 |
{"rb_str_concat", (RUBY_PROC*)&dll_rb_str_concat}, |
246 |
{"rb_str_new", (RUBY_PROC*)&dll_rb_str_new}, |
270 |
{"rb_str_new", (RUBY_PROC*)&dll_rb_str_new}, |
247 |
{"rb_str_new2", (RUBY_PROC*)&dll_rb_str_new2}, |
271 |
{"rb_str_new2", (RUBY_PROC*)&dll_rb_str_new2}, |
|
|
272 |
#if defined(RUBY_VERSION) && RUBY_VERSION >= 19 |
273 |
{"rb_errinfo", (RUBY_PROC*)&dll_rb_errinfo}, |
274 |
#else |
248 |
{"ruby_errinfo", (RUBY_PROC*)&dll_ruby_errinfo}, |
275 |
{"ruby_errinfo", (RUBY_PROC*)&dll_ruby_errinfo}, |
|
|
276 |
#endif |
249 |
{"ruby_init", (RUBY_PROC*)&dll_ruby_init}, |
277 |
{"ruby_init", (RUBY_PROC*)&dll_ruby_init}, |
250 |
{"ruby_init_loadpath", (RUBY_PROC*)&dll_ruby_init_loadpath}, |
278 |
{"ruby_init_loadpath", (RUBY_PROC*)&dll_ruby_init_loadpath}, |
251 |
#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 |
279 |
#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 |
Lines 365-371
Link Here
|
365 |
EMSG(_("E265: $_ must be an instance of String")); |
393 |
EMSG(_("E265: $_ must be an instance of String")); |
366 |
return; |
394 |
return; |
367 |
} |
395 |
} |
368 |
ml_replace(i, (char_u *) STR2CSTR(line), 1); |
396 |
ml_replace(i, (char_u *) StringValuePtr(line), 1); |
369 |
changed(); |
397 |
changed(); |
370 |
#ifdef SYNTAX_HL |
398 |
#ifdef SYNTAX_HL |
371 |
syn_changed(i); /* recompute syntax hl. for this line */ |
399 |
syn_changed(i); /* recompute syntax hl. for this line */ |
Lines 414-420
Link Here
|
414 |
if (ruby_enabled(TRUE)) |
442 |
if (ruby_enabled(TRUE)) |
415 |
{ |
443 |
{ |
416 |
#endif |
444 |
#endif |
|
|
445 |
#if defined(RUBY_VERSION) && RUBY_VERSION >= 19 |
446 |
RUBY_INIT_STACK; |
447 |
#endif |
417 |
ruby_init(); |
448 |
ruby_init(); |
|
|
449 |
ruby_script("vim-ruby"); |
418 |
ruby_init_loadpath(); |
450 |
ruby_init_loadpath(); |
419 |
ruby_io_init(); |
451 |
ruby_io_init(); |
420 |
ruby_vim_init(); |
452 |
ruby_vim_init(); |
Lines 434-441
Link Here
|
434 |
static void error_print(int state) |
466 |
static void error_print(int state) |
435 |
{ |
467 |
{ |
436 |
#ifndef DYNAMIC_RUBY |
468 |
#ifndef DYNAMIC_RUBY |
|
|
469 |
#if !(defined(RUBY_VERSION) && RUBY_VERSION >= 19) |
437 |
RUBYEXTERN VALUE ruby_errinfo; |
470 |
RUBYEXTERN VALUE ruby_errinfo; |
438 |
#endif |
471 |
#endif |
|
|
472 |
#endif |
439 |
VALUE eclass; |
473 |
VALUE eclass; |
440 |
VALUE einfo; |
474 |
VALUE einfo; |
441 |
char buff[BUFSIZ]; |
475 |
char buff[BUFSIZ]; |
Lines 468-476
Link Here
|
468 |
break; |
502 |
break; |
469 |
case TAG_RAISE: |
503 |
case TAG_RAISE: |
470 |
case TAG_FATAL: |
504 |
case TAG_FATAL: |
|
|
505 |
# if defined(RUBY_VERSION) && RUBY_VERSION >= 19 |
506 |
eclass = CLASS_OF(rb_errinfo()); |
507 |
einfo = rb_obj_as_string(rb_errinfo()); |
508 |
#else |
471 |
eclass = CLASS_OF(ruby_errinfo); |
509 |
eclass = CLASS_OF(ruby_errinfo); |
472 |
einfo = rb_obj_as_string(ruby_errinfo); |
510 |
einfo = rb_obj_as_string(ruby_errinfo); |
473 |
if (eclass == rb_eRuntimeError && RSTRING(einfo)->len == 0) { |
511 |
#endif |
|
|
512 |
if (eclass == rb_eRuntimeError && RSTRING_LEN(einfo) == 0) { |
474 |
EMSG(_("E272: unhandled exception")); |
513 |
EMSG(_("E272: unhandled exception")); |
475 |
} |
514 |
} |
476 |
else { |
515 |
else { |
Lines 479-485
Link Here
|
479 |
|
518 |
|
480 |
epath = rb_class_path(eclass); |
519 |
epath = rb_class_path(eclass); |
481 |
vim_snprintf(buff, BUFSIZ, "%s: %s", |
520 |
vim_snprintf(buff, BUFSIZ, "%s: %s", |
482 |
RSTRING(epath)->ptr, RSTRING(einfo)->ptr); |
521 |
RSTRING_PTR(epath), RSTRING_PTR(einfo)); |
483 |
p = strchr(buff, '\n'); |
522 |
p = strchr(buff, '\n'); |
484 |
if (p) *p = '\0'; |
523 |
if (p) *p = '\0'; |
485 |
EMSG(buff); |
524 |
EMSG(buff); |
Lines 497-504
Link Here
|
497 |
char *buff, *p; |
536 |
char *buff, *p; |
498 |
|
537 |
|
499 |
str = rb_obj_as_string(str); |
538 |
str = rb_obj_as_string(str); |
500 |
buff = ALLOCA_N(char, RSTRING(str)->len); |
539 |
buff = ALLOCA_N(char, RSTRING_LEN(str)); |
501 |
strcpy(buff, RSTRING(str)->ptr); |
540 |
strcpy(buff, RSTRING_PTR(str)); |
502 |
p = strchr(buff, '\n'); |
541 |
p = strchr(buff, '\n'); |
503 |
if (p) *p = '\0'; |
542 |
if (p) *p = '\0'; |
504 |
MSG(buff); |
543 |
MSG(buff); |
Lines 507-527
Link Here
|
507 |
|
546 |
|
508 |
static VALUE vim_set_option(VALUE self UNUSED, VALUE str) |
547 |
static VALUE vim_set_option(VALUE self UNUSED, VALUE str) |
509 |
{ |
548 |
{ |
510 |
do_set((char_u *)STR2CSTR(str), 0); |
549 |
do_set((char_u *)StringValuePtr(str), 0); |
511 |
update_screen(NOT_VALID); |
550 |
update_screen(NOT_VALID); |
512 |
return Qnil; |
551 |
return Qnil; |
513 |
} |
552 |
} |
514 |
|
553 |
|
515 |
static VALUE vim_command(VALUE self UNUSED, VALUE str) |
554 |
static VALUE vim_command(VALUE self UNUSED, VALUE str) |
516 |
{ |
555 |
{ |
517 |
do_cmdline_cmd((char_u *)STR2CSTR(str)); |
556 |
do_cmdline_cmd((char_u *)StringValuePtr(str)); |
518 |
return Qnil; |
557 |
return Qnil; |
519 |
} |
558 |
} |
520 |
|
559 |
|
521 |
static VALUE vim_evaluate(VALUE self UNUSED, VALUE str) |
560 |
static VALUE vim_evaluate(VALUE self UNUSED, VALUE str) |
522 |
{ |
561 |
{ |
523 |
#ifdef FEAT_EVAL |
562 |
#ifdef FEAT_EVAL |
524 |
char_u *value = eval_to_string((char_u *)STR2CSTR(str), NULL, TRUE); |
563 |
char_u *value = eval_to_string((char_u *)StringValuePtr(str), NULL, TRUE); |
525 |
|
564 |
|
526 |
if (value != NULL) |
565 |
if (value != NULL) |
527 |
{ |
566 |
{ |
Lines 645-651
Link Here
|
645 |
|
684 |
|
646 |
static VALUE set_buffer_line(buf_T *buf, linenr_T n, VALUE str) |
685 |
static VALUE set_buffer_line(buf_T *buf, linenr_T n, VALUE str) |
647 |
{ |
686 |
{ |
648 |
char *line = STR2CSTR(str); |
687 |
char *line = StringValuePtr(str); |
649 |
aco_save_T aco; |
688 |
aco_save_T aco; |
650 |
|
689 |
|
651 |
if (n > 0 && n <= buf->b_ml.ml_line_count && line != NULL) |
690 |
if (n > 0 && n <= buf->b_ml.ml_line_count && line != NULL) |
Lines 723-729
Link Here
|
723 |
static VALUE buffer_append(VALUE self, VALUE num, VALUE str) |
762 |
static VALUE buffer_append(VALUE self, VALUE num, VALUE str) |
724 |
{ |
763 |
{ |
725 |
buf_T *buf = get_buf(self); |
764 |
buf_T *buf = get_buf(self); |
726 |
char *line = STR2CSTR(str); |
765 |
char *line = StringValuePtr(str); |
727 |
long n = NUM2LONG(num); |
766 |
long n = NUM2LONG(num); |
728 |
aco_save_T aco; |
767 |
aco_save_T aco; |
729 |
|
768 |
|
Lines 890-899
Link Here
|
890 |
win_T *win = get_win(self); |
929 |
win_T *win = get_win(self); |
891 |
|
930 |
|
892 |
Check_Type(pos, T_ARRAY); |
931 |
Check_Type(pos, T_ARRAY); |
893 |
if (RARRAY(pos)->len != 2) |
932 |
if (RARRAY_LEN(pos) != 2) |
894 |
rb_raise(rb_eArgError, "array length must be 2"); |
933 |
rb_raise(rb_eArgError, "array length must be 2"); |
895 |
lnum = RARRAY(pos)->ptr[0]; |
934 |
lnum = RARRAY_PTR(pos)[0]; |
896 |
col = RARRAY(pos)->ptr[1]; |
935 |
col = RARRAY_PTR(pos)[1]; |
897 |
win->w_cursor.lnum = NUM2LONG(lnum); |
936 |
win->w_cursor.lnum = NUM2LONG(lnum); |
898 |
win->w_cursor.col = NUM2UINT(col); |
937 |
win->w_cursor.col = NUM2UINT(col); |
899 |
check_cursor(); /* put cursor on an existing line */ |
938 |
check_cursor(); /* put cursor on an existing line */ |
Lines 910-916
Link Here
|
910 |
if (i > 0) rb_str_cat(str, ", ", 2); |
949 |
if (i > 0) rb_str_cat(str, ", ", 2); |
911 |
rb_str_concat(str, rb_inspect(argv[i])); |
950 |
rb_str_concat(str, rb_inspect(argv[i])); |
912 |
} |
951 |
} |
913 |
MSG(RSTRING(str)->ptr); |
952 |
MSG(RSTRING_PTR(str)); |
914 |
return Qnil; |
953 |
return Qnil; |
915 |
} |
954 |
} |
916 |
|
955 |
|