2016-02-04 22:02:07 +00:00
|
|
|
|
15
|
|
|
|
|
5
|
Rename examples files, as per #288
This renames example files from `exampleN` to `example-description`.
Specifically, the following renaming is applied:
example1 -> example-methods-and-attributes
example2 -> example-python-types
example3 -> example-operator-overloading
example4 -> example-constants-and-functions
example5 -> example-callbacks (*)
example6 -> example-sequence-and-iterators
example7 -> example-buffers
example8 -> example-custom-ref-counting
example9 -> example-modules
example10 -> example-numpy-vectorize
example11 -> example-arg-keywords-and-defaults
example12 -> example-virtual-functions
example13 -> example-keep-alive
example14 -> example-opaque-types
example15 -> example-pickling
example16 -> example-inheritance
example17 -> example-stl-binders
example18 -> example-eval
example19 -> example-custom-exceptions
* the inheritance parts of example5 are moved into example-inheritance
(previously example16), and the remainder is left as example-callbacks.
This commit also renames the internal variables ("Example1",
"Example2", "Example4", etc.) into non-numeric names ("ExampleMandA",
"ExamplePythonTypes", "ExampleWithEnum", etc.) to correspond to the
file renaming.
The order of tests is preserved, but this can easily be changed if
there is some more natural ordering by updating the list in
examples/CMakeLists.txt.
2016-07-18 20:43:18 +00:00
|
|
|
|
example.ExamplePythonTypes: No constructor defined!
|
2016-02-04 22:02:07 +00:00
|
|
|
|
can't set attribute
|
Improve constructor/destructor tracking
This commit rewrites the examples that look for constructor/destructor
calls to do so via static variable tracking rather than output parsing.
The added ConstructorStats class provides methods to keep track of
constructors and destructors, number of default/copy/move constructors,
and number of copy/move assignments. It also provides a mechanism for
storing values (e.g. for value construction), and then allows all of
this to be checked at the end of a test by getting the statistics for a
C++ (or python mapping) class.
By not relying on the precise pattern of constructions/destructions,
but rather simply ensuring that every construction is matched with a
destruction on the same object, we ensure that everything that gets
created also gets destroyed as expected.
This replaces all of the various "std::cout << whatever" code in
constructors/destructors with
`print_created(this)`/`print_destroyed(this)`/etc. functions which
provide similar output, but now has a unified format across the
different examples, including a new ### prefix that makes mixed example
output and lifecycle events easier to distinguish.
With this change, relaxed mode is no longer needed, which enables
testing for proper destruction under MSVC, and under any other compiler
that generates code calling extra constructors, or optimizes away any
constructors. GCC/clang are used as the baseline for move
constructors; the tests are adapted to allow more move constructors to
be evoked (but other types are constructors much have matching counts).
This commit also disables output buffering of tests, as the buffering
sometimes results in C++ output ending up in the middle of python
output (or vice versa), depending on the OS/python version.
2016-08-07 17:05:26 +00:00
|
|
|
|
### ExamplePythonTypes @ 0x1045b80 created via new_instance
|
2015-11-30 11:30:28 +00:00
|
|
|
|
key: key2, value=value2
|
2015-10-01 14:48:34 +00:00
|
|
|
|
key: key, value=value
|
2016-02-04 22:02:07 +00:00
|
|
|
|
key: key, value=value
|
2015-07-05 18:05:44 +00:00
|
|
|
|
key: key2, value=value2
|
2015-11-14 18:04:49 +00:00
|
|
|
|
key: key3
|
2015-11-30 11:30:28 +00:00
|
|
|
|
key: key2
|
2015-11-14 18:04:49 +00:00
|
|
|
|
key: key1
|
2016-02-04 22:02:07 +00:00
|
|
|
|
key: key1
|
2015-11-14 18:04:49 +00:00
|
|
|
|
key: key2
|
|
|
|
|
key: key3
|
2015-07-05 18:05:44 +00:00
|
|
|
|
Entry at positon 0: value
|
|
|
|
|
list item 0: overwritten
|
|
|
|
|
list item 1: value2
|
|
|
|
|
list item 0: value
|
|
|
|
|
list item 1: value2
|
2016-02-07 15:36:26 +00:00
|
|
|
|
[u'array entry 1', u'array entry 2']
|
|
|
|
|
array item 0: array entry 1
|
|
|
|
|
array item 1: array entry 2
|
2015-07-05 18:05:44 +00:00
|
|
|
|
This exception was intentionally thrown.
|
2016-02-04 22:02:07 +00:00
|
|
|
|
(u'test', True)
|
|
|
|
|
(5L, u'test', True)
|
Rename examples files, as per #288
This renames example files from `exampleN` to `example-description`.
Specifically, the following renaming is applied:
example1 -> example-methods-and-attributes
example2 -> example-python-types
example3 -> example-operator-overloading
example4 -> example-constants-and-functions
example5 -> example-callbacks (*)
example6 -> example-sequence-and-iterators
example7 -> example-buffers
example8 -> example-custom-ref-counting
example9 -> example-modules
example10 -> example-numpy-vectorize
example11 -> example-arg-keywords-and-defaults
example12 -> example-virtual-functions
example13 -> example-keep-alive
example14 -> example-opaque-types
example15 -> example-pickling
example16 -> example-inheritance
example17 -> example-stl-binders
example18 -> example-eval
example19 -> example-custom-exceptions
* the inheritance parts of example5 are moved into example-inheritance
(previously example16), and the remainder is left as example-callbacks.
This commit also renames the internal variables ("Example1",
"Example2", "Example4", etc.) into non-numeric names ("ExampleMandA",
"ExamplePythonTypes", "ExampleWithEnum", etc.) to correspond to the
file renaming.
The order of tests is preserved, but this can easily be changed if
there is some more natural ordering by updating the list in
examples/CMakeLists.txt.
2016-07-18 20:43:18 +00:00
|
|
|
|
Help on class ExamplePythonTypes in module example
|
2015-07-05 18:05:44 +00:00
|
|
|
|
|
Rename examples files, as per #288
This renames example files from `exampleN` to `example-description`.
Specifically, the following renaming is applied:
example1 -> example-methods-and-attributes
example2 -> example-python-types
example3 -> example-operator-overloading
example4 -> example-constants-and-functions
example5 -> example-callbacks (*)
example6 -> example-sequence-and-iterators
example7 -> example-buffers
example8 -> example-custom-ref-counting
example9 -> example-modules
example10 -> example-numpy-vectorize
example11 -> example-arg-keywords-and-defaults
example12 -> example-virtual-functions
example13 -> example-keep-alive
example14 -> example-opaque-types
example15 -> example-pickling
example16 -> example-inheritance
example17 -> example-stl-binders
example18 -> example-eval
example19 -> example-custom-exceptions
* the inheritance parts of example5 are moved into example-inheritance
(previously example16), and the remainder is left as example-callbacks.
This commit also renames the internal variables ("Example1",
"Example2", "Example4", etc.) into non-numeric names ("ExampleMandA",
"ExamplePythonTypes", "ExampleWithEnum", etc.) to correspond to the
file renaming.
The order of tests is preserved, but this can easily be changed if
there is some more natural ordering by updating the list in
examples/CMakeLists.txt.
2016-07-18 20:43:18 +00:00
|
|
|
|
class EExxaammpplleePPyytthhoonnTTyyppeess(__builtin__.object)
|
2015-10-01 14:48:34 +00:00
|
|
|
|
| Example 2 documentation
|
|
|
|
|
|
|
2015-07-05 18:05:44 +00:00
|
|
|
|
| Methods defined here:
|
|
|
|
|
|
|
2016-02-04 22:02:07 +00:00
|
|
|
|
| ____iinniitt____(...)
|
|
|
|
|
| x.__init__(...) initializes x; see help(type(x)) for signature
|
2015-07-05 18:05:44 +00:00
|
|
|
|
|
|
2016-02-07 15:36:26 +00:00
|
|
|
|
| ggeett__aarrrraayy(...)
|
|
|
|
|
|
|
2016-08-03 23:40:40 +00:00
|
|
|
|
| Signature : (example.ExamplePythonTypes) -> List[unicode[2]]
|
2016-02-07 15:36:26 +00:00
|
|
|
|
| Return a C++ array
|
|
|
|
|
|
|
2016-02-04 22:02:07 +00:00
|
|
|
|
| ggeett__ddiicctt(...)
|
Rename examples files, as per #288
This renames example files from `exampleN` to `example-description`.
Specifically, the following renaming is applied:
example1 -> example-methods-and-attributes
example2 -> example-python-types
example3 -> example-operator-overloading
example4 -> example-constants-and-functions
example5 -> example-callbacks (*)
example6 -> example-sequence-and-iterators
example7 -> example-buffers
example8 -> example-custom-ref-counting
example9 -> example-modules
example10 -> example-numpy-vectorize
example11 -> example-arg-keywords-and-defaults
example12 -> example-virtual-functions
example13 -> example-keep-alive
example14 -> example-opaque-types
example15 -> example-pickling
example16 -> example-inheritance
example17 -> example-stl-binders
example18 -> example-eval
example19 -> example-custom-exceptions
* the inheritance parts of example5 are moved into example-inheritance
(previously example16), and the remainder is left as example-callbacks.
This commit also renames the internal variables ("Example1",
"Example2", "Example4", etc.) into non-numeric names ("ExampleMandA",
"ExamplePythonTypes", "ExampleWithEnum", etc.) to correspond to the
file renaming.
The order of tests is preserved, but this can easily be changed if
there is some more natural ordering by updating the list in
examples/CMakeLists.txt.
2016-07-18 20:43:18 +00:00
|
|
|
|
| Signature : (example.ExamplePythonTypes) -> dict
|
2015-07-05 18:05:44 +00:00
|
|
|
|
|
|
|
|
|
|
| Return a Python dictionary
|
|
|
|
|
|
|
2016-02-04 22:02:07 +00:00
|
|
|
|
| ggeett__ddiicctt__22(...)
|
2015-07-05 18:05:44 +00:00
|
|
|
|
|
|
2016-08-03 23:40:40 +00:00
|
|
|
|
| Signature : (example.ExamplePythonTypes) -> Dict[unicode, unicode]
|
2015-07-05 18:05:44 +00:00
|
|
|
|
| Return a C++ dictionary
|
|
|
|
|
|
|
2016-02-04 22:02:07 +00:00
|
|
|
|
| ggeett__lliisstt(...)
|
Rename examples files, as per #288
This renames example files from `exampleN` to `example-description`.
Specifically, the following renaming is applied:
example1 -> example-methods-and-attributes
example2 -> example-python-types
example3 -> example-operator-overloading
example4 -> example-constants-and-functions
example5 -> example-callbacks (*)
example6 -> example-sequence-and-iterators
example7 -> example-buffers
example8 -> example-custom-ref-counting
example9 -> example-modules
example10 -> example-numpy-vectorize
example11 -> example-arg-keywords-and-defaults
example12 -> example-virtual-functions
example13 -> example-keep-alive
example14 -> example-opaque-types
example15 -> example-pickling
example16 -> example-inheritance
example17 -> example-stl-binders
example18 -> example-eval
example19 -> example-custom-exceptions
* the inheritance parts of example5 are moved into example-inheritance
(previously example16), and the remainder is left as example-callbacks.
This commit also renames the internal variables ("Example1",
"Example2", "Example4", etc.) into non-numeric names ("ExampleMandA",
"ExamplePythonTypes", "ExampleWithEnum", etc.) to correspond to the
file renaming.
The order of tests is preserved, but this can easily be changed if
there is some more natural ordering by updating the list in
examples/CMakeLists.txt.
2016-07-18 20:43:18 +00:00
|
|
|
|
| Signature : (example.ExamplePythonTypes) -> list
|
2015-07-05 18:05:44 +00:00
|
|
|
|
|
|
|
|
|
|
| Return a Python list
|
|
|
|
|
|
|
2016-02-04 22:02:07 +00:00
|
|
|
|
| ggeett__lliisstt__22(...)
|
2015-07-05 18:05:44 +00:00
|
|
|
|
|
|
2016-08-03 23:40:40 +00:00
|
|
|
|
| Signature : (example.ExamplePythonTypes) -> List[unicode]
|
2015-07-05 18:05:44 +00:00
|
|
|
|
| Return a C++ list
|
|
|
|
|
|
|
2016-02-04 22:02:07 +00:00
|
|
|
|
| ggeett__sseett(...)
|
Rename examples files, as per #288
This renames example files from `exampleN` to `example-description`.
Specifically, the following renaming is applied:
example1 -> example-methods-and-attributes
example2 -> example-python-types
example3 -> example-operator-overloading
example4 -> example-constants-and-functions
example5 -> example-callbacks (*)
example6 -> example-sequence-and-iterators
example7 -> example-buffers
example8 -> example-custom-ref-counting
example9 -> example-modules
example10 -> example-numpy-vectorize
example11 -> example-arg-keywords-and-defaults
example12 -> example-virtual-functions
example13 -> example-keep-alive
example14 -> example-opaque-types
example15 -> example-pickling
example16 -> example-inheritance
example17 -> example-stl-binders
example18 -> example-eval
example19 -> example-custom-exceptions
* the inheritance parts of example5 are moved into example-inheritance
(previously example16), and the remainder is left as example-callbacks.
This commit also renames the internal variables ("Example1",
"Example2", "Example4", etc.) into non-numeric names ("ExampleMandA",
"ExamplePythonTypes", "ExampleWithEnum", etc.) to correspond to the
file renaming.
The order of tests is preserved, but this can easily be changed if
there is some more natural ordering by updating the list in
examples/CMakeLists.txt.
2016-07-18 20:43:18 +00:00
|
|
|
|
| Signature : (example.ExamplePythonTypes) -> set
|
2015-11-14 18:04:49 +00:00
|
|
|
|
|
|
|
|
|
|
| Return a Python set
|
|
|
|
|
|
|
2016-02-04 22:02:07 +00:00
|
|
|
|
| ggeett__sseett22(...)
|
Rename examples files, as per #288
This renames example files from `exampleN` to `example-description`.
Specifically, the following renaming is applied:
example1 -> example-methods-and-attributes
example2 -> example-python-types
example3 -> example-operator-overloading
example4 -> example-constants-and-functions
example5 -> example-callbacks (*)
example6 -> example-sequence-and-iterators
example7 -> example-buffers
example8 -> example-custom-ref-counting
example9 -> example-modules
example10 -> example-numpy-vectorize
example11 -> example-arg-keywords-and-defaults
example12 -> example-virtual-functions
example13 -> example-keep-alive
example14 -> example-opaque-types
example15 -> example-pickling
example16 -> example-inheritance
example17 -> example-stl-binders
example18 -> example-eval
example19 -> example-custom-exceptions
* the inheritance parts of example5 are moved into example-inheritance
(previously example16), and the remainder is left as example-callbacks.
This commit also renames the internal variables ("Example1",
"Example2", "Example4", etc.) into non-numeric names ("ExampleMandA",
"ExamplePythonTypes", "ExampleWithEnum", etc.) to correspond to the
file renaming.
The order of tests is preserved, but this can easily be changed if
there is some more natural ordering by updating the list in
examples/CMakeLists.txt.
2016-07-18 20:43:18 +00:00
|
|
|
|
| Signature : (example.ExamplePythonTypes) -> set
|
2015-11-14 18:04:49 +00:00
|
|
|
|
|
|
|
|
|
|
| Return a C++ set
|
|
|
|
|
|
|
2016-02-04 22:02:07 +00:00
|
|
|
|
| ppaaiirr__ppaasssstthhrroouugghh(...)
|
2015-07-05 18:05:44 +00:00
|
|
|
|
|
|
2016-08-03 23:40:40 +00:00
|
|
|
|
| Signature : (example.ExamplePythonTypes, Tuple[bool, unicode]) -> Tuple[unicode, bool]
|
2015-07-05 18:05:44 +00:00
|
|
|
|
| Return a pair in reversed order
|
|
|
|
|
|
|
2016-02-07 15:36:26 +00:00
|
|
|
|
| pprriinntt__aarrrraayy(...)
|
|
|
|
|
|
|
2016-08-03 23:40:40 +00:00
|
|
|
|
| Signature : (example.ExamplePythonTypes, List[unicode[2]]) -> None
|
2016-02-07 15:36:26 +00:00
|
|
|
|
| Print entries of a C++ array
|
|
|
|
|
|
|
2016-02-04 22:02:07 +00:00
|
|
|
|
| pprriinntt__ddiicctt(...)
|
2015-07-05 18:05:44 +00:00
|
|
|
|
|
|
2016-08-03 23:40:40 +00:00
|
|
|
|
| Signature : (example.ExamplePythonTypes, dict) -> None
|
2015-07-05 18:05:44 +00:00
|
|
|
|
| Print entries of a Python dictionary
|
|
|
|
|
|
|
2016-02-04 22:02:07 +00:00
|
|
|
|
| pprriinntt__ddiicctt__22(...)
|
2015-07-05 18:05:44 +00:00
|
|
|
|
|
|
2016-08-03 23:40:40 +00:00
|
|
|
|
| Signature : (example.ExamplePythonTypes, Dict[unicode, unicode]) -> None
|
2015-07-05 18:05:44 +00:00
|
|
|
|
| Print entries of a C++ dictionary
|
|
|
|
|
|
|
2016-02-04 22:02:07 +00:00
|
|
|
|
| pprriinntt__lliisstt(...)
|
2015-07-05 18:05:44 +00:00
|
|
|
|
|
|
2016-08-03 23:40:40 +00:00
|
|
|
|
| Signature : (example.ExamplePythonTypes, list) -> None
|
2015-07-05 18:05:44 +00:00
|
|
|
|
| Print entries of a Python list
|
|
|
|
|
|
|
2016-02-04 22:02:07 +00:00
|
|
|
|
| pprriinntt__lliisstt__22(...)
|
2015-07-05 18:05:44 +00:00
|
|
|
|
|
|
2016-08-03 23:40:40 +00:00
|
|
|
|
| Signature : (example.ExamplePythonTypes, List[unicode]) -> None
|
2015-07-05 18:05:44 +00:00
|
|
|
|
| Print entries of a C++ list
|
|
|
|
|
|
|
2016-02-04 22:02:07 +00:00
|
|
|
|
| pprriinntt__sseett(...)
|
2015-11-14 18:04:49 +00:00
|
|
|
|
|
|
2016-08-03 23:40:40 +00:00
|
|
|
|
| Signature : (example.ExamplePythonTypes, set) -> None
|
2015-11-14 18:04:49 +00:00
|
|
|
|
| Print entries of a Python set
|
|
|
|
|
|
|
2016-02-04 22:02:07 +00:00
|
|
|
|
| pprriinntt__sseett__22(...)
|
2015-11-14 18:04:49 +00:00
|
|
|
|
|
|
2016-08-03 23:40:40 +00:00
|
|
|
|
| Signature : (example.ExamplePythonTypes, Set[unicode]) -> None
|
2015-11-14 18:04:49 +00:00
|
|
|
|
| Print entries of a C++ set
|
|
|
|
|
|
|
2016-02-04 22:02:07 +00:00
|
|
|
|
| tthhrrooww__eexxcceeppttiioonn(...)
|
2015-07-05 18:05:44 +00:00
|
|
|
|
|
|
2016-08-03 23:40:40 +00:00
|
|
|
|
| Signature : (example.ExamplePythonTypes) -> None
|
2015-07-05 18:05:44 +00:00
|
|
|
|
| Throw an exception
|
|
|
|
|
|
|
2016-02-04 22:02:07 +00:00
|
|
|
|
| ttuuppllee__ppaasssstthhrroouugghh(...)
|
2015-07-05 18:05:44 +00:00
|
|
|
|
|
|
2016-08-03 23:40:40 +00:00
|
|
|
|
| Signature : (example.ExamplePythonTypes, Tuple[bool, unicode, int]) -> Tuple[int, unicode, bool]
|
2015-07-05 18:05:44 +00:00
|
|
|
|
| Return a triple in reversed order
|
|
|
|
|
|
|
|
|
|
|
| ----------------------------------------------------------------------
|
|
|
|
|
| Data and other attributes defined here:
|
|
|
|
|
|
|
Rename examples files, as per #288
This renames example files from `exampleN` to `example-description`.
Specifically, the following renaming is applied:
example1 -> example-methods-and-attributes
example2 -> example-python-types
example3 -> example-operator-overloading
example4 -> example-constants-and-functions
example5 -> example-callbacks (*)
example6 -> example-sequence-and-iterators
example7 -> example-buffers
example8 -> example-custom-ref-counting
example9 -> example-modules
example10 -> example-numpy-vectorize
example11 -> example-arg-keywords-and-defaults
example12 -> example-virtual-functions
example13 -> example-keep-alive
example14 -> example-opaque-types
example15 -> example-pickling
example16 -> example-inheritance
example17 -> example-stl-binders
example18 -> example-eval
example19 -> example-custom-exceptions
* the inheritance parts of example5 are moved into example-inheritance
(previously example16), and the remainder is left as example-callbacks.
This commit also renames the internal variables ("Example1",
"Example2", "Example4", etc.) into non-numeric names ("ExampleMandA",
"ExamplePythonTypes", "ExampleWithEnum", etc.) to correspond to the
file renaming.
The order of tests is preserved, but this can easily be changed if
there is some more natural ordering by updating the list in
examples/CMakeLists.txt.
2016-07-18 20:43:18 +00:00
|
|
|
|
| ____nneeww____ = <built-in method __new__ of example.ExamplePythonTypes__Meta object>
|
2016-02-04 22:02:07 +00:00
|
|
|
|
| T.__new__(S, ...) -> a new object with type S, a subtype of T
|
|
|
|
|
|
|
|
|
|
|
| nneeww__iinnssttaannccee = <built-in method new_instance of PyCapsule object>
|
Rename examples files, as per #288
This renames example files from `exampleN` to `example-description`.
Specifically, the following renaming is applied:
example1 -> example-methods-and-attributes
example2 -> example-python-types
example3 -> example-operator-overloading
example4 -> example-constants-and-functions
example5 -> example-callbacks (*)
example6 -> example-sequence-and-iterators
example7 -> example-buffers
example8 -> example-custom-ref-counting
example9 -> example-modules
example10 -> example-numpy-vectorize
example11 -> example-arg-keywords-and-defaults
example12 -> example-virtual-functions
example13 -> example-keep-alive
example14 -> example-opaque-types
example15 -> example-pickling
example16 -> example-inheritance
example17 -> example-stl-binders
example18 -> example-eval
example19 -> example-custom-exceptions
* the inheritance parts of example5 are moved into example-inheritance
(previously example16), and the remainder is left as example-callbacks.
This commit also renames the internal variables ("Example1",
"Example2", "Example4", etc.) into non-numeric names ("ExampleMandA",
"ExamplePythonTypes", "ExampleWithEnum", etc.) to correspond to the
file renaming.
The order of tests is preserved, but this can easily be changed if
there is some more natural ordering by updating the list in
examples/CMakeLists.txt.
2016-07-18 20:43:18 +00:00
|
|
|
|
| Signature : () -> example.ExamplePythonTypes
|
2016-02-04 22:02:07 +00:00
|
|
|
|
|
|
|
|
|
|
| Return an instance
|
2015-07-05 18:05:44 +00:00
|
|
|
|
|
2016-02-04 22:02:07 +00:00
|
|
|
|
__name__(example) = example
|
Rename examples files, as per #288
This renames example files from `exampleN` to `example-description`.
Specifically, the following renaming is applied:
example1 -> example-methods-and-attributes
example2 -> example-python-types
example3 -> example-operator-overloading
example4 -> example-constants-and-functions
example5 -> example-callbacks (*)
example6 -> example-sequence-and-iterators
example7 -> example-buffers
example8 -> example-custom-ref-counting
example9 -> example-modules
example10 -> example-numpy-vectorize
example11 -> example-arg-keywords-and-defaults
example12 -> example-virtual-functions
example13 -> example-keep-alive
example14 -> example-opaque-types
example15 -> example-pickling
example16 -> example-inheritance
example17 -> example-stl-binders
example18 -> example-eval
example19 -> example-custom-exceptions
* the inheritance parts of example5 are moved into example-inheritance
(previously example16), and the remainder is left as example-callbacks.
This commit also renames the internal variables ("Example1",
"Example2", "Example4", etc.) into non-numeric names ("ExampleMandA",
"ExamplePythonTypes", "ExampleWithEnum", etc.) to correspond to the
file renaming.
The order of tests is preserved, but this can easily be changed if
there is some more natural ordering by updating the list in
examples/CMakeLists.txt.
2016-07-18 20:43:18 +00:00
|
|
|
|
__name__(example.ExamplePythonTypes) = ExamplePythonTypes
|
|
|
|
|
__module__(example.ExamplePythonTypes) = example
|
|
|
|
|
__name__(example.ExamplePythonTypes.get_set) = get_set
|
|
|
|
|
__module__(example.ExamplePythonTypes.get_set) = example
|
Improve constructor/destructor tracking
This commit rewrites the examples that look for constructor/destructor
calls to do so via static variable tracking rather than output parsing.
The added ConstructorStats class provides methods to keep track of
constructors and destructors, number of default/copy/move constructors,
and number of copy/move assignments. It also provides a mechanism for
storing values (e.g. for value construction), and then allows all of
this to be checked at the end of a test by getting the statistics for a
C++ (or python mapping) class.
By not relying on the precise pattern of constructions/destructions,
but rather simply ensuring that every construction is matched with a
destruction on the same object, we ensure that everything that gets
created also gets destroyed as expected.
This replaces all of the various "std::cout << whatever" code in
constructors/destructors with
`print_created(this)`/`print_destroyed(this)`/etc. functions which
provide similar output, but now has a unified format across the
different examples, including a new ### prefix that makes mixed example
output and lifecycle events easier to distinguish.
With this change, relaxed mode is no longer needed, which enables
testing for proper destruction under MSVC, and under any other compiler
that generates code calling extra constructors, or optimizes away any
constructors. GCC/clang are used as the baseline for move
constructors; the tests are adapted to allow more move constructors to
be evoked (but other types are constructors much have matching counts).
This commit also disables output buffering of tests, as the buffering
sometimes results in C++ output ending up in the middle of python
output (or vice versa), depending on the OS/python version.
2016-08-07 17:05:26 +00:00
|
|
|
|
Instances not destroyed: 1
|
|
|
|
|
### ExamplePythonTypes @ 0x1045b80 destroyed
|
|
|
|
|
Instances not destroyed: 0
|