mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
fix warnings for rust-msc
This commit is contained in:
parent
562550dce0
commit
e5d07cf0ce
@ -17,8 +17,8 @@ pub struct ClassInfo {
|
||||
}
|
||||
|
||||
impl ClassInfo {
|
||||
pub fn add_file_profix(file_name: &String, class_name: &String, isPackage: bool) -> String {
|
||||
if isPackage {
|
||||
pub fn add_file_profix(file_name: &String, class_name: &String, is_package: bool) -> String {
|
||||
if is_package {
|
||||
return class_name.clone();
|
||||
}
|
||||
if file_name == "main" {
|
||||
@ -39,7 +39,7 @@ impl ClassInfo {
|
||||
};
|
||||
let super_class_name = match super_class_name.find(".") {
|
||||
None => ClassInfo::add_file_profix(&file_name, &super_class_name, is_package),
|
||||
Some(x) => super_class_name.replace(".", "_"),
|
||||
Some(_x) => super_class_name.replace(".", "_"),
|
||||
};
|
||||
let mut this_calss_name = match my_string::get_first_token(&define, '(') {
|
||||
Some(s) => s,
|
||||
@ -73,15 +73,15 @@ impl ClassInfo {
|
||||
pub fn push_constructor(&mut self, method_define: String) {
|
||||
return self.push_method_with_is_constructor(method_define, true);
|
||||
}
|
||||
pub fn push_import(&mut self, import_define: String, file_name: &String) {
|
||||
let import_info = match ImportInfo::new(&self.this_class_name, import_define, &file_name) {
|
||||
Some(import) => import,
|
||||
None => return,
|
||||
};
|
||||
self.import_list
|
||||
.entry(import_info.import_class_name.clone())
|
||||
.or_insert(import_info);
|
||||
}
|
||||
// pub fn push_import(&mut self, import_define: String, file_name: &String) {
|
||||
// let import_info = match ImportInfo::new(&self.this_class_name, import_define, &file_name) {
|
||||
// Some(import) => import,
|
||||
// None => return,
|
||||
// };
|
||||
// self.import_list
|
||||
// .entry(import_info.import_class_name.clone())
|
||||
// .or_insert(import_info);
|
||||
// }
|
||||
pub fn push_object(&mut self, object_define: String, file_name: &String) {
|
||||
let object_info = match ObjectInfo::new(&self.this_class_name, object_define, &file_name) {
|
||||
Some(object) => object,
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::class_info::ClassInfo;
|
||||
use crate::my_string;
|
||||
use crate::script::Script;
|
||||
// use crate::script::Script;
|
||||
use std::collections::BTreeMap;
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::class_info;
|
||||
use crate::my_string;
|
||||
// use crate::class_info;
|
||||
// use crate::my_string;
|
||||
#[derive(Debug)]
|
||||
pub struct ImportInfo {
|
||||
pub class_name: String,
|
||||
@ -7,26 +7,26 @@ pub struct ImportInfo {
|
||||
}
|
||||
|
||||
impl ImportInfo {
|
||||
pub fn new(
|
||||
class_name: &String,
|
||||
input_define: String,
|
||||
file_name: &String,
|
||||
) -> Option<ImportInfo> {
|
||||
let define = input_define.replace(" ", "");
|
||||
let mut import_class_name = match my_string::get_first_token(&define, '(') {
|
||||
Some(token) => token,
|
||||
None => return None,
|
||||
};
|
||||
import_class_name = match import_class_name.find(".") {
|
||||
None => class_info::ClassInfo::add_file_profix(&file_name, &import_class_name, false),
|
||||
Some(x) => import_class_name.replace(".", "_"),
|
||||
};
|
||||
import_class_name = import_class_name.replace(".", "_");
|
||||
return Some(ImportInfo {
|
||||
class_name: class_name.clone(),
|
||||
import_class_name: import_class_name,
|
||||
});
|
||||
}
|
||||
// pub fn new(
|
||||
// class_name: &String,
|
||||
// input_define: String,
|
||||
// file_name: &String,
|
||||
// ) -> Option<ImportInfo> {
|
||||
// let define = input_define.replace(" ", "");
|
||||
// let mut import_class_name = match my_string::get_first_token(&define, '(') {
|
||||
// Some(token) => token,
|
||||
// None => return None,
|
||||
// };
|
||||
// import_class_name = match import_class_name.find(".") {
|
||||
// None => class_info::ClassInfo::add_file_profix(&file_name, &import_class_name, false),
|
||||
// Some(_x) => import_class_name.replace(".", "_"),
|
||||
// };
|
||||
// import_class_name = import_class_name.replace(".", "_");
|
||||
// return Some(ImportInfo {
|
||||
// class_name: class_name.clone(),
|
||||
// import_class_name: import_class_name,
|
||||
// });
|
||||
// }
|
||||
pub fn import_fn(&self) -> String {
|
||||
return format!(
|
||||
" obj_import(self, \"{}\", New_{});\n",
|
||||
|
@ -24,7 +24,7 @@ impl ObjectInfo {
|
||||
};
|
||||
import_class_name = match import_class_name.find(".") {
|
||||
None => class_info::ClassInfo::add_file_profix(&file_name, &import_class_name, false),
|
||||
Some(x) => import_class_name.replace(".", "_"),
|
||||
Some(_x) => import_class_name.replace(".", "_"),
|
||||
};
|
||||
return Some(ObjectInfo {
|
||||
class_name: class_name.clone(),
|
||||
|
@ -51,24 +51,24 @@ impl PyType {
|
||||
}
|
||||
return "method_returnPtr".to_string();
|
||||
}
|
||||
pub fn set_fn(&self) -> String {
|
||||
if self.type_name == "int" {
|
||||
return "args_setInt".to_string();
|
||||
}
|
||||
if self.type_name == "float" {
|
||||
return "args_setFloat".to_string();
|
||||
}
|
||||
if self.type_name == "pointer" {
|
||||
return "args_setPtr".to_string();
|
||||
}
|
||||
if self.type_name == "str" {
|
||||
return "args_setStr".to_string();
|
||||
}
|
||||
if self.type_name == "any" {
|
||||
return "args_setArg".to_string();
|
||||
}
|
||||
return "args_setPtr".to_string();
|
||||
}
|
||||
// pub fn set_fn(&self) -> String {
|
||||
// if self.type_name == "int" {
|
||||
// return "args_setInt".to_string();
|
||||
// }
|
||||
// if self.type_name == "float" {
|
||||
// return "args_setFloat".to_string();
|
||||
// }
|
||||
// if self.type_name == "pointer" {
|
||||
// return "args_setPtr".to_string();
|
||||
// }
|
||||
// if self.type_name == "str" {
|
||||
// return "args_setStr".to_string();
|
||||
// }
|
||||
// if self.type_name == "any" {
|
||||
// return "args_setArg".to_string();
|
||||
// }
|
||||
// return "args_setPtr".to_string();
|
||||
// }
|
||||
pub fn get_fn(&self) -> String {
|
||||
if self.type_name == "int" {
|
||||
return "args_getInt".to_string();
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::class_info::ClassInfo;
|
||||
use crate::my_string;
|
||||
// use crate::class_info::ClassInfo;
|
||||
// use crate::my_string;
|
||||
#[derive(Debug)]
|
||||
pub struct Script {
|
||||
pub content: String,
|
||||
@ -14,21 +14,21 @@ impl Script {
|
||||
pub fn add(&mut self, content: &String) {
|
||||
self.content.push_str(&Script::obj_run(content));
|
||||
}
|
||||
pub fn assert(class_info: &ClassInfo, content: &String) -> bool {
|
||||
let cmd = my_string::cut(content, '=', '(').unwrap();
|
||||
let cmd = cmd.replace(" ", "");
|
||||
let called_first_object = match my_string::get_first_token(&cmd, '.') {
|
||||
Some(token) => token,
|
||||
None => cmd,
|
||||
};
|
||||
for (_, obj_info) in class_info.object_list.iter() {
|
||||
let obj_name = obj_info.name.clone();
|
||||
if called_first_object == obj_name {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// pub fn assert(class_info: &ClassInfo, content: &String) -> bool {
|
||||
// let cmd = my_string::cut(content, '=', '(').unwrap();
|
||||
// let cmd = cmd.replace(" ", "");
|
||||
// let called_first_object = match my_string::get_first_token(&cmd, '.') {
|
||||
// Some(token) => token,
|
||||
// None => cmd,
|
||||
// };
|
||||
// for (_, obj_info) in class_info.object_list.iter() {
|
||||
// let obj_name = obj_info.name.clone();
|
||||
// if called_first_object == obj_name {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
pub fn obj_run(cmd: &String) -> String {
|
||||
return format!("@BEGIN@{}@END@", cmd);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user