mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Moved RB_METHOD_DEFINITION_DECL to intern.h
This macro is used here before defined in ruby.h.
This commit is contained in:
parent
6333020fc9
commit
710bc00379
3 changed files with 300 additions and 82 deletions
|
@ -387,6 +387,206 @@ namespace test_rb_define_method {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace test_rb_define_module_function {
|
||||||
|
static VALUE
|
||||||
|
m1(VALUE, VALUE)
|
||||||
|
{
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
m2(VALUE, VALUE, VALUE)
|
||||||
|
{
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
ma(VALUE, VALUE)
|
||||||
|
{
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
mv(int, VALUE*, VALUE)
|
||||||
|
{
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
VALUE
|
||||||
|
test(VALUE self)
|
||||||
|
{
|
||||||
|
// No cast
|
||||||
|
rb_define_module_function(self, "m1", m1, 1);
|
||||||
|
rb_define_module_function(self, "m2", m2, 2);
|
||||||
|
rb_define_module_function(self, "ma", ma, -2);
|
||||||
|
rb_define_module_function(self, "mv", mv, -1);
|
||||||
|
|
||||||
|
// Cast by RUBY_METHOD_FUNC
|
||||||
|
rb_define_module_function(self, "m1", RUBY_METHOD_FUNC(m1), 1);
|
||||||
|
rb_define_module_function(self, "m2", RUBY_METHOD_FUNC(m2), 2);
|
||||||
|
rb_define_module_function(self, "ma", RUBY_METHOD_FUNC(ma), -2);
|
||||||
|
rb_define_module_function(self, "mv", RUBY_METHOD_FUNC(mv), -1);
|
||||||
|
|
||||||
|
// Explicit cast instead of RUBY_METHOD_FUNC
|
||||||
|
rb_define_module_function(self, "m1", (VALUE (*)(...))(m1), 1);
|
||||||
|
rb_define_module_function(self, "m2", (VALUE (*)(...))(m2), 2);
|
||||||
|
rb_define_module_function(self, "ma", (VALUE (*)(...))(ma), -2);
|
||||||
|
rb_define_module_function(self, "mv", (VALUE (*)(...))(mv), -1);
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_rb_define_singleton_method {
|
||||||
|
static VALUE
|
||||||
|
m1(VALUE, VALUE)
|
||||||
|
{
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
m2(VALUE, VALUE, VALUE)
|
||||||
|
{
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
ma(VALUE, VALUE)
|
||||||
|
{
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
mv(int, VALUE*, VALUE)
|
||||||
|
{
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
VALUE
|
||||||
|
test(VALUE self)
|
||||||
|
{
|
||||||
|
// No cast
|
||||||
|
rb_define_singleton_method(self, "m1", m1, 1);
|
||||||
|
rb_define_singleton_method(self, "m2", m2, 2);
|
||||||
|
rb_define_singleton_method(self, "ma", ma, -2);
|
||||||
|
rb_define_singleton_method(self, "mv", mv, -1);
|
||||||
|
|
||||||
|
// Cast by RUBY_METHOD_FUNC
|
||||||
|
rb_define_singleton_method(self, "m1", RUBY_METHOD_FUNC(m1), 1);
|
||||||
|
rb_define_singleton_method(self, "m2", RUBY_METHOD_FUNC(m2), 2);
|
||||||
|
rb_define_singleton_method(self, "ma", RUBY_METHOD_FUNC(ma), -2);
|
||||||
|
rb_define_singleton_method(self, "mv", RUBY_METHOD_FUNC(mv), -1);
|
||||||
|
|
||||||
|
// Explicit cast instead of RUBY_METHOD_FUNC
|
||||||
|
rb_define_singleton_method(self, "m1", (VALUE (*)(...))(m1), 1);
|
||||||
|
rb_define_singleton_method(self, "m2", (VALUE (*)(...))(m2), 2);
|
||||||
|
rb_define_singleton_method(self, "ma", (VALUE (*)(...))(ma), -2);
|
||||||
|
rb_define_singleton_method(self, "mv", (VALUE (*)(...))(mv), -1);
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_rb_define_protected_method {
|
||||||
|
static VALUE
|
||||||
|
m1(VALUE, VALUE)
|
||||||
|
{
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
m2(VALUE, VALUE, VALUE)
|
||||||
|
{
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
ma(VALUE, VALUE)
|
||||||
|
{
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
mv(int, VALUE*, VALUE)
|
||||||
|
{
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
VALUE
|
||||||
|
test(VALUE self)
|
||||||
|
{
|
||||||
|
// No cast
|
||||||
|
rb_define_protected_method(self, "m1", m1, 1);
|
||||||
|
rb_define_protected_method(self, "m2", m2, 2);
|
||||||
|
rb_define_protected_method(self, "ma", ma, -2);
|
||||||
|
rb_define_protected_method(self, "mv", mv, -1);
|
||||||
|
|
||||||
|
// Cast by RUBY_METHOD_FUNC
|
||||||
|
rb_define_protected_method(self, "m1", RUBY_METHOD_FUNC(m1), 1);
|
||||||
|
rb_define_protected_method(self, "m2", RUBY_METHOD_FUNC(m2), 2);
|
||||||
|
rb_define_protected_method(self, "ma", RUBY_METHOD_FUNC(ma), -2);
|
||||||
|
rb_define_protected_method(self, "mv", RUBY_METHOD_FUNC(mv), -1);
|
||||||
|
|
||||||
|
// Explicit cast instead of RUBY_METHOD_FUNC
|
||||||
|
rb_define_protected_method(self, "m1", (VALUE (*)(...))(m1), 1);
|
||||||
|
rb_define_protected_method(self, "m2", (VALUE (*)(...))(m2), 2);
|
||||||
|
rb_define_protected_method(self, "ma", (VALUE (*)(...))(ma), -2);
|
||||||
|
rb_define_protected_method(self, "mv", (VALUE (*)(...))(mv), -1);
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_rb_define_private_method {
|
||||||
|
static VALUE
|
||||||
|
m1(VALUE, VALUE)
|
||||||
|
{
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
m2(VALUE, VALUE, VALUE)
|
||||||
|
{
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
ma(VALUE, VALUE)
|
||||||
|
{
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
mv(int, VALUE*, VALUE)
|
||||||
|
{
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
VALUE
|
||||||
|
test(VALUE self)
|
||||||
|
{
|
||||||
|
// No cast
|
||||||
|
rb_define_private_method(self, "m1", m1, 1);
|
||||||
|
rb_define_private_method(self, "m2", m2, 2);
|
||||||
|
rb_define_private_method(self, "ma", ma, -2);
|
||||||
|
rb_define_private_method(self, "mv", mv, -1);
|
||||||
|
|
||||||
|
// Cast by RUBY_METHOD_FUNC
|
||||||
|
rb_define_private_method(self, "m1", RUBY_METHOD_FUNC(m1), 1);
|
||||||
|
rb_define_private_method(self, "m2", RUBY_METHOD_FUNC(m2), 2);
|
||||||
|
rb_define_private_method(self, "ma", RUBY_METHOD_FUNC(ma), -2);
|
||||||
|
rb_define_private_method(self, "mv", RUBY_METHOD_FUNC(mv), -1);
|
||||||
|
|
||||||
|
// Explicit cast instead of RUBY_METHOD_FUNC
|
||||||
|
rb_define_private_method(self, "m1", (VALUE (*)(...))(m1), 1);
|
||||||
|
rb_define_private_method(self, "m2", (VALUE (*)(...))(m2), 2);
|
||||||
|
rb_define_private_method(self, "ma", (VALUE (*)(...))(ma), -2);
|
||||||
|
rb_define_private_method(self, "mv", (VALUE (*)(...))(mv), -1);
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" void
|
extern "C" void
|
||||||
Init_cxxanyargs(void)
|
Init_cxxanyargs(void)
|
||||||
{
|
{
|
||||||
|
@ -412,4 +612,8 @@ Init_cxxanyargs(void)
|
||||||
test(rb_hash_foreach);
|
test(rb_hash_foreach);
|
||||||
test(rb_ivar_foreach);
|
test(rb_ivar_foreach);
|
||||||
test(rb_define_method);
|
test(rb_define_method);
|
||||||
|
test(rb_define_module_function);
|
||||||
|
test(rb_define_singleton_method);
|
||||||
|
test(rb_define_protected_method);
|
||||||
|
test(rb_define_private_method);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1023,6 +1023,89 @@ RUBY_SYMBOL_EXPORT_END
|
||||||
{ /* satisfy cc-mode */
|
{ /* satisfy cc-mode */
|
||||||
#endif
|
#endif
|
||||||
} /* extern "C" { */
|
} /* extern "C" { */
|
||||||
|
extern "C++" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_BUILTIN___BUILTIN_TYPES_COMPATIBLE_P)
|
||||||
|
# define rb_f_notimplement_p(f) __builtin_types_compatible_p(__typeof__(f),__typeof__(rb_f_notimplement))
|
||||||
|
#else
|
||||||
|
# define rb_f_notimplement_p(f) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P) && !defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
|
#if defined(__has_attribute) && __has_attribute(transparent_union) && __has_attribute(unused) && __has_attribute(weakref) && __has_attribute(nonnull)
|
||||||
|
#define RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,funcargs) \
|
||||||
|
__attribute__((__unused__,__weakref__(#def),__nonnull__ nonnull))static void defname(RB_UNWRAP_MACRO decl,VALUE(*func)funcargs,int arity);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(RB_METHOD_DEFINITION_DECL_C) || defined(__cplusplus)
|
||||||
|
#ifndef RB_METHOD_DEFINITION_DECL_C
|
||||||
|
#define RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,funcargs) \
|
||||||
|
static inline void defname(RB_UNWRAP_MACRO decl,VALUE(*func)funcargs,int arity) \
|
||||||
|
{ \
|
||||||
|
def(RB_UNWRAP_MACRO vars,(VALUE(*)(ANYARGS))(func),arity); \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define RB_UNWRAP_MACRO(...) __VA_ARGS__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define RB_METHOD_DEFINITION_DECL_CXX_BEGIN(def) template <int Arity> struct def##_tmpl {};
|
||||||
|
#define RB_METHOD_DEFINITION_DECL_CXX(def,defname,decl,vars,funcargs,arity) \
|
||||||
|
template <> struct def##_tmpl<arity> { \
|
||||||
|
static void define(RB_UNWRAP_MACRO decl, VALUE (*func)funcargs) {::defname(RB_UNWRAP_MACRO vars, func, arity);} \
|
||||||
|
static void define(RB_UNWRAP_MACRO decl, VALUE (*func)(...)) {::defname(RB_UNWRAP_MACRO vars, reinterpret_cast<VALUE(*)funcargs>(func), arity);} \
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
#define RB_METHOD_DEFINITION_DECL_CXX_BEGIN(def) /* nothing */
|
||||||
|
#define RB_METHOD_DEFINITION_DECL_CXX(def,defname,decl,vars,funcargs,arity) /* nothing */
|
||||||
|
#endif
|
||||||
|
#define RB_METHOD_DEFINITION_DECL_1(def,nonnull,defname,arity,decl,vars,funcargs) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,funcargs) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_CXX(def,defname,decl,vars,funcargs,arity)
|
||||||
|
|
||||||
|
#define RB_METHOD_DEFINITION_DECL(def,nonnull,decl,vars) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_CXX_BEGIN(def) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##0 ,0 ,decl,vars,(VALUE)) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##1 ,1 ,decl,vars,(VALUE,VALUE)) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##2 ,2 ,decl,vars,(VALUE,VALUE,VALUE)) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##3 ,3 ,decl,vars,(VALUE,VALUE,VALUE,VALUE)) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##4 ,4 ,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##5 ,5 ,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##6 ,6 ,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##7 ,7 ,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##8 ,8 ,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##9 ,9 ,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##10,10,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##11,11,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##12,12,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##13,13,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##14,14,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##15,15,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_M3(def,nonnull,def##m3,decl,vars) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##m2,-2,decl,vars,(VALUE,VALUE)) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_M1(def,nonnull,def##m1,decl,vars) /* END */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define RB_METHOD_DEFINITION_DECL_M1(def,nonnull,defname,decl,vars) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,(int,VALUE*,VALUE)) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,(int,const VALUE*,VALUE)) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,(int,const VALUE*,VALUE,VALUE)) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,(...)) \
|
||||||
|
template <> struct def##_tmpl<-1> { \
|
||||||
|
static void define(RB_UNWRAP_MACRO decl, VALUE (*func)(int,VALUE*,VALUE)) {::defname(RB_UNWRAP_MACRO vars, func, -1);} \
|
||||||
|
static void define(RB_UNWRAP_MACRO decl, VALUE (*func)(int,const VALUE*,VALUE)) {::defname(RB_UNWRAP_MACRO vars, func, -1);} \
|
||||||
|
static void define(RB_UNWRAP_MACRO decl, VALUE (*func)(int,const VALUE*,VALUE,VALUE)) {::defname(RB_UNWRAP_MACRO vars, func, -1);} \
|
||||||
|
static void define(RB_UNWRAP_MACRO decl, VALUE (*func)(...)) {::defname(RB_UNWRAP_MACRO vars, func, -1);} \
|
||||||
|
};
|
||||||
|
#define RB_METHOD_DEFINITION_DECL_M3(def,nonnull,defname,decl,vars) /* nothing */
|
||||||
|
#else
|
||||||
|
#define RB_METHOD_DEFINITION_DECL_M1(def,nonnull,defname,decl,vars) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,(int,union{VALUE*x;const VALUE*y;}__attribute__((__transparent_union__)),VALUE))
|
||||||
|
#define RB_METHOD_DEFINITION_DECL_M3(def,nonnull,defname,decl,vars) \
|
||||||
|
RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,())
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef RB_METHOD_DEFINITION_DECL
|
#ifdef RB_METHOD_DEFINITION_DECL
|
||||||
|
@ -1133,4 +1216,11 @@ RB_METHOD_DEFINITION_DECL(rb_define_singleton_method, (2,3), (VALUE klass, const
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
#if 0
|
||||||
|
{ /* satisfy cc-mode */
|
||||||
|
#endif
|
||||||
|
} /* extern "C++" { */
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* RUBY_INTERN_H */
|
#endif /* RUBY_INTERN_H */
|
||||||
|
|
|
@ -2773,88 +2773,7 @@ RUBY_SYMBOL_EXPORT_END
|
||||||
{ /* satisfy cc-mode */
|
{ /* satisfy cc-mode */
|
||||||
#endif
|
#endif
|
||||||
} /* extern "C" { */
|
} /* extern "C" { */
|
||||||
#endif
|
extern "C++" {
|
||||||
|
|
||||||
#if defined(HAVE_BUILTIN___BUILTIN_TYPES_COMPATIBLE_P)
|
|
||||||
# define rb_f_notimplement_p(f) __builtin_types_compatible_p(__typeof__(f),__typeof__(rb_f_notimplement))
|
|
||||||
#else
|
|
||||||
# define rb_f_notimplement_p(f) 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P) && !defined(_WIN32) && !defined(__CYGWIN__)
|
|
||||||
#if defined(__has_attribute) && __has_attribute(transparent_union) && __has_attribute(unused) && __has_attribute(weakref) && __has_attribute(nonnull)
|
|
||||||
#define RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,funcargs) \
|
|
||||||
__attribute__((__unused__,__weakref__(#def),__nonnull__ nonnull))static void defname(RB_UNWRAP_MACRO decl,VALUE(*func)funcargs,int arity);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(RB_METHOD_DEFINITION_DECL_C) || defined(__cplusplus)
|
|
||||||
#ifndef RB_METHOD_DEFINITION_DECL_C
|
|
||||||
#define RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,funcargs) \
|
|
||||||
static inline void defname(RB_UNWRAP_MACRO decl,VALUE(*func)funcargs,int arity) \
|
|
||||||
{ \
|
|
||||||
def(RB_UNWRAP_MACRO vars,(VALUE(*)(ANYARGS))(func),arity); \
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define RB_UNWRAP_MACRO(...) __VA_ARGS__
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#define RB_METHOD_DEFINITION_DECL_CXX_BEGIN(def) template <int Arity> struct def##_tmpl {};
|
|
||||||
#define RB_METHOD_DEFINITION_DECL_CXX(def,defname,decl,vars,funcargs,arity) \
|
|
||||||
template <> struct def##_tmpl<arity> { \
|
|
||||||
static void define(RB_UNWRAP_MACRO decl, VALUE (*func)funcargs) {::defname(RB_UNWRAP_MACRO vars, func, arity);} \
|
|
||||||
static void define(RB_UNWRAP_MACRO decl, VALUE (*func)(...)) {::defname(RB_UNWRAP_MACRO vars, reinterpret_cast<VALUE(*)funcargs>(func), arity);} \
|
|
||||||
};
|
|
||||||
#else
|
|
||||||
#define RB_METHOD_DEFINITION_DECL_CXX_BEGIN(def) /* nothing */
|
|
||||||
#define RB_METHOD_DEFINITION_DECL_CXX(def,defname,decl,vars,funcargs,arity) /* nothing */
|
|
||||||
#endif
|
|
||||||
#define RB_METHOD_DEFINITION_DECL_1(def,nonnull,defname,arity,decl,vars,funcargs) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,funcargs) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_CXX(def,defname,decl,vars,funcargs,arity)
|
|
||||||
|
|
||||||
#define RB_METHOD_DEFINITION_DECL(def,nonnull,decl,vars) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_CXX_BEGIN(def) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##0 ,0 ,decl,vars,(VALUE)) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##1 ,1 ,decl,vars,(VALUE,VALUE)) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##2 ,2 ,decl,vars,(VALUE,VALUE,VALUE)) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##3 ,3 ,decl,vars,(VALUE,VALUE,VALUE,VALUE)) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##4 ,4 ,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##5 ,5 ,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##6 ,6 ,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##7 ,7 ,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##8 ,8 ,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##9 ,9 ,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##10,10,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##11,11,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##12,12,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##13,13,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##14,14,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##15,15,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_M3(def,nonnull,def##m3,decl,vars) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##m2,-2,decl,vars,(VALUE,VALUE)) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_M1(def,nonnull,def##m1,decl,vars) /* END */
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#define RB_METHOD_DEFINITION_DECL_M1(def,nonnull,defname,decl,vars) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,(int,VALUE*,VALUE)) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,(int,const VALUE*,VALUE)) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,(int,const VALUE*,VALUE,VALUE)) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,(...)) \
|
|
||||||
template <> struct def##_tmpl<-1> { \
|
|
||||||
static void define(RB_UNWRAP_MACRO decl, VALUE (*func)(int,VALUE*,VALUE)) {::defname(RB_UNWRAP_MACRO vars, func, -1);} \
|
|
||||||
static void define(RB_UNWRAP_MACRO decl, VALUE (*func)(int,const VALUE*,VALUE)) {::defname(RB_UNWRAP_MACRO vars, func, -1);} \
|
|
||||||
static void define(RB_UNWRAP_MACRO decl, VALUE (*func)(int,const VALUE*,VALUE,VALUE)) {::defname(RB_UNWRAP_MACRO vars, func, -1);} \
|
|
||||||
static void define(RB_UNWRAP_MACRO decl, VALUE (*func)(...)) {::defname(RB_UNWRAP_MACRO vars, func, -1);} \
|
|
||||||
};
|
|
||||||
#define RB_METHOD_DEFINITION_DECL_M3(def,nonnull,defname,decl,vars) /* nothing */
|
|
||||||
#else
|
|
||||||
#define RB_METHOD_DEFINITION_DECL_M1(def,nonnull,defname,decl,vars) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,(int,union{VALUE*x;const VALUE*y;}__attribute__((__transparent_union__)),VALUE))
|
|
||||||
#define RB_METHOD_DEFINITION_DECL_M3(def,nonnull,defname,decl,vars) \
|
|
||||||
RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,())
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef RB_METHOD_DEFINITION_DECL
|
#ifdef RB_METHOD_DEFINITION_DECL
|
||||||
|
@ -2948,6 +2867,11 @@ RB_METHOD_DEFINITION_DECL(rb_define_global_function, (1,2), (const char *name),
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#include "backward/cxxanyargs.hpp"
|
#include "backward/cxxanyargs.hpp"
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
{ /* satisfy cc-mode */
|
||||||
|
#endif
|
||||||
|
} /* extern "C++" { */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* RUBY_RUBY_H */
|
#endif /* RUBY_RUBY_H */
|
||||||
|
|
Loading…
Add table
Reference in a new issue