dart_monty_ffi 0.6.0 copy "dart_monty_ffi: ^0.6.0" to clipboard
dart_monty_ffi: ^0.6.0 copied to clipboard

Native FFI backend for dart_monty, pure Dart bindings for Monty — a restricted sandboxed Python interpreter built in Rust.

example/example.dart

// Printing to stdout is expected in an example.
// ignore_for_file: avoid_print
import 'dart:convert';

import 'package:dart_monty_ffi/dart_monty_ffi.dart';
import 'package:dart_monty_platform_interface/dart_monty_platform_interface.dart';

/// Demonstrates direct use of the native FFI bindings.
///
/// Most apps should import `dart_monty` instead — the federated plugin
/// selects the correct backend automatically.
void main() {
  // Open the native library (requires libdart_monty_native on the system).
  final bindings = NativeBindingsFfi();

  // Run a simple expression.
  final handle = bindings.create('2 + 2');
  final runResult = bindings.run(handle);
  final resultJson = runResult.resultJson;
  if (resultJson != null) {
    final json = jsonDecode(resultJson) as Map<String, dynamic>;
    final result = MontyResult.fromJson(json);
    print('Result: ${result.value}'); // 4
  }

  bindings.free(handle);
}
0
likes
160
points
394
downloads

Publisher

unverified uploader

Weekly Downloads

Native FFI backend for dart_monty, pure Dart bindings for Monty — a restricted sandboxed Python interpreter built in Rust.

Repository (GitHub)
View/report issues
Contributing

Topics

#python #sandbox #ffi #interpreter

Documentation

API reference

License

MIT (license)

Dependencies

dart_monty_platform_interface, ffi

More

Packages that depend on dart_monty_ffi