Skip to content

Commit 90d0998

Browse files
committed
Enable interop to use untyped Java collections.
This provides a way to treat some 6model object as a plain old Java object for a while, then later on recover the underlying 6model object once again. This is useful when wanting to use some of the built-in Java collection classes.
1 parent 048ae58 commit 90d0998

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/vm/jvm/runtime/org/perl6/nqp/runtime/BootJavaInterop.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,15 @@ public SixModelObject implementClass(SixModelObject description) {
177177
finishClass(cc);
178178
return RuntimeSupport.boxJava(cc.constructed, getSTableForClass(Class.class));
179179
}
180+
181+
/** Hiding arbitrary 6model objects under Object, for working with
182+
* untyped collection classes, etc. */
183+
public SixModelObject sixmodelToJavaObject(SixModelObject smo) {
184+
return RuntimeSupport.boxJava(smo, getSTableForClass(Object.class));
185+
}
186+
public SixModelObject javaObjectToSixmodel(SixModelObject javaObj) {
187+
return (SixModelObject)RuntimeSupport.unboxJava(javaObj);
188+
}
180189

181190
protected void finishClass(ClassContext cc) {
182191
cc.cv.visitEnd();

0 commit comments

Comments
 (0)