blueloveTH 1 yıl önce
ebeveyn
işleme
efc5755d78
2 değiştirilmiş dosya ile 11 ekleme ve 5 silme
  1. 0 1
      include/pocketpy/_generated.h
  2. 11 4
      prebuild.py

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 1
include/pocketpy/_generated.h


+ 11 - 4
prebuild.py

@@ -6,10 +6,17 @@ def generate_python_sources():
         if not file.endswith(".py"):
             continue
         key = file.split(".")[0]
+        const_char_array = []
         with open("python/" + file) as f:
-            value = f.read()
-            const_array = ','.join([str(b) for b in value.encode('utf-8')])
-        sources[key] = '(const char[]){' + const_array + '}'
+            # convert to char array (signed)
+            for c in f.read().encode('utf-8'):
+                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
 // generated by prebuild.py
@@ -18,7 +25,7 @@ def generate_python_sources():
 #include <string>
 
 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():
         header += f'        {{ "{key}", {value} }},\n'

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor