Search in sources :

Example 66 with Value

use of org.graalvm.polyglot.Value in project graal by oracle.

the class PolyglotNativeAPI method polyglot_value_is_boolean.

@CEntryPoint(name = "polyglot_value_is_boolean")
public static PolyglotStatus polyglot_value_is_boolean(IsolateThread isolate_thread, PolyglotValuePointer value, CIntPointer result) {
    return withHandledErrors(() -> {
        Value jValue = fetchHandle(value);
        result.write(jValue.isBoolean() ? 1 : 0);
    });
}
Also used : Value(org.graalvm.polyglot.Value) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint)

Example 67 with Value

use of org.graalvm.polyglot.Value in project graal by oracle.

the class PolyglotNativeAPI method polyglot_value_fits_in_uint8.

@CEntryPoint(name = "polyglot_value_fits_in_uint8")
public static PolyglotStatus polyglot_value_fits_in_uint8(IsolateThread isolate_thread, PolyglotValuePointer value, CIntPointer result) {
    return withHandledErrors(() -> {
        Value dataObject = fetchHandle(value);
        int intValue = dataObject.asInt();
        result.write((dataObject.fitsInInt() && intValue >= 0 && intValue <= 255) ? 1 : 0);
    });
}
Also used : Value(org.graalvm.polyglot.Value) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint)

Example 68 with Value

use of org.graalvm.polyglot.Value in project graal by oracle.

the class PolyglotNativeAPI method polyglot_value_fits_in_int32.

@CEntryPoint(name = "polyglot_value_fits_in_int32")
public static PolyglotStatus polyglot_value_fits_in_int32(IsolateThread isolate_thread, PolyglotValuePointer value, CIntPointer result) {
    return withHandledErrors(() -> {
        Value dataObject = fetchHandle(value);
        result.write(dataObject.fitsInInt() ? 1 : 0);
    });
}
Also used : Value(org.graalvm.polyglot.Value) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint)

Example 69 with Value

use of org.graalvm.polyglot.Value in project graal by oracle.

the class PolyglotNativeAPI method polyglot_get_member.

@CEntryPoint(name = "polyglot_get_member")
public static PolyglotStatus polyglot_get_member(IsolateThread isolate_thread, PolyglotValuePointer object, CCharPointer utf8_name, PolyglotValuePointerPointer result) {
    return withHandledErrors(() -> {
        Value jObject = fetchHandle(object);
        result.write(createHandle(jObject.getMember(CTypeConversion.toJavaString(utf8_name))));
    });
}
Also used : Value(org.graalvm.polyglot.Value) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint)

Example 70 with Value

use of org.graalvm.polyglot.Value in project graal by oracle.

the class PolyglotNativeAPI method polyglot_value_fits_in_uint32.

@CEntryPoint(name = "polyglot_value_fits_in_uint32")
public static PolyglotStatus polyglot_value_fits_in_uint32(IsolateThread isolate_thread, PolyglotValuePointer value, CIntPointer result) {
    return withHandledErrors(() -> {
        Value dataObject = fetchHandle(value);
        long longValue = dataObject.asLong();
        result.write((dataObject.fitsInLong() && longValue >= 0 && longValue <= 4228250625L) ? 1 : 0);
    });
}
Also used : Value(org.graalvm.polyglot.Value) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint)

Aggregations

Value (org.graalvm.polyglot.Value)277 Test (org.junit.Test)203 ValueAssert.assertValue (com.oracle.truffle.api.test.polyglot.ValueAssert.assertValue)65 Context (org.graalvm.polyglot.Context)58 BoxedTestValue (com.oracle.truffle.llvm.test.interop.values.BoxedTestValue)43 PolyglotException (org.graalvm.polyglot.PolyglotException)42 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)34 ProxyObject (org.graalvm.polyglot.proxy.ProxyObject)34 Source (org.graalvm.polyglot.Source)31 ArrayList (java.util.ArrayList)30 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)23 ProxyExecutable (org.graalvm.polyglot.proxy.ProxyExecutable)18 HashMap (java.util.HashMap)14 TruffleContext (com.oracle.truffle.api.TruffleContext)11 UnsupportedMessageException (com.oracle.truffle.api.interop.UnsupportedMessageException)11 NullValue (com.oracle.truffle.llvm.test.interop.values.NullValue)11 UnsupportedTypeException (com.oracle.truffle.api.interop.UnsupportedTypeException)10 DebugValue (com.oracle.truffle.api.debug.DebugValue)9 LanguageContext (com.oracle.truffle.api.test.polyglot.LanguageSPITestLanguage.LanguageContext)9 List (java.util.List)9