Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

squash PR #24

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ matrix:
# echo "run-clang-tidy-3.9.py -j4 -clang-tidy-binary $(which clang-tidy-3.9) -checks=-*,clang-analyzer-* $FILES_REGEX"
# run-clang-tidy-3.9.py -j4 -clang-tidy-binary $(which clang-tidy-3.9) -checks=-*,clang-analyzer-* $FILES_REGEX
# fi

on_failure: echo "Showing current directory contents" && ls -la
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ if(cxxmodules)
# including <cassert> still manages to respect NDEBUG properly.
CHECK_CXX_SOURCE_COMPILES("#undef NDEBUG
#include <cassert>
#define NDEBUG
#define NEBUG
#include <cassert>
int main() { assert(this code is not compiled); }"
CXX_SUPPORTS_MODULES)
Expand Down
11 changes: 1 addition & 10 deletions bindings/jupyroot/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,7 @@ foreach(val RANGE ${how_many_pythons})
target_link_libraries(${libname} PUBLIC -Wl,--unresolved-symbols=ignore-all Core)
endif()

target_include_directories(${libname} PRIVATE ${python_include_dir})

# Disables warnings originating from deprecated register keyword in Python
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_STANDARD GREATER_EQUAL 11)
target_compile_options(${libname} PRIVATE -Wno-register)
endif()
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND CMAKE_CXX_STANDARD GREATER_EQUAL 11)
target_compile_options(${libname} PRIVATE -Wno-register)
target_compile_options(${libname} PRIVATE -Wno-deprecated-register)
endif()
target_include_directories(${libname} SYSTEM PRIVATE ${python_include_dir})

# Compile .py files
foreach(py_source ${py_sources})
Expand Down
13 changes: 3 additions & 10 deletions bindings/pyroot/cppyy/CPyCppyy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,26 +82,19 @@ foreach(val RANGE ${how_many_pythons})
target_compile_options(${libname} PRIVATE -Wno-cast-function-type)
endif()

# Disables warnings originating from deprecated register keyword in Python
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_STANDARD GREATER_EQUAL 11)
target_compile_options(${libname} PRIVATE -Wno-register)
endif()
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND CMAKE_CXX_STANDARD GREATER_EQUAL 11)
target_compile_options(${libname} PRIVATE -Wno-register)
target_compile_options(${libname} PRIVATE -Wno-deprecated-register)
endif()

# Disables warnings due to new field tp_vectorcall in Python 3.8
if(NOT MSVC AND ${python_version_string} VERSION_GREATER_EQUAL "3.8")
target_compile_options(${libname} PRIVATE -Wno-missing-field-initializers)
endif()

target_include_directories(${libname}
SYSTEM PUBLIC ${python_include_dir})

target_include_directories(${libname}
PRIVATE
${CMAKE_SOURCE_DIR}/core/foundation/inc # needed for string_view backport
${CMAKE_BINARY_DIR}/ginclude
PUBLIC
${python_include_dir}
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
)
Expand Down
100 changes: 61 additions & 39 deletions bindings/pyroot/cppyy/CPyCppyy/src/Pythonize.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -653,19 +653,38 @@ PyObject* MapContains(PyObject* self, PyObject* obj)
return result;
}


//- STL container iterator support --------------------------------------------
static const ptrdiff_t PS_END_ADDR = 7; // non-aligned address, so no clash
static const ptrdiff_t PS_FLAG_ADDR = 11; // id.
static const ptrdiff_t PS_COLL_ADDR = 13; // id.

