fix pyi fn()->None return type

This commit is contained in:
lyon1998 2024-08-02 02:25:38 +08:00
parent c2a3c4cd4e
commit 4b2787903c
7 changed files with 31 additions and 16 deletions

View File

@ -23,9 +23,8 @@ int _random_randrange(PikaObj* self, int start, int stop, int step) {
return start + r * step;
}
PikaObj* _random_seed(PikaObj* self, int a) {
void _random_seed(PikaObj* self, int a) {
srand(a);
return NULL;
}
pika_float _random_uniform(PikaObj* self, pika_float a, pika_float b) {

View File

@ -305,7 +305,7 @@ int _requests_Response_request_init(PikaObj* self, char* method) {
return 1;
}
PikaObj* _requests_Response_request_del(PikaObj* self) {
void _requests_Response_request_del(PikaObj* self) {
struct webclient_session* session;
session = (struct webclient_session*)obj_getPtr(self, "session_address");
if (session) {
@ -313,7 +313,6 @@ PikaObj* _requests_Response_request_del(PikaObj* self) {
RQ_debug("Response free session memory.");
}
RQ_debug("Response set variables None.");
return NULL;
}
void _requests_Response___del__(PikaObj* self) {

View File

@ -23,9 +23,8 @@ int _random_randrange(PikaObj* self, int start, int stop, int step) {
return start + r * step;
}
PikaObj* _random_seed(PikaObj* self, int a) {
void _random_seed(PikaObj* self, int a) {
srand(a);
return NULL;
}
pika_float _random_uniform(PikaObj* self, pika_float a, pika_float b) {

View File

@ -305,7 +305,7 @@ int _requests_Response_request_init(PikaObj* self, char* method) {
return 1;
}
PikaObj* _requests_Response_request_del(PikaObj* self) {
void _requests_Response_request_del(PikaObj* self) {
struct webclient_session* session;
session = (struct webclient_session*)obj_getPtr(self, "session_address");
if (session) {
@ -313,7 +313,6 @@ PikaObj* _requests_Response_request_del(PikaObj* self) {
RQ_debug("Response free session memory.");
}
RQ_debug("Response set variables None.");
return NULL;
}
void _requests_Response___del__(PikaObj* self) {

View File

@ -93,7 +93,8 @@ impl MethodInfo {
format!(
" {}({}_{}, {}),\n",
class_define_method, self.class_name, self.name, self.name_hash
).replace(".", "_")
)
.replace(".", "_")
.as_str(),
);
@ -113,7 +114,8 @@ impl MethodInfo {
return format!(
"void {}_{}Method(PikaObj *self, Args *_args_)",
self.class_name, self.name
).replace(".", "_");
)
.replace(".", "_");
}
pub fn method_impl_declear(&self) -> String {
let return_type_in_c = match self.return_type.as_ref() {
@ -127,7 +129,8 @@ impl MethodInfo {
return format!(
"{} {}_{}(PikaObj *self{});\n",
return_type_in_c, self.class_name, self.name, arg_list_in_c,
).replace(".", "_");
)
.replace(".", "_");
}
pub fn method_fn_impl(&self) -> String {
let mut method_fn_impl = "".to_string();
@ -141,7 +144,13 @@ impl MethodInfo {
None => "".to_string(),
};
let return_type_in_c = match &self.return_type {
Some(x) => format!("{} res = ", x.to_c_type_return()),
Some(x) => {
if x.to_c_type_return() == "void" {
"".to_string()
} else {
format!("{} res = ", x.to_c_type_return())
}
}
None => "".to_string(),
};
let call_arg_list = match &self.arg_list {
@ -178,7 +187,8 @@ impl MethodInfo {
self.name,
self.name,
self.get_arg_list_define(),
).replace(".", "_");
)
.replace(".", "_");
method_fn_impl.push_str(&typedef);
return method_fn_impl;
}

View File

@ -8,7 +8,7 @@ impl PyType {
if self.type_name == "int" {
return "int".to_string();
}
if self.type_name == "int64"{
if self.type_name == "int64" {
return "int64_t".to_string();
}
if self.type_name == "float" {
@ -26,10 +26,13 @@ impl PyType {
if self.type_name == "" {
return "void".to_string();
}
if self.type_name == "None" {
return "void".to_string();
}
if self.type_name == "any" {
return "Arg*".to_string();
}
if self.type_name == "bool"{
if self.type_name == "bool" {
return "pika_bool".to_string();
}
if self.type_name == "@tupleVarPar" {
@ -66,6 +69,9 @@ impl PyType {
if self.type_name == "" {
return "void".to_string();
}
if self.type_name == "None" {
return "void".to_string();
}
if self.type_name == "any" {
return "Arg*".to_string();
}
@ -105,6 +111,9 @@ impl PyType {
if self.type_name == "any" {
return " method_returnArg(_args_, res);\n".to_string();
}
if self.type_name == "None" {
return "".to_string();
}
return " method_returnObj(_args_, res);\n".to_string();
}
// pub fn set_fn(&self) -> String {
@ -132,7 +141,7 @@ impl PyType {
if self.type_name == "int64" {
return "args_getInt".to_string();
}
if self.type_name == "bool"{
if self.type_name == "bool" {
return "args_getBool".to_string();
}
if self.type_name == "float" {