mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Added VC++ support thanks to U.Nakamura's patch. [ruby-dev:25644]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1f0125e4aa
commit
dca41072d3
4 changed files with 18 additions and 8 deletions
|
@ -225,6 +225,8 @@ rb_dlcfunc_inspect(VALUE self)
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
# define DECL_FUNC(f,ret,args,calltype) ret (__attribute__((calltype)) *f)(args)
|
# define DECL_FUNC(f,ret,args,calltype) ret (__attribute__((calltype)) *f)(args)
|
||||||
/* # define DECL_FUNC(f,ret,args,calltype) ret (*f)(args) */
|
/* # define DECL_FUNC(f,ret,args,calltype) ret (*f)(args) */
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
# define DECL_FUNC(f,ret,args,calltype) ret (__##calltype *f)(args)
|
||||||
#else
|
#else
|
||||||
# error "unsupported compiler."
|
# error "unsupported compiler."
|
||||||
#endif
|
#endif
|
||||||
|
@ -331,7 +333,7 @@ rb_dlcfunc_call(VALUE self, VALUE ary)
|
||||||
#if HAVE_LONG_LONG /* used in ruby.h */
|
#if HAVE_LONG_LONG /* used in ruby.h */
|
||||||
case DLTYPE_LONG_LONG:
|
case DLTYPE_LONG_LONG:
|
||||||
#define CASE(n) case n: { \
|
#define CASE(n) case n: { \
|
||||||
DECL_FUNC(f,long long,DLSTACK_PROTO,cdecl) = cfunc->ptr; \
|
DECL_FUNC(f,LONG_LONG,DLSTACK_PROTO,cdecl) = cfunc->ptr; \
|
||||||
LONG_LONG ret; \
|
LONG_LONG ret; \
|
||||||
ret = f(DLSTACK_ARGS(stack)); \
|
ret = f(DLSTACK_ARGS(stack)); \
|
||||||
result = LL2NUM(ret); \
|
result = LL2NUM(ret); \
|
||||||
|
@ -429,7 +431,7 @@ rb_dlcfunc_call(VALUE self, VALUE ary)
|
||||||
#if HAVE_LONG_LONG /* used in ruby.h */
|
#if HAVE_LONG_LONG /* used in ruby.h */
|
||||||
case DLTYPE_LONG_LONG:
|
case DLTYPE_LONG_LONG:
|
||||||
#define CASE(n) case n: { \
|
#define CASE(n) case n: { \
|
||||||
DECL_FUNC(f,long long,DLSTACK_PROTO,stdcall) = cfunc->ptr; \
|
DECL_FUNC(f,LONG_LONG,DLSTACK_PROTO,stdcall) = cfunc->ptr; \
|
||||||
LONG_LONG ret; \
|
LONG_LONG ret; \
|
||||||
ret = f(DLSTACK_ARGS(stack)); \
|
ret = f(DLSTACK_ARGS(stack)); \
|
||||||
result = LL2NUM(ret); \
|
result = LL2NUM(ret); \
|
||||||
|
|
|
@ -360,7 +360,7 @@ rb_dlptr_aref(int argc, VALUE argv[], VALUE self)
|
||||||
defualt:
|
defualt:
|
||||||
rb_bug("rb_dlptr_aset()");
|
rb_bug("rb_dlptr_aset()");
|
||||||
}
|
}
|
||||||
return rb_tainted_str_new(RPTR_DATA(self)->ptr + offset, len);
|
return rb_tainted_str_new((char *)RPTR_DATA(self)->ptr + offset, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
@ -392,7 +392,7 @@ rb_dlptr_aset(int argc, VALUE argv[], VALUE self)
|
||||||
defualt:
|
defualt:
|
||||||
rb_bug("rb_dlptr_aset()");
|
rb_bug("rb_dlptr_aset()");
|
||||||
}
|
}
|
||||||
memcpy(RPTR_DATA(self)->ptr + offset, mem, len);
|
memcpy((char *)RPTR_DATA(self)->ptr + offset, mem, len);
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,15 @@ rb_dl_value2ptr(VALUE self, VALUE val)
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
# define PRE_DECL_CDECL __attribute__((cdecl))
|
# define PRE_DECL_CDECL __attribute__((cdecl))
|
||||||
# define PRE_DECL_STDCALL __attribute__((stdcall))
|
# define PRE_DECL_STDCALL __attribute__((stdcall))
|
||||||
|
# define MIDST_DECL_CDECL
|
||||||
|
# define MIDST_DECL_STDCALL
|
||||||
|
# define POST_DECL_CDECL
|
||||||
|
# define POST_DECL_STDCALL
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
# define PRE_DECL_CDECL
|
||||||
|
# define PRE_DECL_STDCALL
|
||||||
|
# define MIDST_DECL_CDECL __cdecl
|
||||||
|
# define MIDST_DECL_STDCALL __stdcall
|
||||||
# define POST_DECL_CDECL
|
# define POST_DECL_CDECL
|
||||||
# define POST_DECL_STDCALL
|
# define POST_DECL_STDCALL
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -111,18 +111,17 @@ for calltype in CALLTYPES
|
||||||
for n in 0..(MAX_CALLBACK-1)
|
for n in 0..(MAX_CALLBACK-1)
|
||||||
$out << (<<-EOS)
|
$out << (<<-EOS)
|
||||||
|
|
||||||
PRE_DECL_#{calltype.upcase} static #{DLTYPE[ty][:type]}
|
PRE_DECL_#{calltype.upcase} static #{DLTYPE[ty][:type]} MIDST_DECL_#{calltype.upcase}
|
||||||
#{func_name(ty,argc,n,calltype)}(#{(0...argc).collect{|i| "DLSTACK_TYPE stack" + i.to_s}.join(", ")}) POST_DECL_#{calltype.upcase}
|
#{func_name(ty,argc,n,calltype)}(#{(0...argc).collect{|i| "DLSTACK_TYPE stack" + i.to_s}.join(", ")}) POST_DECL_#{calltype.upcase}
|
||||||
{
|
{
|
||||||
VALUE args[#{argc}];
|
VALUE ret, cb#{argc > 0 ? ", args[#{argc}]" : ""};
|
||||||
VALUE ret, cb;
|
|
||||||
#{
|
#{
|
||||||
(0...argc).collect{|i|
|
(0...argc).collect{|i|
|
||||||
" args[%d] = LONG2NUM(stack%d);" % [i,i]
|
" args[%d] = LONG2NUM(stack%d);" % [i,i]
|
||||||
}.join("\n")
|
}.join("\n")
|
||||||
}
|
}
|
||||||
cb = rb_ary_entry(rb_ary_entry(#{proc_entry}, #{ty}), #{(n * DLSTACK_SIZE) + argc});
|
cb = rb_ary_entry(rb_ary_entry(#{proc_entry}, #{ty}), #{(n * DLSTACK_SIZE) + argc});
|
||||||
ret = rb_funcall2(cb, cb_call, #{argc}, args);
|
ret = rb_funcall2(cb, cb_call, #{argc}, #{argc > 0 ? 'args' : 'NULL'});
|
||||||
return #{DLTYPE[ty][:conv] ? DLTYPE[ty][:conv] % "ret" : ""};
|
return #{DLTYPE[ty][:conv] ? DLTYPE[ty][:conv] % "ret" : ""};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue