From d0b56022d8c8ed175e34b1f4824ef41a056d5652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guilloux?= Date: Sat, 14 Jun 2025 23:39:22 +0200 Subject: [PATCH] Fix #14362, 4b677e8256: Class with non static methods may have a default constructor (#14363) --- cmake/scripts/SquirrelExport.cmake | 2 +- regression/regression/main.nut | 28 ++++++++++++++++++++++++++++ regression/regression/result.txt | 29 ++++++++++++++++++++++++++++- 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/cmake/scripts/SquirrelExport.cmake b/cmake/scripts/SquirrelExport.cmake index c5a78c4f6f..8b9ca55621 100644 --- a/cmake/scripts/SquirrelExport.cmake +++ b/cmake/scripts/SquirrelExport.cmake @@ -351,7 +351,7 @@ foreach(LINE IN LISTS SOURCE_LINES) else() string(APPEND SQUIRREL_EXPORT "\n\tSQ${API_CLS}.PreRegister(engine, \"${API_SUPER_CLS}\");") endif() - if(DEFINED CLS_PARAMS AND NOT "${SUPER_CLS}" MATCHES "^ScriptEvent" AND NOT "${CLS}" STREQUAL "ScriptEvent") + if((DEFINED CLS_PARAMS OR DEFINED METHODS) AND NOT "${SUPER_CLS}" MATCHES "^ScriptEvent" AND NOT "${CLS}" STREQUAL "ScriptEvent") if("${CLS_TYPES}" STREQUAL "v") string(APPEND SQUIRREL_EXPORT "\n\tSQ${API_CLS}.AddSQAdvancedConstructor(engine);") else() diff --git a/regression/regression/main.nut b/regression/regression/main.nut index ac0494e1cf..951c9d4598 100644 --- a/regression/regression/main.nut +++ b/regression/regression/main.nut @@ -2023,6 +2023,33 @@ function Regression::Math() print(" 13725 > -2147483648: " + ( 13725 > -2147483648)); } +function Regression::PriorityQueue() +{ + print(""); + print("--PriorityQueue--"); + local queue = AIPriorityQueue(); + print(" IsEmpty(): " + queue.IsEmpty()); + print(" Count(): " + queue.Count()); + print(" --Insert--") + for (local i = 0; i < 10; i++) { + print(" Insert(" + i + ", " + i + "): " + queue.Insert(i, i)); + } + print(" Exists(5): " + queue.Exists(5)); + print(" Insert(5, 5): "+ queue.Insert(5, 5)); + print(" IsEmpty(): " + queue.IsEmpty()); + print(" Count(): " + queue.Count()); + local item = queue.Peek(); + print(" Peek(): " + item); + print(" Count(): " + queue.Count()); + local item2 = queue.Pop(); + print(" Pop(): " + item2); + print(" Count(): " + queue.Count()); + print(" " + item + " == " + item2 + " : " + (item == item2)); + print(" Clear(): " + queue.Clear()); + print(" IsEmpty(): " + queue.IsEmpty()); + print(" Count(): " + queue.Count()); +} + function Regression::Start() { this.TestInit(); @@ -2119,6 +2146,7 @@ function Regression::Start() print(" IsEventWaiting: false"); this.Math(); + this.PriorityQueue(); /* Check Valuate() is actually limited, MUST BE THE LAST TEST. */ print("--Valuate() with excessive CPU usage--") diff --git a/regression/regression/result.txt b/regression/regression/result.txt index 676d30ec0c..18afcb5f2f 100644 --- a/regression/regression/result.txt +++ b/regression/regression/result.txt @@ -9804,11 +9804,38 @@ ERROR: IsEnd() is invalid as Begin() is never called -1 > 2147483647: false -2147483648 > 2147483647: false 13725 > -2147483648: true + +--PriorityQueue-- + IsEmpty(): true + Count(): 0 + --Insert-- + Insert(0, 0): true + Insert(1, 1): true + Insert(2, 2): true + Insert(3, 3): true + Insert(4, 4): true + Insert(5, 5): true + Insert(6, 6): true + Insert(7, 7): true + Insert(8, 8): true + Insert(9, 9): true + Exists(5): true + Insert(5, 5): true + IsEmpty(): false + Count(): 11 + Peek(): 0 + Count(): 11 + Pop(): 0 + Count(): 10 + 0 == 0 : true + Clear(): (null : 0x00000000) + IsEmpty(): true + Count(): 0 --Valuate() with excessive CPU usage-- constructor failed with: excessive CPU usage in list filter function Your script made an error: excessive CPU usage in valuator function -*FUNCTION [Start()] regression/main.nut line [2133] +*FUNCTION [Start()] regression/main.nut line [2161] [Infinite] CLOSURE [list] INSTANCE