Sha256: 646fd7a8f054a600ce235d307487fce6f77047381b8fb28dc0ecc470a88bd571

Contents?: true

Size: 1.06 KB

Versions: 43

Compression:

Stored size: 1.06 KB

Contents

#define DEFUN_TAKEOVER_LOGIC(fname, mpz_fname, old_fname) \
static VALUE takeover_fixnum_##fname(int argc, VALUE *argv, VALUE self) \
{ \
  MP_INT *res_val, *arg_val; \
  VALUE res; \
\
  if (argc != 1 || !GMPZ_P(argv[0])) { \
    return rb_funcall2 (self, rb_intern (old_fname), argc, argv); \
  } else { \
    mpz_make_struct(res, res_val); \
    mpz_get_struct(argv[0], arg_val); \
    mpz_init_set_si (res_val, FIX2INT(self)); \
    mpz_fname (res_val, res_val, arg_val); \
    return res; \
  } \
} \
\
static VALUE takeover_bignum_##fname(int argc, VALUE *argv, VALUE self) \
{\
  MP_INT *res_val, *arg_val; \
  VALUE res; \
\
  if (argc != 1 || !GMPZ_P(argv[0])) { \
    return rb_funcall2 (self, rb_intern (old_fname), argc, argv); \
  } else { \
    mpz_get_struct(argv[0], arg_val); \
    mpz_make_struct_init(res, res_val); \
    mpz_set_bignum (res_val, self); \
    mpz_fname (res_val, res_val, arg_val); \
    return res; \
  } \
}

DEFUN_TAKEOVER_LOGIC(and, mpz_and, "old_and")
DEFUN_TAKEOVER_LOGIC(or, mpz_ior, "old_or")
DEFUN_TAKEOVER_LOGIC(xor, mpz_xor, "old_xor")

Version data entries

43 entries across 43 versions & 3 rubygems

Version Path
srawlins-gmp-0.1.1 ext/takeover.h
srawlins-gmp-0.1.2 ext/takeover.h
srawlins-gmp-0.1.4.2 ext/takeover.h
srawlins-gmp-0.1.5.1 ext/takeover.h
srawlins-gmp-0.1.5 ext/takeover.h
gmp-0.7.19 ext/takeover.h
gmp-0.6.47 ext/takeover.h
gmp-0.6.43 ext/takeover.h
ruby-mpfr-0.0.17 ext/gmp/mpfr/gmp_header/takeover.h
ruby-mpfr-0.0.16 ext/gmp/mpfr/gmp_header/takeover.h
gmp-0.6.41 ext/takeover.h
ruby-mpfr-0.0.15 ext/gmp/mpfr/gmp_header/takeover.h
gmp-0.6.31 ext/takeover.h
gmp-0.6.19 ext/takeover.h
gmp-0.6.17 ext/takeover.h
gmp-0.6.13 ext/takeover.h
gmp-0.6.7 ext/takeover.h
gmp-0.5.47 ext/takeover.h
ruby-mpfr-0.0.14 ext/gmp/mpfr/gmp_header/takeover.h
ruby-mpfr-0.0.13 ext/gmp/mpfr/gmp_header/takeover.h