typegen: fix function and signal parameters being sorted by name
This commit is contained in:
		
							parent
							
								
									c1c349caaa
								
							
						
					
					
						commit
						a036d378c0
					
				
					 3 changed files with 23 additions and 9 deletions
				
			
		| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
{{- $first := true -}}
 | 
					{{- $first := true -}}
 | 
				
			||||||
{{- range $param, $type := . -}}
 | 
					{{- range $param := . -}}
 | 
				
			||||||
	{{- if ne $first true -}}, {{ end -}}
 | 
						{{- if ne $first true -}}, {{ end -}}
 | 
				
			||||||
	{{- $first = false -}}
 | 
						{{- $first = false -}}
 | 
				
			||||||
	{{ $param }}: {{ partial "qmltype.html" $type }}
 | 
						{{ $param.name }}: {{ partial "qmltype.html" $param.type }}
 | 
				
			||||||
{{- end -}}
 | 
					{{- end -}}
 | 
				
			||||||
| 
						 | 
					@ -52,14 +52,21 @@ pub struct Function {
 | 
				
			||||||
	pub name: String,
 | 
						pub name: String,
 | 
				
			||||||
	pub id: String,
 | 
						pub id: String,
 | 
				
			||||||
	pub details: Option<String>,
 | 
						pub details: Option<String>,
 | 
				
			||||||
	pub params: HashMap<String, Type>,
 | 
						pub params: Vec<Parameter>,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[derive(Debug, Serialize)]
 | 
					#[derive(Debug, Serialize)]
 | 
				
			||||||
pub struct Signal {
 | 
					pub struct Signal {
 | 
				
			||||||
	pub name: String,
 | 
						pub name: String,
 | 
				
			||||||
	pub details: Option<String>,
 | 
						pub details: Option<String>,
 | 
				
			||||||
	pub params: HashMap<String, Type>,
 | 
						pub params: Vec<Parameter>,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[derive(Debug, Serialize)]
 | 
				
			||||||
 | 
					pub struct Parameter {
 | 
				
			||||||
 | 
						pub name: String,
 | 
				
			||||||
 | 
						#[serde(rename = "type")]
 | 
				
			||||||
 | 
						pub type_: Type,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[derive(Debug, Serialize)]
 | 
					#[derive(Debug, Serialize)]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
use std::collections::HashMap;
 | 
					use std::collections::HashMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::{
 | 
					use crate::{
 | 
				
			||||||
	outform::{self, Flag, PropertyType},
 | 
						outform::{self, Flag, Parameter, PropertyType},
 | 
				
			||||||
	typespec::{FnParam, Function, Property, Signal, TypeSpec},
 | 
						typespec::{FnParam, Function, Property, Signal, TypeSpec},
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -147,7 +147,8 @@ pub fn resolve_types(
 | 
				
			||||||
				ret: qmlparamtype(&func.ret, typespec),
 | 
									ret: qmlparamtype(&func.ret, typespec),
 | 
				
			||||||
				name: func.name.clone(),
 | 
									name: func.name.clone(),
 | 
				
			||||||
				id: {
 | 
									id: {
 | 
				
			||||||
					let params = func.params
 | 
										let params = func
 | 
				
			||||||
 | 
											.params
 | 
				
			||||||
						.iter()
 | 
											.iter()
 | 
				
			||||||
						.map(|FnParam { type_, .. }| qmlparamtype(type_, typespec).name);
 | 
											.map(|FnParam { type_, .. }| qmlparamtype(type_, typespec).name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -166,7 +167,10 @@ pub fn resolve_types(
 | 
				
			||||||
				params: func
 | 
									params: func
 | 
				
			||||||
					.params
 | 
										.params
 | 
				
			||||||
					.iter()
 | 
										.iter()
 | 
				
			||||||
					.map(|FnParam { type_, name }| (name.clone(), qmlparamtype(type_, typespec)))
 | 
										.map(|FnParam { type_, name }| Parameter {
 | 
				
			||||||
 | 
											name: name.clone(),
 | 
				
			||||||
 | 
											type_: qmlparamtype(type_, typespec),
 | 
				
			||||||
 | 
										})
 | 
				
			||||||
					.collect(),
 | 
										.collect(),
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -178,7 +182,10 @@ pub fn resolve_types(
 | 
				
			||||||
				params: func
 | 
									params: func
 | 
				
			||||||
					.params
 | 
										.params
 | 
				
			||||||
					.iter()
 | 
										.iter()
 | 
				
			||||||
					.map(|FnParam { type_, name }| (name.clone(), qmlparamtype(type_, typespec)))
 | 
										.map(|FnParam { type_, name }| Parameter {
 | 
				
			||||||
 | 
											name: name.clone(),
 | 
				
			||||||
 | 
											type_: qmlparamtype(type_, typespec),
 | 
				
			||||||
 | 
										})
 | 
				
			||||||
					.collect(),
 | 
										.collect(),
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue