Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add C-C++ Interoperability tutorial in CppInterOp docs #121

Merged
merged 1 commit into from Aug 12, 2023

Conversation

Krishna-13-cyber
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Aug 7, 2023

Codecov Report

Merging #121 (4835e89) into main (7d98dc2) will increase coverage by 0.28%.
Report is 4 commits behind head on main.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #121      +/-   ##
==========================================
+ Coverage   62.91%   63.19%   +0.28%     
==========================================
  Files          15       16       +1     
  Lines        4061     4103      +42     
==========================================
+ Hits         2555     2593      +38     
- Misses       1506     1510       +4     

see 5 files with indirect coverage changes

see 5 files with indirect coverage changes

Copy link
Contributor

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paying attention to the details is critical especially in writing documentation.

it will be used to store the instantiated template. The **InstantiationArgs**
is initialized to "A", it will be used as the argument when instantiating the template.
T is initialized to zero, used to store the declaration of the type "T" used for
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
T is initialized to zero, used to store the declaration of the type "T" used for
`T` is initialized to zero, used to store the declaration of the type "T" used for

Comment on lines 226 to 229
We take the first argument (argv[1]), parse it, then take the second argument
(argv[2]) using Clang_LookupName, and reassigns InstantiationArgs to the third
argument (argv[3]). In the else case, we decide to go with the "A".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This snippet checks command-line arguments were provided by the argc arguments.
We take the first argument (argv[1]), parse it, then take the second argument
(argv[2]) using Clang_LookupName, and reassigns InstantiationArgs to the third
argument (argv[3]). In the else case, we decide to go with the "A".
This snippet checks command-line arguments were provided by the `argc` arguments.
We take the first argument (`argv[1]`), parse it, then take the second argument
(`argv[2]`) using **Clang_LookupName**, and reassigns **InstantiationArgs** to the third
argument (`argv[3]`). In the else case, we decide to go with the "A".

Comment on lines 231 to 233
type, using the Clang_InstantiateTemplate function from the
library. The instantiated template is stored in the **Instantiation**.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The code proceeds to instantiate the template B::callme with the given
type, using the Clang_InstantiateTemplate function from the
library. The instantiated template is stored in the **Instantiation**.
The code proceeds to instantiate the template `B::callme` with the given
type, using the **Clang_InstantiateTemplate** function from the
library. The instantiated template is stored in the **Instantiation**.

Comment on lines 240 to 242
the function taking a void* argument and returning void. The result of
Clang_GetFunctionAddress is casted by the function pointer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A function pointer **callme_fn_ptr** is declared with a type fn_def that represents
the function taking a void* argument and returning void. The result of
Clang_GetFunctionAddress is casted by the function pointer.
A function pointer **callme_fn_ptr** is declared with a type `fn_def` that represents
the function taking a `void*` argument and returning void. The result of
**Clang_GetFunctionAddress** is casted by the function pointer.

Comment on lines 249 to 250
pointer to this object is stored in NewA.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The code then creates an object of type `A` using Clang_CreateObject, and the
pointer to this object is stored in NewA.
The code then creates an object of type `A` using **Clang_CreateObject**, and the
pointer to this object is stored in `NewA`.

Comment on lines 256 to 258
calls the member function B::callme with the instantiated type. Thus, the instantiation
happens with type `A` and we get the below result.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Then the function pointer callme_fn_ptr is called with the NewA, which
calls the member function B::callme with the instantiated type. Thus, the instantiation
happens with type `A` and we get the below result.
Then the function pointer `callme_fn_ptr` is called with the `NewA`, which
calls the member function `B::callme` with the instantiated type. Thus, the instantiation
happens with type `A` and we get the below result.

Copy link
Contributor

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@vgvassilev vgvassilev added this pull request to the merge queue Aug 12, 2023
Merged via the queue into compiler-research:main with commit 645a034 Aug 12, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants