2
1
Fork 0

typegen: fix function and signal parameters being sorted by name

This commit is contained in:
outfoxxed 2024-03-21 02:42:57 -07:00
parent c1c349caaa
commit a036d378c0
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
3 changed files with 23 additions and 9 deletions

View file

@ -1,6 +1,6 @@
{{- $first := true -}}
{{- range $param, $type := . -}}
{{- range $param := . -}}
{{- if ne $first true -}}, {{ end -}}
{{- $first = false -}}
{{ $param }}: {{ partial "qmltype.html" $type }}
{{ $param.name }}: {{ partial "qmltype.html" $param.type }}
{{- end -}}

View file

@ -52,14 +52,21 @@ pub struct Function {
pub name: String,
pub id: String,
pub details: Option<String>,
pub params: HashMap<String, Type>,
pub params: Vec<Parameter>,
}
#[derive(Debug, Serialize)]
pub struct Signal {
pub name: 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)]

View file

@ -1,7 +1,7 @@
use std::collections::HashMap;
use crate::{
outform::{self, Flag, PropertyType},
outform::{self, Flag, Parameter, PropertyType},
typespec::{FnParam, Function, Property, Signal, TypeSpec},
};
@ -147,7 +147,8 @@ pub fn resolve_types(
ret: qmlparamtype(&func.ret, typespec),
name: func.name.clone(),
id: {
let params = func.params
let params = func
.params
.iter()
.map(|FnParam { type_, .. }| qmlparamtype(type_, typespec).name);
@ -166,7 +167,10 @@ pub fn resolve_types(
params: func
.params
.iter()
.map(|FnParam { type_, name }| (name.clone(), qmlparamtype(type_, typespec)))
.map(|FnParam { type_, name }| Parameter {
name: name.clone(),
type_: qmlparamtype(type_, typespec),
})
.collect(),
}
}
@ -178,7 +182,10 @@ pub fn resolve_types(
params: func
.params
.iter()
.map(|FnParam { type_, name }| (name.clone(), qmlparamtype(type_, typespec)))
.map(|FnParam { type_, name }| Parameter {
name: name.clone(),
type_: qmlparamtype(type_, typespec),
})
.collect(),
}
}