mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
This commit is contained in:
parent
351fd6ba62
commit
5c82ce92fe
@ -117,8 +117,8 @@ impl ClassInfo {
|
||||
|
||||
pub fn include(&self) -> String {
|
||||
let mut include = String::new();
|
||||
include.push_str(&format!("#include \"{}.h\"\n", self.this_class_name));
|
||||
include.push_str(&format!("#include \"{}.h\"\n", self.super_class_name));
|
||||
include.push_str(&format!("#include \"{}.h\"\n", self.this_class_name.replace(".", "_")));
|
||||
include.push_str(&format!("#include \"{}.h\"\n", self.super_class_name.replace(".", "_")));
|
||||
for (_, import_info) in self.import_list.iter() {
|
||||
include.push_str(&format!(
|
||||
"#include \"{}.h\"\n",
|
||||
@ -139,7 +139,7 @@ impl ClassInfo {
|
||||
for (_, method_info) in self.method_list.iter() {
|
||||
method_impl.push_str(&method_info.method_fn_impl());
|
||||
}
|
||||
return method_impl;
|
||||
return method_impl.replace(".", "_");
|
||||
}
|
||||
|
||||
pub fn script_fn(&self, version_info: VersionInfo) -> String {
|
||||
@ -201,7 +201,7 @@ impl ClassInfo {
|
||||
let mut new_class_fn = String::new();
|
||||
let new_class_fn_head = format!("{}{{\n", self.new_class_fn_name());
|
||||
|
||||
let class_def = format!("class_def({}){{\n", self.this_class_name);
|
||||
let class_def = format!("class_def({}){{\n", self.this_class_name).replace(".", "_");
|
||||
new_class_fn.push_str(&class_def);
|
||||
|
||||
// new_class_fn.push_str("#ifdef _WIN32\n");
|
||||
@ -226,7 +226,7 @@ impl ClassInfo {
|
||||
let class_inhert = format!(
|
||||
"class_inhert({}, {});\n\n",
|
||||
self.this_class_name, self.super_class_name
|
||||
);
|
||||
).replace(".", "_");
|
||||
|
||||
new_class_fn.push_str(&class_inhert);
|
||||
|
||||
@ -238,7 +238,7 @@ impl ClassInfo {
|
||||
new_class_fn.push_str(&object_info.new_object_fn());
|
||||
}
|
||||
|
||||
let obj_set_class = format!(" obj_setClass(self, {});\n", self.this_class_name);
|
||||
let obj_set_class = format!(" obj_setClass(self, {});\n", self.this_class_name).replace(".", "_");
|
||||
new_class_fn.push_str(&obj_set_class);
|
||||
|
||||
new_class_fn.push_str(" return self;\n");
|
||||
@ -247,7 +247,7 @@ impl ClassInfo {
|
||||
}
|
||||
|
||||
pub fn new_class_fn_name(&self) -> String {
|
||||
return format!("PikaObj *New_{}(Args *args)", self.this_class_name);
|
||||
return format!("PikaObj *New_{}(Args *args)", self.this_class_name).replace(".", "_");
|
||||
}
|
||||
|
||||
pub fn method_impl_declear(&self) -> String {
|
||||
|
@ -78,6 +78,7 @@ pub fn pika_compiler_entry() {
|
||||
Some(package_name.clone())
|
||||
}
|
||||
})
|
||||
.map(|name| name.replace(".", "_"))
|
||||
.collect();
|
||||
|
||||
// Add "main" to the start of the module_names
|
||||
@ -116,7 +117,7 @@ pub fn pika_compiler_entry() {
|
||||
|
||||
/* make the -api.c file for each python class */
|
||||
|
||||
let api_file_path = format!("{}__pikaBinding.c", compiler.dist_path);
|
||||
let api_file_path = format!("{}__pikaBinding.c", compiler.dist_path.replace(".", "_"));
|
||||
let mut f = File::create(api_file_path).unwrap();
|
||||
f.write(head_info.as_bytes()).unwrap();
|
||||
/* create include for calsses */
|
||||
@ -160,7 +161,7 @@ pub fn pika_compiler_entry() {
|
||||
/* create module control macro */
|
||||
let module_define = format!(
|
||||
"#ifndef PIKA_MODULE_{}_DISABLE\n",
|
||||
module_name.to_ascii_uppercase()
|
||||
module_name.replace(".", "_").to_ascii_uppercase()
|
||||
);
|
||||
f.write(module_define.as_bytes()).unwrap();
|
||||
/* create method api function */
|
||||
@ -171,9 +172,9 @@ pub fn pika_compiler_entry() {
|
||||
if !class_info.is_package {
|
||||
f.write("\n".as_bytes()).unwrap();
|
||||
let name = String::from(class_info.this_class_name.to_string());
|
||||
f.write(format!("Arg *{}(PikaObj *self){{\n", &name).as_bytes())
|
||||
f.write(format!("Arg *{}(PikaObj *self){{\n", &name).replace(".", "_").as_bytes())
|
||||
.unwrap();
|
||||
f.write(format!(" return obj_newObjInPackage(New_{});\n", &name).as_bytes())
|
||||
f.write(format!(" return obj_newObjInPackage(New_{});\n", &name).replace(".", "_").as_bytes())
|
||||
.unwrap();
|
||||
f.write("}\n".as_bytes()).unwrap();
|
||||
}
|
||||
@ -184,12 +185,12 @@ pub fn pika_compiler_entry() {
|
||||
|
||||
/* make the .h file for each python class */
|
||||
for (_, class_info) in compiler.class_list.iter() {
|
||||
let api_file_path = format!("{}{}.h", compiler.dist_path, class_info.this_class_name);
|
||||
let api_file_path = format!("{}{}.h", compiler.dist_path.replace(".", "_"), class_info.this_class_name.replace(".", "_"));
|
||||
let mut f = File::create(api_file_path).unwrap();
|
||||
f.write(head_info.as_bytes()).unwrap();
|
||||
f.write(format!("#ifndef __{}__H\n", class_info.this_class_name).as_bytes())
|
||||
f.write(format!("#ifndef __{}__H\n", class_info.this_class_name).replace(".", "_").as_bytes())
|
||||
.unwrap();
|
||||
f.write(format!("#define __{}__H\n", class_info.this_class_name).as_bytes())
|
||||
f.write(format!("#define __{}__H\n", class_info.this_class_name).replace(".", "_").as_bytes())
|
||||
.unwrap();
|
||||
f.write("#include <stdio.h>\n".as_bytes()).unwrap();
|
||||
f.write("#include <stdlib.h>\n".as_bytes()).unwrap();
|
||||
@ -205,7 +206,7 @@ pub fn pika_compiler_entry() {
|
||||
drop(f);
|
||||
}
|
||||
/* make the pikascript.c */
|
||||
let api_file_path = format!("{}pikaScript.c", compiler.dist_path);
|
||||
let api_file_path = format!("{}pikaScript.c", compiler.dist_path.replace(".", "_"));
|
||||
let mut f = File::create(api_file_path).unwrap();
|
||||
/* add head */
|
||||
f.write(head_info.as_bytes()).unwrap();
|
||||
@ -225,7 +226,7 @@ pub fn pika_compiler_entry() {
|
||||
drop(f);
|
||||
|
||||
/* make the pikascript.h */
|
||||
let api_file_path = format!("{}pikaScript.h", compiler.dist_path);
|
||||
let api_file_path = format!("{}pikaScript.h", compiler.dist_path.replace(".", "_"));
|
||||
let mut f = File::create(api_file_path).unwrap();
|
||||
f.write("/* ******************************** */\n".as_bytes())
|
||||
.unwrap();
|
||||
|
@ -93,7 +93,7 @@ impl MethodInfo {
|
||||
format!(
|
||||
" {}({}_{}, {}),\n",
|
||||
class_define_method, self.class_name, self.name, self.name_hash
|
||||
)
|
||||
).replace(".", "_")
|
||||
.as_str(),
|
||||
);
|
||||
|
||||
@ -113,7 +113,7 @@ impl MethodInfo {
|
||||
return format!(
|
||||
"void {}_{}Method(PikaObj *self, Args *_args_)",
|
||||
self.class_name, self.name
|
||||
);
|
||||
).replace(".", "_");
|
||||
}
|
||||
pub fn method_impl_declear(&self) -> String {
|
||||
let return_type_in_c = match self.return_type.as_ref() {
|
||||
@ -127,7 +127,7 @@ impl MethodInfo {
|
||||
return format!(
|
||||
"{} {}_{}(PikaObj *self{});\n",
|
||||
return_type_in_c, self.class_name, self.name, arg_list_in_c,
|
||||
);
|
||||
).replace(".", "_");
|
||||
}
|
||||
pub fn method_fn_impl(&self) -> String {
|
||||
let mut method_fn_impl = "".to_string();
|
||||
@ -178,7 +178,7 @@ impl MethodInfo {
|
||||
self.name,
|
||||
self.name,
|
||||
self.get_arg_list_define(),
|
||||
);
|
||||
).replace(".", "_");
|
||||
method_fn_impl.push_str(&typedef);
|
||||
return method_fn_impl;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ impl ObjectInfo {
|
||||
);
|
||||
let module_define = format!(
|
||||
"#ifndef PIKA_MODULE_{}_DISABLE\n",
|
||||
self.import_class_name.to_ascii_uppercase()
|
||||
self.import_class_name.to_ascii_uppercase().replace(".", "_")
|
||||
);
|
||||
new_object_fn.push_str(&module_define);
|
||||
new_object_fn.push_str(&new_fn);
|
||||
|
Loading…
x
Reference in New Issue
Block a user