PyObject* StlSequenceIter(PyObject* self)
{
// Implement python's __iter__ for std::iterator<>s
PyObject* iter = PyObject_CallMethodObjArgs(self, PyStrings::gBegin, nullptr);
if (iter) {
PyObject* end = PyObject_CallMethodObjArgs(self, PyStrings::gEnd, nullptr);
if (end)
PyObject_SetAttr(iter, PyStrings::gEnd, end);
Py_XDECREF(end);

// add iterated collection as attribute so its refcount stays >= 1 while it's being iterated over
PyObject_SetAttr(iter, CPyCppyy_PyText_FromString("_collection"), self);
if (end) {
if (CPPInstance_Check(iter)) {
// use the data member cache to store extra state on the iterator object,
// without it being visible on the Python side
auto& dmc = ((CPPInstance*)iter)->GetDatamemberCache();
dmc.push_back(std::make_pair(PS_END_ADDR, end));

// set a flag, indicating first iteration (reset in __next__)
Py_INCREF(Py_False);
dmc.push_back(std::make_pair(PS_FLAG_ADDR, Py_False));

// make sure the iterated over collection remains alive for the duration
Py_INCREF(self);
dmc.push_back(std::make_pair(PS_COLL_ADDR, self));
} else {
// could store "end" on the object's dictionary anyway, but if end() returns
// a user-customized object, then its __next__ is probably custom, too
Py_DECREF(end);
}
}
}
return iter;
}
Expand Down Expand Up @@ -856,44 +875,47 @@ Py_hash_t StlStringHash(PyObject* self)
PyObject* StlIterNext(PyObject* self)
{
// Python iterator protocol __next__ for STL forward iterators.
PyObject* next = nullptr;
PyObject* last = PyObject_GetAttr(self, PyStrings::gEnd);
bool mustIncrement = true;
PyObject* last = nullptr;
if (CPPInstance_Check(self)) {
auto& dmc = ((CPPInstance*)self)->GetDatamemberCache();
for (auto& p: dmc) {
if (p.first == PS_END_ADDR) {
last = p.second;
Py_INCREF(last);
} else if (p.first == PS_FLAG_ADDR) {
mustIncrement = p.second == Py_True;
if (!mustIncrement) {
Py_DECREF(p.second);
Py_INCREF(Py_True);
p.second = Py_True;
}
}
}
}

PyObject* next = nullptr;
if (last) {
// handle special case of empty container (i.e. self is end)
if (PyObject_RichCompareBool(last, self, Py_EQ) == 0) {
// first, get next from the _current_ iterator as internal state may change
// when call post or pre increment
next = PyObject_CallMethodObjArgs(self, PyStrings::gDeref, nullptr);
if (!next) PyErr_Clear();

// use postinc, even as the C++11 range-based for loops prefer preinc b/c
// that allows the current value from the iterator to be had from __deref__,
// an issue that does not come up in C++
static PyObject* dummy = PyInt_FromLong(1l);
PyObject* iter = PyObject_CallMethodObjArgs(self, PyStrings::gPostInc, dummy, nullptr);
if (!iter) {
// allow preinc, as in that case likely __deref__ is not defined and it
// is the iterator rather that is returned in the loop
PyErr_Clear();
iter = PyObject_CallMethodObjArgs(self, PyStrings::gPreInc, nullptr);
}
if (iter) {
// prefer != as per C++11 range-based for
int isNotEnd = PyObject_RichCompareBool(last, iter, Py_NE);
if (isNotEnd && !next) {
// if no dereference, continue iterating over the iterator
Py_INCREF(iter);
next = iter;
if (!PyObject_RichCompareBool(last, self, Py_EQ)) {
bool iter_valid = true;
if (mustIncrement) {
// prefer preinc, but allow post-inc; in both cases, it is "self" that has
// the updated state to dereference
PyObject* iter = PyObject_CallMethodObjArgs(self, PyStrings::gPreInc, nullptr);
if (!iter) {
PyErr_Clear();
static PyObject* dummy = PyInt_FromLong(1l);
iter = PyObject_CallMethodObjArgs(self, PyStrings::gPostInc, dummy, nullptr);
}
Py_DECREF(iter);
} else {
// fail current next, even if available
Py_XDECREF(next);
next = nullptr;
iter_valid = iter && PyObject_RichCompareBool(last, self, Py_NE);
Py_XDECREF(iter);
}

if (iter_valid) {
next = PyObject_CallMethodObjArgs(self, PyStrings::gDeref, nullptr);
if (!next) PyErr_Clear();
}
} else {
PyErr_SetString(PyExc_StopIteration, "");
}
Py_DECREF(last);
}
Expand Down
15 changes: 4 additions & 11 deletions bindings/pyroot/pythonizations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,23 +111,16 @@ foreach(val RANGE ${how_many_pythons})
endif()

target_include_directories(${libname}
PRIVATE ${python_include_dir}
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>)
SYSTEM PRIVATE ${python_include_dir})

target_include_directories(${libname}
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>)

# Disables warnings caused by Py_RETURN_TRUE/Py_RETURN_FALSE
if(NOT MSVC)
target_compile_options(${libname} PRIVATE -Wno-strict-aliasing)
endif()

# Disables warnings originating from deprecated register keyword in Python
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_STANDARD GREATER_EQUAL 11)
target_compile_options(${libname} PRIVATE -Wno-register)
endif()
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND CMAKE_CXX_STANDARD GREATER_EQUAL 11)
target_compile_options(${libname} PRIVATE -Wno-register)
target_compile_options(${libname} PRIVATE -Wno-deprecated-register)
endif()

# Compile .py files
foreach(py_source ${py_sources})
install(CODE "execute_process(COMMAND ${python_executable} -m py_compile ${localruntimedir}/${py_source})")
Expand Down
8 changes: 4 additions & 4 deletions core/base/src/TAttFill.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ attributes.
## Fill Area attributes
Fill Area attributes are:

- [Fill Area color](\ref F1)
- [Fill Area style](\ref F2)
- [Fill Area color](\ref ATTFILL1)
- [Fill Area style](\ref ATTFILL2)

\anchor F1
\anchor ATTFILL1
## Fill Area color
The fill area color is a color index (integer) pointing in the ROOT
color table.
Expand Down Expand Up @@ -104,7 +104,7 @@ If the current style fill area color is set to 0, then ROOT will force
a black&white output for all objects with a fill area defined and independently
of the object fill style.

\anchor F2
\anchor ATTFILL2
## Fill Area style
The fill area style defines the pattern used to fill a polygon.
The fill area style of any class inheriting from `TAttFill` can
Expand Down
12 changes: 6 additions & 6 deletions core/base/src/TAttLine.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ by many other classes (graphics, histograms). It holds all the line attributes.
## Line attributes
Line attributes are:

- [Line Color](\ref L1)
- [Line Width](\ref L2)
- [Line Style](\ref L3)
- [Line Color](\ref ATTLINE1)
- [Line Width](\ref ATTLINE2)
- [Line Style](\ref ATTLINE3)

\anchor L1
\anchor ATTLINE1
## Line Color
The line color is a color index (integer) pointing in the ROOT
color table.
Expand Down Expand Up @@ -69,7 +69,7 @@ in `$ROOTSYS/etc/system.rootrc`, or on Mac with the Cocoa backend. On the file o
it is visible with PDF, PNG, Gif, JPEG, SVG, TeX ... but not PostScript.


\anchor L2
\anchor ATTLINE2
## Line Width
The line width is expressed in pixel units.
The line width of any class inheriting from `TAttLine` can
Expand All @@ -93,7 +93,7 @@ Begin_Macro
}
End_Macro

