Skip to content

Commit

Permalink
extra_arg: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
melven authored and barche committed Jan 13, 2024
1 parent aac003c commit 100831a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ CppTypes.set(w, "hello")
```

The manually added constructor using the `constructor` function also creates a finalizer.
This can be disabled by adding the argument `false`:
This can be disabled by adding the argument `jlcxx::finalize_policy::no`:

```c++
types.add_type<World>("World")
.constructor<const std::string&>(false);
.constructor<const std::string&>(jlcxx::finalize_policy::no);
```

The `add_type` function actually builds two Julia types related to `World`.
Expand Down Expand Up @@ -648,10 +648,10 @@ The behavior of the macro can be customized by adding methods to `CxxWrap.refere
## Exceptions

When directly adding a regular free C++ function as a method, it will be called directly using `ccall` and any exception will abort the Julia program.
To avoid this, you can force wrapping it in an `std::function` to intercept the exception automatically by setting the `force_convert` argument to `method` to true:
To avoid this, you can force wrapping it in an `std::function` to intercept the exception automatically by setting the `jlcxx::calling_policy` argument to `std_function`:

```c++
mod.method("test_exception", test_exception, true);
mod.method("test_exception", test_exception, jlcxx::calling_policy::std_function);
```

Member functions and lambdas are automatically wrapped in an `std::function` and so any exceptions thrown there are always intercepted and converted to a Julia exception.
Expand Down

0 comments on commit 100831a

Please sign in to comment.