https://github.com/pengwei1024/javascriptcorestudy
JavaScriptCore study
https://github.com/pengwei1024/javascriptcorestudy
android javascriptcore
Last synced: 3 days ago
JSON representation
JavaScriptCore study
- Host: GitHub
- URL: https://github.com/pengwei1024/javascriptcorestudy
- Owner: pengwei1024
- License: apache-2.0
- Created: 2018-06-28T09:04:49.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-29T04:22:55.000Z (almost 8 years ago)
- Last Synced: 2025-07-14T01:00:28.592Z (10 months ago)
- Topics: android, javascriptcore
- Language: C
- Size: 1.64 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JavaScriptCoreStudy
JavaScriptCore study
### 简单的四则运算
```c++
const char *buffer = (env)->GetStringUTFChars(jsValue, 0);
JSValueRef exception = nullptr;
JSGlobalContextRef executor_context_ = ::JSGlobalContextCreate(nullptr);
JSStringRef script = ::JSStringCreateWithUTF8CString(buffer);
JSValueRef value = ::JSEvaluateScript(executor_context_, script, 0, 0, 0, &exception);
if (JSValueIsNumber(executor_context_, value)) {
double result = JSValueToNumber(executor_context_, value, nullptr);
LOGD("JSValueIsNumber: %f", result);
return result;
}
::JSStringRelease(script);
```