mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-02-05 17:28:23 +08:00
fix pyi fn()->None
return type
This commit is contained in:
parent
c2a3c4cd4e
commit
4b2787903c
@ -23,9 +23,8 @@ int _random_randrange(PikaObj* self, int start, int stop, int step) {
|
|||||||
return start + r * step;
|
return start + r * step;
|
||||||
}
|
}
|
||||||
|
|
||||||
PikaObj* _random_seed(PikaObj* self, int a) {
|
void _random_seed(PikaObj* self, int a) {
|
||||||
srand(a);
|
srand(a);
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pika_float _random_uniform(PikaObj* self, pika_float a, pika_float b) {
|
pika_float _random_uniform(PikaObj* self, pika_float a, pika_float b) {
|
||||||
|
@ -305,7 +305,7 @@ int _requests_Response_request_init(PikaObj* self, char* method) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
PikaObj* _requests_Response_request_del(PikaObj* self) {
|
void _requests_Response_request_del(PikaObj* self) {
|
||||||
struct webclient_session* session;
|
struct webclient_session* session;
|
||||||
session = (struct webclient_session*)obj_getPtr(self, "session_address");
|
session = (struct webclient_session*)obj_getPtr(self, "session_address");
|
||||||
if (session) {
|
if (session) {
|
||||||
@ -313,7 +313,6 @@ PikaObj* _requests_Response_request_del(PikaObj* self) {
|
|||||||
RQ_debug("Response free session memory.");
|
RQ_debug("Response free session memory.");
|
||||||
}
|
}
|
||||||
RQ_debug("Response set variables None.");
|
RQ_debug("Response set variables None.");
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _requests_Response___del__(PikaObj* self) {
|
void _requests_Response___del__(PikaObj* self) {
|
||||||
|
@ -23,9 +23,8 @@ int _random_randrange(PikaObj* self, int start, int stop, int step) {
|
|||||||
return start + r * step;
|
return start + r * step;
|
||||||
}
|
}
|
||||||
|
|
||||||
PikaObj* _random_seed(PikaObj* self, int a) {
|
void _random_seed(PikaObj* self, int a) {
|
||||||
srand(a);
|
srand(a);
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pika_float _random_uniform(PikaObj* self, pika_float a, pika_float b) {
|
pika_float _random_uniform(PikaObj* self, pika_float a, pika_float b) {
|
||||||
|
@ -305,7 +305,7 @@ int _requests_Response_request_init(PikaObj* self, char* method) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
PikaObj* _requests_Response_request_del(PikaObj* self) {
|
void _requests_Response_request_del(PikaObj* self) {
|
||||||
struct webclient_session* session;
|
struct webclient_session* session;
|
||||||
session = (struct webclient_session*)obj_getPtr(self, "session_address");
|
session = (struct webclient_session*)obj_getPtr(self, "session_address");
|
||||||
if (session) {
|
if (session) {
|
||||||
@ -313,7 +313,6 @@ PikaObj* _requests_Response_request_del(PikaObj* self) {
|
|||||||
RQ_debug("Response free session memory.");
|
RQ_debug("Response free session memory.");
|
||||||
}
|
}
|
||||||
RQ_debug("Response set variables None.");
|
RQ_debug("Response set variables None.");
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _requests_Response___del__(PikaObj* self) {
|
void _requests_Response___del__(PikaObj* self) {
|
||||||
|
Binary file not shown.
@ -93,7 +93,8 @@ impl MethodInfo {
|
|||||||
format!(
|
format!(
|
||||||
" {}({}_{}, {}),\n",
|
" {}({}_{}, {}),\n",
|
||||||
class_define_method, self.class_name, self.name, self.name_hash
|
class_define_method, self.class_name, self.name, self.name_hash
|
||||||
).replace(".", "_")
|
)
|
||||||
|
.replace(".", "_")
|
||||||
.as_str(),
|
.as_str(),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -113,7 +114,8 @@ impl MethodInfo {
|
|||||||
return format!(
|
return format!(
|
||||||
"void {}_{}Method(PikaObj *self, Args *_args_)",
|
"void {}_{}Method(PikaObj *self, Args *_args_)",
|
||||||
self.class_name, self.name
|
self.class_name, self.name
|
||||||
).replace(".", "_");
|
)
|
||||||
|
.replace(".", "_");
|
||||||
}
|
}
|
||||||
pub fn method_impl_declear(&self) -> String {
|
pub fn method_impl_declear(&self) -> String {
|
||||||
let return_type_in_c = match self.return_type.as_ref() {
|
let return_type_in_c = match self.return_type.as_ref() {
|
||||||
@ -127,7 +129,8 @@ impl MethodInfo {
|
|||||||
return format!(
|
return format!(
|
||||||
"{} {}_{}(PikaObj *self{});\n",
|
"{} {}_{}(PikaObj *self{});\n",
|
||||||
return_type_in_c, self.class_name, self.name, arg_list_in_c,
|
return_type_in_c, self.class_name, self.name, arg_list_in_c,
|
||||||
).replace(".", "_");
|
)
|
||||||
|
.replace(".", "_");
|
||||||
}
|
}
|
||||||
pub fn method_fn_impl(&self) -> String {
|
pub fn method_fn_impl(&self) -> String {
|
||||||
let mut method_fn_impl = "".to_string();
|
let mut method_fn_impl = "".to_string();
|
||||||
@ -141,7 +144,13 @@ impl MethodInfo {
|
|||||||
None => "".to_string(),
|
None => "".to_string(),
|
||||||
};
|
};
|
||||||
let return_type_in_c = match &self.return_type {
|
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(),
|
None => "".to_string(),
|
||||||
};
|
};
|
||||||
let call_arg_list = match &self.arg_list {
|
let call_arg_list = match &self.arg_list {
|
||||||
@ -178,7 +187,8 @@ impl MethodInfo {
|
|||||||
self.name,
|
self.name,
|
||||||
self.name,
|
self.name,
|
||||||
self.get_arg_list_define(),
|
self.get_arg_list_define(),
|
||||||
).replace(".", "_");
|
)
|
||||||
|
.replace(".", "_");
|
||||||
method_fn_impl.push_str(&typedef);
|
method_fn_impl.push_str(&typedef);
|
||||||
return method_fn_impl;
|
return method_fn_impl;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ impl PyType {
|
|||||||
if self.type_name == "int" {
|
if self.type_name == "int" {
|
||||||
return "int".to_string();
|
return "int".to_string();
|
||||||
}
|
}
|
||||||
if self.type_name == "int64"{
|
if self.type_name == "int64" {
|
||||||
return "int64_t".to_string();
|
return "int64_t".to_string();
|
||||||
}
|
}
|
||||||
if self.type_name == "float" {
|
if self.type_name == "float" {
|
||||||
@ -26,10 +26,13 @@ impl PyType {
|
|||||||
if self.type_name == "" {
|
if self.type_name == "" {
|
||||||
return "void".to_string();
|
return "void".to_string();
|
||||||
}
|
}
|
||||||
|
if self.type_name == "None" {
|
||||||
|
return "void".to_string();
|
||||||
|
}
|
||||||
if self.type_name == "any" {
|
if self.type_name == "any" {
|
||||||
return "Arg*".to_string();
|
return "Arg*".to_string();
|
||||||
}
|
}
|
||||||
if self.type_name == "bool"{
|
if self.type_name == "bool" {
|
||||||
return "pika_bool".to_string();
|
return "pika_bool".to_string();
|
||||||
}
|
}
|
||||||
if self.type_name == "@tupleVarPar" {
|
if self.type_name == "@tupleVarPar" {
|
||||||
@ -66,6 +69,9 @@ impl PyType {
|
|||||||
if self.type_name == "" {
|
if self.type_name == "" {
|
||||||
return "void".to_string();
|
return "void".to_string();
|
||||||
}
|
}
|
||||||
|
if self.type_name == "None" {
|
||||||
|
return "void".to_string();
|
||||||
|
}
|
||||||
if self.type_name == "any" {
|
if self.type_name == "any" {
|
||||||
return "Arg*".to_string();
|
return "Arg*".to_string();
|
||||||
}
|
}
|
||||||
@ -105,6 +111,9 @@ impl PyType {
|
|||||||
if self.type_name == "any" {
|
if self.type_name == "any" {
|
||||||
return " method_returnArg(_args_, res);\n".to_string();
|
return " method_returnArg(_args_, res);\n".to_string();
|
||||||
}
|
}
|
||||||
|
if self.type_name == "None" {
|
||||||
|
return "".to_string();
|
||||||
|
}
|
||||||
return " method_returnObj(_args_, res);\n".to_string();
|
return " method_returnObj(_args_, res);\n".to_string();
|
||||||
}
|
}
|
||||||
// pub fn set_fn(&self) -> String {
|
// pub fn set_fn(&self) -> String {
|
||||||
@ -132,7 +141,7 @@ impl PyType {
|
|||||||
if self.type_name == "int64" {
|
if self.type_name == "int64" {
|
||||||
return "args_getInt".to_string();
|
return "args_getInt".to_string();
|
||||||
}
|
}
|
||||||
if self.type_name == "bool"{
|
if self.type_name == "bool" {
|
||||||
return "args_getBool".to_string();
|
return "args_getBool".to_string();
|
||||||
}
|
}
|
||||||
if self.type_name == "float" {
|
if self.type_name == "float" {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user