\anchor L3
\anchor ATTLINE3
## Line Style
Line styles are identified via integer numbers. The line style of any class
inheriting from `TAttLine` can be changed using the method
Expand Down
12 changes: 6 additions & 6 deletions core/base/src/TAttMarker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ attributes.
## Marker attributes
The marker attributes are:

- [Marker color](\ref M1)
- [Marker style](\ref M2)
- [Marker line width](\ref M21)
- [Marker color](\ref ATTMARKER1)
- [Marker style](\ref ATTMARKER2)
- [Marker line width](\ref ATTMARKER21)
- [Marker size](\ref M3)

\anchor M1
\anchor ATTMARKER1
## Marker color
The marker color is a color index (integer) pointing in the ROOT color
table.
Expand Down Expand Up @@ -70,7 +70,7 @@ The transparency is available on all platforms when the flag `OpenGL.CanvasPrefe
in `$ROOTSYS/etc/system.rootrc`, or on Mac with the Cocoa backend. On the file output
it is visible with PDF, PNG, Gif, JPEG, SVG, TeX ... but not PostScript.

\anchor M2
\anchor ATTMARKER2
## Marker style

The Marker style defines the markers' shape.
Expand Down Expand Up @@ -134,7 +134,7 @@ Begin_Macro
}
End_Macro

\anchor M21
\anchor ATTMARKER21
### Marker line width

The line width of a marker is not actually a marker attribute since it does
Expand Down
34 changes: 17 additions & 17 deletions core/base/src/TAttText.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ by many other classes (graphics, histograms). It holds all the text attributes.
## Text attributes
Text attributes are:

- [Text Alignment](\ref T1)
- [Text Angle](\ref T2)
- [Text Color](\ref T3)
- [Text Size](\ref T4)
- [Text Font and Precision](\ref T5)
- [Font quality and speed](\ref T51)
- [How to use True Type Fonts](\ref T52)
- [List of the currently supported fonts](\ref T53)

\anchor T1
- [Text Alignment](\ref ATTTEXT1)
- [Text Angle](\ref ATTTEXT2)
- [Text Color](\ref ATTTEXT3)
- [Text Size](\ref ATTTEXT4)
- [Text Font and Precision](\ref ATTTEXT5)
- [Font quality and speed](\ref ATTTEXT51)
- [How to use True Type Fonts](\ref ATTTEXT52)
- [List of the currently supported fonts](\ref ATTTEXT53)

\anchor ATTTEXT1
## Text Alignment

The text alignment is an integer number (`align`) allowing to control
Expand Down Expand Up @@ -93,7 +93,7 @@ They allow to write:
object->SetTextAlign(kHAlignLeft+kVAlignTop);
~~~

\anchor T2
\anchor ATTTEXT2
## Text Angle

Text angle in degrees.
Expand All @@ -106,7 +106,7 @@ Begin_Macro(source)
textangle.C
End_Macro

\anchor T3
\anchor ATTTEXT3
## Text Color

The text color is a color index (integer) pointing in the ROOT
Expand Down Expand Up @@ -138,7 +138,7 @@ The transparency is available on all platforms when the flag `OpenGL.CanvasPrefe
in `$ROOTSYS/etc/system.rootrc`, or on Mac with the Cocoa backend. On the file output
it is visible with PDF, PNG, Gif, JPEG, SVG, TeX ... but not PostScript.

