From ef3868c8964260b9243010839ddaf42b70b9262d Mon Sep 17 00:00:00 2001 From: lyon Date: Tue, 10 May 2022 22:36:25 +0800 Subject: [PATCH] fix filter for binder --- port/linux/package/pikascript/main.py | 2 +- tools/pikaCompiler/src/compiler.rs | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/port/linux/package/pikascript/main.py b/port/linux/package/pikascript/main.py index c78a19df2..663550abb 100644 --- a/port/linux/package/pikascript/main.py +++ b/port/linux/package/pikascript/main.py @@ -4,7 +4,7 @@ import ctypes import GTestTask import PikaMath import PikaStdDevice -# import test_module1 +import test_module1 diff --git a/tools/pikaCompiler/src/compiler.rs b/tools/pikaCompiler/src/compiler.rs index f0ce3a3c4..0f8ddab5c 100644 --- a/tools/pikaCompiler/src/compiler.rs +++ b/tools/pikaCompiler/src/compiler.rs @@ -52,9 +52,34 @@ impl Compiler { if package_name == "PikaObj" { return compiler; } + /* add to script */ + class_now.script_list.add(&line); + + /* check file, break if *.py no found */ + match Compiler::open_file(format!("{}{}.pyi", compiler.source_path, package_name)) { + Ok(_) => {} + Err(_) => { + /* if *.py exits, not print warning */ + match Compiler::open_file(format!( + "{}{}.py", + compiler.source_path, package_name + )) { + Ok(_) => { + return compiler; + } + Err(_) => { + println!( + " [warning]: file: '{}{}.pyi' or '{}{}.py' no found", + compiler.source_path, file_name, compiler.source_path, file_name + ); + return compiler; + } + }; + } + }; + let package_obj_define = format!("{} = {}()", package_name, package_name); class_now.push_object(package_obj_define, &file_name); - class_now.script_list.add(&line); return Compiler::__do_analize_file(compiler, package_name.to_string(), true); } class_now.script_list.add(&line);