1 Star 0 Fork 40

cosysin/EasyCKL

forked from daemon_process/EasyCKL 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
CustomizeJS.cpp 1.67 KB
一键复制 编辑 原始数据 按行查看 历史
#include "CustomizeJS.h"
extern CefRefPtr<CefV8Handler> myV8handle;
CKLEXPORT void WINAPI Chrome_AddJSFunction(CefV8Context* context, wchar_t* name) {
auto myFun = CefV8Value::CreateFunction(name, myV8handle);
auto pObjApp = context->GetGlobal();
pObjApp->SetValue(name, myFun, V8_PROPERTY_ATTRIBUTE_NONE);
}
CKLEXPORT DWORD WINAPI Chrome_GetV8ValueListSize(const CefV8ValueList* arguments) {
return arguments->size();
}
//*************************
CKLEXPORT DWORD WINAPI Chrome_GetV8ValueInt(const CefV8ValueList* arguments, size_t pos) {
auto value = arguments->at(pos);
if (value->IsValid())
return value->GetUIntValue();
return 0;
}
CKLEXPORT DWORD WINAPI Chrome_GetV8ValueStringLength(const CefV8ValueList* arguments, size_t pos) {
auto value = arguments->at(pos);
if (value->IsValid())
return std::wstring(value->GetStringValue()).length();
return 0;
}
CKLEXPORT void WINAPI Chrome_GetV8ValueString(const CefV8ValueList* arguments, size_t pos, wchar_t* buffer, size_t buffer_length) {
auto value = arguments->at(pos);
if (value->IsValid()) {
auto Value = value->GetStringValue().ToWString();
_ECKL_CopyWString(Value, buffer, buffer_length * sizeof(wchar_t));
//std::wstring(value->GetStringValue()).copy(buffer, buffer_length);
//memset(buffer + buffer_length - 2, 0, 2);//最后两个字节置0
}
}
//*************************
CKLEXPORT void WINAPI Chrome_SetV8ReturnValueInt(CefRefPtr<CefV8Value>* lpretval, int value) {
if (lpretval) {
*lpretval = CefV8Value::CreateInt(value);
}
}
CKLEXPORT void WINAPI Chrome_SetV8ReturnValueString(CefRefPtr<CefV8Value>* lpretval, wchar_t* value) {
if (lpretval) {
*lpretval = CefV8Value::CreateString(value);
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/cosysin/EasyCKL.git
git@gitee.com:cosysin/EasyCKL.git
cosysin
EasyCKL
EasyCKL
master

搜索帮助