@Override public final Object dataGetStruct() { return objectAccessor.get(this); }
private final IRubyObject getValue(ThreadContext context, int index, String name, IRubyObject object) { VariableAccessor variableAccessor = variableReaders[index]; RubyClass cls = object.getMetaClass().getRealClass(); if (variableAccessor.getClassId() != cls.hashCode()) { variableReaders[index] = variableAccessor = cls.getVariableAccessorForRead(name); } return (IRubyObject)variableAccessor.get(object); }
/** * Checks if the variable table contains a variable of the * specified name. */ protected boolean variableTableContains(String name) { return metaClass.getVariableAccessorForRead(name).get(this) != null; }
private final IRubyObject getValue(ThreadContext context, int index, String name, IRubyObject object) { VariableAccessor variableAccessor = variableReaders[index]; RubyClass cls = object.getMetaClass().getRealClass(); if (variableAccessor.getClassId() != cls.hashCode()) { variableReaders[index] = variableAccessor = cls.getVariableAccessorForRead(name); } return (IRubyObject)variableAccessor.get(object); }
/** * Retrieve the FFI ext handle for the given object. * * @param self the object * @return the object's FFI handle */ public final Object getFFIHandle(RubyBasicObject self) { return getFFIHandleAccessorForRead().get(self); }
public IRubyObject ivarGetFail(IRubyObject self) { VariableAccessor variableAccessor = accessor; RubyClass cls = self.getMetaClass().getRealClass(); if (variableAccessor.getClassId() != cls.hashCode()) { accessor = variableAccessor = cls.getVariableAccessorForRead(name); } IRubyObject value = (IRubyObject) variableAccessor.get(self); if (value != null) { return value; } return self.getRuntime().getNil(); }
/** * Checks if the variable table contains a variable of the * specified name. */ protected boolean variableTableContains(String name) { return metaClass.getVariableAccessorForRead(name).get(this) != null; }
public IRubyObject ivarGetFail(IRubyObject self) { VariableAccessor variableAccessor = accessor; RubyClass cls = self.getMetaClass().getRealClass(); if (variableAccessor.getClassId() != cls.hashCode()) { accessor = variableAccessor = cls.getVariableAccessorForRead(name); } IRubyObject value = (IRubyObject) variableAccessor.get(self); if (value != null) { return value; } return self.getRuntime().getNil(); }
/** * Fetch an object from the variable table based on the name. * * @return the object or null if not found */ protected Object variableTableFetch(String name) { return metaClass.getVariableAccessorForRead(name).get(this); }
public void serializeVariables(RubyBasicObject object, ObjectOutputStream oos) throws IOException { if (object.varTable != null) { Map<String, VariableAccessor> accessors = getVariableAccessorsForRead(); oos.writeInt(accessors.size()); for (VariableAccessor accessor : accessors.values()) { oos.writeUTF(RubyBasicObject.ERR_INSECURE_SET_INST_VAR); oos.writeObject(accessor.get(object)); } } else { oos.writeInt(0); } }
/** * Fetch an object from the variable table based on the name. * * @return the object or null if not found */ protected Object variableTableFetch(String name) { return metaClass.getVariableAccessorForRead(name).get(this); }
/** * Retrieve the C ext handle for the given object. * * @param self the object * @return the object's C ext handle */ public final Object getNativeHandle(RubyBasicObject self) { return getNativeHandleAccessorForRead().get(self); }
/** * Retrieve the FFI ext handle for the given object. * * @param self the object * @return the object's FFI handle */ public final Object getFFIHandle(RubyBasicObject self) { return getFFIHandleAccessorForRead().get(self); }
public Object clearVariable(RubyBasicObject object, String name) { synchronized(object) { Object value = getVariableAccessorForRead(name).get(object); getVariableAccessorForWrite(name).set(object, null); return value; } }
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) { IRubyObject variable = (IRubyObject) verifyAccessor(self.getMetaClass().getRealClass()).get(self); return variable == null ? context.nil : variable; }
public Object clearVariable(RubyBasicObject object, String name) { synchronized(object) { Object value = getVariableAccessorForRead(name).get(object); getVariableAccessorForWrite(name).set(object, null); return value; } }
public final Pointer getCallback(IRubyObject callable, CachingCallSite callSite) { if (callable instanceof Pointer) { return (Pointer) callable; } Object ffiHandle = callable.getMetaClass().getRealClass().getFFIHandleAccessorField().getVariableAccessorForRead().get(callable); NativeCallbackPointer cbptr; if (ffiHandle instanceof NativeCallbackPointer && ((cbptr = (NativeCallbackPointer) ffiHandle).cbInfo == callbackInfo)) { return cbptr; } return getCallbackPointer(callable, callSite); }
@JIT public static IRubyObject getVariableWithAccessor(IRubyObject self, VariableAccessor accessor, ThreadContext context, String name) { Ruby runtime = context.runtime; IRubyObject result = (IRubyObject)accessor.get(self); if (result == null) { if (runtime.isVerbose()) { runtime.getWarnings().warning(IRubyWarnings.ID.IVAR_NOT_INITIALIZED, str(runtime, "instance variable ", ids(runtime, name)," not initialized")); } result = context.nil; } return result; }
private synchronized Pointer getCallbackPointer(IRubyObject callable, CachingCallSite callSite) { NativeCallbackPointer cbptr = (NativeCallbackPointer) closures.get(callable); if (cbptr != null) { return cbptr; } closures.put(callable, cbptr = newCallback(callable, callSite)); if (callable.getMetaClass().getFFIHandleAccessorForRead().get(callable) == null) { callable.getMetaClass().getFFIHandleAccessorForWrite().set(callable, cbptr); } return cbptr; }
private synchronized Pointer getCallbackPointer(IRubyObject callable, CachingCallSite callSite) { NativeCallbackPointer cbptr = (NativeCallbackPointer) closures.get(callable); if (cbptr != null) { return cbptr; } closures.put(callable, cbptr = newCallback(callable, callSite)); if (callable.getMetaClass().getFFIHandleAccessorForRead().get(callable) == null) { callable.getMetaClass().getFFIHandleAccessorForWrite().set(callable, cbptr); } return cbptr; }