< prev index next >

src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/SharedUtils.java

Print this page

304 
305     public static MethodHandle unboxVaLists(MethodType type, MethodHandle handle, MethodHandle unboxer) {
306         for (int i = 0; i < type.parameterCount(); i++) {
307             if (type.parameterType(i) == VaList.class) {
308                handle = MethodHandles.filterArguments(handle, i, unboxer);
309             }
310         }
311         return handle;
312     }
313 
314     public static MethodHandle boxVaLists(MethodHandle handle, MethodHandle boxer) {
315         MethodType type = handle.type();
316         for (int i = 0; i < type.parameterCount(); i++) {
317             if (type.parameterType(i) == VaList.class) {
318                handle = MethodHandles.filterArguments(handle, i, boxer);
319             }
320         }
321         return handle;
322     }
323 







324     public static class SimpleVaArg {
325         public final Class<?> carrier;
326         public final MemoryLayout layout;
327         public final Object value;
328 
329         public SimpleVaArg(Class<?> carrier, MemoryLayout layout, Object value) {
330             this.carrier = carrier;
331             this.layout = layout;
332             this.value = value;
333         }
334 
335         public VarHandle varHandle() {
336             return carrier == MemoryAddress.class
337                 ? MemoryHandles.asAddressVarHandle(layout.varHandle(primitiveCarrierForSize(layout.byteSize())))
338                 : layout.varHandle(carrier);
339         }
340     }
341 
342     public static class EmptyVaList implements CSupport.VaList {
343 

304 
305     public static MethodHandle unboxVaLists(MethodType type, MethodHandle handle, MethodHandle unboxer) {
306         for (int i = 0; i < type.parameterCount(); i++) {
307             if (type.parameterType(i) == VaList.class) {
308                handle = MethodHandles.filterArguments(handle, i, unboxer);
309             }
310         }
311         return handle;
312     }
313 
314     public static MethodHandle boxVaLists(MethodHandle handle, MethodHandle boxer) {
315         MethodType type = handle.type();
316         for (int i = 0; i < type.parameterCount(); i++) {
317             if (type.parameterType(i) == VaList.class) {
318                handle = MethodHandles.filterArguments(handle, i, boxer);
319             }
320         }
321         return handle;
322     }
323 
324     static void checkType(Class<?> actualType, Class<?> expectedType) {
325         if (expectedType != actualType) {
326             throw new IllegalArgumentException(
327                     String.format("Invalid operand type: %s. %s expected", actualType, expectedType));
328         }
329     }
330 
331     public static class SimpleVaArg {
332         public final Class<?> carrier;
333         public final MemoryLayout layout;
334         public final Object value;
335 
336         public SimpleVaArg(Class<?> carrier, MemoryLayout layout, Object value) {
337             this.carrier = carrier;
338             this.layout = layout;
339             this.value = value;
340         }
341 
342         public VarHandle varHandle() {
343             return carrier == MemoryAddress.class
344                 ? MemoryHandles.asAddressVarHandle(layout.varHandle(primitiveCarrierForSize(layout.byteSize())))
345                 : layout.varHandle(carrier);
346         }
347     }
348 
349     public static class EmptyVaList implements CSupport.VaList {
350 
< prev index next >