Rename debug in testcases to trace
To remove D specific keyword rename
This commit is contained in:
parent
48c644ea6e
commit
0ba11023ac
13 changed files with 61 additions and 81 deletions
|
|
@ -1,9 +1,5 @@
|
||||||
%module cpp11_move_only
|
%module cpp11_move_only
|
||||||
|
|
||||||
#if defined(SWIGD)
|
|
||||||
%rename(trace) debug;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
%include "cpp11_move_only_helper.i"
|
%include "cpp11_move_only_helper.i"
|
||||||
|
|
||||||
%ignore MoveOnly::operator=;
|
%ignore MoveOnly::operator=;
|
||||||
|
|
@ -13,22 +9,22 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
bool debug = false;
|
bool trace = false;
|
||||||
|
|
||||||
struct MoveOnly {
|
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(const MoveOnly &other) = delete;
|
||||||
MoveOnly & operator=(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(MoveOnly &&other) noexcept { if (trace) 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 & operator=(MoveOnly &&other) noexcept { if (trace) cout << "operator=(MoveOnly &&)" << " " << this << endl; Counter::move_assignment++; return *this; }
|
||||||
~MoveOnly() { if (debug) cout << "~MoveOnly()" << " " << this << endl; Counter::destructor++; }
|
~MoveOnly() { if (trace) cout << "~MoveOnly()" << " " << this << endl; Counter::destructor++; }
|
||||||
|
|
||||||
static MoveOnly create() { return MoveOnly(111); }
|
static MoveOnly create() { return MoveOnly(111); }
|
||||||
// static const MoveOnly createConst() { return MoveOnly(111); } // not supported by default
|
// 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 %{
|
%inline %{
|
||||||
// Movable and Copyable
|
// Movable and Copyable
|
||||||
struct MovableCopyable {
|
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(const MovableCopyable &other) { if (trace) 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 & 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(MovableCopyable &&other) noexcept { if (trace) 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 & operator=(MovableCopyable &&other) noexcept { if (trace) cout << "operator=(MovableCopyable &&)" << " " << this << endl; Counter::move_assignment++; return *this; }
|
||||||
~MovableCopyable() { if (debug) cout << "~MovableCopyable()" << " " << this << endl; Counter::destructor++; }
|
~MovableCopyable() { if (trace) cout << "~MovableCopyable()" << " " << this << endl; Counter::destructor++; }
|
||||||
|
|
||||||
static MovableCopyable create() { return MovableCopyable(111); }
|
static MovableCopyable create() { return MovableCopyable(111); }
|
||||||
static const MovableCopyable createConst() { 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; }
|
||||||
};
|
};
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
|
|
@ -37,26 +37,22 @@ namespace std {
|
||||||
#endif
|
#endif
|
||||||
%}
|
%}
|
||||||
|
|
||||||
#if defined(SWIGD)
|
|
||||||
%rename(trace) debug;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
%include "cpp11_move_only_helper.i"
|
%include "cpp11_move_only_helper.i"
|
||||||
|
|
||||||
%valuewrapper XXX;
|
%valuewrapper XXX;
|
||||||
%ignore XXX::operator=;
|
%ignore XXX::operator=;
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
bool debug = false;
|
bool trace = false;
|
||||||
struct XXX {
|
struct XXX {
|
||||||
XXX(int i = 0) { if (debug) cout << "XXX(" << i << ")" << " " << this << endl; Counter::normal_constructor++; }
|
XXX(int i = 0) { if (trace) 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(const XXX &other) { if (trace) 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 & operator=(const XXX &other) { if (trace) cout << "operator=(const XXX &)" << " " << this << " " << &other << endl; Counter::copy_assignment++; return *this; }
|
||||||
#if defined(__cplusplus) && __cplusplus >= 201103L
|
#if defined(__cplusplus) && __cplusplus >= 201103L
|
||||||
XXX(XXX &&other) noexcept { if (debug) cout << "XXX(XXX &&)" << " " << this << endl; Counter::move_constructor++; }
|
XXX(XXX &&other) noexcept { if (trace) 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 & operator=(XXX &&other) noexcept { if (trace) cout << "operator=(XXX &&)" << " " << this << endl; Counter::move_assignment++; return *this; }
|
||||||
#endif
|
#endif
|
||||||
~XXX() { if (debug) cout << "~XXX()" << " " << this << endl; Counter::destructor++; }
|
~XXX() { if (trace) cout << "~XXX()" << " " << this << endl; Counter::destructor++; }
|
||||||
};
|
};
|
||||||
|
|
||||||
bool has_cplusplus11() {
|
bool has_cplusplus11() {
|
||||||
|
|
@ -73,7 +69,7 @@ void cleanup(std::unique_ptr<XXX>* p);
|
||||||
|
|
||||||
%{
|
%{
|
||||||
std::unique_ptr<XXX> makeUniqueXXX() {
|
std::unique_ptr<XXX> makeUniqueXXX() {
|
||||||
if (debug) cout << "makeUniqueXXX()" << endl;
|
if (trace) cout << "makeUniqueXXX()" << endl;
|
||||||
return std::unique_ptr<XXX>(new XXX(11));
|
return std::unique_ptr<XXX>(new XXX(11));
|
||||||
}
|
}
|
||||||
void cleanup(std::unique_ptr<XXX>* p) {
|
void cleanup(std::unique_ptr<XXX>* p) {
|
||||||
|
|
@ -84,15 +80,15 @@ typedef XXX UUU;
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
XXX createXXX() {
|
XXX createXXX() {
|
||||||
if (debug) cout << "createXXX()" << endl;
|
if (trace) cout << "createXXX()" << endl;
|
||||||
return XXX(111);
|
return XXX(111);
|
||||||
}
|
}
|
||||||
XXX createXXX2() {
|
XXX createXXX2() {
|
||||||
if (debug) cout << "createXXX2()" << endl;
|
if (trace) cout << "createXXX2()" << endl;
|
||||||
return XXX(222);
|
return XXX(222);
|
||||||
}
|
}
|
||||||
UUU createUnknownType() {
|
UUU createUnknownType() {
|
||||||
if (debug) cout << "createXXX2()" << endl;
|
if (trace) cout << "createXXX2()" << endl;
|
||||||
return XXX(222);
|
return XXX(222);
|
||||||
}
|
}
|
||||||
struct YYY {};
|
struct YYY {};
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,6 @@
|
||||||
|
|
||||||
// Testcase for testing rvalue reference input typemaps which assume the object is moved during a function call
|
// 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"
|
%include "cpp11_move_only_helper.i"
|
||||||
|
|
||||||
%rename(MoveAssign) MovableCopyable::operator=(MovableCopyable &&);
|
%rename(MoveAssign) MovableCopyable::operator=(MovableCopyable &&);
|
||||||
|
|
@ -16,18 +12,18 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
bool debug = false;
|
bool trace = false;
|
||||||
|
|
||||||
class MovableCopyable {
|
class MovableCopyable {
|
||||||
public:
|
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(const MovableCopyable &other) { if (trace) 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 & 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(MovableCopyable &&other) noexcept { if (trace) 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 & operator=(MovableCopyable &&other) noexcept { if (trace) cout << "operator=(MovableCopyable &&)" << " " << this << endl; Counter::move_assignment++; return *this; }
|
||||||
~MovableCopyable() { if (debug) cout << "~MovableCopyable()" << " " << this << endl; Counter::destructor++; }
|
~MovableCopyable() { if (trace) cout << "~MovableCopyable()" << " " << this << endl; Counter::destructor++; }
|
||||||
|
|
||||||
static void movein(MovableCopyable &&mcin) {
|
static void movein(MovableCopyable &&mcin) {
|
||||||
MovableCopyable mc = std::move(mcin);
|
MovableCopyable mc = std::move(mcin);
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ public class runme
|
||||||
|
|
||||||
static private void check_equal(string a, string b)
|
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);
|
Console.WriteLine("check_equal {0} {1}", a, b);
|
||||||
display_bytes(a);
|
display_bytes(a);
|
||||||
display_bytes(b);
|
display_bytes(b);
|
||||||
|
|
@ -150,7 +150,7 @@ public class runme
|
||||||
|
|
||||||
foreach (string expected in test_strings)
|
foreach (string expected in test_strings)
|
||||||
{
|
{
|
||||||
if (li_std_wstring.debug)
|
if (li_std_wstring.trace)
|
||||||
Console.WriteLine("expected (C#): " + expected);
|
Console.WriteLine("expected (C#): " + expected);
|
||||||
string received = li_std_wstring.test_value(expected);
|
string received = li_std_wstring.test_value(expected);
|
||||||
check_equal(received, expected);
|
check_equal(received, expected);
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@ using typemap_out_optimalNamespace;
|
||||||
public class typemap_out_optimal_runme {
|
public class typemap_out_optimal_runme {
|
||||||
|
|
||||||
public static void Main() {
|
public static void Main() {
|
||||||
XX.debug = false;
|
XX.trace = false;
|
||||||
if (XX.debug)
|
if (XX.trace)
|
||||||
Console.WriteLine("calling create()");
|
Console.WriteLine("calling create()");
|
||||||
using (XX x = XX.create()) { }
|
using (XX x = XX.create()) { }
|
||||||
if (XX.debug)
|
if (XX.trace)
|
||||||
Console.WriteLine("calling createConst()");
|
Console.WriteLine("calling createConst()");
|
||||||
using (XX x = XX.createConst()) { }
|
using (XX x = XX.createConst()) { }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,5 @@
|
||||||
%module(directors="1") director_pass_by_value
|
%module(directors="1") director_pass_by_value
|
||||||
|
|
||||||
#if defined(SWIGD)
|
|
||||||
%rename(trace) debug;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
%director DirectorPassByValueAbstractBase;
|
%director DirectorPassByValueAbstractBase;
|
||||||
|
|
||||||
%include "cpp11_move_only_helper.i"
|
%include "cpp11_move_only_helper.i"
|
||||||
|
|
@ -14,17 +10,17 @@
|
||||||
%inline %{
|
%inline %{
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
int debug = false;
|
int trace = false;
|
||||||
struct PassedByValue {
|
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(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 (debug) cout << "operator=(const PassedByValue &)" << " " << this << " " << &other << endl; Counter::copy_assignment++; return *this; }
|
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
|
#if __cplusplus >= 201103L
|
||||||
PassedByValue(PassedByValue &&other) noexcept { val = other.val; if (debug) cout << "PassedByValue(PassedByValue &&)" << " " << this << endl; Counter::move_constructor++; }
|
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 (debug) cout << "operator=(PassedByValue &&)" << " " << this << endl; Counter::move_assignment++; return *this; }
|
PassedByValue & operator=(PassedByValue &&other) noexcept { val = other.val; if (trace) cout << "operator=(PassedByValue &&)" << " " << this << endl; Counter::move_assignment++; return *this; }
|
||||||
~PassedByValue() { if (debug) cout << "~PassedByValue()" << " " << this << endl; Counter::destructor++; }
|
~PassedByValue() { if (trace) cout << "~PassedByValue()" << " " << this << endl; Counter::destructor++; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int getVal() { return val; }
|
int getVal() { return val; }
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package main
|
||||||
import . "swigtests/typemap_out_optimal"
|
import . "swigtests/typemap_out_optimal"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
SetXXDebug(false)
|
SetXXTrace(false)
|
||||||
_ = XXCreate()
|
_ = XXCreate()
|
||||||
_ = XXCreateConst()
|
_ = XXCreateConst()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ public class typemap_out_optimal_runme {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String argv[]) {
|
public static void main(String argv[]) {
|
||||||
XX.setDebug(false);
|
XX.setTrace(false);
|
||||||
{
|
{
|
||||||
XX x = XX.create();
|
XX x = XX.create();
|
||||||
x.delete();
|
x.delete();
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
bool debug = false;
|
bool trace = false;
|
||||||
|
|
||||||
void show_wstring_bytes(const std::wstring &s) {
|
void show_wstring_bytes(const std::wstring &s) {
|
||||||
unsigned char *p = (unsigned char *)s.data();
|
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) {
|
std::wstring test_value(std::wstring x) {
|
||||||
if (debug) {
|
if (trace) {
|
||||||
std::wcout << "received(C++): " /*<< x */<< std::endl;
|
std::wcout << "received(C++): " /*<< x */<< std::endl;
|
||||||
show_wstring_bytes(x);
|
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) {
|
bool test_equal(const wchar_t *wcs, const std::wstring& s) {
|
||||||
if (debug) {
|
if (trace) {
|
||||||
show_wstring_bytes(wcs);
|
show_wstring_bytes(wcs);
|
||||||
show_wstring_bytes(s);
|
show_wstring_bytes(s);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,13 @@ def check(p):
|
||||||
if msg != "hi there":
|
if msg != "hi there":
|
||||||
raise RuntimeError("Bad, got: " + msg)
|
raise RuntimeError("Bad, got: " + msg)
|
||||||
|
|
||||||
python_pickle.cvar.debug = False
|
python_pickle.cvar.trace = False
|
||||||
|
|
||||||
p = python_pickle.PickleMe("hi there")
|
p = python_pickle.PickleMe("hi there")
|
||||||
check(p)
|
check(p)
|
||||||
|
|
||||||
r = p.__reduce__()
|
r = p.__reduce__()
|
||||||
if python_pickle.cvar.debug:
|
if python_pickle.cvar.trace:
|
||||||
print("__reduce__ returned: {}".format(r))
|
print("__reduce__ returned: {}".format(r))
|
||||||
pickle_string = pickle.dumps(p)
|
pickle_string = pickle.dumps(p)
|
||||||
newp = pickle.loads(pickle_string)
|
newp = pickle.loads(pickle_string)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
from typemap_out_optimal import *
|
from typemap_out_optimal import *
|
||||||
|
|
||||||
cvar.XX_debug = False
|
cvar.XX_trace = False
|
||||||
x = XX.create()
|
x = XX.create()
|
||||||
del x
|
del x
|
||||||
x = XX.createConst()
|
x = XX.createConst()
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ def __reduce__(self):
|
||||||
#else
|
#else
|
||||||
// Equivalent to Python code above
|
// Equivalent to Python code above
|
||||||
PyObject *__reduce__() {
|
PyObject *__reduce__() {
|
||||||
if (debug)
|
if (trace)
|
||||||
std::cout << "In C++ __reduce__" << std::endl;
|
std::cout << "In C++ __reduce__" << std::endl;
|
||||||
PyObject *args = PyTuple_New(1);
|
PyObject *args = PyTuple_New(1);
|
||||||
PyTuple_SetItem(args, 0, SWIG_From_std_string(self->msg));
|
PyTuple_SetItem(args, 0, SWIG_From_std_string(self->msg));
|
||||||
|
|
@ -39,12 +39,12 @@ def __reduce__(self):
|
||||||
%inline %{
|
%inline %{
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
bool debug = false;
|
bool trace = false;
|
||||||
|
|
||||||
struct PickleMe {
|
struct PickleMe {
|
||||||
std::string msg;
|
std::string msg;
|
||||||
PickleMe(const std::string& msg) : msg(msg) {
|
PickleMe(const std::string& msg) : msg(msg) {
|
||||||
if (debug)
|
if (trace)
|
||||||
std::cout << "In C++ constructor " << " [" << msg << "]" << std::endl;
|
std::cout << "In C++ constructor " << " [" << msg << "]" << std::endl;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -18,20 +18,16 @@
|
||||||
|
|
||||||
%ignore XX::operator=;
|
%ignore XX::operator=;
|
||||||
|
|
||||||
#ifdef SWIGD
|
|
||||||
%rename(trace) XX::debug;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
struct XX {
|
struct XX {
|
||||||
XX() { if (debug) cout << "XX()" << endl; }
|
XX() { if (trace) cout << "XX()" << endl; }
|
||||||
XX(int i) { if (debug) cout << "XX(" << i << ")" << endl; }
|
XX(int i) { if (trace) cout << "XX(" << i << ")" << endl; }
|
||||||
XX(const XX &other) { if (debug) cout << "XX(const XX &)" << endl; }
|
XX(const XX &other) { if (trace) cout << "XX(const XX &)" << endl; }
|
||||||
XX& operator =(const XX &other) { if (debug) cout << "operator=(const XX &)" << endl; return *this; }
|
XX& operator =(const XX &other) { if (trace) cout << "operator=(const XX &)" << endl; return *this; }
|
||||||
~XX() { if (debug) cout << "~XX()" << endl; }
|
~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)
|
// 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() {
|
static XX create() {
|
||||||
|
|
@ -40,8 +36,8 @@ struct XX {
|
||||||
static const XX createConst() {
|
static const XX createConst() {
|
||||||
return XX(456);
|
return XX(456);
|
||||||
}
|
}
|
||||||
static bool debug;
|
static bool trace;
|
||||||
};
|
};
|
||||||
bool XX::debug = true;
|
bool XX::trace = true;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue