Search in sources :

Example 71 with CEntryPoint

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

the class PolyglotNativeAPI method polyglot_lookup.

@CEntryPoint(name = "polyglot_lookup")
public static PolyglotStatus polyglot_lookup(IsolateThread isolate_thread, PolyglotContextPointer context, CCharPointer language, CCharPointer symbol_name, PolyglotValuePointerPointer symbol) {
    return withHandledErrors(() -> {
        Context jContext = ObjectHandles.getGlobal().get(context);
        String symbolName = CTypeConversion.toJavaString(symbol_name);
        String jLanguage = CTypeConversion.toJavaString(language);
        Value resultSymbol = jContext.getBindings(jLanguage).getMember(symbolName);
        if (resultSymbol == null) {
            throw reportError("Symbol " + symbolName + " in language " + jLanguage + " not found.", PolyglotStatus.polyglot_generic_failure);
        } else {
            symbol.write(createHandle(resultSymbol));
        }
    });
}
Also used : CEntryPointContext(org.graalvm.nativeimage.c.function.CEntryPointContext) Context(org.graalvm.polyglot.Context) Value(org.graalvm.polyglot.Value) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint)

Example 72 with CEntryPoint

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

the class PolyglotNativeAPI method polyglot_import_symbol.

@CEntryPoint(name = "polyglot_import_symbol")
public static PolyglotStatus polyglot_import_symbol(IsolateThread isolate_thread, PolyglotContextPointer context, CCharPointer symbol_name, PolyglotValuePointerPointer value) {
    return withHandledErrors(() -> {
        Context jContext = ObjectHandles.getGlobal().get(context);
        String symbolName = CTypeConversion.toJavaString(symbol_name);
        value.write(createHandle(jContext.getPolyglotBindings().getMember(symbolName)));
    });
}
Also used : CEntryPointContext(org.graalvm.nativeimage.c.function.CEntryPointContext) Context(org.graalvm.polyglot.Context) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint)

Example 73 with CEntryPoint

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

the class PolyglotNativeAPI method polyglot_create_boolean.

@CEntryPoint(name = "polyglot_create_boolean")
public static PolyglotStatus polyglot_create_boolean(IsolateThread isolate_thread, PolyglotContextPointer polyglot_context, boolean value, PolyglotValuePointerPointer result) {
    return withHandledErrors(() -> {
        Context ctx = ObjectHandles.getGlobal().get(polyglot_context);
        result.write(createHandle(ctx.asValue(value)));
    });
}
Also used : CEntryPointContext(org.graalvm.nativeimage.c.function.CEntryPointContext) Context(org.graalvm.polyglot.Context) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint)

Example 74 with CEntryPoint

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

the class PolyglotNativeAPI method polyglot_set_member.

@CEntryPoint(name = "polyglot_set_member")
public static PolyglotStatus polyglot_set_member(IsolateThread isolate_thread, PolyglotValuePointer object, CCharPointer utf8_name, PolyglotValuePointer value) {
    return withHandledErrors(() -> {
        Value jObject = fetchHandle(object);
        Value jValue = fetchHandle(value);
        jObject.putMember(CTypeConversion.toJavaString(utf8_name), jValue);
    });
}
Also used : Value(org.graalvm.polyglot.Value) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint)

Example 75 with CEntryPoint

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

the class PolyglotNativeAPI method polyglot_create_char.

@CEntryPoint(name = "polyglot_create_char")
public static PolyglotStatus polyglot_create_char(IsolateThread isolate_thread, PolyglotContextPointer polyglot_context, char c, PolyglotValuePointerPointer result) {
    return withHandledErrors(() -> {
        Context ctx = ObjectHandles.getGlobal().get(polyglot_context);
        result.write(createHandle(ctx.asValue(c)));
    });
}
Also used : CEntryPointContext(org.graalvm.nativeimage.c.function.CEntryPointContext) Context(org.graalvm.polyglot.Context) 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