use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.
the class PolyglotNativeAPI method polyglot_eval.
@CEntryPoint(name = "polyglot_eval")
public static PolyglotStatus polyglot_eval(IsolateThread isolate_thread, PolyglotContextPointer polyglot_context, CCharPointer language, CCharPointer name, CCharPointer code, PolyglotValuePointerPointer result) {
return withHandledErrors(() -> {
Context c = ObjectHandles.getGlobal().get(polyglot_context);
String languageName = CTypeConversion.toJavaString(language);
String jName = CTypeConversion.toJavaString(name);
String jCode = CTypeConversion.toJavaString(code);
Source sourceCode = Source.newBuilder(languageName, jCode, jName).build();
result.write(createHandle(c.eval(sourceCode)));
});
}
use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.
the class PolyglotNativeAPI method polyglot_create_int8.
@SuppressWarnings("UnnecessaryBoxing")
@CEntryPoint(name = "polyglot_create_int8")
public static PolyglotStatus polyglot_create_int8(IsolateThread isolate_thread, PolyglotContextPointer polyglot_context, byte value, PolyglotValuePointerPointer result) {
return withHandledErrors(() -> {
Context ctx = ObjectHandles.getGlobal().get(polyglot_context);
result.write(createHandle(ctx.asValue(Byte.valueOf(value))));
});
}
use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.
the class PolyglotNativeAPI method polyglot_create_int16.
@SuppressWarnings("UnnecessaryBoxing")
@CEntryPoint(name = "polyglot_create_int16")
public static PolyglotStatus polyglot_create_int16(IsolateThread isolate_thread, PolyglotContextPointer polyglot_context, short value, PolyglotValuePointerPointer result) {
return withHandledErrors(() -> {
Context ctx = ObjectHandles.getGlobal().get(polyglot_context);
result.write(createHandle(ctx.asValue(Short.valueOf(value))));
});
}
use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.
the class PolyglotNativeAPI method polyglot_value_fits_in_float.
@CEntryPoint(name = "polyglot_value_fits_in_float")
public static PolyglotStatus polyglot_value_fits_in_float(IsolateThread isolate_thread, PolyglotValuePointer value, CIntPointer result) {
return withHandledErrors(() -> {
Value dataObject = fetchHandle(value);
result.write(dataObject.fitsInFloat() ? 1 : 0);
});
}
use of org.graalvm.nativeimage.c.function.CEntryPoint in project graal by oracle.
the class PolyglotNativeAPI method polyglot_value_create_null.
@CEntryPoint(name = "polyglot_value_create_null")
public static PolyglotStatus polyglot_value_create_null(IsolateThread isolate_thread, PolyglotContextPointer polyglot_context, PolyglotValuePointerPointer result) {
return withHandledErrors(() -> {
Context ctx = ObjectHandles.getGlobal().get(polyglot_context);
result.write(createHandle(ctx.asValue(null)));
});
}
Aggregations