Skip to content

Commit d2f1c3f

Browse files
committed
Define RB_NIL_P() directly in ruby.h
* Use #ifdef TRUFFLERUBY to clearly show the difference with upstream code.
1 parent 05f3773 commit d2f1c3f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/cext/include/ruby/ruby.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,16 @@ enum ruby_special_consts {
477477
#endif
478478
#define SYMBOL_FLAG RUBY_SYMBOL_FLAG
479479

480+
#ifdef TRUFFLERUBY
481+
#define RB_NIL_P(value) ((int) polyglot_as_boolean(polyglot_invoke(RUBY_CEXT, "RB_NIL_P", value)))
480482
int RTEST(VALUE value);
481483
#define NIL_P(v) RB_NIL_P(v)
484+
#else
485+
#define RB_TEST(v) !(((VALUE)(v) & (VALUE)~RUBY_Qnil) == 0)
486+
#define RB_NIL_P(v) !((VALUE)(v) != RUBY_Qnil)
487+
#define RTEST(v) RB_TEST(v)
488+
#define NIL_P(v) RB_NIL_P(v)
489+
#endif
482490

483491
#define CLASS_OF(v) rb_class_of((VALUE)(v))
484492

lib/cext/include/truffleruby/truffleruby-pre.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ extern VALUE (*rb_tr_wrap)(void *obj);
5353
extern VALUE (*rb_tr_longwrap)(long obj);
5454

5555

56-
#define RB_NIL_P(value) ((int)polyglot_as_boolean(polyglot_invoke(rb_tr_cext, "RB_NIL_P", value)))
57-
5856
#include <ruby/thread_native.h>
5957

6058
// Helpers

0 commit comments

Comments
 (0)