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 {
|
impl ClassInfo {
|
||||||
pub fn add_file_profix(file_name: &String, class_name: &String, isPackage: bool) -> String {
|
pub fn add_file_profix(file_name: &String, class_name: &String, is_package: bool) -> String {
|
||||||
if isPackage {
|
if is_package {
|
||||||
return class_name.clone();
|
return class_name.clone();
|
||||||
}
|
}
|
||||||
if file_name == "main" {
|
if file_name == "main" {
|
||||||
@ -39,7 +39,7 @@ impl ClassInfo {
|
|||||||
};
|
};
|
||||||
let super_class_name = match super_class_name.find(".") {
|
let super_class_name = match super_class_name.find(".") {
|
||||||
None => ClassInfo::add_file_profix(&file_name, &super_class_name, is_package),
|
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, '(') {
|
let mut this_calss_name = match my_string::get_first_token(&define, '(') {
|
||||||
Some(s) => s,
|
Some(s) => s,
|
||||||
@ -70,18 +70,18 @@ impl ClassInfo {
|
|||||||
pub fn push_method(&mut self, method_define: String) {
|
pub fn push_method(&mut self, method_define: String) {
|
||||||
return self.push_method_with_is_constructor(method_define, false);
|
return self.push_method_with_is_constructor(method_define, false);
|
||||||
}
|
}
|
||||||
pub fn push_constructor(&mut self, method_define:String){
|
pub fn push_constructor(&mut self, method_define: String) {
|
||||||
return self.push_method_with_is_constructor(method_define, true);
|
return self.push_method_with_is_constructor(method_define, true);
|
||||||
}
|
}
|
||||||
pub fn push_import(&mut self, import_define: String, file_name: &String) {
|
// 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) {
|
// let import_info = match ImportInfo::new(&self.this_class_name, import_define, &file_name) {
|
||||||
Some(import) => import,
|
// Some(import) => import,
|
||||||
None => return,
|
// None => return,
|
||||||
};
|
// };
|
||||||
self.import_list
|
// self.import_list
|
||||||
.entry(import_info.import_class_name.clone())
|
// .entry(import_info.import_class_name.clone())
|
||||||
.or_insert(import_info);
|
// .or_insert(import_info);
|
||||||
}
|
// }
|
||||||
pub fn push_object(&mut self, object_define: String, file_name: &String) {
|
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) {
|
let object_info = match ObjectInfo::new(&self.this_class_name, object_define, &file_name) {
|
||||||
Some(object) => object,
|
Some(object) => object,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::class_info::ClassInfo;
|
use crate::class_info::ClassInfo;
|
||||||
use crate::my_string;
|
use crate::my_string;
|
||||||
use crate::script::Script;
|
// use crate::script::Script;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::class_info;
|
// use crate::class_info;
|
||||||
use crate::my_string;
|
// use crate::my_string;
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ImportInfo {
|
pub struct ImportInfo {
|
||||||
pub class_name: String,
|
pub class_name: String,
|
||||||
@ -7,26 +7,26 @@ pub struct ImportInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ImportInfo {
|
impl ImportInfo {
|
||||||
pub fn new(
|
// pub fn new(
|
||||||
class_name: &String,
|
// class_name: &String,
|
||||||
input_define: String,
|
// input_define: String,
|
||||||
file_name: &String,
|
// file_name: &String,
|
||||||
) -> Option<ImportInfo> {
|
// ) -> Option<ImportInfo> {
|
||||||
let define = input_define.replace(" ", "");
|
// let define = input_define.replace(" ", "");
|
||||||
let mut import_class_name = match my_string::get_first_token(&define, '(') {
|
// let mut import_class_name = match my_string::get_first_token(&define, '(') {
|
||||||
Some(token) => token,
|
// Some(token) => token,
|
||||||
None => return None,
|
// None => return None,
|
||||||
};
|
// };
|
||||||
import_class_name = match import_class_name.find(".") {
|
// import_class_name = match import_class_name.find(".") {
|
||||||
None => class_info::ClassInfo::add_file_profix(&file_name, &import_class_name, false),
|
// 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(".", "_"),
|
||||||
};
|
// };
|
||||||
import_class_name = import_class_name.replace(".", "_");
|
// import_class_name = import_class_name.replace(".", "_");
|
||||||
return Some(ImportInfo {
|
// return Some(ImportInfo {
|
||||||
class_name: class_name.clone(),
|
// class_name: class_name.clone(),
|
||||||
import_class_name: import_class_name,
|
// import_class_name: import_class_name,
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
pub fn import_fn(&self) -> String {
|
pub fn import_fn(&self) -> String {
|
||||||
return format!(
|
return format!(
|
||||||
" obj_import(self, \"{}\", New_{});\n",
|
" obj_import(self, \"{}\", New_{});\n",
|
||||||
|
@ -24,7 +24,7 @@ impl ObjectInfo {
|
|||||||
};
|
};
|
||||||
import_class_name = match import_class_name.find(".") {
|
import_class_name = match import_class_name.find(".") {
|
||||||
None => class_info::ClassInfo::add_file_profix(&file_name, &import_class_name, false),
|
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 {
|
return Some(ObjectInfo {
|
||||||
class_name: class_name.clone(),
|
class_name: class_name.clone(),
|
||||||
|
@ -51,24 +51,24 @@ impl PyType {
|
|||||||
}
|
}
|
||||||
return "method_returnPtr".to_string();
|
return "method_returnPtr".to_string();
|
||||||
}
|
}
|
||||||
pub fn set_fn(&self) -> String {
|
// pub fn set_fn(&self) -> String {
|
||||||
if self.type_name == "int" {
|
// if self.type_name == "int" {
|
||||||
return "args_setInt".to_string();
|
// return "args_setInt".to_string();
|
||||||
}
|
// }
|
||||||
if self.type_name == "float" {
|
// if self.type_name == "float" {
|
||||||
return "args_setFloat".to_string();
|
// return "args_setFloat".to_string();
|
||||||
}
|
// }
|
||||||
if self.type_name == "pointer" {
|
// if self.type_name == "pointer" {
|
||||||
return "args_setPtr".to_string();
|
// return "args_setPtr".to_string();
|
||||||
}
|
// }
|
||||||
if self.type_name == "str" {
|
// if self.type_name == "str" {
|
||||||
return "args_setStr".to_string();
|
// return "args_setStr".to_string();
|
||||||
}
|
// }
|
||||||
if self.type_name == "any" {
|
// if self.type_name == "any" {
|
||||||
return "args_setArg".to_string();
|
// return "args_setArg".to_string();
|
||||||
}
|
// }
|
||||||
return "args_setPtr".to_string();
|
// return "args_setPtr".to_string();
|
||||||
}
|
// }
|
||||||
pub fn get_fn(&self) -> String {
|
pub fn get_fn(&self) -> String {
|
||||||
if self.type_name == "int" {
|
if self.type_name == "int" {
|
||||||
return "args_getInt".to_string();
|
return "args_getInt".to_string();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::class_info::ClassInfo;
|
// use crate::class_info::ClassInfo;
|
||||||
use crate::my_string;
|
// use crate::my_string;
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Script {
|
pub struct Script {
|
||||||
pub content: String,
|
pub content: String,
|
||||||
@ -14,21 +14,21 @@ impl Script {
|
|||||||
pub fn add(&mut self, content: &String) {
|
pub fn add(&mut self, content: &String) {
|
||||||
self.content.push_str(&Script::obj_run(content));
|
self.content.push_str(&Script::obj_run(content));
|
||||||
}
|
}
|
||||||
pub fn assert(class_info: &ClassInfo, content: &String) -> bool {
|
// pub fn assert(class_info: &ClassInfo, content: &String) -> bool {
|
||||||
let cmd = my_string::cut(content, '=', '(').unwrap();
|
// let cmd = my_string::cut(content, '=', '(').unwrap();
|
||||||
let cmd = cmd.replace(" ", "");
|
// let cmd = cmd.replace(" ", "");
|
||||||
let called_first_object = match my_string::get_first_token(&cmd, '.') {
|
// let called_first_object = match my_string::get_first_token(&cmd, '.') {
|
||||||
Some(token) => token,
|
// Some(token) => token,
|
||||||
None => cmd,
|
// None => cmd,
|
||||||
};
|
// };
|
||||||
for (_, obj_info) in class_info.object_list.iter() {
|
// for (_, obj_info) in class_info.object_list.iter() {
|
||||||
let obj_name = obj_info.name.clone();
|
// let obj_name = obj_info.name.clone();
|
||||||
if called_first_object == obj_name {
|
// if called_first_object == obj_name {
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
pub fn obj_run(cmd: &String) -> String {
|
pub fn obj_run(cmd: &String) -> String {
|
||||||
return format!("@BEGIN@{}@END@", cmd);
|
return format!("@BEGIN@{}@END@", cmd);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user