<div dir="ltr">Hi All,<div><br></div><div>The MR for the VTK_EXPECTS hint is ready to merge.  To refresh your memory, this hint adds preconditions to VTK methods so that users are less likely to cause a segfault when they call VTK from a Python script or console:</div><div><br></div><div><div>  void SetTuple(vtkIdType tupleIdx, const double* tuple)</div><div>    VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples());</div></div><div><br></div><div>It is also used to check for null pointers.  Really, it can be check anything to do with the state of the object or the method args, as long as the information is available though the public API.  Failed checks cause a ValueError exception to be raised (which is, of course, much better than a segfault).</div><div><br></div><div><br></div><div>The next hint to be added will be VTK_SIZEHINT(), which is documented here:</div><div><a href="http://www.vtk.org/Wiki/VTK/Wrapping_hints">http://www.vtk.org/Wiki/VTK/Wrapping_hints</a><br></div><div><br></div><div>After some thought, I've decided that the cleanest place to add this hint is after the method declaration:</div><div><br></div><div>  double* GetPoint()</div><div>    VTK_SIZEHINT(3);<br></div><div><br></div><div>The hint takes one or two arguments.  With two arguments, the first arg is the name of the parameter to which the hint applies.  The second argument (the 'size') can be any C++ expression that evaluates to an integral type.  For example:</div><div><br></div><div><div>  void SetTuple(const double* tuple)</div><div>    VTK_SIZEHINT(tuple, GetNumberOfComponents());</div></div><div><br></div><div>  void InsertNextCell(vtkIdType n, vtkidType* ptIds)</div><div>    VTK_SIZEHINT(ptIds, n);</div><div><br></div><div>Since VTK_SIZEHINT is a variadic macro, it formally requires C++11, but compilers have supported variadic macros for a very, very long time so I don't expect this to be an issue.</div><div><br></div><div>Probably the most important use of VTK_SIZEHINT will be by people who wrap their own VTK classes but who don't want to mess around with VTK's hints file.</div><div><br></div><div><br></div><div>Some general info about hints:</div><div><br></div><div>- Any number of hints is allowed for a method. Hints are applied in the order in which they appear.</div><div><br></div><div>- Hints are inherited.  If you add a hint to a base class method, then the same hint applies to all methods that override the base class method.</div><div><br></div><div>Cheers,</div><div> - David</div></div>