mirror of
https://github.com/pocketpy/pocketpy
synced 2026-03-22 05:00:17 +00:00
Improve comments in main.c
This commit is contained in:
parent
cf70668a2f
commit
7a5519b7a0
13
src2/main.c
13
src2/main.c
@ -9,6 +9,15 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*PocketPy Command Line Interface
|
||||||
|
|
||||||
|
-command line arguments: profile, debug, compile
|
||||||
|
-Initialize pocketpy runtime
|
||||||
|
-Runs either the REPL (Python interactive shell) or a Python file(.py/.pyc)
|
||||||
|
-Handles errors and debugging
|
||||||
|
-Finalises pocketpy runtime before exiting
|
||||||
|
*/
|
||||||
|
|
||||||
static char* readfile(const char* path, int* data_size) {
|
static char* readfile(const char* path, int* data_size) {
|
||||||
FILE* f = fopen(path, "rb");
|
FILE* f = fopen(path, "rb");
|
||||||
if(f == NULL) return NULL;
|
if(f == NULL) return NULL;
|
||||||
@ -71,6 +80,8 @@ int main(int argc, char** argv) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initializes the pocketpy runtime and creates the default VM instance.
|
||||||
|
// Must be called before executing any Python code.
|
||||||
py_initialize();
|
py_initialize();
|
||||||
py_sys_setargv(argc, argv);
|
py_sys_setargv(argc, argv);
|
||||||
|
|
||||||
@ -155,6 +166,8 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int code = py_checkexc() ? 1 : 0;
|
int code = py_checkexc() ? 1 : 0;
|
||||||
|
// Cleans up the pocketpy runtime and frees all allocated resources.
|
||||||
|
// Should be called before program exit to avoid memory leaks.
|
||||||
py_finalize();
|
py_finalize();
|
||||||
|
|
||||||
if(debug) py_debugger_exit(code);
|
if(debug) py_debugger_exit(code);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user