org.jruby.truffle.stdlib.psych.EmitterLayoutImpl Maven / Gradle / Ivy
The newest version!
package org.jruby.truffle.stdlib.psych;
import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.dsl.GeneratedBy;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.DynamicObjectFactory;
import com.oracle.truffle.api.object.FinalLocationException;
import com.oracle.truffle.api.object.HiddenKey;
import com.oracle.truffle.api.object.IncompatibleLocationException;
import com.oracle.truffle.api.object.ObjectType;
import com.oracle.truffle.api.object.Property;
import com.oracle.truffle.api.object.Shape;
import org.jruby.truffle.stdlib.psych.EmitterLayout;
import org.jruby.truffle.core.basicobject.BasicObjectLayoutImpl;
@GeneratedBy(org.jruby.truffle.stdlib.psych.EmitterLayout.class)
public class EmitterLayoutImpl extends BasicObjectLayoutImpl implements EmitterLayout {
public static final EmitterLayout INSTANCE = new EmitterLayoutImpl();
public static class EmitterType extends BasicObjectLayoutImpl.BasicObjectType {
public EmitterType(
com.oracle.truffle.api.object.DynamicObject logicalClass,
com.oracle.truffle.api.object.DynamicObject metaClass) {
super(
logicalClass,
metaClass);
}
@Override
public EmitterType setLogicalClass(com.oracle.truffle.api.object.DynamicObject logicalClass) {
return new EmitterType(
logicalClass,
metaClass);
}
@Override
public EmitterType setMetaClass(com.oracle.truffle.api.object.DynamicObject metaClass) {
return new EmitterType(
logicalClass,
metaClass);
}
}
protected static final Shape.Allocator EMITTER_ALLOCATOR = LAYOUT.createAllocator();
protected static final HiddenKey EMITTER_IDENTIFIER = new HiddenKey("emitter");
protected static final Property EMITTER_PROPERTY = Property.create(EMITTER_IDENTIFIER, EMITTER_ALLOCATOR.locationForType(org.yaml.snakeyaml.emitter.Emitter.class), 0);
protected static final HiddenKey OPTIONS_IDENTIFIER = new HiddenKey("options");
protected static final Property OPTIONS_PROPERTY = Property.create(OPTIONS_IDENTIFIER, EMITTER_ALLOCATOR.locationForType(org.yaml.snakeyaml.DumperOptions.class), 0);
protected static final HiddenKey IO_IDENTIFIER = new HiddenKey("io");
protected static final Property IO_PROPERTY = Property.create(IO_IDENTIFIER, EMITTER_ALLOCATOR.locationForType(java.lang.Object.class), 0);
protected EmitterLayoutImpl() {
}
@Override
public DynamicObjectFactory createEmitterShape(
com.oracle.truffle.api.object.DynamicObject logicalClass,
com.oracle.truffle.api.object.DynamicObject metaClass) {
return LAYOUT.createShape(new EmitterType(
logicalClass,
metaClass))
.addProperty(EMITTER_PROPERTY)
.addProperty(OPTIONS_PROPERTY)
.addProperty(IO_PROPERTY)
.createFactory();
}
@Override
public DynamicObject createEmitter(
DynamicObjectFactory factory,
org.yaml.snakeyaml.emitter.Emitter emitter,
org.yaml.snakeyaml.DumperOptions options,
java.lang.Object io) {
assert factory != null;
CompilerAsserts.partialEvaluationConstant(factory);
assert createsEmitter(factory);
assert factory.getShape().hasProperty(EMITTER_IDENTIFIER);
assert factory.getShape().hasProperty(OPTIONS_IDENTIFIER);
assert factory.getShape().hasProperty(IO_IDENTIFIER);
return factory.newInstance(
emitter,
options,
io);
}
@Override
public boolean isEmitter(DynamicObject object) {
return isEmitter(object.getShape().getObjectType());
}
private static boolean isEmitter(ObjectType objectType) {
return objectType instanceof EmitterType;
}
private static boolean createsEmitter(DynamicObjectFactory factory) {
return isEmitter(factory.getShape().getObjectType());
}
@Override
public org.yaml.snakeyaml.emitter.Emitter getEmitter(DynamicObject object) {
assert isEmitter(object);
assert object.getShape().hasProperty(EMITTER_IDENTIFIER);
return (org.yaml.snakeyaml.emitter.Emitter) EMITTER_PROPERTY.get(object, isEmitter(object));
}
@Override
public void setEmitter(DynamicObject object, org.yaml.snakeyaml.emitter.Emitter value) {
assert isEmitter(object);
assert object.getShape().hasProperty(EMITTER_IDENTIFIER);
try {
EMITTER_PROPERTY.set(object, value, object.getShape());
} catch (IncompatibleLocationException | FinalLocationException e) {
throw new UnsupportedOperationException(e);
}
}
@Override
public org.yaml.snakeyaml.DumperOptions getOptions(DynamicObject object) {
assert isEmitter(object);
assert object.getShape().hasProperty(OPTIONS_IDENTIFIER);
return (org.yaml.snakeyaml.DumperOptions) OPTIONS_PROPERTY.get(object, isEmitter(object));
}
@Override
public void setOptions(DynamicObject object, org.yaml.snakeyaml.DumperOptions value) {
assert isEmitter(object);
assert object.getShape().hasProperty(OPTIONS_IDENTIFIER);
try {
OPTIONS_PROPERTY.set(object, value, object.getShape());
} catch (IncompatibleLocationException | FinalLocationException e) {
throw new UnsupportedOperationException(e);
}
}
@Override
public java.lang.Object getIo(DynamicObject object) {
assert isEmitter(object);
assert object.getShape().hasProperty(IO_IDENTIFIER);
return IO_PROPERTY.get(object, isEmitter(object));
}
@Override
public void setIo(DynamicObject object, java.lang.Object value) {
assert isEmitter(object);
assert object.getShape().hasProperty(IO_IDENTIFIER);
try {
IO_PROPERTY.set(object, value, object.getShape());
} catch (IncompatibleLocationException | FinalLocationException e) {
throw new UnsupportedOperationException(e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy