From 0ba11023acfc80689ccb58efa91eaf55c2d60e3b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 20 Aug 2022 15:09:23 +0100 Subject: [PATCH] Rename debug in testcases to trace To remove D specific keyword rename --- Examples/test-suite/cpp11_move_only.i | 30 ++++++++----------- .../test-suite/cpp11_move_only_valuewrapper.i | 26 +++++++--------- .../cpp11_rvalue_reference_move_input.i | 18 +++++------ .../test-suite/csharp/li_std_wstring_runme.cs | 4 +-- .../csharp/typemap_out_optimal_runme.cs | 6 ++-- Examples/test-suite/director_pass_by_value.i | 18 +++++------ .../go/typemap_out_optimal_runme.go | 2 +- .../java/typemap_out_optimal_runme.java | 2 +- Examples/test-suite/li_std_wstring.i | 6 ++-- .../test-suite/python/python_pickle_runme.py | 4 +-- .../python/typemap_out_optimal_runme.py | 2 +- Examples/test-suite/python_pickle.i | 6 ++-- Examples/test-suite/typemap_out_optimal.i | 18 +++++------ 13 files changed, 61 insertions(+), 81 deletions(-) diff --git a/Examples/test-suite/cpp11_move_only.i b/Examples/test-suite/cpp11_move_only.i index f97d7090e..732bc49db 100644 --- a/Examples/test-suite/cpp11_move_only.i +++ b/Examples/test-suite/cpp11_move_only.i @@ -1,9 +1,5 @@ %module cpp11_move_only -#if defined(SWIGD) -%rename(trace) debug; -#endif - %include "cpp11_move_only_helper.i" %ignore MoveOnly::operator=; @@ -13,22 +9,22 @@ #include using namespace std; -bool debug = false; +bool trace = false; struct MoveOnly { - MoveOnly(int i = 0) { if (debug) cout << "MoveOnly(" << i << ")" << " " << this << endl; Counter::normal_constructor++; } + MoveOnly(int i = 0) { if (trace) cout << "MoveOnly(" << i << ")" << " " << this << endl; Counter::normal_constructor++; } MoveOnly(const MoveOnly &other) = delete; MoveOnly & operator=(const MoveOnly &other) = delete; - MoveOnly(MoveOnly &&other) noexcept { if (debug) cout << "MoveOnly(MoveOnly &&)" << " " << this << endl; Counter::move_constructor++; } - MoveOnly & operator=(MoveOnly &&other) noexcept { if (debug) cout << "operator=(MoveOnly &&)" << " " << this << endl; Counter::move_assignment++; return *this; } - ~MoveOnly() { if (debug) cout << "~MoveOnly()" << " " << this << endl; Counter::destructor++; } + MoveOnly(MoveOnly &&other) noexcept { if (trace) cout << "MoveOnly(MoveOnly &&)" << " " << this << endl; Counter::move_constructor++; } + MoveOnly & operator=(MoveOnly &&other) noexcept { if (trace) cout << "operator=(MoveOnly &&)" << " " << this << endl; Counter::move_assignment++; return *this; } + ~MoveOnly() { if (trace) cout << "~MoveOnly()" << " " << this << endl; Counter::destructor++; } static MoveOnly create() { return MoveOnly(111); } // static const MoveOnly createConst() { return MoveOnly(111); } // not supported by default - // static void take(MoveOnly mo) { if (debug) cout << "take(MoveOnly)" << " " << &mo << endl; } + // static void take(MoveOnly mo) { if (trace) cout << "take(MoveOnly)" << " " << &mo << endl; } }; %} @@ -39,18 +35,18 @@ struct MoveOnly { %inline %{ // Movable and Copyable struct MovableCopyable { - MovableCopyable(int i = 0) { if (debug) cout << "MovableCopyable(" << i << ")" << " " << this << endl; Counter::normal_constructor++; } + MovableCopyable(int i = 0) { if (trace) cout << "MovableCopyable(" << i << ")" << " " << this << endl; Counter::normal_constructor++; } - MovableCopyable(const MovableCopyable &other) { if (debug) cout << "MovableCopyable(const MovableCopyable &)" << " " << this << " " << &other << endl; Counter::copy_constructor++;} - MovableCopyable & operator=(const MovableCopyable &other) { if (debug) cout << "operator=(const MovableCopyable &)" << " " << this << " " << &other << endl; Counter::copy_assignment++; return *this; } + MovableCopyable(const MovableCopyable &other) { if (trace) cout << "MovableCopyable(const MovableCopyable &)" << " " << this << " " << &other << endl; Counter::copy_constructor++;} + MovableCopyable & operator=(const MovableCopyable &other) { if (trace) cout << "operator=(const MovableCopyable &)" << " " << this << " " << &other << endl; Counter::copy_assignment++; return *this; } - MovableCopyable(MovableCopyable &&other) noexcept { if (debug) cout << "MovableCopyable(MovableCopyable &&)" << " " << this << endl; Counter::move_constructor++; } - MovableCopyable & operator=(MovableCopyable &&other) noexcept { if (debug) cout << "operator=(MovableCopyable &&)" << " " << this << endl; Counter::move_assignment++; return *this; } - ~MovableCopyable() { if (debug) cout << "~MovableCopyable()" << " " << this << endl; Counter::destructor++; } + MovableCopyable(MovableCopyable &&other) noexcept { if (trace) cout << "MovableCopyable(MovableCopyable &&)" << " " << this << endl; Counter::move_constructor++; } + MovableCopyable & operator=(MovableCopyable &&other) noexcept { if (trace) cout << "operator=(MovableCopyable &&)" << " " << this << endl; Counter::move_assignment++; return *this; } + ~MovableCopyable() { if (trace) cout << "~MovableCopyable()" << " " << this << endl; Counter::destructor++; } static MovableCopyable create() { return MovableCopyable(111); } static const MovableCopyable createConst() { return MovableCopyable(111); } - static void take(MovableCopyable mc) { if (debug) cout << "take(MovableCopyable)" << " " << &mc << endl; } + static void take(MovableCopyable mc) { if (trace) cout << "take(MovableCopyable)" << " " << &mc << endl; } }; %} diff --git a/Examples/test-suite/cpp11_move_only_valuewrapper.i b/Examples/test-suite/cpp11_move_only_valuewrapper.i index bde95f014..a4194ea86 100644 --- a/Examples/test-suite/cpp11_move_only_valuewrapper.i +++ b/Examples/test-suite/cpp11_move_only_valuewrapper.i @@ -37,26 +37,22 @@ namespace std { #endif %} -#if defined(SWIGD) -%rename(trace) debug; -#endif - %include "cpp11_move_only_helper.i" %valuewrapper XXX; %ignore XXX::operator=; %inline %{ -bool debug = false; +bool trace = false; struct XXX { - XXX(int i = 0) { if (debug) cout << "XXX(" << i << ")" << " " << this << endl; Counter::normal_constructor++; } - XXX(const XXX &other) { if (debug) cout << "XXX(const XXX &)" << " " << this << " " << &other << endl; Counter::copy_constructor++;} - XXX & operator=(const XXX &other) { if (debug) cout << "operator=(const XXX &)" << " " << this << " " << &other << endl; Counter::copy_assignment++; return *this; } + XXX(int i = 0) { if (trace) cout << "XXX(" << i << ")" << " " << this << endl; Counter::normal_constructor++; } + XXX(const XXX &other) { if (trace) cout << "XXX(const XXX &)" << " " << this << " " << &other << endl; Counter::copy_constructor++;} + XXX & operator=(const XXX &other) { if (trace) cout << "operator=(const XXX &)" << " " << this << " " << &other << endl; Counter::copy_assignment++; return *this; } #if defined(__cplusplus) && __cplusplus >= 201103L - XXX(XXX &&other) noexcept { if (debug) cout << "XXX(XXX &&)" << " " << this << endl; Counter::move_constructor++; } - XXX & operator=(XXX &&other) noexcept { if (debug) cout << "operator=(XXX &&)" << " " << this << endl; Counter::move_assignment++; return *this; } + XXX(XXX &&other) noexcept { if (trace) cout << "XXX(XXX &&)" << " " << this << endl; Counter::move_constructor++; } + XXX & operator=(XXX &&other) noexcept { if (trace) cout << "operator=(XXX &&)" << " " << this << endl; Counter::move_assignment++; return *this; } #endif - ~XXX() { if (debug) cout << "~XXX()" << " " << this << endl; Counter::destructor++; } + ~XXX() { if (trace) cout << "~XXX()" << " " << this << endl; Counter::destructor++; } }; bool has_cplusplus11() { @@ -73,7 +69,7 @@ void cleanup(std::unique_ptr* p); %{ std::unique_ptr makeUniqueXXX() { - if (debug) cout << "makeUniqueXXX()" << endl; + if (trace) cout << "makeUniqueXXX()" << endl; return std::unique_ptr(new XXX(11)); } void cleanup(std::unique_ptr* p) { @@ -84,15 +80,15 @@ typedef XXX UUU; %inline %{ XXX createXXX() { - if (debug) cout << "createXXX()" << endl; + if (trace) cout << "createXXX()" << endl; return XXX(111); } XXX createXXX2() { - if (debug) cout << "createXXX2()" << endl; + if (trace) cout << "createXXX2()" << endl; return XXX(222); } UUU createUnknownType() { - if (debug) cout << "createXXX2()" << endl; + if (trace) cout << "createXXX2()" << endl; return XXX(222); } struct YYY {}; diff --git a/Examples/test-suite/cpp11_rvalue_reference_move_input.i b/Examples/test-suite/cpp11_rvalue_reference_move_input.i index 03abd7322..69b4fd858 100644 --- a/Examples/test-suite/cpp11_rvalue_reference_move_input.i +++ b/Examples/test-suite/cpp11_rvalue_reference_move_input.i @@ -2,10 +2,6 @@ // Testcase for testing rvalue reference input typemaps which assume the object is moved during a function call -#if defined(SWIGD) -%rename(trace) debug; -#endif - %include "cpp11_move_only_helper.i" %rename(MoveAssign) MovableCopyable::operator=(MovableCopyable &&); @@ -16,18 +12,18 @@ #include using namespace std; -bool debug = false; +bool trace = false; class MovableCopyable { public: - MovableCopyable(int i = 0) { if (debug) cout << "MovableCopyable(" << i << ")" << " " << this << endl; Counter::normal_constructor++; } + MovableCopyable(int i = 0) { if (trace) cout << "MovableCopyable(" << i << ")" << " " << this << endl; Counter::normal_constructor++; } - MovableCopyable(const MovableCopyable &other) { if (debug) cout << "MovableCopyable(const MovableCopyable &)" << " " << this << " " << &other << endl; Counter::copy_constructor++;} - MovableCopyable & operator=(const MovableCopyable &other) { if (debug) cout << "operator=(const MovableCopyable &)" << " " << this << " " << &other << endl; Counter::copy_assignment++; return *this; } + MovableCopyable(const MovableCopyable &other) { if (trace) cout << "MovableCopyable(const MovableCopyable &)" << " " << this << " " << &other << endl; Counter::copy_constructor++;} + MovableCopyable & operator=(const MovableCopyable &other) { if (trace) cout << "operator=(const MovableCopyable &)" << " " << this << " " << &other << endl; Counter::copy_assignment++; return *this; } - MovableCopyable(MovableCopyable &&other) noexcept { if (debug) cout << "MovableCopyable(MovableCopyable &&)" << " " << this << endl; Counter::move_constructor++; } - MovableCopyable & operator=(MovableCopyable &&other) noexcept { if (debug) cout << "operator=(MovableCopyable &&)" << " " << this << endl; Counter::move_assignment++; return *this; } - ~MovableCopyable() { if (debug) cout << "~MovableCopyable()" << " " << this << endl; Counter::destructor++; } + MovableCopyable(MovableCopyable &&other) noexcept { if (trace) cout << "MovableCopyable(MovableCopyable &&)" << " " << this << endl; Counter::move_constructor++; } + MovableCopyable & operator=(MovableCopyable &&other) noexcept { if (trace) cout << "operator=(MovableCopyable &&)" << " " << this << endl; Counter::move_assignment++; return *this; } + ~MovableCopyable() { if (trace) cout << "~MovableCopyable()" << " " << this << endl; Counter::destructor++; } static void movein(MovableCopyable &&mcin) { MovableCopyable mc = std::move(mcin); diff --git a/Examples/test-suite/csharp/li_std_wstring_runme.cs b/Examples/test-suite/csharp/li_std_wstring_runme.cs index 21c225e5f..d2be3d1ff 100644 --- a/Examples/test-suite/csharp/li_std_wstring_runme.cs +++ b/Examples/test-suite/csharp/li_std_wstring_runme.cs @@ -30,7 +30,7 @@ public class runme static private void check_equal(string a, string b) { - if (li_std_wstring.debug) { + if (li_std_wstring.trace) { Console.WriteLine("check_equal {0} {1}", a, b); display_bytes(a); display_bytes(b); @@ -150,7 +150,7 @@ public class runme foreach (string expected in test_strings) { - if (li_std_wstring.debug) + if (li_std_wstring.trace) Console.WriteLine("expected (C#): " + expected); string received = li_std_wstring.test_value(expected); check_equal(received, expected); diff --git a/Examples/test-suite/csharp/typemap_out_optimal_runme.cs b/Examples/test-suite/csharp/typemap_out_optimal_runme.cs index 0d697498a..0d4254eef 100644 --- a/Examples/test-suite/csharp/typemap_out_optimal_runme.cs +++ b/Examples/test-suite/csharp/typemap_out_optimal_runme.cs @@ -4,11 +4,11 @@ using typemap_out_optimalNamespace; public class typemap_out_optimal_runme { public static void Main() { - XX.debug = false; - if (XX.debug) + XX.trace = false; + if (XX.trace) Console.WriteLine("calling create()"); using (XX x = XX.create()) { } - if (XX.debug) + if (XX.trace) Console.WriteLine("calling createConst()"); using (XX x = XX.createConst()) { } } diff --git a/Examples/test-suite/director_pass_by_value.i b/Examples/test-suite/director_pass_by_value.i index 5e31c9d3b..6eb62f035 100644 --- a/Examples/test-suite/director_pass_by_value.i +++ b/Examples/test-suite/director_pass_by_value.i @@ -1,9 +1,5 @@ %module(directors="1") director_pass_by_value -#if defined(SWIGD) -%rename(trace) debug; -#endif - %director DirectorPassByValueAbstractBase; %include "cpp11_move_only_helper.i" @@ -14,17 +10,17 @@ %inline %{ #include using namespace std; -int debug = false; +int trace = false; struct PassedByValue { - PassedByValue(int v = 0x12345678) { val = v; if (debug) cout << "PassedByValue(0x" << hex << val << ")" << " " << this << endl; Counter::normal_constructor++; } + PassedByValue(int v = 0x12345678) { val = v; if (trace) cout << "PassedByValue(0x" << hex << val << ")" << " " << this << endl; Counter::normal_constructor++; } - PassedByValue(const PassedByValue &other) { val = other.val; if (debug) cout << "PassedByValue(const PassedByValue &)" << " " << this << " " << &other << endl; Counter::copy_constructor++;} - PassedByValue & operator=(const PassedByValue &other) { val = other.val; if (debug) cout << "operator=(const PassedByValue &)" << " " << this << " " << &other << endl; Counter::copy_assignment++; return *this; } + PassedByValue(const PassedByValue &other) { val = other.val; if (trace) cout << "PassedByValue(const PassedByValue &)" << " " << this << " " << &other << endl; Counter::copy_constructor++;} + PassedByValue & operator=(const PassedByValue &other) { val = other.val; if (trace) cout << "operator=(const PassedByValue &)" << " " << this << " " << &other << endl; Counter::copy_assignment++; return *this; } #if __cplusplus >= 201103L - PassedByValue(PassedByValue &&other) noexcept { val = other.val; if (debug) cout << "PassedByValue(PassedByValue &&)" << " " << this << endl; Counter::move_constructor++; } - PassedByValue & operator=(PassedByValue &&other) noexcept { val = other.val; if (debug) cout << "operator=(PassedByValue &&)" << " " << this << endl; Counter::move_assignment++; return *this; } - ~PassedByValue() { if (debug) cout << "~PassedByValue()" << " " << this << endl; Counter::destructor++; } + PassedByValue(PassedByValue &&other) noexcept { val = other.val; if (trace) cout << "PassedByValue(PassedByValue &&)" << " " << this << endl; Counter::move_constructor++; } + PassedByValue & operator=(PassedByValue &&other) noexcept { val = other.val; if (trace) cout << "operator=(PassedByValue &&)" << " " << this << endl; Counter::move_assignment++; return *this; } + ~PassedByValue() { if (trace) cout << "~PassedByValue()" << " " << this << endl; Counter::destructor++; } #endif int getVal() { return val; } diff --git a/Examples/test-suite/go/typemap_out_optimal_runme.go b/Examples/test-suite/go/typemap_out_optimal_runme.go index 0467ce293..646aa8ece 100644 --- a/Examples/test-suite/go/typemap_out_optimal_runme.go +++ b/Examples/test-suite/go/typemap_out_optimal_runme.go @@ -3,7 +3,7 @@ package main import . "swigtests/typemap_out_optimal" func main() { - SetXXDebug(false) + SetXXTrace(false) _ = XXCreate() _ = XXCreateConst() } diff --git a/Examples/test-suite/java/typemap_out_optimal_runme.java b/Examples/test-suite/java/typemap_out_optimal_runme.java index b48e5d697..254b0c6b6 100644 --- a/Examples/test-suite/java/typemap_out_optimal_runme.java +++ b/Examples/test-suite/java/typemap_out_optimal_runme.java @@ -13,7 +13,7 @@ public class typemap_out_optimal_runme { } public static void main(String argv[]) { - XX.setDebug(false); + XX.setTrace(false); { XX x = XX.create(); x.delete(); diff --git a/Examples/test-suite/li_std_wstring.i b/Examples/test-suite/li_std_wstring.i index 43031679a..88f80beb4 100644 --- a/Examples/test-suite/li_std_wstring.i +++ b/Examples/test-suite/li_std_wstring.i @@ -23,7 +23,7 @@ #include #include -bool debug = false; +bool trace = false; void show_wstring_bytes(const std::wstring &s) { unsigned char *p = (unsigned char *)s.data(); @@ -59,7 +59,7 @@ wchar_t* test_wchar_overload(wchar_t *x) { } std::wstring test_value(std::wstring x) { - if (debug) { + if (trace) { std::wcout << "received(C++): " /*<< x */<< std::endl; show_wstring_bytes(x); } @@ -80,7 +80,7 @@ void test_reference(std::wstring &x) { } bool test_equal(const wchar_t *wcs, const std::wstring& s) { - if (debug) { + if (trace) { show_wstring_bytes(wcs); show_wstring_bytes(s); } diff --git a/Examples/test-suite/python/python_pickle_runme.py b/Examples/test-suite/python/python_pickle_runme.py index cbe425fa2..7cb07ef59 100644 --- a/Examples/test-suite/python/python_pickle_runme.py +++ b/Examples/test-suite/python/python_pickle_runme.py @@ -8,13 +8,13 @@ def check(p): if msg != "hi there": raise RuntimeError("Bad, got: " + msg) -python_pickle.cvar.debug = False +python_pickle.cvar.trace = False p = python_pickle.PickleMe("hi there") check(p) r = p.__reduce__() -if python_pickle.cvar.debug: +if python_pickle.cvar.trace: print("__reduce__ returned: {}".format(r)) pickle_string = pickle.dumps(p) newp = pickle.loads(pickle_string) diff --git a/Examples/test-suite/python/typemap_out_optimal_runme.py b/Examples/test-suite/python/typemap_out_optimal_runme.py index beed46bfc..6f6cc5490 100644 --- a/Examples/test-suite/python/typemap_out_optimal_runme.py +++ b/Examples/test-suite/python/typemap_out_optimal_runme.py @@ -1,6 +1,6 @@ from typemap_out_optimal import * -cvar.XX_debug = False +cvar.XX_trace = False x = XX.create() del x x = XX.createConst() diff --git a/Examples/test-suite/python_pickle.i b/Examples/test-suite/python_pickle.i index fbb3d05a8..10be972a0 100644 --- a/Examples/test-suite/python_pickle.i +++ b/Examples/test-suite/python_pickle.i @@ -14,7 +14,7 @@ def __reduce__(self): #else // Equivalent to Python code above PyObject *__reduce__() { - if (debug) + if (trace) std::cout << "In C++ __reduce__" << std::endl; PyObject *args = PyTuple_New(1); PyTuple_SetItem(args, 0, SWIG_From_std_string(self->msg)); @@ -39,12 +39,12 @@ def __reduce__(self): %inline %{ #include -bool debug = false; +bool trace = false; struct PickleMe { std::string msg; PickleMe(const std::string& msg) : msg(msg) { - if (debug) + if (trace) std::cout << "In C++ constructor " << " [" << msg << "]" << std::endl; } }; diff --git a/Examples/test-suite/typemap_out_optimal.i b/Examples/test-suite/typemap_out_optimal.i index 11f1db80f..46809d117 100644 --- a/Examples/test-suite/typemap_out_optimal.i +++ b/Examples/test-suite/typemap_out_optimal.i @@ -18,20 +18,16 @@ %ignore XX::operator=; -#ifdef SWIGD -%rename(trace) XX::debug; -#endif - %inline %{ #include using namespace std; struct XX { - XX() { if (debug) cout << "XX()" << endl; } - XX(int i) { if (debug) cout << "XX(" << i << ")" << endl; } - XX(const XX &other) { if (debug) cout << "XX(const XX &)" << endl; } - XX& operator =(const XX &other) { if (debug) cout << "operator=(const XX &)" << endl; return *this; } - ~XX() { if (debug) cout << "~XX()" << endl; } + XX() { if (trace) cout << "XX()" << endl; } + XX(int i) { if (trace) cout << "XX(" << i << ")" << endl; } + XX(const XX &other) { if (trace) cout << "XX(const XX &)" << endl; } + XX& operator =(const XX &other) { if (trace) cout << "operator=(const XX &)" << endl; return *this; } + ~XX() { if (trace) cout << "~XX()" << endl; } // Note: best observed RVO for C#, Java and Python with g++-6 to g++-10 (just one constructor and one destructor call) static XX create() { @@ -40,8 +36,8 @@ struct XX { static const XX createConst() { return XX(456); } - static bool debug; + static bool trace; }; -bool XX::debug = true; +bool XX::trace = true; %}