[vtk-developers] New way of doing wrapper hints
David Gobbi
david.gobbi at gmail.com
Mon Jun 6 12:45:26 EDT 2016
On Mon, Jun 6, 2016 at 9:12 AM, David Thompson <david.thompson at kitware.com>
wrote:
>
> 1. I assume that attributes are allowed prior to function parameters...
> from the spec it was not immediately obvious. For example, what about this
> method:
>
> VTK_SIZEHINT(sz) double* findOrAddEntries(
> int key, int sz, VTK_SIZEHINT(sz) double* vals);
>
> that both accepts and returns a variable-length array (of length sz, one
> of the other parameters)?
>
Yes, the hints can be used in either location. The hint attaches to the
type.
> 2. Would you put them in the declaration or implementation? I have a mild
> preference for the implementation so that the declaration is short and easy
> to skim.
>
The wrappers only see the declaration. They never see the .cxx file.
On Mon, Jun 6, 2016 at 9:13 AM, Brad King <brad.king at kitware.com> wrote:
>
>
> Neat. I suggest using a prefix like `VTK_HINT_` for all such macros,
> and corresponding attribute names with a prefix like `vtk::hint::`.
> That will reserve space for other attributes to be added later for
> reasons other than hints.
My preference is for "VTK_SIZEHINT" because it's easier to say... I can
ask Joe in the cubicle next me me "Hey Joe, what's the size hint for
that method?" In comparison, "VTK_HINT_SIZE" just doesn't roll off
the tongue. In all seriousness, though, I'll go with the latter if people
feel it's the better choice.
Regarding "vtk::hint::", in C++ Section 7.6.1 "Attribute syntax and
semantics", the grammar does not allow more than one "::". Apparently
attribute namespaces cannot be nested.
On Mon, Jun 6, 2016 at 10:03 AM, David Lonie <david.lonie at kitware.com>
wrote:
> +1 to the idea and Brad's suggestion!
>
Grumble.
> Does this sort of pattern occur in VTK a lot? AIUI, the current hints file
> only allows fixed-length arrays and is not dependent on other variables to
> get the size.
>
We want to allow more flexibility than what the current hints file offers.
For example, sometimes a size hint should refer to one of the object's
methods or even to one of the other parameters:
void InsertNextCell(int npts, VTK_SIZEHINT(npts) vtkIdType* conn)
void SetTuple(VTK_SIZEHINT(GetNumberOfComponents()) double* tuple);
Ideally, the size hint could be an expression that would be evaluated to
compute the size. There would be some limitations, of course, but
there are tons of possibilities.
- David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20160606/98088ce5/attachment.html>
More information about the vtk-developers
mailing list