Skip to content

Commit aa11d31

Browse files
committed
[GR-17151] Implement BigDecimal as C extension
PullRequest: truffleruby/2203
2 parents b9050ef + 22c5bab commit aa11d31

39 files changed

+7108
-3383
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Compatibility:
2828
* Support time and date related messages for `Time` (#2166).
2929
* Updated `Dir.{glob,[]}` to raise `ArgumentError` for nul-separated strings.
3030
* `Kernel#lambda` with no block in a method called with a block raises an exception (#2004, @ssnickolay).
31+
* Implemented `BigDecimal` as C extension to improve compatibility.
3132

3233
Performance:
3334

doc/contributor/interop_details.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ When interop message `readMember` is sent
198198
it returns a method with the given name when the method is defined.
199199
- to any non-immediate `Object` like **`nil`**, **`:symbol`**, **a `String`**, **a `BigDecimal`**, **an `Object`**, **a frozen `Object`**, **a `StructWithValue`**, **a `Class`**, **a `Hash`**, **an `Array`**, **`proc {...}`**, **`lambda {...}`**, **a `Method`**, **a `Truffle::FFI::Pointer`**, **polyglot pointer** or **polyglot array**
200200
it fails with `UnknownIdentifierException` when the method is not defined.
201-
- to any non-immediate `Object` like **a `String`**, **a `BigDecimal`**, **an `Object`**, **a `StructWithValue`**, **a `Class`**, **a `Hash`**, **an `Array`**, **`proc {...}`**, **`lambda {...}`**, **a `Method`**, **a `Truffle::FFI::Pointer`**, **polyglot pointer** or **polyglot array**
201+
- to any non-immediate `Object` like **a `String`**, **an `Object`**, **a `StructWithValue`**, **a `Class`**, **a `Hash`**, **an `Array`**, **`proc {...}`**, **`lambda {...}`**, **a `Method`**, **a `Truffle::FFI::Pointer`**, **polyglot pointer** or **polyglot array**
202202
it reads the given instance variable.
203203
- to **polyglot members**
204204
it reads the value stored with the given name.
@@ -208,13 +208,13 @@ When interop message `readMember` is sent
208208
it fails with `UnsupportedMessageError`.
209209

210210
When interop message `writeMember` is sent
211-
- to any non-immediate non-frozen `Object` like **a `String`**, **a `BigDecimal`**, **an `Object`**, **a `StructWithValue`**, **a `Class`**, **a `Hash`**, **an `Array`**, **`proc {...}`**, **`lambda {...}`**, **a `Method`**, **a `Truffle::FFI::Pointer`**, **polyglot pointer** or **polyglot array**
211+
- to any non-immediate non-frozen `Object` like **a `String`**, **an `Object`**, **a `StructWithValue`**, **a `Class`**, **a `Hash`**, **an `Array`**, **`proc {...}`**, **`lambda {...}`**, **a `Method`**, **a `Truffle::FFI::Pointer`**, **polyglot pointer** or **polyglot array**
212212
it writes the given instance variable.
213213
- to **polyglot members**
214214
it writes the given value under the given name.
215215
- to **a `StructWithValue`**
216216
it writes the value to the given struct member.
217-
- to **`nil`**, **`:symbol`** or **a frozen `Object`**
217+
- to **a `BigDecimal`**, **`nil`**, **`:symbol`** or **a frozen `Object`**
218218
it fails with `UnsupportedMessageError` when the receiver is frozen.
219219
- otherwise
220220
it fails with `UnsupportedMessageError`.

lib/cext/include/ruby/ruby.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ rb_long2int_inline(long n)
398398
#endif
399399

400400
#ifdef TRUFFLERUBY
401-
#define RB_FIX2LONG(x) (polyglot_as_i64(rb_tr_unwrap(x)))
401+
#define RB_FIX2LONG(x) ((long)polyglot_as_i64(rb_tr_unwrap(x)))
402402
#else
403403
#define RB_FIX2LONG(x) ((long)RSHIFT((SIGNED_VALUE)(x),1))
404404
#endif

0 commit comments

Comments
 (0)