Compare commits
4 Commits
492815c8fc
...
1930f138d4
| Author | SHA1 | Date | |
|---|---|---|---|
|
1930f138d4
|
|||
|
32cbb15266
|
|||
|
149938cc44
|
|||
|
62f8a7d05f
|
@@ -2,6 +2,7 @@ cmake_minimum_required (VERSION 3.0...3.27)
|
|||||||
project (liberty C CXX)
|
project (liberty C CXX)
|
||||||
|
|
||||||
# Moar warnings
|
# Moar warnings
|
||||||
|
set (CMAKE_CXX_STANDARD 11)
|
||||||
if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUCC)
|
if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUCC)
|
||||||
# -Wunused-function is pretty annoying here, as everything is static
|
# -Wunused-function is pretty annoying here, as everything is static
|
||||||
set (wdisabled "-Wno-unused-function")
|
set (wdisabled "-Wno-unused-function")
|
||||||
@@ -104,6 +105,7 @@ else ()
|
|||||||
add_executable (test-lxdrgen-cpp tests/lxdrgen.cpp
|
add_executable (test-lxdrgen-cpp tests/lxdrgen.cpp
|
||||||
${lxdrgen_base}.cpp tools/lxdrgen-cpp-posix.cpp)
|
${lxdrgen_base}.cpp tools/lxdrgen-cpp-posix.cpp)
|
||||||
endif ()
|
endif ()
|
||||||
|
target_link_libraries (test-lxdrgen-cpp ${common_libraries})
|
||||||
target_include_directories (test-lxdrgen-cpp PUBLIC ${PROJECT_BINARY_DIR})
|
target_include_directories (test-lxdrgen-cpp PUBLIC ${PROJECT_BINARY_DIR})
|
||||||
add_test (NAME test-lxdrgen-cpp COMMAND test-lxdrgen-cpp)
|
add_test (NAME test-lxdrgen-cpp COMMAND test-lxdrgen-cpp)
|
||||||
|
|
||||||
|
|||||||
@@ -45,8 +45,9 @@ lxdrgen-c.awk::
|
|||||||
LibertyXDR backend that builds on top of the C pseudolibrary.
|
LibertyXDR backend that builds on top of the C pseudolibrary.
|
||||||
|
|
||||||
lxdrgen-cpp.awk::
|
lxdrgen-cpp.awk::
|
||||||
lxdrgen-cpp-win32.cpp::
|
|
||||||
lxdrgen-cpp-posix.cpp::
|
lxdrgen-cpp-posix.cpp::
|
||||||
|
lxdrgen-cpp-qt.cpp::
|
||||||
|
lxdrgen-cpp-win32.cpp::
|
||||||
LibertyXDR backend for C++, primarily targeting Win32 and its wide strings.
|
LibertyXDR backend for C++, primarily targeting Win32 and its wide strings.
|
||||||
Link the result together with one of the accompanied source files.
|
Link the result together with one of the accompanied source files.
|
||||||
|
|
||||||
|
|||||||
@@ -38,3 +38,47 @@ function (icon_for_win32 ico pngs pngs_raw)
|
|||||||
DEPENDS ${pngs} ${pngs_raw}
|
DEPENDS ${pngs} ${pngs_raw}
|
||||||
COMMENT "Generating Windows program icon" VERBATIM)
|
COMMENT "Generating Windows program icon" VERBATIM)
|
||||||
endfunction ()
|
endfunction ()
|
||||||
|
|
||||||
|
function (icon_to_iconset_size name svg size iconset outputs)
|
||||||
|
math (EXPR _size2x "${size} * 2")
|
||||||
|
set (_dimensions "${size}x${size}")
|
||||||
|
set (_png1x "${iconset}/icon_${_dimensions}.png")
|
||||||
|
set (_png2x "${iconset}/icon_${_dimensions}@2x.png")
|
||||||
|
set (${outputs} "${_png1x};${_png2x}" PARENT_SCOPE)
|
||||||
|
|
||||||
|
set (_find_program_REQUIRE)
|
||||||
|
if (NOT ${CMAKE_VERSION} VERSION_LESS 3.18.0)
|
||||||
|
set (_find_program_REQUIRE REQUIRED)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
find_program (rsvg_convert_EXECUTABLE rsvg-convert ${_find_program_REQUIRE})
|
||||||
|
add_custom_command (OUTPUT "${_png1x}" "${_png2x}"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${iconset}"
|
||||||
|
COMMAND ${rsvg_convert_EXECUTABLE} "--output=${_png1x}"
|
||||||
|
"--width=${size}" "--height=${size}" -- "${svg}"
|
||||||
|
COMMAND ${rsvg_convert_EXECUTABLE} "--output=${_png2x}"
|
||||||
|
"--width=${_size2x}" "--height=${_size2x}" -- "${svg}"
|
||||||
|
DEPENDS "${svg}"
|
||||||
|
COMMENT "Generating ${name} ${_dimensions} icons" VERBATIM)
|
||||||
|
endfunction ()
|
||||||
|
function (icon_to_icns svg output_basename output)
|
||||||
|
get_filename_component (_name "${output_basename}" NAME_WE)
|
||||||
|
set (_iconset "${PROJECT_BINARY_DIR}/${_name}.iconset")
|
||||||
|
set (_icon "${PROJECT_BINARY_DIR}/${output_basename}")
|
||||||
|
set (${output} "${_icon}" PARENT_SCOPE)
|
||||||
|
|
||||||
|
set (_icon_png_list)
|
||||||
|
foreach (_icon_size 16 32 128 256 512)
|
||||||
|
icon_to_iconset_size ("${_name}" "${svg}"
|
||||||
|
"${_icon_size}" "${_iconset}" _icon_pngs)
|
||||||
|
list (APPEND _icon_png_list ${_icon_pngs})
|
||||||
|
endforeach ()
|
||||||
|
|
||||||
|
# XXX: This will not normally work from within Nix.
|
||||||
|
add_custom_command (OUTPUT "${_icon}"
|
||||||
|
COMMAND iconutil -c icns -o "${_icon}" "${_iconset}"
|
||||||
|
DEPENDS ${_icon_png_list}
|
||||||
|
COMMENT "Generating ${_name} icon" VERBATIM)
|
||||||
|
set_source_files_properties ("${_icon}" PROPERTIES
|
||||||
|
MACOSX_PACKAGE_LOCATION Resources)
|
||||||
|
endfunction ()
|
||||||
|
|||||||
@@ -4833,7 +4833,8 @@ config_item_write_kv_pair (struct config_writer *self,
|
|||||||
str_append_printf (self->output,
|
str_append_printf (self->output,
|
||||||
"%s# %s\n", indent, value->schema->comment);
|
"%s# %s\n", indent, value->schema->comment);
|
||||||
|
|
||||||
bool can_use_word = true;
|
char *end = NULL;
|
||||||
|
bool can_use_word = ((void) strtoll (key, &end, 10), end == key);
|
||||||
for (const char *p = key; *p; p++)
|
for (const char *p = key; *p; p++)
|
||||||
if (!config_tokenizer_is_word_char (*p))
|
if (!config_tokenizer_is_word_char (*p))
|
||||||
can_use_word = false;
|
can_use_word = false;
|
||||||
|
|||||||
@@ -647,7 +647,7 @@ static const struct config_schema g_config_test[] =
|
|||||||
.type = CONFIG_ITEM_INTEGER,
|
.type = CONFIG_ITEM_INTEGER,
|
||||||
.validate = test_config_validate_nonnegative,
|
.validate = test_config_validate_nonnegative,
|
||||||
.default_ = "1" },
|
.default_ = "1" },
|
||||||
{ .name = "foobar",
|
{ .name = "123",
|
||||||
.type = CONFIG_ITEM_STRING,
|
.type = CONFIG_ITEM_STRING,
|
||||||
.default_ = "\"qux\\x01`\" \"\"`a`" },
|
.default_ = "\"qux\\x01`\" \"\"`a`" },
|
||||||
{}
|
{}
|
||||||
@@ -676,10 +676,11 @@ test_config (void)
|
|||||||
config_item_destroy (invalid);
|
config_item_destroy (invalid);
|
||||||
|
|
||||||
hard_assert (!strcmp ("qux\001`a",
|
hard_assert (!strcmp ("qux\001`a",
|
||||||
config_item_get (config.root, "top.foobar", NULL)->value.string.str));
|
config_item_get (config.root, "top.123", NULL)->value.string.str));
|
||||||
|
|
||||||
struct str s = str_make ();
|
struct str s = str_make ();
|
||||||
config_item_write (config.root, true, &s);
|
config_item_write (config.root, true, &s);
|
||||||
|
print_debug ("%s", s.str);
|
||||||
struct config_item *parsed = config_item_parse (s.str, s.len, false, NULL);
|
struct config_item *parsed = config_item_parse (s.str, s.len, false, NULL);
|
||||||
hard_assert (parsed);
|
hard_assert (parsed);
|
||||||
config_item_destroy (parsed);
|
config_item_destroy (parsed);
|
||||||
|
|||||||
23
tools/lxdrgen-cpp-qt.cpp
Normal file
23
tools/lxdrgen-cpp-qt.cpp
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
// lxdrgen-cpp-qt.cpp: Qt support code for lxdrgen-cpp.awk.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2024, Přemysl Eric Janouch <p@janouch.name>
|
||||||
|
// SPDX-License-Identifier: 0BSD
|
||||||
|
#include <QString>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace LibertyXDR {
|
||||||
|
|
||||||
|
bool utf8_to_wstring(const uint8_t *utf8, size_t length, std::wstring &wide) {
|
||||||
|
QByteArrayView view(reinterpret_cast<const char *>(utf8), length);
|
||||||
|
if (!view.isValidUtf8())
|
||||||
|
return false;
|
||||||
|
wide = QString::fromUtf8(view).toStdWString();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wstring_to_utf8(const std::wstring &wide, std::string &utf8) {
|
||||||
|
utf8 = QString::fromStdWString(wide).toUtf8().toStdString();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace LibertyXDR
|
||||||
Reference in New Issue
Block a user