| 1 |
# How to Add a Class in rocIsa |
| 2 |
|
| 3 |
1. Write a function as usual. |
| 4 |
|
| 5 |
```c++ |
| 6 |
void test(const std::string& name); |
| 7 |
``` |
| 8 |
|
| 9 |
2. Create a new cpp or use an existing cpp if your class is related to one of the files. |
| 10 |
3. Inside the cpp add the following code |
| 11 |
|
| 12 |
```c++ |
| 13 |
#include <nanobind/nanobind.h> |
| 14 |
#include <nanobind/stl/string.h> // Need to add this because test is using std::string |
| 15 |
|
| 16 |
namespace nb = nanobind; |
| 17 |
|
| 18 |
void init_test(nb::module_ m) |
| 19 |
{ |
| 20 |
m.def("test", &test); |
| 21 |
} |
| 22 |
``` |