mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
some fix
This commit is contained in:
parent
c60fdd29ab
commit
efc5755d78
File diff suppressed because one or more lines are too long
15
prebuild.py
15
prebuild.py
@ -6,10 +6,17 @@ def generate_python_sources():
|
|||||||
if not file.endswith(".py"):
|
if not file.endswith(".py"):
|
||||||
continue
|
continue
|
||||||
key = file.split(".")[0]
|
key = file.split(".")[0]
|
||||||
|
const_char_array = []
|
||||||
with open("python/" + file) as f:
|
with open("python/" + file) as f:
|
||||||
value = f.read()
|
# convert to char array (signed)
|
||||||
const_array = ','.join([str(b) for b in value.encode('utf-8')])
|
for c in f.read().encode('utf-8'):
|
||||||
sources[key] = '(const char[]){' + const_array + '}'
|
if c < 128:
|
||||||
|
const_char_array.append(str(c))
|
||||||
|
else:
|
||||||
|
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 + '}'
|
||||||
|
|
||||||
header = '''#pragma once
|
header = '''#pragma once
|
||||||
// generated by prebuild.py
|
// generated by prebuild.py
|
||||||
@ -18,7 +25,7 @@ def generate_python_sources():
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace pkpy{
|
namespace pkpy{
|
||||||
inline const std::map<std::string, const char*> kPythonLibs = {
|
inline std::map<std::string, const char*> kPythonLibs = {
|
||||||
'''
|
'''
|
||||||
for key, value in sources.items():
|
for key, value in sources.items():
|
||||||
header += f' {{ "{key}", {value} }},\n'
|
header += f' {{ "{key}", {value} }},\n'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user