Skip to content

Commit

Permalink
Just use the Ruby definition of this type.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Oct 28, 2019
1 parent 8209ab6 commit 221b11d
Showing 1 changed file with 0 additions and 38 deletions.
38 changes: 0 additions & 38 deletions core/src/main/java/org/jruby/ext/ffi/StructLayout.java
Expand Up @@ -145,11 +145,6 @@ public static RubyClass createStructLayoutClass(Ruby runtime, RubyModule module)
ArrayFieldAllocator.INSTANCE, layoutClass);
arrayFieldClass.defineAnnotatedMethods(ArrayField.class);

RubyClass mappedFieldClass = runtime.defineClassUnder("Mapped", fieldClass,
MappedFieldAllocator.INSTANCE, layoutClass);
mappedFieldClass.defineAnnotatedMethods(MappedField.class);


return layoutClass;
}

Expand Down Expand Up @@ -894,39 +889,6 @@ public final IRubyObject initialize(ThreadContext context, IRubyObject[] args) {
}
}

private static final class MappedFieldAllocator implements ObjectAllocator {
public final IRubyObject allocate(Ruby runtime, RubyClass klass) {
return new MappedField(runtime, klass);
}
private static final ObjectAllocator INSTANCE = new MappedFieldAllocator();
}

@JRubyClass(name="FFI::StructLayout::Mapped", parent="FFI::StructLayout::Field")
public static final class MappedField extends Field {

public MappedField(Ruby runtime, RubyClass klass) {
super(runtime, klass, DefaultFieldIO.INSTANCE);
}

@JRubyMethod(required = 4, visibility = PRIVATE)
public IRubyObject initialize(ThreadContext context, IRubyObject[] args) {
if (!(args[2] instanceof MappedType)) {
throw context.runtime.newTypeError(args[2],
context.runtime.getModule("FFI").getClass("Type").getClass("Mapped"));
}

if (!(args[3] instanceof Field)) {
throw context.runtime.newTypeError(args[3],
context.runtime.getModule("FFI").getClass("StructLayout").getClass("Field"));
}

init(args[0], args[2], args[1], new MappedFieldIO((MappedType) args[2], ((Field) args[3]).getFieldIO()));

return this;
}
}


public static interface Storage {
IRubyObject getCachedValue(Member member);
void putCachedValue(Member member, IRubyObject value);
Expand Down

0 comments on commit 221b11d

Please sign in to comment.