/** * Attaches this function to a ruby module or class. * * @param module The module or class to attach the function to. * @param methodName The ruby name to attach the function as. */ @JRubyMethod(name="attach") public IRubyObject attach(ThreadContext context, IRubyObject obj, IRubyObject methodName) { DynamicMethod m = createDynamicMethod(obj.getSingletonClass()); obj.getSingletonClass().addMethod(methodName.asJavaString(), m); if (obj instanceof RubyModule) { ((RubyModule) obj).addMethod(methodName.asJavaString(), m); } getRuntime().getFFI().registerAttachedMethod(m, this); return this; } protected abstract DynamicMethod createDynamicMethod(RubyModule module);
public IRubyObject get(ThreadContext context, StructLayout.Storage cache, Member m, AbstractMemory ptr) { final long address = ((Pointer) ptr).getMemoryIO().getAddress(m.getOffset(ptr)); AbstractInvoker fptr = (AbstractInvoker) cache.getCachedValue(m); if (fptr != null && fptr.getAddress() == address) { return fptr; } fptr = Factory.getInstance().newFunction(context.runtime, ((Pointer) ptr).getPointer(context.runtime, m.getOffset(ptr)), (CallbackInfo) m.type); cache.putCachedValue(m, fptr); return fptr; }
AbstractInvoker.createAbstractInvokerClass(runtime, ffi);
AbstractInvoker.createAbstractInvokerClass(runtime, ffi);
/** * Attaches this function to a ruby module or class. * * @param module The module or class to attach the function to. * @param methodName The ruby name to attach the function as. */ @JRubyMethod(name="attach") public IRubyObject attach(ThreadContext context, IRubyObject obj, IRubyObject methodName) { DynamicMethod m = createDynamicMethod(obj.getSingletonClass()); obj.getSingletonClass().addMethod(methodName.asJavaString(), m); if (obj instanceof RubyModule) { ((RubyModule) obj).addMethod(methodName.asJavaString(), m); } getRuntime().getFFI().registerAttachedMethod(m, this); return this; } protected abstract DynamicMethod createDynamicMethod(RubyModule module);
public IRubyObject get(ThreadContext context, StructLayout.Storage cache, Member m, AbstractMemory ptr) { final long address = ((Pointer) ptr).getMemoryIO().getAddress(m.getOffset(ptr)); AbstractInvoker fptr = (AbstractInvoker) cache.getCachedValue(m); if (fptr != null && fptr.getAddress() == address) { return fptr; } fptr = Factory.getInstance().newFunction(context.runtime, ((Pointer) ptr).getPointer(context.runtime, m.getOffset(ptr)), (CallbackInfo) m.type); cache.putCachedValue(m, fptr); return fptr; }
AbstractInvoker.createAbstractInvokerClass(runtime, ffi);
/** * Attaches this function to a ruby module or class. * * @param module The module or class to attach the function to. * @param methodName The ruby name to attach the function as. */ @JRubyMethod(name="attach") public IRubyObject attach(ThreadContext context, IRubyObject obj, IRubyObject methodName) { DynamicMethod m = createDynamicMethod(obj.getSingletonClass()); m.setName(methodName.asJavaString()); obj.getSingletonClass().addMethod(methodName.asJavaString(), m); if (obj instanceof RubyModule) { ((RubyModule) obj).addMethod(methodName.asJavaString(), m); } getRuntime().getFFI().registerAttachedMethod(m, this); return this; } protected abstract DynamicMethod createDynamicMethod(RubyModule module);
public IRubyObject get(ThreadContext context, StructLayout.Storage cache, Member m, AbstractMemory ptr) { final long address = ((Pointer) ptr).getMemoryIO().getAddress(m.getOffset(ptr)); AbstractInvoker fptr = (AbstractInvoker) cache.getCachedValue(m); if (fptr != null && fptr.getAddress() == address) { return fptr; } fptr = Factory.getInstance().newFunction(context.runtime, ((Pointer) ptr).getPointer(context.runtime, m.getOffset(ptr)), (CallbackInfo) m.type); cache.putCachedValue(m, fptr); return fptr; }
AbstractInvoker.createAbstractInvokerClass(runtime, ffi);
/** * Attaches this function to a ruby module or class. * * @param module The module or class to attach the function to. * @param methodName The ruby name to attach the function as. */ @JRubyMethod(name="attach") public IRubyObject attach(ThreadContext context, IRubyObject obj, IRubyObject methodName) { DynamicMethod m = createDynamicMethod(obj.getSingletonClass()); m.setName(methodName.asJavaString()); obj.getSingletonClass().addMethod(methodName.asJavaString(), m); if (obj instanceof RubyModule) { ((RubyModule) obj).addMethod(methodName.asJavaString(), m); } getRuntime().getFFI().registerAttachedMethod(m, this); return this; } protected abstract DynamicMethod createDynamicMethod(RubyModule module);
public IRubyObject get(ThreadContext context, StructLayout.Storage cache, Member m, AbstractMemory ptr) { final long address = ((Pointer) ptr).getMemoryIO().getAddress(m.getOffset(ptr)); AbstractInvoker fptr = (AbstractInvoker) cache.getCachedValue(m); if (fptr != null && fptr.getAddress() == address) { return fptr; } fptr = Factory.getInstance().newFunction(context.runtime, ((Pointer) ptr).getPointer(context.runtime, m.getOffset(ptr)), (CallbackInfo) m.type); cache.putCachedValue(m, fptr); return fptr; }