Skip to content

Latest commit

 

History

History
61 lines (45 loc) · 1.09 KB

exports.md

File metadata and controls

61 lines (45 loc) · 1.09 KB

Exports

Declare your exports inside macro NAAH_REGISTRATION and use NAAH_EXPORT to register your native module.

NAAH_REGISTRATION {
  // ... your exports code
}

NAAH_EXPORT

Constant Value

NAAH_REGISTRATION {
  using reg = naah::Registration;

  reg::Value("num", 233);
  reg::Value("str", "hello world");
}

Function

uint32_t Add(uint32_t a, uint32_t b) { return a + b; }

NAAH_REGISTRATION {
  using reg = naah::Registration;

  reg::Function("add",
                [](uint32_t a, uint32_t b) -> uint32_t { return a + b; });
  reg::Function<Add>("addTpl");
}

For more information about function exports, see Function.

Class

class Calculator : public naah::Class {
 public:
  uint32_t _num;
  Calculator(uint32_t num): _num(num) {}
  uint32_t add(uint32_t num) {
    return _num + num;
  }
};

NAAH_REGISTRATION {
  using reg = naah::Registration;

  reg::Class<Calculator>("Calculator")
      .Constructor<uint32_t>()
      .InstanceMethod<&Calculator::add>("add")
}

For more information about class exports, see Class.