LCOV - code coverage report
Current view: top level - examples/usercmodule/cppexample - example.cpp (source / functions) Hit Total Coverage
Test: unix_coverage_v1.19.1-740-gbf49a087b.info Lines: 8 8 100.0 %
Date: 2022-12-09 11:55:04 Functions: 2 2 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : extern "C" {
       2                 :            : #include <examplemodule.h>
       3                 :            : 
       4                 :            : // Here we implement the function using C++ code, but since it's
       5                 :            : // declaration has to be compatible with C everything goes in extern "C" scope.
       6                 :          2 : mp_obj_t cppfunc(mp_obj_t a_obj, mp_obj_t b_obj) {
       7                 :            :     // Prove we have (at least) C++11 features.
       8                 :          2 :     const auto a = mp_obj_get_int(a_obj);
       9                 :          2 :     const auto b = mp_obj_get_int(b_obj);
      10                 :          6 :     const auto sum = [&]() {
      11                 :          2 :         return mp_obj_new_int(a + b);
      12                 :          2 :     } ();
      13                 :            :     // Prove we're being scanned for QSTRs.
      14                 :          2 :     mp_obj_t tup[] = {sum, MP_ROM_QSTR(MP_QSTR_hellocpp)};
      15                 :          2 :     return mp_obj_new_tuple(2, tup);
      16                 :            : }
      17                 :            : }

Generated by: LCOV version 1.15-5-g462f71d