add interfaces

This commit is contained in:
blueloveTH 2026-07-22 13:11:45 +08:00
parent beb1557d00
commit 048df25e6f
2 changed files with 28 additions and 0 deletions

View File

@ -8,6 +8,9 @@
#include "pocketpy/export.h"
#include "pocketpy/vmath.h"
// for sandbox branch
#include "pocketpy/sandbox.h"
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -0,0 +1,25 @@
#pragma once
#include "pocketpy/export.h"
#include <stdbool.h>
// Fine-grained capabilities of the VM for sandboxing.
typedef struct py_Capabilities {
// FileIO
bool (*file_open)(const char* path, const char* mode);
// os
bool (*os_chdir)(const char* path);
bool (*os_getcwd)();
bool (*os_system)(const char* command);
bool (*os_remove)(const char* path);
// stdc
bool stdc_write; // memset, write_bytes, ...
bool stdc_read; // memcmp, read_bytes, ...
bool stdc_malloc; // malloc
bool stdc_free; // free
} py_Capabilities;
/// Setup the capabilities for the current VM.
PK_API py_Capabilities* py_capabilities();
/// Raise a `KeyboardInterrupt` to interrupt the current execution.
PK_API void py_interrupt();