mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
some fix
This commit is contained in:
parent
efc5755d78
commit
dc20c56391
File diff suppressed because one or more lines are too long
@ -2,7 +2,6 @@
|
||||
|
||||
#include "common.h"
|
||||
#include "vm.h"
|
||||
#include "_generated.h"
|
||||
|
||||
namespace pkpy {
|
||||
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include "config.h"
|
||||
#include "export.h"
|
||||
|
||||
#include "_generated.h"
|
||||
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
|
13
prebuild.py
13
prebuild.py
@ -16,23 +16,16 @@ def generate_python_sources():
|
||||
const_char_array.append(str(c - 256))
|
||||
const_char_array.append('0')
|
||||
const_char_array = ','.join(const_char_array)
|
||||
sources[key] = '(const char[]){' + const_char_array + '}'
|
||||
sources[key] = '{' + const_char_array + '}'
|
||||
|
||||
header = '''#pragma once
|
||||
// generated by prebuild.py
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace pkpy{
|
||||
inline std::map<std::string, const char*> kPythonLibs = {
|
||||
'''
|
||||
for key, value in sources.items():
|
||||
header += f' {{ "{key}", {value} }},\n'
|
||||
|
||||
header += ''' };
|
||||
} // namespace pkpy
|
||||
'''
|
||||
header += f' inline const char kPythonLibs_{key}[] = {value};\n'
|
||||
header += '}\n'
|
||||
return header
|
||||
|
||||
# use LF line endings instead of CRLF
|
||||
|
@ -552,7 +552,7 @@ namespace pkpy
|
||||
PyObject *mod = vm->new_module("collections");
|
||||
PyDeque::register_class(vm, mod);
|
||||
PyDequeIter::register_class(vm, mod);
|
||||
CodeObject_ code = vm->compile(kPythonLibs["collections"], "collections.py", EXEC_MODE);
|
||||
CodeObject_ code = vm->compile(kPythonLibs_collections, "collections.py", EXEC_MODE);
|
||||
vm->_exec(code, mod);
|
||||
}
|
||||
} // namespace pkpypkpy
|
||||
|
@ -1534,14 +1534,21 @@ void VM::post_init(){
|
||||
add_module_base64(this);
|
||||
add_module_operator(this);
|
||||
|
||||
for(const char* name: {"this", "functools", "heapq", "bisect", "pickle", "_long", "colorsys", "typing", "datetime", "cmath"}){
|
||||
_lazy_modules[name] = kPythonLibs[name];
|
||||
}
|
||||
_lazy_modules["this"] = kPythonLibs_this;
|
||||
_lazy_modules["functools"] = kPythonLibs_functools;
|
||||
_lazy_modules["heapq"] = kPythonLibs_heapq;
|
||||
_lazy_modules["bisect"] = kPythonLibs_bisect;
|
||||
_lazy_modules["pickle"] = kPythonLibs_pickle;
|
||||
_lazy_modules["_long"] = kPythonLibs__long;
|
||||
_lazy_modules["colorsys"] = kPythonLibs_colorsys;
|
||||
_lazy_modules["typing"] = kPythonLibs_typing;
|
||||
_lazy_modules["datetime"] = kPythonLibs_datetime;
|
||||
_lazy_modules["cmath"] = kPythonLibs_cmath;
|
||||
|
||||
try{
|
||||
CodeObject_ code = compile(kPythonLibs["builtins"], "<builtins>", EXEC_MODE);
|
||||
CodeObject_ code = compile(kPythonLibs_builtins, "<builtins>", EXEC_MODE);
|
||||
this->_exec(code, this->builtins);
|
||||
code = compile(kPythonLibs["_set"], "<set>", EXEC_MODE);
|
||||
code = compile(kPythonLibs__set, "<set>", EXEC_MODE);
|
||||
this->_exec(code, this->builtins);
|
||||
}catch(const Exception& e){
|
||||
std::cerr << e.summary() << std::endl;
|
||||
|
Loading…
x
Reference in New Issue
Block a user