mirror of
https://github.com/pocketpy/pocketpy
synced 2026-08-05 13:47:11 +08:00
add interfaces
This commit is contained in:
parent
beb1557d00
commit
048df25e6f
@ -8,6 +8,9 @@
|
|||||||
#include "pocketpy/export.h"
|
#include "pocketpy/export.h"
|
||||||
#include "pocketpy/vmath.h"
|
#include "pocketpy/vmath.h"
|
||||||
|
|
||||||
|
// for sandbox branch
|
||||||
|
#include "pocketpy/sandbox.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
25
include/pocketpy/sandbox.h
Normal file
25
include/pocketpy/sandbox.h
Normal 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();
|
||||||
Loading…
x
Reference in New Issue
Block a user