\anchor T4
\anchor ATTTEXT4
## Text Size

If the text precision (see next paragraph) is smaller than 3, the text
Expand Down Expand Up @@ -169,7 +169,7 @@ The text size of any class inheriting from `TAttText` can
be changed using the method `SetTextSize` and retrieved using the
method `GetTextSize`.

\anchor T5
\anchor ATTTEXT5
## Text Font and Precision

The text font code is combination of the font number and the precision.
Expand All @@ -190,7 +190,7 @@ The text font and precision of any class inheriting from `TAttText` can
be changed using the method `SetTextFont` and retrieved using the
method `GetTextFont`.

\anchor T51
\anchor ATTTEXT51
### Font quality and speed

When precision 0 is used, only the original non-scaled system fonts are
Expand All @@ -201,7 +201,7 @@ Precision 1 and 2 fonts have a different behaviour depending if the
True Type Fonts (TTF) are used or not. If TTF are used, you always get very good
quality scalable and rotatable fonts. However TTF are slow.

\anchor T52
\anchor ATTTEXT52
### How to use True Type Fonts

One can activate the TTF by adding (or activating) the following line
Expand All @@ -225,7 +225,7 @@ printout given by this command:
Unix.*.Root.UseTTFonts: true [Global]
~~~

\anchor T53
\anchor ATTTEXT53
### List of the currently supported fonts

~~~ {.cpp}
Expand Down
Loading