VTK  9.6.20260621
vtkWrappingHints.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
10
11#ifndef vtkWrappingHints_h
12#define vtkWrappingHints_h
13
14// When using Clang frontend, define VTK_WRAP_HINTS_USE_CLANG_ANNOTATE to use
15// the annotate attribute instead of VTK custom C++ attributes.
16// This is useful for external clang-based tool,
17// since Clang will remove unknown attributes from its AST.
18// When VTK_WRAP_HINTS_USE_CLANG_ANNOTATE is defined,
19// `[[vtk::attr(value)]]` will become `annotate("vtk::attr(value)")`,
20// which will appear as `AnnotateAttr "vtk::attr(value)"` in the AST.
21#ifdef VTK_WRAP_HINTS_USE_CLANG_ANNOTATE
22#define VTK_DEFINE_WRAP_HINT(name) __attribute__((annotate(#name)))
23#define VTK_DEFINE_WRAP_HINT_ARGS(name, ...) __attribute__((annotate(#name "(" #__VA_ARGS__ ")")))
24#else
25#define VTK_DEFINE_WRAP_HINT(name) [[name]]
26#define VTK_DEFINE_WRAP_HINT_ARGS(name, ...) [[name(__VA_ARGS__)]]
27#endif
28
29#ifdef __VTK_WRAP__
30#define VTK_WRAP_HINTS_DEFINED
31// Exclude a method or class from wrapping
32#define VTK_WRAPEXCLUDE VTK_DEFINE_WRAP_HINT(vtk::wrapexclude)
33// Exclude a method or class from JavaScript wrapping
34#ifdef __EMSCRIPTEN__
35#define VTK_WRAPEXCLUDE_JAVASCRIPT VTK_WRAPEXCLUDE
36#else
37#define VTK_WRAPEXCLUDE_JAVASCRIPT
38#endif
39// Tell wrappers not to associate this method with any property.
40#define VTK_PROPEXCLUDE VTK_DEFINE_WRAP_HINT(vtk::propexclude)
41// The return value points to a newly-created VTK object.
42#define VTK_NEWINSTANCE VTK_DEFINE_WRAP_HINT(vtk::newinstance)
43// The parameter is a pointer to a zerocopy buffer.
44#define VTK_ZEROCOPY VTK_DEFINE_WRAP_HINT(vtk::zerocopy)
45// The parameter is a path on the filesystem.
46#define VTK_FILEPATH VTK_DEFINE_WRAP_HINT(vtk::filepath)
47// Release Python GIL for the duration of the call
48#define VTK_UNBLOCKTHREADS VTK_DEFINE_WRAP_HINT(vtk::unblockthreads)
49// Set preconditions for a function
50#define VTK_EXPECTS(x) VTK_DEFINE_WRAP_HINT_ARGS(vtk::expects, x)
51// Set size hint for parameter or return value
52#define VTK_SIZEHINT(...) VTK_DEFINE_WRAP_HINT_ARGS(vtk::sizehint, __VA_ARGS__)
53// Opt-in a class for automatic code generation of (de)serializers.
54#define VTK_MARSHALAUTO VTK_DEFINE_WRAP_HINT(vtk::marshalauto)
55// Specifies that a class has hand written (de)serializers.
56#define VTK_MARSHALMANUAL VTK_DEFINE_WRAP_HINT(vtk::marshalmanual)
57// Excludes a function from the auto-generated (de)serialization process.
58#define VTK_MARSHALEXCLUDE(reason) VTK_DEFINE_WRAP_HINT_ARGS(vtk::marshalexclude, reason)
59// Enforces a function as the getter for `property`
60#define VTK_MARSHALGETTER(property) VTK_DEFINE_WRAP_HINT_ARGS(vtk::marshalgetter, #property)
61// Enforces a function as the setter for `property`
62#define VTK_MARSHALSETTER(property) VTK_DEFINE_WRAP_HINT_ARGS(vtk::marshalsetter, #property)
63#endif
64
65#ifndef VTK_WRAP_HINTS_DEFINED
66#define VTK_WRAPEXCLUDE
67#define VTK_WRAPEXCLUDE_JAVASCRIPT
68#define VTK_PROPEXCLUDE
69#define VTK_NEWINSTANCE
70#define VTK_ZEROCOPY
71#define VTK_FILEPATH
72#define VTK_UNBLOCKTHREADS
73#define VTK_EXPECTS(x)
74#define VTK_SIZEHINT(...)
75#define VTK_MARSHALAUTO
76#define VTK_MARSHALMANUAL
77#define VTK_MARSHALEXCLUDE(reason)
78#define VTK_MARSHALGETTER(property)
79#define VTK_MARSHALSETTER(property)
80#endif
81
82#define VTK_MARSHAL_EXCLUDE_REASON_IS_REDUNDANT "is redundant"
83#define VTK_MARSHAL_EXCLUDE_REASON_IS_INTERNAL "is internal"
84#define VTK_MARSHAL_EXCLUDE_REASON_NOT_SUPPORTED \
85 "(de)serialization is not supported for this type of property"
86
87#endif
88// VTK-HeaderTest-Exclude: vtkWrappingHints.h