1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

conformed to the usage of FUNC_CDECL/STDCALL described in [ruby-dev:28970].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ttate 2006-07-06 19:59:31 +00:00
parent 57fe65940c
commit d01f22ec7c
4 changed files with 9 additions and 45 deletions

View file

@ -222,20 +222,9 @@ rb_dlcfunc_inspect(VALUE self)
return val;
}
#if defined(__GNUC__)
# define DECL_FUNC_CDECL(f,ret,args) FUNC_CDECL(ret (*f)(args))
# define DECL_FUNC_STDCALL(f,ret,args) FUNC_STDCALL(ret (*f)(args))
/* # define DECL_FUNC(f,ret,args,calltype) ret (*f)(args) */
#elif defined(_MSC_VER) || defined(__BORLANDC__)
# define DECL_FUNC_CDECL(f,ret,args) ret (__cdecl *f)(args)
# define DECL_FUNC_STDCALL(f,ret,args) ret (__stdcall *f)(args)
#elif defined(__SUNPRO_C)
# define DECL_FUNC(f,ret,args,calltype) ret (*f)(args)
# define DECL_FUNC_CDECL(f,ret,args) ret (*f)(args)
# define DECL_FUNC_STDCALL(f,ret,args) ret (*f)(args)
#else
# error "unsupported compiler."
#endif
# define DECL_FUNC_CDECL(f,ret,args) ret (FUNC_CDECL(*f))(args)
# define DECL_FUNC_STDCALL(f,ret,args) ret (FUNC_STDCALL(*f))(args)
#define CALL_CASE switch( RARRAY(ary)->len ){ \
CASE(0); break; \

View file

@ -56,31 +56,6 @@ rb_dl_value2ptr(VALUE self, VALUE val)
return PTR2NUM((void*)val);
}
#if defined(__GNUC__)
# define PRE_DECL_CDECL __attribute__((cdecl))
# 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) || defined(__BORLANDC__)
# 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_STDCALL
#elif (__SUNPRO_C)
# define PRE_DECL_CDECL
# define PRE_DECL_STDCALL
# define MIDST_DECL_CDECL
# define MIDST_DECL_STDCALL
# define POST_DECL_CDECL
# define POST_DECL_STDCALL
#else
# error "unsupported compiler"
#endif
#include "callback.h"
void

View file

@ -111,8 +111,8 @@ for calltype in CALLTYPES
for n in 0..(MAX_CALLBACK-1)
$out << (<<-EOS)
FUNC_#{calltype.upcase}(static #{DLTYPE[ty][:type]}
#{func_name(ty,argc,n,calltype)}(#{(0...argc).collect{|i| "DLSTACK_TYPE stack" + i.to_s}.join(", ")}))
static #{DLTYPE[ty][:type]}
FUNC_#{calltype.upcase}(#{func_name(ty,argc,n,calltype)})(#{(0...argc).collect{|i| "DLSTACK_TYPE stack" + i.to_s}.join(", ")})
{
VALUE ret, cb#{argc > 0 ? ", args[#{argc}]" : ""};
#{

View file

@ -94,14 +94,14 @@ class TestDL < TestBase
assert_equal(str[0,2], ptr[0,2])
assert_equal(str[1,2], ptr[1,2])
assert_equal(str[1,0], ptr[1,0])
assert_equal(str[0], ptr[0])
assert_equal(str[1], ptr[1])
assert_equal(str[0].ord, ptr[0])
assert_equal(str[1].ord, ptr[1])
}
str = 'abc'
ptr = CPtr[str]
check.call(str, ptr)
str[0] = ?c
ptr[0] = ?c
str[0] = "c"
ptr[0] = "c".ord
check.call(str, ptr)
str[0,2] = "aa"
ptr[0,2] = "aa"