Skip to content

Commit

Permalink
Binding
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethassogba committed Nov 18, 2024
1 parent af339d8 commit 45fc447
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/demeter/binding/material.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#include <nanobind/nanobind.h>

int add(int a, int b) { return a + b; }
namespace nb = nanobind;
using namespace nb::literals;

NB_MODULE(my_ext, m) { m.def("add", &add); }
int add(int a, int b = 1) { return a + b; }

NB_MODULE(demeter_ext, m) {
m.doc() = "A simple example python extension";
m.def(
"add", &add, "a"_a, "b"_a = 1,
"This function adds two numbers and increments if only one is provided.");
m.attr("the_answer") = 42;
}

0 comments on commit 45fc447

Please sign in to comment.