1
1
diff --git a/src/main/java/org/graalvm/polyglot/nativeapi/PolyglotNativeAPI.java b/src/main/java/org/graalvm/polyglot/nativeapi/PolyglotNativeAPI.java
2
- index 1ed21c307..496663aec 100644
2
+ index 1ed21c307..7301ff355 100644
3
3
--- a/src/main/java/org/graalvm/polyglot/nativeapi/PolyglotNativeAPI.java
4
4
+++ b/src/main/java/org/graalvm/polyglot/nativeapi/PolyglotNativeAPI.java
5
5
@@ -28,23 +28,60 @@ import static org.graalvm.polyglot.nativeapi.types.PolyglotNativeAPITypes.Polygl
@@ -189,7 +189,7 @@ index 1ed21c307..496663aec 100644
189
189
@CEntryPoint(name = "poly_context_builder_build", exceptionHandler = ExceptionHandler.class, documentation = {
190
190
"Builds a <code>context</code> from a <code>context_builder</code>. The same builder can be used to ",
191
191
"produce multiple <code>poly_context</code> instances.",
192
- @@ -808,6 +935,138 @@ public final class PolyglotNativeAPI {
192
+ @@ -808,6 +935,160 @@ public final class PolyglotNativeAPI {
193
193
return poly_ok;
194
194
}
195
195
@@ -215,6 +215,28 @@ index 1ed21c307..496663aec 100644
215
215
+ return poly_ok;
216
216
+ }
217
217
+
218
+ + @CEntryPoint(name = "poly_create_source", exceptionHandler = ExceptionHandler.class, documentation = {
219
+ + "Creates a Source object.",
220
+ + "",
221
+ + "@param language_id_utf8 0 terminated and UTF-8 encoded language identifier.",
222
+ + "@param name_utf8 0 terminated and UTF-8 encoded name given to the evaluate source code.",
223
+ + "@param source_utf8 0 terminated and UTF-8 encoded source code to be evaluated.",
224
+ + "@param result <code>poly_value</code> that is the Source Builder object.",
225
+ + "@return poly_ok if all works, poly_generic_error if there is a failure.",
226
+ + })
227
+ + public static PolyglotStatus poly_create_source(PolyglotIsolateThread thread, @CConst CCharPointer language_id_utf8, @CConst CCharPointer path_utf8,
228
+ + PolyglotValuePointer result) throws Exception {
229
+ + resetErrorState();
230
+ + nullCheck(language_id_utf8, "language_id_utf8");
231
+ + nullCheck(path_utf8, "path_utf8");
232
+ + String languageName = CTypeConversion.utf8ToJavaString(language_id_utf8);
233
+ + String jPath = CTypeConversion.utf8ToJavaString(path_utf8);
234
+ +
235
+ + Source source = Source.newBuilder(languageName, new File(jPath)).build();
236
+ + result.write(createHandle(source));
237
+ + return poly_ok;
238
+ + }
239
+ +
218
240
+ @CEntryPoint(name = "poly_create_source_builder", exceptionHandler = ExceptionHandler.class, documentation = {
219
241
+ "Creates a Source object.",
220
242
+ "",
@@ -328,7 +350,7 @@ index 1ed21c307..496663aec 100644
328
350
@CEntryPoint(name = "poly_context_get_engine", exceptionHandler = ExceptionHandler.class, documentation = {
329
351
"Returns the engine this context belongs to.",
330
352
"",
331
- @@ -954,6 +1213 ,36 @@ public final class PolyglotNativeAPI {
353
+ @@ -954,6 +1235 ,36 @@ public final class PolyglotNativeAPI {
332
354
return poly_ok;
333
355
}
334
356
@@ -365,7 +387,7 @@ index 1ed21c307..496663aec 100644
365
387
@CEntryPoint(name = "poly_value_put_member", exceptionHandler = ExceptionHandler.class, documentation = {
366
388
"Sets the value of a member with the `identifier_utf8`.",
367
389
"",
368
- @@ -975,6 +1264 ,25 @@ public final class PolyglotNativeAPI {
390
+ @@ -975,6 +1286 ,25 @@ public final class PolyglotNativeAPI {
369
391
return poly_ok;
370
392
}
371
393
@@ -391,7 +413,7 @@ index 1ed21c307..496663aec 100644
391
413
@CEntryPoint(name = "poly_value_has_member", exceptionHandler = ExceptionHandler.class, documentation = {
392
414
"Returns `true` if such a member exists for the given `identifier_utf8`. If the value has no members ",
393
415
"then it returns `false`.",
394
- @@ -1174,86 +1482 ,1769 @@ public final class PolyglotNativeAPI {
416
+ @@ -1174,86 +1504 ,1769 @@ public final class PolyglotNativeAPI {
395
417
return poly_ok;
396
418
}
397
419
@@ -2212,7 +2234,7 @@ index 1ed21c307..496663aec 100644
2212
2234
@CEntryPoint(name = "poly_create_array", exceptionHandler = ExceptionHandler.class, documentation = {
2213
2235
"Creates a polyglot array from the C array of polyglot values.",
2214
2236
"",
2215
- @@ -1396,6 +3387 ,60 @@ public final class PolyglotNativeAPI {
2237
+ @@ -1396,6 +3409 ,60 @@ public final class PolyglotNativeAPI {
2216
2238
return poly_ok;
2217
2239
}
2218
2240
@@ -2273,7 +2295,7 @@ index 1ed21c307..496663aec 100644
2273
2295
@CEntryPoint(name = "poly_value_is_null", exceptionHandler = ExceptionHandler.class, documentation = {
2274
2296
"Returns `true` if this value is `null` like.",
2275
2297
"",
2276
- @@ -1668,6 +3713 ,71 @@ public final class PolyglotNativeAPI {
2298
+ @@ -1668,6 +3735 ,71 @@ public final class PolyglotNativeAPI {
2277
2299
return poly_ok;
2278
2300
}
2279
2301
@@ -2345,7 +2367,7 @@ index 1ed21c307..496663aec 100644
2345
2367
@CEntryPoint(name = "poly_value_to_string_utf8", exceptionHandler = ExceptionHandler.class, documentation = {
2346
2368
"Writes a <code>toString</code> representation of a <code>poly_value</code> as a 0 terminated and UTF-8 encoded string.",
2347
2369
"",
2348
- @@ -1985,14 +4095 ,14 @@ public final class PolyglotNativeAPI {
2370
+ @@ -1985,14 +4117 ,14 @@ public final class PolyglotNativeAPI {
2349
2371
for (int i = 0; i < arguments.length; i++) {
2350
2372
handleArgs[i] = createHandle(arguments[i]);
2351
2373
}
@@ -2366,7 +2388,7 @@ index 1ed21c307..496663aec 100644
2366
2388
} finally {
2367
2389
threadLocals.get().callbackException = null;
2368
2390
getHandles().popFramesIncluding(frame);
2369
- @@ -2003,6 +4113 ,81 @@ public final class PolyglotNativeAPI {
2391
+ @@ -2003,6 +4135 ,81 @@ public final class PolyglotNativeAPI {
2370
2392
return poly_ok;
2371
2393
}
2372
2394
@@ -2448,7 +2470,7 @@ index 1ed21c307..496663aec 100644
2448
2470
@CEntryPoint(name = "poly_get_callback_info", exceptionHandler = ExceptionHandler.class, documentation = {
2449
2471
"Retrieves details about the call within a callback (e.g., the arguments from a given callback info).",
2450
2472
"",
2451
- @@ -2020,20 +4205 ,43 @@ public final class PolyglotNativeAPI {
2473
+ @@ -2020,20 +4227 ,43 @@ public final class PolyglotNativeAPI {
2452
2474
nullCheck(data, "data");
2453
2475
PolyglotCallbackInfoInternal callbackInfo = fetchHandle(callback_info);
2454
2476
UnsignedWord numberOfArguments = WordFactory.unsigned(callbackInfo.arguments.length);
@@ -2501,7 +2523,7 @@ index 1ed21c307..496663aec 100644
2501
2523
@CEntryPoint(name = "poly_throw_exception", exceptionHandler = ExceptionHandler.class, documentation = {
2502
2524
"Raises an exception in a C callback.",
2503
2525
"",
2504
- @@ -2052,6 +4260 ,25 @@ public final class PolyglotNativeAPI {
2526
+ @@ -2052,6 +4282 ,25 @@ public final class PolyglotNativeAPI {
2505
2527
return poly_ok;
2506
2528
}
2507
2529
@@ -2527,7 +2549,7 @@ index 1ed21c307..496663aec 100644
2527
2549
@CEntryPoint(name = "poly_delete_reference", exceptionHandler = ExceptionHandler.class, documentation = {
2528
2550
"Deletes a poly_reference. After this point, the reference must not be used anymore.",
2529
2551
"",
2530
- @@ -2171,6 +4398 ,26 @@ public final class PolyglotNativeAPI {
2552
+ @@ -2171,6 +4420 ,26 @@ public final class PolyglotNativeAPI {
2531
2553
return poly_ok;
2532
2554
}
2533
2555
@@ -2554,7 +2576,7 @@ index 1ed21c307..496663aec 100644
2554
2576
@CEntryPoint(name = "poly_exception_is_internal_error", exceptionHandler = ExceptionHandler.class, documentation = {
2555
2577
"Checks if this exception was caused by an internal implementation error.",
2556
2578
"",
2557
- @@ -2649,6 +4896 ,61 @@ public final class PolyglotNativeAPI {
2579
+ @@ -2649,6 +4918 ,61 @@ public final class PolyglotNativeAPI {
2558
2580
}
2559
2581
}
2560
2582
@@ -2627,5 +2649,5 @@ index a227d9c9e..58a723a15 100644
2627
2649
- return createIsolate(params, isolate, thread) == 0 ? Poly.ok() : Poly.generic_failure();
2628
2650
+ return createIsolate(params, isolate, thread);
2629
2651
}
2630
-
2652
+
2631
2653
@Uninterruptible(reason = UNINTERRUPTIBLE_REASON)
0 commit comments