Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions builtin-functions/kphp-light/stdlib/vkext-functions.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

// ===== SUPPORTED =====

function vk_utf8_to_win ($text ::: string, $max_len ::: int = 0, $exit_on_error ::: bool = false) ::: string;

function vk_win_to_utf8 ($text ::: string, $escape ::: bool = true) ::: string;
Expand Down Expand Up @@ -36,7 +34,4 @@ function vk_stats_hll_unpack($hll ::: string) ::: string | false;

function vk_stats_hll_is_packed($hll ::: string) ::: bool;

// ===== UNSUPPORTED =====

/** @kphp-extern-func-info stub generation-required */
function vk_flex ($name ::: string, $case_name ::: string, $sex ::: int, $type ::: string, $lang_id ::: int = 0) ::: string;
11 changes: 8 additions & 3 deletions compiler/compiler-settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,16 @@ void CompilerSettings::init() {

#if defined(__APPLE__)
append_if_doesnt_contain(ld_flags.value_, system_installed_static_libs, "-l");
auto flex_prefix = kphp_src_path.value_ + "objs/flex/lib";
append_if_doesnt_contain(ld_flags.value_, vk::to_array({"vk-flex-data"}), flex_prefix, ".a");
if (!is_k2_mode) {
auto flex_prefix = kphp_src_path.value_ + "objs/flex/lib";
append_if_doesnt_contain(ld_flags.value_, vk::to_array({"vk-flex-data"}), flex_prefix, ".a");
}
system_installed_dynamic_libs.emplace_back("iconv");
#else
system_installed_static_libs.emplace_back("vk-flex-data");
if (!is_k2_mode) {
// In the case of K2, the vk-flex-data library is compiled into runtime-light
system_installed_static_libs.emplace_back("vk-flex-data");
}
append_if_doesnt_contain(ld_flags.value_, system_installed_static_libs, "-l:lib", ".a");
system_installed_dynamic_libs.emplace_back("rt");
#endif
Expand Down
5 changes: 5 additions & 0 deletions flex/flex.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ add_dependencies(flex-data-src-pic flex-data)
vk_add_library_no_pic(flex-data-src-no-pic OBJECT ${FLEX_SOURCES})
add_dependencies(flex-data-src-no-pic flex-data)

if (COMPILE_RUNTIME_LIGHT)
target_compile_options(flex-data-src-pic PUBLIC -stdlib=libc++ ${RUNTIME_LIGHT_VISIBILITY})
target_link_options(flex-data-src-pic PUBLIC -stdlib=libc++)
endif()

vk_add_library_pic(flex_data_shared-pic SHARED $<TARGET_OBJECTS:flex-data-src-pic>)
add_dependencies(flex_data_shared-pic flex-data-src-pic)

Expand Down
21 changes: 21 additions & 0 deletions runtime-common/stdlib/vkext/vkext-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
#include <array>
#include <cstdio>

#include "flex/flex.h"

#include "runtime-common/core/utils/kphp-assert-core.h"
#include "runtime-common/stdlib/string/string-context.h"

namespace {

constexpr std::array<int, 256> utf8_to_win_convert_0x400 = {
Expand Down Expand Up @@ -458,3 +463,19 @@ string f$vk_whitespace_pack(const string& str, bool html_opt) noexcept {
}
return buffered.result;
}

string f$vk_flex(const string& name, const string& case_name, int64_t sex, const string& type, int64_t lang_id) noexcept {
constexpr size_t ERROR_MSG_BUG_SIZE{1000};
std::array<char, ERROR_MSG_BUG_SIZE> error_msg_buffer{'\0'};

auto* static_buffer{StringLibContext::get().static_buf.get()};
std::string_view res = flex(std::string_view{name.c_str(), name.size()}, std::string_view{case_name.c_str(), case_name.size()}, sex == 1,
std::string_view{type.c_str(), type.size()}, lang_id, static_buffer, error_msg_buffer.data(), ERROR_MSG_BUG_SIZE);
if (error_msg_buffer[0] != '\0') {
php_warning("%s", error_msg_buffer.data());
}
if (res.data() == name.c_str()) {
return name;
}
return string{res.data(), static_cast<string::size_type>(res.size())};
}
2 changes: 2 additions & 0 deletions runtime-common/stdlib/vkext/vkext-functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ inline string f$vk_sp_to_cyrillic(const string& s) noexcept {
inline string f$vk_sp_words_only(const string& s) noexcept {
return vkext_impl_::sp_words_only(s);
}

string f$vk_flex(const string& name, const string& case_name, int64_t sex, const string& type, int64_t lang_id = 0) noexcept;
2 changes: 1 addition & 1 deletion runtime-light/runtime-light.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ set(RUNTIME_LIGHT_LINK_LIBS "${KPHP_TIMELIB_PIC_LIBRARIES} ${PCRE2_PIC_LIBRARIES
vk_add_library_pic(kphp-light-runtime-pic STATIC)
target_compile_options(kphp-light-runtime-pic PUBLIC ${RUNTIME_LIGHT_COMPILE_FLAGS})
target_link_options(kphp-light-runtime-pic PUBLIC ${RUNTIME_LIGHT_LINK_FLAGS})
target_link_libraries(kphp-light-runtime-pic PUBLIC vk::pic::light-common vk::pic::unicode vk::pic::runtime-light vk::pic::runtime-common)
target_link_libraries(kphp-light-runtime-pic PUBLIC vk::pic::flex-data-src vk::pic::light-common vk::pic::unicode vk::pic::runtime-light vk::pic::runtime-common)

set_target_properties(kphp-light-runtime-pic PROPERTIES LIBRARY_OUTPUT_NAME libkphp-light-runtime.a)

Expand Down
2 changes: 1 addition & 1 deletion runtime/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <unistd.h>

#include "runtime-common/stdlib/serialization/json-functions.h"
#include "runtime-common/stdlib/vkext/vkext-functions.h"
#include "runtime/context/runtime-context.h"
#include "runtime/critical_section.h"
#include "runtime/datetime/datetime_functions.h"
Expand All @@ -20,7 +21,6 @@
#include "runtime/interface.h"
#include "runtime/math_functions.h"
#include "runtime/string_functions.h"
#include "runtime/vkext.h"
#include "server/json-logger.h"
#include "server/php-engine-vars.h"

Expand Down
1 change: 0 additions & 1 deletion runtime/runtime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ prepend(KPHP_RUNTIME_SOURCES ${BASE_DIR}/runtime/
uber-h3.cpp
udp.cpp
tcp.cpp
vkext.cpp
ffi.cpp
zlib.cpp
zstd.cpp)
Expand Down
27 changes: 0 additions & 27 deletions runtime/vkext.cpp

This file was deleted.

11 changes: 0 additions & 11 deletions runtime/vkext.h

This file was deleted.

2 changes: 1 addition & 1 deletion tests/cpp/runtime/flex-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <string>
#include <vector>

#include "runtime/vkext.h"
#include "runtime-common/stdlib/vkext/vkext-functions.h"

using casing_table = std::array<std::string, 6>;

Expand Down
2 changes: 1 addition & 1 deletion tests/phpt/dl/474_flex.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@ok k2_skip benchmark
@ok benchmark
<?php

$langs = array (0, 1, 2, 8, 11, 19, 21, 51, 52, 91, 100, 777, 888, 999);
Expand Down
Loading