Skip to content

Commit 0d4ab93

Browse files
Krishna-13-cybervgvassilev
authored andcommitted
Add tutorial and other contents for CppInterOp Documentation
1 parent 486e7c3 commit 0d4ab93

6 files changed

+317
-27
lines changed

docs/DevelopersDocumentation.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Developers Documentation
44
Building from source
55
---------------------
66

7-
Clang-Repl
7+
CppInterOp
88
===========
99

1010
.. code-block:: bash
@@ -23,9 +23,6 @@ Clang-Repl
2323
2424
cmake --build . --target install
2525
26-
27-
CppInterOp is a C++ Language Interoperability Layer
28-
2926
CppInterOp Internal Documentation
3027
=================================
3128

docs/FAQ.rst

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,24 @@
11
FAQ
2-
*****
2+
----
3+
4+
1. **What is CppInterOp?**:
5+
6+
- CppInterOp is a Clang-based C++ Interoperability library.
7+
8+
2. **Why should you use CppInterOp?**:
9+
10+
- It can help you to integrate C++ code with other languages, which can make your
11+
code more portable and reusable.
12+
13+
- It can help you to prototype environments for C++, which can make it easier to
14+
experiment with new ideas and developments.
15+
16+
- It can help you to develop scientific applications that use C++ and other
17+
languages, which can make your applications more powerful and flexible.
18+
19+
3. **How can we integrate C++ code with other languages using CppInterOp?**:
20+
- You can refer the guides/tutorials here for:-
21+
22+
- Installation And Usage Guide-:doc:`Installation and usage <InstallationAndUsage>`
23+
24+
- Tutorials-:doc:`Tutorials <tutorials>`

docs/InstallationAndUsage.rst

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
InstallationAndUsage
22
---------------------
33

4-
54
Build cling with LLVM and clang:
65
===================================
76

@@ -29,41 +28,45 @@ Build cling with LLVM and clang:
2928
cmake --build . --target cling --parallel $(nproc --all)
3029
cmake --build . --target gtest_main --parallel $(nproc --all)
3130
32-
Note down the llvm-project directory location as we will need it later:
31+
Note down the llvm-project directory location as we will need it later:
3332
3433
cd ../
3534
export LLVM_DIR=$PWD
3635
cd ../
3736
38-
Clone the InterOp repo. Build it using cling and install. Note down the path to InterOp install directory. This will be referred to as INTEROP_DIR:
37+
# Clone the InterOp repo. Build it using cling and install.
38+
# Note down the path to InterOp install directory.
39+
# This will be referred to as INTEROP_DIR:
3940
4041
export INTEROP_DIR=$PWD/cppyy-backend/python/cppyy_backend
4142
git clone https://github.com/compiler-research/InterOp.git
4243
cd InterOp
4344
mkdir build && cd build
4445
INTEROP_BUILD_DIR=$(PWD)
45-
cmake -DBUILD_SHARED_LIBS=ON -DUSE_CLING=ON -DUSE_REPL=Off -DCling_DIR=$LLVM_DIR/build -DCMAKE_INSTALL_PREFIX=$INTEROP_DIR ..
46+
cmake -DBUILD_SHARED_LIBS=ON -DUSE_CLING=ON -DUSE_REPL=Off
47+
-DCling_DIR=$LLVM_DIR/build -DCMAKE_INSTALL_PREFIX=$INTEROP_DIR ..
4648
cmake --build . --target install
4749
4850
Build Clang-Repl:
4951
=================
5052

51-
.. code-block:: text
53+
.. code-block:: bash
5254
5355
54-
Get the llvm/release/16.x version:
56+
# Get the llvm/release/16.x version:
5557
git clone https://github.com/llvm/llvm-project.git
5658
git checkout release/16.x
5759
58-
Patches for development
59-
compgen -G "../patches/llvm/clang16-*.patch" > /dev/null && find ../patches/llvm/clang16-*.patch -printf "%f\n"
60+
# Patches for development
61+
compgen -G "../patches/llvm/clang16-*.patch" > /dev/null
62+
&& find ../patches/llvm/clang16-*.patch -printf "%f\n"
6063
&& git apply ../patches/llvm/clang16-*.patch
6164
6265
6366
mkdir build
6467
cd build
6568
66-
Build Clang-16 :
69+
# Build Clang-16 :
6770
6871
cmake -DLLVM_ENABLE_PROJECTS=clang \
6972
-DLLVM_TARGETS_TO_BUILD="host;NVPTX" \
@@ -79,12 +82,12 @@ Build Clang-Repl:
7982
8083
cmake --build . --target clang clang-repl --parallel $(nproc --all)
8184
82-
Note down the llvm-project directory location as we will need it later:
85+
# Note down the llvm-project directory location as we will need it later:
8386
cd ../
8487
export LLVM_DIR=$PWD
8588
cd ../
8689
87-
Export Commands:
90+
# Export Commands:
8891
export CB_PYTHON_DIR="$PWD/cppyy-backend/python"
8992
export INTEROP_DIR="$CB_PYTHON_DIR/cppyy_backend"
9093

docs/UsingCppInterOp.rst

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,71 @@
11
Using CppInterop
22
----------------
33

4-
This section briefly describes all the key functionalities offered by CppInterop.
5-
If you are just getting started with CppInterop, then this is the best place to start.
6-
You may want to skim some sections on the first read.
4+
C++ Language Interoperability Layer
5+
===================================
76

8-
In case you haven't installed CppInterop already, then please do before proceeding
9-
with this guide.
7+
The CppInterop comes with using it is a dynamic shared library,
8+
**libclangInterOp.so** which resides in the CppInterOp/build/lib/.
109

