mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
Fix selene typedefs generation
This commit is contained in:
parent
e1fa0867b7
commit
ed07409dbc
3 changed files with 13 additions and 7 deletions
|
@ -11,14 +11,14 @@ local function pong(request: NetRequest): string
|
||||||
return `Pong!\n{request.path}\n{request.body}`
|
return `Pong!\n{request.path}\n{request.body}`
|
||||||
end
|
end
|
||||||
|
|
||||||
local function teapot(request: NetRequest): NetResponse
|
local function teapot(_request: NetRequest): NetResponse
|
||||||
return {
|
return {
|
||||||
status = 418,
|
status = 418,
|
||||||
body = "🫖",
|
body = "🫖",
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local function notFound(request: NetRequest): NetResponse
|
local function notFound(_request: NetRequest): NetResponse
|
||||||
return {
|
return {
|
||||||
status = 404,
|
status = 404,
|
||||||
body = "Not Found",
|
body = "Not Found",
|
||||||
|
|
|
@ -22,7 +22,7 @@ end)
|
||||||
|
|
||||||
-- Send one message per second and time it
|
-- Send one message per second and time it
|
||||||
|
|
||||||
for i = 1, 5 do
|
for _ = 1, 5 do
|
||||||
local start = os.clock()
|
local start = os.clock()
|
||||||
socket.send(tostring(1))
|
socket.send(tostring(1))
|
||||||
local response = socket.next()
|
local response = socket.next()
|
||||||
|
|
|
@ -117,10 +117,16 @@ fn doc_item_to_selene_yaml_mapping(item: &DefinitionsItem) -> Result<YamlMapping
|
||||||
let mut args = YamlSequence::new();
|
let mut args = YamlSequence::new();
|
||||||
for arg_type in item.arg_types() {
|
for arg_type in item.arg_types() {
|
||||||
let mut arg_mapping = YamlMapping::new();
|
let mut arg_mapping = YamlMapping::new();
|
||||||
let (type_str, type_opt) = match arg_type.strip_suffix('?') {
|
let (type_str, mut type_opt) = match arg_type.strip_suffix('?') {
|
||||||
Some(stripped) => (stripped, true),
|
Some(stripped) => (stripped, true),
|
||||||
None => (arg_type, false),
|
None => (arg_type, false),
|
||||||
};
|
};
|
||||||
|
let simplified = simplify_type_str_into_primitives(
|
||||||
|
type_str.trim_start_matches('(').trim_end_matches(')'),
|
||||||
|
);
|
||||||
|
if simplified.contains("...") {
|
||||||
|
type_opt = true;
|
||||||
|
}
|
||||||
if type_opt {
|
if type_opt {
|
||||||
arg_mapping.insert(
|
arg_mapping.insert(
|
||||||
YamlValue::String("required".to_string()),
|
YamlValue::String("required".to_string()),
|
||||||
|
@ -129,9 +135,7 @@ fn doc_item_to_selene_yaml_mapping(item: &DefinitionsItem) -> Result<YamlMapping
|
||||||
}
|
}
|
||||||
arg_mapping.insert(
|
arg_mapping.insert(
|
||||||
YamlValue::String("type".to_string()),
|
YamlValue::String("type".to_string()),
|
||||||
YamlValue::String(simplify_type_str_into_primitives(
|
YamlValue::String(simplified),
|
||||||
type_str.trim_start_matches('(').trim_end_matches(')'),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
args.push(YamlValue::Mapping(arg_mapping));
|
args.push(YamlValue::Mapping(arg_mapping));
|
||||||
}
|
}
|
||||||
|
@ -155,6 +159,8 @@ fn simplify_type_str_into_primitives(type_str: &str) -> String {
|
||||||
primitives.push("string".to_string());
|
primitives.push("string".to_string());
|
||||||
} else if type_inner == "boolean" {
|
} else if type_inner == "boolean" {
|
||||||
primitives.push("bool".to_string());
|
primitives.push("bool".to_string());
|
||||||
|
} else if type_inner == "thread" {
|
||||||
|
primitives.push("any".to_string());
|
||||||
} else {
|
} else {
|
||||||
primitives.push(type_inner.to_string());
|
primitives.push(type_inner.to_string());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue