hello.cpp 425 B

123456789101112131415161718192021222324252627282930313233
  1. #include "hello.h"
  2. #include "module.h"
  3. #include "sol/sol.hpp"
  4. hello::hello()
  5. {
  6. }
  7. hello::~hello()
  8. {
  9. }
  10. std::string hello::name()
  11. {
  12. return "My name is `Fast Web`";
  13. }
  14. extern "C" {
  15. #ifdef _WIN32
  16. DLL_EXPORT
  17. #endif
  18. int fastweb_module_regist(void* sol2, void* lua)
  19. {
  20. sol::state* state = static_cast<sol::state*>(sol2);
  21. state->new_usertype<hello>("hello",
  22. "name", &hello::name
  23. );
  24. // 返回成功
  25. return 0;
  26. }
  27. }