mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Compare commits
181 Commits
v7.4.0.37
...
v7.4.0.105
| Author | SHA1 | Date | |
|---|---|---|---|
| 358903d331 | |||
| 46e8d03eeb | |||
| 554ad261cf | |||
| 78c662ea55 | |||
| 98a02441de | |||
| efb3075e0e | |||
| da703d88ca | |||
| dc73c8b2b6 | |||
| 1404829b68 | |||
| be9f8ba8e6 | |||
| f858b76fd4 | |||
| 3914b9a9d5 | |||
| e19d1c6735 | |||
| 041d8a3dc4 | |||
| 3d7eefcd3d | |||
| 82db1cd0d1 | |||
| 14ea99e880 | |||
| 7363c995dd | |||
| 66a2edf5d2 | |||
| 36e5cada88 | |||
| 01e9bb8cef | |||
| 9887883626 | |||
| 3d828f9683 | |||
| 2d890247ab | |||
| 5acc2513c8 | |||
| d3dc902f23 | |||
| 11ae76f9f0 | |||
| 7340469a8c | |||
| 92e03fd7b6 | |||
| 7a12a4d43e | |||
| c59f679043 | |||
| 3cb1503632 | |||
| b2b0c74cd4 | |||
| a1376d647f | |||
| dc17f5fe2e | |||
| 6d45b90ac0 | |||
| 7130c2d1bb | |||
| e19db2847f | |||
| 2e8bb7177c | |||
| c8ca57ea40 | |||
| e7931e73d1 | |||
| 5c3760a907 | |||
| 6320c543c0 | |||
| 324dd2de49 | |||
| e07fd5ed24 | |||
| 19295c1037 | |||
| 7ad0e7e9fe | |||
| ce9ede6820 | |||
| 379f474739 | |||
| a2662a6f2b | |||
| c52893306d | |||
| 3a9a2b5ee7 | |||
| 8df04c48ad | |||
| f7b0565233 | |||
| ef7fb15efe | |||
| e32b53d662 | |||
| 0b683226e9 | |||
| 73924f3ae0 | |||
| e8ecef51dd | |||
| 5bf730e1d6 | |||
| 091f3a3a8e | |||
| ffa8467c9e | |||
| 398c69c01e | |||
| a48ed74102 | |||
| 45628154d9 | |||
| 2921e476c3 | |||
| e97fd44489 | |||
| 1dba0723c7 | |||
| 217ec901ed | |||
| 68723a5e81 | |||
| 53810c07ac | |||
| 14fcc4dfac | |||
| b4b1cae18e | |||
| ab74e3fce7 | |||
| 4f48287d28 | |||
| 3b20ac3825 | |||
| 3f782ab389 | |||
| c22d4c60c0 | |||
| 9349ddf604 | |||
| 70c4f045ea | |||
| d955de5bdb | |||
| 0bd9cead65 | |||
| c282e86832 | |||
| cd91baaabe | |||
| 727a7722bb | |||
| 0d47bdc47d | |||
| cd458b81ec | |||
| 4beb4c8d70 | |||
| aa56efb495 | |||
| 44016b4ccc | |||
| d2158ded6f | |||
| 34790c680a | |||
| 4dfa989980 | |||
| 99ba013151 | |||
| 857957e824 | |||
| c0972a5b4a | |||
| c0f231fa92 | |||
| 6ec0609de3 | |||
| 43aacc8dd9 | |||
| f75d977661 | |||
| 48d19d9aa0 | |||
| 16448245b8 | |||
| c8a03fec41 | |||
| db05f4d373 | |||
| b6e741c4a5 | |||
| ff75d14e29 | |||
| ed0bcfc642 | |||
| 33e6c14a04 | |||
| f7b3ab2411 | |||
| ea49ffe242 | |||
| 471f739a66 | |||
| a710a7b77c | |||
| 13ff65c6e9 | |||
| 5050726d47 | |||
| 3296d32168 | |||
| 11b59048cd | |||
| 6b0513cd81 | |||
| e335a237a5 | |||
| af6802e035 | |||
| 01f01ec85f | |||
| a3f7e83ccf | |||
| 09d87538e7 | |||
| 2f9726e455 | |||
| 5178cf0cb7 | |||
| 0a517af106 | |||
| 76fea998ea | |||
| 721805535e | |||
| 1f5025b136 | |||
| a61c267941 | |||
| 6f4041b476 | |||
| 97aad68726 | |||
| e83a86ee56 | |||
| a6882895a5 | |||
| 85ab308f80 | |||
| c4bda0b403 | |||
| 0f492bce2b | |||
| 92f114a30f | |||
| 98f33c04be | |||
| 34c36cae01 | |||
| a6a4d74304 | |||
| 58112c000c | |||
| 76c00154af | |||
| 4fec85c60b | |||
| 19c56e1b4d | |||
| 71e3768ed9 | |||
| fb0e7f8d3f | |||
| f59e5745af | |||
| 6b9ae7e71e | |||
| 2601448513 | |||
| 263e50601a | |||
| c60d06733b | |||
| 9d9edd2cfc | |||
| 7bc69064f7 | |||
| 2dd276c427 | |||
| 9e62296b29 | |||
| 6c76366705 | |||
| 0f59c2254d | |||
| 4910d69a40 | |||
| ae92f47e54 | |||
| b2a8407617 | |||
| f41c850c0e | |||
| a977fe30f0 | |||
| 2c799de36a | |||
| a736c35880 | |||
| 00e54401da | |||
| 486ff2087c | |||
| b0cbf8520a | |||
| ea181c8110 | |||
| 2f4756138c | |||
| 32a046f4d2 | |||
| 163ab8da25 | |||
| fad145455e | |||
| a32ce7650f | |||
| 9ea4cd8ba5 | |||
| 7ba98fe047 | |||
| 7550c08748 | |||
| fc0f496c5f | |||
| 24acad0cd2 | |||
| bc33a5b2e3 | |||
| 43514de87e | |||
| 61d26acf71 |
2
Common/3dParty/googletest/.gitignore
vendored
Normal file
2
Common/3dParty/googletest/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
googletest/
|
||||
build/
|
||||
12
Common/3dParty/googletest/googletest.pri
Normal file
12
Common/3dParty/googletest/googletest.pri
Normal file
@ -0,0 +1,12 @@
|
||||
CORE_GTEST_PATH=$$PWD/googletest/googletest
|
||||
|
||||
CONFIG += c++14
|
||||
|
||||
CORE_GTEST_PATH_INCLUDE = $$CORE_GTEST_PATH/include
|
||||
|
||||
INCLUDEPATH += $$CORE_GTEST_PATH
|
||||
INCLUDEPATH += $$CORE_GTEST_PATH_INCLUDE
|
||||
|
||||
SOURCES += \
|
||||
$$CORE_GTEST_PATH/src/gtest-all.cc \
|
||||
$$CORE_GTEST_PATH/src/gtest_main.cc
|
||||
@ -1,38 +0,0 @@
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/../openssl/build/$$CORE_BUILDS_PLATFORM_PREFIX/lib
|
||||
|
||||
core_android {
|
||||
|
||||
OPENSSL_ABI_PATH = $$replace(CORE_BUILDS_PLATFORM_PREFIX, "android_", "")
|
||||
contains(OPENSSL_ABI_PATH, "armv7" ) {
|
||||
OPENSSL_ABI_PATH = $$replace(OPENSSL_ABI_PATH, "armv7", "armeabi-v7a")
|
||||
}
|
||||
contains(OPENSSL_ABI_PATH, "arm64_v8a" ) {
|
||||
OPENSSL_ABI_PATH = $$replace(OPENSSL_ABI_PATH, "arm64_v8a", "arm64-v8a")
|
||||
}
|
||||
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/../openssl/build/android/$$OPENSSL_ABI_PATH/lib
|
||||
}
|
||||
|
||||
core_ios {
|
||||
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/../openssl/build/ios/openssl-universal/lib
|
||||
|
||||
bundle_xcframeworks {
|
||||
xcframework_platform_ios_simulator {
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/../openssl/build/ios/openssl-xc/simulator/lib
|
||||
} else {
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/../openssl/build/ios/openssl-xc/lib
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
core_windows {
|
||||
LIBS += $$OPENSSL_LIBS_DIRECTORY/libssl.lib
|
||||
LIBS += $$OPENSSL_LIBS_DIRECTORY/libcrypto.lib
|
||||
} else {
|
||||
LIBS += $$OPENSSL_LIBS_DIRECTORY/libssl.a
|
||||
LIBS += $$OPENSSL_LIBS_DIRECTORY/libcrypto.a
|
||||
}
|
||||
|
||||
INCLUDEPATH += $$OPENSSL_LIBS_DIRECTORY/../include
|
||||
@ -83,19 +83,19 @@ function configure_make() {
|
||||
|
||||
if [[ "${ARCH}" == "x86_64" ]]; then
|
||||
|
||||
./Configure android-x86_64 --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method
|
||||
./Configure android-x86_64 --prefix="${PREFIX_DIR}" no-shared no-tests enable-ssl3 enable-ssl3-method enable-md2 no-asm
|
||||
|
||||
elif [[ "${ARCH}" == "x86" ]]; then
|
||||
|
||||
./Configure android-x86 --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method
|
||||
./Configure android-x86 --prefix="${PREFIX_DIR}" no-shared no-tests enable-ssl3 enable-ssl3-method enable-md2 no-asm
|
||||
|
||||
elif [[ "${ARCH}" == "arm" ]]; then
|
||||
|
||||
./Configure android-arm --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method
|
||||
./Configure android-arm --prefix="${PREFIX_DIR}" no-shared no-tests enable-ssl3 enable-ssl3-method enable-md2 no-asm
|
||||
|
||||
elif [[ "${ARCH}" == "arm64" ]]; then
|
||||
|
||||
./Configure android-arm64 --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method
|
||||
./Configure android-arm64 --prefix="${PREFIX_DIR}" no-shared no-tests enable-ssl3 enable-ssl3-method enable-md2 no-asm
|
||||
|
||||
else
|
||||
log_error "not support" && exit 1
|
||||
@ -103,6 +103,9 @@ function configure_make() {
|
||||
|
||||
log_info "make $ABI start..."
|
||||
|
||||
sed -ie 's/LIB_CFLAGS=/LIB_CFLAGS=-fvisibility=hidden /g' ./Makefile
|
||||
sed -ie 's/LIB_CXXFLAGS=/LIB_CXXFLAGS=-fvisibility=hidden /g' ./Makefile
|
||||
|
||||
make clean >"${OUTPUT_ROOT}/log/${ABI}.log"
|
||||
if make -j$(get_cpu_count) >>"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1; then
|
||||
make install_sw >>"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1
|
||||
|
||||
@ -100,32 +100,32 @@ function configure_make() {
|
||||
if [[ "${ARCH_NAME}" == "x86_64" ]]; then
|
||||
|
||||
# openssl1.1.1d can be set normally, 1.1.0f does not take effect
|
||||
./Configure darwin64-x86_64-cc no-shared --prefix="${PREFIX_DIR}"
|
||||
./Configure darwin64-x86_64-cc no-shared --prefix="${PREFIX_DIR}" enable-md2
|
||||
sed -i -e 's/-mtune=intel//g' "Makefile"
|
||||
|
||||
elif [[ "${ARCH_NAME}" == "armv7" ]]; then
|
||||
|
||||
# openssl1.1.1d can be set normally, 1.1.0f does not take effect
|
||||
./Configure iphoneos-cross no-shared --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method
|
||||
./Configure iphoneos-cross no-shared --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method enable-md2
|
||||
sed -ie "s!-fno-common!-fno-common -fembed-bitcode !" "Makefile"
|
||||
|
||||
elif [[ "${ARCH_NAME}" == "arm64" ]]; then
|
||||
|
||||
# openssl1.1.1d can be set normally, 1.1.0f does not take effect
|
||||
./Configure iphoneos-cross no-shared --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method
|
||||
./Configure iphoneos-cross no-shared --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method enable-md2
|
||||
sed -ie "s!-fno-common!-fno-common -fembed-bitcode !" "Makefile"
|
||||
|
||||
elif [[ "${ARCH_NAME}" == "i386" ]]; then
|
||||
|
||||
# openssl1.1.1d can be set normally, 1.1.0f does not take effect
|
||||
./Configure darwin-i386-cc no-shared --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method
|
||||
./Configure darwin-i386-cc no-shared --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method enable-md2
|
||||
sed -ie "s!-fno-common!-fno-common -fembed-bitcode !" "Makefile"
|
||||
sed -i -e 's/-mtune=intel//g' "Makefile"
|
||||
|
||||
elif [[ "${ARCH_NAME}" == "sim_arm64" ]]; then
|
||||
|
||||
# openssl1.1.1d can be set normally, 1.1.0f does not take effect
|
||||
./Configure iphoneos-cross no-shared --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method
|
||||
./Configure iphoneos-cross no-shared --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method enable-md2
|
||||
sed -ie "s!-fno-common!-fno-common -fembed-bitcode !" "Makefile"
|
||||
|
||||
else
|
||||
|
||||
@ -1,14 +1,48 @@
|
||||
OPEN_SSL_PLATFORM=$$CORE_BUILDS_PLATFORM_PREFIX
|
||||
build_xp:OPEN_SSL_PLATFORM=$$join(OPEN_SSL_PLATFORM, OPEN_SSL_PLATFORM, "", "_xp")
|
||||
|
||||
INCLUDEPATH += $$PWD/build/$$OPEN_SSL_PLATFORM/include
|
||||
|
||||
core_windows:LIBS += -L$$PWD/build/$$OPEN_SSL_PLATFORM/lib -llibcrypto -llibssl
|
||||
!core_windows:LIBS += -L$$PWD/build/$$OPEN_SSL_PLATFORM/lib -lcrypto -lssl
|
||||
|
||||
open_ssl_common {
|
||||
DEFINES += COMMON_OPENSSL_BUILDING
|
||||
|
||||
HEADERS += $$PWD/common/common_openssl.h
|
||||
SOURCES += $$PWD/common/common_openssl.cpp
|
||||
}
|
||||
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/build/$$OPEN_SSL_PLATFORM/lib
|
||||
|
||||
core_android {
|
||||
|
||||
OPENSSL_ABI_PATH = $$replace(CORE_BUILDS_PLATFORM_PREFIX, "android_", "")
|
||||
contains(OPENSSL_ABI_PATH, "armv7" ) {
|
||||
OPENSSL_ABI_PATH = $$replace(OPENSSL_ABI_PATH, "armv7", "armeabi-v7a")
|
||||
}
|
||||
contains(OPENSSL_ABI_PATH, "arm64_v8a" ) {
|
||||
OPENSSL_ABI_PATH = $$replace(OPENSSL_ABI_PATH, "arm64_v8a", "arm64-v8a")
|
||||
}
|
||||
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/build/android/$$OPENSSL_ABI_PATH/lib
|
||||
}
|
||||
|
||||
core_ios {
|
||||
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/ios/openssl-universal/lib
|
||||
|
||||
bundle_xcframeworks {
|
||||
xcframework_platform_ios_simulator {
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/build/ios/openssl-xc/simulator/lib
|
||||
} else {
|
||||
OPENSSL_LIBS_DIRECTORY = $$PWD/build/ios/openssl-xc/lib
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
core_windows {
|
||||
LIBS += $$OPENSSL_LIBS_DIRECTORY/libssl.lib
|
||||
LIBS += $$OPENSSL_LIBS_DIRECTORY/libcrypto.lib
|
||||
} else {
|
||||
LIBS += $$OPENSSL_LIBS_DIRECTORY/libssl.a
|
||||
LIBS += $$OPENSSL_LIBS_DIRECTORY/libcrypto.a
|
||||
}
|
||||
|
||||
INCLUDEPATH += $$OPENSSL_LIBS_DIRECTORY/../include
|
||||
|
||||
@ -48,7 +48,7 @@ restore_build_gn()
|
||||
|
||||
if [ ! -d "v8" ]
|
||||
then
|
||||
fetch v8
|
||||
./depot_tools/fetch v8
|
||||
cd v8
|
||||
git checkout -b 6.0 branch-heads/6.0
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ for image in $(docker images --format "{{.ID}}"); do
|
||||
done
|
||||
|
||||
docker rm v8docker
|
||||
docker build . -t v8_docker --build-arg CACHEBUST=0 --no-cache=true
|
||||
#add --progress=plain for full logs from build.sh
|
||||
docker build . -t v8_docker --build-arg CACHEBUST=0 --no-cache=true --platform linux/amd64
|
||||
docker run -d --name v8docker v8_docker:latest
|
||||
docker cp v8docker:/home/docker/v8/build.zip .
|
||||
@ -1,4 +1,6 @@
|
||||
CORE_V8_PATH_OVERRIDE=$$PWD
|
||||
!v8_version_60:CONFIG += v8_version_89
|
||||
|
||||
v8_version_89 {
|
||||
CONFIG += c++14
|
||||
CONFIG += use_v8_monolith
|
||||
@ -14,6 +16,15 @@ v8_version_89 {
|
||||
CORE_V8_PATH_INCLUDE = $$CORE_V8_PATH_OVERRIDE/v8
|
||||
CORE_V8_PATH_LIBS = $$CORE_V8_PATH_INCLUDE/out.gn/$$CORE_BUILDS_PLATFORM_PREFIX/obj
|
||||
|
||||
core_android {
|
||||
CORE_V8_PATH_INCLUDE = $$CORE_V8_PATH_OVERRIDE/android/v8
|
||||
|
||||
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_arm64_v8a):CORE_V8_PATH_LIBS=$$CORE_V8_PATH_OVERRIDE/android/build/arm64-v8a
|
||||
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_armv7): CORE_V8_PATH_LIBS=$$CORE_V8_PATH_OVERRIDE/android/build/armeabi-v7a
|
||||
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_x86): CORE_V8_PATH_LIBS=$$CORE_V8_PATH_OVERRIDE/android/build/x86
|
||||
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_x86_64): CORE_V8_PATH_LIBS=$$CORE_V8_PATH_OVERRIDE/android/build/x86_64
|
||||
}
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$CORE_V8_PATH_INCLUDE \
|
||||
$$CORE_V8_PATH_INCLUDE/include
|
||||
@ -23,7 +34,6 @@ core_windows {
|
||||
|
||||
use_v8_monolith {
|
||||
LIBS += -L$$CORE_V8_PATH_LIBS -lv8_monolith
|
||||
core_debug:DEFINES += "_ITERATOR_DEBUG_LEVEL=0"
|
||||
} else {
|
||||
LIBS += -L$$CORE_V8_PATH_LIBS -lv8_base -lv8_libplatform -lv8_libbase -lv8_snapshot -lv8_libsampler
|
||||
LIBS += -L$$CORE_V8_PATH_LIBS/third_party/icu -licui18n -licuuc
|
||||
@ -64,3 +74,8 @@ core_mac {
|
||||
QMAKE_CXXFLAGS += -Wall -Wno-inconsistent-missing-override
|
||||
QMAKE_CFLAGS += -Wall -Wno-inconsistent-missing-override
|
||||
}
|
||||
|
||||
core_android {
|
||||
LIBS += -L$$CORE_V8_PATH_LIBS -lv8_base -lv8_libplatform -lv8_libbase -lv8_nosnapshot -lv8_libsampler
|
||||
LIBS += -L$$CORE_V8_PATH_LIBS -licui18n -licuuc
|
||||
}
|
||||
|
||||
@ -24,6 +24,8 @@ core_linux {
|
||||
SOURCES += $$PWD/src/FileTransporter_curl.cpp
|
||||
}
|
||||
core_mac {
|
||||
use_v8:DEFINES += OLD_MACOS_SYSTEM
|
||||
|
||||
OBJECTIVE_SOURCES += $$PWD/src/FileTransporter_mac.mm
|
||||
LIBS += -framework AppKit
|
||||
}
|
||||
|
||||
@ -49,323 +49,350 @@
|
||||
|
||||
namespace NSNetwork
|
||||
{
|
||||
namespace NSFileTransport
|
||||
{
|
||||
std::string wget_url_validate(const std::string& url)
|
||||
{
|
||||
std::string::size_type pos = 0;
|
||||
const char* url_ptr = url.c_str();
|
||||
while ('-' == *url_ptr++) // '\0' => break
|
||||
++pos;
|
||||
if (*url_ptr == '\0')
|
||||
return "";
|
||||
namespace NSFileTransport
|
||||
{
|
||||
std::string wget_url_validate(const std::string& url)
|
||||
{
|
||||
std::string::size_type pos = 0;
|
||||
const char* url_ptr = url.c_str();
|
||||
while ('-' == *url_ptr++) // '\0' => break
|
||||
++pos;
|
||||
if (*url_ptr == '\0')
|
||||
return "";
|
||||
|
||||
return url.substr(pos);
|
||||
}
|
||||
return url.substr(pos);
|
||||
}
|
||||
|
||||
int download_external(const std::wstring& sUrl, const std::wstring& sOutput, std::function<void(int)> func_onProgress = nullptr, std::function<bool(void)> func_checkAborted = nullptr)
|
||||
{
|
||||
pid_t pid;
|
||||
int nReturnCode = -1;
|
||||
std::string sUrlA = U_TO_UTF8(sUrl);
|
||||
//sUrlA =("\"" + sUrlA + "\"");
|
||||
std::string sOutputA = U_TO_UTF8(sOutput);
|
||||
//sOutputA =("\"" + sOutputA + "\"");
|
||||
int download_external(const std::wstring& sUrl, const std::wstring& sOutput, std::function<void(int)> func_onProgress = nullptr, std::function<bool(void)> func_checkAborted = nullptr)
|
||||
{
|
||||
pid_t pid;
|
||||
int nReturnCode = -1;
|
||||
std::string sUrlA = U_TO_UTF8(sUrl);
|
||||
//sUrlA =("\"" + sUrlA + "\"");
|
||||
std::string sOutputA = U_TO_UTF8(sOutput);
|
||||
//sOutputA =("\"" + sOutputA + "\"");
|
||||
|
||||
if (0 != nReturnCode && NSFile::CFileBinary::Exists(L"/usr/bin/curl"))
|
||||
{
|
||||
int pipefd[2];
|
||||
if(func_onProgress)
|
||||
pipe(pipefd);
|
||||
std::wstring sCurlBin = L"";
|
||||
if (NSFile::CFileBinary::Exists(L"/usr/bin/curl"))
|
||||
sCurlBin = L"/usr/bin/curl";
|
||||
if (NSFile::CFileBinary::Exists(L"/usr/local/bin/curl"))
|
||||
sCurlBin = L"/usr/local/bin/curl";
|
||||
|
||||
pid = fork(); // create child process
|
||||
int status;
|
||||
if (0 != nReturnCode && !sCurlBin.empty())
|
||||
{
|
||||
int pipefd[2];
|
||||
if(func_onProgress)
|
||||
pipe(pipefd);
|
||||
|
||||
switch (pid)
|
||||
{
|
||||
case -1: // error
|
||||
break;
|
||||
pid = fork(); // create child process
|
||||
int status;
|
||||
|
||||
case 0: // child process
|
||||
{
|
||||
const char* nargs[10];
|
||||
nargs[0] = "/usr/bin/curl";
|
||||
nargs[1] = "--url";
|
||||
nargs[2] = sUrlA.c_str();
|
||||
nargs[3] = "--output";
|
||||
nargs[4] = sOutputA.c_str();
|
||||
func_onProgress == NULL ? nargs[5] = "--silent" : nargs[5] = "--progress-bar";
|
||||
nargs[6] = "-L";
|
||||
nargs[7] = "--connect-timeout";
|
||||
nargs[8] = "10";
|
||||
nargs[9] = NULL;
|
||||
switch (pid)
|
||||
{
|
||||
case -1: // error
|
||||
break;
|
||||
|
||||
const char* nenv[3];
|
||||
nenv[0] = "LD_PRELOAD=";
|
||||
nenv[1] = "LD_LIBRARY_PATH=";
|
||||
nenv[2] = NULL;
|
||||
case 0: // child process
|
||||
{
|
||||
std::string sProgramBinA = U_TO_UTF8(sCurlBin);
|
||||
|
||||
if(func_onProgress)
|
||||
{
|
||||
close(pipefd[0]); // close reading end in the child
|
||||
const char* nargs[10];
|
||||
nargs[0] = sProgramBinA.c_str();
|
||||
nargs[1] = "--url";
|
||||
nargs[2] = sUrlA.c_str();
|
||||
nargs[3] = "--output";
|
||||
nargs[4] = sOutputA.c_str();
|
||||
func_onProgress == NULL ? nargs[5] = "--silent" : nargs[5] = "--progress-bar";
|
||||
nargs[6] = "-L";
|
||||
nargs[7] = "--connect-timeout";
|
||||
nargs[8] = "10";
|
||||
nargs[9] = NULL;
|
||||
|
||||
dup2(pipefd[1], 1); // send stdout to the pipe
|
||||
dup2(pipefd[1], 2); // send stderr to the pipe
|
||||
const char* nenv[3];
|
||||
nenv[0] = "LD_PRELOAD=";
|
||||
nenv[1] = "LD_LIBRARY_PATH=";
|
||||
nenv[2] = NULL;
|
||||
|
||||
close(pipefd[1]); // this descriptor is no longer needed
|
||||
}
|
||||
if(func_onProgress)
|
||||
{
|
||||
close(pipefd[0]); // close reading end in the child
|
||||
|
||||
execve("/usr/bin/curl", (char * const *)nargs, (char * const *)nenv);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
default: // parent process, pid now contains the child pid
|
||||
if(func_onProgress)
|
||||
{
|
||||
close(pipefd[1]);
|
||||
// close the write end of the pipe in the parent
|
||||
size_t size = 81;
|
||||
char buffer[size];
|
||||
std::string str;
|
||||
ssize_t res = 1;
|
||||
std::regex r(R"(\d+(?:\.\d+)?%)");
|
||||
std::smatch sm;
|
||||
std::string percentFull;
|
||||
std::string percent;
|
||||
int percentInt;
|
||||
dup2(pipefd[1], 1); // send stdout to the pipe
|
||||
dup2(pipefd[1], 2); // send stderr to the pipe
|
||||
|
||||
while (1)
|
||||
{
|
||||
if(func_checkAborted && func_checkAborted())
|
||||
{
|
||||
kill(pid, SIGTERM);
|
||||
//while (-1 == waitpid(pid, &status, 0)); // wait for child to complete
|
||||
return nReturnCode;
|
||||
}
|
||||
close(pipefd[1]); // this descriptor is no longer needed
|
||||
}
|
||||
|
||||
str.clear();
|
||||
res = read(pipefd[0], buffer, sizeof(buffer));
|
||||
execve(sProgramBinA.c_str(), (char * const *)nargs, (char * const *)nenv);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
default: // parent process, pid now contains the child pid
|
||||
if(func_onProgress)
|
||||
{
|
||||
close(pipefd[1]);
|
||||
// close the write end of the pipe in the parent
|
||||
size_t size = 81;
|
||||
char buffer[size];
|
||||
std::string str;
|
||||
ssize_t res = 1;
|
||||
std::regex r(R"(\d+(?:\.\d+)?%)");
|
||||
std::smatch sm;
|
||||
std::string percentFull;
|
||||
std::string percent;
|
||||
int percentInt;
|
||||
|
||||
if(res == 0)
|
||||
break;
|
||||
while (1)
|
||||
{
|
||||
if(func_checkAborted && func_checkAborted())
|
||||
{
|
||||
kill(pid, SIGTERM);
|
||||
//while (-1 == waitpid(pid, &status, 0)); // wait for child to complete
|
||||
return nReturnCode;
|
||||
}
|
||||
|
||||
str.append(buffer);
|
||||
str.clear();
|
||||
res = read(pipefd[0], buffer, sizeof(buffer));
|
||||
|
||||
if(regex_search(str, sm, r))
|
||||
{
|
||||
percentFull = sm.str();
|
||||
percent = percentFull.substr(0, percentFull.find("."));
|
||||
percentInt = std::stoi(percent);
|
||||
if(res == 0)
|
||||
break;
|
||||
|
||||
if(percentInt >= 0 && percentInt <= 100)
|
||||
func_onProgress(percentInt);
|
||||
}
|
||||
str.append(buffer);
|
||||
|
||||
if(str.find("100.0%") != std::string::npos)
|
||||
break;
|
||||
if(regex_search(str, sm, r))
|
||||
{
|
||||
percentFull = sm.str();
|
||||
percent = percentFull.substr(0, percentFull.find("."));
|
||||
percentInt = std::stoi(percent);
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
int waitres;
|
||||
while (1) // wait for child to complete
|
||||
{
|
||||
if(func_checkAborted && func_checkAborted())
|
||||
{
|
||||
kill(pid, SIGTERM);
|
||||
return nReturnCode;
|
||||
}
|
||||
else if((waitres = waitpid(pid, &status, WNOHANG)) > 0)
|
||||
{
|
||||
if (WIFEXITED(status))
|
||||
{
|
||||
nReturnCode = WEXITSTATUS(status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(percentInt >= 0 && percentInt <= 100)
|
||||
func_onProgress(percentInt);
|
||||
}
|
||||
|
||||
if (0 != nReturnCode && NSFile::CFileBinary::Exists(L"/usr/bin/wget"))
|
||||
{
|
||||
std::string sUrlValidateA = wget_url_validate(sUrlA);
|
||||
if(str.find("100.0%") != std::string::npos)
|
||||
break;
|
||||
|
||||
pid = fork(); // create child process
|
||||
int status;
|
||||
}
|
||||
}
|
||||
else {
|
||||
int waitres;
|
||||
while (1) // wait for child to complete
|
||||
{
|
||||
if(func_checkAborted && func_checkAborted())
|
||||
{
|
||||
kill(pid, SIGTERM);
|
||||
return nReturnCode;
|
||||
}
|
||||
else if((waitres = waitpid(pid, &status, WNOHANG)) > 0)
|
||||
{
|
||||
if (WIFEXITED(status))
|
||||
{
|
||||
nReturnCode = WEXITSTATUS(status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (pid)
|
||||
{
|
||||
case -1: // error
|
||||
break;
|
||||
std::wstring sWgetBin = L"";
|
||||
if (NSFile::CFileBinary::Exists(L"/usr/bin/wget"))
|
||||
sWgetBin = L"/usr/bin/wget";
|
||||
if (NSFile::CFileBinary::Exists(L"/usr/local/bin/wget"))
|
||||
sWgetBin = L"/usr/local/bin/wget";
|
||||
|
||||
case 0: // child process
|
||||
{
|
||||
const char* nargs[8];
|
||||
nargs[0] = "/usr/bin/wget";
|
||||
nargs[1] = sUrlValidateA.c_str();
|
||||
nargs[2] = "-O";
|
||||
nargs[3] = sOutputA.c_str();
|
||||
nargs[4] = "-q";
|
||||
nargs[5] = "--connect-timeout=10";
|
||||
nargs[6] = "--tries=2";
|
||||
nargs[7] = NULL;
|
||||
if (0 != nReturnCode && !sWgetBin.empty())
|
||||
{
|
||||
std::string sUrlValidateA = wget_url_validate(sUrlA);
|
||||
|
||||
const char* nenv[2];
|
||||
nenv[0] = "LD_PRELOAD=";
|
||||
nenv[1] = NULL;
|
||||
pid = fork(); // create child process
|
||||
int status;
|
||||
|
||||
execve("/usr/bin/wget", (char * const *)nargs, (char * const *)nenv);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
default: // parent process, pid now contains the child pid
|
||||
int waitres;
|
||||
while (1) // wait for child to complete
|
||||
{
|
||||
if(func_checkAborted && func_checkAborted())
|
||||
{
|
||||
kill(pid, SIGTERM);
|
||||
return nReturnCode;
|
||||
}
|
||||
else if((waitres = waitpid(pid, &status, WNOHANG)) > 0)
|
||||
{
|
||||
if (WIFEXITED(status))
|
||||
{
|
||||
nReturnCode = WEXITSTATUS(status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (pid)
|
||||
{
|
||||
case -1: // error
|
||||
break;
|
||||
|
||||
if (0 == nReturnCode)
|
||||
{
|
||||
if (!NSFile::CFileBinary::Exists(sOutput))
|
||||
nReturnCode = -1;
|
||||
}
|
||||
case 0: // child process
|
||||
{
|
||||
std::string sProgramBinA = U_TO_UTF8(sWgetBin);
|
||||
|
||||
return nReturnCode;
|
||||
}
|
||||
#ifndef OLD_MACOS_SYSTEM
|
||||
const char* nargs[8];
|
||||
#else
|
||||
const char* nargs[9];
|
||||
#endif
|
||||
|
||||
int uploaddata_external(const std::wstring &sUploadUrl, const unsigned char* cData, const int nSize)
|
||||
{
|
||||
int nReturnCode = -1;
|
||||
NSFile::CFileBinary oFileData;
|
||||
std::wstring tempFileName = NSFile::CFileBinary::GetTempPath() + L"/tmpFileForUpload";
|
||||
oFileData.CreateFileW(tempFileName);
|
||||
oFileData.WriteFile(cData, nSize);
|
||||
oFileData.CloseFile();
|
||||
nargs[0] = sProgramBinA.c_str();
|
||||
nargs[1] = sUrlValidateA.c_str();
|
||||
nargs[2] = "-O";
|
||||
nargs[3] = sOutputA.c_str();
|
||||
nargs[4] = "-q";
|
||||
nargs[5] = "--connect-timeout=10";
|
||||
nargs[6] = "--tries=2";
|
||||
|
||||
std::string sUploadUrlA = U_TO_UTF8(sUploadUrl);
|
||||
#ifndef OLD_MACOS_SYSTEM
|
||||
nargs[7] = NULL;
|
||||
#else
|
||||
nargs[7] = "--no-check-certificate";
|
||||
nargs[8] = NULL;
|
||||
#endif
|
||||
|
||||
const char* nenv[2];
|
||||
nenv[0] = "LD_PRELOAD=";
|
||||
nenv[1] = NULL;
|
||||
|
||||
execve(sProgramBinA.c_str(), (char * const *)nargs, (char * const *)nenv);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
default: // parent process, pid now contains the child pid
|
||||
int waitres;
|
||||
while (1) // wait for child to complete
|
||||
{
|
||||
if(func_checkAborted && func_checkAborted())
|
||||
{
|
||||
kill(pid, SIGTERM);
|
||||
return nReturnCode;
|
||||
}
|
||||
else if((waitres = waitpid(pid, &status, WNOHANG)) > 0)
|
||||
{
|
||||
if (WIFEXITED(status))
|
||||
{
|
||||
nReturnCode = WEXITSTATUS(status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == nReturnCode)
|
||||
{
|
||||
if (!NSFile::CFileBinary::Exists(sOutput))
|
||||
nReturnCode = -1;
|
||||
}
|
||||
|
||||
return nReturnCode;
|
||||
}
|
||||
|
||||
int uploaddata_external(const std::wstring &sUploadUrl, const unsigned char* cData, const int nSize)
|
||||
{
|
||||
int nReturnCode = -1;
|
||||
NSFile::CFileBinary oFileData;
|
||||
std::wstring tempFileName = NSFile::CFileBinary::GetTempPath() + L"/tmpFileForUpload";
|
||||
oFileData.CreateFileW(tempFileName);
|
||||
oFileData.WriteFile(cData, nSize);
|
||||
oFileData.CloseFile();
|
||||
|
||||
std::string sUploadUrlA = U_TO_UTF8(sUploadUrl);
|
||||
|
||||
|
||||
if (0 != nReturnCode && NSFile::CFileBinary::Exists(L"/usr/bin/curl"))
|
||||
{
|
||||
pid_t pid = fork(); // create child process
|
||||
int status;
|
||||
if (0 != nReturnCode && NSFile::CFileBinary::Exists(L"/usr/bin/curl"))
|
||||
{
|
||||
pid_t pid = fork(); // create child process
|
||||
int status;
|
||||
|
||||
switch (pid)
|
||||
{
|
||||
case -1: // error
|
||||
break;
|
||||
switch (pid)
|
||||
{
|
||||
case -1: // error
|
||||
break;
|
||||
|
||||
case 0: // child process
|
||||
{
|
||||
//curl --request POST --data-binary "@template_entry.xml" $URL
|
||||
auto pathTofile(std::string("@") + std::string(tempFileName.begin(), tempFileName.end()));
|
||||
const char* nargs[9];
|
||||
nargs[0] = "/usr/bin/curl";
|
||||
nargs[1] = "--request";
|
||||
nargs[2] = "POST";
|
||||
nargs[3] = "--data-binary";
|
||||
nargs[4] = pathTofile.c_str();
|
||||
nargs[5] = sUploadUrlA.c_str();
|
||||
nargs[6] = "--connect-timeout";
|
||||
nargs[7] = "10";
|
||||
nargs[8] = NULL;
|
||||
case 0: // child process
|
||||
{
|
||||
//curl --request POST --data-binary "@template_entry.xml" $URL
|
||||
auto pathTofile(std::string("@") + std::string(tempFileName.begin(), tempFileName.end()));
|
||||
const char* nargs[9];
|
||||
nargs[0] = "/usr/bin/curl";
|
||||
nargs[1] = "--request";
|
||||
nargs[2] = "POST";
|
||||
nargs[3] = "--data-binary";
|
||||
nargs[4] = pathTofile.c_str();
|
||||
nargs[5] = sUploadUrlA.c_str();
|
||||
nargs[6] = "--connect-timeout";
|
||||
nargs[7] = "10";
|
||||
nargs[8] = NULL;
|
||||
|
||||
const char* nenv[3];
|
||||
nenv[0] = "LD_PRELOAD=";
|
||||
nenv[1] = "LD_LIBRARY_PATH=";
|
||||
nenv[2] = NULL;
|
||||
const char* nenv[3];
|
||||
nenv[0] = "LD_PRELOAD=";
|
||||
nenv[1] = "LD_LIBRARY_PATH=";
|
||||
nenv[2] = NULL;
|
||||
|
||||
execve("/usr/bin/curl", (char * const *)nargs, (char * const *)nenv);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
default: // parent process, pid now contains the child pid
|
||||
while (-1 == waitpid(pid, &status, 0)); // wait for child to complete
|
||||
if (WIFEXITED(status))
|
||||
{
|
||||
nReturnCode = WEXITSTATUS(status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
NSFile::CFileBinary::Remove(tempFileName);
|
||||
execve("/usr/bin/curl", (char * const *)nargs, (char * const *)nenv);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
default: // parent process, pid now contains the child pid
|
||||
while (-1 == waitpid(pid, &status, 0)); // wait for child to complete
|
||||
if (WIFEXITED(status))
|
||||
{
|
||||
nReturnCode = WEXITSTATUS(status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
NSFile::CFileBinary::Remove(tempFileName);
|
||||
|
||||
return nReturnCode;
|
||||
}
|
||||
return nReturnCode;
|
||||
}
|
||||
|
||||
int uploadfile_external(const std::wstring &sUploadUrl, const std::wstring &sUploadFilePath)
|
||||
{
|
||||
int nReturnCode = -1;
|
||||
int uploadfile_external(const std::wstring &sUploadUrl, const std::wstring &sUploadFilePath)
|
||||
{
|
||||
int nReturnCode = -1;
|
||||
|
||||
std::string sUploadUrlA = U_TO_UTF8(sUploadUrl);
|
||||
std::string sUploadFilePathA = U_TO_UTF8(sUploadFilePath);
|
||||
std::string sUploadFileNameA = U_TO_UTF8(NSFile::GetFileName(sUploadFilePath));
|
||||
std::string sUploadUrlA = U_TO_UTF8(sUploadUrl);
|
||||
std::string sUploadFilePathA = U_TO_UTF8(sUploadFilePath);
|
||||
std::string sUploadFileNameA = U_TO_UTF8(NSFile::GetFileName(sUploadFilePath));
|
||||
|
||||
if (0 != nReturnCode && NSFile::CFileBinary::Exists(L"/usr/bin/curl"))
|
||||
{
|
||||
pid_t pid = fork(); // create child process
|
||||
int status;
|
||||
if (0 != nReturnCode && NSFile::CFileBinary::Exists(L"/usr/bin/curl"))
|
||||
{
|
||||
pid_t pid = fork(); // create child process
|
||||
int status;
|
||||
|
||||
switch (pid)
|
||||
{
|
||||
case -1: // error
|
||||
break;
|
||||
switch (pid)
|
||||
{
|
||||
case -1: // error
|
||||
break;
|
||||
|
||||
case 0: // child process
|
||||
{
|
||||
//curl -v -F filename=image.jpg -F upload=@/home/vladimir/Pictures/Test.png $URL
|
||||
auto filename(std::string("filename=") + sUploadFileNameA);
|
||||
auto upload(std::string("upload=@") + sUploadFilePathA);
|
||||
const char* nargs[10];
|
||||
nargs[0] = "/usr/bin/curl";
|
||||
nargs[1] = "-v";
|
||||
nargs[2] = "-F";
|
||||
nargs[3] = filename.c_str();
|
||||
nargs[4] = "-F";
|
||||
nargs[5] = upload.c_str();
|
||||
nargs[6] = sUploadUrlA.c_str();
|
||||
nargs[7] = "--connect-timeout";
|
||||
nargs[8] = "10";
|
||||
nargs[9] = NULL;
|
||||
case 0: // child process
|
||||
{
|
||||
//curl -v -F filename=image.jpg -F upload=@/home/vladimir/Pictures/Test.png $URL
|
||||
auto filename(std::string("filename=") + sUploadFileNameA);
|
||||
auto upload(std::string("upload=@") + sUploadFilePathA);
|
||||
const char* nargs[10];
|
||||
nargs[0] = "/usr/bin/curl";
|
||||
nargs[1] = "-v";
|
||||
nargs[2] = "-F";
|
||||
nargs[3] = filename.c_str();
|
||||
nargs[4] = "-F";
|
||||
nargs[5] = upload.c_str();
|
||||
nargs[6] = sUploadUrlA.c_str();
|
||||
nargs[7] = "--connect-timeout";
|
||||
nargs[8] = "10";
|
||||
nargs[9] = NULL;
|
||||
|
||||
const char* nenv[3];
|
||||
nenv[0] = "LD_PRELOAD=";
|
||||
nenv[1] = "LD_LIBRARY_PATH=";
|
||||
nenv[2] = NULL;
|
||||
const char* nenv[3];
|
||||
nenv[0] = "LD_PRELOAD=";
|
||||
nenv[1] = "LD_LIBRARY_PATH=";
|
||||
nenv[2] = NULL;
|
||||
|
||||
execve("/usr/bin/curl", (char * const *)nargs, (char * const *)nenv);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
default: // parent process, pid now contains the child pid
|
||||
while (-1 == waitpid(pid, &status, 0)); // wait for child to complete
|
||||
if (WIFEXITED(status))
|
||||
{
|
||||
nReturnCode = WEXITSTATUS(status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
execve("/usr/bin/curl", (char * const *)nargs, (char * const *)nenv);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
default: // parent process, pid now contains the child pid
|
||||
while (-1 == waitpid(pid, &status, 0)); // wait for child to complete
|
||||
if (WIFEXITED(status))
|
||||
{
|
||||
nReturnCode = WEXITSTATUS(status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return nReturnCode;
|
||||
}
|
||||
}
|
||||
return nReturnCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -49,6 +49,7 @@ namespace NSNetwork
|
||||
virtual void send(const std::string& message) = 0;
|
||||
virtual void close() = 0;
|
||||
virtual void setUrl(const std::string& url) = 0;
|
||||
virtual bool setReconnectInfo(const int& attemtCount, const int& delay, const int& delayMax) { return false; }
|
||||
virtual ~IWebSocket() {}
|
||||
};
|
||||
|
||||
|
||||
@ -64,5 +64,11 @@ namespace NSNetwork
|
||||
{
|
||||
delete m_internal;
|
||||
}
|
||||
|
||||
bool CIOWebSocket::setReconnectInfo(const int& attemtCount, const int& delay, const int& delayMax)
|
||||
{
|
||||
m_internal->setReconnectInfo(attemtCount, delay, delayMax);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,6 +63,7 @@ namespace NSNetwork
|
||||
virtual void open(const std::map<std::string, std::string>& query) = 0;
|
||||
virtual void send(const std::string& message) = 0;
|
||||
virtual void close() = 0;
|
||||
virtual void setReconnectInfo(const int& attemtCount, const int& delay, const int& delayMax) = 0;
|
||||
};
|
||||
|
||||
class CIOWebSocket: public CWebWorkerBase
|
||||
@ -78,6 +79,7 @@ namespace NSNetwork
|
||||
virtual void open(const std::map<std::string, std::string>& query) override;
|
||||
virtual void send(const std::string& message) override;
|
||||
virtual void close() override;
|
||||
virtual bool setReconnectInfo(const int& attemtCount, const int& delay, const int& delayMax);
|
||||
|
||||
friend class CIOWebSocket_private;
|
||||
friend class CIOWebSocket_private_tls;
|
||||
|
||||
@ -230,6 +230,13 @@ namespace NSNetwork
|
||||
|
||||
m_socket.reset();
|
||||
}
|
||||
|
||||
virtual void setReconnectInfo(const int& attemtCount, const int& delay, const int& delayMax) override
|
||||
{
|
||||
m_socket->set_reconnect_attempts(attemtCount);
|
||||
m_socket->set_reconnect_delay(delay);
|
||||
m_socket->set_reconnect_delay_max(delayMax);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -234,6 +234,13 @@ namespace NSNetwork
|
||||
|
||||
m_socket.reset();
|
||||
}
|
||||
|
||||
virtual void setReconnectInfo(const int& attemtCount, const int& delay, const int& delayMax) override
|
||||
{
|
||||
m_socket->set_reconnect_attempts(attemtCount);
|
||||
m_socket->set_reconnect_delay(delay);
|
||||
m_socket->set_reconnect_delay_max(delayMax);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ libsocketio:CONFIG += use_openssl
|
||||
ixwebsocket:CONFIG += use_openssl
|
||||
|
||||
use_openssl {
|
||||
include($$PWD/../../3dParty/ixwebsocket/openssl.pri)
|
||||
include($$PWD/../../3dParty/openssl/openssl.pri)
|
||||
}
|
||||
|
||||
libsocketio {
|
||||
@ -59,7 +59,8 @@ libsocketio {
|
||||
_WEBSOCKETPP_CPP11_CHRONO_ \
|
||||
\
|
||||
"SIO_TLS=1" \
|
||||
"SIO_TLS_NO=0"
|
||||
"SIO_TLS_NO=0" \
|
||||
"PING_TIMEOUT_INTERVAL=20000"
|
||||
|
||||
include($$PWD/../../3dParty/boost/boost.pri)
|
||||
|
||||
@ -71,6 +72,13 @@ libsocketio {
|
||||
$$PWD/src/socketio/socketio_internal_private_no_tls.h
|
||||
|
||||
SOURCES += $$PWD/src/socketio/socketio_internal.cpp
|
||||
|
||||
core_linux:LIBS += -lpthread
|
||||
|
||||
core_windows {
|
||||
LIBS += -lcrypt32
|
||||
LIBS += -lUser32
|
||||
}
|
||||
}
|
||||
|
||||
HEADERS += \
|
||||
|
||||
@ -137,7 +137,8 @@ mac {
|
||||
|
||||
gcc {
|
||||
COMPILER_VERSION = $$system($$QMAKE_CXX " -dumpversion")
|
||||
COMPILER_MAJOR_VERSION = $$str_member($$COMPILER_VERSION)
|
||||
COMPILER_MAJOR_VERSION_ARRAY = $$split(COMPILER_VERSION, ".")
|
||||
COMPILER_MAJOR_VERSION = $$member(COMPILER_MAJOR_VERSION_ARRAY, 0)
|
||||
lessThan(COMPILER_MAJOR_VERSION, 5): CONFIG += build_gcc_less_5
|
||||
lessThan(COMPILER_MAJOR_VERSION, 6): CONFIG += build_gcc_less_6
|
||||
}
|
||||
@ -146,6 +147,9 @@ gcc {
|
||||
core_windows {
|
||||
DEFINES += WIN32 _WIN32
|
||||
DEFINES += NOMINMAX
|
||||
|
||||
# use default _ITERATOR_DEBUG_LEVEL value
|
||||
#core_debug:DEFINES += "_ITERATOR_DEBUG_LEVEL=0"
|
||||
}
|
||||
core_win_64 {
|
||||
DEFINES += WIN64 _WIN64
|
||||
@ -384,28 +388,34 @@ core_static_link_libstd {
|
||||
message(core_static_link_libstd)
|
||||
}
|
||||
plugin {
|
||||
QMAKE_CXXFLAGS += -fvisibility=hidden
|
||||
QMAKE_CFLAGS += -fvisibility=hidden
|
||||
|
||||
TARGET_EXT = .so
|
||||
}
|
||||
}
|
||||
|
||||
core_mac {
|
||||
plugin {
|
||||
QMAKE_CXXFLAGS += -fvisibility=hidden
|
||||
QMAKE_CFLAGS += -fvisibility=hidden
|
||||
}
|
||||
}
|
||||
|
||||
core_windows {
|
||||
plugin {
|
||||
TARGET_EXT = .dll
|
||||
}
|
||||
}
|
||||
|
||||
core_disable_all_warnings {
|
||||
CONFIG += warn_off
|
||||
!core_windows {
|
||||
plugin:CONFIG += config_hidden_symbols
|
||||
staticlib:CONFIG += config_hidden_symbols
|
||||
}
|
||||
|
||||
config_hidden_symbols {
|
||||
QMAKE_CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
|
||||
QMAKE_CFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
|
||||
|
||||
core_mac:CONFIG += clang_no_exclude_libs
|
||||
core_ios:CONFIG += clang_no_exclude_libs
|
||||
|
||||
!clang_no_exclude_libs {
|
||||
plugin:QMAKE_LFLAGS += -Wl,--exclude-libs,ALL
|
||||
equals(TEMPLATE, app) {
|
||||
QMAKE_LFLAGS += -Wl,--exclude-libs,ALL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# BUILD_PATHS
|
||||
@ -542,3 +552,11 @@ defineTest(ADD_DEPENDENCY) {
|
||||
|
||||
ADD_INC_PATH = $$(ADDITIONAL_INCLUDE_PATH)
|
||||
!isEmpty(ADD_INC_PATH):INCLUDEPATH += $$ADD_INC_PATH
|
||||
|
||||
!core_enable_all_warnings {
|
||||
core_disable_all_warnings {
|
||||
QMAKE_CXXFLAGS_WARN_OFF = -w
|
||||
QMAKE_CFLAGS_WARN_OFF = -w
|
||||
CONFIG += warn_off
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,14 +18,7 @@ DEFINES += GRAPHICS_USE_DYNAMIC_LIBRARY
|
||||
ADD_DEPENDENCY(graphics, kernel, UnicodeConverter)
|
||||
|
||||
core_windows {
|
||||
DEFINES += \
|
||||
JAS_WIN_MSVC_BUILD \
|
||||
WIN32
|
||||
|
||||
DEFINES -= UNICODE
|
||||
DEFINES -= _DEBUG
|
||||
|
||||
message(windows)
|
||||
|
||||
LIBS += -lAdvapi32
|
||||
LIBS += -lShell32
|
||||
|
||||
@ -1070,6 +1070,8 @@ namespace NSEditorApi
|
||||
js_wrapper<int> m_nInsertPageNum;
|
||||
|
||||
js_wrapper<CAscShadow> m_oShadow;
|
||||
|
||||
js_wrapper<int> m_nVerticalTextAlign;
|
||||
|
||||
public:
|
||||
CAscShapeProp()
|
||||
@ -1094,6 +1096,8 @@ namespace NSEditorApi
|
||||
LINK_PROPERTY_INT_JS(InsertPageNum)
|
||||
|
||||
LINK_PROPERTY_OBJECT_JS(CAscShadow, Shadow)
|
||||
|
||||
LINK_PROPERTY_INT_JS(VerticalTextAlign)
|
||||
};
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -230,11 +230,11 @@ namespace NSStringExt
|
||||
}
|
||||
static inline void ToLower(std::string& wsString)
|
||||
{
|
||||
std::transform(wsString.begin(), wsString.end(), wsString.begin(), ::towlower);
|
||||
std::transform(wsString.begin(), wsString.end(), wsString.begin(), ::tolower);
|
||||
}
|
||||
static inline void ToUpper(std::string& wsString)
|
||||
{
|
||||
std::transform(wsString.begin(), wsString.end(), wsString.begin(), ::towupper);
|
||||
std::transform(wsString.begin(), wsString.end(), wsString.begin(), ::toupper);
|
||||
}
|
||||
static inline void ToLower(std::wstring& wsString)
|
||||
{
|
||||
|
||||
@ -155,7 +155,7 @@ _TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c)
|
||||
return (memcmp(p1, p2, (size_t) c));
|
||||
}
|
||||
|
||||
#ifndef _IOS
|
||||
#if !defined(_IOS) && !defined(DISABLE_IMAGE_EXCEPTIONS)
|
||||
static void
|
||||
Win32WarningHandler(const char* module, const char* fmt, va_list ap)
|
||||
{
|
||||
|
||||
@ -149,17 +149,35 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (true)
|
||||
{
|
||||
NSDoctRenderer::CDocBuilder::Initialize(L"/home/mihail/main/build_tools/out/linux_64/onlyoffice/documentbuilder");
|
||||
NSDoctRenderer::CDocBuilder oBuilder;
|
||||
|
||||
// если отключена эта опция - то она отключится на parse_args
|
||||
oBuilder.SetProperty("--check-fonts", L"");
|
||||
oBuilder.SetProperty("--check-fonts", L"");
|
||||
oBuilder.SetProperty("--cache-scripts", L"false");
|
||||
oBuilder.SetTmpFolder(L"tmp");
|
||||
|
||||
//oBuilder.SetProperty("--use-doctrenderer-scheme", L"");
|
||||
//oBuilder.SetProperty("--work-directory", L"builder");
|
||||
//oBuilder.SetProperty("--use-doctrenderer-scheme", L"");
|
||||
//oBuilder.SetProperty("--work-directory", L"builder");
|
||||
|
||||
parse_args(&oBuilder, argc - 1, argv);
|
||||
|
||||
oBuilder.Run(sBuildFile.c_str());
|
||||
// oBuilder.WriteData(L"result.log", L"Alert!", false);
|
||||
|
||||
// формируем документ SampleTetxt2.docx - с одним вырезанным из SampleDocument.docx абзаца
|
||||
oBuilder.Run(sBuildFile.c_str());
|
||||
// включаем вторую схему сохранения
|
||||
oBuilder.SetProperty("--use-doctrenderer-scheme", L"");
|
||||
// перекрашиваем абзац в красный цвет
|
||||
oBuilder.Run(L"/home/mihail/script2.docbuilder");
|
||||
// oBuilder.OpenFile(L"SampleText2.docx", L"");
|
||||
// oBuilder.ExecuteCommand(L"var oParagraph = Api.GetDocument().GetElement(1);\n"
|
||||
// L"oParagraph.SetColor(255, 0, 0);\n"
|
||||
// L"\n");
|
||||
// // сохраняем
|
||||
// oBuilder.SaveFile(OFFICESTUDIO_FILE_DOCUMENT_DOCX, L"SampleText2.docx");
|
||||
// oBuilder.CloseFile();
|
||||
|
||||
}
|
||||
|
||||
NSDoctRenderer::CDocBuilder::Dispose();
|
||||
|
||||
@ -33,6 +33,15 @@
|
||||
#ifndef _BUILDER_COMMON_H
|
||||
#define _BUILDER_COMMON_H
|
||||
|
||||
#include "./../common/base_export.h"
|
||||
#ifdef DOCTRENDERER_NO_USE_DYNAMIC_LIBRARY
|
||||
#define BUILDER_DECL
|
||||
#else
|
||||
#include "../common/base_export.h"
|
||||
#ifdef DOCTRENDERER_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
#define BUILDER_DECL Q_DECL_EXPORT
|
||||
#else
|
||||
#define BUILDER_DECL Q_DECL_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // _BUILDER_COMMON_H
|
||||
#endif // _BUILDER_COMMON_H
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#define OFFICESTUDIO_FILE_DOCUMENT_TXT OFFICESTUDIO_FILE_DOCUMENT + 0x0005
|
||||
#define OFFICESTUDIO_FILE_DOCUMENT_DOTX OFFICESTUDIO_FILE_DOCUMENT + 0x000c
|
||||
#define OFFICESTUDIO_FILE_DOCUMENT_OTT OFFICESTUDIO_FILE_DOCUMENT + 0x000f
|
||||
#define OFFICESTUDIO_FILE_DOCUMENT_HTML OFFICESTUDIO_FILE_DOCUMENT + 0x0012
|
||||
|
||||
#define OFFICESTUDIO_FILE_PRESENTATION 0x0080
|
||||
#define OFFICESTUDIO_FILE_PRESENTATION_PPTX OFFICESTUDIO_FILE_PRESENTATION + 0x0001
|
||||
|
||||
@ -114,6 +114,7 @@ namespace NSDoctRenderer
|
||||
}
|
||||
}
|
||||
|
||||
bool bIsAbsoluteFontsPath = false;
|
||||
if (!m_bIsNotUseConfigAllFontsDir)
|
||||
{
|
||||
std::wstring sAllFontsPath = oNode.ReadNodeText(L"allfonts");
|
||||
@ -129,7 +130,11 @@ namespace NSDoctRenderer
|
||||
{
|
||||
std::wstring sAppDir = NSSystemUtils::GetAppDataDir();
|
||||
if (NSDirectory::CreateDirectory(sAppDir + L"/docbuilder"))
|
||||
{
|
||||
m_strAllFonts = sAppDir + L"/docbuilder/AllFonts.js";
|
||||
// файл может не существовать пока - и тогда private_GetFile не учтет его
|
||||
bIsAbsoluteFontsPath = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -138,7 +143,7 @@ namespace NSDoctRenderer
|
||||
}
|
||||
}
|
||||
}
|
||||
m_arrFiles.push_back(private_GetFile(sConfigDir, m_strAllFonts));
|
||||
m_arrFiles.push_back(bIsAbsoluteFontsPath ? m_strAllFonts : private_GetFile(sConfigDir, m_strAllFonts));
|
||||
}
|
||||
|
||||
std::wstring sSdkPath = oNode.ReadNodeText(L"sdkjs");
|
||||
|
||||
@ -787,14 +787,7 @@ public:
|
||||
if (NULL == m_pBuilder)
|
||||
return S_FALSE;
|
||||
|
||||
int nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX;
|
||||
CStringW sType = (CString)type;
|
||||
if (L"pptx" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX;
|
||||
else if (L"xlsx" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX;
|
||||
|
||||
bool bRet = m_pBuilder->CreateFile(nType);
|
||||
bool bRet = m_pBuilder->CreateFile(type);
|
||||
*result = bRet ? VARIANT_TRUE : VARIANT_FALSE;
|
||||
return S_OK;
|
||||
}
|
||||
@ -811,41 +804,8 @@ public:
|
||||
if (NULL == m_pBuilder)
|
||||
return S_FALSE;
|
||||
|
||||
int nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX;
|
||||
CStringW sType = (CString)type;
|
||||
if (L"docx" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX;
|
||||
else if (L"doc" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC;
|
||||
else if (L"odt" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT;
|
||||
else if (L"rtf" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_RTF;
|
||||
else if (L"txt" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT;
|
||||
else if (L"pptx" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX;
|
||||
else if (L"odp" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP;
|
||||
else if (L"xlsx" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX;
|
||||
else if (L"xls" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS;
|
||||
else if (L"ods" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS;
|
||||
else if (L"csv" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV;
|
||||
else if (L"pdf" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF;
|
||||
else if (L"image" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_IMAGE;
|
||||
else if (L"jpg" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_IMAGE;
|
||||
else if (L"png" == sType)
|
||||
nType = AVS_OFFICESTUDIO_FILE_IMAGE;
|
||||
|
||||
bool bRet = m_pBuilder->SaveFile(nType, path);
|
||||
*result = bRet ? VARIANT_TRUE : VARIANT_FALSE;
|
||||
int nRet = m_pBuilder->SaveFile(type, path);
|
||||
*result = (nRet == 0) ? VARIANT_TRUE : VARIANT_FALSE;
|
||||
return S_OK;
|
||||
}
|
||||
STDMETHOD(CloseFile)()
|
||||
|
||||
255
DesktopEditor/doctrenderer/docbuilder.com/src/docbuilder_midl.h
Normal file
255
DesktopEditor/doctrenderer/docbuilder.com/src/docbuilder_midl.h
Normal file
@ -0,0 +1,255 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error "C++ compiler required"
|
||||
#endif
|
||||
|
||||
#include "rpc.h"
|
||||
#include "rpcndr.h"
|
||||
|
||||
#ifdef CreateFile
|
||||
#undef CreateFile
|
||||
#endif
|
||||
|
||||
/* Forward Declarations */
|
||||
typedef interface IONLYOFFICEDocBuilderValue IONLYOFFICEDocBuilderValue;
|
||||
typedef interface IONLYOFFICEDocBuilderContextScope IONLYOFFICEDocBuilderContextScope;
|
||||
typedef interface IONLYOFFICEDocBuilderContext IONLYOFFICEDocBuilderContext;
|
||||
typedef interface IONLYOFFICEDocBuilder IONLYOFFICEDocBuilder;
|
||||
|
||||
typedef class CONLYOFFICEDocBuilderValue CONLYOFFICEDocBuilderValue;
|
||||
typedef class CONLYOFFICEDocBuilderContextScope CONLYOFFICEDocBuilderContextScope;
|
||||
typedef class CONLYOFFICEDocBuilderContext CONLYOFFICEDocBuilderContext;
|
||||
typedef class CONLYOFFICEDocBuilder CONLYOFFICEDocBuilder;
|
||||
|
||||
MIDL_INTERFACE("2637FDFA-8473-4CB8-B90B-C23CB949D009")
|
||||
IONLYOFFICEDocBuilderValue : public IDispatch
|
||||
{
|
||||
public:
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CreateInstance(
|
||||
/* [optional][in] */ VARIANT value) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsEmpty(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE Clear( void) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsNull(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsUndefined(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsBool(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsInt(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsDouble(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsString(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsFunction(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsObject(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsArray(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsTypedArray(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE GetLength(
|
||||
/* [retval][out] */ long *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE ToBool(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE ToInt(
|
||||
/* [retval][out] */ long *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE ToDouble(
|
||||
/* [retval][out] */ double *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE ToString(
|
||||
/* [retval][out] */ BSTR *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE GetProperty(
|
||||
/* [in] */ BSTR name,
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderValue **result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE Get(
|
||||
/* [in] */ long index,
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderValue **result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE SetProperty(
|
||||
/* [in] */ BSTR name,
|
||||
/* [in] */ IONLYOFFICEDocBuilderValue *value) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE Set(
|
||||
/* [in] */ long index,
|
||||
/* [in] */ IONLYOFFICEDocBuilderValue *value) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE Call(
|
||||
/* [in] */ BSTR name,
|
||||
/* [optional][in] */ VARIANT val1,
|
||||
/* [optional][in] */ VARIANT val2,
|
||||
/* [optional][in] */ VARIANT val3,
|
||||
/* [optional][in] */ VARIANT val4,
|
||||
/* [optional][in] */ VARIANT val5,
|
||||
/* [optional][in] */ VARIANT val6,
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderValue **result) = 0;
|
||||
|
||||
};
|
||||
|
||||
MIDL_INTERFACE("656ae95c-ae91-4dc0-88bf-0b770fc2d552")
|
||||
IONLYOFFICEDocBuilderContextScope : public IDispatch
|
||||
{
|
||||
public:
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE Close( void) = 0;
|
||||
|
||||
};
|
||||
|
||||
MIDL_INTERFACE("0416975a-65c3-4015-85e4-55d9dafec5fc")
|
||||
IONLYOFFICEDocBuilderContext : public IDispatch
|
||||
{
|
||||
public:
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CreateUndefined(
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderValue **result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CreateNull(
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderValue **result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CreateObject(
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderValue **result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CreateArray(
|
||||
/* [in] */ long length,
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderValue **result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CreateTypedArray(
|
||||
/* [in] */ VARIANT buffer,
|
||||
/* [in] */ long length,
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderValue **result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE GetGlobal(
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderValue **result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CreateScope(
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderContextScope **result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsError(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
};
|
||||
|
||||
MIDL_INTERFACE("0C07B7E7-86A4-42E1-8E42-2FA961992E0F")
|
||||
IONLYOFFICEDocBuilder : public IDispatch
|
||||
{
|
||||
public:
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CreateInstance( void) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE OpenFile(
|
||||
/* [in] */ BSTR path,
|
||||
/* [in] */ BSTR params,
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CreateFile(
|
||||
/* [in] */ BSTR type,
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE SetTmpFolder(
|
||||
/* [in] */ BSTR folder) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE SaveFile(
|
||||
/* [in] */ BSTR type,
|
||||
/* [in] */ BSTR path,
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CloseFile( void) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE ExecuteCommand(
|
||||
/* [in] */ BSTR command,
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE Run(
|
||||
/* [in] */ BSTR path,
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE RunText(
|
||||
/* [in] */ BSTR commands,
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE SetProperty(
|
||||
/* [in] */ BSTR key,
|
||||
/* [in] */ BSTR value) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE Execute(
|
||||
/* [in] */ BSTR command,
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderValue **result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE WriteData(
|
||||
/* [in] */ BSTR path,
|
||||
/* [in] */ BSTR value,
|
||||
/* [in] */ VARIANT_BOOL append) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsSaveWithDoctrendererMode(
|
||||
/* [retval][out] */ VARIANT_BOOL *result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE GetContext(
|
||||
/* [retval][out] */ IONLYOFFICEDocBuilderContext **result) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE Initialize( void) = 0;
|
||||
|
||||
virtual /* [id] */ HRESULT STDMETHODCALLTYPE Dispose( void) = 0;
|
||||
|
||||
};
|
||||
|
||||
class DECLSPEC_UUID("85C41585-25D7-40F1-9CC6-FA17052650F4")
|
||||
CONLYOFFICEDocBuilderValue;
|
||||
|
||||
class DECLSPEC_UUID("c54e2b15-ff5b-45a2-aa15-89a02605c30c")
|
||||
CONLYOFFICEDocBuilderContextScope;
|
||||
|
||||
class DECLSPEC_UUID("299250bb-16c2-4ab4-8a49-a0c350d66bb5")
|
||||
CONLYOFFICEDocBuilderContext;
|
||||
|
||||
class DECLSPEC_UUID("9BF69F3C-1506-41B9-B8EE-2839948C02E9")
|
||||
CONLYOFFICEDocBuilder;
|
||||
@ -3,37 +3,25 @@
|
||||
#include <atlcomcli.h>
|
||||
#include <atlsafe.h>
|
||||
|
||||
#include "../../src/_docbuilder.h"
|
||||
#include "../../src/_docbuilder_i.c"
|
||||
#include "../../src/docbuilder_midl.h"
|
||||
|
||||
#ifdef _NATIVE_WCHAR_T_DEFINED
|
||||
# ifdef _DEBUG
|
||||
# pragma comment(lib, "comsuppwd.lib")
|
||||
# else
|
||||
#ifdef _UNICODE
|
||||
# pragma comment(lib, "comsuppw.lib")
|
||||
# endif
|
||||
#else
|
||||
# ifdef _DEBUG
|
||||
# pragma comment(lib, "comsuppd.lib")
|
||||
# else
|
||||
# pragma comment(lib, "comsupp.lib")
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#define RELEASEINTERFACE(pinterface)\
|
||||
{\
|
||||
if (pinterface!=NULL)\
|
||||
{\
|
||||
pinterface->Release();\
|
||||
pinterface=NULL;\
|
||||
}\
|
||||
#define RELEASEINTERFACE(pinterface) \
|
||||
{ \
|
||||
if (NULL != pinterface) \
|
||||
{ \
|
||||
pinterface->Release(); \
|
||||
pinterface = NULL; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
wchar_t result_path[] = L"result.docx";
|
||||
CoInitialize(NULL);
|
||||
|
||||
IONLYOFFICEDocBuilder* oBuilder = NULL;
|
||||
@ -46,21 +34,18 @@ int main(int argc, char *argv[])
|
||||
IONLYOFFICEDocBuilderValue* oParagraph = NULL;
|
||||
IONLYOFFICEDocBuilderValue* oContent = NULL;
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
hr = CoCreateInstance(__uuidof(CONLYOFFICEDocBuilder), NULL, CLSCTX_ALL,
|
||||
__uuidof(IONLYOFFICEDocBuilder), (void**)&oBuilder);
|
||||
HRESULT hr = CoCreateInstance(__uuidof(CONLYOFFICEDocBuilder), NULL, CLSCTX_ALL, __uuidof(IONLYOFFICEDocBuilder), (void**)&oBuilder);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
std::cout << "Failed!" << std::endl;
|
||||
exit(1);
|
||||
CoUninitialize(); \
|
||||
return 1;
|
||||
}
|
||||
|
||||
VARIANT_BOOL b;
|
||||
|
||||
oBuilder->Initialize();
|
||||
oBuilder->CreateFileW(result_path, &b);
|
||||
oBuilder->CreateFile(_bstr_t("docx"), &b);
|
||||
oBuilder->GetContext(&oContext);
|
||||
|
||||
oContext->CreateScope(&oScope);
|
||||
@ -69,18 +54,17 @@ int main(int argc, char *argv[])
|
||||
oGlobal->GetProperty(_bstr_t("Api"), &oApi);
|
||||
oContext->CreateArray(1, &oContent);
|
||||
|
||||
oApi->Call(_bstr_t(L"GetDocument"), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), &oDocument);
|
||||
oApi->Call(_bstr_t(L"CreateParagraph"), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), &oParagraph);
|
||||
oApi->Call(_bstr_t("GetDocument"), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), &oDocument);
|
||||
oApi->Call(_bstr_t("CreateParagraph"), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), &oParagraph);
|
||||
oContext->CreateArray(1, &oContent);
|
||||
|
||||
|
||||
oParagraph->Call(_bstr_t(L"SetSpacingAfter"), ATL::CComVariant(1000), ATL::CComVariant(VARIANT_FALSE), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), NULL);
|
||||
oParagraph->Call(_bstr_t(L"AddText"), ATL::CComVariant(L"Hello from COM!"), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), NULL);
|
||||
oParagraph->Call(_bstr_t("SetSpacingAfter"), ATL::CComVariant(1000), ATL::CComVariant(VARIANT_FALSE), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), NULL);
|
||||
oParagraph->Call(_bstr_t("AddText"), ATL::CComVariant("Hello from COM!"), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), NULL);
|
||||
oContent->Set(0, oParagraph);
|
||||
|
||||
oDocument->Call(_bstr_t(L"InsertContent"), ATL::CComVariant(oContent), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), NULL);
|
||||
oDocument->Call(_bstr_t("InsertContent"), ATL::CComVariant(oContent), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), ATL::CComVariant(), NULL);
|
||||
|
||||
oBuilder->SaveFile(_bstr_t(".docx"), result_path, &b);
|
||||
oBuilder->SaveFile(_bstr_t("docx"), _bstr_t("result.docx"), &b);
|
||||
|
||||
RELEASEINTERFACE(oContent);
|
||||
|
||||
|
||||
119
DesktopEditor/doctrenderer/docbuilder.com/test/cpp/main2.cpp
Normal file
119
DesktopEditor/doctrenderer/docbuilder.com/test/cpp/main2.cpp
Normal file
@ -0,0 +1,119 @@
|
||||
#include <iostream>
|
||||
#include <comutil.h>
|
||||
#include <atlcomcli.h>
|
||||
#include <atlsafe.h>
|
||||
#include <string>
|
||||
|
||||
#include "../../src/docbuilder_midl.h"
|
||||
|
||||
#ifdef _UNICODE
|
||||
# pragma comment(lib, "comsuppw.lib")
|
||||
#else
|
||||
# pragma comment(lib, "comsupp.lib")
|
||||
#endif
|
||||
|
||||
#define RELEASEINTERFACE(pinterface) \
|
||||
{ \
|
||||
if (NULL != pinterface) \
|
||||
{ \
|
||||
pinterface->Release(); \
|
||||
pinterface = NULL; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define EMPTY_PARAM ATL::CComVariant()
|
||||
#define _B(x) _bstr_t(L##x)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// uncomment for debug js
|
||||
//SetEnvironmentVariableA("V8_USE_INSPECTOR", "1");
|
||||
|
||||
CoInitialize(NULL);
|
||||
|
||||
IONLYOFFICEDocBuilder* pBuilder = NULL;
|
||||
if (FAILED(CoCreateInstance(__uuidof(CONLYOFFICEDocBuilder), NULL, CLSCTX_ALL, __uuidof(IONLYOFFICEDocBuilder), (void**)&pBuilder)))
|
||||
{
|
||||
CoUninitialize();
|
||||
return 1;
|
||||
}
|
||||
|
||||
VARIANT_BOOL bRes;
|
||||
pBuilder->Initialize();
|
||||
pBuilder->OpenFile(_B("file.docx"), _B(""), &bRes);
|
||||
//pBuilder->SaveFile(_B("html"), _B("D:/FILES/images.html"), &bRes);
|
||||
|
||||
IONLYOFFICEDocBuilderContext* pContext = NULL;
|
||||
pBuilder->GetContext(&pContext);
|
||||
|
||||
IONLYOFFICEDocBuilderContextScope* pScope = NULL;
|
||||
pContext->CreateScope(&pScope);
|
||||
|
||||
IONLYOFFICEDocBuilderValue* pGlobal = NULL;
|
||||
pContext->GetGlobal(&pGlobal);
|
||||
|
||||
IONLYOFFICEDocBuilderValue* pApi = NULL;
|
||||
pGlobal->GetProperty(_B("Api"), &pApi);
|
||||
IONLYOFFICEDocBuilderValue* pDocument = NULL;
|
||||
pApi->Call(_B("GetDocument"), EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, &pDocument);
|
||||
|
||||
IONLYOFFICEDocBuilderValue* pRanges = NULL;
|
||||
pDocument->Call(_B("Search"), ATL::CComVariant("year"), EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, &pRanges);
|
||||
|
||||
if (pRanges)
|
||||
{
|
||||
VARIANT_BOOL vbIsArray = VARIANT_FALSE;
|
||||
pRanges->IsArray(&vbIsArray);
|
||||
|
||||
if (VARIANT_TRUE == vbIsArray)
|
||||
{
|
||||
long nCount = 0;
|
||||
pRanges->GetLength(&nCount);
|
||||
|
||||
if (0 < nCount)
|
||||
{
|
||||
IONLYOFFICEDocBuilderValue* pSearchRange = NULL;
|
||||
pRanges->Get(0, &pSearchRange);
|
||||
|
||||
IONLYOFFICEDocBuilderValue* pComment = NULL;
|
||||
pSearchRange->Call(_B("AddComment"), ATL::CComVariant("Comment Text"), ATL::CComVariant("Author"),
|
||||
EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, &pComment);
|
||||
|
||||
IONLYOFFICEDocBuilderValue* pCommentID = NULL;
|
||||
pComment->Call(_B("GetId"), EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, EMPTY_PARAM, &pCommentID);
|
||||
|
||||
// get comment id.
|
||||
// work with comment:
|
||||
// https://api.onlyoffice.com/docbuilder/textdocumentapi/apidocument/getcommentbyid
|
||||
// https://api.onlyoffice.com/docbuilder/textdocumentapi/apicomment
|
||||
|
||||
BSTR bsCommentId = NULL;
|
||||
pCommentID->ToString(&bsCommentId);
|
||||
SysFreeString(bsCommentId);
|
||||
|
||||
RELEASEINTERFACE(pCommentID);
|
||||
RELEASEINTERFACE(pComment);
|
||||
RELEASEINTERFACE(pSearchRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RELEASEINTERFACE(pRanges);
|
||||
RELEASEINTERFACE(pDocument);
|
||||
RELEASEINTERFACE(pApi);
|
||||
|
||||
RELEASEINTERFACE(pGlobal);
|
||||
RELEASEINTERFACE(pScope);
|
||||
RELEASEINTERFACE(pContext);
|
||||
|
||||
pBuilder->SaveFile(_B("docx"), _B("file.docx"), &bRes);
|
||||
|
||||
pBuilder->CloseFile();
|
||||
pBuilder->Dispose();
|
||||
|
||||
RELEASEINTERFACE(pBuilder);
|
||||
|
||||
CoUninitialize();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -59,6 +59,10 @@ namespace NSDoctRenderer
|
||||
{
|
||||
return m_pInternal->SaveFile(type, path, params);
|
||||
}
|
||||
int CDocBuilder::SaveFile(const wchar_t* extension, const wchar_t* path, const wchar_t* params)
|
||||
{
|
||||
return m_pInternal->SaveFile(extension, path, params);
|
||||
}
|
||||
bool CDocBuilder::ExecuteCommand(const wchar_t* command, CDocBuilderValue* retValue)
|
||||
{
|
||||
return m_pInternal->ExecuteCommand(command, retValue);
|
||||
|
||||
@ -41,7 +41,7 @@ namespace NSDoctRenderer
|
||||
* The string class with the wchar_t* property.
|
||||
*/
|
||||
class CString_Private;
|
||||
class Q_DECL_EXPORT CString
|
||||
class BUILDER_DECL CString
|
||||
{
|
||||
public:
|
||||
CString();
|
||||
@ -61,7 +61,7 @@ namespace NSDoctRenderer
|
||||
* It represents a wrapper for a JS object.
|
||||
*/
|
||||
class CDocBuilderValue_Private;
|
||||
class Q_DECL_EXPORT CDocBuilderValue
|
||||
class BUILDER_DECL CDocBuilderValue
|
||||
{
|
||||
public:
|
||||
CDocBuilderValue();
|
||||
@ -238,7 +238,7 @@ namespace NSDoctRenderer
|
||||
* All opened scopes will be closed automatically when the builder CloseFile method is called.
|
||||
*/
|
||||
class CDocBuilderContextScope_Private;
|
||||
class Q_DECL_EXPORT CDocBuilderContextScope
|
||||
class BUILDER_DECL CDocBuilderContextScope
|
||||
{
|
||||
public:
|
||||
CDocBuilderContextScope();
|
||||
@ -261,7 +261,7 @@ namespace NSDoctRenderer
|
||||
* Class for getting JS context for working.
|
||||
*/
|
||||
class CDocBuilderContext_Private;
|
||||
class Q_DECL_EXPORT CDocBuilderContext
|
||||
class BUILDER_DECL CDocBuilderContext
|
||||
{
|
||||
public:
|
||||
CDocBuilderContext();
|
||||
@ -333,7 +333,7 @@ namespace NSDoctRenderer
|
||||
* Base class used by ONLYOFFICE Document Builder for the document file (text document, spreadsheet, presentation, form document, PDF) to be generated.
|
||||
*/
|
||||
class CDocBuilder_Private;
|
||||
class Q_DECL_EXPORT CDocBuilder
|
||||
class BUILDER_DECL CDocBuilder
|
||||
{
|
||||
public:
|
||||
CDocBuilder();
|
||||
@ -355,6 +355,7 @@ namespace NSDoctRenderer
|
||||
* @return True if the operation is successful
|
||||
*/
|
||||
bool CreateFile(const int& type);
|
||||
bool CreateFile(const wchar_t* extension);
|
||||
/**
|
||||
* Sets the path to the folder where the program will temporarily save files needed for the program correct work.
|
||||
* After the successful document file creation, all the files will be deleted from the folder. If no temporary folder is set, the system one will be used.
|
||||
@ -380,6 +381,7 @@ namespace NSDoctRenderer
|
||||
* @return Process x2t return code
|
||||
*/
|
||||
int SaveFile(const int& type, const wchar_t* path, const wchar_t* params = 0);
|
||||
int SaveFile(const wchar_t* extension, const wchar_t* path, const wchar_t* params = 0);
|
||||
/**
|
||||
* Closes the file to stop working with it. You can use a single ONLYOFFICE Document Builder instance
|
||||
* to work with all your files, but you need to close the previous file before you can
|
||||
|
||||
@ -49,7 +49,8 @@ namespace docbuilder_net
|
||||
RTF = MASK + 0x0004,
|
||||
TXT = MASK + 0x0005,
|
||||
DOTX = MASK + 0x000c,
|
||||
OTT = MASK + 0x000f
|
||||
OTT = MASK + 0x000f,
|
||||
HTML = MASK + 0x0012
|
||||
};
|
||||
|
||||
public enum class Spreadsheet : int
|
||||
|
||||
@ -48,18 +48,13 @@ CV8RealTimeWorker::CV8RealTimeWorker(NSDoctRenderer::CDocBuilder* pBuilder)
|
||||
m_nFileType = -1;
|
||||
|
||||
m_context = new CJSContext();
|
||||
m_context->Initialize();
|
||||
m_context->CreateContext();
|
||||
CJSContextScope scope(m_context);
|
||||
|
||||
m_isolate_scope = m_context->CreateIsolateScope();
|
||||
m_handle_scope = m_context->CreateLocalScope();
|
||||
|
||||
m_context->CreateGlobalForContext();
|
||||
CNativeControlEmbed::CreateObjectBuilderInContext("CreateNativeEngine", m_context);
|
||||
CGraphicsEmbed::CreateObjectInContext("CreateNativeGraphics", m_context);
|
||||
NSJSBase::CreateDefaults(m_context);
|
||||
m_context->CreateContext();
|
||||
|
||||
JSSmart<CJSContextScope> context_scope = m_context->CreateContextScope();
|
||||
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
|
||||
|
||||
builder_CreateNative("builderJS", m_context, pBuilder);
|
||||
@ -67,14 +62,12 @@ CV8RealTimeWorker::CV8RealTimeWorker(NSDoctRenderer::CDocBuilder* pBuilder)
|
||||
CV8RealTimeWorker::~CV8RealTimeWorker()
|
||||
{
|
||||
m_oContextData.Clear();
|
||||
m_handle_scope = NULL;
|
||||
m_isolate_scope = NULL;
|
||||
m_context->Dispose();
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue)
|
||||
{
|
||||
LOGGER_SPEED_START
|
||||
LOGGER_SPEED_START();
|
||||
|
||||
if (retValue)
|
||||
retValue->Clear();
|
||||
@ -82,10 +75,10 @@ bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRender
|
||||
std::string commandA = U_TO_UTF8(command);
|
||||
//commandA = "Api." + commandA;
|
||||
|
||||
JSSmart<CJSContextScope> context_scope = m_context->CreateContextScope();
|
||||
CJSContextScope scope(m_context);
|
||||
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
|
||||
|
||||
LOGGER_SPEED_LAP("compile_command")
|
||||
LOGGER_SPEED_LAP("compile_command");
|
||||
|
||||
JSSmart<CJSValue> retNativeVal = m_context->runScript(commandA, try_catch);
|
||||
if(try_catch->Check())
|
||||
@ -98,7 +91,7 @@ bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRender
|
||||
privateRet->m_value = retNativeVal;
|
||||
}
|
||||
|
||||
LOGGER_SPEED_LAP("run_command")
|
||||
LOGGER_SPEED_LAP("run_command");
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -107,7 +100,7 @@ std::string CV8RealTimeWorker::GetGlobalVariable()
|
||||
{
|
||||
std::string commandA = "JSON.stringify(GlobalVariable);";
|
||||
|
||||
JSSmart<CJSContextScope> context_scope = m_context->CreateContextScope();
|
||||
CJSContextScope scope(m_context);
|
||||
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
|
||||
|
||||
JSSmart<CJSValue> _value = m_context->runScript(commandA, try_catch);
|
||||
@ -124,7 +117,7 @@ std::wstring CV8RealTimeWorker::GetJSVariable(std::wstring sParam)
|
||||
NSStringUtils::string_replaceA(sParamA, "\\\"", "\"");
|
||||
std::string commandA = "(function(){ return (" + sParamA + "); })()";
|
||||
|
||||
JSSmart<CJSContextScope> context_scope = m_context->CreateContextScope();
|
||||
CJSContextScope scope(m_context);
|
||||
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
|
||||
|
||||
JSSmart<CJSValue> _value = m_context->runScript(commandA, try_catch);
|
||||
@ -137,10 +130,10 @@ std::wstring CV8RealTimeWorker::GetJSVariable(std::wstring sParam)
|
||||
|
||||
bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstring& path, const std::string& sString, const std::wstring& sCachePath, CV8Params* pParams)
|
||||
{
|
||||
LOGGER_SPEED_START
|
||||
LOGGER_SPEED_START();
|
||||
|
||||
JSSmart<CJSContextScope> context_scope = m_context->CreateContextScope();
|
||||
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
|
||||
CJSContextScope scope(m_context);
|
||||
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
|
||||
|
||||
LOGGER_SPEED_LAP("compile");
|
||||
|
||||
@ -148,7 +141,7 @@ bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstri
|
||||
if(try_catch->Check())
|
||||
return false;
|
||||
|
||||
LOGGER_SPEED_LAP("run")
|
||||
LOGGER_SPEED_LAP("run");
|
||||
|
||||
if (true)
|
||||
{
|
||||
@ -246,8 +239,10 @@ bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstri
|
||||
bIsBreak = !this->ExecuteCommand(L"Api.asc_nativeInitBuilder();");
|
||||
if (!bIsBreak)
|
||||
bIsBreak = !this->ExecuteCommand(L"Api.asc_SetSilentMode(true);");
|
||||
if (!bIsBreak)
|
||||
bIsBreak = !this->ExecuteCommand(L"Api.asc_showComments();");
|
||||
|
||||
LOGGER_SPEED_LAP("open")
|
||||
LOGGER_SPEED_LAP("open");
|
||||
|
||||
return !bIsBreak;
|
||||
}
|
||||
@ -259,10 +254,12 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
|
||||
_formatDst = NSDoctRenderer::DoctRendererFormat::PPTT;
|
||||
else if (type & AVS_OFFICESTUDIO_FILE_SPREADSHEET)
|
||||
_formatDst = NSDoctRenderer::DoctRendererFormat::XLST;
|
||||
else if ((type & AVS_OFFICESTUDIO_FILE_CROSSPLATFORM) || (type & AVS_OFFICESTUDIO_FILE_IMAGE))
|
||||
else if (type & AVS_OFFICESTUDIO_FILE_CROSSPLATFORM)
|
||||
_formatDst = NSDoctRenderer::DoctRendererFormat::PDF;
|
||||
else if (type & AVS_OFFICESTUDIO_FILE_IMAGE)
|
||||
_formatDst = NSDoctRenderer::DoctRendererFormat::IMAGE;
|
||||
|
||||
JSSmart<CJSContextScope> context_scope = m_context->CreateContextScope();
|
||||
CJSContextScope scope(m_context);
|
||||
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
|
||||
|
||||
NSNativeControl::CNativeControl* pNative = NULL;
|
||||
@ -285,7 +282,12 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
|
||||
if (pNative == NULL)
|
||||
return false;
|
||||
|
||||
if (_formatDst == NSDoctRenderer::DoctRendererFormat::PDF)
|
||||
bool bIsSilentMode = false;
|
||||
if (_formatDst == NSDoctRenderer::DoctRendererFormat::PDF ||
|
||||
_formatDst == NSDoctRenderer::DoctRendererFormat::IMAGE)
|
||||
bIsSilentMode = true;
|
||||
|
||||
if (bIsSilentMode)
|
||||
this->ExecuteCommand(L"Api.asc_SetSilentMode(false);");
|
||||
|
||||
std::wstring strError;
|
||||
@ -297,7 +299,7 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
|
||||
strError,
|
||||
sJsonParams);
|
||||
|
||||
if (_formatDst == NSDoctRenderer::DoctRendererFormat::PDF)
|
||||
if (bIsSilentMode)
|
||||
this->ExecuteCommand(L"Api.asc_SetSilentMode(true);");
|
||||
|
||||
return bIsError;
|
||||
@ -1051,7 +1053,7 @@ namespace NSDoctRenderer
|
||||
{
|
||||
CDocBuilderContextScope ret;
|
||||
ret.m_internal->m_scope_wrap = new CDocBuilderContextScopeWrap();
|
||||
ret.m_internal->m_scope_wrap->m_scope = m_internal->m_context->CreateContextScope();
|
||||
ret.m_internal->m_scope_wrap->m_scope = new CJSContextScope(m_internal->m_context);
|
||||
ret.m_internal->m_context_data = m_internal->m_context_data;
|
||||
|
||||
m_internal->m_context_data->AddScope(ret.m_internal->m_scope_wrap);
|
||||
@ -1111,6 +1113,19 @@ namespace NSDoctRenderer
|
||||
|
||||
return m_pInternal->CreateFile(type);
|
||||
}
|
||||
bool CDocBuilder::CreateFile(const wchar_t* extension)
|
||||
{
|
||||
std::wstring sType = (NULL != extension) ? std::wstring(extension) : L"docx";
|
||||
int type = AVS_OFFICESTUDIO_FILE_DOCUMENT;
|
||||
|
||||
if (L"pptx" == sType)
|
||||
type = AVS_OFFICESTUDIO_FILE_PRESENTATION;
|
||||
else if (L"xlsx" == sType)
|
||||
type = AVS_OFFICESTUDIO_FILE_SPREADSHEET;
|
||||
|
||||
return CreateFile(type);
|
||||
}
|
||||
|
||||
void CDocBuilder::SetTmpFolder(const wchar_t* folder)
|
||||
{
|
||||
if (m_pInternal->m_bIsServerSafeVersion)
|
||||
|
||||
@ -58,6 +58,7 @@
|
||||
#endif
|
||||
|
||||
#include "../fontengine/ApplicationFontsWorker.h"
|
||||
#include "../../OfficeUtils/src/OfficeUtils.h"
|
||||
|
||||
#ifdef CreateFile
|
||||
#undef CreateFile
|
||||
@ -391,8 +392,6 @@ public:
|
||||
class CV8RealTimeWorker
|
||||
{
|
||||
public:
|
||||
JSSmart<CJSIsolateScope> m_isolate_scope;
|
||||
JSSmart<CJSLocalScope> m_handle_scope;
|
||||
JSSmart<CJSContext> m_context;
|
||||
|
||||
int m_nFileType;
|
||||
@ -888,7 +887,7 @@ namespace NSDoctRenderer
|
||||
{
|
||||
Init();
|
||||
|
||||
LOGGER_SPEED_START
|
||||
LOGGER_SPEED_START();
|
||||
|
||||
CheckFileDir();
|
||||
NSDirectory::CreateDirectory(m_sFileDir + L"/changes");
|
||||
@ -910,7 +909,7 @@ namespace NSDoctRenderer
|
||||
|
||||
int nReturnCode = ConvertToInternalFormat(m_sFileDir, sFileCopy, params);
|
||||
|
||||
LOGGER_SPEED_LAP("open_convert")
|
||||
LOGGER_SPEED_LAP("open_convert");
|
||||
|
||||
if (0 == nReturnCode)
|
||||
return 0;
|
||||
@ -968,9 +967,9 @@ namespace NSDoctRenderer
|
||||
return 1;
|
||||
}
|
||||
|
||||
LOGGER_SPEED_START
|
||||
LOGGER_SPEED_START();
|
||||
|
||||
std::wstring sConvertionParams = L"";
|
||||
std::wstring sConvertionParams = L"";
|
||||
if (NULL != params)
|
||||
{
|
||||
sConvertionParams = std::wstring(params);
|
||||
@ -1161,13 +1160,34 @@ namespace NSDoctRenderer
|
||||
}
|
||||
#endif
|
||||
|
||||
// html correct (TODO: move to x2t)
|
||||
if (0 == nReturnCode && type == AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML_IN_CONTAINER)
|
||||
{
|
||||
COfficeUtils oUtils;
|
||||
if (S_OK == oUtils.IsArchive(_path))
|
||||
{
|
||||
std::wstring sTmpFile = sDstTmpDir + L"/tmp_html";
|
||||
NSDirectory::CreateDirectory(sTmpFile);
|
||||
if (S_OK == oUtils.ExtractToDirectory(_path, sTmpFile, NULL, 0))
|
||||
{
|
||||
std::vector<std::wstring> arFiles = NSDirectory::GetFiles(sTmpFile);
|
||||
if (arFiles.size() == 1)
|
||||
{
|
||||
NSFile::CFileBinary::Remove(_path);
|
||||
NSFile::CFileBinary::Move(arFiles[0], _path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NSDirectory::DeleteDirectory(sDstTmpDir);
|
||||
NSFile::CFileBinary::Remove(sTempFileForParams);
|
||||
|
||||
LOGGER_SPEED_LAP("save_convert")
|
||||
LOGGER_SPEED_LAP("save_convert");
|
||||
|
||||
if (0 == nReturnCode)
|
||||
return 0;
|
||||
if (0 == nReturnCode)
|
||||
return 0;
|
||||
|
||||
std::wstring sErrorLog = L"save file error (" + std::to_wstring(nReturnCode) + L")";
|
||||
CV8RealTimeWorker::_LOGGING_ERROR_(L"error: ", sErrorLog);
|
||||
@ -1204,6 +1224,45 @@ namespace NSDoctRenderer
|
||||
return true;
|
||||
}
|
||||
|
||||
int SaveFile(const std::wstring& ext, const std::wstring& path, const wchar_t* params = NULL)
|
||||
{
|
||||
int nType = -1;
|
||||
if (L"docx" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX;
|
||||
else if (L"doc" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC;
|
||||
else if (L"odt" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT;
|
||||
else if (L"rtf" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_RTF;
|
||||
else if (L"txt" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT;
|
||||
else if (L"pptx" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX;
|
||||
else if (L"odp" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP;
|
||||
else if (L"xlsx" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX;
|
||||
else if (L"xls" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS;
|
||||
else if (L"ods" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS;
|
||||
else if (L"csv" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV;
|
||||
else if (L"pdf" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF;
|
||||
else if (L"image" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_IMAGE;
|
||||
else if (L"jpg" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_IMAGE;
|
||||
else if (L"png" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_IMAGE;
|
||||
else if (L"html" == ext)
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML_IN_CONTAINER;
|
||||
|
||||
return SaveFile(nType, path, params);
|
||||
}
|
||||
|
||||
bool ExecuteCommand(const std::wstring& command, CDocBuilderValue* retValue = NULL)
|
||||
{
|
||||
if (command.length() < 7 && !retValue) // minimum command (!!!)
|
||||
|
||||
@ -391,6 +391,7 @@ namespace NSDoctRenderer
|
||||
}
|
||||
case DoctRendererFormat::PDF:
|
||||
case DoctRendererFormat::PPTX_THEME_THUMBNAIL:
|
||||
case DoctRendererFormat::IMAGE:
|
||||
{
|
||||
// CALCULATE
|
||||
if (pParams->m_sJsonParams.empty())
|
||||
@ -423,14 +424,28 @@ namespace NSDoctRenderer
|
||||
}
|
||||
|
||||
// RENDER
|
||||
if (!bIsBreak && DoctRendererFormat::PDF == pParams->m_eDstFormat)
|
||||
if (!bIsBreak &&
|
||||
(DoctRendererFormat::PDF == pParams->m_eDstFormat || DoctRendererFormat::IMAGE == pParams->m_eDstFormat))
|
||||
{
|
||||
if (pParams->m_sJsonParams.empty())
|
||||
args[0] = CJSContext::createNull();
|
||||
{
|
||||
if (DoctRendererFormat::IMAGE == pParams->m_eDstFormat)
|
||||
{
|
||||
args[0] = context->JSON_Parse("{ \"saveFormat\" : \"image\" }");
|
||||
}
|
||||
else
|
||||
args[0] = CJSContext::createNull();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string sTmp = U_TO_UTF8((pParams->m_sJsonParams));
|
||||
args[0] = context->JSON_Parse(sTmp.c_str());
|
||||
|
||||
if (DoctRendererFormat::IMAGE == pParams->m_eDstFormat)
|
||||
{
|
||||
JSSmart<CJSObject> argObj = args[0]->toObject();
|
||||
argObj->set("saveFormat", CJSContext::createString("image"));
|
||||
}
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> js_result2 = js_objectApi->call_func("asc_nativeGetPDF", 1, args);
|
||||
@ -535,39 +550,34 @@ namespace NSDoctRenderer
|
||||
|
||||
bool ExecuteScript(const std::string& strScript, const std::wstring& sCachePath, std::wstring& strError, std::wstring& strReturnParams)
|
||||
{
|
||||
LOGGER_SPEED_START
|
||||
LOGGER_SPEED_START();
|
||||
|
||||
bool bIsBreak = false;
|
||||
bool bIsBreak = false;
|
||||
JSSmart<CJSContext> context = new CJSContext();
|
||||
context->Initialize();
|
||||
|
||||
if (true)
|
||||
{
|
||||
JSSmart<CJSIsolateScope> isolate_scope = context->CreateIsolateScope();
|
||||
JSSmart<CJSLocalScope> handle_scope = context->CreateLocalScope();
|
||||
|
||||
context->CreateGlobalForContext();
|
||||
context->CreateContext();
|
||||
CJSContextScope scope(context);
|
||||
CNativeControlEmbed::CreateObjectBuilderInContext("CreateNativeEngine", context);
|
||||
CGraphicsEmbed::CreateObjectInContext("CreateNativeGraphics", context);
|
||||
NSJSBase::CreateDefaults(context);
|
||||
context->CreateContext();
|
||||
|
||||
JSSmart<CJSContextScope> context_scope = context->CreateContextScope();
|
||||
JSSmart<CJSTryCatch> try_catch = context->GetExceptions();
|
||||
|
||||
LOGGER_SPEED_LAP("compile")
|
||||
LOGGER_SPEED_LAP("compile");
|
||||
|
||||
JSSmart<CJSValue> res = context->runScript(strScript, try_catch, sCachePath);
|
||||
JSSmart<CJSValue> res = context->runScript(strScript, try_catch, sCachePath);
|
||||
if(try_catch->Check())
|
||||
{
|
||||
strError = L"code=\"run\"";
|
||||
bIsBreak = true;
|
||||
}
|
||||
|
||||
LOGGER_SPEED_LAP("run")
|
||||
LOGGER_SPEED_LAP("run");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
JSSmart<CJSObject> global_js = context->GetGlobal();
|
||||
//---------------------------------------------------------------
|
||||
JSSmart<CJSObject> global_js = context->GetGlobal();
|
||||
JSSmart<CJSValue> args[1];
|
||||
args[0] = CJSContext::createInt(0);
|
||||
|
||||
@ -653,10 +663,10 @@ namespace NSDoctRenderer
|
||||
}
|
||||
}
|
||||
|
||||
LOGGER_SPEED_LAP("open")
|
||||
LOGGER_SPEED_LAP("open");
|
||||
|
||||
// CHANGES
|
||||
if (!bIsBreak)
|
||||
// CHANGES
|
||||
if (!bIsBreak)
|
||||
{
|
||||
if (m_oParams.m_arChanges.size() != 0)
|
||||
{
|
||||
@ -704,9 +714,9 @@ namespace NSDoctRenderer
|
||||
}
|
||||
}
|
||||
|
||||
LOGGER_SPEED_LAP("changes")
|
||||
LOGGER_SPEED_LAP("changes");
|
||||
|
||||
bool bIsMailMerge = false;
|
||||
bool bIsMailMerge = false;
|
||||
if (!m_oParams.m_strMailMergeDatabasePath.empty() &&
|
||||
m_oParams.m_nMailMergeIndexEnd >= m_oParams.m_nMailMergeIndexStart &&
|
||||
m_oParams.m_nMailMergeIndexEnd >= 0)
|
||||
@ -825,7 +835,7 @@ namespace NSDoctRenderer
|
||||
bIsBreak = Doct_renderer_SaveFile(&m_oParams, pNative, context, args, strError, js_objectApi);
|
||||
}
|
||||
|
||||
LOGGER_SPEED_LAP("save")
|
||||
LOGGER_SPEED_LAP("save");
|
||||
}
|
||||
|
||||
context->Dispose();
|
||||
@ -891,6 +901,7 @@ namespace NSDoctRenderer
|
||||
{
|
||||
case DoctRendererFormat::DOCT:
|
||||
case DoctRendererFormat::PDF:
|
||||
case DoctRendererFormat::IMAGE:
|
||||
case DoctRendererFormat::HTML:
|
||||
{
|
||||
arSdkFiles = &m_pInternal->m_arDoctSDK;
|
||||
@ -908,6 +919,7 @@ namespace NSDoctRenderer
|
||||
{
|
||||
case DoctRendererFormat::PPTT:
|
||||
case DoctRendererFormat::PDF:
|
||||
case DoctRendererFormat::IMAGE:
|
||||
case DoctRendererFormat::PPTX_THEME_THUMBNAIL:
|
||||
{
|
||||
arSdkFiles = &m_pInternal->m_arPpttSDK;
|
||||
@ -925,6 +937,7 @@ namespace NSDoctRenderer
|
||||
{
|
||||
case DoctRendererFormat::XLST:
|
||||
case DoctRendererFormat::PDF:
|
||||
case DoctRendererFormat::IMAGE:
|
||||
{
|
||||
arSdkFiles = &m_pInternal->m_arXlstSDK;
|
||||
m_pInternal->m_strEditorType = L"spreadsheet";
|
||||
@ -1077,20 +1090,15 @@ namespace NSDoctRenderer
|
||||
strScript += "\n$.ready();";
|
||||
|
||||
JSSmart<CJSContext> context = new CJSContext();
|
||||
context->Initialize();
|
||||
|
||||
if (true)
|
||||
{
|
||||
JSSmart<CJSIsolateScope> isolate_scope = context->CreateIsolateScope();
|
||||
JSSmart<CJSLocalScope> handle_scope = context->CreateLocalScope();
|
||||
|
||||
context->CreateGlobalForContext();
|
||||
context->CreateContext();
|
||||
CJSContextScope scope(context);
|
||||
CNativeControlEmbed::CreateObjectBuilderInContext("CreateNativeEngine", context);
|
||||
CGraphicsEmbed::CreateObjectInContext("CreateNativeGraphics", context);
|
||||
NSJSBase::CreateDefaults(context);
|
||||
context->CreateContext();
|
||||
|
||||
JSSmart<CJSContextScope> context_scope = context->CreateContextScope();
|
||||
JSSmart<CJSTryCatch> try_catch = context->GetExceptions();
|
||||
|
||||
context->runScript(strScript, try_catch, sCachePath);
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../common/base_export.h"
|
||||
#include "./common.h"
|
||||
|
||||
namespace NSDoctRenderer
|
||||
{
|
||||
@ -48,6 +48,7 @@ namespace NSDoctRenderer
|
||||
PDF = 3,
|
||||
HTML = 4,
|
||||
PPTX_THEME_THUMBNAIL = 5,
|
||||
IMAGE = 6,
|
||||
|
||||
INVALID = 255
|
||||
};
|
||||
@ -57,7 +58,7 @@ namespace NSDoctRenderer
|
||||
namespace NSDoctRenderer
|
||||
{
|
||||
class CDoctRenderer_Private;
|
||||
class Q_DECL_EXPORT CDoctrenderer
|
||||
class BUILDER_DECL CDoctrenderer
|
||||
{
|
||||
public:
|
||||
CDoctrenderer(const std::wstring& sAllFontsPath = L"");
|
||||
|
||||
@ -12,21 +12,12 @@ CORE_ROOT_DIR = $$PWD/../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include(../../Common/base.pri)
|
||||
|
||||
DEFINES += DOCTRENDERER_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
ADD_DEPENDENCY(graphics, kernel, UnicodeConverter, kernel_network)
|
||||
|
||||
#CONFIG += build_xp
|
||||
core_android:DEFINES += DISABLE_MEMORY_LIMITATION
|
||||
|
||||
core_ios {
|
||||
CONFIG += doct_renderer_empty
|
||||
}
|
||||
core_android {
|
||||
DEFINES += DISABLE_MEMORY_LIMITATION
|
||||
CONFIG += doct_renderer_empty
|
||||
}
|
||||
|
||||
doct_renderer_empty {
|
||||
SOURCES += doctrenderer_empty.cpp
|
||||
} else {
|
||||
HEADERS += \
|
||||
config.h \
|
||||
doctrenderer.h \
|
||||
@ -37,7 +28,8 @@ SOURCES += \
|
||||
doctrenderer.cpp \
|
||||
docbuilder.cpp \
|
||||
docbuilder_p.cpp \
|
||||
graphics.cpp
|
||||
graphics.cpp \
|
||||
hash.cpp
|
||||
|
||||
SOURCES += \
|
||||
../../Common/OfficeFileFormatChecker2.cpp \
|
||||
@ -47,7 +39,8 @@ SOURCES += \
|
||||
HEADERS += \
|
||||
docbuilder_p.h \
|
||||
nativecontrol.h \
|
||||
graphics.h
|
||||
graphics.h \
|
||||
hash.h
|
||||
|
||||
HEADERS += \
|
||||
embed/PointerEmbed.h \
|
||||
@ -57,6 +50,8 @@ HEADERS += \
|
||||
embed/NativeControlEmbed.h \
|
||||
embed/NativeBuilderEmbed.h \
|
||||
embed/TextMeasurerEmbed.h \
|
||||
embed/HashEmbed.h \
|
||||
embed/Default.h \
|
||||
js_internal/js_base.h
|
||||
|
||||
SOURCES += \
|
||||
@ -66,13 +61,10 @@ SOURCES += \
|
||||
embed/MemoryStreamEmbed.cpp \
|
||||
embed/NativeControlEmbed.cpp \
|
||||
embed/NativeBuilderEmbed.cpp \
|
||||
embed/TextMeasurerEmbed.cpp
|
||||
embed/TextMeasurerEmbed.cpp \
|
||||
embed/HashEmbed.cpp \
|
||||
embed/Default.cpp
|
||||
|
||||
core_mac {
|
||||
!use_v8:CONFIG += use_javascript_core
|
||||
}
|
||||
|
||||
#CONFIG += v8_use_inspector
|
||||
include($$PWD/js_internal/js_base.pri)
|
||||
|
||||
!use_javascript_core {
|
||||
@ -82,8 +74,9 @@ include($$PWD/js_internal/js_base.pri)
|
||||
embed/v8/v8_NativeBuilder.cpp \
|
||||
embed/v8/v8_Graphics.cpp \
|
||||
embed/v8/v8_Zip.cpp \
|
||||
embed/v8/v8_Pointer.cpp \
|
||||
embed/v8/v8_TextMeasurer.cpp
|
||||
embed/v8/v8_Pointer.cpp \
|
||||
embed/v8/v8_TextMeasurer.cpp \
|
||||
embed/v8/v8_Hash.cpp
|
||||
|
||||
build_xp:DESTDIR=$$DESTDIR/xp
|
||||
} else {
|
||||
@ -94,14 +87,15 @@ include($$PWD/js_internal/js_base.pri)
|
||||
embed/jsc/jsc_NativeControl.mm \
|
||||
embed/jsc/jsc_NativeBuilder.mm \
|
||||
embed/jsc/jsc_Zip.mm \
|
||||
embed/jsc/jsc_Pointer.mm \
|
||||
embed/jsc/jsc_TextMeasurer.mm
|
||||
embed/jsc/jsc_Pointer.mm \
|
||||
embed/jsc/jsc_TextMeasurer.mm \
|
||||
embed/jsc/jsc_Hash.mm
|
||||
|
||||
LIBS += -framework Foundation
|
||||
}
|
||||
}
|
||||
|
||||
include(../graphics/pro/textshaper.pri)
|
||||
include(../../Common/3dParty/openssl/openssl.pri)
|
||||
|
||||
# downloader
|
||||
DEFINES += BUIDLER_OPEN_DOWNLOAD_ENABLED
|
||||
|
||||
@ -1,195 +0,0 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#include "doctrenderer.h"
|
||||
#include "docbuilder.h"
|
||||
|
||||
#ifdef BOOL
|
||||
#undef BOOL
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace NSDoctRenderer
|
||||
{
|
||||
CString::CString() {}
|
||||
CString::CString(const CString& src) {}
|
||||
CString& CString::operator=(const CString& src) { return *this; }
|
||||
wchar_t* CString::c_str() const { return NULL; }
|
||||
|
||||
CDocBuilderValue::CDocBuilderValue() {}
|
||||
CDocBuilderValue::CDocBuilderValue(const CDocBuilderValue& src) {}
|
||||
CDocBuilderValue& CDocBuilderValue::operator=(const CDocBuilderValue& src) { return *this; }
|
||||
CDocBuilderValue::~CDocBuilderValue() {}
|
||||
void* private_get_internal() { return NULL; }
|
||||
|
||||
bool CDocBuilderValue::IsEmpty() { return true; }
|
||||
void CDocBuilderValue::Clear() {}
|
||||
|
||||
bool CDocBuilderValue::IsNull() { return false; }
|
||||
bool CDocBuilderValue::IsUndefined() { return false; }
|
||||
bool CDocBuilderValue::IsBool() { return false; }
|
||||
bool CDocBuilderValue::IsInt() { return false; }
|
||||
bool CDocBuilderValue::IsDouble() { return false; }
|
||||
bool CDocBuilderValue::IsString() { return false; }
|
||||
bool CDocBuilderValue::IsFunction() { return false; }
|
||||
bool CDocBuilderValue::IsObject() { return false; }
|
||||
bool CDocBuilderValue::IsArray() { return false; }
|
||||
bool CDocBuilderValue::IsTypedArray() { return false; }
|
||||
|
||||
unsigned int CDocBuilderValue::GetLength() { return 0; }
|
||||
bool CDocBuilderValue::ToBool() { return false; }
|
||||
int CDocBuilderValue::ToInt() { return 0; }
|
||||
double CDocBuilderValue::ToDouble() { return 0; }
|
||||
CString CDocBuilderValue::ToString() { return CString(); }
|
||||
|
||||
CDocBuilderValue CDocBuilderValue::GetProperty(const wchar_t* name) { CDocBuilderValue ret; return ret; }
|
||||
|
||||
CDocBuilderValue CDocBuilderValue::Get(const char* name) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Get(const wchar_t* name) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::operator[](const char* name) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::operator[](const wchar_t* name) { CDocBuilderValue ret; return ret; }
|
||||
|
||||
CDocBuilderValue CDocBuilderValue::Get(const int& index) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::operator[](const int& index) { CDocBuilderValue ret; return ret; }
|
||||
|
||||
void CDocBuilderValue::SetProperty(const wchar_t* name, CDocBuilderValue value) {}
|
||||
void CDocBuilderValue::Set(const wchar_t* name, CDocBuilderValue value) {}
|
||||
void CDocBuilderValue::Set(const int& index, CDocBuilderValue value) {}
|
||||
|
||||
// primitives
|
||||
CDocBuilderValue::CDocBuilderValue(const bool& value) {}
|
||||
CDocBuilderValue::CDocBuilderValue(const int& value) {}
|
||||
CDocBuilderValue::CDocBuilderValue(const unsigned int& value) {}
|
||||
CDocBuilderValue::CDocBuilderValue(const double& value) {}
|
||||
CDocBuilderValue::CDocBuilderValue(const char* value) {}
|
||||
CDocBuilderValue::CDocBuilderValue(const wchar_t* value) {}
|
||||
|
||||
CDocBuilderValue CDocBuilderValue::CreateUndefined() { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::CreateNull() { CDocBuilderValue ret; return ret; }
|
||||
|
||||
CDocBuilderValue CDocBuilderValue::Call(const char* name) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const char* name, CDocBuilderValue p1) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const char* name, CDocBuilderValue p1, CDocBuilderValue p2) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const char* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const char* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3, CDocBuilderValue p4) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const char* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3, CDocBuilderValue p4, CDocBuilderValue p5) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const char* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3, CDocBuilderValue p4, CDocBuilderValue p5, CDocBuilderValue p6) { CDocBuilderValue ret; return ret; }
|
||||
|
||||
CDocBuilderValue CDocBuilderValue::Call(const wchar_t* name) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const wchar_t* name, CDocBuilderValue p1) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const wchar_t* name, CDocBuilderValue p1, CDocBuilderValue p2) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const wchar_t* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const wchar_t* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3, CDocBuilderValue p4) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const wchar_t* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3, CDocBuilderValue p4, CDocBuilderValue p5) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderValue::Call(const wchar_t* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3, CDocBuilderValue p4, CDocBuilderValue p5, CDocBuilderValue p6) { CDocBuilderValue ret; return ret; }
|
||||
|
||||
CDocBuilderContextScope::CDocBuilderContextScope() {}
|
||||
CDocBuilderContextScope::CDocBuilderContextScope(const CDocBuilderContextScope& src) {}
|
||||
CDocBuilderContextScope& CDocBuilderContextScope::operator=(const CDocBuilderContextScope& src) { return *this; }
|
||||
CDocBuilderContextScope::~CDocBuilderContextScope() {}
|
||||
void CDocBuilderContextScope::Close() {}
|
||||
|
||||
CDocBuilderContext::CDocBuilderContext() {}
|
||||
CDocBuilderContext::CDocBuilderContext(const CDocBuilderContext& src) {}
|
||||
CDocBuilderContext& CDocBuilderContext::operator=(const CDocBuilderContext& src) { return *this; }
|
||||
CDocBuilderContext::~CDocBuilderContext() {}
|
||||
|
||||
CDocBuilderValue CDocBuilderContext::CreateUndefined() { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderContext::CreateNull() { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderContext::CreateObject() { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderContext::CreateArray(const int& length) { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderValue CDocBuilderContext::CreateTypedArray(unsigned char* buffer, const int& length, const bool& externalize) { CDocBuilderValue ret; return ret; }
|
||||
|
||||
CDocBuilderValue CDocBuilderContext::GetGlobal() { CDocBuilderValue ret; return ret; }
|
||||
CDocBuilderContextScope CDocBuilderContext::CreateScope() { CDocBuilderContextScope ret; return ret; }
|
||||
bool CDocBuilderContext::IsError() { return true; }
|
||||
}
|
||||
|
||||
namespace NSDoctRenderer
|
||||
{
|
||||
CDocBuilder::CDocBuilder() {}
|
||||
CDocBuilder::~CDocBuilder() {}
|
||||
|
||||
int CDocBuilder::OpenFile(const wchar_t* path, const wchar_t* params) { return 0; }
|
||||
bool CDocBuilder::CreateFile(const int& type) { return false; }
|
||||
void CDocBuilder::SetTmpFolder(const wchar_t* folder) {}
|
||||
int CDocBuilder::SaveFile(const int& type, const wchar_t* path, const wchar_t* params) { return 0; }
|
||||
void CDocBuilder::CloseFile() {}
|
||||
bool CDocBuilder::ExecuteCommand(const wchar_t* command, CDocBuilderValue* retValue) { return false; }
|
||||
|
||||
bool CDocBuilder::Run(const wchar_t* path) { return false; }
|
||||
|
||||
bool CDocBuilder::RunTextW(const wchar_t* commands) { return false; }
|
||||
bool CDocBuilder::RunTextA(const char* commands) { return false; }
|
||||
|
||||
void CDocBuilder::SetProperty(const char* param, const wchar_t* value) {}
|
||||
void CDocBuilder::SetPropertyW(const wchar_t* param, const wchar_t* value) {}
|
||||
|
||||
void CDocBuilder::WriteData(const wchar_t* path, const wchar_t* value, const bool& append) {}
|
||||
bool CDocBuilder::IsSaveWithDoctrendererMode() { return false; }
|
||||
|
||||
char* CDocBuilder::GetVersion() { return "0.0"; }
|
||||
|
||||
CDocBuilderContext CDocBuilder::GetContext()
|
||||
{
|
||||
return CDocBuilderContext();
|
||||
}
|
||||
|
||||
void CDocBuilder::Initialize(const wchar_t* directory) {}
|
||||
void CDocBuilder::Dispose() {}
|
||||
}
|
||||
|
||||
namespace NSDoctRenderer
|
||||
{
|
||||
CDoctrenderer::CDoctrenderer(const std::wstring& sAllFontsPath) {}
|
||||
|
||||
CDoctrenderer::~CDoctrenderer() {}
|
||||
|
||||
void CDoctrenderer::LoadConfig(const std::wstring& sConfigDir, const std::wstring& sAllFontsPath)
|
||||
{
|
||||
}
|
||||
|
||||
bool CDoctrenderer::Execute(const std::wstring& strXml, std::wstring& strError)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::wstring> CDoctrenderer::GetImagesInChanges()
|
||||
{
|
||||
std::vector<std::wstring> stub;
|
||||
return stub;
|
||||
}
|
||||
|
||||
void CDoctrenderer::CreateCache(const std::wstring& sAllFontsPath, const std::wstring& sCacheDir)
|
||||
{
|
||||
}
|
||||
}
|
||||
17
DesktopEditor/doctrenderer/embed/Default.cpp
Normal file
17
DesktopEditor/doctrenderer/embed/Default.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include "Default.h"
|
||||
|
||||
#include "./ZipEmbed.h"
|
||||
#include "./TextMeasurerEmbed.h"
|
||||
#include "./MemoryStreamEmbed.h"
|
||||
#include "./HashEmbed.h"
|
||||
|
||||
namespace NSJSBase
|
||||
{
|
||||
void CreateDefaults(JSSmart<CJSContext>& context)
|
||||
{
|
||||
CZipEmbed::CreateObjectInContext("CreateNativeZip", context);
|
||||
CTextMeasurerEmbed::CreateObjectInContext("CreateNativeTextMeasurer", context);
|
||||
CMemoryStreamEmbed::CreateObjectInContext("CreateNativeMemoryStream", context);
|
||||
CHashEmbed::CreateObjectInContext("CreateNativeHash", context);
|
||||
}
|
||||
}
|
||||
@ -1,18 +1,11 @@
|
||||
#ifndef _BUILD_NATIVE_DEFAULT_EMBED_H_
|
||||
#define _BUILD_NATIVE_DEFAULT_EMBED_H_
|
||||
|
||||
#include "./ZipEmbed.h"
|
||||
#include "./TextMeasurerEmbed.h"
|
||||
#include "./MemoryStreamEmbed.h"
|
||||
#include "../js_internal/js_base.h"
|
||||
|
||||
namespace NSJSBase
|
||||
{
|
||||
static void CreateDefaults(JSSmart<CJSContext>& context)
|
||||
{
|
||||
CZipEmbed::CreateObjectInContext("CreateNativeZip", context);
|
||||
CTextMeasurerEmbed::CreateObjectInContext("CreateNativeTextMeasurer", context);
|
||||
CMemoryStreamEmbed::CreateObjectInContext("CreateNativeMemoryStream", context);
|
||||
}
|
||||
void JS_DECL CreateDefaults(JSSmart<CJSContext>& context);
|
||||
}
|
||||
|
||||
#endif // _BUILD_NATIVE_DEFAULT_EMBED_H_
|
||||
|
||||
@ -2,565 +2,565 @@
|
||||
|
||||
JSSmart<CJSValue> CGraphicsEmbed::init(JSSmart<CJSValue> Native, JSSmart<CJSValue> width_px, JSSmart<CJSValue> height_px, JSSmart<CJSValue> width_mm, JSSmart<CJSValue> height_mm)
|
||||
{
|
||||
m_pInternal->init((NSNativeControl::CNativeControl*)Native->toObjectSmart()->getNative()->getObject(), width_px->toDouble(), height_px->toDouble(), width_mm->toDouble(), height_mm->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->init((NSNativeControl::CNativeControl*)Native->toObjectSmart()->getNative()->getObject(), width_px->toDouble(), height_px->toDouble(), width_mm->toDouble(), height_mm->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::Destroy()
|
||||
{
|
||||
m_pInternal->Destroy();
|
||||
return NULL;
|
||||
m_pInternal->Destroy();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::EndDraw()
|
||||
{
|
||||
m_pInternal->EndDraw();
|
||||
return NULL;
|
||||
m_pInternal->EndDraw();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::put_GlobalAlpha(JSSmart<CJSValue> enable, JSSmart<CJSValue> globalAlpha)
|
||||
{
|
||||
m_pInternal->put_GlobalAlpha(enable->toBool(), globalAlpha->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->put_GlobalAlpha(enable->toBool(), globalAlpha->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::Start_GlobalAlpha()
|
||||
{
|
||||
m_pInternal->Start_GlobalAlpha();
|
||||
return NULL;
|
||||
m_pInternal->Start_GlobalAlpha();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::End_GlobalAlpha()
|
||||
{
|
||||
m_pInternal->End_GlobalAlpha();
|
||||
return NULL;
|
||||
m_pInternal->End_GlobalAlpha();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::p_color(JSSmart<CJSValue> r, JSSmart<CJSValue> g, JSSmart<CJSValue> b, JSSmart<CJSValue> a)
|
||||
{
|
||||
m_pInternal->p_color(r->toInt32(), g->toInt32(), b->toInt32(), a->toInt32());
|
||||
return NULL;
|
||||
m_pInternal->p_color(r->toInt32(), g->toInt32(), b->toInt32(), a->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::p_width(JSSmart<CJSValue> w)
|
||||
{
|
||||
m_pInternal->p_width(w->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->p_width(w->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::p_dash(JSSmart<CJSValue> params)
|
||||
{
|
||||
JSSmart<CJSArray> items = params->toArray();
|
||||
size_t length = items->getCount();
|
||||
double* dash = NULL;
|
||||
if(length > 0)
|
||||
dash = new double[length];
|
||||
for(size_t i = 0; i < length; i++)
|
||||
dash[i] = items->get(i)->toDouble();
|
||||
m_pInternal->p_dash(length, dash);
|
||||
RELEASEARRAYOBJECTS(dash);
|
||||
return NULL;
|
||||
JSSmart<CJSArray> items = params->toArray();
|
||||
size_t length = items->getCount();
|
||||
double* dash = NULL;
|
||||
if(length > 0)
|
||||
dash = new double[length];
|
||||
for(size_t i = 0; i < length; i++)
|
||||
dash[i] = items->get(i)->toDouble();
|
||||
m_pInternal->p_dash(length, dash);
|
||||
RELEASEARRAYOBJECTS(dash);
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::b_color1(JSSmart<CJSValue> r, JSSmart<CJSValue> g, JSSmart<CJSValue> b, JSSmart<CJSValue> a)
|
||||
{
|
||||
m_pInternal->b_color1(r->toInt32(), g->toInt32(), b->toInt32(), a->toInt32());
|
||||
return NULL;
|
||||
m_pInternal->b_color1(r->toInt32(), g->toInt32(), b->toInt32(), a->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::b_color2(JSSmart<CJSValue> r, JSSmart<CJSValue> g, JSSmart<CJSValue> b, JSSmart<CJSValue> a)
|
||||
{
|
||||
m_pInternal->b_color2(r->toInt32(), g->toInt32(), b->toInt32(), a->toInt32());
|
||||
return NULL;
|
||||
m_pInternal->b_color2(r->toInt32(), g->toInt32(), b->toInt32(), a->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::transform(JSSmart<CJSValue> sx, JSSmart<CJSValue> shy, JSSmart<CJSValue> shx, JSSmart<CJSValue> sy, JSSmart<CJSValue> tx, JSSmart<CJSValue> ty)
|
||||
{
|
||||
m_pInternal->transform(sx->toDouble(), shy->toDouble(), shx->toDouble(), sy->toDouble(), tx->toDouble(), ty->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->transform(sx->toDouble(), shy->toDouble(), shx->toDouble(), sy->toDouble(), tx->toDouble(), ty->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::CalculateFullTransform(JSSmart<CJSValue> isInvertNeed)
|
||||
{
|
||||
m_pInternal->CalculateFullTransform();
|
||||
return NULL;
|
||||
m_pInternal->CalculateFullTransform();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::_s()
|
||||
{
|
||||
m_pInternal->_s();
|
||||
return NULL;
|
||||
m_pInternal->_s();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::_e()
|
||||
{
|
||||
m_pInternal->_e();
|
||||
return NULL;
|
||||
m_pInternal->_e();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::_z()
|
||||
{
|
||||
m_pInternal->_z();
|
||||
return NULL;
|
||||
m_pInternal->_z();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::_m (JSSmart<CJSValue> x, JSSmart<CJSValue> y)
|
||||
{
|
||||
m_pInternal->_m(x->toDouble(), y->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->_m(x->toDouble(), y->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::_l (JSSmart<CJSValue> x, JSSmart<CJSValue> y)
|
||||
{
|
||||
m_pInternal->_l(x->toDouble(), y->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->_l(x->toDouble(), y->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::_c (JSSmart<CJSValue> x1, JSSmart<CJSValue> y1, JSSmart<CJSValue> x2, JSSmart<CJSValue> y2, JSSmart<CJSValue> x3, JSSmart<CJSValue> y3)
|
||||
{
|
||||
m_pInternal->_c(x1->toDouble(), y1->toDouble(), x2->toDouble(), y2->toDouble(), x3->toDouble(), y3->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->_c(x1->toDouble(), y1->toDouble(), x2->toDouble(), y2->toDouble(), x3->toDouble(), y3->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::_c2(JSSmart<CJSValue> x1, JSSmart<CJSValue> y1, JSSmart<CJSValue> x2, JSSmart<CJSValue> y2)
|
||||
{
|
||||
m_pInternal->_c2(x1->toDouble(), y1->toDouble(), x2->toDouble(), y2->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->_c2(x1->toDouble(), y1->toDouble(), x2->toDouble(), y2->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::ds()
|
||||
{
|
||||
m_pInternal->ds();
|
||||
return NULL;
|
||||
m_pInternal->ds();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::df()
|
||||
{
|
||||
m_pInternal->df();
|
||||
return NULL;
|
||||
m_pInternal->df();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::save()
|
||||
{
|
||||
m_pInternal->save();
|
||||
return NULL;
|
||||
m_pInternal->save();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::restore()
|
||||
{
|
||||
m_pInternal->restore();
|
||||
return NULL;
|
||||
m_pInternal->restore();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::clip()
|
||||
{
|
||||
m_pInternal->clip();
|
||||
return NULL;
|
||||
m_pInternal->clip();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::reset()
|
||||
{
|
||||
m_pInternal->reset();
|
||||
return NULL;
|
||||
m_pInternal->reset();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::FreeFont()
|
||||
{
|
||||
m_pInternal->FreeFont();
|
||||
return NULL;
|
||||
m_pInternal->FreeFont();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::ClearLastFont()
|
||||
{
|
||||
m_pInternal->ClearLastFont();
|
||||
return NULL;
|
||||
m_pInternal->ClearLastFont();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::drawImage2(JSSmart<CJSValue> img, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h, JSSmart<CJSValue> alpha, JSSmart<CJSValue> srcRect)
|
||||
{
|
||||
m_pInternal->drawImage(img->toStringW(), x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble(), alpha->toInt32());
|
||||
return NULL;
|
||||
m_pInternal->drawImage(img->toStringW(), x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble(), alpha->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::drawImage (JSSmart<CJSValue> img, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h, JSSmart<CJSValue> alpha, JSSmart<CJSValue> srcRect, JSSmart<CJSValue> nativeImage)
|
||||
{
|
||||
m_pInternal->drawImage(img->toStringW(), x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble(), alpha->toInt32());
|
||||
return NULL;
|
||||
m_pInternal->drawImage(img->toStringW(), x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble(), alpha->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::GetFont()
|
||||
{
|
||||
return CJSContext::createString(m_pInternal->GetFont());
|
||||
return CJSContext::createString(m_pInternal->GetFont());
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::font(JSSmart<CJSValue> font_id, JSSmart<CJSValue> font_size)
|
||||
{
|
||||
m_pInternal->font();
|
||||
return NULL;
|
||||
m_pInternal->font();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::SetFont(JSSmart<CJSValue> path, JSSmart<CJSValue> face, JSSmart<CJSValue> size, JSSmart<CJSValue> style)
|
||||
{
|
||||
m_pInternal->SetFont(path->toStringW(), face->toInt32(), size->toDouble(), style->toInt32());
|
||||
return NULL;
|
||||
m_pInternal->SetFont(path->toStringW(), face->toInt32(), size->toDouble(), style->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::GetTextPr()
|
||||
{
|
||||
m_pInternal->GetTextPr();
|
||||
return NULL;
|
||||
m_pInternal->GetTextPr();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::FillText(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> text)
|
||||
{
|
||||
m_pInternal->FillText(x->toDouble(), y->toDouble(), text->toInt32());
|
||||
return NULL;
|
||||
m_pInternal->FillText(x->toDouble(), y->toDouble(), text->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::t(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> _arr)
|
||||
{
|
||||
m_pInternal->t(x->toDouble(), y->toDouble(), _arr->toStringW());
|
||||
return NULL;
|
||||
m_pInternal->t(x->toDouble(), y->toDouble(), _arr->toStringW());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::FillText2(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> text, JSSmart<CJSValue> cropX, JSSmart<CJSValue> cropW)
|
||||
{
|
||||
m_pInternal->FillText(x->toDouble(), y->toDouble(), text->toInt32());
|
||||
return NULL;
|
||||
m_pInternal->FillText(x->toDouble(), y->toDouble(), text->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::t2(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> _arr, JSSmart<CJSValue> cropX, JSSmart<CJSValue> cropW)
|
||||
{
|
||||
m_pInternal->t(x->toDouble(), y->toDouble(), _arr->toStringW());
|
||||
return NULL;
|
||||
m_pInternal->t(x->toDouble(), y->toDouble(), _arr->toStringW());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::FillTextCode(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> lUnicode)
|
||||
{
|
||||
m_pInternal->FillText(x->toDouble(), y->toDouble(), lUnicode->toInt32());
|
||||
return NULL;
|
||||
m_pInternal->FillText(x->toDouble(), y->toDouble(), lUnicode->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::tg(JSSmart<CJSValue> text, JSSmart<CJSValue> x, JSSmart<CJSValue> y)
|
||||
{
|
||||
m_pInternal->tg(text->toInt32(), x->toDouble(), y->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->tg(text->toInt32(), x->toDouble(), y->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::charspace(JSSmart<CJSValue> space)
|
||||
{
|
||||
m_pInternal->charspace();
|
||||
return NULL;
|
||||
m_pInternal->charspace();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::private_FillGlyph (JSSmart<CJSValue> pGlyph, JSSmart<CJSValue> _bounds)
|
||||
{
|
||||
m_pInternal->private_FillGlyph();
|
||||
return NULL;
|
||||
m_pInternal->private_FillGlyph();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::private_FillGlyphC(JSSmart<CJSValue> pGlyph, JSSmart<CJSValue> cropX, JSSmart<CJSValue> cropW)
|
||||
{
|
||||
m_pInternal->private_FillGlyphC();
|
||||
return NULL;
|
||||
m_pInternal->private_FillGlyphC();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::private_FillGlyph2(JSSmart<CJSValue> pGlyph)
|
||||
{
|
||||
m_pInternal->private_FillGlyph2();
|
||||
return NULL;
|
||||
m_pInternal->private_FillGlyph2();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::SetIntegerGrid(JSSmart<CJSValue> param)
|
||||
{
|
||||
m_pInternal->SetIntegerGrid(param->toBool());
|
||||
return NULL;
|
||||
m_pInternal->SetIntegerGrid(param->toBool());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::GetIntegerGrid()
|
||||
{
|
||||
return CJSContext::createBool(m_pInternal->GetIntegerGrid());
|
||||
return CJSContext::createBool(m_pInternal->GetIntegerGrid());
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::DrawStringASCII (JSSmart<CJSValue> text, JSSmart<CJSValue> x, JSSmart<CJSValue> y)
|
||||
{
|
||||
m_pInternal->DrawStringASCII(text->toStringW(), x->toDouble(), y->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->DrawStringASCII(text->toStringW(), x->toDouble(), y->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::DrawStringASCII2(JSSmart<CJSValue> text, JSSmart<CJSValue> x, JSSmart<CJSValue> y)
|
||||
{
|
||||
m_pInternal->DrawStringASCII(text->toStringW(), x->toDouble(), y->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->DrawStringASCII(text->toStringW(), x->toDouble(), y->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::DrawHeaderEdit(JSSmart<CJSValue> yPos, JSSmart<CJSValue> lock_type, JSSmart<CJSValue> sectionNum, JSSmart<CJSValue> bIsRepeat, JSSmart<CJSValue> type)
|
||||
{
|
||||
m_pInternal->DrawHeaderEdit(yPos->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->DrawHeaderEdit(yPos->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::DrawFooterEdit(JSSmart<CJSValue> yPos, JSSmart<CJSValue> lock_type, JSSmart<CJSValue> sectionNum, JSSmart<CJSValue> bIsRepeat, JSSmart<CJSValue> type)
|
||||
{
|
||||
m_pInternal->DrawFooterEdit(yPos->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->DrawFooterEdit(yPos->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::DrawLockParagraph (JSSmart<CJSValue> x, JSSmart<CJSValue> y1, JSSmart<CJSValue> y2)
|
||||
{
|
||||
m_pInternal->DrawLockParagraph(x->toDouble(), y1->toDouble(), y2->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->DrawLockParagraph(x->toDouble(), y1->toDouble(), y2->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::DrawLockObjectRect(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h)
|
||||
{
|
||||
m_pInternal->DrawLockObjectRect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->DrawLockObjectRect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::DrawEmptyTableLine(JSSmart<CJSValue> x1, JSSmart<CJSValue> y1, JSSmart<CJSValue> x2, JSSmart<CJSValue> y2)
|
||||
{
|
||||
m_pInternal->DrawEmptyTableLine(x1->toDouble(), y1->toDouble(), x2->toDouble(), y2->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->DrawEmptyTableLine(x1->toDouble(), y1->toDouble(), x2->toDouble(), y2->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::DrawSpellingLine (JSSmart<CJSValue> y0, JSSmart<CJSValue> x0, JSSmart<CJSValue> x1, JSSmart<CJSValue> w)
|
||||
{
|
||||
m_pInternal->DrawSpellingLine(y0->toDouble(), x0->toDouble(), x1->toDouble(), w->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->DrawSpellingLine(y0->toDouble(), x0->toDouble(), x1->toDouble(), w->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::drawHorLine (JSSmart<CJSValue> align, JSSmart<CJSValue> y, JSSmart<CJSValue> x, JSSmart<CJSValue> r, JSSmart<CJSValue> penW)
|
||||
{
|
||||
m_pInternal->drawHorLine(align->toInt32(), y->toDouble(), x->toDouble(), r->toDouble(), penW->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->drawHorLine(align->toInt32(), y->toDouble(), x->toDouble(), r->toDouble(), penW->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::drawHorLine2(JSSmart<CJSValue> align, JSSmart<CJSValue> y, JSSmart<CJSValue> x, JSSmart<CJSValue> r, JSSmart<CJSValue> penW)
|
||||
{
|
||||
m_pInternal->drawHorLine2(align->toInt32(), y->toDouble(), x->toDouble(), r->toDouble(), penW->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->drawHorLine2(align->toInt32(), y->toDouble(), x->toDouble(), r->toDouble(), penW->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::drawVerLine (JSSmart<CJSValue> align, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> b, JSSmart<CJSValue> penW)
|
||||
{
|
||||
m_pInternal->drawVerLine(align->toInt32(), x->toDouble(), y->toDouble(), b->toDouble(), penW->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->drawVerLine(align->toInt32(), x->toDouble(), y->toDouble(), b->toDouble(), penW->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::drawHorLineExt(JSSmart<CJSValue> align, JSSmart<CJSValue> y, JSSmart<CJSValue> x, JSSmart<CJSValue> r, JSSmart<CJSValue> penW, JSSmart<CJSValue> leftMW, JSSmart<CJSValue> rightMW)
|
||||
{
|
||||
m_pInternal->drawHorLineExt(align->toInt32(), y->toDouble(), x->toDouble(), r->toDouble(), penW->toDouble(), leftMW->toDouble(), rightMW->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->drawHorLineExt(align->toInt32(), y->toDouble(), x->toDouble(), r->toDouble(), penW->toDouble(), leftMW->toDouble(), rightMW->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::rect (JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h)
|
||||
{
|
||||
m_pInternal->rect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->rect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::TableRect(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h)
|
||||
{
|
||||
m_pInternal->TableRect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->TableRect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::AddClipRect(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h)
|
||||
{
|
||||
m_pInternal->AddClipRect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->AddClipRect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::RemoveClipRect()
|
||||
{
|
||||
m_pInternal->RemoveClipRect();
|
||||
return NULL;
|
||||
m_pInternal->RemoveClipRect();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::SetClip(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h)
|
||||
{
|
||||
m_pInternal->SetClip(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->SetClip(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::RemoveClip()
|
||||
{
|
||||
m_pInternal->restore();
|
||||
return NULL;
|
||||
m_pInternal->restore();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::drawMailMergeField(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h)
|
||||
{
|
||||
m_pInternal->drawMailMergeField(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->drawMailMergeField(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::drawSearchResult (JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h)
|
||||
{
|
||||
m_pInternal->drawSearchResult(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->drawSearchResult(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::drawFlowAnchor (JSSmart<CJSValue> x, JSSmart<CJSValue> y)
|
||||
{
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::SavePen()
|
||||
{
|
||||
m_pInternal->SavePen();
|
||||
return NULL;
|
||||
m_pInternal->SavePen();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::RestorePen()
|
||||
{
|
||||
m_pInternal->RestorePen();
|
||||
return NULL;
|
||||
m_pInternal->RestorePen();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::SaveBrush()
|
||||
{
|
||||
m_pInternal->SaveBrush();
|
||||
return NULL;
|
||||
m_pInternal->SaveBrush();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::RestoreBrush()
|
||||
{
|
||||
m_pInternal->RestoreBrush();
|
||||
return NULL;
|
||||
m_pInternal->RestoreBrush();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::SavePenBrush()
|
||||
{
|
||||
m_pInternal->SavePenBrush();
|
||||
return NULL;
|
||||
m_pInternal->SavePenBrush();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::RestorePenBrush()
|
||||
{
|
||||
m_pInternal->RestorePenBrush();
|
||||
return NULL;
|
||||
m_pInternal->RestorePenBrush();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::SaveGrState()
|
||||
{
|
||||
m_pInternal->SaveGrState();
|
||||
return NULL;
|
||||
m_pInternal->SaveGrState();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::RestoreGrState()
|
||||
{
|
||||
m_pInternal->RestoreGrState();
|
||||
return NULL;
|
||||
m_pInternal->RestoreGrState();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::StartClipPath()
|
||||
{
|
||||
m_pInternal->StartClipPath();
|
||||
return NULL;
|
||||
m_pInternal->StartClipPath();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::EndClipPath()
|
||||
{
|
||||
m_pInternal->EndClipPath();
|
||||
return NULL;
|
||||
m_pInternal->EndClipPath();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::StartCheckTableDraw()
|
||||
{
|
||||
return CJSContext::createBool(m_pInternal->StartCheckTableDraw());
|
||||
return CJSContext::createBool(m_pInternal->StartCheckTableDraw());
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::SetTextClipRect(JSSmart<CJSValue> _l, JSSmart<CJSValue> _t, JSSmart<CJSValue> _r, JSSmart<CJSValue> _b)
|
||||
{
|
||||
m_pInternal->SetTextClipRect(_l->toDouble(), _t->toDouble(), _r->toDouble(), _b->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->SetTextClipRect(_l->toDouble(), _t->toDouble(), _r->toDouble(), _b->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::AddSmartRect (JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h, JSSmart<CJSValue> pen_w)
|
||||
{
|
||||
m_pInternal->rect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->rect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::CheckUseFonts2 (JSSmart<CJSValue> _transform)
|
||||
{
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::UncheckUseFonts2()
|
||||
{
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::Drawing_StartCheckBounds(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h)
|
||||
{
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::Drawing_EndCheckBounds()
|
||||
{
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::DrawPresentationComment(JSSmart<CJSValue> type, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h)
|
||||
{
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::DrawPolygon(JSSmart<CJSValue> oPath, JSSmart<CJSValue> lineWidth, JSSmart<CJSValue> shift)
|
||||
{
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::DrawFootnoteRect(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h)
|
||||
{
|
||||
m_pInternal->DrawFootnoteRect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->DrawFootnoteRect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::toDataURL(JSSmart<CJSValue> type)
|
||||
{
|
||||
return CJSContext::createString(m_pInternal->toDataURL(type->toStringW()));
|
||||
return CJSContext::createString(m_pInternal->toDataURL(type->toStringW()));
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::GetPenColor()
|
||||
{
|
||||
JSSmart<CJSObject> e = CJSContext::createObject();
|
||||
NSGraphics::CColor res = m_pInternal->GetPenColor();
|
||||
e->set("R", res.r);
|
||||
e->set("G", res.g);
|
||||
e->set("B", res.b);
|
||||
e->set("A", res.a);
|
||||
return e->toValue();
|
||||
JSSmart<CJSObject> e = CJSContext::createObject();
|
||||
NSGraphics::CColor res = m_pInternal->GetPenColor();
|
||||
e->set("R", res.r);
|
||||
e->set("G", res.g);
|
||||
e->set("B", res.b);
|
||||
e->set("A", res.a);
|
||||
return e->toValue();
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::GetBrushColor()
|
||||
{
|
||||
JSSmart<CJSObject> e = CJSContext::createObject();
|
||||
NSGraphics::CColor res = m_pInternal->GetBrushColor();
|
||||
e->set("R", res.r);
|
||||
e->set("G", res.g);
|
||||
e->set("B", res.b);
|
||||
e->set("A", res.a);
|
||||
return e->toValue();
|
||||
JSSmart<CJSObject> e = CJSContext::createObject();
|
||||
NSGraphics::CColor res = m_pInternal->GetBrushColor();
|
||||
e->set("R", res.r);
|
||||
e->set("G", res.g);
|
||||
e->set("B", res.b);
|
||||
e->set("A", res.a);
|
||||
return e->toValue();
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::put_brushTexture(JSSmart<CJSValue> src, JSSmart<CJSValue> type)
|
||||
{
|
||||
m_pInternal->put_brushTexture(src->toStringW(), type->toInt32());
|
||||
return NULL;
|
||||
m_pInternal->put_brushTexture(src->toStringW(), type->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::put_brushTextureMode(JSSmart<CJSValue> mode)
|
||||
{
|
||||
m_pInternal->put_brushTextureMode(mode->toInt32());
|
||||
return NULL;
|
||||
m_pInternal->put_brushTextureMode(mode->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::put_BrushTextureAlpha(JSSmart<CJSValue> a)
|
||||
{
|
||||
m_pInternal->put_BrushTextureAlpha(a->toInt32());
|
||||
return NULL;
|
||||
m_pInternal->put_BrushTextureAlpha(a->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::put_BrushGradient(JSSmart<CJSValue> colors, JSSmart<CJSValue> transparent, JSSmart<CJSValue> x0, JSSmart<CJSValue> y0, JSSmart<CJSValue> x1, JSSmart<CJSValue> y1, JSSmart<CJSValue> r0, JSSmart<CJSValue> r1)
|
||||
{
|
||||
JSSmart<CJSArray> items = colors->toArray();
|
||||
size_t length = items->getCount() / 5;
|
||||
LONG* color = NULL;
|
||||
double* pos = NULL;
|
||||
if (length > 0)
|
||||
{
|
||||
color = new LONG[length];
|
||||
pos = new double[length];
|
||||
}
|
||||
LONG R, G, B, A;
|
||||
for (size_t i = 0; i < 5 * length; i++)
|
||||
{
|
||||
JSSmart<CJSValue> item = items->get(i);
|
||||
size_t nDel = i % 5;
|
||||
switch (nDel)
|
||||
{
|
||||
case 0: pos[i / 5] = item->toDouble() / 100000.0; break;
|
||||
case 1: R = item->toInt32(); break;
|
||||
case 2: G = item->toInt32(); break;
|
||||
case 3: B = item->toInt32(); break;
|
||||
case 4:
|
||||
A = item->toInt32();
|
||||
if (!transparent->isNull())
|
||||
A = transparent->toInt32();
|
||||
color[i / 5] = R | (G << 8) | (B << 16) | (A << 24);
|
||||
break;
|
||||
}
|
||||
}
|
||||
JSSmart<CJSArray> items = colors->toArray();
|
||||
size_t length = items->getCount() / 5;
|
||||
LONG* color = NULL;
|
||||
double* pos = NULL;
|
||||
if (length > 0)
|
||||
{
|
||||
color = new LONG[length];
|
||||
pos = new double[length];
|
||||
}
|
||||
LONG R, G, B, A;
|
||||
for (size_t i = 0; i < 5 * length; i++)
|
||||
{
|
||||
JSSmart<CJSValue> item = items->get(i);
|
||||
size_t nDel = i % 5;
|
||||
switch (nDel)
|
||||
{
|
||||
case 0: pos[i / 5] = item->toDouble() / 100000.0; break;
|
||||
case 1: R = item->toInt32(); break;
|
||||
case 2: G = item->toInt32(); break;
|
||||
case 3: B = item->toInt32(); break;
|
||||
case 4:
|
||||
A = item->toInt32();
|
||||
if (!transparent->isNull())
|
||||
A = transparent->toInt32();
|
||||
color[i / 5] = R | (G << 8) | (B << 16) | (A << 24);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
double _x0 = x0->toDouble() / 100000.0;
|
||||
double _y0 = y0->toDouble() / 100000.0;
|
||||
double _x1 = x1->toDouble() / 100000.0;
|
||||
double _y1 = y1->toDouble() / 100000.0;
|
||||
double _r0 = r0->toDouble() / 100000.0;
|
||||
double _r1 = r1->toDouble() / 100000.0;
|
||||
double _x0 = x0->toDouble() / 100000.0;
|
||||
double _y0 = y0->toDouble() / 100000.0;
|
||||
double _x1 = x1->toDouble() / 100000.0;
|
||||
double _y1 = y1->toDouble() / 100000.0;
|
||||
double _r0 = r0->toDouble() / 100000.0;
|
||||
double _r1 = r1->toDouble() / 100000.0;
|
||||
|
||||
m_pInternal->put_BrushGradient(color, pos, length, _x0, _y0, _x1, _y1, _r0, _r1);
|
||||
m_pInternal->put_BrushGradient(color, pos, length, _x0, _y0, _x1, _y1, _r0, _r1);
|
||||
|
||||
RELEASEARRAYOBJECTS(color);
|
||||
RELEASEARRAYOBJECTS(pos);
|
||||
return NULL;
|
||||
RELEASEARRAYOBJECTS(color);
|
||||
RELEASEARRAYOBJECTS(pos);
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::TransformPointX(JSSmart<CJSValue> x, JSSmart<CJSValue> y)
|
||||
{
|
||||
return CJSContext::createDouble(m_pInternal->TransformPointX(x->toDouble(), y->toDouble()));
|
||||
return CJSContext::createDouble(m_pInternal->TransformPointX(x->toDouble(), y->toDouble()));
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::TransformPointY(JSSmart<CJSValue> x, JSSmart<CJSValue> y)
|
||||
{
|
||||
return CJSContext::createDouble(m_pInternal->TransformPointY(x->toDouble(), y->toDouble()));
|
||||
return CJSContext::createDouble(m_pInternal->TransformPointY(x->toDouble(), y->toDouble()));
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::put_LineJoin(JSSmart<CJSValue> join)
|
||||
{
|
||||
m_pInternal->put_LineJoin(join->toInt32());
|
||||
return NULL;
|
||||
m_pInternal->put_LineJoin(join->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::get_LineJoin()
|
||||
{
|
||||
return CJSContext::createInt(m_pInternal->GetLineJoin());
|
||||
return CJSContext::createInt(m_pInternal->GetLineJoin());
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::put_TextureBounds(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h)
|
||||
{
|
||||
m_pInternal->put_TextureBounds(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->put_TextureBounds(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::GetlineWidth()
|
||||
{
|
||||
return CJSContext::createDouble(m_pInternal->GetlineWidth());
|
||||
return CJSContext::createDouble(m_pInternal->GetlineWidth());
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::DrawPath(JSSmart<CJSValue> path)
|
||||
{
|
||||
m_pInternal->DrawPath(path->toInt32());
|
||||
return NULL;
|
||||
m_pInternal->DrawPath(path->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::CoordTransformOffset(JSSmart<CJSValue> tx, JSSmart<CJSValue> ty)
|
||||
{
|
||||
m_pInternal->CoordTransformOffset(tx->toDouble(), ty->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->CoordTransformOffset(tx->toDouble(), ty->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::GetTransform()
|
||||
{
|
||||
JSSmart<CJSObject> e = CJSContext::createObject();
|
||||
NSGraphics::CTransform res = m_pInternal->GetTransform();
|
||||
e->set("sx", res.sx);
|
||||
e->set("shx", res.shx);
|
||||
e->set("shy", res.shy);
|
||||
e->set("sy", res.sy);
|
||||
e->set("tx", res.tx);
|
||||
e->set("ty", res.ty);
|
||||
return e->toValue();
|
||||
JSSmart<CJSObject> e = CJSContext::createObject();
|
||||
NSGraphics::CTransform res = m_pInternal->GetTransform();
|
||||
e->set("sx", res.sx);
|
||||
e->set("shx", res.shx);
|
||||
e->set("shy", res.shy);
|
||||
e->set("sy", res.sy);
|
||||
e->set("tx", res.tx);
|
||||
e->set("ty", res.ty);
|
||||
return e->toValue();
|
||||
}
|
||||
|
||||
@ -8,131 +8,131 @@ using namespace NSJSBase;
|
||||
class CGraphicsEmbed : public CJSEmbedObject
|
||||
{
|
||||
public:
|
||||
NSGraphics::CGraphics* m_pInternal;
|
||||
NSGraphics::CGraphics* m_pInternal;
|
||||
|
||||
public:
|
||||
CGraphicsEmbed() : m_pInternal(new NSGraphics::CGraphics()) {}
|
||||
~CGraphicsEmbed() { RELEASEOBJECT(m_pInternal); }
|
||||
CGraphicsEmbed() : m_pInternal(new NSGraphics::CGraphics()) {}
|
||||
~CGraphicsEmbed() { RELEASEOBJECT(m_pInternal); }
|
||||
|
||||
virtual void* getObject() override { return (void*)m_pInternal; }
|
||||
virtual void* getObject() override { return (void*)m_pInternal; }
|
||||
|
||||
public:
|
||||
JSSmart<CJSValue> init(JSSmart<CJSValue> Native, JSSmart<CJSValue> width_px, JSSmart<CJSValue> height_px, JSSmart<CJSValue> width_mm, JSSmart<CJSValue> height_mm);
|
||||
JSSmart<CJSValue> Destroy();
|
||||
JSSmart<CJSValue> EndDraw();
|
||||
JSSmart<CJSValue> put_GlobalAlpha(JSSmart<CJSValue> enable, JSSmart<CJSValue> globalAlpha);
|
||||
JSSmart<CJSValue> Start_GlobalAlpha();
|
||||
JSSmart<CJSValue> End_GlobalAlpha();
|
||||
// pen methods
|
||||
JSSmart<CJSValue> p_color(JSSmart<CJSValue> r, JSSmart<CJSValue> g, JSSmart<CJSValue> b, JSSmart<CJSValue> a);
|
||||
JSSmart<CJSValue> p_width(JSSmart<CJSValue> w);
|
||||
JSSmart<CJSValue> p_dash(JSSmart<CJSValue> params);
|
||||
// brush methods
|
||||
JSSmart<CJSValue> b_color1(JSSmart<CJSValue> r, JSSmart<CJSValue> g, JSSmart<CJSValue> b, JSSmart<CJSValue> a);
|
||||
JSSmart<CJSValue> b_color2(JSSmart<CJSValue> r, JSSmart<CJSValue> g, JSSmart<CJSValue> b, JSSmart<CJSValue> a);
|
||||
JSSmart<CJSValue> transform(JSSmart<CJSValue> sx, JSSmart<CJSValue> shy, JSSmart<CJSValue> shx, JSSmart<CJSValue> sy, JSSmart<CJSValue> tx, JSSmart<CJSValue> ty);
|
||||
JSSmart<CJSValue> CalculateFullTransform(JSSmart<CJSValue> isInvertNeed);
|
||||
// path commands
|
||||
JSSmart<CJSValue> _s();
|
||||
JSSmart<CJSValue> _e();
|
||||
JSSmart<CJSValue> _z();
|
||||
JSSmart<CJSValue> _m (JSSmart<CJSValue> x, JSSmart<CJSValue> y);
|
||||
JSSmart<CJSValue> _l (JSSmart<CJSValue> x, JSSmart<CJSValue> y);
|
||||
JSSmart<CJSValue> _c (JSSmart<CJSValue> x1, JSSmart<CJSValue> y1, JSSmart<CJSValue> x2, JSSmart<CJSValue> y2, JSSmart<CJSValue> x3, JSSmart<CJSValue> y3);
|
||||
JSSmart<CJSValue> _c2(JSSmart<CJSValue> x1, JSSmart<CJSValue> y1, JSSmart<CJSValue> x2, JSSmart<CJSValue> y2);
|
||||
JSSmart<CJSValue> ds();
|
||||
JSSmart<CJSValue> df();
|
||||
// canvas state
|
||||
JSSmart<CJSValue> save();
|
||||
JSSmart<CJSValue> restore();
|
||||
JSSmart<CJSValue> clip();
|
||||
JSSmart<CJSValue> reset();
|
||||
JSSmart<CJSValue> FreeFont();
|
||||
JSSmart<CJSValue> ClearLastFont();
|
||||
// images
|
||||
JSSmart<CJSValue> drawImage2(JSSmart<CJSValue> img, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h, JSSmart<CJSValue> alpha, JSSmart<CJSValue> srcRect);
|
||||
JSSmart<CJSValue> drawImage (JSSmart<CJSValue> img, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h, JSSmart<CJSValue> alpha, JSSmart<CJSValue> srcRect, JSSmart<CJSValue> nativeImage);
|
||||
// text
|
||||
JSSmart<CJSValue> GetFont();
|
||||
JSSmart<CJSValue> font(JSSmart<CJSValue> font_id, JSSmart<CJSValue> font_size);
|
||||
JSSmart<CJSValue> SetFont(JSSmart<CJSValue> path, JSSmart<CJSValue> face, JSSmart<CJSValue> size, JSSmart<CJSValue> style);
|
||||
JSSmart<CJSValue> GetTextPr();
|
||||
JSSmart<CJSValue> FillText(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> text);
|
||||
JSSmart<CJSValue> t(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> _arr);
|
||||
JSSmart<CJSValue> FillText2(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> text, JSSmart<CJSValue> cropX, JSSmart<CJSValue> cropW);
|
||||
JSSmart<CJSValue> t2(JSSmart<CJSValue> text, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> cropX, JSSmart<CJSValue> cropW);
|
||||
JSSmart<CJSValue> FillTextCode(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> lUnicode);
|
||||
JSSmart<CJSValue> tg(JSSmart<CJSValue> text, JSSmart<CJSValue> x, JSSmart<CJSValue> y);
|
||||
JSSmart<CJSValue> charspace(JSSmart<CJSValue> space);
|
||||
// private methods
|
||||
JSSmart<CJSValue> private_FillGlyph (JSSmart<CJSValue> pGlyph, JSSmart<CJSValue> _bounds);
|
||||
JSSmart<CJSValue> private_FillGlyphC(JSSmart<CJSValue> pGlyph, JSSmart<CJSValue> cropX, JSSmart<CJSValue> cropW);
|
||||
JSSmart<CJSValue> private_FillGlyph2(JSSmart<CJSValue> pGlyph);
|
||||
JSSmart<CJSValue> SetIntegerGrid(JSSmart<CJSValue> param);
|
||||
JSSmart<CJSValue> GetIntegerGrid();
|
||||
JSSmart<CJSValue> DrawStringASCII (JSSmart<CJSValue> text, JSSmart<CJSValue> x, JSSmart<CJSValue> y);
|
||||
JSSmart<CJSValue> DrawStringASCII2(JSSmart<CJSValue> text, JSSmart<CJSValue> x, JSSmart<CJSValue> y);
|
||||
JSSmart<CJSValue> DrawHeaderEdit(JSSmart<CJSValue> yPos, JSSmart<CJSValue> lock_type, JSSmart<CJSValue> sectionNum, JSSmart<CJSValue> bIsRepeat, JSSmart<CJSValue> type);
|
||||
JSSmart<CJSValue> DrawFooterEdit(JSSmart<CJSValue> yPos, JSSmart<CJSValue> lock_type, JSSmart<CJSValue> sectionNum, JSSmart<CJSValue> bIsRepeat, JSSmart<CJSValue> type);
|
||||
JSSmart<CJSValue> DrawLockParagraph (JSSmart<CJSValue> x, JSSmart<CJSValue> y1, JSSmart<CJSValue> y2);
|
||||
JSSmart<CJSValue> DrawLockObjectRect(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
|
||||
JSSmart<CJSValue> DrawEmptyTableLine(JSSmart<CJSValue> x1, JSSmart<CJSValue> y1, JSSmart<CJSValue> x2, JSSmart<CJSValue> y2);
|
||||
JSSmart<CJSValue> DrawSpellingLine (JSSmart<CJSValue> y0, JSSmart<CJSValue> x0, JSSmart<CJSValue> x1, JSSmart<CJSValue> w);
|
||||
// smart methods for horizontal / vertical lines
|
||||
JSSmart<CJSValue> drawHorLine (JSSmart<CJSValue> align, JSSmart<CJSValue> y, JSSmart<CJSValue> x, JSSmart<CJSValue> r, JSSmart<CJSValue> penW);
|
||||
JSSmart<CJSValue> drawHorLine2(JSSmart<CJSValue> align, JSSmart<CJSValue> y, JSSmart<CJSValue> x, JSSmart<CJSValue> r, JSSmart<CJSValue> penW);
|
||||
JSSmart<CJSValue> drawVerLine (JSSmart<CJSValue> align, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> b, JSSmart<CJSValue> penW);
|
||||
// мега крутые функции для таблиц
|
||||
JSSmart<CJSValue> drawHorLineExt(JSSmart<CJSValue> align, JSSmart<CJSValue> y, JSSmart<CJSValue> x, JSSmart<CJSValue> r, JSSmart<CJSValue> penW, JSSmart<CJSValue> leftMW, JSSmart<CJSValue> rightMW);
|
||||
JSSmart<CJSValue> rect (JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
|
||||
JSSmart<CJSValue> TableRect(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
|
||||
// функции клиппирования
|
||||
JSSmart<CJSValue> AddClipRect(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
|
||||
JSSmart<CJSValue> RemoveClipRect();
|
||||
JSSmart<CJSValue> SetClip(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
|
||||
JSSmart<CJSValue> RemoveClip();
|
||||
JSSmart<CJSValue> drawMailMergeField(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
|
||||
JSSmart<CJSValue> drawSearchResult (JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
|
||||
JSSmart<CJSValue> drawFlowAnchor (JSSmart<CJSValue> x, JSSmart<CJSValue> y);
|
||||
JSSmart<CJSValue> SavePen();
|
||||
JSSmart<CJSValue> RestorePen();
|
||||
JSSmart<CJSValue> SaveBrush();
|
||||
JSSmart<CJSValue> RestoreBrush();
|
||||
JSSmart<CJSValue> SavePenBrush();
|
||||
JSSmart<CJSValue> RestorePenBrush();
|
||||
JSSmart<CJSValue> SaveGrState();
|
||||
JSSmart<CJSValue> RestoreGrState();
|
||||
JSSmart<CJSValue> StartClipPath();
|
||||
JSSmart<CJSValue> EndClipPath();
|
||||
JSSmart<CJSValue> StartCheckTableDraw();
|
||||
JSSmart<CJSValue> SetTextClipRect(JSSmart<CJSValue> _l, JSSmart<CJSValue> _t, JSSmart<CJSValue> _r, JSSmart<CJSValue> _b);
|
||||
JSSmart<CJSValue> AddSmartRect (JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h, JSSmart<CJSValue> pen_w);
|
||||
JSSmart<CJSValue> CheckUseFonts2 (JSSmart<CJSValue> _transform);
|
||||
JSSmart<CJSValue> UncheckUseFonts2();
|
||||
JSSmart<CJSValue> Drawing_StartCheckBounds(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
|
||||
JSSmart<CJSValue> Drawing_EndCheckBounds();
|
||||
JSSmart<CJSValue> DrawPresentationComment(JSSmart<CJSValue> type, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
|
||||
JSSmart<CJSValue> DrawPolygon(JSSmart<CJSValue> oPath, JSSmart<CJSValue> lineWidth, JSSmart<CJSValue> shift);
|
||||
JSSmart<CJSValue> DrawFootnoteRect(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
|
||||
// new methods
|
||||
JSSmart<CJSValue> toDataURL(JSSmart<CJSValue> type);
|
||||
JSSmart<CJSValue> GetPenColor();
|
||||
JSSmart<CJSValue> GetBrushColor();
|
||||
JSSmart<CJSValue> put_brushTexture(JSSmart<CJSValue> src, JSSmart<CJSValue> type);
|
||||
JSSmart<CJSValue> put_brushTextureMode(JSSmart<CJSValue> mode);
|
||||
JSSmart<CJSValue> put_BrushTextureAlpha(JSSmart<CJSValue> a);
|
||||
JSSmart<CJSValue> put_BrushGradient(JSSmart<CJSValue> colors, JSSmart<CJSValue> n, JSSmart<CJSValue> x0, JSSmart<CJSValue> y0, JSSmart<CJSValue> x1, JSSmart<CJSValue> y1, JSSmart<CJSValue> r0, JSSmart<CJSValue> r1);
|
||||
JSSmart<CJSValue> TransformPointX(JSSmart<CJSValue> x, JSSmart<CJSValue> y);
|
||||
JSSmart<CJSValue> TransformPointY(JSSmart<CJSValue> x, JSSmart<CJSValue> y);
|
||||
JSSmart<CJSValue> put_LineJoin(JSSmart<CJSValue> join);
|
||||
JSSmart<CJSValue> get_LineJoin();
|
||||
JSSmart<CJSValue> put_TextureBounds(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
|
||||
JSSmart<CJSValue> GetlineWidth();
|
||||
JSSmart<CJSValue> DrawPath(JSSmart<CJSValue> path);
|
||||
JSSmart<CJSValue> CoordTransformOffset(JSSmart<CJSValue> tx, JSSmart<CJSValue> ty);
|
||||
JSSmart<CJSValue> GetTransform();
|
||||
JSSmart<CJSValue> init(JSSmart<CJSValue> Native, JSSmart<CJSValue> width_px, JSSmart<CJSValue> height_px, JSSmart<CJSValue> width_mm, JSSmart<CJSValue> height_mm);
|
||||
JSSmart<CJSValue> Destroy();
|
||||
JSSmart<CJSValue> EndDraw();
|
||||
JSSmart<CJSValue> put_GlobalAlpha(JSSmart<CJSValue> enable, JSSmart<CJSValue> globalAlpha);
|
||||
JSSmart<CJSValue> Start_GlobalAlpha();
|
||||
JSSmart<CJSValue> End_GlobalAlpha();
|
||||
// pen methods
|
||||
JSSmart<CJSValue> p_color(JSSmart<CJSValue> r, JSSmart<CJSValue> g, JSSmart<CJSValue> b, JSSmart<CJSValue> a);
|
||||
JSSmart<CJSValue> p_width(JSSmart<CJSValue> w);
|
||||
JSSmart<CJSValue> p_dash(JSSmart<CJSValue> params);
|
||||
// brush methods
|
||||
JSSmart<CJSValue> b_color1(JSSmart<CJSValue> r, JSSmart<CJSValue> g, JSSmart<CJSValue> b, JSSmart<CJSValue> a);
|
||||
JSSmart<CJSValue> b_color2(JSSmart<CJSValue> r, JSSmart<CJSValue> g, JSSmart<CJSValue> b, JSSmart<CJSValue> a);
|
||||
JSSmart<CJSValue> transform(JSSmart<CJSValue> sx, JSSmart<CJSValue> shy, JSSmart<CJSValue> shx, JSSmart<CJSValue> sy, JSSmart<CJSValue> tx, JSSmart<CJSValue> ty);
|
||||
JSSmart<CJSValue> CalculateFullTransform(JSSmart<CJSValue> isInvertNeed);
|
||||
// path commands
|
||||
JSSmart<CJSValue> _s();
|
||||
JSSmart<CJSValue> _e();
|
||||
JSSmart<CJSValue> _z();
|
||||
JSSmart<CJSValue> _m (JSSmart<CJSValue> x, JSSmart<CJSValue> y);
|
||||
JSSmart<CJSValue> _l (JSSmart<CJSValue> x, JSSmart<CJSValue> y);
|
||||
JSSmart<CJSValue> _c (JSSmart<CJSValue> x1, JSSmart<CJSValue> y1, JSSmart<CJSValue> x2, JSSmart<CJSValue> y2, JSSmart<CJSValue> x3, JSSmart<CJSValue> y3);
|
||||
JSSmart<CJSValue> _c2(JSSmart<CJSValue> x1, JSSmart<CJSValue> y1, JSSmart<CJSValue> x2, JSSmart<CJSValue> y2);
|
||||
JSSmart<CJSValue> ds();
|
||||
JSSmart<CJSValue> df();
|
||||
// canvas state
|
||||
JSSmart<CJSValue> save();
|
||||
JSSmart<CJSValue> restore();
|
||||
JSSmart<CJSValue> clip();
|
||||
JSSmart<CJSValue> reset();
|
||||
JSSmart<CJSValue> FreeFont();
|
||||
JSSmart<CJSValue> ClearLastFont();
|
||||
// images
|
||||
JSSmart<CJSValue> drawImage2(JSSmart<CJSValue> img, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h, JSSmart<CJSValue> alpha, JSSmart<CJSValue> srcRect);
|
||||
JSSmart<CJSValue> drawImage (JSSmart<CJSValue> img, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h, JSSmart<CJSValue> alpha, JSSmart<CJSValue> srcRect, JSSmart<CJSValue> nativeImage);
|
||||
// text
|
||||
JSSmart<CJSValue> GetFont();
|
||||
JSSmart<CJSValue> font(JSSmart<CJSValue> font_id, JSSmart<CJSValue> font_size);
|
||||
JSSmart<CJSValue> SetFont(JSSmart<CJSValue> path, JSSmart<CJSValue> face, JSSmart<CJSValue> size, JSSmart<CJSValue> style);
|
||||
JSSmart<CJSValue> GetTextPr();
|
||||
JSSmart<CJSValue> FillText(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> text);
|
||||
JSSmart<CJSValue> t(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> _arr);
|
||||
JSSmart<CJSValue> FillText2(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> text, JSSmart<CJSValue> cropX, JSSmart<CJSValue> cropW);
|
||||
JSSmart<CJSValue> t2(JSSmart<CJSValue> text, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> cropX, JSSmart<CJSValue> cropW);
|
||||
JSSmart<CJSValue> FillTextCode(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> lUnicode);
|
||||
JSSmart<CJSValue> tg(JSSmart<CJSValue> text, JSSmart<CJSValue> x, JSSmart<CJSValue> y);
|
||||
JSSmart<CJSValue> charspace(JSSmart<CJSValue> space);
|
||||
// private methods
|
||||
JSSmart<CJSValue> private_FillGlyph (JSSmart<CJSValue> pGlyph, JSSmart<CJSValue> _bounds);
|
||||
JSSmart<CJSValue> private_FillGlyphC(JSSmart<CJSValue> pGlyph, JSSmart<CJSValue> cropX, JSSmart<CJSValue> cropW);
|
||||
JSSmart<CJSValue> private_FillGlyph2(JSSmart<CJSValue> pGlyph);
|
||||
JSSmart<CJSValue> SetIntegerGrid(JSSmart<CJSValue> param);
|
||||
JSSmart<CJSValue> GetIntegerGrid();
|
||||
JSSmart<CJSValue> DrawStringASCII (JSSmart<CJSValue> text, JSSmart<CJSValue> x, JSSmart<CJSValue> y);
|
||||
JSSmart<CJSValue> DrawStringASCII2(JSSmart<CJSValue> text, JSSmart<CJSValue> x, JSSmart<CJSValue> y);
|
||||
JSSmart<CJSValue> DrawHeaderEdit(JSSmart<CJSValue> yPos, JSSmart<CJSValue> lock_type, JSSmart<CJSValue> sectionNum, JSSmart<CJSValue> bIsRepeat, JSSmart<CJSValue> type);
|
||||
JSSmart<CJSValue> DrawFooterEdit(JSSmart<CJSValue> yPos, JSSmart<CJSValue> lock_type, JSSmart<CJSValue> sectionNum, JSSmart<CJSValue> bIsRepeat, JSSmart<CJSValue> type);
|
||||
JSSmart<CJSValue> DrawLockParagraph (JSSmart<CJSValue> x, JSSmart<CJSValue> y1, JSSmart<CJSValue> y2);
|
||||
JSSmart<CJSValue> DrawLockObjectRect(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
|
||||
JSSmart<CJSValue> DrawEmptyTableLine(JSSmart<CJSValue> x1, JSSmart<CJSValue> y1, JSSmart<CJSValue> x2, JSSmart<CJSValue> y2);
|
||||
JSSmart<CJSValue> DrawSpellingLine (JSSmart<CJSValue> y0, JSSmart<CJSValue> x0, JSSmart<CJSValue> x1, JSSmart<CJSValue> w);
|
||||
// smart methods for horizontal / vertical lines
|
||||
JSSmart<CJSValue> drawHorLine (JSSmart<CJSValue> align, JSSmart<CJSValue> y, JSSmart<CJSValue> x, JSSmart<CJSValue> r, JSSmart<CJSValue> penW);
|
||||
JSSmart<CJSValue> drawHorLine2(JSSmart<CJSValue> align, JSSmart<CJSValue> y, JSSmart<CJSValue> x, JSSmart<CJSValue> r, JSSmart<CJSValue> penW);
|
||||
JSSmart<CJSValue> drawVerLine (JSSmart<CJSValue> align, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> b, JSSmart<CJSValue> penW);
|
||||
// мега крутые функции для таблиц
|
||||
JSSmart<CJSValue> drawHorLineExt(JSSmart<CJSValue> align, JSSmart<CJSValue> y, JSSmart<CJSValue> x, JSSmart<CJSValue> r, JSSmart<CJSValue> penW, JSSmart<CJSValue> leftMW, JSSmart<CJSValue> rightMW);
|
||||
JSSmart<CJSValue> rect (JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
|
||||
JSSmart<CJSValue> TableRect(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
|
||||
// функции клиппирования
|
||||
JSSmart<CJSValue> AddClipRect(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
|
||||
JSSmart<CJSValue> RemoveClipRect();
|
||||
JSSmart<CJSValue> SetClip(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
|
||||
JSSmart<CJSValue> RemoveClip();
|
||||
JSSmart<CJSValue> drawMailMergeField(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
|
||||
JSSmart<CJSValue> drawSearchResult (JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
|
||||
JSSmart<CJSValue> drawFlowAnchor (JSSmart<CJSValue> x, JSSmart<CJSValue> y);
|
||||
JSSmart<CJSValue> SavePen();
|
||||
JSSmart<CJSValue> RestorePen();
|
||||
JSSmart<CJSValue> SaveBrush();
|
||||
JSSmart<CJSValue> RestoreBrush();
|
||||
JSSmart<CJSValue> SavePenBrush();
|
||||
JSSmart<CJSValue> RestorePenBrush();
|
||||
JSSmart<CJSValue> SaveGrState();
|
||||
JSSmart<CJSValue> RestoreGrState();
|
||||
JSSmart<CJSValue> StartClipPath();
|
||||
JSSmart<CJSValue> EndClipPath();
|
||||
JSSmart<CJSValue> StartCheckTableDraw();
|
||||
JSSmart<CJSValue> SetTextClipRect(JSSmart<CJSValue> _l, JSSmart<CJSValue> _t, JSSmart<CJSValue> _r, JSSmart<CJSValue> _b);
|
||||
JSSmart<CJSValue> AddSmartRect (JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h, JSSmart<CJSValue> pen_w);
|
||||
JSSmart<CJSValue> CheckUseFonts2 (JSSmart<CJSValue> _transform);
|
||||
JSSmart<CJSValue> UncheckUseFonts2();
|
||||
JSSmart<CJSValue> Drawing_StartCheckBounds(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
|
||||
JSSmart<CJSValue> Drawing_EndCheckBounds();
|
||||
JSSmart<CJSValue> DrawPresentationComment(JSSmart<CJSValue> type, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
|
||||
JSSmart<CJSValue> DrawPolygon(JSSmart<CJSValue> oPath, JSSmart<CJSValue> lineWidth, JSSmart<CJSValue> shift);
|
||||
JSSmart<CJSValue> DrawFootnoteRect(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
|
||||
// new methods
|
||||
JSSmart<CJSValue> toDataURL(JSSmart<CJSValue> type);
|
||||
JSSmart<CJSValue> GetPenColor();
|
||||
JSSmart<CJSValue> GetBrushColor();
|
||||
JSSmart<CJSValue> put_brushTexture(JSSmart<CJSValue> src, JSSmart<CJSValue> type);
|
||||
JSSmart<CJSValue> put_brushTextureMode(JSSmart<CJSValue> mode);
|
||||
JSSmart<CJSValue> put_BrushTextureAlpha(JSSmart<CJSValue> a);
|
||||
JSSmart<CJSValue> put_BrushGradient(JSSmart<CJSValue> colors, JSSmart<CJSValue> n, JSSmart<CJSValue> x0, JSSmart<CJSValue> y0, JSSmart<CJSValue> x1, JSSmart<CJSValue> y1, JSSmart<CJSValue> r0, JSSmart<CJSValue> r1);
|
||||
JSSmart<CJSValue> TransformPointX(JSSmart<CJSValue> x, JSSmart<CJSValue> y);
|
||||
JSSmart<CJSValue> TransformPointY(JSSmart<CJSValue> x, JSSmart<CJSValue> y);
|
||||
JSSmart<CJSValue> put_LineJoin(JSSmart<CJSValue> join);
|
||||
JSSmart<CJSValue> get_LineJoin();
|
||||
JSSmart<CJSValue> put_TextureBounds(JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h);
|
||||
JSSmart<CJSValue> GetlineWidth();
|
||||
JSSmart<CJSValue> DrawPath(JSSmart<CJSValue> path);
|
||||
JSSmart<CJSValue> CoordTransformOffset(JSSmart<CJSValue> tx, JSSmart<CJSValue> ty);
|
||||
JSSmart<CJSValue> GetTransform();
|
||||
|
||||
static void CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context);
|
||||
static void CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context);
|
||||
};
|
||||
|
||||
#endif // _BUILD_NATIVE_GRAPHICS_EMBED_H_
|
||||
|
||||
20
DesktopEditor/doctrenderer/embed/HashEmbed.cpp
Normal file
20
DesktopEditor/doctrenderer/embed/HashEmbed.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include "HashEmbed.h"
|
||||
|
||||
JSSmart<CJSValue> CHashEmbed::hash(JSSmart<CJSValue> data, JSSmart<CJSValue> size, JSSmart<CJSValue> alg)
|
||||
{
|
||||
std::string _data = data->toStringA();
|
||||
int _size = size->toInt32();
|
||||
int _alg = alg->toInt32();
|
||||
unsigned char* pData = m_pHash->hash(reinterpret_cast<const unsigned char*>(_data.c_str()), _size, _alg);
|
||||
return CJSContext::createUint8Array(pData, CHash::getDigestLength(static_cast<CHash::HashAlgs>(_alg)), false);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CHashEmbed::hash2(JSSmart<CJSValue> password, JSSmart<CJSValue> salt, JSSmart<CJSValue> spinCount, JSSmart<CJSValue> alg)
|
||||
{
|
||||
std::string _password = password->toStringA();
|
||||
std::string _salt = salt->toStringA();
|
||||
int _spinCount = spinCount->toInt32();
|
||||
int _alg = alg->toInt32();
|
||||
unsigned char* pData = m_pHash->hash2(reinterpret_cast<const char*>(_password.c_str()), reinterpret_cast<const char*>(_salt.c_str()), _spinCount, _alg);
|
||||
return CJSContext::createUint8Array(pData, CHash::getDigestLength(static_cast<CHash::HashAlgs>(_alg)), false);
|
||||
}
|
||||
31
DesktopEditor/doctrenderer/embed/HashEmbed.h
Normal file
31
DesktopEditor/doctrenderer/embed/HashEmbed.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef _BUILD_NATIVE_HASH_EMBED_H_
|
||||
#define _BUILD_NATIVE_HASH_EMBED_H_
|
||||
|
||||
#include "../js_internal/js_base.h"
|
||||
#include "../hash.h"
|
||||
|
||||
using namespace NSJSBase;
|
||||
class CHashEmbed : public CJSEmbedObject
|
||||
{
|
||||
public:
|
||||
CHash* m_pHash;
|
||||
|
||||
CHashEmbed() : m_pHash(new CHash(NSJSBase::NSAllocator::Alloc))
|
||||
{
|
||||
}
|
||||
|
||||
~CHashEmbed()
|
||||
{
|
||||
RELEASEOBJECT(m_pHash);
|
||||
}
|
||||
|
||||
virtual void* getObject() override { return (void*)m_pHash; }
|
||||
|
||||
JSSmart<CJSValue> hash(JSSmart<CJSValue> data, JSSmart<CJSValue> size, JSSmart<CJSValue> alg);
|
||||
JSSmart<CJSValue> hash2(JSSmart<CJSValue> password, JSSmart<CJSValue> salt, JSSmart<CJSValue> spinCount, JSSmart<CJSValue> alg);
|
||||
|
||||
public:
|
||||
static void CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context);
|
||||
};
|
||||
|
||||
#endif // _BUILD_NATIVE_HASH_EMBED_H_
|
||||
@ -2,65 +2,65 @@
|
||||
|
||||
JSSmart<CJSValue> CMemoryStreamEmbed::Copy(JSSmart<CJSValue> stream, JSSmart<CJSValue> pos, JSSmart<CJSValue> len)
|
||||
{
|
||||
JSSmart<CJSObject> _obj = stream->toObject();
|
||||
NSMemoryStream::CMemoryStream* pStream = (NSMemoryStream::CMemoryStream*)(_obj->getNative());
|
||||
m_pInternal->Copy(pStream, pos->toInt32(), len->toInt32());
|
||||
return NULL;
|
||||
JSSmart<CJSObject> _obj = stream->toObject();
|
||||
NSMemoryStream::CMemoryStream* pStream = (NSMemoryStream::CMemoryStream*)(_obj->getNative());
|
||||
m_pInternal->Copy(pStream, pos->toInt32(), len->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CMemoryStreamEmbed::ClearNoAttack()
|
||||
{
|
||||
m_pInternal->ClearNoAttack();
|
||||
return NULL;
|
||||
m_pInternal->ClearNoAttack();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CMemoryStreamEmbed::WriteByte(JSSmart<CJSValue> value)
|
||||
{
|
||||
m_pInternal->WriteBYTE((BYTE)value->toInt32());
|
||||
return NULL;
|
||||
m_pInternal->WriteBYTE((BYTE)value->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CMemoryStreamEmbed::WriteBool(JSSmart<CJSValue> value)
|
||||
{
|
||||
m_pInternal->WriteBYTE(value->toBool() ? 1 : 0);
|
||||
return NULL;
|
||||
m_pInternal->WriteBYTE(value->toBool() ? 1 : 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CMemoryStreamEmbed::WriteLong(JSSmart<CJSValue> value)
|
||||
{
|
||||
m_pInternal->WriteLONG((LONG)value->toInt32());
|
||||
return NULL;
|
||||
m_pInternal->WriteLONG((LONG)value->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CMemoryStreamEmbed::WriteDouble(JSSmart<CJSValue> value)
|
||||
{
|
||||
m_pInternal->WriteLONG((LONG)(value->toDouble() * 100000));
|
||||
return NULL;
|
||||
m_pInternal->WriteLONG((LONG)(value->toDouble() * 100000));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CMemoryStreamEmbed::WriteDouble2(JSSmart<CJSValue> value)
|
||||
{
|
||||
m_pInternal->WriteDouble(value->toDouble());
|
||||
return NULL;
|
||||
m_pInternal->WriteDouble(value->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CMemoryStreamEmbed::WriteStringA(JSSmart<CJSValue> value)
|
||||
{
|
||||
std::string param = value->toStringA();
|
||||
m_pInternal->WriteStringA2(param.c_str(), (int)param.length());
|
||||
return NULL;
|
||||
std::string param = value->toStringA();
|
||||
m_pInternal->WriteStringA2(param.c_str(), (int)param.length());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CMemoryStreamEmbed::WriteString(JSSmart<CJSValue> value)
|
||||
{
|
||||
std::wstring param = value->toStringW();
|
||||
m_pInternal->WriteString(param.c_str(), (int)param.length());
|
||||
return NULL;
|
||||
std::wstring param = value->toStringW();
|
||||
m_pInternal->WriteString(param.c_str(), (int)param.length());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CMemoryStreamEmbed::WriteString2(JSSmart<CJSValue> value)
|
||||
{
|
||||
std::wstring param = value->toStringW();
|
||||
m_pInternal->WriteString2(param.c_str(), (int)param.length());
|
||||
return NULL;
|
||||
std::wstring param = value->toStringW();
|
||||
m_pInternal->WriteString2(param.c_str(), (int)param.length());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -8,28 +8,28 @@ using namespace NSJSBase;
|
||||
class CMemoryStreamEmbed : public CJSEmbedObject
|
||||
{
|
||||
public:
|
||||
NSMemoryStream::CMemoryStream* m_pInternal;
|
||||
NSMemoryStream::CMemoryStream* m_pInternal;
|
||||
|
||||
public:
|
||||
CMemoryStreamEmbed() : m_pInternal(new NSMemoryStream::CMemoryStream()) {}
|
||||
~CMemoryStreamEmbed() { RELEASEOBJECT(m_pInternal); }
|
||||
CMemoryStreamEmbed() : m_pInternal(new NSMemoryStream::CMemoryStream()) {}
|
||||
~CMemoryStreamEmbed() { RELEASEOBJECT(m_pInternal); }
|
||||
|
||||
virtual void* getObject() override { return (void*)m_pInternal; }
|
||||
virtual void* getObject() override { return (void*)m_pInternal; }
|
||||
|
||||
public:
|
||||
JSSmart<CJSValue> Copy(JSSmart<CJSValue> stream, JSSmart<CJSValue> pos, JSSmart<CJSValue> len);
|
||||
JSSmart<CJSValue> ClearNoAttack();
|
||||
JSSmart<CJSValue> Copy(JSSmart<CJSValue> stream, JSSmart<CJSValue> pos, JSSmart<CJSValue> len);
|
||||
JSSmart<CJSValue> ClearNoAttack();
|
||||
|
||||
JSSmart<CJSValue> WriteByte(JSSmart<CJSValue> value);
|
||||
JSSmart<CJSValue> WriteBool(JSSmart<CJSValue> value);
|
||||
JSSmart<CJSValue> WriteLong(JSSmart<CJSValue> value);
|
||||
JSSmart<CJSValue> WriteDouble(JSSmart<CJSValue> value);
|
||||
JSSmart<CJSValue> WriteDouble2(JSSmart<CJSValue> value);
|
||||
JSSmart<CJSValue> WriteStringA(JSSmart<CJSValue> value);
|
||||
JSSmart<CJSValue> WriteString(JSSmart<CJSValue> value);
|
||||
JSSmart<CJSValue> WriteString2(JSSmart<CJSValue> value);
|
||||
JSSmart<CJSValue> WriteByte(JSSmart<CJSValue> value);
|
||||
JSSmart<CJSValue> WriteBool(JSSmart<CJSValue> value);
|
||||
JSSmart<CJSValue> WriteLong(JSSmart<CJSValue> value);
|
||||
JSSmart<CJSValue> WriteDouble(JSSmart<CJSValue> value);
|
||||
JSSmart<CJSValue> WriteDouble2(JSSmart<CJSValue> value);
|
||||
JSSmart<CJSValue> WriteStringA(JSSmart<CJSValue> value);
|
||||
JSSmart<CJSValue> WriteString(JSSmart<CJSValue> value);
|
||||
JSSmart<CJSValue> WriteString2(JSSmart<CJSValue> value);
|
||||
|
||||
static void CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context);
|
||||
static void CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context);
|
||||
};
|
||||
|
||||
#endif // _BUILD_NATIVE_MEMORYSTREAM_EMBED_H_
|
||||
|
||||
@ -5,115 +5,115 @@
|
||||
|
||||
JSSmart<CJSValue> CBuilderEmbed::builder_OpenFile(JSSmart<CJSValue> sPath, JSSmart<CJSValue> sParams)
|
||||
{
|
||||
std::wstring Path = sPath->toStringW();
|
||||
std::wstring Params = sParams->toStringW();
|
||||
int ret = m_pBuilder->OpenFile(Path.c_str(), Params.c_str());
|
||||
return CJSContext::createInt(ret);
|
||||
std::wstring Path = sPath->toStringW();
|
||||
std::wstring Params = sParams->toStringW();
|
||||
int ret = m_pBuilder->OpenFile(Path.c_str(), Params.c_str());
|
||||
return CJSContext::createInt(ret);
|
||||
}
|
||||
JSSmart<CJSValue> CBuilderEmbed::builder_CreateFile(JSSmart<CJSValue> type)
|
||||
{
|
||||
int nFormat = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX;
|
||||
if (type->isString())
|
||||
nFormat = NSDoctRenderer::GetFormatByTexExtention(type->toStringW());
|
||||
else
|
||||
nFormat = type->toInt32();
|
||||
int nFormat = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX;
|
||||
if (type->isString())
|
||||
nFormat = NSDoctRenderer::GetFormatByTexExtention(type->toStringW());
|
||||
else
|
||||
nFormat = type->toInt32();
|
||||
|
||||
bool ret = m_pBuilder->CreateFile(nFormat);
|
||||
return CJSContext::createBool(ret);
|
||||
bool ret = m_pBuilder->CreateFile(nFormat);
|
||||
return CJSContext::createBool(ret);
|
||||
}
|
||||
JSSmart<CJSValue> CBuilderEmbed::builder_SetTmpFolder(JSSmart<CJSValue> path)
|
||||
{
|
||||
std::wstring sPath = path->toStringW();
|
||||
m_pBuilder->SetTmpFolder(sPath.c_str());
|
||||
return NULL;
|
||||
std::wstring sPath = path->toStringW();
|
||||
m_pBuilder->SetTmpFolder(sPath.c_str());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CBuilderEmbed::builder_SaveFile(JSSmart<CJSValue> type, JSSmart<CJSValue> path, JSSmart<CJSValue> params)
|
||||
{
|
||||
int nFormat = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX;
|
||||
if (type->isString())
|
||||
nFormat = NSDoctRenderer::GetFormatByTexExtention(type->toStringW());
|
||||
else
|
||||
nFormat = type->toInt32();
|
||||
int nFormat = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX;
|
||||
if (type->isString())
|
||||
nFormat = NSDoctRenderer::GetFormatByTexExtention(type->toStringW());
|
||||
else
|
||||
nFormat = type->toInt32();
|
||||
|
||||
std::wstring sPath = path->toStringW();
|
||||
std::wstring sParams = params->toStringW();
|
||||
int ret = m_pBuilder->SaveFile(nFormat, sPath.c_str(), sParams.empty() ? NULL : sParams.c_str());
|
||||
return CJSContext::createInt(ret);
|
||||
std::wstring sPath = path->toStringW();
|
||||
std::wstring sParams = params->toStringW();
|
||||
int ret = m_pBuilder->SaveFile(nFormat, sPath.c_str(), sParams.empty() ? NULL : sParams.c_str());
|
||||
return CJSContext::createInt(ret);
|
||||
}
|
||||
JSSmart<CJSValue> CBuilderEmbed::builder_CloseFile()
|
||||
{
|
||||
m_pBuilder->CloseFile();
|
||||
return NULL;
|
||||
m_pBuilder->CloseFile();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
JSSmart<CJSValue> CBuilderDocumentEmbed::builder_doc_IsValid()
|
||||
{
|
||||
return CJSContext::createBool(m_bIsValid);
|
||||
return CJSContext::createBool(m_bIsValid);
|
||||
}
|
||||
JSSmart<CJSValue> CBuilderDocumentEmbed::builder_doc_GetBinary()
|
||||
{
|
||||
return CJSContext::createUint8Array(m_sFolder + L"/Editor.bin");
|
||||
return CJSContext::createUint8Array(m_sFolder + L"/Editor.bin");
|
||||
}
|
||||
JSSmart<CJSValue> CBuilderDocumentEmbed::builder_doc_GetFolder()
|
||||
{
|
||||
return CJSContext::createString(m_sFolder);
|
||||
return CJSContext::createString(m_sFolder);
|
||||
}
|
||||
JSSmart<CJSValue> CBuilderDocumentEmbed::builder_doc_CloseFile()
|
||||
{
|
||||
CloseFile();
|
||||
return NULL;
|
||||
CloseFile();
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CBuilderDocumentEmbed::builder_doc_GetImageMap()
|
||||
{
|
||||
std::vector<std::wstring> files = NSDirectory::GetFiles(m_sFolder + L"/media");
|
||||
std::vector<std::wstring> files = NSDirectory::GetFiles(m_sFolder + L"/media");
|
||||
|
||||
JSSmart<CJSObject> obj = CJSContext::createObject();
|
||||
for (std::vector<std::wstring>::iterator i = files.begin(); i != files.end(); i++)
|
||||
{
|
||||
std::wstring sFile = *i;
|
||||
NSStringUtils::string_replace(sFile, L"\\", L"/");
|
||||
std::wstring sName = L"media/" + NSFile::GetFileName(sFile);
|
||||
JSSmart<CJSObject> obj = CJSContext::createObject();
|
||||
for (std::vector<std::wstring>::iterator i = files.begin(); i != files.end(); i++)
|
||||
{
|
||||
std::wstring sFile = *i;
|
||||
NSStringUtils::string_replace(sFile, L"\\", L"/");
|
||||
std::wstring sName = L"media/" + NSFile::GetFileName(sFile);
|
||||
|
||||
obj->set(U_TO_UTF8(sName).c_str(), CJSContext::createString(sFile));
|
||||
}
|
||||
obj->set(U_TO_UTF8(sName).c_str(), CJSContext::createString(sFile));
|
||||
}
|
||||
|
||||
return obj->toValue();
|
||||
return obj->toValue();
|
||||
}
|
||||
|
||||
void CBuilderDocumentEmbed::OpenFile(const std::wstring& sFile, const std::wstring& sParams)
|
||||
{
|
||||
NSDoctRenderer::CDocBuilder_Private* pBuilder = GetPrivate(m_pBuilder);
|
||||
NSDoctRenderer::CDocBuilder_Private* pBuilder = GetPrivate(m_pBuilder);
|
||||
|
||||
std::wstring sTmpDir = pBuilder->m_sTmpFolder;
|
||||
std::wstring sTmpDir = pBuilder->m_sTmpFolder;
|
||||
|
||||
m_sFolder = NSFile::CFileBinary::CreateTempFileWithUniqueName(sTmpDir, L"DE_");
|
||||
if (NSFile::CFileBinary::Exists(m_sFolder))
|
||||
NSFile::CFileBinary::Remove(m_sFolder);
|
||||
m_sFolder = NSFile::CFileBinary::CreateTempFileWithUniqueName(sTmpDir, L"DE_");
|
||||
if (NSFile::CFileBinary::Exists(m_sFolder))
|
||||
NSFile::CFileBinary::Remove(m_sFolder);
|
||||
|
||||
NSStringUtils::string_replace(m_sFolder, L"\\", L"/");
|
||||
NSStringUtils::string_replace(m_sFolder, L"\\", L"/");
|
||||
|
||||
std::wstring::size_type nPosPoint = m_sFolder.rfind('.');
|
||||
if (nPosPoint != std::wstring::npos && nPosPoint > sTmpDir.length())
|
||||
{
|
||||
m_sFolder = m_sFolder.substr(0, nPosPoint);
|
||||
}
|
||||
std::wstring::size_type nPosPoint = m_sFolder.rfind('.');
|
||||
if (nPosPoint != std::wstring::npos && nPosPoint > sTmpDir.length())
|
||||
{
|
||||
m_sFolder = m_sFolder.substr(0, nPosPoint);
|
||||
}
|
||||
|
||||
NSDirectory::CreateDirectory(m_sFolder);
|
||||
NSDirectory::CreateDirectory(m_sFolder);
|
||||
|
||||
std::wstring sExtCopy = pBuilder->GetFileCopyExt(sFile);
|
||||
std::wstring sFileCopy = m_sFolder + L"/origin." + sExtCopy;
|
||||
std::wstring sExtCopy = pBuilder->GetFileCopyExt(sFile);
|
||||
std::wstring sFileCopy = m_sFolder + L"/origin." + sExtCopy;
|
||||
|
||||
pBuilder->MoveFileOpen(sFile, sFileCopy);
|
||||
int nConvertResult = pBuilder->ConvertToInternalFormat(m_sFolder, sFileCopy, sParams);
|
||||
pBuilder->MoveFileOpen(sFile, sFileCopy);
|
||||
int nConvertResult = pBuilder->ConvertToInternalFormat(m_sFolder, sFileCopy, sParams);
|
||||
|
||||
if (0 == nConvertResult)
|
||||
m_bIsValid = true;
|
||||
if (0 == nConvertResult)
|
||||
m_bIsValid = true;
|
||||
}
|
||||
void CBuilderDocumentEmbed::CloseFile()
|
||||
{
|
||||
if (!m_sFolder.empty())
|
||||
NSDirectory::DeleteDirectory(m_sFolder);
|
||||
m_bIsValid = false;
|
||||
m_sFolder = L"";
|
||||
if (!m_sFolder.empty())
|
||||
NSDirectory::DeleteDirectory(m_sFolder);
|
||||
m_bIsValid = false;
|
||||
m_sFolder = L"";
|
||||
}
|
||||
|
||||
@ -39,46 +39,46 @@ using namespace NSJSBase;
|
||||
class CBuilderEmbed : public CJSEmbedObject
|
||||
{
|
||||
public:
|
||||
NSDoctRenderer::CDocBuilder* m_pBuilder;
|
||||
NSDoctRenderer::CDocBuilder* m_pBuilder;
|
||||
|
||||
CBuilderEmbed() : m_pBuilder(NULL) {}
|
||||
~CBuilderEmbed() { if(m_pBuilder) RELEASEOBJECT(m_pBuilder); }
|
||||
CBuilderEmbed() : m_pBuilder(NULL) {}
|
||||
~CBuilderEmbed() { if(m_pBuilder) RELEASEOBJECT(m_pBuilder); }
|
||||
|
||||
virtual void* getObject() { return (void*)m_pBuilder; }
|
||||
virtual void* getObject() { return (void*)m_pBuilder; }
|
||||
|
||||
public:
|
||||
JSSmart<CJSValue> builder_OpenFile(JSSmart<CJSValue> sPath, JSSmart<CJSValue> sParams);
|
||||
JSSmart<CJSValue> builder_CreateFile(JSSmart<CJSValue> type);
|
||||
JSSmart<CJSValue> builder_SetTmpFolder(JSSmart<CJSValue> path);
|
||||
JSSmart<CJSValue> builder_SaveFile(JSSmart<CJSValue> type, JSSmart<CJSValue> path, JSSmart<CJSValue> params);
|
||||
JSSmart<CJSValue> builder_CloseFile();
|
||||
JSSmart<CJSValue> builder_OpenTmpFile(JSSmart<CJSValue> path, JSSmart<CJSValue> params);
|
||||
JSSmart<CJSValue> builder_OpenFile(JSSmart<CJSValue> sPath, JSSmart<CJSValue> sParams);
|
||||
JSSmart<CJSValue> builder_CreateFile(JSSmart<CJSValue> type);
|
||||
JSSmart<CJSValue> builder_SetTmpFolder(JSSmart<CJSValue> path);
|
||||
JSSmart<CJSValue> builder_SaveFile(JSSmart<CJSValue> type, JSSmart<CJSValue> path, JSSmart<CJSValue> params);
|
||||
JSSmart<CJSValue> builder_CloseFile();
|
||||
JSSmart<CJSValue> builder_OpenTmpFile(JSSmart<CJSValue> path, JSSmart<CJSValue> params);
|
||||
};
|
||||
|
||||
class CBuilderDocumentEmbed : public CJSEmbedObject
|
||||
{
|
||||
public:
|
||||
NSDoctRenderer::CDocBuilder* m_pBuilder;
|
||||
bool m_bIsValid;
|
||||
std::wstring m_sFolder;
|
||||
NSDoctRenderer::CDocBuilder* m_pBuilder;
|
||||
bool m_bIsValid;
|
||||
std::wstring m_sFolder;
|
||||
|
||||
public:
|
||||
CBuilderDocumentEmbed() : m_pBuilder(NULL), m_bIsValid(false) {}
|
||||
~CBuilderDocumentEmbed() { if(m_pBuilder) RELEASEOBJECT(m_pBuilder); }
|
||||
CBuilderDocumentEmbed() : m_pBuilder(NULL), m_bIsValid(false) {}
|
||||
~CBuilderDocumentEmbed() { if(m_pBuilder) RELEASEOBJECT(m_pBuilder); }
|
||||
|
||||
virtual void* getObject() { return (void*)m_pBuilder; }
|
||||
NSDoctRenderer::CDocBuilder_Private* GetPrivate(NSDoctRenderer::CDocBuilder* pBuilder) { return pBuilder->GetPrivate(); }
|
||||
virtual void* getObject() { return (void*)m_pBuilder; }
|
||||
NSDoctRenderer::CDocBuilder_Private* GetPrivate(NSDoctRenderer::CDocBuilder* pBuilder) { return pBuilder->GetPrivate(); }
|
||||
|
||||
public:
|
||||
void OpenFile(const std::wstring& sFile, const std::wstring& sParams);
|
||||
void CloseFile();
|
||||
void OpenFile(const std::wstring& sFile, const std::wstring& sParams);
|
||||
void CloseFile();
|
||||
|
||||
public:
|
||||
JSSmart<CJSValue> builder_doc_IsValid();
|
||||
JSSmart<CJSValue> builder_doc_GetBinary();
|
||||
JSSmart<CJSValue> builder_doc_GetFolder();
|
||||
JSSmart<CJSValue> builder_doc_CloseFile();
|
||||
JSSmart<CJSValue> builder_doc_GetImageMap();
|
||||
JSSmart<CJSValue> builder_doc_IsValid();
|
||||
JSSmart<CJSValue> builder_doc_GetBinary();
|
||||
JSSmart<CJSValue> builder_doc_GetFolder();
|
||||
JSSmart<CJSValue> builder_doc_CloseFile();
|
||||
JSSmart<CJSValue> builder_doc_GetImageMap();
|
||||
};
|
||||
|
||||
void builder_CreateNative(const std::string& name, JSSmart<CJSContext> context, NSDoctRenderer::CDocBuilder* builder);
|
||||
|
||||
@ -2,217 +2,217 @@
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::SetFilePath(JSSmart<CJSValue> path)
|
||||
{
|
||||
m_pInternal->SetFilePath(path->toStringW());
|
||||
return NULL;
|
||||
m_pInternal->SetFilePath(path->toStringW());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::GetFilePath()
|
||||
{
|
||||
return CJSContext::createString(m_pInternal->GetFilePath());
|
||||
return CJSContext::createString(m_pInternal->GetFilePath());
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::SetFileId(JSSmart<CJSValue> fileId)
|
||||
{
|
||||
m_pInternal->SetFileId(fileId->toStringW());
|
||||
return NULL;
|
||||
m_pInternal->SetFileId(fileId->toStringW());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::GetFileId()
|
||||
{
|
||||
return CJSContext::createString(m_pInternal->GetFileId());
|
||||
return CJSContext::createString(m_pInternal->GetFileId());
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::GetFileBinary(JSSmart<CJSValue> file)
|
||||
{
|
||||
return CJSContext::createUint8Array(file->toStringW());
|
||||
return CJSContext::createUint8Array(file->toStringW());
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::GetFontBinary(JSSmart<CJSValue> file)
|
||||
{
|
||||
// TODO:
|
||||
// по идее файлы могут совпадать по имени, но лежать в разных директориях.
|
||||
// и поэтому в AllFonts.js надо бы писать пути полные.
|
||||
// пока оставим поддержку старой версии тоже
|
||||
std::wstring sFile = file->toStringW();
|
||||
bool bIsFullFilePath = (std::wstring::npos != sFile.find('\\') || std::wstring::npos != sFile.find('/'));
|
||||
if (bIsFullFilePath)
|
||||
{
|
||||
bIsFullFilePath = NSFile::CFileBinary::Exists(sFile);
|
||||
}
|
||||
// TODO:
|
||||
// по идее файлы могут совпадать по имени, но лежать в разных директориях.
|
||||
// и поэтому в AllFonts.js надо бы писать пути полные.
|
||||
// пока оставим поддержку старой версии тоже
|
||||
std::wstring sFile = file->toStringW();
|
||||
bool bIsFullFilePath = (std::wstring::npos != sFile.find('\\') || std::wstring::npos != sFile.find('/'));
|
||||
if (bIsFullFilePath)
|
||||
{
|
||||
bIsFullFilePath = NSFile::CFileBinary::Exists(sFile);
|
||||
}
|
||||
|
||||
if (!bIsFullFilePath)
|
||||
{
|
||||
std::map<std::wstring, std::wstring>::iterator pair = m_pInternal->m_map_fonts.find(sFile);
|
||||
if (pair != m_pInternal->m_map_fonts.end())
|
||||
sFile = pair->second;
|
||||
else
|
||||
sFile = m_pInternal->m_sDefaultFont;
|
||||
}
|
||||
if (!bIsFullFilePath)
|
||||
{
|
||||
std::map<std::wstring, std::wstring>::iterator pair = m_pInternal->m_map_fonts.find(sFile);
|
||||
if (pair != m_pInternal->m_map_fonts.end())
|
||||
sFile = pair->second;
|
||||
else
|
||||
sFile = m_pInternal->m_sDefaultFont;
|
||||
}
|
||||
|
||||
return CJSContext::createUint8Array(sFile);
|
||||
return CJSContext::createUint8Array(sFile);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::GetFontsDirectory()
|
||||
{
|
||||
return CJSContext::createString(m_pInternal->m_strFontsDirectory);
|
||||
return CJSContext::createString(m_pInternal->m_strFontsDirectory);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::GetFileString(JSSmart<CJSValue> file)
|
||||
{
|
||||
return CJSContext::createUint8Array(file->toStringW());
|
||||
return CJSContext::createUint8Array(file->toStringW());
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::GetEditorType()
|
||||
{
|
||||
return CJSContext::createString(m_pInternal->m_strEditorType);
|
||||
return CJSContext::createString(m_pInternal->m_strEditorType);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::CheckNextChange()
|
||||
{
|
||||
m_pInternal->m_nCurrentChangesNumber++;
|
||||
if (-1 != m_pInternal->m_nMaxChangesNumber)
|
||||
{
|
||||
if (m_pInternal->m_nCurrentChangesNumber >= m_pInternal->m_nMaxChangesNumber)
|
||||
{
|
||||
return CJSContext::createBool(false);
|
||||
}
|
||||
}
|
||||
return CJSContext::createBool(true);
|
||||
m_pInternal->m_nCurrentChangesNumber++;
|
||||
if (-1 != m_pInternal->m_nMaxChangesNumber)
|
||||
{
|
||||
if (m_pInternal->m_nCurrentChangesNumber >= m_pInternal->m_nMaxChangesNumber)
|
||||
{
|
||||
return CJSContext::createBool(false);
|
||||
}
|
||||
}
|
||||
return CJSContext::createBool(true);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::GetCountChanges()
|
||||
{
|
||||
int nCount = 0;
|
||||
if (m_pInternal->m_pChanges != NULL)
|
||||
{
|
||||
nCount = (int)m_pInternal->m_pChanges->size();
|
||||
}
|
||||
int nCount = 0;
|
||||
if (m_pInternal->m_pChanges != NULL)
|
||||
{
|
||||
nCount = (int)m_pInternal->m_pChanges->size();
|
||||
}
|
||||
|
||||
return CJSContext::createInt(nCount);
|
||||
return CJSContext::createInt(nCount);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::GetChangesFile(JSSmart<CJSValue> index)
|
||||
{
|
||||
int nIndex = index->toInt32();
|
||||
std::wstring strFile = L"";
|
||||
if (m_pInternal->m_pChanges != NULL)
|
||||
strFile = (*m_pInternal->m_pChanges)[nIndex];
|
||||
return CJSContext::createString(strFile);
|
||||
int nIndex = index->toInt32();
|
||||
std::wstring strFile = L"";
|
||||
if (m_pInternal->m_pChanges != NULL)
|
||||
strFile = (*m_pInternal->m_pChanges)[nIndex];
|
||||
return CJSContext::createString(strFile);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::Save_AllocNative(JSSmart<CJSValue> nLen)
|
||||
{
|
||||
int Len = nLen->toInt32();
|
||||
m_pInternal->Save_Alloc(Len);
|
||||
return CJSContext::createUint8Array(m_pInternal->m_pSaveBinary, m_pInternal->m_nSaveLen, true);
|
||||
int Len = nLen->toInt32();
|
||||
m_pInternal->Save_Alloc(Len);
|
||||
return CJSContext::createUint8Array(m_pInternal->m_pSaveBinary, m_pInternal->m_nSaveLen, true);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::Save_ReAllocNative(JSSmart<CJSValue> pos, JSSmart<CJSValue> len)
|
||||
{
|
||||
int _pos = pos->toInt32();
|
||||
int _len = len->toInt32();
|
||||
m_pInternal->Save_ReAlloc(_pos, _len);
|
||||
return CJSContext::createUint8Array(m_pInternal->m_pSaveBinary, m_pInternal->m_nSaveLen, true);
|
||||
int _pos = pos->toInt32();
|
||||
int _len = len->toInt32();
|
||||
m_pInternal->Save_ReAlloc(_pos, _len);
|
||||
return CJSContext::createUint8Array(m_pInternal->m_pSaveBinary, m_pInternal->m_nSaveLen, true);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::Save_End(JSSmart<CJSValue> pos, JSSmart<CJSValue> len)
|
||||
{
|
||||
std::string sHeader = pos->toStringA();
|
||||
int _len = len->toInt32();
|
||||
m_pInternal->Save_End(sHeader, _len);
|
||||
return NULL;
|
||||
std::string sHeader = pos->toStringA();
|
||||
int _len = len->toInt32();
|
||||
m_pInternal->Save_End(sHeader, _len);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::AddImageInChanges(JSSmart<CJSValue> img)
|
||||
{
|
||||
std::wstring sImage = img->toStringW();
|
||||
if (sImage.empty())
|
||||
return NULL;
|
||||
std::wstring sImage = img->toStringW();
|
||||
if (sImage.empty())
|
||||
return NULL;
|
||||
|
||||
std::map<std::wstring, bool>::const_iterator iter = m_pInternal->m_mapImagesInChanges.find(sImage);
|
||||
if (iter == m_pInternal->m_mapImagesInChanges.end())
|
||||
m_pInternal->m_mapImagesInChanges.insert(std::pair<std::wstring, bool>(sImage, true));
|
||||
return NULL;
|
||||
std::map<std::wstring, bool>::const_iterator iter = m_pInternal->m_mapImagesInChanges.find(sImage);
|
||||
if (iter == m_pInternal->m_mapImagesInChanges.end())
|
||||
m_pInternal->m_mapImagesInChanges.insert(std::pair<std::wstring, bool>(sImage, true));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::ConsoleLog(JSSmart<CJSValue> message)
|
||||
{
|
||||
m_pInternal->ConsoleLog(message->toStringA());
|
||||
return NULL;
|
||||
m_pInternal->ConsoleLog(message->toStringA());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::SaveChanges(JSSmart<CJSValue> sParam, JSSmart<CJSValue> nDeleteIndex, JSSmart<CJSValue> nCount)
|
||||
{
|
||||
m_pInternal->DumpChanges(sParam->toStringA(), nDeleteIndex->toInt32(), nCount->toInt32());
|
||||
return NULL;
|
||||
m_pInternal->DumpChanges(sParam->toStringA(), nDeleteIndex->toInt32(), nCount->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::zipOpenFile(JSSmart<CJSValue> name)
|
||||
{
|
||||
bool bIsOpen = m_pInternal->m_oZipWorker.Open(name->toStringW());
|
||||
if (!bIsOpen)
|
||||
return CJSContext::createNull();
|
||||
bool bIsOpen = m_pInternal->m_oZipWorker.Open(name->toStringW());
|
||||
if (!bIsOpen)
|
||||
return CJSContext::createNull();
|
||||
|
||||
JSSmart<CJSObject> obj = CJSContext::createObject();
|
||||
for (std::vector<std::wstring>::iterator i = m_pInternal->m_oZipWorker.m_arFiles.begin(); i != m_pInternal->m_oZipWorker.m_arFiles.end(); i++)
|
||||
{
|
||||
std::string sFile = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(*i);
|
||||
obj->set(sFile.c_str(), CJSContext::createString(sFile));
|
||||
}
|
||||
JSSmart<CJSObject> obj = CJSContext::createObject();
|
||||
for (std::vector<std::wstring>::iterator i = m_pInternal->m_oZipWorker.m_arFiles.begin(); i != m_pInternal->m_oZipWorker.m_arFiles.end(); i++)
|
||||
{
|
||||
std::string sFile = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(*i);
|
||||
obj->set(sFile.c_str(), CJSContext::createString(sFile));
|
||||
}
|
||||
|
||||
return obj->toValue();
|
||||
return obj->toValue();
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::zipOpenFileBase64(JSSmart<CJSValue> name)
|
||||
{
|
||||
bool bIsOpen = m_pInternal->m_oZipWorker.OpenBase64(name->toStringA());
|
||||
if (!bIsOpen)
|
||||
return CJSContext::createNull();
|
||||
bool bIsOpen = m_pInternal->m_oZipWorker.OpenBase64(name->toStringA());
|
||||
if (!bIsOpen)
|
||||
return CJSContext::createNull();
|
||||
|
||||
JSSmart<CJSObject> obj = CJSContext::createObject();
|
||||
for (std::vector<std::wstring>::iterator i = m_pInternal->m_oZipWorker.m_arFiles.begin(); i != m_pInternal->m_oZipWorker.m_arFiles.end(); i++)
|
||||
{
|
||||
std::string sFile = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(*i);
|
||||
obj->set(sFile.c_str(), CJSContext::createString(sFile));
|
||||
}
|
||||
JSSmart<CJSObject> obj = CJSContext::createObject();
|
||||
for (std::vector<std::wstring>::iterator i = m_pInternal->m_oZipWorker.m_arFiles.begin(); i != m_pInternal->m_oZipWorker.m_arFiles.end(); i++)
|
||||
{
|
||||
std::string sFile = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(*i);
|
||||
obj->set(sFile.c_str(), CJSContext::createString(sFile));
|
||||
}
|
||||
|
||||
return obj->toValue();
|
||||
return obj->toValue();
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::zipGetFileAsString(JSSmart<CJSValue> name)
|
||||
{
|
||||
BYTE* pData = NULL;
|
||||
DWORD len = 0;
|
||||
m_pInternal->m_oZipWorker.GetFileData(name->toStringW(), pData, len);
|
||||
return CJSContext::createString((char*)pData, len);
|
||||
BYTE* pData = NULL;
|
||||
DWORD len = 0;
|
||||
m_pInternal->m_oZipWorker.GetFileData(name->toStringW(), pData, len);
|
||||
return CJSContext::createString((char*)pData, len);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::zipGetFileAsBinary(JSSmart<CJSValue> name)
|
||||
{
|
||||
return CJSContext::createUint8Array(m_pInternal->m_oZipWorker.m_sTmpFolder + L"/" + name->toStringW());
|
||||
return CJSContext::createUint8Array(m_pInternal->m_oZipWorker.m_sTmpFolder + L"/" + name->toStringW());
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::zipCloseFile()
|
||||
{
|
||||
m_pInternal->m_oZipWorker.Close();
|
||||
return NULL;
|
||||
m_pInternal->m_oZipWorker.Close();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::GetImageUrl(JSSmart<CJSValue> sUrl)
|
||||
{
|
||||
std::wstring Url = sUrl->toStringW();
|
||||
std::wstring Url = sUrl->toStringW();
|
||||
|
||||
if (!m_pInternal->m_pWorker)
|
||||
m_pInternal->m_pWorker = new CImagesWorker(m_pInternal->m_strImagesDirectory);
|
||||
if (!m_pInternal->m_pWorker)
|
||||
m_pInternal->m_pWorker = new CImagesWorker(m_pInternal->m_strImagesDirectory);
|
||||
|
||||
std::wstring sRet = m_pInternal->m_pWorker->GetImage(Url);
|
||||
std::wstring sRet = m_pInternal->m_pWorker->GetImage(Url);
|
||||
|
||||
return CJSContext::createString(sRet);
|
||||
return CJSContext::createString(sRet);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::GetImagesPath()
|
||||
{
|
||||
return CJSContext::createString(m_pInternal->m_strImagesDirectory);
|
||||
return CJSContext::createString(m_pInternal->m_strImagesDirectory);
|
||||
}
|
||||
|
||||
#include "./../../graphics/MetafileToRenderer.h"
|
||||
|
||||
@ -8,45 +8,45 @@ using namespace NSJSBase;
|
||||
class CNativeControlEmbed : public CJSEmbedObject
|
||||
{
|
||||
public:
|
||||
NSNativeControl::CNativeControl* m_pInternal;
|
||||
CZipWorker m_oZipWorker;
|
||||
NSNativeControl::CNativeControl* m_pInternal;
|
||||
CZipWorker m_oZipWorker;
|
||||
public:
|
||||
CNativeControlEmbed() : m_pInternal(new NSNativeControl::CNativeControl()) {}
|
||||
~CNativeControlEmbed() { RELEASEOBJECT(m_pInternal); }
|
||||
CNativeControlEmbed() : m_pInternal(new NSNativeControl::CNativeControl()) {}
|
||||
~CNativeControlEmbed() { RELEASEOBJECT(m_pInternal); }
|
||||
|
||||
virtual void* getObject() override { return (void*)m_pInternal; }
|
||||
virtual void* getObject() override { return (void*)m_pInternal; }
|
||||
|
||||
public:
|
||||
|
||||
JSSmart<CJSValue> SetFilePath(JSSmart<CJSValue> path);
|
||||
JSSmart<CJSValue> GetFilePath();
|
||||
JSSmart<CJSValue> SetFileId(JSSmart<CJSValue> fileId);
|
||||
JSSmart<CJSValue> GetFileId();
|
||||
JSSmart<CJSValue> GetFileBinary(JSSmart<CJSValue> file);
|
||||
JSSmart<CJSValue> GetFontBinary(JSSmart<CJSValue> file);
|
||||
JSSmart<CJSValue> GetFontsDirectory();
|
||||
JSSmart<CJSValue> GetFileString(JSSmart<CJSValue> file);
|
||||
JSSmart<CJSValue> GetEditorType();
|
||||
JSSmart<CJSValue> CheckNextChange();
|
||||
JSSmart<CJSValue> GetCountChanges();
|
||||
JSSmart<CJSValue> GetChangesFile(JSSmart<CJSValue> index);
|
||||
JSSmart<CJSValue> Save_AllocNative(JSSmart<CJSValue> nLen);
|
||||
JSSmart<CJSValue> Save_ReAllocNative(JSSmart<CJSValue> pos, JSSmart<CJSValue> len);
|
||||
JSSmart<CJSValue> Save_End(JSSmart<CJSValue> pos, JSSmart<CJSValue> len);
|
||||
JSSmart<CJSValue> AddImageInChanges(JSSmart<CJSValue> img);
|
||||
JSSmart<CJSValue> ConsoleLog(JSSmart<CJSValue> message);
|
||||
JSSmart<CJSValue> SaveChanges(JSSmart<CJSValue> sParam, JSSmart<CJSValue> nDeleteIndex, JSSmart<CJSValue> nCount);
|
||||
JSSmart<CJSValue> zipOpenFile(JSSmart<CJSValue> name);
|
||||
JSSmart<CJSValue> zipOpenFileBase64(JSSmart<CJSValue> name);
|
||||
JSSmart<CJSValue> zipGetFileAsString(JSSmart<CJSValue> name);
|
||||
JSSmart<CJSValue> zipGetFileAsBinary(JSSmart<CJSValue> name);
|
||||
JSSmart<CJSValue> zipCloseFile();
|
||||
JSSmart<CJSValue> GetImageUrl(JSSmart<CJSValue> sUrl);
|
||||
JSSmart<CJSValue> GetImagesPath();
|
||||
JSSmart<CJSValue> SetFilePath(JSSmart<CJSValue> path);
|
||||
JSSmart<CJSValue> GetFilePath();
|
||||
JSSmart<CJSValue> SetFileId(JSSmart<CJSValue> fileId);
|
||||
JSSmart<CJSValue> GetFileId();
|
||||
JSSmart<CJSValue> GetFileBinary(JSSmart<CJSValue> file);
|
||||
JSSmart<CJSValue> GetFontBinary(JSSmart<CJSValue> file);
|
||||
JSSmart<CJSValue> GetFontsDirectory();
|
||||
JSSmart<CJSValue> GetFileString(JSSmart<CJSValue> file);
|
||||
JSSmart<CJSValue> GetEditorType();
|
||||
JSSmart<CJSValue> CheckNextChange();
|
||||
JSSmart<CJSValue> GetCountChanges();
|
||||
JSSmart<CJSValue> GetChangesFile(JSSmart<CJSValue> index);
|
||||
JSSmart<CJSValue> Save_AllocNative(JSSmart<CJSValue> nLen);
|
||||
JSSmart<CJSValue> Save_ReAllocNative(JSSmart<CJSValue> pos, JSSmart<CJSValue> len);
|
||||
JSSmart<CJSValue> Save_End(JSSmart<CJSValue> pos, JSSmart<CJSValue> len);
|
||||
JSSmart<CJSValue> AddImageInChanges(JSSmart<CJSValue> img);
|
||||
JSSmart<CJSValue> ConsoleLog(JSSmart<CJSValue> message);
|
||||
JSSmart<CJSValue> SaveChanges(JSSmart<CJSValue> sParam, JSSmart<CJSValue> nDeleteIndex, JSSmart<CJSValue> nCount);
|
||||
JSSmart<CJSValue> zipOpenFile(JSSmart<CJSValue> name);
|
||||
JSSmart<CJSValue> zipOpenFileBase64(JSSmart<CJSValue> name);
|
||||
JSSmart<CJSValue> zipGetFileAsString(JSSmart<CJSValue> name);
|
||||
JSSmart<CJSValue> zipGetFileAsBinary(JSSmart<CJSValue> name);
|
||||
JSSmart<CJSValue> zipCloseFile();
|
||||
JSSmart<CJSValue> GetImageUrl(JSSmart<CJSValue> sUrl);
|
||||
JSSmart<CJSValue> GetImagesPath();
|
||||
JSSmart<CJSValue> GetImageOriginalSize(JSSmart<CJSValue> sUrl);
|
||||
|
||||
static void CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context);
|
||||
static void CreateObjectBuilderInContext(const std::string& name, JSSmart<CJSContext> context);
|
||||
static void CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context);
|
||||
static void CreateObjectBuilderInContext(const std::string& name, JSSmart<CJSContext> context);
|
||||
};
|
||||
|
||||
#endif // _BUILD_NATIVE_NATIVECONTROL_EMBED_H_
|
||||
|
||||
@ -3,30 +3,30 @@
|
||||
|
||||
namespace NSPointerObjectDeleters
|
||||
{
|
||||
void EmptyDeleter(void* data)
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
void FreeDeleter(void* data)
|
||||
{
|
||||
free(data);
|
||||
}
|
||||
void EmptyDeleter(void* data)
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
void FreeDeleter(void* data)
|
||||
{
|
||||
free(data);
|
||||
}
|
||||
}
|
||||
|
||||
CPointerEmbedObject::CPointerEmbedObject(void* data, NSPointerObjectDeleters::PointerObjectDeleter deleter)
|
||||
{
|
||||
Data = data;
|
||||
Deleter = deleter;
|
||||
Data = data;
|
||||
Deleter = deleter;
|
||||
}
|
||||
|
||||
void CPointerEmbedObject::Free()
|
||||
{
|
||||
if (Data && Deleter)
|
||||
Deleter(Data);
|
||||
Data = nullptr;
|
||||
if (Data && Deleter)
|
||||
Deleter(Data);
|
||||
Data = nullptr;
|
||||
}
|
||||
|
||||
CPointerEmbedObject::~CPointerEmbedObject()
|
||||
{
|
||||
Free();
|
||||
Free();
|
||||
}
|
||||
|
||||
@ -5,10 +5,10 @@
|
||||
|
||||
namespace NSPointerObjectDeleters
|
||||
{
|
||||
using PointerObjectDeleter = void (*)(void* data);
|
||||
using PointerObjectDeleter = void (*)(void* data);
|
||||
|
||||
void EmptyDeleter(void* data);
|
||||
void FreeDeleter(void* data);
|
||||
void EmptyDeleter(void* data);
|
||||
void FreeDeleter(void* data);
|
||||
}
|
||||
|
||||
#define POINTER_DELETER(CLASS_NAME, NAME) void NAME(void* data) { CLASS_NAME* p = (CLASS_NAME*)data; delete data; }
|
||||
@ -17,19 +17,19 @@ using namespace NSJSBase;
|
||||
class CPointerEmbedObject : public CJSEmbedObject
|
||||
{
|
||||
public:
|
||||
void* Data;
|
||||
void* Data;
|
||||
|
||||
private:
|
||||
NSPointerObjectDeleters::PointerObjectDeleter Deleter;
|
||||
NSPointerObjectDeleters::PointerObjectDeleter Deleter;
|
||||
|
||||
public:
|
||||
CPointerEmbedObject(void* data, NSPointerObjectDeleters::PointerObjectDeleter = nullptr);
|
||||
void Free();
|
||||
virtual ~CPointerEmbedObject();
|
||||
CPointerEmbedObject(void* data, NSPointerObjectDeleters::PointerObjectDeleter = nullptr);
|
||||
void Free();
|
||||
virtual ~CPointerEmbedObject();
|
||||
|
||||
virtual void* getObject() { return Data; }
|
||||
virtual void* getObject() { return Data; }
|
||||
|
||||
JSSmart<CJSValue> createObject();
|
||||
JSSmart<CJSValue> createObject();
|
||||
};
|
||||
|
||||
#endif // _BUILD_NATIVE_POINTER_EMBED_H_
|
||||
|
||||
@ -12,182 +12,182 @@
|
||||
class CExternalPointerJS : public NSShaper::CExternalPointer
|
||||
{
|
||||
public:
|
||||
CExternalPointerJS() : NSShaper::CExternalPointer() {}
|
||||
virtual ~CExternalPointerJS() {}
|
||||
CExternalPointerJS() : NSShaper::CExternalPointer() {}
|
||||
virtual ~CExternalPointerJS() {}
|
||||
|
||||
public:
|
||||
virtual void Alloc(const unsigned int& len)
|
||||
{
|
||||
Len = len;
|
||||
Data = NSAllocator::Alloc((size_t)Len);
|
||||
}
|
||||
virtual void Free()
|
||||
{
|
||||
if (Data)
|
||||
NSAllocator::Free(Data, (size_t)Len);
|
||||
}
|
||||
virtual void Alloc(const unsigned int& len)
|
||||
{
|
||||
Len = len;
|
||||
Data = NSAllocator::Alloc((size_t)Len);
|
||||
}
|
||||
virtual void Free()
|
||||
{
|
||||
if (Data)
|
||||
NSAllocator::Free(Data, (size_t)Len);
|
||||
}
|
||||
};
|
||||
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Malloc(JSSmart<CJSValue> typed_array_or_len)
|
||||
{
|
||||
void* pData = NULL;
|
||||
size_t len = 0;
|
||||
void* pData = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
if (typed_array_or_len->isNumber())
|
||||
{
|
||||
len = (size_t)typed_array_or_len->toInt32();
|
||||
if (0 != len)
|
||||
pData = malloc((size_t)len);
|
||||
}
|
||||
else
|
||||
{
|
||||
JSSmart<CJSTypedArray> typedArray = typed_array_or_len->toTypedArray();
|
||||
CJSDataBuffer pBuffer = typedArray->getData();
|
||||
pData = malloc(pBuffer.Len);
|
||||
memcpy(pData, pBuffer.Data, pBuffer.Len);
|
||||
if (pBuffer.IsExternalize)
|
||||
pBuffer.Free();
|
||||
}
|
||||
if (typed_array_or_len->isNumber())
|
||||
{
|
||||
len = (size_t)typed_array_or_len->toInt32();
|
||||
if (0 != len)
|
||||
pData = malloc((size_t)len);
|
||||
}
|
||||
else
|
||||
{
|
||||
JSSmart<CJSTypedArray> typedArray = typed_array_or_len->toTypedArray();
|
||||
CJSDataBuffer pBuffer = typedArray->getData();
|
||||
pData = malloc(pBuffer.Len);
|
||||
memcpy(pData, pBuffer.Data, pBuffer.Len);
|
||||
if (pBuffer.IsExternalize)
|
||||
pBuffer.Free();
|
||||
}
|
||||
|
||||
CPointerEmbedObject* pObject = new CPointerEmbedObject(pData, NSPointerObjectDeleters::FreeDeleter);
|
||||
return pObject->createObject();
|
||||
CPointerEmbedObject* pObject = new CPointerEmbedObject(pData, NSPointerObjectDeleters::FreeDeleter);
|
||||
return pObject->createObject();
|
||||
}
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Free(JSSmart<CJSValue> pointer)
|
||||
{
|
||||
CPointerEmbedObject* pEmbed = (CPointerEmbedObject*)pointer->toObjectSmart()->getNative();
|
||||
pEmbed->Free();
|
||||
return CJSContext::createUndefined();
|
||||
CPointerEmbedObject* pEmbed = (CPointerEmbedObject*)pointer->toObjectSmart()->getNative();
|
||||
pEmbed->Free();
|
||||
return CJSContext::createUndefined();
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Init()
|
||||
{
|
||||
CPointerEmbedObject* pointer = new CPointerEmbedObject(NSShaper::FT_Library_Init(), [](void* data) { NSShaper::FT_Library_UnReference(data); });
|
||||
return pointer->createObject();
|
||||
CPointerEmbedObject* pointer = new CPointerEmbedObject(NSShaper::FT_Library_Init(), [](void* data) { NSShaper::FT_Library_UnReference(data); });
|
||||
return pointer->createObject();
|
||||
}
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Set_TrueType_HintProp(JSSmart<CJSValue> library, JSSmart<CJSValue> tt_interpreter)
|
||||
{
|
||||
return CJSContext::createInt(NSShaper::FT_Set_TrueType_HintProp(RAW_POINTER(library), tt_interpreter->toUInt32()));
|
||||
return CJSContext::createInt(NSShaper::FT_Set_TrueType_HintProp(RAW_POINTER(library), tt_interpreter->toUInt32()));
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Open_Face(JSSmart<CJSValue> library, JSSmart<CJSValue> memory, JSSmart<CJSValue> size, JSSmart<CJSValue> face_index)
|
||||
{
|
||||
void* ftlibrary = RAW_POINTER(library);
|
||||
void* face = NSShaper::FT_Open_Face(ftlibrary, (unsigned char*)RAW_POINTER(memory), size->toUInt32(), face_index->toInt32());
|
||||
if (NULL != face)
|
||||
NSShaper::FT_Library_Reference(ftlibrary);
|
||||
CPointerEmbedObject* pointer = new CPointerEmbedObject(face, [](void* data) { NSShaper::FT_Done_Face_With_Library(data); });
|
||||
return pointer->createObject();
|
||||
void* ftlibrary = RAW_POINTER(library);
|
||||
void* face = NSShaper::FT_Open_Face(ftlibrary, (unsigned char*)RAW_POINTER(memory), size->toUInt32(), face_index->toInt32());
|
||||
if (NULL != face)
|
||||
NSShaper::FT_Library_Reference(ftlibrary);
|
||||
CPointerEmbedObject* pointer = new CPointerEmbedObject(face, [](void* data) { NSShaper::FT_Done_Face_With_Library(data); });
|
||||
return pointer->createObject();
|
||||
}
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Open_Face2(JSSmart<CJSValue> library, JSSmart<CJSValue> array, JSSmart<CJSValue> face_index)
|
||||
{
|
||||
void* ftlibrary = RAW_POINTER(library);
|
||||
JSSmart<CJSTypedArray> typedArray = array->toTypedArray();
|
||||
CJSDataBuffer buffer = typedArray->getData();
|
||||
void* face = NSShaper::FT_Open_Face(ftlibrary, (unsigned char*)buffer.Data, (unsigned int)buffer.Len, face_index->toInt32());
|
||||
if (NULL != face)
|
||||
NSShaper::FT_Library_Reference(ftlibrary);
|
||||
CPointerEmbedObject* pointer = new CPointerEmbedObject(face, [](void* data) { NSShaper::FT_Done_Face_With_Library(data); });
|
||||
return pointer->createObject();
|
||||
void* ftlibrary = RAW_POINTER(library);
|
||||
JSSmart<CJSTypedArray> typedArray = array->toTypedArray();
|
||||
CJSDataBuffer buffer = typedArray->getData();
|
||||
void* face = NSShaper::FT_Open_Face(ftlibrary, (unsigned char*)buffer.Data, (unsigned int)buffer.Len, face_index->toInt32());
|
||||
if (NULL != face)
|
||||
NSShaper::FT_Library_Reference(ftlibrary);
|
||||
CPointerEmbedObject* pointer = new CPointerEmbedObject(face, [](void* data) { NSShaper::FT_Done_Face_With_Library(data); });
|
||||
return pointer->createObject();
|
||||
}
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_GetFaceInfo(JSSmart<CJSValue> face)
|
||||
{
|
||||
CExternalPointerJS result;
|
||||
if (!NSShaper::FT_GetFaceInfo(RAW_POINTER(face), &result))
|
||||
return CJSContext::createNull();
|
||||
CExternalPointerJS result;
|
||||
if (!NSShaper::FT_GetFaceInfo(RAW_POINTER(face), &result))
|
||||
return CJSContext::createNull();
|
||||
|
||||
return CJSContext::createUint8Array(result.Data, result.Len, false);
|
||||
return CJSContext::createUint8Array(result.Data, result.Len, false);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Load_Glyph(JSSmart<CJSValue> face, JSSmart<CJSValue> gid, JSSmart<CJSValue> mode)
|
||||
{
|
||||
return CJSContext::createInt(NSShaper::FT_Load_Glyph(RAW_POINTER(face), gid->toUInt32(), mode->toInt32()));
|
||||
return CJSContext::createInt(NSShaper::FT_Load_Glyph(RAW_POINTER(face), gid->toUInt32(), mode->toInt32()));
|
||||
}
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Get_Glyph_Measure_Params(JSSmart<CJSValue> face, JSSmart<CJSValue> is_vector)
|
||||
{
|
||||
CExternalPointerJS result;
|
||||
if (!NSShaper::FT_Get_Glyph_Measure_Params(RAW_POINTER(face), is_vector->toBool(), &result))
|
||||
return CJSContext::createNull();
|
||||
CExternalPointerJS result;
|
||||
if (!NSShaper::FT_Get_Glyph_Measure_Params(RAW_POINTER(face), is_vector->toBool(), &result))
|
||||
return CJSContext::createNull();
|
||||
|
||||
return CJSContext::createUint8Array(result.Data, result.Len, false);
|
||||
return CJSContext::createUint8Array(result.Data, result.Len, false);
|
||||
}
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Get_Glyph_Render_Params(JSSmart<CJSValue> face, JSSmart<CJSValue> render_mode)
|
||||
{
|
||||
CExternalPointerJS result;
|
||||
if (!NSShaper::FT_Get_Glyph_Render_Params(RAW_POINTER(face), render_mode->toInt32(), &result))
|
||||
return CJSContext::createNull();
|
||||
CExternalPointerJS result;
|
||||
if (!NSShaper::FT_Get_Glyph_Render_Params(RAW_POINTER(face), render_mode->toInt32(), &result))
|
||||
return CJSContext::createNull();
|
||||
|
||||
return CJSContext::createUint8Array(result.Data, result.Len, false);
|
||||
return CJSContext::createUint8Array(result.Data, result.Len, false);
|
||||
}
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Get_Glyph_Render_Buffer(JSSmart<CJSValue> face, JSSmart<CJSValue> size)
|
||||
{
|
||||
void* Data = NSShaper::FT_Get_Glyph_Render_Buffer(RAW_POINTER(face));
|
||||
return CJSContext::createUint8Array((unsigned char*)Data, size->toInt32(), true);
|
||||
void* Data = NSShaper::FT_Get_Glyph_Render_Buffer(RAW_POINTER(face));
|
||||
return CJSContext::createUint8Array((unsigned char*)Data, size->toInt32(), true);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Set_Transform(JSSmart<CJSValue> face, JSSmart<CJSValue> xx, JSSmart<CJSValue> yx, JSSmart<CJSValue> xy, JSSmart<CJSValue> yy)
|
||||
{
|
||||
NSShaper::FT_Set_Transform(RAW_POINTER(face), xx->toInt32(), yx->toInt32(), xy->toInt32(), yy->toInt32());
|
||||
return CJSContext::createUndefined();
|
||||
NSShaper::FT_Set_Transform(RAW_POINTER(face), xx->toInt32(), yx->toInt32(), xy->toInt32(), yy->toInt32());
|
||||
return CJSContext::createUndefined();
|
||||
}
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Set_Char_Size(JSSmart<CJSValue> face, JSSmart<CJSValue> char_width, JSSmart<CJSValue> char_height, JSSmart<CJSValue> hres, JSSmart<CJSValue> vres)
|
||||
{
|
||||
return CJSContext::createInt(NSShaper::FT_Set_Char_Size(RAW_POINTER(face), char_width->toInt32(), char_height->toInt32(), hres->toUInt32(), vres->toUInt32()));
|
||||
return CJSContext::createInt(NSShaper::FT_Set_Char_Size(RAW_POINTER(face), char_width->toInt32(), char_height->toInt32(), hres->toUInt32(), vres->toUInt32()));
|
||||
}
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_SetCMapForCharCode(JSSmart<CJSValue> face, JSSmart<CJSValue> unicode)
|
||||
{
|
||||
return CJSContext::createUInt(NSShaper::FT_SetCMapForCharCode(RAW_POINTER(face), unicode->toUInt32()));
|
||||
return CJSContext::createUInt(NSShaper::FT_SetCMapForCharCode(RAW_POINTER(face), unicode->toUInt32()));
|
||||
}
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_GetKerningX(JSSmart<CJSValue> face, JSSmart<CJSValue> gid1, JSSmart<CJSValue> gid2)
|
||||
{
|
||||
return CJSContext::createInt(NSShaper::FT_GetKerningX(RAW_POINTER(face), gid1->toUInt32(), gid2->toUInt32()));
|
||||
return CJSContext::createInt(NSShaper::FT_GetKerningX(RAW_POINTER(face), gid1->toUInt32(), gid2->toUInt32()));
|
||||
}
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_GetFaceMaxAdvanceX(JSSmart<CJSValue> face)
|
||||
{
|
||||
return CJSContext::createInt(NSShaper::FT_GetFaceMaxAdvanceX(RAW_POINTER(face)));
|
||||
return CJSContext::createInt(NSShaper::FT_GetFaceMaxAdvanceX(RAW_POINTER(face)));
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_HARFBUZZ_SHAPER
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::HB_LanguageFromString(JSSmart<CJSValue> language_bcp_47)
|
||||
{
|
||||
void* Data = NSShaper::HB_LanguageFromString(language_bcp_47->toStringA());
|
||||
CPointerEmbedObject* pObject = new CPointerEmbedObject(Data, NSPointerObjectDeleters::EmptyDeleter);
|
||||
return pObject->createObject();
|
||||
void* Data = NSShaper::HB_LanguageFromString(language_bcp_47->toStringA());
|
||||
CPointerEmbedObject* pObject = new CPointerEmbedObject(Data, NSPointerObjectDeleters::EmptyDeleter);
|
||||
return pObject->createObject();
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::HB_ShapeText(JSSmart<CJSValue> face, JSSmart<CJSValue> font, JSSmart<CJSValue> text,
|
||||
JSSmart<CJSValue> nFeatures, JSSmart<CJSValue> nScript, JSSmart<CJSValue> nDirection, JSSmart<CJSValue> nLanguage)
|
||||
JSSmart<CJSValue> nFeatures, JSSmart<CJSValue> nScript, JSSmart<CJSValue> nDirection, JSSmart<CJSValue> nLanguage)
|
||||
{
|
||||
CPointerEmbedObject* pFont = POINTER_OBJECT(font);
|
||||
CExternalPointerJS result;
|
||||
CPointerEmbedObject* pFont = POINTER_OBJECT(font);
|
||||
CExternalPointerJS result;
|
||||
|
||||
JSSmart<CJSTypedArray> typedArray = text->toTypedArray();
|
||||
CJSDataBuffer buffer = typedArray->getData();
|
||||
JSSmart<CJSTypedArray> typedArray = text->toTypedArray();
|
||||
CJSDataBuffer buffer = typedArray->getData();
|
||||
|
||||
char* pText = (char*)buffer.Data;
|
||||
char* pText = (char*)buffer.Data;
|
||||
|
||||
NSShaper::HB_ShapeText(RAW_POINTER(face), pFont->Data, pText,
|
||||
nFeatures->toUInt32(), nScript->toUInt32(), nDirection->toUInt32(), RAW_POINTER(nLanguage),
|
||||
&result, true);
|
||||
NSShaper::HB_ShapeText(RAW_POINTER(face), pFont->Data, pText,
|
||||
nFeatures->toUInt32(), nScript->toUInt32(), nDirection->toUInt32(), RAW_POINTER(nLanguage),
|
||||
&result, true);
|
||||
|
||||
if (buffer.IsExternalize)
|
||||
buffer.Free();
|
||||
if (buffer.IsExternalize)
|
||||
buffer.Free();
|
||||
|
||||
if (NULL == result.Data)
|
||||
return CJSContext::createNull();
|
||||
if (NULL == result.Data)
|
||||
return CJSContext::createNull();
|
||||
|
||||
return CJSContext::createUint8Array(result.Data, result.Len, false);
|
||||
return CJSContext::createUint8Array(result.Data, result.Len, false);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::HB_FontMalloc()
|
||||
{
|
||||
CPointerEmbedObject* pObject = new CPointerEmbedObject(NULL, [](void* data) { NSShaper::HB_FontFree(data); });
|
||||
return pObject->createObject();
|
||||
CPointerEmbedObject* pObject = new CPointerEmbedObject(NULL, [](void* data) { NSShaper::HB_FontFree(data); });
|
||||
return pObject->createObject();
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::HB_FontFree(JSSmart<CJSValue> font)
|
||||
{
|
||||
CPointerEmbedObject* pFont = POINTER_OBJECT(font);
|
||||
pFont->Free();
|
||||
return CJSContext::createUndefined();
|
||||
CPointerEmbedObject* pFont = POINTER_OBJECT(font);
|
||||
pFont->Free();
|
||||
return CJSContext::createUndefined();
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -12,46 +12,46 @@ using namespace NSJSBase;
|
||||
class CTextMeasurerEmbed : public CJSEmbedObject
|
||||
{
|
||||
public:
|
||||
CTextMeasurerEmbed()
|
||||
{
|
||||
}
|
||||
~CTextMeasurerEmbed()
|
||||
{
|
||||
}
|
||||
CTextMeasurerEmbed()
|
||||
{
|
||||
}
|
||||
~CTextMeasurerEmbed()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
JSSmart<CJSValue> FT_Malloc(JSSmart<CJSValue> typed_array_or_len);
|
||||
JSSmart<CJSValue> FT_Free(JSSmart<CJSValue> pointer);
|
||||
JSSmart<CJSValue> FT_Malloc(JSSmart<CJSValue> typed_array_or_len);
|
||||
JSSmart<CJSValue> FT_Free(JSSmart<CJSValue> pointer);
|
||||
|
||||
JSSmart<CJSValue> FT_Init();
|
||||
JSSmart<CJSValue> FT_Set_TrueType_HintProp(JSSmart<CJSValue> library, JSSmart<CJSValue> tt_interpreter);
|
||||
JSSmart<CJSValue> FT_Init();
|
||||
JSSmart<CJSValue> FT_Set_TrueType_HintProp(JSSmart<CJSValue> library, JSSmart<CJSValue> tt_interpreter);
|
||||
|
||||
JSSmart<CJSValue> FT_Open_Face(JSSmart<CJSValue> library, JSSmart<CJSValue> memory, JSSmart<CJSValue> size, JSSmart<CJSValue> face_index);
|
||||
JSSmart<CJSValue> FT_Open_Face2(JSSmart<CJSValue> library, JSSmart<CJSValue> array, JSSmart<CJSValue> face_index);
|
||||
JSSmart<CJSValue> FT_GetFaceInfo(JSSmart<CJSValue> face);
|
||||
JSSmart<CJSValue> FT_Open_Face(JSSmart<CJSValue> library, JSSmart<CJSValue> memory, JSSmart<CJSValue> size, JSSmart<CJSValue> face_index);
|
||||
JSSmart<CJSValue> FT_Open_Face2(JSSmart<CJSValue> library, JSSmart<CJSValue> array, JSSmart<CJSValue> face_index);
|
||||
JSSmart<CJSValue> FT_GetFaceInfo(JSSmart<CJSValue> face);
|
||||
|
||||
JSSmart<CJSValue> FT_Load_Glyph(JSSmart<CJSValue> face, JSSmart<CJSValue> gid, JSSmart<CJSValue> mode);
|
||||
JSSmart<CJSValue> FT_Get_Glyph_Measure_Params(JSSmart<CJSValue> face, JSSmart<CJSValue> is_vector);
|
||||
JSSmart<CJSValue> FT_Get_Glyph_Render_Params(JSSmart<CJSValue> face, JSSmart<CJSValue> render_mode);
|
||||
JSSmart<CJSValue> FT_Get_Glyph_Render_Buffer(JSSmart<CJSValue> face, JSSmart<CJSValue> size);
|
||||
JSSmart<CJSValue> FT_Load_Glyph(JSSmart<CJSValue> face, JSSmart<CJSValue> gid, JSSmart<CJSValue> mode);
|
||||
JSSmart<CJSValue> FT_Get_Glyph_Measure_Params(JSSmart<CJSValue> face, JSSmart<CJSValue> is_vector);
|
||||
JSSmart<CJSValue> FT_Get_Glyph_Render_Params(JSSmart<CJSValue> face, JSSmart<CJSValue> render_mode);
|
||||
JSSmart<CJSValue> FT_Get_Glyph_Render_Buffer(JSSmart<CJSValue> face, JSSmart<CJSValue> size);
|
||||
|
||||
JSSmart<CJSValue> FT_Set_Transform(JSSmart<CJSValue> face, JSSmart<CJSValue> xx, JSSmart<CJSValue> yx, JSSmart<CJSValue> xy, JSSmart<CJSValue> yy);
|
||||
JSSmart<CJSValue> FT_Set_Char_Size(JSSmart<CJSValue> face, JSSmart<CJSValue> char_width, JSSmart<CJSValue> char_height, JSSmart<CJSValue> hres, JSSmart<CJSValue> vres);
|
||||
JSSmart<CJSValue> FT_SetCMapForCharCode(JSSmart<CJSValue> face, JSSmart<CJSValue> unicode);
|
||||
JSSmart<CJSValue> FT_GetKerningX(JSSmart<CJSValue> face, JSSmart<CJSValue> gid1, JSSmart<CJSValue> gid2);
|
||||
JSSmart<CJSValue> FT_GetFaceMaxAdvanceX(JSSmart<CJSValue> face);
|
||||
JSSmart<CJSValue> FT_Set_Transform(JSSmart<CJSValue> face, JSSmart<CJSValue> xx, JSSmart<CJSValue> yx, JSSmart<CJSValue> xy, JSSmart<CJSValue> yy);
|
||||
JSSmart<CJSValue> FT_Set_Char_Size(JSSmart<CJSValue> face, JSSmart<CJSValue> char_width, JSSmart<CJSValue> char_height, JSSmart<CJSValue> hres, JSSmart<CJSValue> vres);
|
||||
JSSmart<CJSValue> FT_SetCMapForCharCode(JSSmart<CJSValue> face, JSSmart<CJSValue> unicode);
|
||||
JSSmart<CJSValue> FT_GetKerningX(JSSmart<CJSValue> face, JSSmart<CJSValue> gid1, JSSmart<CJSValue> gid2);
|
||||
JSSmart<CJSValue> FT_GetFaceMaxAdvanceX(JSSmart<CJSValue> face);
|
||||
|
||||
#ifdef SUPPORT_HARFBUZZ_SHAPER
|
||||
JSSmart<CJSValue> HB_LanguageFromString(JSSmart<CJSValue> language_bcp_47);
|
||||
JSSmart<CJSValue> HB_LanguageFromString(JSSmart<CJSValue> language_bcp_47);
|
||||
|
||||
JSSmart<CJSValue> HB_ShapeText(JSSmart<CJSValue> face, JSSmart<CJSValue> font, JSSmart<CJSValue> text,
|
||||
JSSmart<CJSValue> nFeatures, JSSmart<CJSValue> nScript, JSSmart<CJSValue> nDirection, JSSmart<CJSValue> nLanguage);
|
||||
JSSmart<CJSValue> HB_ShapeText(JSSmart<CJSValue> face, JSSmart<CJSValue> font, JSSmart<CJSValue> text,
|
||||
JSSmart<CJSValue> nFeatures, JSSmart<CJSValue> nScript, JSSmart<CJSValue> nDirection, JSSmart<CJSValue> nLanguage);
|
||||
|
||||
JSSmart<CJSValue> HB_FontMalloc();
|
||||
JSSmart<CJSValue> HB_FontFree(JSSmart<CJSValue> font);
|
||||
JSSmart<CJSValue> HB_FontMalloc();
|
||||
JSSmart<CJSValue> HB_FontFree(JSSmart<CJSValue> font);
|
||||
#endif
|
||||
|
||||
static void CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context);
|
||||
static void CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context);
|
||||
};
|
||||
|
||||
#endif // _BUILD_NATIVE_TEXT_MEASURER_EMBED_H_
|
||||
|
||||
31
DesktopEditor/doctrenderer/embed/jsc/jsc_Hash.mm
Normal file
31
DesktopEditor/doctrenderer/embed/jsc/jsc_Hash.mm
Normal file
@ -0,0 +1,31 @@
|
||||
#include "../HashEmbed.h"
|
||||
#include "../../js_internal/jsc/jsc_base.h"
|
||||
|
||||
@protocol IJSCHash <JSExport>
|
||||
-(JSValue*) hash : (JSValue*)data : (JSValue*)size : (JSValue*)alg;
|
||||
-(JSValue*) hash2 : (JSValue*)password : (JSValue*)salt : (JSValue*)spinCount : (JSValue*)alg;
|
||||
|
||||
@end
|
||||
|
||||
@interface CJSCHash : NSObject<IJSCHash, JSEmbedObjectProtocol>
|
||||
{
|
||||
@public
|
||||
CHashEmbed* m_internal;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation CJSCHash
|
||||
|
||||
EMBED_OBJECT_WRAPPER_METHODS(CHashEmbed)
|
||||
|
||||
FUNCTION_WRAPPER_JS_3(hash, hash)
|
||||
FUNCTION_WRAPPER_JS_4(hash2, hash2)
|
||||
|
||||
@end
|
||||
|
||||
void CHashEmbed::CreateObjectInContext(const std::string &name, JSSmart<CJSContext> context)
|
||||
{
|
||||
context->m_internal->context[[NSString stringWithAString:name]] = ^(){
|
||||
return [[CJSCHash alloc] init];
|
||||
};
|
||||
}
|
||||
@ -3,260 +3,248 @@
|
||||
|
||||
namespace NSGraphics
|
||||
{
|
||||
#define CURRENTWRAPPER CGraphicsEmbed
|
||||
#define CURRENTWRAPPER CGraphicsEmbed
|
||||
|
||||
// FUNCTION
|
||||
FUNCTION_WRAPPER_V8_5(_init, init)
|
||||
FUNCTION_WRAPPER_V8 (_destroy, Destroy)
|
||||
FUNCTION_WRAPPER_V8 (_EndDraw, EndDraw)
|
||||
FUNCTION_WRAPPER_V8_2(_put_GlobalAlpha, put_GlobalAlpha)
|
||||
FUNCTION_WRAPPER_V8 (_Start_GlobalAlpha, Start_GlobalAlpha)
|
||||
FUNCTION_WRAPPER_V8 (_End_GlobalAlpha, End_GlobalAlpha)
|
||||
// pen methods
|
||||
FUNCTION_WRAPPER_V8_4(_p_color, p_color)
|
||||
FUNCTION_WRAPPER_V8_1(_p_width, p_width)
|
||||
FUNCTION_WRAPPER_V8_1(_p_dash, p_dash)
|
||||
// brush methods
|
||||
FUNCTION_WRAPPER_V8_4(_b_color1, b_color1)
|
||||
FUNCTION_WRAPPER_V8_4(_b_color2, b_color2)
|
||||
FUNCTION_WRAPPER_V8_6(_transform, transform)
|
||||
FUNCTION_WRAPPER_V8_1(_CalculateFullTransform, CalculateFullTransform)
|
||||
// path commands
|
||||
FUNCTION_WRAPPER_V8 (__s, _s)
|
||||
FUNCTION_WRAPPER_V8 (__e, _e)
|
||||
FUNCTION_WRAPPER_V8 (__z, _z)
|
||||
FUNCTION_WRAPPER_V8_2(__m, _m)
|
||||
FUNCTION_WRAPPER_V8_2(__l, _l)
|
||||
FUNCTION_WRAPPER_V8_6(__c, _c)
|
||||
FUNCTION_WRAPPER_V8_4(__c2, _c2)
|
||||
FUNCTION_WRAPPER_V8 (_ds, ds)
|
||||
FUNCTION_WRAPPER_V8 (_df, df)
|
||||
// canvas state
|
||||
FUNCTION_WRAPPER_V8 (_save, save)
|
||||
FUNCTION_WRAPPER_V8 (_restore, restore)
|
||||
FUNCTION_WRAPPER_V8 (_clip, clip)
|
||||
FUNCTION_WRAPPER_V8 (_reset, reset)
|
||||
FUNCTION_WRAPPER_V8 (_FreeFont, FreeFont)
|
||||
FUNCTION_WRAPPER_V8 (_ClearLastFont, ClearLastFont)
|
||||
// images
|
||||
FUNCTION_WRAPPER_V8_7(_drawImage2, drawImage2)
|
||||
FUNCTION_WRAPPER_V8_8(_drawImage, drawImage)
|
||||
// text
|
||||
FUNCTION_WRAPPER_V8 (_GetFont, GetFont)
|
||||
FUNCTION_WRAPPER_V8_2(_font, font)
|
||||
FUNCTION_WRAPPER_V8_4(_SetFont, SetFont)
|
||||
FUNCTION_WRAPPER_V8 (_GetTextPr, GetTextPr)
|
||||
FUNCTION_WRAPPER_V8_3(_FillText, FillText)
|
||||
FUNCTION_WRAPPER_V8_3(_t, t)
|
||||
FUNCTION_WRAPPER_V8_5(_FillText2, FillText2)
|
||||
FUNCTION_WRAPPER_V8_5(_t2, t2)
|
||||
FUNCTION_WRAPPER_V8_3(_FillTextCode, FillTextCode)
|
||||
FUNCTION_WRAPPER_V8_3(_tg, tg)
|
||||
FUNCTION_WRAPPER_V8_1(_charspace, charspace)
|
||||
// private methods
|
||||
FUNCTION_WRAPPER_V8_2(_private_FillGlyph, private_FillGlyph)
|
||||
FUNCTION_WRAPPER_V8_3(_private_FillGlyphC, private_FillGlyphC)
|
||||
FUNCTION_WRAPPER_V8_1(_private_FillGlyph2, private_FillGlyph2)
|
||||
FUNCTION_WRAPPER_V8_1(_SetIntegerGrid, SetIntegerGrid)
|
||||
FUNCTION_WRAPPER_V8 (_GetIntegerGrid, GetIntegerGrid)
|
||||
FUNCTION_WRAPPER_V8_3(_DrawStringASCII, DrawStringASCII)
|
||||
FUNCTION_WRAPPER_V8_3(_DrawStringASCII2, DrawStringASCII2)
|
||||
FUNCTION_WRAPPER_V8_5(_DrawHeaderEdit, DrawHeaderEdit)
|
||||
FUNCTION_WRAPPER_V8_5(_DrawFooterEdit, DrawFooterEdit)
|
||||
FUNCTION_WRAPPER_V8_3(_DrawLockParagraph, DrawLockParagraph)
|
||||
FUNCTION_WRAPPER_V8_4(_DrawLockObjectRect, DrawLockObjectRect)
|
||||
FUNCTION_WRAPPER_V8_4(_DrawEmptyTableLine, DrawEmptyTableLine)
|
||||
FUNCTION_WRAPPER_V8_4(_DrawSpellingLine, DrawSpellingLine)
|
||||
// smart methods for horizontal / vertical lines
|
||||
FUNCTION_WRAPPER_V8_5(_drawHorLine, drawHorLine)
|
||||
FUNCTION_WRAPPER_V8_5(_drawHorLine2, drawHorLine2)
|
||||
FUNCTION_WRAPPER_V8_5(_drawVerLine, drawVerLine)
|
||||
// мега крутые функции для таблиц
|
||||
FUNCTION_WRAPPER_V8_7(_drawHorLineExt, drawHorLineExt)
|
||||
FUNCTION_WRAPPER_V8_4(_rect, rect)
|
||||
FUNCTION_WRAPPER_V8_4(_TableRect, TableRect)
|
||||
// функции клиппирования
|
||||
FUNCTION_WRAPPER_V8_4(_AddClipRect, AddClipRect)
|
||||
FUNCTION_WRAPPER_V8 (_RemoveClipRect, RemoveClipRect)
|
||||
FUNCTION_WRAPPER_V8_4(_SetClip, SetClip)
|
||||
FUNCTION_WRAPPER_V8 (_RemoveClip, RemoveClip)
|
||||
FUNCTION_WRAPPER_V8_4(_drawMailMergeField, drawMailMergeField)
|
||||
FUNCTION_WRAPPER_V8_4(_drawSearchResult, drawSearchResult)
|
||||
FUNCTION_WRAPPER_V8_2(_drawFlowAnchor, drawFlowAnchor)
|
||||
FUNCTION_WRAPPER_V8 (_SavePen, SavePen)
|
||||
FUNCTION_WRAPPER_V8 (_RestorePen, RestorePen)
|
||||
FUNCTION_WRAPPER_V8 (_SaveBrush, SaveBrush)
|
||||
FUNCTION_WRAPPER_V8 (_RestoreBrush, RestoreBrush)
|
||||
FUNCTION_WRAPPER_V8 (_SavePenBrush, SavePenBrush)
|
||||
FUNCTION_WRAPPER_V8 (_RestorePenBrush, RestorePenBrush)
|
||||
FUNCTION_WRAPPER_V8 (_SaveGrState, SaveGrState)
|
||||
FUNCTION_WRAPPER_V8 (_RestoreGrState, RestoreGrState)
|
||||
FUNCTION_WRAPPER_V8 (_StartClipPath, StartClipPath)
|
||||
FUNCTION_WRAPPER_V8 (_EndClipPath, EndClipPath)
|
||||
FUNCTION_WRAPPER_V8 (_StartCheckTableDraw, StartCheckTableDraw)
|
||||
FUNCTION_WRAPPER_V8_4(_SetTextClipRect, SetTextClipRect)
|
||||
FUNCTION_WRAPPER_V8_5(_AddSmartRect, AddSmartRect)
|
||||
FUNCTION_WRAPPER_V8_1(_CheckUseFonts2, CheckUseFonts2)
|
||||
FUNCTION_WRAPPER_V8 (_UncheckUseFonts2, UncheckUseFonts2)
|
||||
FUNCTION_WRAPPER_V8_4(_Drawing_StartCheckBounds, Drawing_StartCheckBounds)
|
||||
FUNCTION_WRAPPER_V8 (_Drawing_EndCheckBounds, Drawing_EndCheckBounds)
|
||||
FUNCTION_WRAPPER_V8_5(_DrawPresentationComment, DrawPresentationComment)
|
||||
FUNCTION_WRAPPER_V8_3(_DrawPolygon, DrawPolygon)
|
||||
FUNCTION_WRAPPER_V8_4(_DrawFootnoteRect, DrawFootnoteRect)
|
||||
// new methods
|
||||
FUNCTION_WRAPPER_V8_1(_toDataURL, toDataURL)
|
||||
FUNCTION_WRAPPER_V8 (_GetPenColor, GetPenColor)
|
||||
FUNCTION_WRAPPER_V8 (_GetBrushColor, GetBrushColor)
|
||||
FUNCTION_WRAPPER_V8_2(_put_brushTexture, put_brushTexture)
|
||||
FUNCTION_WRAPPER_V8_1(_put_brushTextureMode, put_brushTextureMode)
|
||||
FUNCTION_WRAPPER_V8_1(_put_BrushTextureAlpha, put_BrushTextureAlpha)
|
||||
FUNCTION_WRAPPER_V8_8(_put_BrushGradient, put_BrushGradient)
|
||||
FUNCTION_WRAPPER_V8_2(_TransformPointX, TransformPointX)
|
||||
FUNCTION_WRAPPER_V8_2(_TransformPointY, TransformPointY)
|
||||
FUNCTION_WRAPPER_V8_1(_put_LineJoin, put_LineJoin)
|
||||
FUNCTION_WRAPPER_V8 (_get_LineJoin, get_LineJoin)
|
||||
FUNCTION_WRAPPER_V8_4(_put_TextureBounds, put_TextureBounds)
|
||||
FUNCTION_WRAPPER_V8 (_GetlineWidth, GetlineWidth)
|
||||
FUNCTION_WRAPPER_V8_1(_DrawPath, DrawPath)
|
||||
FUNCTION_WRAPPER_V8_2(_CoordTransformOffset, CoordTransformOffset)
|
||||
FUNCTION_WRAPPER_V8 (_GetTransform, GetTransform)
|
||||
// FUNCTION
|
||||
FUNCTION_WRAPPER_V8_5(_init, init)
|
||||
FUNCTION_WRAPPER_V8 (_destroy, Destroy)
|
||||
FUNCTION_WRAPPER_V8 (_EndDraw, EndDraw)
|
||||
FUNCTION_WRAPPER_V8_2(_put_GlobalAlpha, put_GlobalAlpha)
|
||||
FUNCTION_WRAPPER_V8 (_Start_GlobalAlpha, Start_GlobalAlpha)
|
||||
FUNCTION_WRAPPER_V8 (_End_GlobalAlpha, End_GlobalAlpha)
|
||||
// pen methods
|
||||
FUNCTION_WRAPPER_V8_4(_p_color, p_color)
|
||||
FUNCTION_WRAPPER_V8_1(_p_width, p_width)
|
||||
FUNCTION_WRAPPER_V8_1(_p_dash, p_dash)
|
||||
// brush methods
|
||||
FUNCTION_WRAPPER_V8_4(_b_color1, b_color1)
|
||||
FUNCTION_WRAPPER_V8_4(_b_color2, b_color2)
|
||||
FUNCTION_WRAPPER_V8_6(_transform, transform)
|
||||
FUNCTION_WRAPPER_V8_1(_CalculateFullTransform, CalculateFullTransform)
|
||||
// path commands
|
||||
FUNCTION_WRAPPER_V8 (__s, _s)
|
||||
FUNCTION_WRAPPER_V8 (__e, _e)
|
||||
FUNCTION_WRAPPER_V8 (__z, _z)
|
||||
FUNCTION_WRAPPER_V8_2(__m, _m)
|
||||
FUNCTION_WRAPPER_V8_2(__l, _l)
|
||||
FUNCTION_WRAPPER_V8_6(__c, _c)
|
||||
FUNCTION_WRAPPER_V8_4(__c2, _c2)
|
||||
FUNCTION_WRAPPER_V8 (_ds, ds)
|
||||
FUNCTION_WRAPPER_V8 (_df, df)
|
||||
// canvas state
|
||||
FUNCTION_WRAPPER_V8 (_save, save)
|
||||
FUNCTION_WRAPPER_V8 (_restore, restore)
|
||||
FUNCTION_WRAPPER_V8 (_clip, clip)
|
||||
FUNCTION_WRAPPER_V8 (_reset, reset)
|
||||
FUNCTION_WRAPPER_V8 (_FreeFont, FreeFont)
|
||||
FUNCTION_WRAPPER_V8 (_ClearLastFont, ClearLastFont)
|
||||
// images
|
||||
FUNCTION_WRAPPER_V8_7(_drawImage2, drawImage2)
|
||||
FUNCTION_WRAPPER_V8_8(_drawImage, drawImage)
|
||||
// text
|
||||
FUNCTION_WRAPPER_V8 (_GetFont, GetFont)
|
||||
FUNCTION_WRAPPER_V8_2(_font, font)
|
||||
FUNCTION_WRAPPER_V8_4(_SetFont, SetFont)
|
||||
FUNCTION_WRAPPER_V8 (_GetTextPr, GetTextPr)
|
||||
FUNCTION_WRAPPER_V8_3(_FillText, FillText)
|
||||
FUNCTION_WRAPPER_V8_3(_t, t)
|
||||
FUNCTION_WRAPPER_V8_5(_FillText2, FillText2)
|
||||
FUNCTION_WRAPPER_V8_5(_t2, t2)
|
||||
FUNCTION_WRAPPER_V8_3(_FillTextCode, FillTextCode)
|
||||
FUNCTION_WRAPPER_V8_3(_tg, tg)
|
||||
FUNCTION_WRAPPER_V8_1(_charspace, charspace)
|
||||
// private methods
|
||||
FUNCTION_WRAPPER_V8_2(_private_FillGlyph, private_FillGlyph)
|
||||
FUNCTION_WRAPPER_V8_3(_private_FillGlyphC, private_FillGlyphC)
|
||||
FUNCTION_WRAPPER_V8_1(_private_FillGlyph2, private_FillGlyph2)
|
||||
FUNCTION_WRAPPER_V8_1(_SetIntegerGrid, SetIntegerGrid)
|
||||
FUNCTION_WRAPPER_V8 (_GetIntegerGrid, GetIntegerGrid)
|
||||
FUNCTION_WRAPPER_V8_3(_DrawStringASCII, DrawStringASCII)
|
||||
FUNCTION_WRAPPER_V8_3(_DrawStringASCII2, DrawStringASCII2)
|
||||
FUNCTION_WRAPPER_V8_5(_DrawHeaderEdit, DrawHeaderEdit)
|
||||
FUNCTION_WRAPPER_V8_5(_DrawFooterEdit, DrawFooterEdit)
|
||||
FUNCTION_WRAPPER_V8_3(_DrawLockParagraph, DrawLockParagraph)
|
||||
FUNCTION_WRAPPER_V8_4(_DrawLockObjectRect, DrawLockObjectRect)
|
||||
FUNCTION_WRAPPER_V8_4(_DrawEmptyTableLine, DrawEmptyTableLine)
|
||||
FUNCTION_WRAPPER_V8_4(_DrawSpellingLine, DrawSpellingLine)
|
||||
// smart methods for horizontal / vertical lines
|
||||
FUNCTION_WRAPPER_V8_5(_drawHorLine, drawHorLine)
|
||||
FUNCTION_WRAPPER_V8_5(_drawHorLine2, drawHorLine2)
|
||||
FUNCTION_WRAPPER_V8_5(_drawVerLine, drawVerLine)
|
||||
// мега крутые функции для таблиц
|
||||
FUNCTION_WRAPPER_V8_7(_drawHorLineExt, drawHorLineExt)
|
||||
FUNCTION_WRAPPER_V8_4(_rect, rect)
|
||||
FUNCTION_WRAPPER_V8_4(_TableRect, TableRect)
|
||||
// функции клиппирования
|
||||
FUNCTION_WRAPPER_V8_4(_AddClipRect, AddClipRect)
|
||||
FUNCTION_WRAPPER_V8 (_RemoveClipRect, RemoveClipRect)
|
||||
FUNCTION_WRAPPER_V8_4(_SetClip, SetClip)
|
||||
FUNCTION_WRAPPER_V8 (_RemoveClip, RemoveClip)
|
||||
FUNCTION_WRAPPER_V8_4(_drawMailMergeField, drawMailMergeField)
|
||||
FUNCTION_WRAPPER_V8_4(_drawSearchResult, drawSearchResult)
|
||||
FUNCTION_WRAPPER_V8_2(_drawFlowAnchor, drawFlowAnchor)
|
||||
FUNCTION_WRAPPER_V8 (_SavePen, SavePen)
|
||||
FUNCTION_WRAPPER_V8 (_RestorePen, RestorePen)
|
||||
FUNCTION_WRAPPER_V8 (_SaveBrush, SaveBrush)
|
||||
FUNCTION_WRAPPER_V8 (_RestoreBrush, RestoreBrush)
|
||||
FUNCTION_WRAPPER_V8 (_SavePenBrush, SavePenBrush)
|
||||
FUNCTION_WRAPPER_V8 (_RestorePenBrush, RestorePenBrush)
|
||||
FUNCTION_WRAPPER_V8 (_SaveGrState, SaveGrState)
|
||||
FUNCTION_WRAPPER_V8 (_RestoreGrState, RestoreGrState)
|
||||
FUNCTION_WRAPPER_V8 (_StartClipPath, StartClipPath)
|
||||
FUNCTION_WRAPPER_V8 (_EndClipPath, EndClipPath)
|
||||
FUNCTION_WRAPPER_V8 (_StartCheckTableDraw, StartCheckTableDraw)
|
||||
FUNCTION_WRAPPER_V8_4(_SetTextClipRect, SetTextClipRect)
|
||||
FUNCTION_WRAPPER_V8_5(_AddSmartRect, AddSmartRect)
|
||||
FUNCTION_WRAPPER_V8_1(_CheckUseFonts2, CheckUseFonts2)
|
||||
FUNCTION_WRAPPER_V8 (_UncheckUseFonts2, UncheckUseFonts2)
|
||||
FUNCTION_WRAPPER_V8_4(_Drawing_StartCheckBounds, Drawing_StartCheckBounds)
|
||||
FUNCTION_WRAPPER_V8 (_Drawing_EndCheckBounds, Drawing_EndCheckBounds)
|
||||
FUNCTION_WRAPPER_V8_5(_DrawPresentationComment, DrawPresentationComment)
|
||||
FUNCTION_WRAPPER_V8_3(_DrawPolygon, DrawPolygon)
|
||||
FUNCTION_WRAPPER_V8_4(_DrawFootnoteRect, DrawFootnoteRect)
|
||||
// new methods
|
||||
FUNCTION_WRAPPER_V8_1(_toDataURL, toDataURL)
|
||||
FUNCTION_WRAPPER_V8 (_GetPenColor, GetPenColor)
|
||||
FUNCTION_WRAPPER_V8 (_GetBrushColor, GetBrushColor)
|
||||
FUNCTION_WRAPPER_V8_2(_put_brushTexture, put_brushTexture)
|
||||
FUNCTION_WRAPPER_V8_1(_put_brushTextureMode, put_brushTextureMode)
|
||||
FUNCTION_WRAPPER_V8_1(_put_BrushTextureAlpha, put_BrushTextureAlpha)
|
||||
FUNCTION_WRAPPER_V8_8(_put_BrushGradient, put_BrushGradient)
|
||||
FUNCTION_WRAPPER_V8_2(_TransformPointX, TransformPointX)
|
||||
FUNCTION_WRAPPER_V8_2(_TransformPointY, TransformPointY)
|
||||
FUNCTION_WRAPPER_V8_1(_put_LineJoin, put_LineJoin)
|
||||
FUNCTION_WRAPPER_V8 (_get_LineJoin, get_LineJoin)
|
||||
FUNCTION_WRAPPER_V8_4(_put_TextureBounds, put_TextureBounds)
|
||||
FUNCTION_WRAPPER_V8 (_GetlineWidth, GetlineWidth)
|
||||
FUNCTION_WRAPPER_V8_1(_DrawPath, DrawPath)
|
||||
FUNCTION_WRAPPER_V8_2(_CoordTransformOffset, CoordTransformOffset)
|
||||
FUNCTION_WRAPPER_V8 (_GetTransform, GetTransform)
|
||||
|
||||
v8::Handle<v8::ObjectTemplate> CreateGraphicsTemplate(v8::Isolate* isolate)
|
||||
{
|
||||
v8::EscapableHandleScope handle_scope(isolate);
|
||||
v8::Handle<v8::ObjectTemplate> CreateGraphicsTemplate(v8::Isolate* isolate)
|
||||
{
|
||||
v8::EscapableHandleScope handle_scope(isolate);
|
||||
|
||||
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New(isolate);
|
||||
result->SetInternalFieldCount(1);
|
||||
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New(isolate);
|
||||
result->SetInternalFieldCount(1);
|
||||
|
||||
v8::Isolate* current = v8::Isolate::GetCurrent();
|
||||
v8::Isolate* current = v8::Isolate::GetCurrent();
|
||||
|
||||
// методы
|
||||
NSV8Objects::Template_Set(result, "create", _init);
|
||||
NSV8Objects::Template_Set(result, "Destroy", _destroy);
|
||||
NSV8Objects::Template_Set(result, "EndDraw", _EndDraw);
|
||||
NSV8Objects::Template_Set(result, "put_GlobalAlpha", _put_GlobalAlpha);
|
||||
NSV8Objects::Template_Set(result, "Start_GlobalAlpha", _Start_GlobalAlpha);
|
||||
NSV8Objects::Template_Set(result, "End_GlobalAlpha", _End_GlobalAlpha);
|
||||
NSV8Objects::Template_Set(result, "p_color", _p_color);
|
||||
NSV8Objects::Template_Set(result, "p_width", _p_width);
|
||||
NSV8Objects::Template_Set(result, "p_dash", _p_dash);
|
||||
NSV8Objects::Template_Set(result, "b_color1", _b_color1);
|
||||
NSV8Objects::Template_Set(result, "b_color2", _b_color2);
|
||||
NSV8Objects::Template_Set(result, "transform", _transform);
|
||||
NSV8Objects::Template_Set(result, "CalculateFullTransform", _CalculateFullTransform);
|
||||
NSV8Objects::Template_Set(result, "_s", __s);
|
||||
NSV8Objects::Template_Set(result, "_e", __e);
|
||||
NSV8Objects::Template_Set(result, "_z", __z);
|
||||
NSV8Objects::Template_Set(result, "_m", __m);
|
||||
NSV8Objects::Template_Set(result, "_l", __l);
|
||||
NSV8Objects::Template_Set(result, "_c", __c);
|
||||
NSV8Objects::Template_Set(result, "_c2", __c2);
|
||||
NSV8Objects::Template_Set(result, "ds", _ds);
|
||||
NSV8Objects::Template_Set(result, "df", _df);
|
||||
NSV8Objects::Template_Set(result, "save", _save);
|
||||
NSV8Objects::Template_Set(result, "restore", _restore);
|
||||
NSV8Objects::Template_Set(result, "clip", _clip);
|
||||
NSV8Objects::Template_Set(result, "reset", _reset);
|
||||
NSV8Objects::Template_Set(result, "FreeFont", _FreeFont);
|
||||
NSV8Objects::Template_Set(result, "ClearLastFont", _ClearLastFont);
|
||||
NSV8Objects::Template_Set(result, "drawImage2", _drawImage2);
|
||||
NSV8Objects::Template_Set(result, "drawImage", _drawImage);
|
||||
NSV8Objects::Template_Set(result, "GetFont", _GetFont);
|
||||
NSV8Objects::Template_Set(result, "font", _font);
|
||||
NSV8Objects::Template_Set(result, "SetFont", _SetFont);
|
||||
NSV8Objects::Template_Set(result, "GetTextPr", _GetTextPr);
|
||||
NSV8Objects::Template_Set(result, "FillText", _FillText);
|
||||
NSV8Objects::Template_Set(result, "t", _t);
|
||||
NSV8Objects::Template_Set(result, "FillText2", _FillText2);
|
||||
NSV8Objects::Template_Set(result, "t2", _t2);
|
||||
NSV8Objects::Template_Set(result, "FillTextCode", _FillTextCode);
|
||||
NSV8Objects::Template_Set(result, "tg", _tg);
|
||||
NSV8Objects::Template_Set(result, "charspace", _charspace);
|
||||
NSV8Objects::Template_Set(result, "private_FillGlyph", _private_FillGlyph);
|
||||
NSV8Objects::Template_Set(result, "private_FillGlyphC", _private_FillGlyphC);
|
||||
NSV8Objects::Template_Set(result, "private_FillGlyph2", _private_FillGlyph2);
|
||||
NSV8Objects::Template_Set(result, "SetIntegerGrid", _SetIntegerGrid);
|
||||
NSV8Objects::Template_Set(result, "GetIntegerGrid", _GetIntegerGrid);
|
||||
NSV8Objects::Template_Set(result, "DrawStringASCII", _DrawStringASCII);
|
||||
NSV8Objects::Template_Set(result, "DrawStringASCII2", _DrawStringASCII2);
|
||||
NSV8Objects::Template_Set(result, "DrawHeaderEdit", _DrawHeaderEdit);
|
||||
NSV8Objects::Template_Set(result, "DrawFooterEdit", _DrawFooterEdit);
|
||||
NSV8Objects::Template_Set(result, "DrawLockParagraph", _DrawLockParagraph);
|
||||
NSV8Objects::Template_Set(result, "DrawLockObjectRect", _DrawLockObjectRect);
|
||||
NSV8Objects::Template_Set(result, "DrawEmptyTableLine", _DrawEmptyTableLine);
|
||||
NSV8Objects::Template_Set(result, "DrawSpellingLine", _DrawSpellingLine);
|
||||
NSV8Objects::Template_Set(result, "drawHorLine", _drawHorLine);
|
||||
NSV8Objects::Template_Set(result, "drawHorLine2", _drawHorLine2);
|
||||
NSV8Objects::Template_Set(result, "drawVerLine", _drawVerLine);
|
||||
NSV8Objects::Template_Set(result, "drawHorLineExt", _drawHorLineExt);
|
||||
NSV8Objects::Template_Set(result, "rect", _rect);
|
||||
NSV8Objects::Template_Set(result, "TableRect", _TableRect);
|
||||
NSV8Objects::Template_Set(result, "AddClipRect", _AddClipRect);
|
||||
NSV8Objects::Template_Set(result, "RemoveClipRect", _RemoveClipRect);
|
||||
NSV8Objects::Template_Set(result, "SetClip", _SetClip);
|
||||
NSV8Objects::Template_Set(result, "RemoveClip", _RemoveClip);
|
||||
NSV8Objects::Template_Set(result, "drawMailMergeField", _drawMailMergeField);
|
||||
NSV8Objects::Template_Set(result, "drawSearchResult", _drawSearchResult);
|
||||
NSV8Objects::Template_Set(result, "drawFlowAnchor", _drawFlowAnchor);
|
||||
NSV8Objects::Template_Set(result, "SavePen", _SavePen);
|
||||
NSV8Objects::Template_Set(result, "RestorePen", _RestorePen);
|
||||
NSV8Objects::Template_Set(result, "SaveBrush", _SaveBrush);
|
||||
NSV8Objects::Template_Set(result, "RestoreBrush", _RestoreBrush);
|
||||
NSV8Objects::Template_Set(result, "SavePenBrush", _SavePenBrush);
|
||||
NSV8Objects::Template_Set(result, "RestorePenBrush", _RestorePenBrush);
|
||||
NSV8Objects::Template_Set(result, "SaveGrState", _SaveGrState);
|
||||
NSV8Objects::Template_Set(result, "RestoreGrState", _RestoreGrState);
|
||||
NSV8Objects::Template_Set(result, "StartClipPath", _StartClipPath);
|
||||
NSV8Objects::Template_Set(result, "EndClipPath", _EndClipPath);
|
||||
NSV8Objects::Template_Set(result, "StartCheckTableDraw", _StartCheckTableDraw);
|
||||
NSV8Objects::Template_Set(result, "SetTextClipRect", _SetTextClipRect);
|
||||
NSV8Objects::Template_Set(result, "AddSmartRect", _AddSmartRect);
|
||||
NSV8Objects::Template_Set(result, "CheckUseFonts2", _CheckUseFonts2);
|
||||
NSV8Objects::Template_Set(result, "UncheckUseFonts2", _UncheckUseFonts2);
|
||||
NSV8Objects::Template_Set(result, "Drawing_StartCheckBounds", _Drawing_StartCheckBounds);
|
||||
NSV8Objects::Template_Set(result, "Drawing_EndCheckBounds", _Drawing_EndCheckBounds);
|
||||
NSV8Objects::Template_Set(result, "DrawPresentationComment", _DrawPresentationComment);
|
||||
NSV8Objects::Template_Set(result, "DrawPolygon", _DrawPolygon);
|
||||
NSV8Objects::Template_Set(result, "DrawFootnoteRect", _DrawFootnoteRect);
|
||||
NSV8Objects::Template_Set(result, "toDataURL", _toDataURL);
|
||||
NSV8Objects::Template_Set(result, "GetPenColor", _GetPenColor);
|
||||
NSV8Objects::Template_Set(result, "GetBrushColor", _GetBrushColor);
|
||||
NSV8Objects::Template_Set(result, "put_brushTexture", _put_brushTexture);
|
||||
NSV8Objects::Template_Set(result, "put_brushTextureMode", _put_brushTextureMode);
|
||||
NSV8Objects::Template_Set(result, "put_BrushTextureAlpha", _put_BrushTextureAlpha);
|
||||
NSV8Objects::Template_Set(result, "put_BrushGradient", _put_BrushGradient);
|
||||
NSV8Objects::Template_Set(result, "TransformPointX", _TransformPointX);
|
||||
NSV8Objects::Template_Set(result, "TransformPointY", _TransformPointY);
|
||||
NSV8Objects::Template_Set(result, "put_LineJoin", _put_LineJoin);
|
||||
NSV8Objects::Template_Set(result, "get_LineJoin", _get_LineJoin);
|
||||
NSV8Objects::Template_Set(result, "put_TextureBounds", _put_TextureBounds);
|
||||
NSV8Objects::Template_Set(result, "GetlineWidth", _GetlineWidth);
|
||||
NSV8Objects::Template_Set(result, "DrawPath", _DrawPath);
|
||||
NSV8Objects::Template_Set(result, "CoordTransformOffset", _CoordTransformOffset);
|
||||
NSV8Objects::Template_Set(result, "GetTransform", _GetTransform);
|
||||
// методы
|
||||
NSV8Objects::Template_Set(result, "create", _init);
|
||||
NSV8Objects::Template_Set(result, "Destroy", _destroy);
|
||||
NSV8Objects::Template_Set(result, "EndDraw", _EndDraw);
|
||||
NSV8Objects::Template_Set(result, "put_GlobalAlpha", _put_GlobalAlpha);
|
||||
NSV8Objects::Template_Set(result, "Start_GlobalAlpha", _Start_GlobalAlpha);
|
||||
NSV8Objects::Template_Set(result, "End_GlobalAlpha", _End_GlobalAlpha);
|
||||
NSV8Objects::Template_Set(result, "p_color", _p_color);
|
||||
NSV8Objects::Template_Set(result, "p_width", _p_width);
|
||||
NSV8Objects::Template_Set(result, "p_dash", _p_dash);
|
||||
NSV8Objects::Template_Set(result, "b_color1", _b_color1);
|
||||
NSV8Objects::Template_Set(result, "b_color2", _b_color2);
|
||||
NSV8Objects::Template_Set(result, "transform", _transform);
|
||||
NSV8Objects::Template_Set(result, "CalculateFullTransform", _CalculateFullTransform);
|
||||
NSV8Objects::Template_Set(result, "_s", __s);
|
||||
NSV8Objects::Template_Set(result, "_e", __e);
|
||||
NSV8Objects::Template_Set(result, "_z", __z);
|
||||
NSV8Objects::Template_Set(result, "_m", __m);
|
||||
NSV8Objects::Template_Set(result, "_l", __l);
|
||||
NSV8Objects::Template_Set(result, "_c", __c);
|
||||
NSV8Objects::Template_Set(result, "_c2", __c2);
|
||||
NSV8Objects::Template_Set(result, "ds", _ds);
|
||||
NSV8Objects::Template_Set(result, "df", _df);
|
||||
NSV8Objects::Template_Set(result, "save", _save);
|
||||
NSV8Objects::Template_Set(result, "restore", _restore);
|
||||
NSV8Objects::Template_Set(result, "clip", _clip);
|
||||
NSV8Objects::Template_Set(result, "reset", _reset);
|
||||
NSV8Objects::Template_Set(result, "FreeFont", _FreeFont);
|
||||
NSV8Objects::Template_Set(result, "ClearLastFont", _ClearLastFont);
|
||||
NSV8Objects::Template_Set(result, "drawImage2", _drawImage2);
|
||||
NSV8Objects::Template_Set(result, "drawImage", _drawImage);
|
||||
NSV8Objects::Template_Set(result, "GetFont", _GetFont);
|
||||
NSV8Objects::Template_Set(result, "font", _font);
|
||||
NSV8Objects::Template_Set(result, "SetFont", _SetFont);
|
||||
NSV8Objects::Template_Set(result, "GetTextPr", _GetTextPr);
|
||||
NSV8Objects::Template_Set(result, "FillText", _FillText);
|
||||
NSV8Objects::Template_Set(result, "t", _t);
|
||||
NSV8Objects::Template_Set(result, "FillText2", _FillText2);
|
||||
NSV8Objects::Template_Set(result, "t2", _t2);
|
||||
NSV8Objects::Template_Set(result, "FillTextCode", _FillTextCode);
|
||||
NSV8Objects::Template_Set(result, "tg", _tg);
|
||||
NSV8Objects::Template_Set(result, "charspace", _charspace);
|
||||
NSV8Objects::Template_Set(result, "private_FillGlyph", _private_FillGlyph);
|
||||
NSV8Objects::Template_Set(result, "private_FillGlyphC", _private_FillGlyphC);
|
||||
NSV8Objects::Template_Set(result, "private_FillGlyph2", _private_FillGlyph2);
|
||||
NSV8Objects::Template_Set(result, "SetIntegerGrid", _SetIntegerGrid);
|
||||
NSV8Objects::Template_Set(result, "GetIntegerGrid", _GetIntegerGrid);
|
||||
NSV8Objects::Template_Set(result, "DrawStringASCII", _DrawStringASCII);
|
||||
NSV8Objects::Template_Set(result, "DrawStringASCII2", _DrawStringASCII2);
|
||||
NSV8Objects::Template_Set(result, "DrawHeaderEdit", _DrawHeaderEdit);
|
||||
NSV8Objects::Template_Set(result, "DrawFooterEdit", _DrawFooterEdit);
|
||||
NSV8Objects::Template_Set(result, "DrawLockParagraph", _DrawLockParagraph);
|
||||
NSV8Objects::Template_Set(result, "DrawLockObjectRect", _DrawLockObjectRect);
|
||||
NSV8Objects::Template_Set(result, "DrawEmptyTableLine", _DrawEmptyTableLine);
|
||||
NSV8Objects::Template_Set(result, "DrawSpellingLine", _DrawSpellingLine);
|
||||
NSV8Objects::Template_Set(result, "drawHorLine", _drawHorLine);
|
||||
NSV8Objects::Template_Set(result, "drawHorLine2", _drawHorLine2);
|
||||
NSV8Objects::Template_Set(result, "drawVerLine", _drawVerLine);
|
||||
NSV8Objects::Template_Set(result, "drawHorLineExt", _drawHorLineExt);
|
||||
NSV8Objects::Template_Set(result, "rect", _rect);
|
||||
NSV8Objects::Template_Set(result, "TableRect", _TableRect);
|
||||
NSV8Objects::Template_Set(result, "AddClipRect", _AddClipRect);
|
||||
NSV8Objects::Template_Set(result, "RemoveClipRect", _RemoveClipRect);
|
||||
NSV8Objects::Template_Set(result, "SetClip", _SetClip);
|
||||
NSV8Objects::Template_Set(result, "RemoveClip", _RemoveClip);
|
||||
NSV8Objects::Template_Set(result, "drawMailMergeField", _drawMailMergeField);
|
||||
NSV8Objects::Template_Set(result, "drawSearchResult", _drawSearchResult);
|
||||
NSV8Objects::Template_Set(result, "drawFlowAnchor", _drawFlowAnchor);
|
||||
NSV8Objects::Template_Set(result, "SavePen", _SavePen);
|
||||
NSV8Objects::Template_Set(result, "RestorePen", _RestorePen);
|
||||
NSV8Objects::Template_Set(result, "SaveBrush", _SaveBrush);
|
||||
NSV8Objects::Template_Set(result, "RestoreBrush", _RestoreBrush);
|
||||
NSV8Objects::Template_Set(result, "SavePenBrush", _SavePenBrush);
|
||||
NSV8Objects::Template_Set(result, "RestorePenBrush", _RestorePenBrush);
|
||||
NSV8Objects::Template_Set(result, "SaveGrState", _SaveGrState);
|
||||
NSV8Objects::Template_Set(result, "RestoreGrState", _RestoreGrState);
|
||||
NSV8Objects::Template_Set(result, "StartClipPath", _StartClipPath);
|
||||
NSV8Objects::Template_Set(result, "EndClipPath", _EndClipPath);
|
||||
NSV8Objects::Template_Set(result, "StartCheckTableDraw", _StartCheckTableDraw);
|
||||
NSV8Objects::Template_Set(result, "SetTextClipRect", _SetTextClipRect);
|
||||
NSV8Objects::Template_Set(result, "AddSmartRect", _AddSmartRect);
|
||||
NSV8Objects::Template_Set(result, "CheckUseFonts2", _CheckUseFonts2);
|
||||
NSV8Objects::Template_Set(result, "UncheckUseFonts2", _UncheckUseFonts2);
|
||||
NSV8Objects::Template_Set(result, "Drawing_StartCheckBounds", _Drawing_StartCheckBounds);
|
||||
NSV8Objects::Template_Set(result, "Drawing_EndCheckBounds", _Drawing_EndCheckBounds);
|
||||
NSV8Objects::Template_Set(result, "DrawPresentationComment", _DrawPresentationComment);
|
||||
NSV8Objects::Template_Set(result, "DrawPolygon", _DrawPolygon);
|
||||
NSV8Objects::Template_Set(result, "DrawFootnoteRect", _DrawFootnoteRect);
|
||||
NSV8Objects::Template_Set(result, "toDataURL", _toDataURL);
|
||||
NSV8Objects::Template_Set(result, "GetPenColor", _GetPenColor);
|
||||
NSV8Objects::Template_Set(result, "GetBrushColor", _GetBrushColor);
|
||||
NSV8Objects::Template_Set(result, "put_brushTexture", _put_brushTexture);
|
||||
NSV8Objects::Template_Set(result, "put_brushTextureMode", _put_brushTextureMode);
|
||||
NSV8Objects::Template_Set(result, "put_BrushTextureAlpha", _put_BrushTextureAlpha);
|
||||
NSV8Objects::Template_Set(result, "put_BrushGradient", _put_BrushGradient);
|
||||
NSV8Objects::Template_Set(result, "TransformPointX", _TransformPointX);
|
||||
NSV8Objects::Template_Set(result, "TransformPointY", _TransformPointY);
|
||||
NSV8Objects::Template_Set(result, "put_LineJoin", _put_LineJoin);
|
||||
NSV8Objects::Template_Set(result, "get_LineJoin", _get_LineJoin);
|
||||
NSV8Objects::Template_Set(result, "put_TextureBounds", _put_TextureBounds);
|
||||
NSV8Objects::Template_Set(result, "GetlineWidth", _GetlineWidth);
|
||||
NSV8Objects::Template_Set(result, "DrawPath", _DrawPath);
|
||||
NSV8Objects::Template_Set(result, "CoordTransformOffset", _CoordTransformOffset);
|
||||
NSV8Objects::Template_Set(result, "GetTransform", _GetTransform);
|
||||
|
||||
return handle_scope.Escape(result);
|
||||
}
|
||||
return handle_scope.Escape(result);
|
||||
}
|
||||
|
||||
void CreateNativeGraphics(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
{
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
|
||||
v8::Handle<v8::ObjectTemplate> GraphicsTemplate = NSGraphics::CreateGraphicsTemplate(isolate);
|
||||
CGraphicsEmbed* pGraphics = new CGraphicsEmbed();
|
||||
|
||||
v8::Local<v8::Object> obj = GraphicsTemplate->NewInstance(isolate->GetCurrentContext()).ToLocalChecked();
|
||||
obj->SetInternalField(0, v8::External::New(CV8Worker::GetCurrent(), pGraphics));
|
||||
|
||||
NSJSBase::CJSEmbedObjectPrivate::CreateWeaker(obj);
|
||||
|
||||
args.GetReturnValue().Set(obj);
|
||||
}
|
||||
void CreateNativeGraphics(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
{
|
||||
CreateNativeInternalField(new CGraphicsEmbed(), NSGraphics::CreateGraphicsTemplate, args);
|
||||
}
|
||||
}
|
||||
|
||||
void CGraphicsEmbed::CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context)
|
||||
{
|
||||
v8::Isolate* current = CV8Worker::GetCurrent();
|
||||
context->m_internal->m_global->Set(current, name.c_str(), v8::FunctionTemplate::New(current, NSGraphics::CreateNativeGraphics));
|
||||
InsertToGlobal(name, context, NSGraphics::CreateNativeGraphics);
|
||||
}
|
||||
|
||||
34
DesktopEditor/doctrenderer/embed/v8/v8_Hash.cpp
Normal file
34
DesktopEditor/doctrenderer/embed/v8/v8_Hash.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include "../HashEmbed.h"
|
||||
#include "../../js_internal/v8/v8_base.h"
|
||||
|
||||
namespace NSHash
|
||||
{
|
||||
#define CURRENTWRAPPER CHashEmbed
|
||||
|
||||
FUNCTION_WRAPPER_V8_3(_hash, hash)
|
||||
FUNCTION_WRAPPER_V8_4(_hash2, hash2)
|
||||
|
||||
v8::Handle<v8::ObjectTemplate> CreateHashTemplate(v8::Isolate* isolate)
|
||||
{
|
||||
v8::EscapableHandleScope handle_scope(isolate);
|
||||
|
||||
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New(isolate);
|
||||
result->SetInternalFieldCount(1);
|
||||
|
||||
// methods
|
||||
NSV8Objects::Template_Set(result, "hash", _hash);
|
||||
NSV8Objects::Template_Set(result, "hash2", _hash2);
|
||||
|
||||
return handle_scope.Escape(result);
|
||||
}
|
||||
|
||||
void CreateNativeHash(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
{
|
||||
CreateNativeInternalField(new CHashEmbed(), NSHash::CreateHashTemplate, args);
|
||||
}
|
||||
}
|
||||
|
||||
void CHashEmbed::CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context)
|
||||
{
|
||||
InsertToGlobal(name, context, NSHash::CreateNativeHash);
|
||||
}
|
||||
@ -3,68 +3,56 @@
|
||||
|
||||
namespace NSMemoryStream
|
||||
{
|
||||
#define CURRENTWRAPPER CMemoryStreamEmbed
|
||||
#define CURRENTWRAPPER CMemoryStreamEmbed
|
||||
|
||||
FUNCTION_WRAPPER_V8_1(_ms_write_byte, WriteByte)
|
||||
FUNCTION_WRAPPER_V8_1(_ms_write_bool, WriteBool)
|
||||
FUNCTION_WRAPPER_V8_1(_ms_write_long, WriteLong)
|
||||
FUNCTION_WRAPPER_V8_1(_ms_write_double, WriteDouble)
|
||||
FUNCTION_WRAPPER_V8_1(_ms_write_double2, WriteDouble2)
|
||||
FUNCTION_WRAPPER_V8_1(_ms_writestringA, WriteStringA)
|
||||
FUNCTION_WRAPPER_V8_1(_ms_writestring1, WriteString)
|
||||
FUNCTION_WRAPPER_V8_1(_ms_writestring2, WriteString2)
|
||||
FUNCTION_WRAPPER_V8_3(_ms_copy, Copy)
|
||||
FUNCTION_WRAPPER_V8(_ms_clearnoattack, ClearNoAttack)
|
||||
FUNCTION_WRAPPER_V8_1(_ms_write_byte, WriteByte)
|
||||
FUNCTION_WRAPPER_V8_1(_ms_write_bool, WriteBool)
|
||||
FUNCTION_WRAPPER_V8_1(_ms_write_long, WriteLong)
|
||||
FUNCTION_WRAPPER_V8_1(_ms_write_double, WriteDouble)
|
||||
FUNCTION_WRAPPER_V8_1(_ms_write_double2, WriteDouble2)
|
||||
FUNCTION_WRAPPER_V8_1(_ms_writestringA, WriteStringA)
|
||||
FUNCTION_WRAPPER_V8_1(_ms_writestring1, WriteString)
|
||||
FUNCTION_WRAPPER_V8_1(_ms_writestring2, WriteString2)
|
||||
FUNCTION_WRAPPER_V8_3(_ms_copy, Copy)
|
||||
FUNCTION_WRAPPER_V8(_ms_clearnoattack, ClearNoAttack)
|
||||
|
||||
void _ms_pos(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& args)
|
||||
{
|
||||
CMemoryStreamEmbed* _this = (CMemoryStreamEmbed*)unwrap_native(args.This());
|
||||
args.GetReturnValue().Set(v8::Integer::New(CV8Worker::GetCurrent(), _this->m_pInternal->GetSize()));
|
||||
}
|
||||
void _ms_pos(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& args)
|
||||
{
|
||||
CMemoryStreamEmbed* _this = (CMemoryStreamEmbed*)unwrap_native(args.This());
|
||||
args.GetReturnValue().Set(v8::Integer::New(CV8Worker::GetCurrent(), _this->m_pInternal->GetSize()));
|
||||
}
|
||||
|
||||
v8::Handle<v8::ObjectTemplate> CreateMemoryStreamTemplate(v8::Isolate* isolate)
|
||||
{
|
||||
v8::EscapableHandleScope handle_scope(isolate);
|
||||
v8::Handle<v8::ObjectTemplate> CreateMemoryStreamTemplate(v8::Isolate* isolate)
|
||||
{
|
||||
v8::EscapableHandleScope handle_scope(isolate);
|
||||
|
||||
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New(V8IsolateOneArg);
|
||||
result->SetInternalFieldCount(1);
|
||||
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New(V8IsolateOneArg);
|
||||
result->SetInternalFieldCount(1);
|
||||
|
||||
// property
|
||||
result->SetAccessor(CreateV8String(CV8Worker::GetCurrent(), "pos"), _ms_pos);
|
||||
// property
|
||||
result->SetAccessor(CreateV8String(CV8Worker::GetCurrent(), "pos"), _ms_pos);
|
||||
|
||||
NSV8Objects::Template_Set(result, "Copy", _ms_copy);
|
||||
NSV8Objects::Template_Set(result, "ClearNoAttack", _ms_clearnoattack);
|
||||
NSV8Objects::Template_Set(result, "WriteByte", _ms_write_byte);
|
||||
NSV8Objects::Template_Set(result, "WriteBool", _ms_write_bool);
|
||||
NSV8Objects::Template_Set(result, "WriteLong", _ms_write_long);
|
||||
NSV8Objects::Template_Set(result, "WriteDouble", _ms_write_double);
|
||||
NSV8Objects::Template_Set(result, "WriteDouble2", _ms_write_double2);
|
||||
NSV8Objects::Template_Set(result, "WriteStringA", _ms_writestringA);
|
||||
NSV8Objects::Template_Set(result, "WriteString", _ms_writestring1);
|
||||
NSV8Objects::Template_Set(result, "WriteString2", _ms_writestring2);
|
||||
NSV8Objects::Template_Set(result, "Copy", _ms_copy);
|
||||
NSV8Objects::Template_Set(result, "ClearNoAttack", _ms_clearnoattack);
|
||||
NSV8Objects::Template_Set(result, "WriteByte", _ms_write_byte);
|
||||
NSV8Objects::Template_Set(result, "WriteBool", _ms_write_bool);
|
||||
NSV8Objects::Template_Set(result, "WriteLong", _ms_write_long);
|
||||
NSV8Objects::Template_Set(result, "WriteDouble", _ms_write_double);
|
||||
NSV8Objects::Template_Set(result, "WriteDouble2", _ms_write_double2);
|
||||
NSV8Objects::Template_Set(result, "WriteStringA", _ms_writestringA);
|
||||
NSV8Objects::Template_Set(result, "WriteString", _ms_writestring1);
|
||||
NSV8Objects::Template_Set(result, "WriteString2", _ms_writestring2);
|
||||
|
||||
return handle_scope.Escape(result);
|
||||
}
|
||||
return handle_scope.Escape(result);
|
||||
}
|
||||
|
||||
void CreateNativeMemoryStream(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
{
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
|
||||
v8::Handle<v8::ObjectTemplate> MemoryObjectTemplate = NSMemoryStream::CreateMemoryStreamTemplate(isolate);
|
||||
CMemoryStreamEmbed* pMemoryObject = new CMemoryStreamEmbed();
|
||||
|
||||
v8::Local<v8::Object> obj = MemoryObjectTemplate->NewInstance(isolate->GetCurrentContext()).ToLocalChecked();
|
||||
obj->SetInternalField(0, v8::External::New(CV8Worker::GetCurrent(), pMemoryObject));
|
||||
|
||||
NSJSBase::CJSEmbedObjectPrivate::CreateWeaker(obj);
|
||||
|
||||
args.GetReturnValue().Set(obj);
|
||||
}
|
||||
}
|
||||
void CreateNativeMemoryStream(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
{
|
||||
CreateNativeInternalField(new CMemoryStreamEmbed(), NSMemoryStream::CreateMemoryStreamTemplate, args);
|
||||
}
|
||||
}
|
||||
|
||||
void CMemoryStreamEmbed::CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context)
|
||||
{
|
||||
v8::Isolate* current = CV8Worker::GetCurrent();
|
||||
context->m_internal->m_global->Set(current, name.c_str(), v8::FunctionTemplate::New(current, NSMemoryStream::CreateNativeMemoryStream));
|
||||
InsertToGlobal(name, context, NSMemoryStream::CreateNativeMemoryStream);
|
||||
}
|
||||
|
||||
@ -53,62 +53,62 @@ FUNCTION_WRAPPER_V8(_builder_doc_GetImageMap, builder_doc_GetImageMap)
|
||||
|
||||
v8::Local<v8::Value> _builder_CreateNativeTmpDoc(v8::Isolate* isolate, NSDoctRenderer::CDocBuilder* pBuilder, const std::wstring& sFile, const std::wstring& sParams)
|
||||
{
|
||||
v8::Local<v8::ObjectTemplate> _template = v8::ObjectTemplate::New(isolate);
|
||||
_template->SetInternalFieldCount(1); // отводим в нем место для хранения CNativeControl
|
||||
v8::Local<v8::ObjectTemplate> _template = v8::ObjectTemplate::New(isolate);
|
||||
_template->SetInternalFieldCount(1); // отводим в нем место для хранения CNativeControl
|
||||
|
||||
NSV8Objects::Template_Set(_template, "IsValid", _builder_doc_IsValid);
|
||||
NSV8Objects::Template_Set(_template, "GetBinary", _builder_doc_GetBinary);
|
||||
NSV8Objects::Template_Set(_template, "GetFolder", _builder_doc_GetFolder);
|
||||
NSV8Objects::Template_Set(_template, "Close", _builder_doc_CloseFile);
|
||||
NSV8Objects::Template_Set(_template, "GetImageMap", _builder_doc_GetImageMap);
|
||||
NSV8Objects::Template_Set(_template, "IsValid", _builder_doc_IsValid);
|
||||
NSV8Objects::Template_Set(_template, "GetBinary", _builder_doc_GetBinary);
|
||||
NSV8Objects::Template_Set(_template, "GetFolder", _builder_doc_GetFolder);
|
||||
NSV8Objects::Template_Set(_template, "Close", _builder_doc_CloseFile);
|
||||
NSV8Objects::Template_Set(_template, "GetImageMap", _builder_doc_GetImageMap);
|
||||
|
||||
CBuilderDocumentEmbed* _embed = new CBuilderDocumentEmbed();
|
||||
_embed->m_pBuilder = pBuilder;
|
||||
_embed->OpenFile(sFile, sParams);
|
||||
CBuilderDocumentEmbed* _embed = new CBuilderDocumentEmbed();
|
||||
_embed->m_pBuilder = pBuilder;
|
||||
_embed->OpenFile(sFile, sParams);
|
||||
|
||||
v8::Local<v8::Object> obj = _template->NewInstance(V8ContextOneArg).ToLocalChecked();
|
||||
obj->SetInternalField(0, v8::External::New(isolate, _embed));
|
||||
v8::Local<v8::Object> obj = _template->NewInstance(V8ContextOneArg).ToLocalChecked();
|
||||
obj->SetInternalField(0, v8::External::New(isolate, _embed));
|
||||
|
||||
return obj;
|
||||
return obj;
|
||||
}
|
||||
v8::Local<v8::Value> _builder_CreateNative(v8::Isolate* isolate, NSDoctRenderer::CDocBuilder* builder)
|
||||
{
|
||||
v8::Local<v8::ObjectTemplate> _template = v8::ObjectTemplate::New(isolate);
|
||||
_template->SetInternalFieldCount(1);
|
||||
v8::Local<v8::ObjectTemplate> _template = v8::ObjectTemplate::New(isolate);
|
||||
_template->SetInternalFieldCount(1);
|
||||
|
||||
NSV8Objects::Template_Set(_template, "OpenFile", _builder_OpenFile);
|
||||
NSV8Objects::Template_Set(_template, "CreateFile", _builder_CreateFile);
|
||||
NSV8Objects::Template_Set(_template, "SetTmpFolder", _builder_SetTmpFolder);
|
||||
NSV8Objects::Template_Set(_template, "SaveFile", _builder_SaveFile);
|
||||
NSV8Objects::Template_Set(_template, "CloseFile", _builder_CloseFile);
|
||||
NSV8Objects::Template_Set(_template, "OpenTmpFile", _builder_OpenTmpFile);
|
||||
NSV8Objects::Template_Set(_template, "OpenFile", _builder_OpenFile);
|
||||
NSV8Objects::Template_Set(_template, "CreateFile", _builder_CreateFile);
|
||||
NSV8Objects::Template_Set(_template, "SetTmpFolder", _builder_SetTmpFolder);
|
||||
NSV8Objects::Template_Set(_template, "SaveFile", _builder_SaveFile);
|
||||
NSV8Objects::Template_Set(_template, "CloseFile", _builder_CloseFile);
|
||||
NSV8Objects::Template_Set(_template, "OpenTmpFile", _builder_OpenTmpFile);
|
||||
|
||||
CBuilderEmbed* _embed = new CBuilderEmbed();
|
||||
_embed->m_pBuilder = builder;
|
||||
CBuilderEmbed* _embed = new CBuilderEmbed();
|
||||
_embed->m_pBuilder = builder;
|
||||
|
||||
v8::Local<v8::Object> obj = _template->NewInstance(V8ContextOneArg).ToLocalChecked();
|
||||
obj->SetInternalField(0, v8::External::New(isolate, _embed));
|
||||
v8::Local<v8::Object> obj = _template->NewInstance(V8ContextOneArg).ToLocalChecked();
|
||||
obj->SetInternalField(0, v8::External::New(isolate, _embed));
|
||||
|
||||
return obj;
|
||||
return obj;
|
||||
}
|
||||
|
||||
void builder_CreateNativeTmpDoc(const std::string& name, JSSmart<CJSContext> context, NSDoctRenderer::CDocBuilder* builder, const std::wstring& sFile, const std::wstring& sParams)
|
||||
{
|
||||
v8::Isolate* current = CV8Worker::GetCurrent();
|
||||
context->m_internal->m_context->Global()->Set(context->m_internal->m_context, CreateV8String(current, name.c_str()), _builder_CreateNativeTmpDoc(current, builder, sFile, sParams));
|
||||
v8::Isolate* current = CV8Worker::GetCurrent();
|
||||
context->m_internal->m_context->Global()->Set(context->m_internal->m_context, CreateV8String(current, name.c_str()), _builder_CreateNativeTmpDoc(current, builder, sFile, sParams));
|
||||
}
|
||||
void builder_CreateNative (const std::string& name, JSSmart<CJSContext> context, NSDoctRenderer::CDocBuilder* builder)
|
||||
{
|
||||
v8::Isolate* current = CV8Worker::GetCurrent();
|
||||
context->m_internal->m_context->Global()->Set(context->m_internal->m_context, CreateV8String(current, name.c_str()), _builder_CreateNative(current, builder));
|
||||
v8::Isolate* current = CV8Worker::GetCurrent();
|
||||
context->m_internal->m_context->Global()->Set(context->m_internal->m_context, CreateV8String(current, name.c_str()), _builder_CreateNative(current, builder));
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CBuilderEmbed::builder_OpenTmpFile(JSSmart<CJSValue> path, JSSmart<CJSValue> params)
|
||||
{
|
||||
std::wstring sPath = path->toStringW();
|
||||
std::wstring sParams = params->toStringW();
|
||||
v8::Local<v8::Value> obj = _builder_CreateNativeTmpDoc(CV8Worker::GetCurrent(), m_pBuilder, sPath, sParams);
|
||||
CJSValueV8* res = new CJSValueV8();
|
||||
res->value = obj;
|
||||
return res;
|
||||
std::wstring sPath = path->toStringW();
|
||||
std::wstring sParams = params->toStringW();
|
||||
v8::Local<v8::Value> obj = _builder_CreateNativeTmpDoc(CV8Worker::GetCurrent(), m_pBuilder, sPath, sParams);
|
||||
CJSValueV8* res = new CJSValueV8();
|
||||
res->value = obj;
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -108,54 +108,22 @@ namespace NSNativeControl
|
||||
|
||||
void CreateNativeObject(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
{
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
|
||||
if (CIsolateAdditionalData::CheckSingletonType(isolate, CIsolateAdditionalData::iadtSingletonNative))
|
||||
{
|
||||
args.GetReturnValue().Set(v8::Undefined(isolate));
|
||||
return;
|
||||
}
|
||||
|
||||
v8::Handle<v8::ObjectTemplate> NativeObjectTemplate = CreateNativeControlTemplate(isolate);
|
||||
CNativeControlEmbed* pNativeObject = new CNativeControlEmbed();
|
||||
|
||||
v8::Local<v8::Object> obj = NativeObjectTemplate->NewInstance(isolate->GetCurrentContext()).ToLocalChecked();
|
||||
obj->SetInternalField(0, v8::External::New(CV8Worker::GetCurrent(), pNativeObject));
|
||||
|
||||
args.GetReturnValue().Set(obj);
|
||||
CreateNativeInternalField(new CNativeControlEmbed(), CreateNativeControlTemplate, args, CIsolateAdditionalData::iadtSingletonNative);
|
||||
}
|
||||
|
||||
// Без SaveChanges
|
||||
void CreateNativeObjectBuilder(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
{
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
|
||||
if (CIsolateAdditionalData::CheckSingletonType(isolate, CIsolateAdditionalData::iadtSingletonNative))
|
||||
{
|
||||
args.GetReturnValue().Set(v8::Undefined(isolate));
|
||||
return;
|
||||
}
|
||||
|
||||
v8::Handle<v8::ObjectTemplate> NativeObjectTemplate = CreateNativeControlTemplateBuilder(isolate);
|
||||
CNativeControlEmbed* pNativeObject = new CNativeControlEmbed();
|
||||
|
||||
v8::Local<v8::Object> obj = NativeObjectTemplate->NewInstance(isolate->GetCurrentContext()).ToLocalChecked();
|
||||
obj->SetInternalField(0, v8::External::New(CV8Worker::GetCurrent(), pNativeObject));
|
||||
|
||||
args.GetReturnValue().Set(obj);
|
||||
CreateNativeInternalField(new CNativeControlEmbed(), CreateNativeControlTemplateBuilder, args, CIsolateAdditionalData::iadtSingletonNative);
|
||||
}
|
||||
}
|
||||
|
||||
void CNativeControlEmbed::CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context)
|
||||
{
|
||||
v8::Isolate* current = CV8Worker::GetCurrent();
|
||||
context->m_internal->m_global->Set(current, name.c_str(), v8::FunctionTemplate::New(current, NSNativeControl::CreateNativeObject));
|
||||
InsertToGlobal(name, context, NSNativeControl::CreateNativeObject);
|
||||
}
|
||||
|
||||
void CNativeControlEmbed::CreateObjectBuilderInContext(const std::string& name, JSSmart<CJSContext> context)
|
||||
{
|
||||
v8::Isolate* current = CV8Worker::GetCurrent();
|
||||
context->m_internal->m_global->Set(current, name.c_str(), v8::FunctionTemplate::New(current, NSNativeControl::CreateNativeObjectBuilder));
|
||||
InsertToGlobal(name, context, NSNativeControl::CreateNativeObjectBuilder);
|
||||
}
|
||||
|
||||
@ -3,30 +3,30 @@
|
||||
|
||||
v8::Handle<v8::ObjectTemplate> CreatePointerTemplate(v8::Isolate* isolate)
|
||||
{
|
||||
v8::EscapableHandleScope handle_scope(isolate);
|
||||
v8::EscapableHandleScope handle_scope(isolate);
|
||||
|
||||
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New(isolate);
|
||||
result->SetInternalFieldCount(1);
|
||||
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New(isolate);
|
||||
result->SetInternalFieldCount(1);
|
||||
|
||||
return handle_scope.Escape(result);
|
||||
return handle_scope.Escape(result);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CPointerEmbedObject::createObject()
|
||||
{
|
||||
v8::Isolate* isolate = CV8Worker::GetCurrent();
|
||||
//v8::HandleScope scope(isolate);
|
||||
v8::Isolate* isolate = CV8Worker::GetCurrent();
|
||||
//v8::HandleScope scope(isolate);
|
||||
|
||||
v8::Handle<v8::ObjectTemplate> pointerTemplate = v8::ObjectTemplate::New(isolate);
|
||||
pointerTemplate->SetInternalFieldCount(1);
|
||||
v8::Handle<v8::ObjectTemplate> pointerTemplate = v8::ObjectTemplate::New(isolate);
|
||||
pointerTemplate->SetInternalFieldCount(1);
|
||||
|
||||
v8::Local<v8::Object> obj = pointerTemplate->NewInstance(isolate->GetCurrentContext()).ToLocalChecked();
|
||||
obj->SetInternalField(0, v8::External::New(CV8Worker::GetCurrent(), this));
|
||||
v8::Local<v8::Object> obj = pointerTemplate->NewInstance(isolate->GetCurrentContext()).ToLocalChecked();
|
||||
obj->SetInternalField(0, v8::External::New(CV8Worker::GetCurrent(), this));
|
||||
|
||||
NSJSBase::CJSEmbedObjectPrivate::CreateWeaker(obj);
|
||||
NSJSBase::CJSEmbedObjectPrivate::CreateWeaker(obj);
|
||||
|
||||
CJSValueV8* returnValue = new CJSValueV8();
|
||||
returnValue->value = obj;
|
||||
CJSValueV8* returnValue = new CJSValueV8();
|
||||
returnValue->value = obj;
|
||||
|
||||
JSSmart<CJSValue> ret = returnValue;
|
||||
return ret;
|
||||
JSSmart<CJSValue> ret = returnValue;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -3,94 +3,82 @@
|
||||
|
||||
namespace NSMeasurer
|
||||
{
|
||||
#define CURRENTWRAPPER CTextMeasurerEmbed
|
||||
#define CURRENTWRAPPER CTextMeasurerEmbed
|
||||
|
||||
FUNCTION_WRAPPER_V8_1(_FT_Malloc, FT_Malloc)
|
||||
FUNCTION_WRAPPER_V8_1(_FT_Free, FT_Free)
|
||||
FUNCTION_WRAPPER_V8_1(_FT_Malloc, FT_Malloc)
|
||||
FUNCTION_WRAPPER_V8_1(_FT_Free, FT_Free)
|
||||
|
||||
FUNCTION_WRAPPER_V8 (_FT_Init, FT_Init)
|
||||
FUNCTION_WRAPPER_V8_2(_FT_Set_TrueType_HintProp, FT_Set_TrueType_HintProp)
|
||||
FUNCTION_WRAPPER_V8 (_FT_Init, FT_Init)
|
||||
FUNCTION_WRAPPER_V8_2(_FT_Set_TrueType_HintProp, FT_Set_TrueType_HintProp)
|
||||
|
||||
FUNCTION_WRAPPER_V8_4(_FT_Open_Face, FT_Open_Face)
|
||||
FUNCTION_WRAPPER_V8_3(_FT_Open_Face2, FT_Open_Face2)
|
||||
FUNCTION_WRAPPER_V8_1(_FT_GetFaceInfo, FT_GetFaceInfo)
|
||||
FUNCTION_WRAPPER_V8_4(_FT_Open_Face, FT_Open_Face)
|
||||
FUNCTION_WRAPPER_V8_3(_FT_Open_Face2, FT_Open_Face2)
|
||||
FUNCTION_WRAPPER_V8_1(_FT_GetFaceInfo, FT_GetFaceInfo)
|
||||
|
||||
FUNCTION_WRAPPER_V8_3(_FT_Load_Glyph, FT_Load_Glyph)
|
||||
FUNCTION_WRAPPER_V8_2(_FT_Get_Glyph_Measure_Params, FT_Get_Glyph_Measure_Params)
|
||||
FUNCTION_WRAPPER_V8_2(_FT_Get_Glyph_Render_Params, FT_Get_Glyph_Render_Params)
|
||||
FUNCTION_WRAPPER_V8_2(_FT_Get_Glyph_Render_Buffer, FT_Get_Glyph_Render_Buffer)
|
||||
FUNCTION_WRAPPER_V8_3(_FT_Load_Glyph, FT_Load_Glyph)
|
||||
FUNCTION_WRAPPER_V8_2(_FT_Get_Glyph_Measure_Params, FT_Get_Glyph_Measure_Params)
|
||||
FUNCTION_WRAPPER_V8_2(_FT_Get_Glyph_Render_Params, FT_Get_Glyph_Render_Params)
|
||||
FUNCTION_WRAPPER_V8_2(_FT_Get_Glyph_Render_Buffer, FT_Get_Glyph_Render_Buffer)
|
||||
|
||||
FUNCTION_WRAPPER_V8_5(_FT_Set_Transform, FT_Set_Transform)
|
||||
FUNCTION_WRAPPER_V8_5(_FT_Set_Char_Size, FT_Set_Char_Size)
|
||||
FUNCTION_WRAPPER_V8_2(_FT_SetCMapForCharCode, FT_SetCMapForCharCode)
|
||||
FUNCTION_WRAPPER_V8_3(_FT_GetKerningX, FT_GetKerningX)
|
||||
FUNCTION_WRAPPER_V8_1(_FT_GetFaceMaxAdvanceX, FT_GetFaceMaxAdvanceX)
|
||||
FUNCTION_WRAPPER_V8_5(_FT_Set_Transform, FT_Set_Transform)
|
||||
FUNCTION_WRAPPER_V8_5(_FT_Set_Char_Size, FT_Set_Char_Size)
|
||||
FUNCTION_WRAPPER_V8_2(_FT_SetCMapForCharCode, FT_SetCMapForCharCode)
|
||||
FUNCTION_WRAPPER_V8_3(_FT_GetKerningX, FT_GetKerningX)
|
||||
FUNCTION_WRAPPER_V8_1(_FT_GetFaceMaxAdvanceX, FT_GetFaceMaxAdvanceX)
|
||||
|
||||
#ifdef SUPPORT_HARFBUZZ_SHAPER
|
||||
FUNCTION_WRAPPER_V8_1(_HB_LanguageFromString, HB_LanguageFromString)
|
||||
FUNCTION_WRAPPER_V8_7(_HB_ShapeText, HB_ShapeText)
|
||||
FUNCTION_WRAPPER_V8 (_HB_FontMalloc, HB_FontMalloc)
|
||||
FUNCTION_WRAPPER_V8_1(_HB_FontFree, HB_FontFree)
|
||||
FUNCTION_WRAPPER_V8_1(_HB_LanguageFromString, HB_LanguageFromString)
|
||||
FUNCTION_WRAPPER_V8_7(_HB_ShapeText, HB_ShapeText)
|
||||
FUNCTION_WRAPPER_V8 (_HB_FontMalloc, HB_FontMalloc)
|
||||
FUNCTION_WRAPPER_V8_1(_HB_FontFree, HB_FontFree)
|
||||
#endif
|
||||
|
||||
v8::Handle<v8::ObjectTemplate> CreateMeasurerTemplate(v8::Isolate* isolate)
|
||||
{
|
||||
v8::EscapableHandleScope handle_scope(isolate);
|
||||
v8::Handle<v8::ObjectTemplate> CreateMeasurerTemplate(v8::Isolate* isolate)
|
||||
{
|
||||
v8::EscapableHandleScope handle_scope(isolate);
|
||||
|
||||
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New(isolate);
|
||||
result->SetInternalFieldCount(1);
|
||||
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New(isolate);
|
||||
result->SetInternalFieldCount(1);
|
||||
|
||||
// методы
|
||||
NSV8Objects::Template_Set(result, "FT_Malloc", _FT_Malloc);
|
||||
NSV8Objects::Template_Set(result, "FT_Free", _FT_Free);
|
||||
// методы
|
||||
NSV8Objects::Template_Set(result, "FT_Malloc", _FT_Malloc);
|
||||
NSV8Objects::Template_Set(result, "FT_Free", _FT_Free);
|
||||
|
||||
NSV8Objects::Template_Set(result, "FT_Init", _FT_Init);
|
||||
NSV8Objects::Template_Set(result, "FT_Set_TrueType_HintProp", _FT_Set_TrueType_HintProp);
|
||||
NSV8Objects::Template_Set(result, "FT_Init", _FT_Init);
|
||||
NSV8Objects::Template_Set(result, "FT_Set_TrueType_HintProp", _FT_Set_TrueType_HintProp);
|
||||
|
||||
NSV8Objects::Template_Set(result, "FT_Open_Face", _FT_Open_Face);
|
||||
NSV8Objects::Template_Set(result, "FT_Open_Face2", _FT_Open_Face2);
|
||||
NSV8Objects::Template_Set(result, "FT_GetFaceInfo", _FT_GetFaceInfo);
|
||||
NSV8Objects::Template_Set(result, "FT_Open_Face", _FT_Open_Face);
|
||||
NSV8Objects::Template_Set(result, "FT_Open_Face2", _FT_Open_Face2);
|
||||
NSV8Objects::Template_Set(result, "FT_GetFaceInfo", _FT_GetFaceInfo);
|
||||
|
||||
NSV8Objects::Template_Set(result, "FT_Load_Glyph", _FT_Load_Glyph);
|
||||
NSV8Objects::Template_Set(result, "FT_Get_Glyph_Measure_Params",_FT_Get_Glyph_Measure_Params);
|
||||
NSV8Objects::Template_Set(result, "FT_Get_Glyph_Render_Params", _FT_Get_Glyph_Render_Params);
|
||||
NSV8Objects::Template_Set(result, "FT_Get_Glyph_Render_Buffer", _FT_Get_Glyph_Render_Buffer);
|
||||
NSV8Objects::Template_Set(result, "FT_Load_Glyph", _FT_Load_Glyph);
|
||||
NSV8Objects::Template_Set(result, "FT_Get_Glyph_Measure_Params",_FT_Get_Glyph_Measure_Params);
|
||||
NSV8Objects::Template_Set(result, "FT_Get_Glyph_Render_Params", _FT_Get_Glyph_Render_Params);
|
||||
NSV8Objects::Template_Set(result, "FT_Get_Glyph_Render_Buffer", _FT_Get_Glyph_Render_Buffer);
|
||||
|
||||
NSV8Objects::Template_Set(result, "FT_Set_Transform", _FT_Set_Transform);
|
||||
NSV8Objects::Template_Set(result, "FT_Set_Char_Size", _FT_Set_Char_Size);
|
||||
NSV8Objects::Template_Set(result, "FT_SetCMapForCharCode", _FT_SetCMapForCharCode);
|
||||
NSV8Objects::Template_Set(result, "FT_GetKerningX", _FT_GetKerningX);
|
||||
NSV8Objects::Template_Set(result, "FT_GetFaceMaxAdvanceX", _FT_GetFaceMaxAdvanceX);
|
||||
NSV8Objects::Template_Set(result, "FT_Set_Transform", _FT_Set_Transform);
|
||||
NSV8Objects::Template_Set(result, "FT_Set_Char_Size", _FT_Set_Char_Size);
|
||||
NSV8Objects::Template_Set(result, "FT_SetCMapForCharCode", _FT_SetCMapForCharCode);
|
||||
NSV8Objects::Template_Set(result, "FT_GetKerningX", _FT_GetKerningX);
|
||||
NSV8Objects::Template_Set(result, "FT_GetFaceMaxAdvanceX", _FT_GetFaceMaxAdvanceX);
|
||||
|
||||
#ifdef SUPPORT_HARFBUZZ_SHAPER
|
||||
NSV8Objects::Template_Set(result, "HB_LanguageFromString", _HB_LanguageFromString);
|
||||
NSV8Objects::Template_Set(result, "HB_ShapeText", _HB_ShapeText);
|
||||
NSV8Objects::Template_Set(result, "HB_FontMalloc", _HB_FontMalloc);
|
||||
NSV8Objects::Template_Set(result, "HB_FontFree", _HB_FontFree);
|
||||
NSV8Objects::Template_Set(result, "HB_LanguageFromString", _HB_LanguageFromString);
|
||||
NSV8Objects::Template_Set(result, "HB_ShapeText", _HB_ShapeText);
|
||||
NSV8Objects::Template_Set(result, "HB_FontMalloc", _HB_FontMalloc);
|
||||
NSV8Objects::Template_Set(result, "HB_FontFree", _HB_FontFree);
|
||||
#endif
|
||||
|
||||
return handle_scope.Escape(result);
|
||||
}
|
||||
return handle_scope.Escape(result);
|
||||
}
|
||||
|
||||
void CreateNativeMeasurer(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
{
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
|
||||
v8::Handle<v8::ObjectTemplate> MeasurerTemplate = CreateMeasurerTemplate(isolate);
|
||||
CTextMeasurerEmbed* pMeasurer = new CTextMeasurerEmbed();
|
||||
|
||||
v8::Local<v8::Object> obj = MeasurerTemplate->NewInstance(isolate->GetCurrentContext()).ToLocalChecked();
|
||||
obj->SetInternalField(0, v8::External::New(CV8Worker::GetCurrent(), pMeasurer));
|
||||
|
||||
NSJSBase::CJSEmbedObjectPrivate::CreateWeaker(obj);
|
||||
|
||||
args.GetReturnValue().Set(obj);
|
||||
}
|
||||
void CreateNativeMeasurer(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
{
|
||||
CreateNativeInternalField(new CTextMeasurerEmbed(), CreateMeasurerTemplate, args);
|
||||
}
|
||||
}
|
||||
|
||||
void CTextMeasurerEmbed::CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context)
|
||||
{
|
||||
v8::Isolate* current = CV8Worker::GetCurrent();
|
||||
context->m_internal->m_global->Set(current, name.c_str(), v8::FunctionTemplate::New(current, NSMeasurer::CreateNativeMeasurer));
|
||||
InsertToGlobal(name, context, NSMeasurer::CreateNativeMeasurer);
|
||||
}
|
||||
|
||||
@ -46,23 +46,11 @@ namespace NSZip
|
||||
|
||||
void CreateNativeZip(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
{
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
|
||||
v8::Handle<v8::ObjectTemplate> ZipTemplate = NSZip::CreateZipTemplate(isolate);
|
||||
CZipEmbed* pZip = new CZipEmbed();
|
||||
|
||||
v8::Local<v8::Object> obj = ZipTemplate->NewInstance(isolate->GetCurrentContext()).ToLocalChecked();
|
||||
obj->SetInternalField(0, v8::External::New(CV8Worker::GetCurrent(), pZip));
|
||||
|
||||
NSJSBase::CJSEmbedObjectPrivate::CreateWeaker(obj);
|
||||
|
||||
args.GetReturnValue().Set(obj);
|
||||
CreateNativeInternalField(new CZipEmbed(), NSZip::CreateZipTemplate, args);
|
||||
}
|
||||
}
|
||||
|
||||
void CZipEmbed::CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context)
|
||||
{
|
||||
v8::Isolate* current = CV8Worker::GetCurrent();
|
||||
context->m_internal->m_global->Set(current, name.c_str(), v8::FunctionTemplate::New(current, NSZip::CreateNativeZip));
|
||||
InsertToGlobal(name, context, NSZip::CreateNativeZip);
|
||||
}
|
||||
|
||||
401
DesktopEditor/doctrenderer/hash.cpp
Normal file
401
DesktopEditor/doctrenderer/hash.cpp
Normal file
@ -0,0 +1,401 @@
|
||||
#include "hash.h"
|
||||
|
||||
#ifndef OWN_BASE_64
|
||||
#include "../common/Base64.h"
|
||||
#endif
|
||||
|
||||
#include "openssl/sha.h"
|
||||
#include "openssl/md2.h"
|
||||
#include "openssl/md4.h"
|
||||
#include "openssl/md5.h"
|
||||
#include "openssl/whrlpool.h"
|
||||
#include "openssl/ripemd.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
int CHash::getDigestLength(HashAlgs alg)
|
||||
{
|
||||
static const int aDigestLengths[] = { 16, 16, 16, 20, 20, 32, 48, 64, 64 };
|
||||
return aDigestLengths[alg];
|
||||
}
|
||||
|
||||
CHash::CHash(std::function<void*(size_t)> allocator) : m_fAllocator(allocator)
|
||||
{
|
||||
}
|
||||
|
||||
CHash::~CHash()
|
||||
{
|
||||
}
|
||||
|
||||
unsigned char* CHash::hash(const unsigned char* data, int size, int alg)
|
||||
{
|
||||
unsigned int nBufLen = 0;
|
||||
unsigned char* pBufData = NULL;
|
||||
size_t d = (size_t)size;
|
||||
|
||||
switch (alg)
|
||||
{
|
||||
case haMD2:
|
||||
{
|
||||
nBufLen = 16;
|
||||
pBufData = (unsigned char*)m_fAllocator(nBufLen);
|
||||
MD2(data, d, pBufData);
|
||||
break;
|
||||
}
|
||||
case haMD4:
|
||||
{
|
||||
nBufLen = 16;
|
||||
pBufData = (unsigned char*)m_fAllocator(nBufLen);
|
||||
MD4(data, d, pBufData);
|
||||
break;
|
||||
}
|
||||
case haMD5:
|
||||
{
|
||||
nBufLen = 16;
|
||||
pBufData = (unsigned char*)m_fAllocator(nBufLen);
|
||||
MD5(data, d, pBufData);
|
||||
break;
|
||||
}
|
||||
case haRMD160:
|
||||
{
|
||||
nBufLen = 20;
|
||||
pBufData = (unsigned char*)m_fAllocator(nBufLen);
|
||||
RIPEMD160(data, d, pBufData);
|
||||
break;
|
||||
}
|
||||
case haSHA1:
|
||||
{
|
||||
nBufLen = 20;
|
||||
pBufData = (unsigned char*)m_fAllocator(nBufLen);
|
||||
SHA1(data, d, pBufData);
|
||||
break;
|
||||
}
|
||||
case haSHA256:
|
||||
{
|
||||
nBufLen = 32;
|
||||
pBufData = (unsigned char*)m_fAllocator(nBufLen);
|
||||
SHA256(data, d, pBufData);
|
||||
break;
|
||||
}
|
||||
case haSHA384:
|
||||
{
|
||||
nBufLen = 48;
|
||||
pBufData = (unsigned char*)m_fAllocator(nBufLen);
|
||||
SHA384(data, d, pBufData);
|
||||
break;
|
||||
}
|
||||
case haSHA512:
|
||||
{
|
||||
nBufLen = 64;
|
||||
pBufData = (unsigned char*)m_fAllocator(nBufLen);
|
||||
SHA512(data, d, pBufData);
|
||||
break;
|
||||
}
|
||||
case haWHIRLPOOL:
|
||||
{
|
||||
nBufLen = 64;
|
||||
pBufData = (unsigned char*)m_fAllocator(nBufLen);
|
||||
WHIRLPOOL(data, d, pBufData);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return pBufData;
|
||||
}
|
||||
|
||||
namespace NSUtfs
|
||||
{
|
||||
#define WriteUtf16_byte(code, p) \
|
||||
*p++ = code & 0xFF; \
|
||||
*p++ = (code >> 8) & 0xFF;
|
||||
|
||||
#define WriteUtf16(code, p) \
|
||||
if (code < 0x10000) \
|
||||
{ \
|
||||
WriteUtf16_byte(code, p) \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
code -= 0x10000; \
|
||||
WriteUtf16_byte((0xD800 | ((code >> 10) & 0x03FF)), p); \
|
||||
WriteUtf16_byte((0xDC00 | (code & 0x03FF)), p); \
|
||||
}
|
||||
|
||||
void Utf8_to_utf16le(const char* utf8, unsigned char*& utf16, size_t& utf16_len)
|
||||
{
|
||||
size_t utf8_count = std::strlen(utf8);
|
||||
utf16 = (unsigned char*)malloc(utf8_count * 2);
|
||||
unsigned char* utf16_cur = utf16;
|
||||
|
||||
size_t index = 0;
|
||||
while (index < utf8_count)
|
||||
{
|
||||
unsigned char byteMain = utf8[index];
|
||||
if (0x00 == (byteMain & 0x80))
|
||||
{
|
||||
// 1 byte
|
||||
WriteUtf16(byteMain, utf16_cur);
|
||||
++index;
|
||||
}
|
||||
else if (0x00 == (byteMain & 0x20))
|
||||
{
|
||||
// 2 byte
|
||||
int val = 0;
|
||||
if ((index + 1) < utf8_count)
|
||||
{
|
||||
val = (int)(((byteMain & 0x1F) << 6) |
|
||||
(utf8[index + 1] & 0x3F));
|
||||
}
|
||||
|
||||
WriteUtf16(val, utf16_cur);
|
||||
index += 2;
|
||||
}
|
||||
else if (0x00 == (byteMain & 0x10))
|
||||
{
|
||||
// 3 byte
|
||||
int val = 0;
|
||||
if ((index + 2) < utf8_count)
|
||||
{
|
||||
val = (int)(((byteMain & 0x0F) << 12) |
|
||||
((utf8[index + 1] & 0x3F) << 6) |
|
||||
(utf8[index + 2] & 0x3F));
|
||||
}
|
||||
|
||||
WriteUtf16(val, utf16_cur);
|
||||
index += 3;
|
||||
}
|
||||
else if (0x00 == (byteMain & 0x0F))
|
||||
{
|
||||
// 4 byte
|
||||
int val = 0;
|
||||
if ((index + 3) < utf8_count)
|
||||
{
|
||||
val = (int)(((byteMain & 0x07) << 18) |
|
||||
((utf8[index + 1] & 0x3F) << 12) |
|
||||
((utf8[index + 2] & 0x3F) << 6) |
|
||||
(utf8[index + 3] & 0x3F));
|
||||
}
|
||||
|
||||
WriteUtf16(val, utf16_cur);
|
||||
index += 4;
|
||||
}
|
||||
else if (0x00 == (byteMain & 0x08))
|
||||
{
|
||||
// 4 byte
|
||||
int val = 0;
|
||||
if ((index + 3) < utf8_count)
|
||||
{
|
||||
val = (int)(((byteMain & 0x07) << 18) |
|
||||
((utf8[index + 1] & 0x3F) << 12) |
|
||||
((utf8[index + 2] & 0x3F) << 6) |
|
||||
(utf8[index + 3] & 0x3F));
|
||||
}
|
||||
|
||||
WriteUtf16(val, utf16_cur);
|
||||
index += 4;
|
||||
}
|
||||
else if (0x00 == (byteMain & 0x04))
|
||||
{
|
||||
// 5 byte
|
||||
int val = 0;
|
||||
if ((index + 4) < utf8_count)
|
||||
{
|
||||
val = (int)(((byteMain & 0x03) << 24) |
|
||||
((utf8[index + 1] & 0x3F) << 18) |
|
||||
((utf8[index + 2] & 0x3F) << 12) |
|
||||
((utf8[index + 3] & 0x3F) << 6) |
|
||||
(utf8[index + 4] & 0x3F));
|
||||
}
|
||||
|
||||
WriteUtf16(val, utf16_cur);
|
||||
index += 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 6 byte
|
||||
int val = 0;
|
||||
if ((index + 5) < utf8_count)
|
||||
{
|
||||
val = (int)(((byteMain & 0x01) << 30) |
|
||||
((utf8[index + 1] & 0x3F) << 24) |
|
||||
((utf8[index + 2] & 0x3F) << 18) |
|
||||
((utf8[index + 3] & 0x3F) << 12) |
|
||||
((utf8[index + 4] & 0x3F) << 6) |
|
||||
(utf8[index + 5] & 0x3F));
|
||||
}
|
||||
|
||||
WriteUtf16(val, utf16_cur);
|
||||
index += 5;
|
||||
}
|
||||
}
|
||||
|
||||
utf16_len = (int)(utf16_cur - utf16);
|
||||
}
|
||||
}
|
||||
|
||||
void hash_iteration(unsigned char*& input, int iter, unsigned char*& tmp, int alg, size_t alg_size)
|
||||
{
|
||||
input[alg_size] = 0xFF & (iter >> 0);
|
||||
input[alg_size + 1] = 0xFF & (iter >> 8);
|
||||
input[alg_size + 2] = 0xFF & (iter >> 16);
|
||||
input[alg_size + 3] = 0xFF & (iter >> 24);
|
||||
|
||||
switch (alg)
|
||||
{
|
||||
case CHash::haMD2:
|
||||
{
|
||||
MD2(input, alg_size + 4, tmp);
|
||||
break;
|
||||
}
|
||||
case CHash::haMD4:
|
||||
{
|
||||
MD4(input, alg_size + 4, tmp);
|
||||
break;
|
||||
}
|
||||
case CHash::haMD5:
|
||||
{
|
||||
MD5(input, alg_size + 4, tmp);
|
||||
break;
|
||||
}
|
||||
case CHash::haRMD160:
|
||||
{
|
||||
RIPEMD160(input, alg_size + 4, tmp);
|
||||
break;
|
||||
}
|
||||
case CHash::haSHA1:
|
||||
{
|
||||
SHA1(input, alg_size + 4, tmp);
|
||||
break;
|
||||
}
|
||||
case CHash::haSHA256:
|
||||
{
|
||||
SHA256(input, alg_size + 4, tmp);
|
||||
break;
|
||||
}
|
||||
case CHash::haSHA384:
|
||||
{
|
||||
SHA384(input, alg_size + 4, tmp);
|
||||
break;
|
||||
}
|
||||
case CHash::haSHA512:
|
||||
{
|
||||
SHA512(input, alg_size + 4, tmp);
|
||||
break;
|
||||
}
|
||||
case CHash::haWHIRLPOOL:
|
||||
{
|
||||
WHIRLPOOL(input, alg_size + 4, tmp);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
unsigned char* mem = input;
|
||||
input = tmp;
|
||||
tmp = mem;
|
||||
}
|
||||
|
||||
unsigned char* CHash::hash2(const char* password, const char* salt, int spinCount, int alg)
|
||||
{
|
||||
int inputSaltLen = std::strlen(salt);
|
||||
unsigned char* passwordUtf16 = NULL;
|
||||
size_t passwordUtf16Len = 0;
|
||||
NSUtfs::Utf8_to_utf16le(password, passwordUtf16, passwordUtf16Len);
|
||||
|
||||
int inputDataLen = inputSaltLen + passwordUtf16Len;
|
||||
unsigned char* inputData = (unsigned char*)malloc(inputDataLen);
|
||||
NSBase64::Base64Decode(salt, inputSaltLen, inputData, &inputDataLen);
|
||||
memcpy(inputData + inputDataLen, passwordUtf16, passwordUtf16Len);
|
||||
inputDataLen += passwordUtf16Len;
|
||||
|
||||
free(passwordUtf16);
|
||||
|
||||
size_t alg_size = 0;
|
||||
unsigned char* pBuffer1 = NULL;
|
||||
switch (alg)
|
||||
{
|
||||
case haMD2:
|
||||
{
|
||||
alg_size = 16;
|
||||
pBuffer1 = (unsigned char*)m_fAllocator(alg_size + 4);
|
||||
MD2(inputData, inputDataLen, pBuffer1);
|
||||
break;
|
||||
}
|
||||
case haMD4:
|
||||
{
|
||||
alg_size = 16;
|
||||
pBuffer1 = (unsigned char*)m_fAllocator(alg_size + 4);
|
||||
MD4(inputData, inputDataLen, pBuffer1);
|
||||
break;
|
||||
}
|
||||
case haMD5:
|
||||
{
|
||||
alg_size = 16;
|
||||
pBuffer1 = (unsigned char*)m_fAllocator(alg_size + 4);
|
||||
MD5(inputData, inputDataLen, pBuffer1);
|
||||
break;
|
||||
}
|
||||
case haRMD160:
|
||||
{
|
||||
alg_size = 20;
|
||||
pBuffer1 = (unsigned char*)m_fAllocator(alg_size + 4);
|
||||
RIPEMD160(inputData, inputDataLen, pBuffer1);
|
||||
break;
|
||||
}
|
||||
case haSHA1:
|
||||
{
|
||||
alg_size = 20;
|
||||
pBuffer1 = (unsigned char*)m_fAllocator(alg_size + 4);
|
||||
SHA1(inputData, inputDataLen, pBuffer1);
|
||||
break;
|
||||
}
|
||||
case haSHA256:
|
||||
{
|
||||
alg_size = 32;
|
||||
pBuffer1 = (unsigned char*)m_fAllocator(alg_size + 4);
|
||||
SHA256(inputData, inputDataLen, pBuffer1);
|
||||
break;
|
||||
}
|
||||
case haSHA384:
|
||||
{
|
||||
alg_size = 48;
|
||||
pBuffer1 = (unsigned char*)m_fAllocator(alg_size + 4);
|
||||
SHA384(inputData, inputDataLen, pBuffer1);
|
||||
break;
|
||||
}
|
||||
case haSHA512:
|
||||
{
|
||||
alg_size = 64;
|
||||
pBuffer1 = (unsigned char*)m_fAllocator(alg_size + 4);
|
||||
SHA512(inputData, inputDataLen, pBuffer1);
|
||||
break;
|
||||
}
|
||||
case haWHIRLPOOL:
|
||||
{
|
||||
alg_size = 64;
|
||||
pBuffer1 = (unsigned char*)m_fAllocator(alg_size + 4);
|
||||
WHIRLPOOL(inputData, inputDataLen, pBuffer1);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
free(inputData);
|
||||
|
||||
if (0 == spinCount)
|
||||
return pBuffer1;
|
||||
|
||||
unsigned char* pBuffer2 = (unsigned char*)malloc(alg_size + 4);
|
||||
for (int i = 0; i < spinCount; ++i)
|
||||
{
|
||||
hash_iteration(pBuffer1, i, pBuffer2, alg, alg_size);
|
||||
}
|
||||
|
||||
free(pBuffer2);
|
||||
return pBuffer1;
|
||||
}
|
||||
42
DesktopEditor/doctrenderer/hash.h
Normal file
42
DesktopEditor/doctrenderer/hash.h
Normal file
@ -0,0 +1,42 @@
|
||||
#ifndef NSHASH_H
|
||||
#define NSHASH_H
|
||||
|
||||
#include <functional>
|
||||
#include "./common.h"
|
||||
|
||||
// hide algs into lib
|
||||
namespace NSHash
|
||||
{
|
||||
void BUILDER_DECL hash_internal(const unsigned char* src, unsigned char* dst, size_t size, int alg);
|
||||
}
|
||||
|
||||
class BUILDER_DECL CHash
|
||||
{
|
||||
public:
|
||||
enum HashAlgs
|
||||
{
|
||||
haMD2 = 0,
|
||||
haMD4 = 1,
|
||||
haMD5 = 2,
|
||||
haRMD160 = 3,
|
||||
haSHA1 = 4,
|
||||
haSHA256 = 5,
|
||||
haSHA384 = 6,
|
||||
haSHA512 = 7,
|
||||
haWHIRLPOOL = 8
|
||||
};
|
||||
|
||||
static int getDigestLength(HashAlgs alg);
|
||||
|
||||
public:
|
||||
CHash(std::function<void*(size_t)> allocator);
|
||||
~CHash();
|
||||
|
||||
unsigned char* hash(const unsigned char* data, int size, int alg);
|
||||
unsigned char* hash2(const char* password, const char* salt, int spinCount, int alg);
|
||||
|
||||
private:
|
||||
std::function<void*(size_t)> m_fAllocator;
|
||||
};
|
||||
|
||||
#endif // NSHASH_H
|
||||
135
DesktopEditor/doctrenderer/js_internal/js_base.cpp
Normal file
135
DesktopEditor/doctrenderer/js_internal/js_base.cpp
Normal file
@ -0,0 +1,135 @@
|
||||
#include "js_base.h"
|
||||
|
||||
namespace NSJSBase {
|
||||
|
||||
CJSValue::CJSValue()
|
||||
{
|
||||
}
|
||||
|
||||
CJSValue::~CJSValue()
|
||||
{
|
||||
}
|
||||
|
||||
JSSmart<CJSObject> CJSValue::toObjectSmart()
|
||||
{
|
||||
return toObject();
|
||||
}
|
||||
|
||||
CJSEmbedObjectPrivateBase::CJSEmbedObjectPrivateBase()
|
||||
{
|
||||
}
|
||||
|
||||
CJSEmbedObjectPrivateBase::~CJSEmbedObjectPrivateBase()
|
||||
{
|
||||
}
|
||||
|
||||
CJSEmbedObject::CJSEmbedObject()
|
||||
{
|
||||
embed_native_internal = NULL;
|
||||
}
|
||||
|
||||
CJSEmbedObject::~CJSEmbedObject()
|
||||
{
|
||||
RELEASEOBJECT(embed_native_internal);
|
||||
}
|
||||
|
||||
void* CJSEmbedObject::getObject()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CJSObject::CJSObject()
|
||||
{
|
||||
}
|
||||
|
||||
CJSObject::~CJSObject()
|
||||
{
|
||||
}
|
||||
|
||||
CJSArray::CJSArray()
|
||||
{
|
||||
}
|
||||
|
||||
CJSArray::~CJSArray()
|
||||
{
|
||||
}
|
||||
|
||||
BYTE* CJSDataBuffer::Copy()
|
||||
{
|
||||
if (0 == Len)
|
||||
return NULL;
|
||||
BYTE* pMem = new BYTE[Len];
|
||||
if (!pMem)
|
||||
return NULL;
|
||||
|
||||
memcpy(pMem, Data, Len);
|
||||
return pMem;
|
||||
}
|
||||
|
||||
CJSDataBuffer::CJSDataBuffer()
|
||||
{
|
||||
Data = NULL;
|
||||
Len = 0;
|
||||
IsExternalize = false;
|
||||
}
|
||||
|
||||
void CJSDataBuffer::Free()
|
||||
{
|
||||
if (Data)
|
||||
{
|
||||
NSAllocator::Free(Data, Len);
|
||||
Data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
CJSTypedArray::CJSTypedArray(BYTE* data, int count)
|
||||
{
|
||||
}
|
||||
|
||||
CJSTypedArray::~CJSTypedArray()
|
||||
{
|
||||
}
|
||||
|
||||
CJSFunction::CJSFunction()
|
||||
{
|
||||
}
|
||||
|
||||
CJSFunction::~CJSFunction()
|
||||
{
|
||||
}
|
||||
|
||||
CJSTryCatch::CJSTryCatch()
|
||||
{
|
||||
}
|
||||
|
||||
CJSTryCatch::~CJSTryCatch()
|
||||
{
|
||||
}
|
||||
|
||||
CJSValue* CJSContext::createUint8Array(const std::wstring& sFilePath)
|
||||
{
|
||||
NSFile::CFileBinary oFileBinary;
|
||||
if (oFileBinary.OpenFile(sFilePath))
|
||||
{
|
||||
long nFileSize = oFileBinary.GetFileSize();
|
||||
BYTE* pData = NSAllocator::Alloc((size_t)nFileSize);
|
||||
DWORD dwSizeRead;
|
||||
if (oFileBinary.ReadFile(pData, (DWORD)nFileSize, dwSizeRead))
|
||||
{
|
||||
return CJSContext::createUint8Array(pData, (int)nFileSize, false);
|
||||
}
|
||||
NSAllocator::Free(pData, (size_t)nFileSize);
|
||||
}
|
||||
return CJSContext::createNull();
|
||||
}
|
||||
|
||||
CJSContextScope::CJSContextScope(JSSmart<CJSContext> context) : m_context(context)
|
||||
{
|
||||
m_context->Enter();
|
||||
}
|
||||
|
||||
CJSContextScope::~CJSContextScope()
|
||||
{
|
||||
m_context->Exit();
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,20 @@
|
||||
#include "../../../OOXML/Base/SmartPtr.h"
|
||||
#include "../../graphics/BaseThread.h"
|
||||
|
||||
// disable export (ios/android problem (external embed objects))
|
||||
#define JSBASE_NO_USE_DYNAMIC_LIBRARY
|
||||
|
||||
#ifdef JSBASE_NO_USE_DYNAMIC_LIBRARY
|
||||
#define JS_DECL
|
||||
#else
|
||||
#include "../../common/base_export.h"
|
||||
#ifdef JSBASE_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
#define JS_DECL Q_DECL_EXPORT
|
||||
#else
|
||||
#define JS_DECL Q_DECL_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define JS_VALUE_EXIST(value) (value.is_init() && !value->isNull() && !value->isUndefined())
|
||||
#define JS_IS_VALUE_ARRAY(value) (value.is_init() && !value->isNull() && !value->isUndefined() && value->isArray())
|
||||
|
||||
@ -14,285 +28,235 @@ using JSSmart = NSCommon::smart_ptr<T>;
|
||||
|
||||
namespace NSJSBase
|
||||
{
|
||||
class CJSObject;
|
||||
class CJSArray;
|
||||
class CJSTypedArray;
|
||||
class CJSFunction;
|
||||
class CJSObject;
|
||||
class CJSArray;
|
||||
class CJSTypedArray;
|
||||
class CJSFunction;
|
||||
|
||||
class CJSValue
|
||||
{
|
||||
public:
|
||||
CJSValue() {}
|
||||
virtual ~CJSValue() {}
|
||||
class JS_DECL CJSValue
|
||||
{
|
||||
public:
|
||||
CJSValue();
|
||||
virtual ~CJSValue();
|
||||
|
||||
virtual bool isUndefined() = 0;
|
||||
virtual bool isNull() = 0;
|
||||
virtual bool isBool() = 0;
|
||||
virtual bool isNumber() = 0;
|
||||
virtual bool isString() = 0;
|
||||
virtual bool isArray() = 0;
|
||||
virtual bool isTypedArray() = 0;
|
||||
virtual bool isObject() = 0;
|
||||
virtual bool isFunction() = 0;
|
||||
virtual bool isEmpty() = 0;
|
||||
virtual bool isUndefined() = 0;
|
||||
virtual bool isNull() = 0;
|
||||
virtual bool isBool() = 0;
|
||||
virtual bool isNumber() = 0;
|
||||
virtual bool isString() = 0;
|
||||
virtual bool isArray() = 0;
|
||||
virtual bool isTypedArray() = 0;
|
||||
virtual bool isObject() = 0;
|
||||
virtual bool isFunction() = 0;
|
||||
virtual bool isEmpty() = 0;
|
||||
|
||||
virtual void doUndefined() = 0;
|
||||
virtual void doNull() = 0;
|
||||
virtual void doUndefined() = 0;
|
||||
virtual void doNull() = 0;
|
||||
|
||||
virtual bool toBool() = 0;
|
||||
virtual int toInt32() = 0;
|
||||
virtual unsigned int toUInt32() = 0;
|
||||
virtual double toDouble() = 0;
|
||||
virtual std::string toStringA() = 0;
|
||||
virtual std::wstring toStringW() = 0;
|
||||
virtual bool toBool() = 0;
|
||||
virtual int toInt32() = 0;
|
||||
virtual unsigned int toUInt32() = 0;
|
||||
virtual double toDouble() = 0;
|
||||
virtual std::string toStringA() = 0;
|
||||
virtual std::wstring toStringW() = 0;
|
||||
|
||||
virtual CJSObject* toObject() = 0;
|
||||
virtual CJSArray* toArray() = 0;
|
||||
virtual CJSTypedArray* toTypedArray() = 0;
|
||||
virtual CJSFunction* toFunction() = 0;
|
||||
virtual CJSObject* toObject() = 0;
|
||||
virtual CJSArray* toArray() = 0;
|
||||
virtual CJSTypedArray* toTypedArray() = 0;
|
||||
virtual CJSFunction* toFunction() = 0;
|
||||
|
||||
virtual JSSmart<CJSObject> toObjectSmart() { return toObject(); }
|
||||
};
|
||||
virtual JSSmart<CJSObject> toObjectSmart();
|
||||
};
|
||||
|
||||
class CJSEmbedObjectPrivateBase
|
||||
{
|
||||
public:
|
||||
CJSEmbedObjectPrivateBase() {}
|
||||
virtual ~CJSEmbedObjectPrivateBase() {}
|
||||
};
|
||||
class JS_DECL CJSEmbedObjectPrivateBase
|
||||
{
|
||||
public:
|
||||
CJSEmbedObjectPrivateBase();
|
||||
virtual ~CJSEmbedObjectPrivateBase();
|
||||
};
|
||||
|
||||
class CJSEmbedObject
|
||||
{
|
||||
public:
|
||||
CJSEmbedObject() { embed_native_internal = NULL; }
|
||||
virtual ~CJSEmbedObject() { RELEASEOBJECT(embed_native_internal); }
|
||||
class JS_DECL CJSEmbedObject
|
||||
{
|
||||
public:
|
||||
CJSEmbedObject();
|
||||
virtual ~CJSEmbedObject();
|
||||
|
||||
public:
|
||||
virtual void* getObject() { return NULL; }
|
||||
public:
|
||||
virtual void* getObject();
|
||||
|
||||
protected:
|
||||
CJSEmbedObjectPrivateBase* embed_native_internal;
|
||||
protected:
|
||||
CJSEmbedObjectPrivateBase* embed_native_internal;
|
||||
|
||||
friend class CJSEmbedObjectPrivateBase;
|
||||
friend class CJSEmbedObjectPrivate;
|
||||
};
|
||||
friend class CJSEmbedObjectPrivateBase;
|
||||
friend class CJSEmbedObjectPrivate;
|
||||
};
|
||||
|
||||
class CJSObject : public CJSValue
|
||||
{
|
||||
public:
|
||||
CJSObject() {}
|
||||
virtual ~CJSObject() {}
|
||||
class JS_DECL CJSObject : public CJSValue
|
||||
{
|
||||
public:
|
||||
CJSObject();
|
||||
virtual ~CJSObject();
|
||||
|
||||
virtual CJSValue* get(const char* name) = 0;
|
||||
virtual void set(const char* name, CJSValue* value) = 0;
|
||||
virtual CJSValue* get(const char* name) = 0;
|
||||
virtual void set(const char* name, CJSValue* value) = 0;
|
||||
|
||||
virtual void set(const char* name, const int& value) = 0;
|
||||
virtual void set(const char* name, const double& value) = 0;
|
||||
virtual void set(const char* name, const int& value) = 0;
|
||||
virtual void set(const char* name, const double& value) = 0;
|
||||
|
||||
virtual CJSEmbedObject* getNative() = 0;
|
||||
virtual CJSEmbedObject* getNative() = 0;
|
||||
|
||||
virtual JSSmart<CJSValue> call_func(const char* name, const int argc = 0, JSSmart<CJSValue> argv[] = NULL) = 0;
|
||||
virtual JSSmart<CJSValue> toValue() = 0;
|
||||
};
|
||||
virtual JSSmart<CJSValue> call_func(const char* name, const int argc = 0, JSSmart<CJSValue> argv[] = NULL) = 0;
|
||||
virtual JSSmart<CJSValue> toValue() = 0;
|
||||
};
|
||||
|
||||
class CJSArray : public CJSValue
|
||||
{
|
||||
public:
|
||||
CJSArray() {}
|
||||
virtual ~CJSArray() {}
|
||||
class JS_DECL CJSArray : public CJSValue
|
||||
{
|
||||
public:
|
||||
CJSArray();
|
||||
virtual ~CJSArray();
|
||||
|
||||
virtual int getCount() = 0;
|
||||
virtual JSSmart<CJSValue> get(const int& index) = 0;
|
||||
virtual void set(const int& index, CJSValue* value) = 0;
|
||||
virtual void set(const int& index, const bool& value) = 0;
|
||||
virtual void set(const int& index, const int& value) = 0;
|
||||
virtual void set(const int& index, const double& value) = 0;
|
||||
virtual int getCount() = 0;
|
||||
virtual JSSmart<CJSValue> get(const int& index) = 0;
|
||||
virtual void set(const int& index, CJSValue* value) = 0;
|
||||
virtual void set(const int& index, const bool& value) = 0;
|
||||
virtual void set(const int& index, const int& value) = 0;
|
||||
virtual void set(const int& index, const double& value) = 0;
|
||||
|
||||
virtual void add(CJSValue* value) = 0;
|
||||
virtual void add_null() = 0;
|
||||
virtual void add_undefined() = 0;
|
||||
virtual void add_bool(const bool& value) = 0;
|
||||
virtual void add_byte(const BYTE& value) = 0;
|
||||
virtual void add_int(const int& value) = 0;
|
||||
virtual void add_double(const double& value) = 0;
|
||||
virtual void add_stringa(const std::string& value) = 0;
|
||||
virtual void add_string(const std::wstring& value) = 0;
|
||||
virtual JSSmart<CJSValue> toValue() = 0;
|
||||
};
|
||||
virtual void add(CJSValue* value) = 0;
|
||||
virtual void add_null() = 0;
|
||||
virtual void add_undefined() = 0;
|
||||
virtual void add_bool(const bool& value) = 0;
|
||||
virtual void add_byte(const BYTE& value) = 0;
|
||||
virtual void add_int(const int& value) = 0;
|
||||
virtual void add_double(const double& value) = 0;
|
||||
virtual void add_stringa(const std::string& value) = 0;
|
||||
virtual void add_string(const std::wstring& value) = 0;
|
||||
virtual JSSmart<CJSValue> toValue() = 0;
|
||||
};
|
||||
|
||||
namespace NSAllocator
|
||||
{
|
||||
unsigned char* Alloc(const size_t& size);
|
||||
void Free(unsigned char* data, const size_t& size);
|
||||
}
|
||||
namespace NSAllocator
|
||||
{
|
||||
unsigned char* Alloc(const size_t& size);
|
||||
void Free(unsigned char* data, const size_t& size);
|
||||
}
|
||||
|
||||
class CJSDataBuffer
|
||||
{
|
||||
public:
|
||||
BYTE* Data;
|
||||
size_t Len;
|
||||
class JS_DECL CJSDataBuffer
|
||||
{
|
||||
public:
|
||||
BYTE* Data;
|
||||
size_t Len;
|
||||
|
||||
bool IsExternalize;
|
||||
bool IsExternalize;
|
||||
|
||||
public:
|
||||
BYTE* Copy()
|
||||
{
|
||||
if (0 == Len)
|
||||
return NULL;
|
||||
BYTE* pMem = new BYTE[Len];
|
||||
if (!pMem)
|
||||
return NULL;
|
||||
public:
|
||||
BYTE* Copy();
|
||||
CJSDataBuffer();
|
||||
void Free();
|
||||
};
|
||||
|
||||
memcpy(pMem, Data, Len);
|
||||
return pMem;
|
||||
}
|
||||
CJSDataBuffer()
|
||||
{
|
||||
Data = NULL;
|
||||
Len = 0;
|
||||
IsExternalize = false;
|
||||
}
|
||||
void Free()
|
||||
{
|
||||
if (Data)
|
||||
{
|
||||
NSAllocator::Free(Data, Len);
|
||||
Data = NULL;
|
||||
}
|
||||
}
|
||||
};
|
||||
class JS_DECL CJSTypedArray : public CJSValue
|
||||
{
|
||||
public:
|
||||
CJSTypedArray(BYTE* data = NULL, int count = 0);
|
||||
virtual ~CJSTypedArray();
|
||||
|
||||
class CJSTypedArray : public CJSValue
|
||||
{
|
||||
public:
|
||||
CJSTypedArray(BYTE* data = NULL, int count = 0) {}
|
||||
virtual ~CJSTypedArray() {}
|
||||
virtual int getCount() = 0;
|
||||
virtual CJSDataBuffer getData() = 0;
|
||||
virtual JSSmart<CJSValue> toValue() = 0;
|
||||
};
|
||||
|
||||
virtual int getCount() = 0;
|
||||
virtual CJSDataBuffer getData() = 0;
|
||||
virtual JSSmart<CJSValue> toValue() = 0;
|
||||
};
|
||||
class JS_DECL CJSFunction : public CJSValue
|
||||
{
|
||||
public:
|
||||
CJSFunction();
|
||||
virtual ~CJSFunction();
|
||||
|
||||
class CJSFunction : public CJSValue
|
||||
{
|
||||
public:
|
||||
CJSFunction() {}
|
||||
virtual ~CJSFunction() {}
|
||||
virtual CJSValue* Call(CJSValue* recv, int argc, JSSmart<CJSValue> argv[]) = 0;
|
||||
};
|
||||
|
||||
virtual CJSValue* Call(CJSValue* recv, int argc, JSSmart<CJSValue> argv[]) = 0;
|
||||
};
|
||||
class JS_DECL CJSTryCatch
|
||||
{
|
||||
public:
|
||||
CJSTryCatch();
|
||||
virtual ~CJSTryCatch();
|
||||
virtual bool Check() = 0;
|
||||
};
|
||||
|
||||
class CJSTryCatch
|
||||
{
|
||||
public:
|
||||
CJSTryCatch() {}
|
||||
virtual ~CJSTryCatch() {}
|
||||
virtual bool Check() = 0;
|
||||
};
|
||||
class CJSContextPrivate;
|
||||
class JS_DECL CJSContext
|
||||
{
|
||||
public:
|
||||
CJSContextPrivate* m_internal;
|
||||
|
||||
class CJSIsolateScope
|
||||
{
|
||||
public:
|
||||
CJSIsolateScope()
|
||||
{
|
||||
}
|
||||
virtual ~CJSIsolateScope()
|
||||
{
|
||||
}
|
||||
};
|
||||
public:
|
||||
CJSContext(const bool& bIsInitialize = true);
|
||||
~CJSContext();
|
||||
|
||||
class CJSContextScope
|
||||
{
|
||||
public:
|
||||
CJSContextScope()
|
||||
{
|
||||
}
|
||||
virtual ~CJSContextScope()
|
||||
{
|
||||
}
|
||||
};
|
||||
void Initialize();
|
||||
void Dispose();
|
||||
|
||||
class CJSLocalScope
|
||||
{
|
||||
public:
|
||||
CJSLocalScope()
|
||||
{
|
||||
}
|
||||
virtual ~CJSLocalScope()
|
||||
{
|
||||
}
|
||||
};
|
||||
CJSTryCatch* GetExceptions();
|
||||
|
||||
class CJSContextPrivate;
|
||||
class CJSContext
|
||||
{
|
||||
public:
|
||||
CJSContextPrivate* m_internal;
|
||||
void CreateContext();
|
||||
CJSObject* GetGlobal();
|
||||
|
||||
public:
|
||||
CJSContext();
|
||||
~CJSContext();
|
||||
// Use this methods before working with needed context if you want to work with multiple contexts simultaneously (or use CJSContextScope)
|
||||
void Enter();
|
||||
void Exit();
|
||||
|
||||
void Initialize();
|
||||
void Dispose();
|
||||
JSSmart<CJSValue> runScript(const std::string& script, JSSmart<CJSTryCatch> exception = NULL, const std::wstring& scriptPath = std::wstring(L""));
|
||||
CJSValue* JSON_Parse(const char* json_content);
|
||||
void MoveToThread(ASC_THREAD_ID* id = NULL);
|
||||
|
||||
CJSTryCatch* GetExceptions();
|
||||
public:
|
||||
static CJSValue* createUndefined();
|
||||
static CJSValue* createNull();
|
||||
static CJSValue* createBool(const bool& value);
|
||||
static CJSValue* createInt(const int& value);
|
||||
static CJSValue* createUInt(const unsigned int& value);
|
||||
static CJSValue* createDouble(const double& value);
|
||||
static CJSValue* createString(const char* value, const int& length = -1);
|
||||
static CJSValue* createString(const wchar_t* value, const int& length = -1);
|
||||
static CJSValue* createString(const std::string& value);
|
||||
static CJSValue* createString(const std::wstring& value);
|
||||
|
||||
void CreateContext();
|
||||
void CreateGlobalForContext();
|
||||
CJSObject* GetGlobal();
|
||||
static CJSObject* createObject();
|
||||
|
||||
CJSIsolateScope* CreateIsolateScope();
|
||||
CJSContextScope* CreateContextScope();
|
||||
CJSLocalScope* CreateLocalScope();
|
||||
static CJSArray* createArray(const int& count);
|
||||
|
||||
JSSmart<CJSValue> runScript(const std::string& script, JSSmart<CJSTryCatch> exception = NULL, const std::wstring& scriptPath = std::wstring(L""));
|
||||
CJSValue* JSON_Parse(const char* json_content);
|
||||
void MoveToThread(ASC_THREAD_ID* id = NULL);
|
||||
static CJSTypedArray* createUint8Array(BYTE* data = NULL, int count = 0, const bool& isExternalize = true);
|
||||
|
||||
public:
|
||||
static CJSValue* createUndefined();
|
||||
static CJSValue* createNull();
|
||||
static CJSValue* createBool(const bool& value);
|
||||
static CJSValue* createInt(const int& value);
|
||||
static CJSValue* createUInt(const unsigned int& value);
|
||||
static CJSValue* createDouble(const double& value);
|
||||
static CJSValue* createString(const char* value, const int& length = -1);
|
||||
static CJSValue* createString(const wchar_t* value, const int& length = -1);
|
||||
static CJSValue* createString(const std::string& value);
|
||||
static CJSValue* createString(const std::wstring& value);
|
||||
static CJSValue* createUint8Array(const std::wstring& sFilePath);
|
||||
|
||||
static CJSObject* createObject();
|
||||
public:
|
||||
static JSSmart<CJSContext> GetCurrent();
|
||||
|
||||
static CJSArray* createArray(const int& count);
|
||||
public:
|
||||
static void ExternalInitialize(const std::wstring& sDirectory);
|
||||
static void ExternalDispose();
|
||||
static bool IsSupportNativeTypedArrays();
|
||||
};
|
||||
|
||||
static CJSTypedArray* createUint8Array(BYTE* data = NULL, int count = 0, const bool& isExternalize = true);
|
||||
class CJSLocalScopePrivate;
|
||||
class JS_DECL CJSLocalScope
|
||||
{
|
||||
public:
|
||||
CJSLocalScopePrivate* m_internal;
|
||||
|
||||
static CJSValue* createUint8Array(const std::wstring& sFilePath)
|
||||
{
|
||||
NSFile::CFileBinary oFileBinary;
|
||||
if (oFileBinary.OpenFile(sFilePath))
|
||||
{
|
||||
long nFileSize = oFileBinary.GetFileSize();
|
||||
BYTE* pData = NSAllocator::Alloc((size_t)nFileSize);
|
||||
DWORD dwSizeRead;
|
||||
if (oFileBinary.ReadFile(pData, (DWORD)nFileSize, dwSizeRead))
|
||||
{
|
||||
return CJSContext::createUint8Array(pData, (int)nFileSize, false);
|
||||
}
|
||||
NSAllocator::Free(pData, (size_t)nFileSize);
|
||||
}
|
||||
return CJSContext::createNull();
|
||||
}
|
||||
public:
|
||||
CJSLocalScope();
|
||||
~CJSLocalScope();
|
||||
};
|
||||
|
||||
public:
|
||||
static CJSContext* GetCurrent();
|
||||
class JS_DECL CJSContextScope
|
||||
{
|
||||
public:
|
||||
JSSmart<CJSContext> m_context;
|
||||
|
||||
public:
|
||||
static void ExternalInitialize(const std::wstring& sDirectory);
|
||||
static void ExternalDispose();
|
||||
static bool IsSupportNativeTypedArrays();
|
||||
};
|
||||
public:
|
||||
CJSContextScope(JSSmart<CJSContext> context);
|
||||
~CJSContextScope();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _CORE_EXT_JS_BASE_H_
|
||||
|
||||
@ -8,6 +8,7 @@ core_ios {
|
||||
INCLUDEPATH += $$PWD
|
||||
|
||||
HEADERS += $$PWD/js_base.h
|
||||
SOURCES += $$PWD/js_base.cpp
|
||||
|
||||
HEADERS += $$PWD/js_logger.h
|
||||
SOURCES += $$PWD/js_logger.cpp
|
||||
@ -17,6 +18,15 @@ SOURCES += $$PWD/js_logger.cpp
|
||||
HEADERS += $$PWD/v8/v8_base.h
|
||||
SOURCES += $$PWD/v8/v8_base.cpp
|
||||
|
||||
core_mac:CONFIG += disable_v8_use_inspector
|
||||
core_android:CONFIG += disable_v8_use_inspector
|
||||
linux_arm64:CONFIG += disable_v8_use_inspector
|
||||
build_xp::CONFIG += disable_v8_use_inspector
|
||||
|
||||
core_android:CONFIG += v8_version_60
|
||||
|
||||
!disable_v8_use_inspector:CONFIG += v8_use_inspector
|
||||
|
||||
!build_xp {
|
||||
include($$PWD/../../../Common/3dParty/v8/v8.pri)
|
||||
} else {
|
||||
@ -25,30 +35,28 @@ SOURCES += $$PWD/js_logger.cpp
|
||||
}
|
||||
|
||||
v8_use_inspector {
|
||||
#define
|
||||
core_windows:DEFINES += WIN32_LEAN_AND_MEAN
|
||||
DEFINES += V8_INSPECTOR
|
||||
|
||||
#paths
|
||||
V8_INSPECTOR_PATH = $$PWD/v8/inspector
|
||||
|
||||
#inspector files
|
||||
HEADERS += \
|
||||
$$V8_INSPECTOR_PATH/channel.h \
|
||||
$$V8_INSPECTOR_PATH/client.h \
|
||||
$$V8_INSPECTOR_PATH/inspector_impl.h \
|
||||
$$V8_INSPECTOR_PATH/singleconnectionserver.h \
|
||||
$$V8_INSPECTOR_PATH/singlethreadutils.h \
|
||||
$$V8_INSPECTOR_PATH/inspector_pool.h \
|
||||
$$V8_INSPECTOR_PATH/inspector_interface.h
|
||||
|
||||
SOURCES += \
|
||||
$$V8_INSPECTOR_PATH/channel.cpp \
|
||||
$$V8_INSPECTOR_PATH/client.cpp \
|
||||
$$V8_INSPECTOR_PATH/inspector_impl.cpp \
|
||||
$$V8_INSPECTOR_PATH/singleconnectionserver.cpp \
|
||||
$$V8_INSPECTOR_PATH/singlethreadutils.cpp \
|
||||
$$V8_INSPECTOR_PATH/inspector_pool.cpp \
|
||||
$$V8_INSPECTOR_PATH/inspector_interface.cpp
|
||||
$$V8_INSPECTOR_PATH/inspector.cpp \
|
||||
$$V8_INSPECTOR_PATH/utils.cpp \
|
||||
$$V8_INSPECTOR_PATH/v8_inspector_channel.cpp \
|
||||
$$V8_INSPECTOR_PATH/v8_inspector_client.cpp \
|
||||
$$V8_INSPECTOR_PATH/websocket_server.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$V8_INSPECTOR_PATH/inspector.h \
|
||||
$$V8_INSPECTOR_PATH/inspector_pool.h \
|
||||
$$V8_INSPECTOR_PATH/utils.h\
|
||||
$$V8_INSPECTOR_PATH/v8_inspector_channel.h \
|
||||
$$V8_INSPECTOR_PATH/v8_inspector_client.h \
|
||||
$$V8_INSPECTOR_PATH/websocket_server.h
|
||||
|
||||
|
||||
#to include inspector files
|
||||
@ -60,6 +68,10 @@ SOURCES += $$PWD/js_logger.cpp
|
||||
LIBS += -L$$CORE_V8_PATH_LIBS/src/inspector -linspector
|
||||
}
|
||||
|
||||
core_linux {
|
||||
LIBS += -lpthread
|
||||
}
|
||||
|
||||
#boost
|
||||
CONFIG += core_boost_date_time
|
||||
include($$PWD/../../../Common/3dParty/boost/boost.pri)
|
||||
|
||||
@ -5,31 +5,31 @@
|
||||
|
||||
namespace NSJSBase
|
||||
{
|
||||
std::string g_logger_file = NSSystemUtils::GetEnvVariableA(L"js_speed");
|
||||
bool g_logger_enabled = g_logger_file.empty() ? false : true;
|
||||
unsigned long g_logger_time = 0;
|
||||
std::string g_logger_file = NSSystemUtils::GetEnvVariableA(L"js_speed");
|
||||
bool g_logger_enabled = g_logger_file.empty() ? false : true;
|
||||
unsigned long g_logger_time = 0;
|
||||
|
||||
void LOGGER_START_FUNC()
|
||||
{
|
||||
g_logger_time = NSTimers::GetTickCount();
|
||||
}
|
||||
void LOGGER_LAP_FUNC(const char* details)
|
||||
{
|
||||
if (!g_logger_enabled)
|
||||
return;
|
||||
unsigned long dwCur = (unsigned long)NSTimers::GetTickCount();
|
||||
void LOGGER_START_FUNC()
|
||||
{
|
||||
g_logger_time = NSTimers::GetTickCount();
|
||||
}
|
||||
void LOGGER_LAP_FUNC(const char* details)
|
||||
{
|
||||
if (!g_logger_enabled)
|
||||
return;
|
||||
unsigned long dwCur = (unsigned long)NSTimers::GetTickCount();
|
||||
|
||||
if (g_logger_file.length() == 1)
|
||||
{
|
||||
printf(details);
|
||||
printf(": %d\n", (int)(dwCur - g_logger_time));
|
||||
}
|
||||
else
|
||||
{
|
||||
FILE* f = fopen(g_logger_file.c_str(), "a+");
|
||||
fprintf(f, "%s: %d\n", details, (int)(dwCur - g_logger_time));
|
||||
fclose(f);
|
||||
}
|
||||
g_logger_time = dwCur;
|
||||
}
|
||||
if (g_logger_file.length() == 1)
|
||||
{
|
||||
printf(details);
|
||||
printf(": %d\n", (int)(dwCur - g_logger_time));
|
||||
}
|
||||
else
|
||||
{
|
||||
FILE* f = fopen(g_logger_file.c_str(), "a+");
|
||||
fprintf(f, "%s: %d\n", details, (int)(dwCur - g_logger_time));
|
||||
fclose(f);
|
||||
}
|
||||
g_logger_time = dwCur;
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
|
||||
namespace NSJSBase
|
||||
{
|
||||
void LOGGER_START_FUNC();
|
||||
void LOGGER_LAP_FUNC(const char* details);
|
||||
void LOGGER_START_FUNC();
|
||||
void LOGGER_LAP_FUNC(const char* details);
|
||||
}
|
||||
|
||||
#if 1
|
||||
|
||||
@ -197,9 +197,11 @@ std::wstring CJSValueJSCTemplate<T>::toStringW()
|
||||
|
||||
namespace NSJSBase
|
||||
{
|
||||
CJSContext::CJSContext()
|
||||
CJSContext::CJSContext(const bool& bIsInitialize)
|
||||
{
|
||||
m_internal = new CJSContextPrivate();
|
||||
if (bIsInitialize)
|
||||
Initialize();
|
||||
}
|
||||
CJSContext::~CJSContext()
|
||||
{
|
||||
@ -222,6 +224,9 @@ namespace NSJSBase
|
||||
{
|
||||
[m_internal->context evaluateScript:@"function jsc_toBase64(r){for(var o=[\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\",\"H\",\"I\",\"J\",\"K\",\"L\",\"M\",\"N\",\"O\",\"P\",\"Q\",\"R\",\"S\",\"T\",\"U\",\"V\",\"W\",\"X\",\"Y\",\"Z\",\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\",\"h\",\"i\",\"j\",\"k\",\"l\",\"m\",\"n\",\"o\",\"p\",\"q\",\"r\",\"s\",\"t\",\"u\",\"v\",\"w\",\"x\",\"y\",\"z\",\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"+\",\"/\"],a=r.length,f=4*(a/3>>0),n=f/76>>0,t=19,v=0,e=[],i=\"\",s=0;s<=n;s++){s==n&&(t=f%76/4>>0);for(var u=0;u<t;u++){for(var c=0,h=0;h<3;h++)c|=r[0+v++],c<<=8;i=\"\";for(var A=0;A<4;A++){i+=o[c>>>26&255],c<<=6,c&=4294967295}e.push(i)}}if(n=a%3!=0?a%3+1:0){for(c=0,h=0;h<3;h++)h<a%3&&(c|=r[0+v++]),c<<=8;i=\"\";for(A=0;A<n;A++){i+=o[c>>>26&255],c<<=6}t=0!=n?4-n:0;for(u=0;u<t;u++)i+=\"=\";e.push(i)}return e.join(\"\")}function jsc_fromBase64(r,o){for(var a,f=r.length,n=0,t=new Array(void 0===o?f:o),v=t,e=0,i=0;e<f;){for(var s=0,u=0,c=0;c<4&&!(f<=e);c++){var h=65<=(a=r.charCodeAt(e++))&&a<=90?a-65:97<=a&&a<=122?a-71:48<=a&&a<=57?a+4:43==a?62:47==a?63:-1;-1!=h?(s<<=6,s|=h,u+=6):c--}for(s<<=24-u,i=u>>>3,c=0;c<i;c++)v[n++]=(16711680&s)>>>16,s<<=8}return t}\n"];
|
||||
}
|
||||
|
||||
JSValue* global_js = [m_internal->context globalObject];
|
||||
[global_js setValue:global_js forProperty:[[NSString alloc] initWithUTF8String:"window"]];
|
||||
}
|
||||
void CJSContext::Dispose()
|
||||
{
|
||||
@ -237,11 +242,6 @@ namespace NSJSBase
|
||||
// NONE
|
||||
}
|
||||
|
||||
void CJSContext::CreateGlobalForContext()
|
||||
{
|
||||
// NONE
|
||||
}
|
||||
|
||||
CJSObject* CJSContext::GetGlobal()
|
||||
{
|
||||
CJSObjectJSC* ret = new CJSObjectJSC();
|
||||
@ -249,31 +249,6 @@ namespace NSJSBase
|
||||
return ret;
|
||||
}
|
||||
|
||||
CJSIsolateScope* CJSContext::CreateIsolateScope()
|
||||
{
|
||||
#if 0
|
||||
// FOR DEBUG
|
||||
[m_internal->context setExceptionHandler:^(JSContext *context, JSValue *value) {
|
||||
NSLog(@"%@", value);
|
||||
}];
|
||||
#endif
|
||||
|
||||
return new CJSIsolateScope();
|
||||
}
|
||||
|
||||
CJSContextScope* CJSContext::CreateContextScope()
|
||||
{
|
||||
CJSContextScope* pScope = new CJSContextScope();
|
||||
JSValue* global_js = [m_internal->context globalObject];
|
||||
[global_js setValue:global_js forProperty:[[NSString alloc] initWithUTF8String:"window"]];
|
||||
return pScope;
|
||||
}
|
||||
|
||||
CJSLocalScope* CJSContext::CreateLocalScope()
|
||||
{
|
||||
return new CJSLocalScope();
|
||||
}
|
||||
|
||||
CJSValue* CJSContext::createUndefined()
|
||||
{
|
||||
CJSValueJSC* _value = new CJSValueJSC();
|
||||
@ -380,7 +355,7 @@ namespace NSJSBase
|
||||
free(data);
|
||||
}
|
||||
|
||||
CJSContext* CJSContext::GetCurrent()
|
||||
JSSmart<CJSContext> CJSContext::GetCurrent()
|
||||
{
|
||||
CJSContext* ret = new CJSContext();
|
||||
ret->m_internal->context = NSJSBase::CJSContextPrivate::GetCurrentContext();
|
||||
@ -419,6 +394,32 @@ namespace NSJSBase
|
||||
m_internal->m_arThreads.push_back((NULL == id) ? NSThreads::GetCurrentThreadId() : *id);
|
||||
}
|
||||
}
|
||||
|
||||
void CJSContext::Enter()
|
||||
{
|
||||
}
|
||||
|
||||
void CJSContext::Exit()
|
||||
{
|
||||
}
|
||||
|
||||
class CJSLocalScopePrivate
|
||||
{
|
||||
public:
|
||||
CJSLocalScopePrivate()
|
||||
{
|
||||
}
|
||||
~CJSLocalScopePrivate()
|
||||
{
|
||||
}
|
||||
};
|
||||
CJSLocalScope::CJSLocalScope() : m_internal(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
CJSLocalScope::~CJSLocalScope()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
namespace NSJSBase
|
||||
|
||||
@ -1,28 +0,0 @@
|
||||
#include "channel.h"
|
||||
|
||||
NSJSBase::v8_debug::internal::CInspectorChannel::CInspectorChannel(sendDataCallback sendData)
|
||||
: m_SendData(std::move(sendData))
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CInspectorChannel::sendResponse(int callId
|
||||
, std::unique_ptr<v8_inspector::StringBuffer> message)
|
||||
{
|
||||
if (message) {
|
||||
m_SendData(message->string());
|
||||
}
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CInspectorChannel::sendNotification(
|
||||
std::unique_ptr<v8_inspector::StringBuffer> message)
|
||||
{
|
||||
if (message) {
|
||||
m_SendData(message->string());
|
||||
}
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CInspectorChannel::flushProtocolNotifications()
|
||||
{
|
||||
//do nothing
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
#ifndef CHANNEL_H
|
||||
#define CHANNEL_H
|
||||
|
||||
#include <v8-inspector.h>//v8_inspector stuff
|
||||
#include <functional>//std::function
|
||||
|
||||
namespace NSJSBase {
|
||||
namespace v8_debug {
|
||||
namespace internal {
|
||||
//class that sends messages to frontend
|
||||
class CInspectorChannel : public v8_inspector::V8Inspector::Channel
|
||||
{
|
||||
public:
|
||||
using sendDataCallback = std::function<void(const v8_inspector::StringView&)>;
|
||||
|
||||
private:
|
||||
sendDataCallback m_SendData{};
|
||||
|
||||
public:
|
||||
CInspectorChannel(sendDataCallback sendData);
|
||||
|
||||
//send message to frontend through socket
|
||||
virtual void sendResponse(int callId,
|
||||
std::unique_ptr<v8_inspector::StringBuffer> message) override;
|
||||
virtual void sendNotification(std::unique_ptr<v8_inspector::StringBuffer> message) override;
|
||||
|
||||
//may do nothing
|
||||
virtual void flushProtocolNotifications() override;
|
||||
};
|
||||
|
||||
}//namespace internal
|
||||
}//namespace v8_debug
|
||||
}//namespace NSJSBase
|
||||
|
||||
#endif // CHANNEL_H
|
||||
@ -1,256 +0,0 @@
|
||||
#include "client.h"
|
||||
#include "channel.h"//client holds channel
|
||||
#include "singlethreadutils.h"//converting strings
|
||||
#include <libplatform/libplatform.h>//v8::Platform
|
||||
#include "inspector_impl.h"//to interact with inspector
|
||||
#include <iostream>//std::cout
|
||||
|
||||
namespace {
|
||||
//use it in loop
|
||||
class TrueSetter {
|
||||
bool &m_bool;
|
||||
public:
|
||||
TrueSetter(bool &b) : m_bool(b) {m_bool = true;}
|
||||
~TrueSetter() {m_bool = false;}
|
||||
};
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CInspectorClient::setUpDebuggingSession(
|
||||
const std::string &contextName
|
||||
)
|
||||
{
|
||||
//client instance is this
|
||||
|
||||
//channel
|
||||
m_pChannel = std::make_unique<CInspectorChannel>(
|
||||
[this](const v8_inspector::StringView &message) {
|
||||
m_pInspectingWrapper->sendData(message);
|
||||
}
|
||||
);
|
||||
|
||||
//inspector
|
||||
m_pInspector = v8_inspector::V8Inspector::create(m_pIsolate, this);
|
||||
|
||||
//state for session
|
||||
v8_inspector::StringView state{};
|
||||
|
||||
//session
|
||||
m_pSession = m_pInspector->connect(m_iContextGroupId, m_pChannel.get(), state);
|
||||
|
||||
//register context in v8 inspector
|
||||
m_pInspector->contextCreated({m_Context, m_iContextGroupId, strToView(contextName)});
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CInspectorClient::pumpPlatform()
|
||||
{
|
||||
while (v8::platform::PumpMessageLoop(m_pPlatform, m_pIsolate)) {
|
||||
//just pump until pumped
|
||||
}
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CInspectorClient::runMessageLoopOnPause(
|
||||
int
|
||||
) {
|
||||
//no nested calls
|
||||
if (m_bPause) {
|
||||
return;
|
||||
}
|
||||
|
||||
TrueSetter f(m_bPause);
|
||||
|
||||
while (m_bPause) {
|
||||
//while not paused by cdt or cdt disconnected
|
||||
if (
|
||||
!m_pInspectingWrapper->waitForMessage()
|
||||
) {
|
||||
break;
|
||||
}
|
||||
//
|
||||
pumpPlatform();
|
||||
}
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CInspectorClient::quitMessageLoopOnPause() {
|
||||
m_bPause = false;
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CInspectorClient::processFrontendMessage(
|
||||
const std::string &message
|
||||
)
|
||||
{
|
||||
//send message to V8 internals
|
||||
dispatchProtocolMessage(message);
|
||||
//check it for notable stuff
|
||||
checkFrontendMessage(message);
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CInspectorClient::checkFrontendMessage(const std::string &message)
|
||||
{
|
||||
std::string method = getMethod(m_Context, message);
|
||||
|
||||
//если сервер не готов - смотрим сообщение о готовности
|
||||
if (!m_bServerReady) {
|
||||
if (serverReadyMessage == method) {
|
||||
m_bServerReady = true;
|
||||
m_pInspectingWrapper->onServerReady();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//если пауза поставлена из v8, то ничего не смотрим
|
||||
if (!m_bMySessionPause) {
|
||||
return;
|
||||
}
|
||||
|
||||
//3
|
||||
//ждём первого сообщения о постановке/снятии брейкпойнта
|
||||
//остальные придут на паузе
|
||||
//если Runtime.getProperties пришёл до этого, снимаемся с паузы
|
||||
if (m_bBreakpointAdded) {
|
||||
if (isBreakpointAlterMethod(method)) {
|
||||
m_bBreakpointAlterMethodCame = true;
|
||||
if (m_bResumeOnBreakpointCame) {
|
||||
return resumeDebuggingSession();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//1
|
||||
//если пришёл Debugger.setBreakpointsActive
|
||||
if (activateBreakpointsMethod == method) {
|
||||
//и active == true
|
||||
if (isActiveTrue(message)) {
|
||||
//ставим флаг, что ждём изменения брейкпойнтов
|
||||
m_bBreakpointAdded = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//функции вызываются чаще, первыми проверяем их
|
||||
if (funcResumeMessageLate == method) {
|
||||
//если ждём изменения брейкпойнтов, запоминаем, что Runtime.getProperties пришёл
|
||||
if (m_bBreakpointAdded) {
|
||||
m_bResumeOnBreakpointCame = true;
|
||||
//если сообщение об изменении брейкпойнтов пришло до этого, снимаемся с паузы
|
||||
if (m_bBreakpointAlterMethodCame) {
|
||||
return resumeDebuggingSession();
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
return resumeDebuggingSession();
|
||||
}
|
||||
}
|
||||
|
||||
//проверяем скрипт
|
||||
if (scriptResumeMessage == method) {
|
||||
return resumeDebuggingSession();
|
||||
}
|
||||
}
|
||||
|
||||
NSJSBase::v8_debug::internal::CInspectorClient::~CInspectorClient() {
|
||||
//если не релизить, она дважды удаляется, и программа падает на выходе
|
||||
m_pSession.release();
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CInspectorClient::maybeLogIncoming(
|
||||
const std::string &message) const
|
||||
{
|
||||
if (!m_bLog) {
|
||||
return;
|
||||
}
|
||||
//log incoming message
|
||||
logCdtMessage(std::cout, message);
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CInspectorClient::pauseOnNextStatement()
|
||||
{
|
||||
m_bMySessionPause = true;
|
||||
m_pSession->schedulePauseOnNextStatement(strToView("other"), {});
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CInspectorClient::resumeDebuggingSession()
|
||||
{
|
||||
//manual pause setting flag
|
||||
m_bMySessionPause = false;
|
||||
|
||||
//breakpoint altering flags
|
||||
m_bBreakpointAdded = false;
|
||||
m_bBreakpointAlterMethodCame = false;
|
||||
m_bResumeOnBreakpointCame = false;
|
||||
|
||||
m_pSession->resume();
|
||||
}
|
||||
|
||||
bool NSJSBase::v8_debug::internal::CInspectorClient::isBreakpointAlterMethod(const std::string &method)
|
||||
{
|
||||
return method == setBreakpointMethod || method == removeBreakpointMethod;
|
||||
}
|
||||
|
||||
bool NSJSBase::v8_debug::internal::CInspectorClient::isActiveTrue(const std::string &message)
|
||||
{
|
||||
v8::Local<v8::Value> params = getJsonProperty(m_Context, message, "params");
|
||||
if (params.IsEmpty()) {
|
||||
return false;
|
||||
}
|
||||
if (!params->IsObject()) {
|
||||
return false;
|
||||
}
|
||||
v8::MaybeLocal<v8::Object> maybeObj = params->ToObject(m_Context);
|
||||
if (maybeObj.IsEmpty()) {
|
||||
return false;
|
||||
}
|
||||
v8::Local<v8::Object> obj = maybeObj.ToLocalChecked();
|
||||
v8::Local<v8::Value> active = getJsonPropertyImpl(m_Context, obj, "active");
|
||||
if (active.IsEmpty()) {
|
||||
return false;
|
||||
}
|
||||
if (!active->IsBoolean()){
|
||||
return false;
|
||||
}
|
||||
v8::MaybeLocal<v8::Boolean> maybeBool = active->ToBoolean(m_Context);
|
||||
if (maybeBool.IsEmpty()) {
|
||||
return false;
|
||||
}
|
||||
v8::Local<v8::Boolean> result = maybeBool.ToLocalChecked();
|
||||
return result->IsTrue();
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CInspectorClient::dispatchProtocolMessage(
|
||||
const std::string &message)
|
||||
{
|
||||
maybeLogIncoming(message);
|
||||
m_pSession->dispatchProtocolMessage(strToView(message));
|
||||
}
|
||||
|
||||
NSJSBase::v8_debug::internal::CInspectorClient::CInspectorClient(
|
||||
//for v8 inspector
|
||||
v8::Local<v8::Context> context,
|
||||
//for cdt
|
||||
const std::string &contextName
|
||||
//somewhat
|
||||
, int contextGroupId
|
||||
//to pump platform on pause
|
||||
, v8::Platform *platform
|
||||
//to interact with inspector, which holds client
|
||||
, CInspectorImpl *inspector
|
||||
//
|
||||
, bool log
|
||||
)
|
||||
|
||||
//v8 stuff
|
||||
: m_Context{context}
|
||||
, m_pIsolate{m_Context->GetIsolate()}
|
||||
, m_pPlatform{platform}
|
||||
|
||||
//callbacks
|
||||
, m_pInspectingWrapper{inspector}
|
||||
|
||||
//logging
|
||||
, m_bLog(log)
|
||||
|
||||
//somewhat
|
||||
, m_iContextGroupId{contextGroupId}
|
||||
{
|
||||
setUpDebuggingSession(contextName);
|
||||
}
|
||||
@ -1,126 +0,0 @@
|
||||
#ifndef CLIENT_H
|
||||
#define CLIENT_H
|
||||
|
||||
#include <v8-inspector.h>//v8_inspector stuff
|
||||
#include "channel.h"//CChannel for debug session
|
||||
|
||||
namespace NSJSBase {
|
||||
namespace v8_debug {
|
||||
namespace internal {
|
||||
|
||||
//inspector holds client, but instead of using callbacks client directly accesses inspector
|
||||
//it's safe due to inspector and client living in the same thread
|
||||
//and inspector managing lifetime of client, but not vice versa
|
||||
class CInspectorImpl;
|
||||
|
||||
//class that is intended to synchronously consume frontend messages on pause
|
||||
//it also sets up the debugging session
|
||||
class CInspectorClient : public v8_inspector::V8InspectorClient
|
||||
{
|
||||
//notable cdt messages
|
||||
static constexpr char serverReadyMessage[32] {"Runtime.runIfWaitingForDebugger"};
|
||||
|
||||
static constexpr char scriptResumeMessage[25] {"Debugger.getScriptSource"};
|
||||
|
||||
static constexpr char funcResumeMessageEarly[35] {"Overlay.setPausedInDebuggerMessage"};
|
||||
static constexpr char funcResumeMessageLate[22] {"Runtime.getProperties"};
|
||||
|
||||
static constexpr char activateBreakpointsMethod[30] {"Debugger.setBreakpointsActive"};
|
||||
static constexpr char setBreakpointMethod[23] {"Debugger.setBreakpoint"};
|
||||
static constexpr char removeBreakpointMethod[26] {"Debugger.removeBreakpoint"};
|
||||
static constexpr char getPossibleBreakpointsMethod[32] {"Debugger.getPossibleBreakpoints"};
|
||||
|
||||
//v8 stuff
|
||||
v8::Local<v8::Context> m_Context{};//to register context in inspector
|
||||
v8::Isolate *m_pIsolate{nullptr};//to create inspector
|
||||
v8::Platform *m_pPlatform{nullptr};//to pump platform on pause
|
||||
|
||||
//debug state
|
||||
bool m_bServerReady{false};
|
||||
bool m_bMySessionPause{false};
|
||||
|
||||
//debug session data
|
||||
std::unique_ptr<v8_inspector::V8Inspector> m_pInspector{nullptr};
|
||||
std::unique_ptr<v8_inspector::V8Inspector::Channel> m_pChannel{nullptr};
|
||||
std::unique_ptr<v8_inspector::V8InspectorSession> m_pSession{nullptr};
|
||||
|
||||
//сообщения об изменении брейкпойнтов могут приходить в любом порядке
|
||||
//поэтому вместо конечного автомата просто флаги
|
||||
bool m_bBreakpointAdded{false};
|
||||
bool m_bBreakpointAlterMethodCame{false};
|
||||
bool m_bResumeOnBreakpointCame{false};
|
||||
|
||||
//message loop flag
|
||||
bool m_bPause{false};
|
||||
|
||||
//to interact with superior class which holds all the stuff, including client
|
||||
CInspectorImpl *m_pInspectingWrapper{nullptr};
|
||||
|
||||
//log
|
||||
bool m_bLog{false};
|
||||
|
||||
//idk what is intended for
|
||||
const int m_iContextGroupId;
|
||||
|
||||
|
||||
//sets up a debugging session
|
||||
void setUpDebuggingSession(const std::string &contextName);
|
||||
|
||||
//pumps platform on pause
|
||||
void pumpPlatform();
|
||||
|
||||
//logs incoming message
|
||||
void maybeLogIncoming(const std::string &message) const;
|
||||
|
||||
//client's duty to send protocol messages to v8 internals
|
||||
void dispatchProtocolMessage(const std::string &message);
|
||||
|
||||
//check for pause flags
|
||||
void checkFrontendMessage(const std::string &message);
|
||||
|
||||
//
|
||||
void resumeDebuggingSession();
|
||||
|
||||
//
|
||||
bool isBreakpointAlterMethod(const std::string &method);
|
||||
bool isActiveTrue(const std::string &message);
|
||||
|
||||
public:
|
||||
CInspectorClient() = delete;
|
||||
CInspectorClient(const CInspectorClient&) = delete;
|
||||
CInspectorClient(CInspectorClient&&) = delete;
|
||||
CInspectorClient& operator=(const CInspectorClient&) = delete;
|
||||
CInspectorClient& operator=(CInspectorClient&&) = delete;
|
||||
|
||||
CInspectorClient(
|
||||
v8::Local<v8::Context> context,
|
||||
//for cdt
|
||||
const std::string &contextName
|
||||
//somewhat
|
||||
, int contextGroupId
|
||||
//to pump it
|
||||
, v8::Platform *platform
|
||||
//to interact with inspector, which holds client
|
||||
, CInspectorImpl *inspector
|
||||
//
|
||||
, bool log
|
||||
);
|
||||
|
||||
//api for v8 internals
|
||||
virtual void runMessageLoopOnPause(int contextGroupId) override;
|
||||
virtual void quitMessageLoopOnPause() override;
|
||||
|
||||
//dispatch and check message
|
||||
void processFrontendMessage(const std::string &message);
|
||||
|
||||
//api for inspector: schedule pause on next statement
|
||||
void pauseOnNextStatement();
|
||||
|
||||
~CInspectorClient();
|
||||
};
|
||||
|
||||
}//namespace internal
|
||||
}//namespace v8_debug
|
||||
}//namespace NSJSBase
|
||||
|
||||
#endif // CLIENT_H
|
||||
@ -0,0 +1,18 @@
|
||||
function main() {
|
||||
console.log('Hello, ChromeDevTools!');
|
||||
console.log("I heard you're an amazing tool! I'm here to play with you!");
|
||||
for (var i = 1; i <= 5; ++i) {
|
||||
console.log(i + " * " + i + " = " + i * i);
|
||||
}
|
||||
var a = 7;
|
||||
var b = 5;
|
||||
var c = a * b;
|
||||
console.log(a + " * " + b + " = " + c);
|
||||
}
|
||||
|
||||
var sayHi = function (name) {
|
||||
return "Hi, " + name;
|
||||
};
|
||||
|
||||
main();
|
||||
sayHi('Foo');
|
||||
@ -0,0 +1,76 @@
|
||||
#include "inspector.h"
|
||||
|
||||
#include "../v8_base.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace NSJSBase
|
||||
{
|
||||
|
||||
CInspector::CInspector(v8::Isolate* pIsolate, int nContextGroupId)
|
||||
: m_pIsolate(pIsolate)
|
||||
{
|
||||
m_pWebsocketServer.reset(
|
||||
new CWebSocketServer(
|
||||
std::bind(&CInspector::onMessage, this, std::placeholders::_1)
|
||||
)
|
||||
);
|
||||
m_pIspectorClient.reset(
|
||||
new CV8InspectorClientImpl(
|
||||
CV8Worker::getInitializer().getPlatform(),
|
||||
m_pIsolate,
|
||||
nContextGroupId,
|
||||
std::bind(&CInspector::sendMessage, this, std::placeholders::_1),
|
||||
std::bind(&CInspector::waitForFrontendMessage, this)
|
||||
)
|
||||
);
|
||||
m_pWebsocketServer->connect();
|
||||
}
|
||||
|
||||
void CInspector::onMessage(std::string& sMessage)
|
||||
{
|
||||
v8::Local<v8::Object> oJsonObject = parseJson(m_pIsolate->GetCurrentContext(), sMessage);
|
||||
|
||||
if (!oJsonObject.IsEmpty())
|
||||
{
|
||||
std::string sMethod = getPropertyFromJson(m_pIsolate, oJsonObject, "method");
|
||||
if (sMethod == "Runtime.runIfWaitingForDebugger")
|
||||
{
|
||||
m_pWebsocketServer->isServerReady_ = true;
|
||||
}
|
||||
#ifdef V8_VERSION_89_PLUS
|
||||
|
||||
#else
|
||||
// In older version of V8 there is an eror "Either url or urlRegex must be specified." on trying to set a breakpoint in CDT.
|
||||
// So we have to specify it explicitly before "lineNumber" param
|
||||
else if (sMethod == "Debugger.setBreakpointByUrl" && sMessage.find("\"url") == sMessage.npos)
|
||||
{
|
||||
int pos = sMessage.find("\"lineNumber\"");
|
||||
sMessage.insert(pos, "\"url\":\"\",");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
v8_inspector::StringView oProtocolMessage = convertToStringView(sMessage);
|
||||
m_pIspectorClient->dispatchProtocolMessage(oProtocolMessage);
|
||||
}
|
||||
|
||||
void CInspector::sendMessage(const std::string& sMessage)
|
||||
{
|
||||
m_pWebsocketServer->sendMessage(sMessage);
|
||||
}
|
||||
|
||||
void CInspector::startAgent(bool bIsBreakOnStart)
|
||||
{
|
||||
if (bIsBreakOnStart)
|
||||
{
|
||||
m_pIspectorClient->schedulePauseOnNextStatement(convertToStringView("debugging"));
|
||||
}
|
||||
}
|
||||
|
||||
bool CInspector::waitForFrontendMessage()
|
||||
{
|
||||
m_pWebsocketServer->waitForFrontendMessageOnPause();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
#ifndef INSPECTOR_H
|
||||
#define INSPECTOR_H
|
||||
|
||||
#include "websocket_server.h"
|
||||
#include "v8_inspector_client.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
// To use inspector set V8_USE_INSPECTOR environment variable to any non-zero value
|
||||
// Unset V8_USE_INSPECTOR or set it to '0' for disabling the inspector
|
||||
|
||||
|
||||
// Inspector code structure based on "V8 Inspector simple examle" from this repository:
|
||||
// https://github.com/ahmadov/v8_inspector_example
|
||||
|
||||
namespace NSJSBase
|
||||
{
|
||||
|
||||
class CInspector
|
||||
{
|
||||
private:
|
||||
// pointer to V8 isolate in which scripts/functions are executed
|
||||
v8::Isolate* m_pIsolate;
|
||||
|
||||
std::unique_ptr<CWebSocketServer> m_pWebsocketServer;
|
||||
std::unique_ptr<CV8InspectorClientImpl> m_pIspectorClient;
|
||||
|
||||
private:
|
||||
void onMessage(std::string& sMessage);
|
||||
void sendMessage(const std::string& sMessage);
|
||||
bool waitForFrontendMessage();
|
||||
|
||||
public:
|
||||
CInspector(v8::Isolate* pIsolate, int nContextGroupId);
|
||||
|
||||
void startAgent(bool bIsBreakOnStart = true);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // INSPECTOR_H
|
||||
@ -0,0 +1,31 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
TARGET = test
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
CONFIG += core_static_link_libstd
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../../../../core
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
############### destination path ###############
|
||||
DESTDIR = $$PWD/build
|
||||
################################################
|
||||
|
||||
ADD_DEPENDENCY(kernel, UnicodeConverter, doctrenderer)
|
||||
|
||||
core_linux {
|
||||
LIBS += -Wl,-unresolved-symbols=ignore-in-shared-libs
|
||||
LIBS += -ldl
|
||||
}
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
||||
# cout logs
|
||||
DEFINES += LOG_TO_COUT
|
||||
@ -1,119 +0,0 @@
|
||||
#include "inspector_impl.h"
|
||||
#include <iostream>//std::cout
|
||||
#include "singlethreadutils.h"//string conversion
|
||||
|
||||
bool NSJSBase::v8_debug::internal::CInspectorImpl::initServer()
|
||||
{
|
||||
//set on message callback
|
||||
auto messageCallback = [this](const std::string &message) {
|
||||
if (!message.empty()) {
|
||||
m_Client.processFrontendMessage(message);
|
||||
}
|
||||
};
|
||||
m_Server.setOnMessageCallback(messageCallback);
|
||||
|
||||
//listen
|
||||
return m_Server.listen();
|
||||
}
|
||||
|
||||
bool NSJSBase::v8_debug::internal::CInspectorImpl::connectServer()
|
||||
{
|
||||
printChromeLaunchHint(std::cout, m_Server.port());
|
||||
return m_Server.waitForConnection();
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CInspectorImpl::waitWhileServerReady()
|
||||
{
|
||||
m_Server.run();
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CInspectorImpl::maybeLogOutgoing(
|
||||
const std::string &message) const
|
||||
{
|
||||
if (!m_bLog) {
|
||||
return;
|
||||
}
|
||||
logOutgoingMessage(std::cout, message);
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CInspectorImpl::printChromeLaunchHint(
|
||||
std::ostream &out
|
||||
, uint16_t port)
|
||||
{
|
||||
out << "chrome "
|
||||
<< "--remote-debugging-port=9222 "
|
||||
<< "http://localhost:9222/devtools/inspector.html?ws=localhost:"
|
||||
<< port
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CInspectorImpl::sendData(const v8_inspector::StringView &message)
|
||||
{
|
||||
//не отправляем пустые сообщения
|
||||
if (message.length() == 0) {
|
||||
return;
|
||||
}
|
||||
std::string str = internal::viewToStr(
|
||||
m_pIsolate
|
||||
, message);
|
||||
//
|
||||
maybeLogOutgoing(str);
|
||||
//
|
||||
this->m_Server.sendData(str);
|
||||
}
|
||||
|
||||
bool NSJSBase::v8_debug::internal::CInspectorImpl::waitForMessage()
|
||||
{
|
||||
return m_Server.waitAndProcessMessage();
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CInspectorImpl::onServerReady()
|
||||
{
|
||||
//когда сервак готов, ставим его на паузу и идём дальше по плюсовому коду
|
||||
m_Server.pause();
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CInspectorImpl::prepareServer()
|
||||
{
|
||||
//ждём, когда юзер законнектится
|
||||
if (!connectServer()) {
|
||||
return;
|
||||
}
|
||||
//прокидываем первые неинтересные сообщения
|
||||
waitWhileServerReady();
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CInspectorImpl::beforeLaunch()
|
||||
{
|
||||
//перед запуском кода ставим паузу в его начале
|
||||
m_Client.pauseOnNextStatement();
|
||||
}
|
||||
|
||||
NSJSBase::v8_debug::internal::CInspectorImpl::CInspectorImpl(
|
||||
//
|
||||
v8::Local<v8::Context> context
|
||||
//platform to pump
|
||||
, v8::Platform *platform
|
||||
//
|
||||
, uint16_t port
|
||||
, int contextGroupId
|
||||
, const std::string &contextName
|
||||
, bool log
|
||||
)
|
||||
: m_Server{port}
|
||||
, m_pIsolate{context->GetIsolate()}
|
||||
, m_bLog{log}
|
||||
, m_Client{context, contextName, contextGroupId, platform, this, log}
|
||||
{
|
||||
//аттачим acceptor к эндпойнту прямо в конструкторе
|
||||
if (!initServer()) {
|
||||
std::cerr << "server can't listen to incoming connections" << std::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
NSJSBase::v8_debug::internal::CInspectorImpl::~CInspectorImpl() {
|
||||
if (m_Server.listening() && m_Server.connected()) {
|
||||
m_Server.shutdown();
|
||||
}
|
||||
}
|
||||
@ -1,78 +0,0 @@
|
||||
#ifndef INSPECTOR_IMPL_H
|
||||
#define INSPECTOR_IMPL_H
|
||||
|
||||
//здесь лежат бустовые хедеры, он должен быть включён выше всех
|
||||
#include "singleconnectionserver.h"//CSingleConnectionServer
|
||||
#include "client.h"//inspector is what holds client
|
||||
|
||||
namespace NSJSBase {
|
||||
namespace v8_debug {
|
||||
namespace internal {
|
||||
|
||||
class CInspectorImpl
|
||||
{
|
||||
//server
|
||||
CSingleConnectionServer m_Server;
|
||||
|
||||
//to convert v8 string view to string
|
||||
v8::Isolate *m_pIsolate{nullptr};// для viewToStr
|
||||
|
||||
//logging protocol messages
|
||||
bool m_bLog{false};
|
||||
|
||||
//сам клиент
|
||||
CInspectorClient m_Client;
|
||||
|
||||
|
||||
|
||||
//сервер
|
||||
bool initServer();
|
||||
bool connectServer();
|
||||
void waitWhileServerReady();
|
||||
|
||||
//logging and hints
|
||||
void maybeLogOutgoing(const std::string &message) const;
|
||||
void printChromeLaunchHint(std::ostream &out
|
||||
, uint16_t port);
|
||||
|
||||
public:
|
||||
//explicitly delete all the stuff
|
||||
CInspectorImpl(const CInspectorImpl&) = delete;
|
||||
CInspectorImpl(CInspectorImpl&&) = delete;
|
||||
CInspectorImpl& operator=(const CInspectorImpl&) = delete;
|
||||
CInspectorImpl& operator=(CInspectorImpl&&) = delete;
|
||||
|
||||
//only allowed ctor
|
||||
CInspectorImpl(
|
||||
//context for client
|
||||
v8::Local<v8::Context> context
|
||||
//platform to pump
|
||||
, v8::Platform *platform
|
||||
//port to connect to
|
||||
, uint16_t port
|
||||
//some stuff for cdt and v8 internals
|
||||
, int contextGroupId
|
||||
, const std::string &contextName
|
||||
//
|
||||
, bool log
|
||||
);
|
||||
|
||||
//api for inspector client
|
||||
void sendData(const v8_inspector::StringView &message);
|
||||
bool waitForMessage();
|
||||
void onServerReady();
|
||||
|
||||
//necessary to call before using inspector
|
||||
void prepareServer();
|
||||
|
||||
//before debugged code
|
||||
void beforeLaunch();
|
||||
|
||||
~CInspectorImpl();
|
||||
};
|
||||
|
||||
}//namespace internal
|
||||
}//namespace v8_debug
|
||||
}//namespace NSJSBase
|
||||
|
||||
#endif // INSPECTOR_IMPL_H
|
||||
@ -1,12 +0,0 @@
|
||||
#include "inspector_interface.h"
|
||||
#include "inspector_pool.h"//to get inspectors
|
||||
|
||||
void NSJSBase::v8_debug::before(const v8::Local<v8::Context> &context
|
||||
, v8::Platform *platform
|
||||
, const std::string &contextName) {
|
||||
internal::CInspectorPool::get().getInspector(context, platform, contextName).beforeLaunch();
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::disposeInspector(const v8::Local<v8::Context> &context) {
|
||||
internal::CInspectorPool::get().disposeInspector(context);
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
#ifndef INSPECTOR_INTERFACE_H
|
||||
#define INSPECTOR_INTERFACE_H
|
||||
|
||||
#include <v8.h>
|
||||
|
||||
//simplified to the limit interface
|
||||
//also required to avoid cyclic dependency
|
||||
|
||||
namespace NSJSBase {
|
||||
namespace v8_debug {
|
||||
|
||||
void before(const v8::Local<v8::Context> &context, v8::Platform *platform, const std::string &contextName);
|
||||
void disposeInspector(const v8::Local<v8::Context> &context);
|
||||
|
||||
}//namespace v8_debug
|
||||
}//namespace NSJSBase
|
||||
|
||||
#endif // INSPECTOR_INTERFACE_H
|
||||
@ -1,68 +1,55 @@
|
||||
#include "inspector_pool.h"
|
||||
|
||||
NSJSBase::v8_debug::internal::CInspectorPool::CInspectorPool() = default;
|
||||
#include "../v8_base.h"
|
||||
|
||||
NSJSBase::v8_debug::internal::CInspectorPool::~CInspectorPool() = default;
|
||||
|
||||
NSJSBase::v8_debug::internal::CInspectorImpl&
|
||||
NSJSBase::v8_debug::internal::CInspectorPool::addInspector(v8::Local<v8::Context> context
|
||||
, v8::Platform *platform
|
||||
, const std::string &contextName)
|
||||
namespace NSJSBase
|
||||
{
|
||||
std::pair<storage_t::iterator, bool> result = m_Inspectors.emplace(
|
||||
std::piecewise_construct
|
||||
, std::forward_as_tuple(context)
|
||||
, std::forward_as_tuple(
|
||||
context
|
||||
, platform
|
||||
, getPort()
|
||||
, getContextGroupId()
|
||||
, contextName
|
||||
, m_bLog
|
||||
)
|
||||
);
|
||||
CInspectorImpl &inspector = result.first->second;
|
||||
inspector.prepareServer();
|
||||
return inspector;
|
||||
}
|
||||
|
||||
uint16_t NSJSBase::v8_debug::internal::CInspectorPool::getPort()
|
||||
{
|
||||
static std::atomic<uint16_t> initialPort{8080};
|
||||
return initialPort++;
|
||||
}
|
||||
CInspector& CInspectorPool::addInspector(v8::Isolate* pIsolate)
|
||||
{
|
||||
std::pair<storage_t::iterator, bool> result = m_Inspectors.emplace(
|
||||
std::piecewise_construct
|
||||
, std::forward_as_tuple(pIsolate)
|
||||
, std::forward_as_tuple(
|
||||
pIsolate
|
||||
, getContextGroupId()
|
||||
)
|
||||
);
|
||||
CInspector& oInspector = result.first->second;
|
||||
return oInspector;
|
||||
}
|
||||
|
||||
int NSJSBase::v8_debug::internal::CInspectorPool::getContextGroupId()
|
||||
{
|
||||
static std::atomic<int> initialId{1};
|
||||
return initialId++;
|
||||
}
|
||||
int CInspectorPool::getContextGroupId()
|
||||
{
|
||||
static int nInitialId{1};
|
||||
return nInitialId++;
|
||||
}
|
||||
|
||||
NSJSBase::v8_debug::internal::CInspectorImpl&
|
||||
NSJSBase::v8_debug::internal::CInspectorPool::getInspector(v8::Local<v8::Context> context
|
||||
, v8::Platform *platform
|
||||
, const std::string &contextName)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock{m_Mutex};
|
||||
storage_t::iterator iter = m_Inspectors.find(context);
|
||||
if (m_Inspectors.end() == iter) {
|
||||
return addInspector(context, platform, contextName);
|
||||
}
|
||||
return iter->second;
|
||||
}
|
||||
CInspector&
|
||||
CInspectorPool::getInspector(v8::Isolate* pIsolate)
|
||||
{
|
||||
storage_t::iterator iter = m_Inspectors.find(pIsolate);
|
||||
if (iter == m_Inspectors.end())
|
||||
{
|
||||
return addInspector(pIsolate);
|
||||
}
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CInspectorPool::disposeInspector(v8::Local<v8::Context> context)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock{m_Mutex};
|
||||
storage_t::iterator iter = m_Inspectors.find(context);
|
||||
if (m_Inspectors.end() != iter) {
|
||||
m_Inspectors.erase(iter);
|
||||
}
|
||||
}
|
||||
void CInspectorPool::disposeInspector(v8::Isolate* pIsolate)
|
||||
{
|
||||
storage_t::iterator iter = m_Inspectors.find(pIsolate);
|
||||
if (m_Inspectors.end() != iter)
|
||||
{
|
||||
m_Inspectors.erase(iter);
|
||||
}
|
||||
}
|
||||
|
||||
CInspectorPool&
|
||||
CInspectorPool::get()
|
||||
{
|
||||
static CInspectorPool oPool;
|
||||
return oPool;
|
||||
}
|
||||
|
||||
NSJSBase::v8_debug::internal::CInspectorPool&
|
||||
NSJSBase::v8_debug::internal::CInspectorPool::get()
|
||||
{
|
||||
static CInspectorPool pool;
|
||||
return pool;
|
||||
}
|
||||
|
||||
@ -1,64 +1,43 @@
|
||||
#ifndef CINSPECTORPOOL_H
|
||||
#define CINSPECTORPOOL_H
|
||||
#ifndef INSPECTOR_POOL_H
|
||||
#define INSPECTOR_POOL_H
|
||||
|
||||
#include "inspector_impl.h"//inspector itself
|
||||
#include <map>//to hold inspectors
|
||||
#include <mutex>//may be used in multithread environment
|
||||
#include "inspector.h"
|
||||
|
||||
namespace NSJSBase {
|
||||
namespace v8_debug {
|
||||
namespace internal {
|
||||
#include <unordered_map>
|
||||
|
||||
class CInspectorPool
|
||||
namespace NSJSBase
|
||||
{
|
||||
struct ContextLess
|
||||
{
|
||||
inline bool operator()(const v8::Local<v8::Context> &lhs, const v8::Local<v8::Context> &rhs) const {
|
||||
if (lhs == rhs) {
|
||||
return false;
|
||||
}
|
||||
return std::less<v8::Context*>{}(*lhs, *rhs);
|
||||
}
|
||||
};
|
||||
using storage_t = std::map<v8::Local<v8::Context>, CInspectorImpl, ContextLess>;
|
||||
|
||||
std::mutex m_Mutex{};
|
||||
storage_t m_Inspectors{};
|
||||
class CInspectorPool
|
||||
{
|
||||
using storage_t = std::unordered_map<v8::Isolate*, CInspector>;
|
||||
|
||||
static constexpr bool m_bLog{false};
|
||||
storage_t m_Inspectors;
|
||||
|
||||
//добавить новый инспектор
|
||||
CInspectorImpl& addInspector(v8::Local<v8::Context> context
|
||||
, v8::Platform *platform
|
||||
, const std::string &contextName);
|
||||
// add new inspector
|
||||
CInspector& addInspector(v8::Isolate* pIsolate);
|
||||
|
||||
//порт для сервака, id для v8
|
||||
static uint16_t getPort();
|
||||
static int getContextGroupId();
|
||||
// group id for V8 internals
|
||||
static int getContextGroupId();
|
||||
|
||||
//всё приватное, синглтон по классике
|
||||
CInspectorPool();
|
||||
~CInspectorPool();
|
||||
// private due to singleton pattern
|
||||
CInspectorPool() = default;
|
||||
~CInspectorPool() = default;
|
||||
|
||||
public:
|
||||
CInspectorPool(const CInspectorPool&) = delete;
|
||||
CInspectorPool(CInspectorPool&&) = delete;
|
||||
CInspectorPool& operator=(const CInspectorPool&) = delete;
|
||||
CInspectorPool& operator=(CInspectorPool&&) = delete;
|
||||
public:
|
||||
CInspectorPool(const CInspectorPool&) = delete;
|
||||
CInspectorPool(CInspectorPool&&) = delete;
|
||||
CInspectorPool& operator=(const CInspectorPool&) = delete;
|
||||
CInspectorPool& operator=(CInspectorPool&&) = delete;
|
||||
|
||||
//инстанс пула
|
||||
static CInspectorPool& get();
|
||||
// get instance
|
||||
static CInspectorPool& get();
|
||||
// get inspector by isolate
|
||||
CInspector& getInspector(v8::Isolate* pIsolate);
|
||||
// remove inspector from isolate
|
||||
void disposeInspector(v8::Isolate* pIsolate);
|
||||
};
|
||||
|
||||
//достать инспектор для контекста
|
||||
CInspectorImpl& getInspector(v8::Local<v8::Context> context
|
||||
, v8::Platform *platform
|
||||
, const std::string &contextName);
|
||||
//удалить инспектор для контекста
|
||||
void disposeInspector(v8::Local<v8::Context> context);
|
||||
};
|
||||
}
|
||||
|
||||
}//namespace internal
|
||||
}//namespace v8_debug
|
||||
}//namespace NSJSBase
|
||||
|
||||
#endif // CINSPECTORPOOL_H
|
||||
#endif // INSPECTOR_POOL_H
|
||||
|
||||
@ -1,85 +1,109 @@
|
||||
#include "../v8_base.h"
|
||||
#include "inspector_impl.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//V8 INIT
|
||||
JSSmart<NSJSBase::CJSContext> pJSContext = new NSJSBase::CJSContext();
|
||||
pJSContext->Initialize();
|
||||
|
||||
{
|
||||
JSSmart<NSJSBase::CJSIsolateScope> isolate_scope = pJSContext->CreateIsolateScope();
|
||||
JSSmart<NSJSBase::CJSLocalScope> handle_scope = pJSContext->CreateLocalScope();
|
||||
|
||||
pJSContext->CreateGlobalForContext();
|
||||
pJSContext->CreateContext();
|
||||
|
||||
JSSmart<NSJSBase::CJSContextScope> context_scope = pJSContext->CreateContextScope();
|
||||
JSSmart<NSJSBase::CJSTryCatch> try_catch = pJSContext->GetExceptions();
|
||||
JSSmart<NSJSBase::CJSObject> global_js = pJSContext->GetGlobal();
|
||||
|
||||
//zero
|
||||
pJSContext->
|
||||
runScript(
|
||||
"var a = 1;\nvar b = 2;\nvar c = 3;\nvar d = 4;", try_catch
|
||||
);
|
||||
try_catch->Check();
|
||||
std::cout << "after zero\n";
|
||||
|
||||
|
||||
//one
|
||||
pJSContext->
|
||||
runScript(
|
||||
"function function_1() \n { \n return 1 + 2;\n }", try_catch
|
||||
);
|
||||
try_catch->Check();
|
||||
std::cout << "after one\n";
|
||||
|
||||
//two
|
||||
pJSContext->
|
||||
runScript(
|
||||
"function function_2()\n {\n return 100 + function_1(); \n}", try_catch
|
||||
);
|
||||
try_catch->Check();
|
||||
std::cout << "after two\n";
|
||||
|
||||
//three
|
||||
JSSmart<NSJSBase::CJSValue> js_result =
|
||||
global_js->call_func("function_1")
|
||||
;
|
||||
std::cout << "after three\n";
|
||||
|
||||
//four
|
||||
JSSmart<NSJSBase::CJSValue> js_result2 = global_js->call_func("function_2");
|
||||
std::cout << "after four\n";
|
||||
|
||||
std::cout << "function_1 = ";
|
||||
//check
|
||||
if (js_result.IsInit()){
|
||||
if (js_result->isNumber()) {
|
||||
std::cout << js_result->toInt32() << std::endl;
|
||||
} else {
|
||||
std::cout << "no result\n";
|
||||
}
|
||||
} else {
|
||||
std::cout << "result not init\n";
|
||||
}
|
||||
|
||||
|
||||
std::cout << "function_2 = ";
|
||||
//check
|
||||
if (js_result.IsInit()){
|
||||
if (js_result2->isNumber()) {
|
||||
std::cout << js_result2->toInt32() << std::endl;
|
||||
} else {
|
||||
std::cout << "no result\n";
|
||||
}
|
||||
} else {
|
||||
std::cout << "result not init\n";
|
||||
}
|
||||
}
|
||||
|
||||
pJSContext->Dispose();
|
||||
NSJSBase::CJSContext::ExternalDispose();
|
||||
return 0;
|
||||
}
|
||||
#include "../../js_base.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
std::string readFileContent(const std::string& sFilename)
|
||||
{
|
||||
std::ifstream oFile(sFilename);
|
||||
if (!oFile.is_open())
|
||||
{
|
||||
std:: cerr << "Could not open the file: " << sFilename << std::endl;
|
||||
return "";
|
||||
}
|
||||
std::string sContent((std::istreambuf_iterator<char>(oFile)), std::istreambuf_iterator<char>());
|
||||
return sContent;
|
||||
}
|
||||
|
||||
using namespace NSJSBase;
|
||||
int main()
|
||||
{
|
||||
JSSmart<CJSContext> pContext1 = new CJSContext();
|
||||
pContext1->CreateContext();
|
||||
|
||||
|
||||
JSSmart<CJSContext> pContext2 = new CJSContext();
|
||||
pContext2->CreateContext();
|
||||
|
||||
{
|
||||
CJSContextScope oScope(pContext1);
|
||||
|
||||
JSSmart<CJSValue> pRet = pContext1->runScript("var special = 42;\n"
|
||||
"special;\n");
|
||||
|
||||
{
|
||||
CJSContextScope oScope(pContext2);
|
||||
|
||||
|
||||
JSSmart<CJSValue> pRet = pContext2->runScript(readFileContent("../example/code.js"));
|
||||
|
||||
std::cout << "RESULT: ";
|
||||
if (pRet->isString())
|
||||
{
|
||||
std::cout << pRet->toStringA() << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "ERROR!" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "RESULT: ";
|
||||
if (pRet->isNumber())
|
||||
{
|
||||
std::cout << pRet->toInt32() << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "ERROR!" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
CJSContextScope oScope(pContext1);
|
||||
|
||||
JSSmart<CJSValue> pRet = pContext1->runScript("function sayHi(name) {\n"
|
||||
" var a = special;\n"
|
||||
" var msg = 'Hi, ' + name;\n"
|
||||
" return msg;\n"
|
||||
"}\n"
|
||||
"sayHi('Foo');\n");
|
||||
pContext1->runScript("sayHi('Foo 2');\n");
|
||||
std::cout << "RESULT: ";
|
||||
if (pRet->isString())
|
||||
{
|
||||
std::cout << pRet->toStringA() << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "ERROR!" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
CJSContextScope oScope(pContext1);
|
||||
|
||||
JSSmart<CJSObject> pGlobal = pContext1->GetGlobal();
|
||||
JSSmart<CJSValue> argv[1];
|
||||
argv[0] = pContext1->createString("Bar");
|
||||
JSSmart<CJSValue> pRet = pGlobal->call_func("sayHi", 1, argv);
|
||||
|
||||
std::cout << "RESULT: ";
|
||||
if (pRet->isString())
|
||||
{
|
||||
std::cout << pRet->toStringA() << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "ERROR!" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
pContext1->Dispose();
|
||||
std::cout << "AFTER CONTEXT1 DISPOSE" << std::endl;
|
||||
pContext2->Dispose();
|
||||
std::cout << "AFTER CONTEXT2 DISPOSE" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1,62 +0,0 @@
|
||||
Классы v8-инспектора - это CInspectorClient (client) и CInspectorChannel (channel).
|
||||
Channel нужен для передачи сообщений на фронтенд и не представляет собой ничего интересного.
|
||||
Базовые функции клиента заключаются в том, чтобы синхронно принимать сообщения с фронтенда,
|
||||
когда JS стоит на паузе (runMessageLoopOnPause), а также сниматься с паузы (quitMessageLoopOnPause).
|
||||
Вся логика создания v8 debug session реализована на клиенте в функции setUpDebuggingSession, потому что так удобнее.
|
||||
Там создаётся channel, далее создаётся v8-inspector, для этого ему нужен isolate и client.
|
||||
Далее создаётся V8InspectorSession. Контекст, в котором создан client, регистрируется на инспекторе.
|
||||
Кроме всего этого, нужно отправлять входящие с сервера сообщения на v8 (V8InspectorSession::dispatchProtocolMessage).
|
||||
Этим также занимается client, раз уж V8InspectorSession лежит в нём.
|
||||
Класс CInspectorImpl - это обёртка вокруг клиента, в которой реализована дополнительная логика.
|
||||
Во-первых, там лежит клиент, в котором лежит всё, что напрямую касается v8-инспектора.
|
||||
Во-вторых, там лежит сервер, к которому подключается Chrome Developer Tools и через который происходит обмен сообщениями.
|
||||
Сервер умеет отправлять сообщения, ждать одного сообщения, а также входить и выходить из message loop (последнее на практике почти не используется).
|
||||
CInspectorPool - это синглтон, который хранит в себе CInspectorImpl - по одному на v8::Context.
|
||||
inspector_interface.h - это просто обёртка вокруг CInspectorPool без лишних #include,
|
||||
что позволяет гарантированно избегать циклических зависомостей в заголовках.
|
||||
Также он умеет удалять их.
|
||||
Singlethreadutils - это примитивы, необходимые для:
|
||||
- парсинга файлов (пережиток тестовых запусков);
|
||||
- логгирования сообщений;
|
||||
- преобразований между разными строками: std::string, v8::String и v8_inspector::StringView
|
||||
(это необходимо для взаимодействия между сервером, принимающим std::string, и v8, использующим свои строковые классы);
|
||||
- парсинга жсонов - это нужно, чтобы доставать из сообщений с фронтенда пересылаемые методы.
|
||||
Зачем нужно последнее, станет ясно чуть позже.
|
||||
|
||||
Работает это следующим образом.
|
||||
В самом начале, когда инспектор создаётся, на нём должен быть вызван prepareServer,
|
||||
который ждёт подключения Chrome Developer Tools (CDT) и после этого запускает message loop на сервере.
|
||||
Клиент ждёт, когда с сервера придёт сообщение Runtime.runIfWaitingForDebugger. Это свидетельствует о готовности CDT.
|
||||
После этого сервер выходит из message loop.
|
||||
Перед запуском скрипта или функции вызывается CInspectorImpl::beforeLaunch,
|
||||
который вызывает CInspectorClient::pauseOnNextStatement, который вызывает V8InspectorSession::schedulePauseOnNextStatement.
|
||||
Эта функция ставит галочку, что на следующем стейтменте нужно остановиться, и сразу возвращается.
|
||||
Пауза на первом стейтменте скрипта или функции нужна, чтобы они появились в CDT.
|
||||
Кроме того, клиент на этом моменте ставит флаг, что паузу он вызвал сам - это нужно в дальнейшем.
|
||||
Далее при запуске функции или скрипта он ставится на паузу, вызывается CInspectorClient::runMessageLoopOnPause,
|
||||
и начинается синхронный обмен сообщениями.
|
||||
Этот обмен нужно закончить, когда скрипт или функция появятся в CDT.
|
||||
В случае со скриптом индикатором этого является метод Debugger.getScriptSource, приходящий с сервера.
|
||||
В случае с функцией однозначного индикатора нет, используется метод Runtime.getProperties.
|
||||
Также возможно использование метода Overlay.setPausedInDebuggerMessage - обычно он приходит раньше, чем Runtime.getProperties,
|
||||
но этот вариант не протестирован.
|
||||
Проверка сообщений с сервера на наличие этих методов производится после их отправки на v8.
|
||||
В случае, если не стоит флаг о том, что пауза была вызвана с клиента, сообщения не проверяются вообще -
|
||||
это значит, что пауза вызвана пользователем (чаще всего это breakpoint или step into/over/out после брейкпойнта)
|
||||
и с неё не нужно сниматься автоматически.
|
||||
В случае, если пауза была вызвана клиентом, он мониторит входящие сообщения на предмет вышеописанных методов
|
||||
и вызывает V8InspectorSession::resume, если один из них приходит.
|
||||
После этого на CDT отправляется сообщение Debugger.resume, и JS-код дальше исполняется внутри v8.
|
||||
Если там есть где остановиться, v8 снова входит в runMessageLoopOnPause и отправляет на CDT Debugger.paused.
|
||||
Поскольку это пользовательская пауза, клиент не снимается с неё автоматически,
|
||||
а ждёт, пока пользователь снимется с неё через CDT.
|
||||
Когда JS-код полностью исполнен, продолжается выполнение C++-кода.
|
||||
Элементы v8-инспектора, которые лежат внутри клиента, нужно уничтожать до выхода из isolate scope и context scope.
|
||||
Если их уничтожать на выходе из программы, то она падает.
|
||||
Чтобы этого избежать, в CJSContext::dispose вызывается CInspectorPool::disposeContext, который находит CInspectorImpl,
|
||||
созданный для уничтожаемого контекста, и удаляет его.
|
||||
Каждый сервер, а следовательно, каждый CInspectorImpl, требует порт.
|
||||
CInspectorImpl создаётся на каждый контекст (хотя было бы правильнее на isolate, но здесь это не принципиально,
|
||||
потому что на isolate всегда только один контекст).
|
||||
Следовательно, на каждый контекст выделяется порт.
|
||||
Порты начинаются с 8080.
|
||||
@ -1,282 +0,0 @@
|
||||
#include "singleconnectionserver.h"
|
||||
#include <iostream>//reporting errors
|
||||
|
||||
namespace ip = boost::asio::ip;
|
||||
namespace beast = boost::beast;
|
||||
|
||||
std::pair<std::string, beast::error_code>
|
||||
NSJSBase::v8_debug::internal::CSingleConnectionServer::getData()
|
||||
{
|
||||
//set up buffer
|
||||
beast::multi_buffer buffer;
|
||||
//to check for err
|
||||
beast::error_code errCode;
|
||||
//read into buffer; blocks here
|
||||
m_pWebsocketStream->read(buffer, errCode);
|
||||
//check for error
|
||||
if (errCode) {
|
||||
if (//cdt disconnection
|
||||
errCode == boost::asio::error::operation_aborted
|
||||
) {
|
||||
setDisconnected();
|
||||
return {std::string(), errCode};
|
||||
}
|
||||
reportError(errCode, "while reading");
|
||||
return {std::string(), errCode};
|
||||
}
|
||||
//set mode equal to incoming message mode
|
||||
m_pWebsocketStream->text(
|
||||
//returns true if socket got text message, false on binary
|
||||
m_pWebsocketStream->got_text()
|
||||
);
|
||||
//return value read
|
||||
return {boost::beast::buffers_to_string(buffer.data()), errCode};
|
||||
}
|
||||
|
||||
beast::error_code NSJSBase::v8_debug::internal::CSingleConnectionServer::discardData()
|
||||
{
|
||||
beast::flat_buffer buffer;//no need in multi buffer
|
||||
beast::error_code errCode;
|
||||
m_pWebsocketStream->read(buffer, errCode);
|
||||
return errCode;
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CSingleConnectionServer::reportError(
|
||||
const beast::error_code &code
|
||||
, const char *context) const
|
||||
{
|
||||
beast::error_code ec;
|
||||
std::cerr
|
||||
<< m_Endpoint.address().to_string(ec)
|
||||
<< ':'
|
||||
<< m_Endpoint.port()
|
||||
<< ": "
|
||||
<< context << ": error with code " << code << ": " << code.message() << std::endl;
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CSingleConnectionServer::setConnected()
|
||||
{
|
||||
m_bCdtConnected = true;
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CSingleConnectionServer::setDisconnected()
|
||||
{
|
||||
m_bCdtConnected = false;
|
||||
}
|
||||
|
||||
bool NSJSBase::v8_debug::internal::CSingleConnectionServer::checkStream()
|
||||
{
|
||||
if (!m_pWebsocketStream) {
|
||||
std::cerr << "no websocket stream when requested one" << std::endl;
|
||||
setDisconnected();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
NSJSBase::v8_debug::internal::CSingleConnectionServer::CSingleConnectionServer(uint16_t port
|
||||
, std::string host)
|
||||
//set up endpoint
|
||||
: m_Endpoint(
|
||||
ip::make_address(host)
|
||||
, port
|
||||
)
|
||||
|
||||
//constructs unopened acceptor
|
||||
, m_ConnectionAcceptor(
|
||||
m_io_context
|
||||
)
|
||||
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CSingleConnectionServer::setOnMessageCallback(
|
||||
onMessageCallback callback)
|
||||
{
|
||||
m_fOnMessage = std::move(callback);
|
||||
}
|
||||
|
||||
bool NSJSBase::v8_debug::internal::CSingleConnectionServer::waitForConnection()
|
||||
{
|
||||
//to check errors
|
||||
boost::beast::error_code errCode;
|
||||
//make socket on io context
|
||||
tcp::socket socket{m_io_context};
|
||||
//blocks until connected
|
||||
m_ConnectionAcceptor.accept(socket, errCode);
|
||||
//check for error
|
||||
if (errCode) {
|
||||
reportError(errCode, "while accepting connection");
|
||||
return false;
|
||||
}
|
||||
//set up websocket stream and delete old one if any
|
||||
m_pWebsocketStream.reset(new stream_t{
|
||||
//move local object to stream
|
||||
std::move(socket)
|
||||
}
|
||||
);
|
||||
//accept client handshake
|
||||
m_pWebsocketStream->accept(errCode);
|
||||
//check error
|
||||
if (errCode) {
|
||||
reportError(errCode, "while accepting client handshake");
|
||||
return false;
|
||||
}
|
||||
//connection established
|
||||
setConnected();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NSJSBase::v8_debug::internal::CSingleConnectionServer::listen()
|
||||
{
|
||||
//
|
||||
boost::beast::error_code errCode;
|
||||
|
||||
//open acceptor with endpoint's protocol
|
||||
m_ConnectionAcceptor.open(m_Endpoint.protocol(), errCode);
|
||||
//check for error
|
||||
if (errCode) {
|
||||
reportError(errCode, "while opening acceptor");
|
||||
return false;
|
||||
}
|
||||
|
||||
//bind acceptor to endpoint
|
||||
m_ConnectionAcceptor.bind(m_Endpoint, errCode);
|
||||
//check for error
|
||||
if (errCode) {
|
||||
reportError(errCode, "while binding acceptor to endpoint");
|
||||
return false;
|
||||
}
|
||||
|
||||
//listen
|
||||
m_ConnectionAcceptor.listen(
|
||||
1//max amount of pending connections
|
||||
, errCode);
|
||||
//check for error
|
||||
if (errCode) {
|
||||
reportError(errCode, "while attempting to listen");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_bListening = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
//blocks
|
||||
void NSJSBase::v8_debug::internal::CSingleConnectionServer::run(onResumeCallback beforeRun)
|
||||
{
|
||||
//resume stuff
|
||||
m_bPaused = false;
|
||||
if (beforeRun) {
|
||||
beforeRun();
|
||||
}
|
||||
|
||||
while (!m_bPaused) {
|
||||
if (!waitAndProcessMessage()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CSingleConnectionServer::sendData(const std::string &data)
|
||||
{
|
||||
//check stream
|
||||
if (!checkStream()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//no need to check for pause
|
||||
|
||||
//write data to buffer
|
||||
beast::multi_buffer buffer;
|
||||
beast::ostream(buffer) << data;
|
||||
|
||||
//text or binary mode as already set
|
||||
boost::beast::error_code errCode;
|
||||
m_pWebsocketStream->write(buffer.data(), errCode);
|
||||
if (errCode) {
|
||||
reportError(errCode, "while sending data");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool NSJSBase::v8_debug::internal::CSingleConnectionServer::waitAndProcessMessage()
|
||||
{
|
||||
//check stream
|
||||
if (!checkStream()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::pair<std::string, beast::error_code> result = getData();
|
||||
|
||||
if (!connected()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (result.second) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_fOnMessage){
|
||||
m_fOnMessage(result.first);
|
||||
}
|
||||
|
||||
//it won't work with check for pause
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NSJSBase::v8_debug::internal::CSingleConnectionServer::connected() const
|
||||
{
|
||||
return m_bCdtConnected;
|
||||
}
|
||||
|
||||
bool NSJSBase::v8_debug::internal::CSingleConnectionServer::listening() const
|
||||
{
|
||||
return m_bListening;
|
||||
}
|
||||
|
||||
bool NSJSBase::v8_debug::internal::CSingleConnectionServer::shutdown()
|
||||
{
|
||||
//check stream
|
||||
if (!checkStream()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
beast::error_code errCode;
|
||||
//send close frame
|
||||
m_pWebsocketStream->close(beast::websocket::close_code::normal, errCode);
|
||||
|
||||
if (errCode) {
|
||||
reportError(errCode, "while closing");
|
||||
return false;
|
||||
}
|
||||
|
||||
//discard pending messages until receiving close frame
|
||||
while (true) {
|
||||
//read and get error_code
|
||||
errCode = discardData();
|
||||
|
||||
//close frame is delivered as closed error
|
||||
if (errCode == beast::websocket::error::closed) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//any other errors
|
||||
if (errCode) {
|
||||
reportError(errCode, "while waiting for close responce at close");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::CSingleConnectionServer::pause()
|
||||
{
|
||||
m_bPaused = true;
|
||||
}
|
||||
|
||||
uint16_t NSJSBase::v8_debug::internal::CSingleConnectionServer::port() const
|
||||
{
|
||||
return m_Endpoint.port();
|
||||
}
|
||||
@ -1,85 +0,0 @@
|
||||
#ifndef SINGLECONNECTIONSERVER_H
|
||||
#define SINGLECONNECTIONSERVER_H
|
||||
|
||||
//boost stuff
|
||||
#include <boost/beast/core.hpp>
|
||||
#include <boost/beast/websocket.hpp>
|
||||
#include <boost/asio/strand.hpp>
|
||||
|
||||
#include <functional>//std::function
|
||||
#include <atomic>//std::atomic for thread-safe flags
|
||||
|
||||
namespace NSJSBase {
|
||||
namespace v8_debug {
|
||||
namespace internal {
|
||||
|
||||
class CSingleConnectionServer
|
||||
{
|
||||
public:
|
||||
using onMessageCallback = std::function<void(const std::string &message)>;
|
||||
using onResumeCallback = std::function<void()>;//not used, for any case
|
||||
|
||||
private:
|
||||
//tcp is a class
|
||||
using tcp = boost::asio::ip::tcp;
|
||||
//
|
||||
using stream_t = boost::beast::websocket::stream<
|
||||
tcp::socket
|
||||
>;
|
||||
|
||||
//boost stuff
|
||||
//required for all io operations
|
||||
boost::asio::io_context m_io_context{
|
||||
1//use only one thread
|
||||
};
|
||||
//tcp endpoint
|
||||
boost::asio::ip::tcp::endpoint m_Endpoint;
|
||||
//connection acceptor
|
||||
boost::asio::ip::tcp::acceptor m_ConnectionAcceptor;
|
||||
//using pointer to be able to create stream on connection, not in ctor
|
||||
std::unique_ptr<stream_t> m_pWebsocketStream{nullptr};
|
||||
|
||||
//message handler
|
||||
onMessageCallback m_fOnMessage{};
|
||||
|
||||
//flags
|
||||
std::atomic<bool> m_bCdtConnected{false};//используется для выхода из цикла после закрытия chrome dev tools
|
||||
std::atomic<bool> m_bListening{false};//слушает ли сервак входящие соединения
|
||||
std::atomic<bool> m_bPaused{false};//пауза
|
||||
|
||||
|
||||
|
||||
//private api
|
||||
//read data(blocks)
|
||||
std::pair<std::string, boost::beast::error_code> getData();
|
||||
boost::beast::error_code discardData();
|
||||
//report error
|
||||
void reportError(const boost::beast::error_code &code, const char *context) const;
|
||||
//
|
||||
void setConnected();
|
||||
void setDisconnected();
|
||||
//
|
||||
bool checkStream();
|
||||
|
||||
public:
|
||||
CSingleConnectionServer(uint16_t port = 8080, std::string host = "127.0.0.1");
|
||||
|
||||
void setOnMessageCallback(onMessageCallback callback);
|
||||
|
||||
bool waitForConnection();
|
||||
bool listen();
|
||||
void run(onResumeCallback beforeRun = onResumeCallback{});
|
||||
void sendData(const std::string &data);
|
||||
bool waitAndProcessMessage();
|
||||
bool connected() const;
|
||||
bool listening() const;
|
||||
bool shutdown();
|
||||
void pause();
|
||||
uint16_t port() const;
|
||||
};
|
||||
|
||||
}//namespace internal
|
||||
}//namespace v8_debug
|
||||
}//namespace NSJSBase
|
||||
|
||||
#endif // SINGLECONNECTIONSERVER_H
|
||||
@ -1,205 +0,0 @@
|
||||
#include "singlethreadutils.h"
|
||||
#include <iostream>//logging
|
||||
#include <fstream>//get file data
|
||||
#include <sstream>//string stream in getContents
|
||||
|
||||
//#define V8_DEBUG_MULTITHREADED
|
||||
|
||||
#ifdef V8_DEBUG_MULTITHREADED
|
||||
|
||||
#define LOCK_AND_ENTER_ISOLATE(isolate_ptr) \
|
||||
v8::Locker aasdufasidhfajskfjadhfk_lock_isolate_by_current_thread(isolate_ptr); \
|
||||
v8::Isolate::Scope aasdufasidhfajskfjadhfk_enter_isolate_scope(isolate_ptr);
|
||||
|
||||
#define LOCK_AND_ENTER_ISOLATE_BY_CONTEXT(context) \
|
||||
v8::Isolate *asdfdsfduf_isolate_ptr = context->GetIsolate(); \
|
||||
LOCK_AND_ENTER_ISOLATE(asdfdsfduf_isolate_ptr)
|
||||
|
||||
#else
|
||||
|
||||
#define LOCK_AND_ENTER_ISOLATE(isolate_ptr)
|
||||
#define LOCK_AND_ENTER_ISOLATE_BY_CONTEXT(context)
|
||||
|
||||
#endif
|
||||
|
||||
std::string NSJSBase::v8_debug::internal::getContents(std::istream &in)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << in.rdbuf();
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string NSJSBase::v8_debug::internal::getFileData(const std::string &filename)
|
||||
{
|
||||
std::ifstream f(filename);
|
||||
return getContents(f);
|
||||
}
|
||||
|
||||
v8_inspector::StringView NSJSBase::v8_debug::internal::strToView(const std::string &str) {
|
||||
const uint8_t *data = reinterpret_cast<const uint8_t*>(str.c_str());
|
||||
std::size_t len = str.length();
|
||||
return v8_inspector::StringView{data, len};
|
||||
}
|
||||
|
||||
std::string NSJSBase::v8_debug::internal::viewToStr(v8::Isolate *isolate
|
||||
, const v8_inspector::StringView &view)
|
||||
{
|
||||
LOCK_AND_ENTER_ISOLATE(isolate);
|
||||
|
||||
v8::Local<v8::String> v8str = viewTov8str(isolate, view);
|
||||
v8::String::Utf8Value utf8(v8str);
|
||||
return std::string(*utf8);
|
||||
}
|
||||
|
||||
v8::Local<v8::Object> NSJSBase::v8_debug::internal::parseJsonImpl(v8::Local<v8::Context> context
|
||||
, v8::Local<v8::String> v8str)
|
||||
{
|
||||
v8::Local<v8::Value> value = v8::JSON::Parse(context, v8str).ToLocalChecked();
|
||||
v8::MaybeLocal<v8::Object> obj = value->ToObject(context);
|
||||
if (obj.IsEmpty()) {
|
||||
v8::Local<v8::Object>();
|
||||
}
|
||||
return
|
||||
obj.ToLocalChecked()
|
||||
;
|
||||
}
|
||||
|
||||
v8::Local<v8::String> NSJSBase::v8_debug::internal::tov8str(v8::Isolate *isolate
|
||||
, const std::string &str)
|
||||
{
|
||||
LOCK_AND_ENTER_ISOLATE(isolate);
|
||||
|
||||
return v8::String::NewFromUtf8(isolate
|
||||
, str.c_str()
|
||||
, v8::NewStringType::kNormal
|
||||
, str.length())
|
||||
.ToLocalChecked();
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> NSJSBase::v8_debug::internal::getJsonPropertyImpl(v8::Local<v8::Context> context
|
||||
, v8::Local<v8::Object> jsonObject
|
||||
, const std::string &property)
|
||||
{
|
||||
LOCK_AND_ENTER_ISOLATE_BY_CONTEXT(context);
|
||||
|
||||
v8::Local<v8::Value> name = v8::String::NewFromUtf8(
|
||||
context->GetIsolate()
|
||||
, property.c_str()
|
||||
, v8::NewStringType::kNormal
|
||||
, property.length())
|
||||
.ToLocalChecked();
|
||||
v8::MaybeLocal<v8::Value> maybeProperty = jsonObject->Get(context, name);
|
||||
if (maybeProperty.IsEmpty()) {
|
||||
return v8::Local<v8::Value>();
|
||||
}
|
||||
return maybeProperty.ToLocalChecked();
|
||||
}
|
||||
|
||||
std::string NSJSBase::v8_debug::internal::getMethod(v8::Local<v8::Context> context
|
||||
, const std::string &json)
|
||||
{
|
||||
return getMethodImpl(context, parseJson(context, json));
|
||||
}
|
||||
|
||||
std::string NSJSBase::v8_debug::internal::getMethod(v8::Local<v8::Context> context
|
||||
, const v8_inspector::StringView &view)
|
||||
{
|
||||
return getMethodImpl(context, parseJson(context, view));
|
||||
}
|
||||
|
||||
std::string NSJSBase::v8_debug::internal::getMethodImpl(v8::Local<v8::Context> context
|
||||
, v8::Local<v8::Object> jsonObj)
|
||||
{
|
||||
if (jsonObj.IsEmpty()) {
|
||||
return std::string();
|
||||
}
|
||||
return asString(getJsonPropertyImpl(context, jsonObj, "method"));
|
||||
}
|
||||
|
||||
v8::Local<v8::String> NSJSBase::v8_debug::internal::viewTov8str(v8::Isolate *isolate
|
||||
, const v8_inspector::StringView &view)
|
||||
{
|
||||
LOCK_AND_ENTER_ISOLATE(isolate);
|
||||
|
||||
return
|
||||
(
|
||||
view.is8Bit()
|
||||
?
|
||||
v8::String::NewFromOneByte
|
||||
(
|
||||
isolate
|
||||
, view.characters8()
|
||||
, v8::NewStringType::kNormal
|
||||
, view.length()
|
||||
)
|
||||
:
|
||||
v8::String::NewFromTwoByte
|
||||
(
|
||||
isolate
|
||||
, view.characters16()
|
||||
, v8::NewStringType::kNormal
|
||||
, view.length()
|
||||
)
|
||||
).ToLocalChecked();
|
||||
}
|
||||
|
||||
v8::Local<v8::Object> NSJSBase::v8_debug::internal::parseJson(v8::Local<v8::Context> context
|
||||
, const std::string &str)
|
||||
{
|
||||
LOCK_AND_ENTER_ISOLATE_BY_CONTEXT(context);
|
||||
|
||||
return parseJsonImpl(context, tov8str(context->GetIsolate(), str));
|
||||
}
|
||||
|
||||
v8::Local<v8::Object> NSJSBase::v8_debug::internal::parseJson(v8::Local<v8::Context> context
|
||||
, const v8_inspector::StringView &view)
|
||||
{
|
||||
LOCK_AND_ENTER_ISOLATE_BY_CONTEXT(context);
|
||||
|
||||
return parseJsonImpl(context, viewTov8str(context->GetIsolate(), view));
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::logWithPrefix(std::ostream &out
|
||||
, const std::string &prefix
|
||||
, const std::string &message)
|
||||
{
|
||||
out << prefix;
|
||||
static constexpr std::size_t bigLen = 10000;
|
||||
if (message.size() > bigLen) {
|
||||
out << "message of size " << message.size();
|
||||
}
|
||||
else {
|
||||
out << message;
|
||||
}
|
||||
out << std::endl;
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::logCdtMessage(std::ostream &out
|
||||
, const std::string &message)
|
||||
{
|
||||
logWithPrefix(out, "CDT: ", message);
|
||||
}
|
||||
|
||||
void NSJSBase::v8_debug::internal::logOutgoingMessage(std::ostream &out
|
||||
, const std::string &message)
|
||||
{
|
||||
logWithPrefix(out, "responce: ", message);
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> NSJSBase::v8_debug::internal::getJsonProperty(
|
||||
v8::Local<v8::Context> context
|
||||
, const std::string &json
|
||||
, const std::string &property)
|
||||
{
|
||||
v8::Local<v8::Object> jsonObject = parseJson(context, json);
|
||||
if (jsonObject.IsEmpty()) {
|
||||
return v8::Local<v8::Value>();
|
||||
}
|
||||
return getJsonPropertyImpl(context, jsonObject, property);
|
||||
}
|
||||
|
||||
std::string NSJSBase::v8_debug::internal::asString(v8::Local<v8::Value> value)
|
||||
{
|
||||
v8::String::Utf8Value utf8(value);
|
||||
return std::string(*utf8);
|
||||
}
|
||||
@ -1,71 +0,0 @@
|
||||
#ifndef SINGLETHREADUTILS_H
|
||||
#define SINGLETHREADUTILS_H
|
||||
|
||||
#include <v8-inspector.h>//v8 stuff
|
||||
#include <string>//std::string
|
||||
|
||||
namespace NSJSBase {
|
||||
namespace v8_debug {
|
||||
namespace internal {
|
||||
|
||||
//getting file data
|
||||
std::string getContents(std::istream &in);
|
||||
std::string getFileData(const std::string &filename);
|
||||
|
||||
//logging
|
||||
void logWithPrefix(std::ostream &out, const std::string &prefix, const std::string &message);
|
||||
void logCdtMessage(std::ostream &out, const std::string &message);
|
||||
void logOutgoingMessage(std::ostream &out, const std::string &message);
|
||||
|
||||
//conversion between different strings
|
||||
v8_inspector::StringView strToView(const std::string &str);
|
||||
std::string viewToStr(v8::Isolate *isolate
|
||||
, const v8_inspector::StringView &view);
|
||||
v8::Local<v8::String> tov8str(v8::Isolate *isolate
|
||||
, const std::string &str);
|
||||
v8::Local<v8::String> viewTov8str(v8::Isolate *isolate
|
||||
, const v8_inspector::StringView &view);
|
||||
std::string asString(v8::Local<v8::Value> value);
|
||||
|
||||
|
||||
//get value of property |property| from json object
|
||||
v8::Local<v8::Value> getJsonProperty(v8::Local<v8::Context> context
|
||||
, const std::string &json
|
||||
, const std::string &property);
|
||||
v8::Local<v8::Value> getJsonPropertyImpl(
|
||||
v8::Local<v8::Context> context
|
||||
, v8::Local<v8::Object> jsonObject
|
||||
, const std::string &property
|
||||
);
|
||||
|
||||
//extract field "method" from json string
|
||||
std::string getMethodImpl(v8::Local<v8::Context> context
|
||||
, v8::Local<v8::Object> jsonObj);
|
||||
std::string getMethod(
|
||||
v8::Local<v8::Context> context
|
||||
, const std::string &json
|
||||
);
|
||||
std::string getMethod(
|
||||
v8::Local<v8::Context> context
|
||||
, const v8_inspector::StringView &view
|
||||
);
|
||||
|
||||
|
||||
//parse string and get json object
|
||||
v8::Local<v8::Object> parseJsonImpl(v8::Local<v8::Context> context
|
||||
, v8::Local<v8::String> v8str
|
||||
);
|
||||
v8::Local<v8::Object> parseJson(
|
||||
v8::Local<v8::Context> context
|
||||
, const std::string &str
|
||||
);
|
||||
v8::Local<v8::Object> parseJson(
|
||||
v8::Local<v8::Context> context
|
||||
, const v8_inspector::StringView &view
|
||||
);
|
||||
}//namespace internal
|
||||
}//namespace v8_debug
|
||||
}//namespace NSJSBase
|
||||
|
||||
|
||||
#endif // SINGLETHREADUTILS_H
|
||||
@ -0,0 +1,44 @@
|
||||
#include "utils.h"
|
||||
|
||||
#include "../v8_base.h"
|
||||
|
||||
namespace NSJSBase
|
||||
{
|
||||
|
||||
std::string convertToString(v8::Isolate* pIsolate, const v8_inspector::StringView oStringView)
|
||||
{
|
||||
int length = static_cast<int>(oStringView.length());
|
||||
v8::Local<v8::String> message =
|
||||
(
|
||||
oStringView.is8Bit()
|
||||
? v8::String::NewFromOneByte(pIsolate, reinterpret_cast<const uint8_t*>(oStringView.characters8()), v8::NewStringType::kNormal, length).ToLocalChecked()
|
||||
: v8::String::NewFromTwoByte(pIsolate, reinterpret_cast<const uint16_t*>(oStringView.characters16()), v8::NewStringType::kNormal, length).ToLocalChecked()
|
||||
);
|
||||
v8::String::Utf8Value result(V8IsolateFirstArg message);
|
||||
return *result;
|
||||
}
|
||||
|
||||
v8_inspector::StringView convertToStringView(const std::string& str)
|
||||
{
|
||||
const uint8_t* pStringView = reinterpret_cast<const uint8_t*>(str.c_str());
|
||||
return { pStringView, str.length() };
|
||||
}
|
||||
|
||||
v8::Local<v8::Object> parseJson(const v8::Local<v8::Context>& context, const std::string& sJson)
|
||||
{
|
||||
v8::MaybeLocal<v8::Value> jsonValue = v8::JSON::Parse(context, CreateV8String(context->GetIsolate(), sJson));
|
||||
if (jsonValue.IsEmpty())
|
||||
{
|
||||
return v8::Local<v8::Object>();
|
||||
}
|
||||
return jsonValue.ToLocalChecked()->ToObject(context).ToLocalChecked();
|
||||
}
|
||||
|
||||
std::string getPropertyFromJson(v8::Isolate* pIsolate, const v8::Local<v8::Object>& jsonObject, const std::string& sPropertyName)
|
||||
{
|
||||
v8::Local<v8::Value> property = jsonObject->Get(pIsolate->GetCurrentContext(), CreateV8String(pIsolate, sPropertyName)).ToLocalChecked();
|
||||
v8::String::Utf8Value utf8Value(V8IsolateFirstArg property);
|
||||
return *utf8Value;
|
||||
}
|
||||
|
||||
}
|
||||
22
DesktopEditor/doctrenderer/js_internal/v8/inspector/utils.h
Normal file
22
DesktopEditor/doctrenderer/js_internal/v8/inspector/utils.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
|
||||
#include <v8.h>
|
||||
#include <v8-inspector.h>
|
||||
#include <string>
|
||||
|
||||
namespace NSJSBase
|
||||
{
|
||||
|
||||
// convert v8_inspector::StringView to std::string
|
||||
std::string convertToString(v8::Isolate* pIsolate, const v8_inspector::StringView oStringView);
|
||||
// convert std::string to v8_inspector::StringView
|
||||
v8_inspector::StringView convertToStringView(const std::string& str);
|
||||
// get JSON object from JSON-string
|
||||
v8::Local<v8::Object> parseJson(const v8::Local<v8::Context>& context, const std::string& sJson);
|
||||
// get specified property value from JSON object
|
||||
std::string getPropertyFromJson(v8::Isolate* pIsolate, const v8::Local<v8::Object>& jsonObject, const std::string& sPropertyName);
|
||||
|
||||
}
|
||||
|
||||
#endif // UTILS_H
|
||||
@ -1,20 +0,0 @@
|
||||
CORE_BUILDS_PLATFORM_PREFIX = win_64
|
||||
BUILD_MODE=debug
|
||||
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
CONFIG -= qt
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../../../../core
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
ADD_DEPENDENCY(kernel, UnicodeConverter)
|
||||
|
||||
core_linux:include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri)
|
||||
|
||||
CONFIG += v8_use_inspector
|
||||
include($$CORE_ROOT_DIR/DesktopEditor/doctrenderer/js_internal/js_base.pri)
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/main.cpp
|
||||
@ -0,0 +1,31 @@
|
||||
#include <functional>
|
||||
#include "v8_inspector_channel.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace NSJSBase
|
||||
{
|
||||
|
||||
CV8InspectorChannelImpl::CV8InspectorChannelImpl(v8::Isolate* pIsolate, const std::function<void(std::string)>& fOnResponse)
|
||||
: m_pIsolate(pIsolate)
|
||||
, m_fOnResponce(fOnResponse)
|
||||
{
|
||||
}
|
||||
|
||||
void CV8InspectorChannelImpl::sendResponse(int nCallId, std::unique_ptr<v8_inspector::StringBuffer> pMessage)
|
||||
{
|
||||
const std::string response = convertToString(m_pIsolate, pMessage->string());
|
||||
m_fOnResponce(response);
|
||||
}
|
||||
|
||||
void CV8InspectorChannelImpl::sendNotification(std::unique_ptr<v8_inspector::StringBuffer> pMessage)
|
||||
{
|
||||
const std::string notification = convertToString(m_pIsolate, pMessage->string());
|
||||
m_fOnResponce(notification);
|
||||
}
|
||||
|
||||
void CV8InspectorChannelImpl::flushProtocolNotifications()
|
||||
{
|
||||
// does nothing
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
#ifndef V8_INSPECTOR_CHANNEL_IMPL_H
|
||||
#define V8_INSPECTOR_CHANNEL_IMPL_H
|
||||
|
||||
#include <functional>
|
||||
#include <v8.h>
|
||||
#include <v8-inspector.h>
|
||||
#include <string>
|
||||
|
||||
namespace NSJSBase
|
||||
{
|
||||
|
||||
class CV8InspectorChannelImpl final: public v8_inspector::V8Inspector::Channel
|
||||
{
|
||||
private:
|
||||
v8::Isolate* m_pIsolate;
|
||||
std::function<void(std::string)> m_fOnResponce;
|
||||
|
||||
public:
|
||||
CV8InspectorChannelImpl(v8::Isolate* pIsolate, const std::function<void(std::string)>& fOnResponse);
|
||||
|
||||
// overriden interface methods
|
||||
void sendResponse(int nCallId, std::unique_ptr<v8_inspector::StringBuffer> pMessage) override;
|
||||
void sendNotification(std::unique_ptr<v8_inspector::StringBuffer> pMessage) override;
|
||||
void flushProtocolNotifications() override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // V8_INSPECTOR_CHANNEL_IMPL_H
|
||||
@ -0,0 +1,73 @@
|
||||
#include "v8_inspector_client.h"
|
||||
|
||||
#include <libplatform/libplatform.h>
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
namespace NSJSBase
|
||||
{
|
||||
|
||||
CV8InspectorClientImpl::CV8InspectorClientImpl(
|
||||
v8::Platform* pPlatform,
|
||||
v8::Isolate* pIsolate,
|
||||
int nContextGroupId,
|
||||
const std::function<void(std::string)>& fOnResponse,
|
||||
const std::function<bool(void)>& fOnWaitFrontendMessageOnPause)
|
||||
: m_pPlatform(pPlatform)
|
||||
, m_pIsolate(pIsolate)
|
||||
, m_nContextGroupId(nContextGroupId)
|
||||
, m_fOnWaitFrontendMessageOnPause(std::move(fOnWaitFrontendMessageOnPause))
|
||||
{
|
||||
v8::Local<v8::Context> context = m_pIsolate->GetCurrentContext();
|
||||
// initialize all V8 inspector stuff
|
||||
m_pChannel.reset(new CV8InspectorChannelImpl(m_pIsolate, fOnResponse));
|
||||
m_pInspector = v8_inspector::V8Inspector::create(m_pIsolate, this);
|
||||
m_pSession = m_pInspector->connect(m_nContextGroupId, m_pChannel.get(), v8_inspector::StringView());
|
||||
context->SetAlignedPointerInEmbedderData(1, this);
|
||||
|
||||
v8_inspector::StringView oContextName = convertToStringView("inspector" + std::to_string(nContextGroupId));
|
||||
m_pInspector->contextCreated(v8_inspector::V8ContextInfo(context, m_nContextGroupId, oContextName));
|
||||
}
|
||||
|
||||
void CV8InspectorClientImpl::dispatchProtocolMessage(const v8_inspector::StringView& oMessage)
|
||||
{
|
||||
m_pSession->dispatchProtocolMessage(oMessage);
|
||||
}
|
||||
|
||||
void CV8InspectorClientImpl::runMessageLoopOnPause(int nContextGroupId)
|
||||
{
|
||||
if (m_bRunNestedLoop)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_bTerminated = false;
|
||||
m_bRunNestedLoop = true;
|
||||
while (!m_bTerminated && m_fOnWaitFrontendMessageOnPause())
|
||||
{
|
||||
while (v8::platform::PumpMessageLoop(m_pPlatform, m_pIsolate)) {}
|
||||
}
|
||||
m_bTerminated = true;
|
||||
m_bRunNestedLoop = false;
|
||||
}
|
||||
|
||||
void CV8InspectorClientImpl::quitMessageLoopOnPause()
|
||||
{
|
||||
m_bTerminated = true;
|
||||
}
|
||||
|
||||
v8::Local<v8::Context> CV8InspectorClientImpl::ensureDefaultContextInGroup(int nContextGroupId)
|
||||
{
|
||||
return m_pIsolate->GetCurrentContext();
|
||||
}
|
||||
|
||||
void CV8InspectorClientImpl::schedulePauseOnNextStatement(const v8_inspector::StringView& oReason)
|
||||
{
|
||||
m_pSession->schedulePauseOnNextStatement(oReason, {});
|
||||
}
|
||||
|
||||
void CV8InspectorClientImpl::waitFrontendMessageOnPause()
|
||||
{
|
||||
m_bTerminated = false;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
#ifndef V8_INSPECTOR_CLIENT_IMPL_H
|
||||
#define V8_INSPECTOR_CLIENT_IMPL_H
|
||||
|
||||
#include <v8.h>
|
||||
#include <v8-inspector.h>
|
||||
|
||||
#include "v8_inspector_channel.h"
|
||||
|
||||
namespace NSJSBase
|
||||
{
|
||||
|
||||
class CV8InspectorClientImpl final: public v8_inspector::V8InspectorClient
|
||||
{
|
||||
private:
|
||||
v8::Platform* m_pPlatform;
|
||||
// V8 Inspector stuff
|
||||
std::unique_ptr<v8_inspector::V8Inspector> m_pInspector;
|
||||
std::unique_ptr<v8_inspector::V8InspectorSession> m_pSession;
|
||||
std::unique_ptr<CV8InspectorChannelImpl> m_pChannel;
|
||||
// V8 isolate
|
||||
v8::Isolate* m_pIsolate;
|
||||
// context group id
|
||||
const int m_nContextGroupId;
|
||||
// callbacks
|
||||
std::function<bool(void)> m_fOnWaitFrontendMessageOnPause;
|
||||
// server message loop terminate flag
|
||||
bool m_bTerminated = false;
|
||||
// flag for preventing server from falling into two loops
|
||||
bool m_bRunNestedLoop = false;
|
||||
|
||||
private:
|
||||
v8::Local<v8::Context> ensureDefaultContextInGroup(int nContextGroupId) override;
|
||||
|
||||
public:
|
||||
CV8InspectorClientImpl(
|
||||
v8::Platform* pPlatform,
|
||||
v8::Isolate* pIsolate,
|
||||
int nContextGroupId,
|
||||
const std::function<void(std::string)>& fOnResponse,
|
||||
const std::function<bool(void)>& fOnWaitFrontendMessageOnPause);
|
||||
// send message to V8 internals
|
||||
void dispatchProtocolMessage(const v8_inspector::StringView& oMessage);
|
||||
// overriden interface methods
|
||||
void runMessageLoopOnPause(int nContextGroupId) override;
|
||||
void quitMessageLoopOnPause() override;
|
||||
// pause on next statement
|
||||
void schedulePauseOnNextStatement(const v8_inspector::StringView& oReason);
|
||||
// wait for message from frontend
|
||||
void waitFrontendMessageOnPause();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // V8_INSPECTOR_CLIENT_IMPL_H
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user