Skip to content

Commit

Permalink
docs: fix docs core typo
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromehan authored and churchill-zhang committed Mar 17, 2020
1 parent 22e8602 commit 48258d4
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions docs/core/custom.md
Expand Up @@ -4,7 +4,7 @@

## 继承 ModuleBase

[core/module/](//github.com/Tencent/Hippy/tree/master/core/modules) 下创建 test-module.h
[core/modules/](//github.com/Tencent/Hippy/tree/master/core/modules) 下创建 test-module.h

```cpp
#ifndef CORE_MODULES_TEST_MODULE_H_
Expand All @@ -23,30 +23,33 @@ class TestModule : public ModuleBase {
#endif // CORE_MODULES_TEST_MODULE_H_
```

[core/module/](//github.com/Tencent/Hippy/tree/master/core/modules) 下创建 test-module.cc
[core/modules/](//github.com/Tencent/Hippy/tree/master/core/modules) 下创建 test-module.cc

```cpp
#include "core/modules/module-register.h"
#include "core/modules/test-module.h"
#include "core/napi/js-native-api.h"

#include "core/base/logging.h"
REGISTER_MODULE(TestModule, RetStr)
REGISTER_MODULE(TestModule, Print)

void TestModule::RetStr(const hippy::napi::CallbackInfo& info) {
hippy::napi::napi_context context = info.GetContext();
std::shared_ptr<Environment> env = info.GetEnv();
hippy::napi::napi_context context = env->getContext();
HIPPY_CHECK(context);

info.GetReturnValue()->Set(hippy::napi::napi_create_string(context, "hello world"));
}

void TestModule::Print(const hippy::napi::CallbackInfo& info) {
hippy::napi::napi_context context = info.GetContext();
std::shared_ptr<Environment> env = info.GetEnv();
hippy::napi::napi_context context = env->getContext();
HIPPY_CHECK(context);

HIPPY_LOG(hippy::Debug, "hello world");

info.GetReturnValue()->SetUndefined();
}

```
# JS 桥接
Expand Down

0 comments on commit 48258d4

Please sign in to comment.