Skip to content

Commit ec388ad

Browse files
committed
[lldb][docs] Update SB API design document
The documentation should have been updated in 662548c. This updates it to be more accurate with the current design. Differential Revision: https://reviews.llvm.org/D150630
1 parent 631ff46 commit ec388ad

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

lldb/docs/design/sbapi.rst

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ lldb. As such it is important that they not suffer from the binary
77
incompatibilities that C++ is so susceptible to. We've established a few rules
88
to ensure that this happens.
99

10+
Extending the SB API
11+
--------------------
12+
1013
The classes in the SB API's are all called SB<SomeName>, where SomeName is in
1114
CamelCase starting with an upper case letter. The method names are all
1215
CamelCase with initial capital letter as well.
@@ -45,14 +48,29 @@ classes to report whether the object is empty or not.
4548

4649
Another piece of the SB API infrastructure is the Python (or other script
4750
interpreter) customization. SWIG allows you to add property access, iterators
48-
and documentation to classes, but to do that you have to use a Swig interface
49-
file in place of the .h file. Those files have a different format than a
50-
straight C++ header file. These files are called SB<ClassName>.i, and live in
51-
"scripts/interface". They are constructed by starting with the associated .h
52-
file, and adding documentation and the Python decorations, etc. We do this in a
53-
decidedly low-tech way, by maintaining the two files in parallel. That
54-
simplifies the build process, but it does mean that if you add a method to the
55-
C++ API's for an SB class, you have to copy the interface to the .i file.
51+
and documentation to classes. We place the property accessors and iterators in
52+
a file dedicated to extensions to existing SB classes at
53+
"bindings/interface/SB<ClassName>Extensions.i". The documentation is similarly
54+
located at "bindings/interface/SB<ClassName>Docstrings.i". These two files, in
55+
addition to the actual header SB<ClassName>.h, forms the interface that lldb
56+
exposes to users through the scripting languages.
57+
58+
There are some situations where you may want to add functionality to the SB API
59+
only for use in C++. To prevent SWIG from generating bindings to these
60+
functions, you can use a C macro guard, like so:
61+
62+
::
63+
64+
#ifndef SWIG
65+
int GetResourceCPPOnly() const;
66+
#endif
67+
68+
In this case, ``GetResourceCPPOnly`` will not be generated for Python or other
69+
scripting languages. If you wanted to add a resource specifically only for the
70+
SWIG case, you can invert the condition and use ``#ifdef SWIG`` instead. When
71+
building the LLDB framework for macOS, the headers are processed with
72+
``unifdef`` prior to being copied into the framework bundle to remove macros
73+
involving SWIG.
5674

5775
API Instrumentation
5876
-------------------

0 commit comments

Comments
 (0)