11-
Let's get started.
10+
.. code-block:: bash
1211
13-
C++ Language Interoperability Layer
14-
===================================
12+
libInterop = ctypes.CDLL("./libclangInterOp.so")
13+
14+
The above method of usage is for Python; for C, we can include the headers of
15+
the library. Including this library in our programme enables the user to use
16+
the abilities of CppInterOp. CppInterOp helps programmers with multiple
17+
verifications such as isClass, isBoolean, isStruct, and many more in different
18+
languages. With the interop layer, we can access the scopes, namespaces of
19+
classes and members that are being used. The interoperability layer helps us
20+
with the instantiation of templates, diagnostic interaction, creation of
21+
objects, and many more things.
22+
23+
This section briefly describes all the key **features** offered by
24+
CppInterop. If you are just getting started with CppInterop, then this is the
25+
best place to start.
26+
27+
Incremental Adoption
28+
====================
29+
CppInterOp can be adopted incrementally. While the rest of the framework is the
30+
same, a small part of CppInterOp can be utilized. More components may be
31+
adopted over time.
32+
33+
Minimalist by design
34+
====================
35+
While the library includes some tricky code, it is designed to be simple and
36+
robust (simple function calls, no inheritance, etc.). The goal is to make it as
37+
close to the compiler API as possible, and each routine should do just one thing.
38+
that it was designed for.
39+
40+
Further Enhancing the Dynamic/Automatic bindings in CPPYY
41+
=========================================================
42+
The main use case for CppInterOp is the CPPYY service. CPPYY is an
43+
automatic run-time bindings generator for Python and C++, and supports a wide
44+
range of C++ features (e.g., template instantiation). It operates on demand and
45+
generates only what is necessary. It requires a compiler (Cling or Clang-REPL).
46+
that can be available during programme runtime.
47+
48+
Once CppInterOp is integrated with LLVM's Clang-REPL component (that can then
49+
be used as a runtime compiler for CPPYY), it will further enhance CPPYY's
50+
performance in the following ways:
51+
52+
53+
**Simpler codebase:** The removal of string parsing logic will lead to a simpler
54+
code base.
55+
56+
**LLVM Integration:** The CppInterOp interfaces will be part of the LLVM
57+
toolchain (as part of Clang-REPL).
58+
59+
**Better C++ Support:** C++ features such as Partial Template Specialisation will
60+
be available through CppInterOp.
61+
62+
**Fewer Lines of Code:** A lot of dependencies and workarounds will be removed,
63+
reducing the lines of code required to execute CPPYY.
64+
65+
**Well tested interoperability Layer:** The CppInterOp interfaces have full
66+
unit test coverage.
1567

1668

69+
In case you haven't already installed CppInterop, please do so before proceeding
70+
with the Installation And Usage Guide.
71+
:doc:`Installation and usage <InstallationAndUsage>`

docs/reference.rst

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
11
Reference
22
---------
33

4-
5-
Add reference
4+
[1] Results of US Research Software Sustainability Institute (URSSI)
5+
programming language survey, private communication from Dan Katz (UIUC/NCSA),
6+
https://spectrum.ieee. org/computing/software/the-2017-top-programming-languages
7+
(Visited August 2021).
8+
9+
[2] Beazley, David M. “SWIG: An Easy to Use Tool for Integrating Scripting
10+
Languages with C and C++.” Tcl/Tk Workshop. Vol. 43. 1996.
11+
12+
[3] SIP software home page, https://www.riverbankcomputing.com/ software/sip/intro (Visited Sep 2021)
13+
14+
[4] Boost.Python Reference Manual (for software version 1.72),
15+
https: //www.boost.org/doc/libs/1_65_1/libs/python/doc/html/reference/index.html, (Visited August 2021)
16+
17+
[5] Pybind11 project homepage, http://pybind11.readthedocs.io/ (Visited August 2021).
18+
19+
[6] ​​Vassilev, Vassil, et al. “Cling–the new interactive interpreter for ROOT 6.
20+
” Journal of Physics: Conference Series. Vol. 396. No. 5. IOP Publishing, 2012.
21+
22+
[7] Cxx.jl GitHub repository, https://github.com/JuliaInterop/Cxx.jl (Visited September 2021)
23+
24+
[8] Wim Lavrijsen, cppyy, presentation, https://compiler-research.org/meetings/#caas_02Sep2021 (Visited September 2021)
25+
26+
[9] Cppyy Philosophy, https://cppyy.readthedocs.io/en/latest/philosophy.html#run-time-v-s-compile-time (Visited August 2021)
27+
28+
[10] Clang: a C language family frontend for LLVM, https://clang.llvm.org/, (Visited August 2021)
29+
30+
[11] Alexandru Militaru, Calling C++ libraries from a D-written DSL: A cling/cppyy-based approach, presentation,
31+
https://compiler-research.org/meetings/#caas_04Feb2021, (Visited August 2021)
32+
33+
[12] Keno Fischer, A brief history of Cxx.jl, https://compiler-research.org/meetings/#caas_05Aug2021, (Visited August 2021)
34+
35+
[13] Template instantiation not happening in indirectly called function,
36+
https://bitbucket.org/wlav/cppyy/issues/369/template-instantiation-not-happening-in (Visited August 2021).
37+
38+
[14] Extend clang AST to provide information for the type as written in template instantiations,
39+
https://llvm.org/OpenProjects.html#clang-template-instantiation-sugar (Visited August 2021).

0 commit comments

Comments
 (0)