Ver Fonte

support multiline define for pre-compiler

pikastech há 3 anos atrás
pai
commit
c5ccb1bf4f

+ 0 - 1
package/PikaStdLib/PikaDebug.pyi

@@ -4,4 +4,3 @@ class Debuger:
 
     def set_trace(self):
         pass
-    

+ 2 - 1
port/linux/.vscode/settings.json

@@ -68,5 +68,6 @@
         "pikastddata_string.h": "c",
         "gtesttask_proxytest.h": "c",
         "datastack.h": "c"
-    }
+    },
+    "python.formatting.provider": "autopep8"
 }

+ 10 - 2
port/linux/package/pikascript/PikaCV.pyi

@@ -122,7 +122,11 @@ class Transforms:
     @staticmethod
     def rotateDown(image: Image):
         """Rotate the image """
-    def threshold(image: Image, thre: int, maxval: int, thresholdType: int):
+    def threshold(
+            image: Image,
+            thre: int,
+            maxval: int,
+            thresholdType: int):
         """
         0:THRESH_BINARY 
         1:THRESH_BINARY_INV
@@ -144,7 +148,11 @@ class Transforms:
         TODO:
         1:BILINEAR
         """
-    def adaptiveThreshold(image: Image, maxval: int, subsize: int, c: int, method: int):
+    def adaptiveThreshold(image: Image,
+                          maxval: int,
+                          subsize: int,
+                          c: int,
+                          method: int):
         """
         AdaptiveThreshold
         method

+ 0 - 1
port/linux/package/pikascript/PikaDebug.pyi

@@ -4,4 +4,3 @@ class Debuger:
 
     def set_trace(self):
         pass
-    

+ 1 - 0
tools/pikaCompiler/main.py

@@ -1,5 +1,6 @@
 import PikaStdLib
 import test
+import TemplateDevice
 from pika_cjson import cJSON
 print('hello pikascript!')
 mem = PikaStdLib.MemChecker()

+ 16 - 3
tools/pikaCompiler/src/compiler.rs

@@ -249,12 +249,25 @@ impl Compiler {
         }
 
         let lines: Vec<&str> = file_str.split('\n').collect();
+        let mut last_line = String::from("");
         /* analyse each line */
         for line in lines.iter() {
-            let line = line.replace("\r", "");
+            let mut line = line.replace("\r", "");
             /* replace \t with 4 spaces */
-            let line = line.replace("\t", "    ");
-
+            line = line.replace("\t", "    ");
+            if line.contains("(") && !line.contains(")") {
+                last_line = line.clone();
+                continue;
+            }
+            if last_line != "" {
+                if line.contains(")") {
+                    line = format!("{}{}", last_line, line);
+                    last_line = String::from("");
+                } else {
+                    last_line = format!("{}{}", last_line, line);
+                    continue;
+                }
+            }
             self = match pkg_type {
                 PackageType::CPackageTop | PackageType::CPackageInner => {
                     Compiler::analyse_pyi_line(self, line.to_string(), &file_name, is_top_c_pkg)