/** * Creates a new <tt>StructLayout</tt> instance. * * @param runtime The runtime for the <tt>StructLayout</tt> * @param klass the ruby class to use for the <tt>StructLayout</tt> */ public Struct(Ruby runtime, RubyClass klass) { this(runtime, klass, getStructLayout(runtime, klass), null); }
/** * Creates a new <tt>StructLayout</tt> instance. * * @param runtime The runtime for the <tt>StructLayout</tt> * @param klass the ruby class to use for the <tt>StructLayout</tt> */ public Struct(Ruby runtime, RubyClass klass) { this(runtime, klass, getStructLayout(runtime, klass), null); }
/** * Creates a new <tt>StructLayout</tt> instance. * * @param runtime The runtime for the <tt>StructLayout</tt> * @param klass the ruby class to use for the <tt>StructLayout</tt> */ public Struct(Ruby runtime, RubyClass klass) { this(runtime, klass, getStructLayout(runtime, klass), null); }
/** * Creates a new <tt>StructLayout</tt> instance. * * @param runtime The runtime for the <tt>StructLayout</tt> * @param klass the ruby class to use for the <tt>StructLayout</tt> */ public Struct(Ruby runtime, RubyClass klass) { this(runtime, klass, getStructLayout(runtime, klass), null); }
@JRubyMethod(name = "layout") public final IRubyObject layout(ThreadContext context) { // getStructLayout gets the @layout from the structClass // which should be OK during concurrent access of this method if (structLayout == null) { structLayout = Struct.getStructLayout(context.runtime, structClass); } return structLayout; }
@JRubyMethod(name = "layout") public final IRubyObject layout(ThreadContext context) { // getStructLayout gets the @layout from the structClass // which should be OK during concurrent access of this method if (structLayout == null) { structLayout = Struct.getStructLayout(context.runtime, structClass); } return structLayout; }
@JRubyMethod(name = "offsets", meta = true) public static IRubyObject offsets(ThreadContext context, IRubyObject structClass) { return getStructLayout(context.runtime, structClass).offsets(context); }
@JRubyMethod(name = { "alignment", "align" }, meta = true) public static IRubyObject alignment(ThreadContext context, IRubyObject structClass) { return getStructLayout(context.runtime, structClass).alignment(context); }
@JRubyMethod(name = "members", meta = true) public static IRubyObject members(ThreadContext context, IRubyObject structClass) { return getStructLayout(context.runtime, structClass).members(context); }
@JRubyMethod(name = "offset_of", meta = true) public static IRubyObject offset_of(ThreadContext context, IRubyObject structClass, IRubyObject fieldName) { return getStructLayout(context.runtime, structClass).offset_of(context, fieldName); }
@JRubyMethod(name = "members", meta = true) public static IRubyObject members(ThreadContext context, IRubyObject structClass) { return getStructLayout(context.runtime, structClass).members(context); }
@JRubyMethod(name = "offset_of", meta = true) public static IRubyObject offset_of(ThreadContext context, IRubyObject structClass, IRubyObject fieldName) { return getStructLayout(context.runtime, structClass).offset_of(context, fieldName); }
@JRubyMethod(name = "offset_of", meta = true) public static IRubyObject offset_of(ThreadContext context, IRubyObject structClass, IRubyObject fieldName) { return getStructLayout(context.runtime, structClass).offset_of(context, fieldName); }
@JRubyMethod(name = "offsets", meta = true) public static IRubyObject offsets(ThreadContext context, IRubyObject structClass) { return getStructLayout(context.runtime, structClass).offsets(context); }
@JRubyMethod(name = "offset_of", meta = true) public static IRubyObject offset_of(ThreadContext context, IRubyObject structClass, IRubyObject fieldName) { return getStructLayout(context.runtime, structClass).offset_of(context, fieldName); }
private static final Struct allocateStruct(ThreadContext context, IRubyObject klass, int flags) { Ruby runtime = context.runtime; StructLayout layout = getStructLayout(runtime, klass); return new Struct(runtime, (RubyClass) klass, layout, new Buffer(runtime, layout.getSize(), flags)); }
private static final Struct allocateStruct(ThreadContext context, IRubyObject klass, int flags) { Ruby runtime = context.runtime; StructLayout layout = getStructLayout(runtime, klass); return new Struct(runtime, (RubyClass) klass, layout, new Buffer(runtime, layout.getSize(), flags)); }
private static final Struct allocateStruct(ThreadContext context, IRubyObject klass, int flags) { Ruby runtime = context.runtime; StructLayout layout = getStructLayout(runtime, klass); return new Struct(runtime, (RubyClass) klass, layout, new Buffer(runtime, layout.getSize(), flags)); }
private static final Struct allocateStruct(ThreadContext context, IRubyObject klass, int flags) { Ruby runtime = context.runtime; StructLayout layout = getStructLayout(runtime, klass); return new Struct(runtime, (RubyClass) klass, layout, new Buffer(runtime, layout.getSize(), flags)); }
@JRubyMethod(name = "new", meta = true) public static final IRubyObject newStructByValue(ThreadContext context, IRubyObject klass, IRubyObject structClass) { if (!(structClass instanceof RubyClass)) { throw context.runtime.newTypeError("wrong argument type " + structClass.getMetaClass().getName() + " (expected Class)"); } if (!((RubyClass) structClass).isKindOfModule(context.runtime.getFFI().structClass)) { throw context.runtime.newTypeError("wrong argument type " + structClass.getMetaClass().getName() + " (expected subclass of FFI::Struct)"); } return new StructByValue(context.runtime, (RubyClass) klass, (RubyClass) structClass, Struct.getStructLayout(context.runtime, structClass)); }