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);
});
}
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);
});
}
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);
});
}
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);
});
}
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));
}
});
}
Aggregations