Search in sources :

Example 1 with NativeSimpleType

use of com.oracle.truffle.nfi.types.NativeSimpleType in project graal by oracle.

the class ImplicitConvertNFITest method data.

@Parameters(name = "{0}, ({3}) {1}")
public static Collection<Object[]> data() {
    ArrayList<Object[]> ret = new ArrayList<>();
    for (NativeSimpleType type : NumericNFITest.NUMERIC_TYPES) {
        for (Object value : NUMERIC_VALUES) {
            long numericValue = 0;
            if (value instanceof Number) {
                numericValue = ((Number) value).longValue();
            } else if (value instanceof Character) {
                numericValue = (Character) value;
            } else if (value instanceof Boolean) {
                numericValue = (Boolean) value ? 1 : 0;
            }
            ret.add(new Object[] { type, value, numericValue, value.getClass() });
        }
    }
    return ret;
}
Also used : ArrayList(java.util.ArrayList) TruffleObject(com.oracle.truffle.api.interop.TruffleObject) NativeSimpleType(com.oracle.truffle.nfi.types.NativeSimpleType) Parameters(org.junit.runners.Parameterized.Parameters)

Example 2 with NativeSimpleType

use of com.oracle.truffle.nfi.types.NativeSimpleType in project graal by oracle.

the class NFIInitialization method initializeNativeSimpleType.

@CEntryPoint
@CEntryPointOptions(publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static void initializeNativeSimpleType(@SuppressWarnings("unused") IsolateThread thread, NativeTruffleContext ctx, CCharPointer typeName, ffi_type ffiType) {
    NativeSimpleType simpleType = NativeSimpleType.valueOf(CTypeConversion.toJavaString(typeName));
    int size = (int) ffiType.size().rawValue();
    int alignment = ffiType.alignment();
    TruffleNFISupport support = ImageSingletons.lookup(TruffleNFISupport.class);
    Target_com_oracle_truffle_nfi_impl_NFIContext context = support.resolveContextHandle(ctx.contextHandle());
    context.initializeSimpleType(simpleType, size, alignment, ffiType.rawValue());
}
Also used : CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) NativeSimpleType(com.oracle.truffle.nfi.types.NativeSimpleType) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions)

Aggregations

NativeSimpleType (com.oracle.truffle.nfi.types.NativeSimpleType)2 CEntryPointOptions (com.oracle.svm.core.c.function.CEntryPointOptions)1 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)1 ArrayList (java.util.ArrayList)1 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)1 Parameters (org.junit.runners.Parameterized.Parameters)1