Search in sources :

Example 11 with CEntryPoint

use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.

the class PolyglotNativeAPI method polyglot_create_engine.

@CEntryPoint(name = "polyglot_create_engine", documentation = { "Creates a polyglot engine.", "Engine is a unit that holds configuration, instruments, and compiled code for many contexts", "inside the engine." })
public static PolyglotStatus polyglot_create_engine(IsolateThread isolate_thread, PolyglotEnginePointerPointer engine) {
    return withHandledErrors(() -> {
        ObjectHandle handle = createHandle(Engine.create());
        engine.write(handle);
    });
}
Also used : ObjectHandle(org.graalvm.nativeimage.ObjectHandle) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint)

Example 12 with CEntryPoint

use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.

the class PolyglotNativeAPI method polyglot_value_is_string.

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

Example 13 with CEntryPoint

use of org.graalvm.nativeimage.c.function.CEntryPoint 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 14 with CEntryPoint

use of org.graalvm.nativeimage.c.function.CEntryPoint 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 15 with CEntryPoint

use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.

the class PolyglotNativeAPI method polyglot_available_languages.

@CEntryPoint(name = "polyglot_available_languages")
public static PolyglotStatus polyglot_available_languages(IsolateThread isolate_thread, PolyglotEnginePointer engine_handle, CCharPointerPointer lang_array) {
    return withHandledErrors(() -> {
        String[] langs = sortedLangs(ObjectHandles.getGlobal().get(engine_handle));
        for (int i = 0; i < langs.length; i++) {
            CCharPointer name = lang_array.read(i);
            CTypeConversion.toCString(langs[i], UTF8_CHARSET, name, WordFactory.unsigned(langs[i].getBytes(UTF8_CHARSET).length));
        }
    });
}
Also used : CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CCharPointer(org.graalvm.nativeimage.c.type.CCharPointer) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint)

Aggregations

CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)81 CEntryPointOptions (com.oracle.svm.core.c.function.CEntryPointOptions)26 Value (org.graalvm.polyglot.Value)23 CEntryPointContext (org.graalvm.nativeimage.c.function.CEntryPointContext)19 Context (org.graalvm.polyglot.Context)19 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)7 ObjectHandle (org.graalvm.nativeimage.ObjectHandle)5 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)4 CCharPointer (org.graalvm.nativeimage.c.type.CCharPointer)4 CIntPointer (org.graalvm.nativeimage.c.type.CIntPointer)4 JNIObjectHandle (com.oracle.svm.jni.nativeapi.JNIObjectHandle)3 PinnedObject (org.graalvm.nativeimage.PinnedObject)3 Log (com.oracle.svm.core.log.Log)2 JNIAccessibleMethodDescriptor (com.oracle.svm.jni.access.JNIAccessibleMethodDescriptor)2 JNINativeLinkage (com.oracle.svm.jni.access.JNINativeLinkage)2 JNIMethodId (com.oracle.svm.jni.nativeapi.JNIMethodId)2 JNINativeMethod (com.oracle.svm.jni.nativeapi.JNINativeMethod)2 Executable (java.lang.reflect.Executable)2 Method (java.lang.reflect.Method)2 ByteBuffer (java.nio.ByteBuffer)2