Esempio n. 1
0
 public void put(
     ThreadContext context, Storage cache, Member m, IRubyObject ptr, IRubyObject value) {
   if (value.isNil()) {
     m.getMemoryIO(ptr).putAddress(m.getOffset(ptr), 0L);
     cache.putReference(m, value);
   } else {
     Pointer cb =
         Factory.getInstance()
             .getCallbackManager()
             .getCallback(context.getRuntime(), (CallbackInfo) m.type, value);
     m.getMemoryIO(ptr).putMemoryIO(m.getOffset(ptr), cb.getMemoryIO());
     cache.putReference(m, cb);
   }
 }
Esempio n. 2
0
    public void put(
        ThreadContext context, Storage cache, Member m, IRubyObject ptr, IRubyObject value) {
      final IRubyObject nativeValue = mappedType.toNative(context, value);
      nativeFieldIO.put(context, cache, m, ptr, nativeValue);

      if (isValueReferenceNeeded()) {
        // keep references to both the ruby and native values to preserve
        // reference chains
        cache.putReference(m, new Object[] {value, nativeValue});
      }
    }