From ed07409dbcef9257871a239086ddec4c24c1d51b Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Wed, 22 Mar 2023 16:40:43 +0100 Subject: [PATCH] Fix selene typedefs generation --- .lune/http_server.luau | 4 ++-- .lune/websocket_client.luau | 2 +- packages/cli/src/gen/selene_defs.rs | 14 ++++++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.lune/http_server.luau b/.lune/http_server.luau index 8970455..a3a484b 100644 --- a/.lune/http_server.luau +++ b/.lune/http_server.luau @@ -11,14 +11,14 @@ local function pong(request: NetRequest): string return `Pong!\n{request.path}\n{request.body}` end -local function teapot(request: NetRequest): NetResponse +local function teapot(_request: NetRequest): NetResponse return { status = 418, body = "🫖", } end -local function notFound(request: NetRequest): NetResponse +local function notFound(_request: NetRequest): NetResponse return { status = 404, body = "Not Found", diff --git a/.lune/websocket_client.luau b/.lune/websocket_client.luau index 5fa015b..fe6ae5b 100644 --- a/.lune/websocket_client.luau +++ b/.lune/websocket_client.luau @@ -22,7 +22,7 @@ end) -- Send one message per second and time it -for i = 1, 5 do +for _ = 1, 5 do local start = os.clock() socket.send(tostring(1)) local response = socket.next() diff --git a/packages/cli/src/gen/selene_defs.rs b/packages/cli/src/gen/selene_defs.rs index fd9a6dc..d542a7e 100644 --- a/packages/cli/src/gen/selene_defs.rs +++ b/packages/cli/src/gen/selene_defs.rs @@ -117,10 +117,16 @@ fn doc_item_to_selene_yaml_mapping(item: &DefinitionsItem) -> Result (stripped, true), 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 { arg_mapping.insert( YamlValue::String("required".to_string()), @@ -129,9 +135,7 @@ fn doc_item_to_selene_yaml_mapping(item: &DefinitionsItem) -> Result String { primitives.push("string".to_string()); } else if type_inner == "boolean" { primitives.push("bool".to_string()); + } else if type_inner == "thread" { + primitives.push("any".to_string()); } else { primitives.push(type_inner.to_string()); }